diff options
1564 files changed, 5149 insertions, 59504 deletions
diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt index b36f2b1134..92e68060c6 100644 --- a/COPYRIGHT.txt +++ b/COPYRIGHT.txt @@ -43,7 +43,7 @@ Source: https://github.com/godotengine/godot Files: * Comment: Godot Engine Copyright: 2007-2017, Juan Linietsky, Ariel Manzur. - 2014-2017, Godot Engine contributors (cf. AUTHORS.md) + 2014-2017, Godot Engine contributors. License: Expat Files: ./icon.png @@ -51,7 +51,7 @@ Files: ./icon.png ./logo.png ./logo.svg Comment: Godot Engine logo -Copyright: Andrea Calabró +Copyright: 2017, Andrea Calabró License: CC-BY-3.0 Files: ./platform/android/android_native_app_glue.c @@ -92,7 +92,7 @@ Files: ./platform/android/power_android.cpp Comment: Simple DirectMedia Layer Copyright: 1997-2017, Sam Lantinga 2007-2017, Juan Linietsky, Ariel Manzur. - 2014-2017, Godot Engine contributors (cf. AUTHORS.md) + 2014-2017, Godot Engine contributors. License: Expat and Zlib Files: ./servers/physics/gjk_epa.cpp @@ -108,7 +108,7 @@ Files: ./servers/physics/gjk_epa.cpp Comment: Bullet Continuous Collision Detection and Physics Library Copyright: 2003-2008, Erwin Coumans 2007-2017, Juan Linietsky, Ariel Manzur. - 2014-2017, Godot Engine contributors (cf. AUTHORS.md) + 2014-2017, Godot Engine contributors. License: Expat and Zlib Files: ./servers/physics/joints/cone_twist_joint_sw.cpp @@ -116,7 +116,7 @@ Files: ./servers/physics/joints/cone_twist_joint_sw.cpp Comment: Bullet Continuous Collision Detection and Physics Library Copyright: 2007, Starbreeze Studios 2007-2017, Juan Linietsky, Ariel Manzur. - 2014-2017, Godot Engine contributors (cf. AUTHORS.md) + 2014-2017, Godot Engine contributors. License: Expat and Zlib Files: ./thirdparty/b2d_convexdecomp/ @@ -135,6 +135,11 @@ Comment: ENet Copyright: 2002-2016, Lee Salzman License: Expat +Files: ./thirdparty/etc2comp/ +Comment: Etc2Comp +Copyright: 2015, Etc2Comp Authors +License: Apache-2.0 + Files: ./thirdparty/fonts/DroidSans*.ttf Comment: DroidSans font Copyright: 2008, The Android Open Source Project @@ -147,7 +152,7 @@ License: OFL-1.1 Files: ./thirdparty/freetype/ Comment: The FreeType Project -Copyright: 1996-2016, David Turner, Robert Wilhelm, and Werner Lemberg. +Copyright: 1996-2017, David Turner, Robert Wilhelm, and Werner Lemberg. License: FTL Files: ./thirdparty/glad/ @@ -268,7 +273,7 @@ License: BSD-3-clause Files: ./thirdparty/misc/stb_truetype.h ./thirdparty/misc/stb_vorbis.c Comment: stb libraries -Copyright: 2007-2015, Sean Barrett +Copyright: 2007-2017, Sean Barrett License: public-domain Files: ./thirdparty/misc/triangulator.cpp @@ -295,6 +300,11 @@ Copyright: 2001-2011, Xiph.Org, Skype Limited, Octasic, Erik de Castro Lopo License: BSD-3-clause +Files: ./thirdparty/nanosvg/ +Comment: NanoSVG +Copyright: 2013-2014, Mikko Mononen +License: Zlib + Files: ./thirdparty/pvrtccompressor/ Comment: PvrTcCompressor Copyright: 2014, Jeffrey Lim. @@ -321,6 +331,11 @@ Comment: zlib Copyright: 1995-2017, Jean-loup Gailly and Mark Adler License: Zlib +Files: ./thirdparty/zstd/ +Comment: Zstandard +Copyright: 2016-2017, Facebook, Inc. +License: BSD-3-Clause + License: Apache-2.0 @@ -372,9 +387,9 @@ License: BSD-3-clause notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. . - 3. Neither the name of the University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. . THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE diff --git a/SConstruct b/SConstruct index 45765976cd..fee9786234 100644 --- a/SConstruct +++ b/SConstruct @@ -265,17 +265,17 @@ if selected_platform in platform_list: CCFLAGS = env.get('CCFLAGS', '') env['CCFLAGS'] = '' - env.Append(CCFLAGS=string.split(str(CCFLAGS))) + env.Append(CCFLAGS=str(CCFLAGS).split()) CFLAGS = env.get('CFLAGS', '') env['CFLAGS'] = '' - env.Append(CFLAGS=string.split(str(CFLAGS))) + env.Append(CFLAGS=str(CFLAGS).split()) LINKFLAGS = env.get('LINKFLAGS', '') env['LINKFLAGS'] = '' - env.Append(LINKFLAGS=string.split(str(LINKFLAGS))) + env.Append(LINKFLAGS=str(LINKFLAGS).split()) flag_list = platform_flags[selected_platform] for f in flag_list: diff --git a/compat.py b/compat.py new file mode 100644 index 0000000000..7338c479fb --- /dev/null +++ b/compat.py @@ -0,0 +1,31 @@ +import sys + +if sys.version_info < (3,): + def isbasestring(s): + return isinstance(s, basestring) + def open_utf8(filename, mode): + return open(filename, mode) + def byte_to_str(x): + return str(ord(x)) + import cStringIO + def StringIO(): + return cStringIO.StringIO() + def encode_utf8(x): + return x + def iteritems(d): + return d.iteritems() +else: + def isbasestring(s): + return isinstance(s, (str, bytes)) + def open_utf8(filename, mode): + return open(filename, mode, encoding="utf-8") + def byte_to_str(x): + return str(x) + import io + def StringIO(): + return io.StringIO() + import codecs + def encode_utf8(x): + return codecs.utf_8_encode(x)[0] + def iteritems(d): + return iter(d.items()) diff --git a/core/SCsub b/core/SCsub index 4c541d7269..c1e57f6840 100644 --- a/core/SCsub +++ b/core/SCsub @@ -18,7 +18,7 @@ gd_cpp = '#include "project_settings.h"\n' gd_cpp += gd_inc gd_cpp += "void ProjectSettings::register_global_defaults() {\n" + gd_call + "\n}\n" -f = open("global_defaults.gen.cpp", "wb") +f = open("global_defaults.gen.cpp", "w") f.write(gd_cpp) f.close() @@ -47,7 +47,7 @@ if ("SCRIPT_AES256_ENCRYPTION_KEY" in os.environ): txt = "0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0" print("Invalid AES256 encryption key, not 64 bits hex: " + e) -f = open("script_encryption_key.gen.cpp", "wb") +f = open("script_encryption_key.gen.cpp", "w") f.write("#include \"project_settings.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n") f.close() diff --git a/core/allocators.h b/core/allocators.h index 3735a7746e..0b891b76a9 100644 --- a/core/allocators.h +++ b/core/allocators.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/array.cpp b/core/array.cpp index 21dab2ba90..c35bf5bf0c 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/array.h b/core/array.h index 589d52886f..777116ab56 100644 --- a/core/array.h +++ b/core/array.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 7f4a83ed49..abe8b9b715 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index fc280bd7ef..1a3782c471 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/class_db.cpp b/core/class_db.cpp index cd55219b53..0d6c72afa8 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -600,9 +600,9 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName #ifdef DEBUG_METHODS_ENABLED String enum_name = p_enum; - if (enum_name!=String()) { - if (enum_name.find(".")!=-1) { - enum_name=enum_name.get_slicec('.',1); + if (enum_name != String()) { + if (enum_name.find(".") != -1) { + enum_name = enum_name.get_slicec('.', 1); } List<StringName> *constants_list = type->enum_map.getptr(enum_name); @@ -614,7 +614,6 @@ void ClassDB::bind_integer_constant(const StringName &p_class, const StringName new_list.push_back(p_name); type->enum_map[enum_name] = new_list; } - } type->constant_order.push_back(p_name); diff --git a/core/class_db.h b/core/class_db.h index 0943cd36cc..25a5000572 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -181,27 +181,6 @@ public: static void _add_class() { _add_class2(T::get_class_static(), T::get_parent_class_static()); -#if 0 - GLOBAL_LOCK_FUNCTION; - - StringName name = T::get_class_static(); - - ERR_FAIL_COND(types.has(name)); - - types[name]=TypeInfo(); - TypeInfo &ti=types[name]; - ti.name=name; - ti.inherits=T::get_parent_class_static(); - - if (ti.inherits) { - - ERR_FAIL_COND( !types.has(ti.inherits) ); //it MUST be registered. - ti.inherits_ptr = &types[ti.inherits]; - - } else { - ti.inherits_ptr=NULL; - } -#endif } template <class T> @@ -252,102 +231,6 @@ public: static uint64_t get_api_hash(APIType p_api); -#if 0 - template<class N, class M> - static MethodBind* bind_method(N p_method_name, M p_method, - //default arguments - ParamDef d1=ParamDef(), - ParamDef d2=ParamDef(), - ParamDef d3=ParamDef(), - ParamDef d4=ParamDef(), - ParamDef d5=ParamDef() - ) { - - return bind_methodf(METHOD_FLAGS_DEFAULT,p_method_name, p_method, d1,d2,d3,d4,d5); - } - - - - template<class N, class M> - static MethodBind* bind_methodf(uint32_t p_flags, N p_method_name, M p_method, - - - //default arguments - const ParamDef &d1=ParamDef(), - const ParamDef &d2=ParamDef(), - const ParamDef &d3=ParamDef(), - const ParamDef &d4=ParamDef(), - const ParamDef &d5=ParamDef() - ) { - - GLOBAL_LOCK_FUNCTION; - - MethodDefinition method_name=p_method_name; - - MethodBind *bind = create_method_bind(p_method); - bind->set_name(method_name.name); - ERR_FAIL_COND_V(!bind,NULL); - - String instance_type=bind->get_instance_type(); - - TypeInfo *type=types.getptr(instance_type); - if (!type) { - memdelete(bind); - ERR_FAIL_COND_V(!type,NULL); - } - - if (type->method_map.has(method_name.name)) { - memdelete(bind); - // overloading not supported - ERR_EXPLAIN("Method already bound: "+instance_type+"::"+method_name.name); - ERR_FAIL_V(NULL); - } - bind->set_argument_names(method_name.args); - type->method_map[method_name.name]=bind; - - Vector<Variant> defvals; - -#define PARSE_DEFVAL(m_defval) \ - if (d##m_defval.used) \ - defvals.insert(0, d##m_defval.val); \ - else \ - goto set_defvals; - - - PARSE_DEFVAL(1); - PARSE_DEFVAL(2); - PARSE_DEFVAL(3); - PARSE_DEFVAL(4); - PARSE_DEFVAL(5); - set_defvals: - - bind->set_default_arguments(defvals); - bind->set_hint_flags(p_flags); - - return bind; -#undef PARSE_DEFVAL - } -#else - -#if 0 - template<class N, class M> - static MethodBind* bind_method(N p_method_name, M p_method, - //default arguments - const ParamDef &d1=ParamDef(), - const ParamDef &d2=ParamDef(), - const ParamDef &d3=ParamDef(), - const ParamDef &d4=ParamDef(), - const ParamDef &d5=ParamDef() - ) { - - MethodDefinition method_name=p_method_name; - - MethodBind *bind = create_method_bind(p_method); - - return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,method_name,d1,d2,d3,d4,d5); //use static function, much smaller binary usage - } -#endif - template <class N, class M> static MethodBind *bind_method(N p_method_name, M p_method) { @@ -410,26 +293,6 @@ public: return bind_methodfi(METHOD_FLAGS_DEFAULT, bind, p_method_name, ptr, 6); } -#if 0 - template<class N, class M> - static MethodBind* bind_methodf(uint32_t p_flags, N p_method_name, M p_method, - - const ParamDef& d1=ParamDef(), - const ParamDef& d2=ParamDef(), - const ParamDef& d3=ParamDef(), - const ParamDef& d4=ParamDef(), - const ParamDef& d5=ParamDef() - ) { - - MethodDefinition method_name=p_method_name; - - MethodBind *bind = create_method_bind(p_method); - - return bind_methodfi(p_flags,bind,method_name,d1,d2,d3,d4,d5); //use static function, much smaller binary usage - } -#endif - -#endif template <class M> static MethodBind *bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method, const MethodInfo &p_info = MethodInfo(), const Vector<Variant> &p_default_args = Vector<Variant>()) { @@ -457,7 +320,8 @@ public: } type->method_map[p_name] = bind; #ifdef DEBUG_METHODS_ENABLED -// bind->set_return_type("Variant"); + // FIXME: <reduz> set_return_type is no longer in MethodBind, so I guess it should be moved to vararg method bind + //bind->set_return_type("Variant"); type->method_order.push_back(p_name); #endif diff --git a/core/color.cpp b/core/color.cpp index 22a5504431..356e8c168c 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/color.h b/core/color.h index 9074a0e6d6..6df114f2f2 100644 --- a/core/color.h +++ b/core/color.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp index c9edd1d47b..8e2aa24c22 100644 --- a/core/command_queue_mt.cpp +++ b/core/command_queue_mt.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index c3e44f731f..f99e16da15 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index 172249c5d7..74565d2e32 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/compressed_translation.h b/core/compressed_translation.h index c010491b3a..acccf95743 100644 --- a/core/compressed_translation.h +++ b/core/compressed_translation.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp index 2f5a684373..ef9346253f 100644 --- a/core/core_string_names.cpp +++ b/core/core_string_names.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/core_string_names.h b/core/core_string_names.h index 40f76aa9c0..2eb2b703ae 100644 --- a/core/core_string_names.h +++ b/core/core_string_names.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/dictionary.cpp b/core/dictionary.cpp index 1fe45aff94..bb2e892951 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -200,17 +200,6 @@ uint32_t Dictionary::hash() const { Array Dictionary::keys() const { -#if 0 - Array karr; - karr.resize(size()); - const Variant *K = NULL; - int idx = 0; - while ((K = next(K))) { - karr[idx++] = (*K); - } - return karr; -#else - Array varr; varr.resize(size()); if (_p->variant_map.empty()) @@ -228,7 +217,6 @@ Array Dictionary::keys() const { } return varr; -#endif } Array Dictionary::values() const { diff --git a/core/dictionary.h b/core/dictionary.h index 27caba916f..c8177d5648 100644 --- a/core/dictionary.h +++ b/core/dictionary.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/dvector.cpp b/core/dvector.cpp index 4bbe1aafd9..185cecd531 100644 --- a/core/dvector.cpp +++ b/core/dvector.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/dvector.h b/core/dvector.h index 66af42f7e2..1b81ceec5e 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/engine.cpp b/core/engine.cpp index c8218e47ac..d73693dc12 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/engine.h b/core/engine.h index c46ae1cb64..6f46ec8923 100644 --- a/core/engine.h +++ b/core/engine.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/error_list.h b/core/error_list.h index 14ef7bbc18..bc65ad0ee4 100644 --- a/core/error_list.h +++ b/core/error_list.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/error_macros.cpp b/core/error_macros.cpp index afbff6c52d..5919d38375 100644 --- a/core/error_macros.cpp +++ b/core/error_macros.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/error_macros.h b/core/error_macros.h index 6c803951a1..005b0e32a3 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/event_queue.cpp b/core/event_queue.cpp index c5257d5f6b..12f9942a07 100644 --- a/core/event_queue.cpp +++ b/core/event_queue.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/event_queue.h b/core/event_queue.h index a6c436909d..af1a760945 100644 --- a/core/event_queue.h +++ b/core/event_queue.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/func_ref.cpp b/core/func_ref.cpp index 5622a03665..d9a8f6bcdb 100644 --- a/core/func_ref.cpp +++ b/core/func_ref.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/func_ref.h b/core/func_ref.h index e60d5bd771..b9b1988ede 100644 --- a/core/func_ref.h +++ b/core/func_ref.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/global_constants.cpp b/core/global_constants.cpp index cd9a302ba6..224ee0e0aa 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/global_constants.h b/core/global_constants.h index ad639d0afa..350018e336 100644 --- a/core/global_constants.h +++ b/core/global_constants.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/hash_map.h b/core/hash_map.h index 2d7249e2fc..b22c6378b0 100644 --- a/core/hash_map.h +++ b/core/hash_map.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/hashfuncs.h b/core/hashfuncs.h index 8392984565..56d40f1dd7 100644 --- a/core/hashfuncs.h +++ b/core/hashfuncs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/helper/math_fieldwise.cpp b/core/helper/math_fieldwise.cpp index 5545c2d642..2ce2a70866 100644 --- a/core/helper/math_fieldwise.cpp +++ b/core/helper/math_fieldwise.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/helper/math_fieldwise.h b/core/helper/math_fieldwise.h index 58489fd3bb..4671703f41 100644 --- a/core/helper/math_fieldwise.h +++ b/core/helper/math_fieldwise.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/helper/value_evaluator.h b/core/helper/value_evaluator.h index e32697ca95..bb234de989 100644 --- a/core/helper/value_evaluator.h +++ b/core/helper/value_evaluator.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/image.cpp b/core/image.cpp index 0f09fbc0c1..bb1ce2cee3 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/image.h b/core/image.h index 2d61032896..27df65a898 100644 --- a/core/image.h +++ b/core/image.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/input_map.cpp b/core/input_map.cpp index 8435882325..82a2eaddae 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/input_map.h b/core/input_map.h index ba93e61f5f..18e6b04d4e 100644 --- a/core/input_map.h +++ b/core/input_map.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/int_types.h b/core/int_types.h index 973e0c749d..e9bcc88ee8 100644 --- a/core/int_types.h +++ b/core/int_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/compression.cpp b/core/io/compression.cpp index 139383710c..44fa65e11d 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/compression.h b/core/io/compression.h index 5eb7806d7b..22d8109d4f 100644 --- a/core/io/compression.h +++ b/core/io/compression.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index edd090adf2..daa6b01d6e 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/config_file.h b/core/io/config_file.h index 75a3a519a6..8ed8a069e4 100644 --- a/core/io/config_file.h +++ b/core/io/config_file.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_buffered.cpp b/core/io/file_access_buffered.cpp index 126ec7575e..859f2e3f8c 100644 --- a/core/io/file_access_buffered.cpp +++ b/core/io/file_access_buffered.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_buffered.h b/core/io/file_access_buffered.h index 0ad2d0e929..d3137058fb 100644 --- a/core/io/file_access_buffered.h +++ b/core/io/file_access_buffered.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_buffered_fa.h b/core/io/file_access_buffered_fa.h index 362589adf1..9e41834561 100644 --- a/core/io/file_access_buffered_fa.h +++ b/core/io/file_access_buffered_fa.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index 959a5dc86f..70430ca5d3 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h index 340c298a0f..2fe1428752 100644 --- a/core/io/file_access_compressed.h +++ b/core/io/file_access_compressed.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index f2b33a01bb..cf82d04ac5 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h index 2bd3c52661..3df2806a7a 100644 --- a/core/io/file_access_encrypted.h +++ b/core/io/file_access_encrypted.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 8e719568e5..5b186b7798 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_memory.h b/core/io/file_access_memory.h index ea858c547e..7feb16461b 100644 --- a/core/io/file_access_memory.h +++ b/core/io/file_access_memory.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index aa67479d7e..be31076557 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 1e85756122..d6010cdbac 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index c3bcfc840b..e36ff28220 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 25473131d6..758e9afa8e 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index d748d5c773..8c99ef2983 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/file_access_zip.h b/core/io/file_access_zip.h index c9cc2dac79..2a8ec3fca5 100644 --- a/core/io/file_access_zip.h +++ b/core/io/file_access_zip.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 1c35c6edeb..dd56db9bf9 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/http_client.h b/core/io/http_client.h index cc5f1ed935..023370ae81 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 7b5b4a13ea..637b95ccf8 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/image_loader.h b/core/io/image_loader.h index f79d9789bf..17a89603fa 100644 --- a/core/io/image_loader.h +++ b/core/io/image_loader.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 0e2b5ed519..60a44b2128 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/ip.h b/core/io/ip.h index 66a4a48da2..04c6811792 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp index ea3041945c..da74f6c116 100644 --- a/core/io/ip_address.cpp +++ b/core/io/ip_address.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/ip_address.h b/core/io/ip_address.h index da16622a9b..205efd9a0e 100644 --- a/core/io/ip_address.h +++ b/core/io/ip_address.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/json.cpp b/core/io/json.cpp index d537061c5b..2e9170bc34 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/json.h b/core/io/json.h index 75df15a077..893a88e264 100644 --- a/core/io/json.h +++ b/core/io/json.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 93002e5446..af7db904e9 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/marshalls.h b/core/io/marshalls.h index 234ae3b183..5541e52a89 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp index 402526a52c..dea6fab350 100644 --- a/core/io/networked_multiplayer_peer.cpp +++ b/core/io/networked_multiplayer_peer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h index bd951912f9..efaea46b84 100644 --- a/core/io/networked_multiplayer_peer.h +++ b/core/io/networked_multiplayer_peer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index ca00b8b480..16c73c26e7 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h index 597119f7f4..b08d44ad8a 100644 --- a/core/io/packet_peer.h +++ b/core/io/packet_peer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp index d1729819a8..2773d2a5a3 100644 --- a/core/io/packet_peer_udp.cpp +++ b/core/io/packet_peer_udp.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h index 007b810b67..5a2b54774f 100644 --- a/core/io/packet_peer_udp.h +++ b/core/io/packet_peer_udp.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 28382ab419..f1f5b6f538 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/pck_packer.h b/core/io/pck_packer.h index ddfa093a6b..c0a6acd859 100644 --- a/core/io/pck_packer.h +++ b/core/io/pck_packer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 0977b03e2f..965d11e414 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1717,54 +1717,6 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant default: {} } } -#if 0 -Error ResourceFormatSaverBinary::_save_obj(const Object *p_object,SavedObject *so) { - - //use classic way - List<PropertyInfo> property_list; - p_object->get_property_list( &property_list ); - - for(List<PropertyInfo>::Element *E=property_list.front();E;E=E->next()) { - - if (skip_editor && E->get().name.begins_with("__editor")) - continue; - if (E->get().usage&PROPERTY_USAGE_STORAGE || (bundle_resources && E->get().usage&PROPERTY_USAGE_BUNDLE)) { - - SavedObject::SavedProperty sp; - sp.name_idx=get_string_index(E->get().name); - sp.value = p_object->get(E->get().name); - _find_resources(sp.value); - so->properties.push_back(sp); - } - } - - return OK; - -} - - - -Error ResourceFormatSaverBinary::save(const Object *p_object,const Variant &p_meta) { - - ERR_FAIL_COND_V(!f,ERR_UNCONFIGURED); - ERR_EXPLAIN("write_object should supply either an object, a meta, or both"); - ERR_FAIL_COND_V(!p_object && p_meta.get_type()==Variant::NIL, ERR_INVALID_PARAMETER); - - SavedObject *so = memnew( SavedObject ); - - if (p_object) - so->type=p_object->get_type(); - - _find_resources(p_meta); - so->meta=p_meta; - Error err = _save_obj(p_object,so); - ERR_FAIL_COND_V( err, ERR_INVALID_DATA ); - - saved_objects.push_back(so); - - return OK; -} -#endif void ResourceFormatSaverBinaryInstance::save_unicode_string(const String &p_string) { diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 1c66344e3e..1bd0d333c6 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp index 7033dbe5fb..5a4f29fe67 100644 --- a/core/io/resource_import.cpp +++ b/core/io/resource_import.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/resource_import.h b/core/io/resource_import.h index 67fd870178..bf0bf3987a 100644 --- a/core/io/resource_import.h +++ b/core/io/resource_import.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 5347cd6ee1..f0e804e2fa 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index e6687800d7..9e059c2977 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 314259b2e9..e6187c9e3c 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h index f7fbcc1fb8..3fdd00133a 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index 7042700d92..1006158003 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h index d0748a8c9e..1ee997c123 100644 --- a/core/io/stream_peer.h +++ b/core/io/stream_peer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp index 24f6473330..d1fe214343 100644 --- a/core/io/stream_peer_ssl.cpp +++ b/core/io/stream_peer_ssl.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/stream_peer_ssl.h b/core/io/stream_peer_ssl.h index a81ae24e4a..bcbbeb0d48 100644 --- a/core/io/stream_peer_ssl.h +++ b/core/io/stream_peer_ssl.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index ae5603aa31..0e047a8f32 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index 53c21a93fd..45c93c2d36 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp index 29a80ecc19..a4364fa17c 100644 --- a/core/io/tcp_server.cpp +++ b/core/io/tcp_server.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h index b4ff3246ad..a7276401e4 100644 --- a/core/io/tcp_server.h +++ b/core/io/tcp_server.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index 1a670b0ab0..353eabea45 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h index a731e4e0d6..a14238f1df 100644 --- a/core/io/translation_loader_po.h +++ b/core/io/translation_loader_po.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index d8b69b0951..62110bfe24 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h index 297211ecc6..28c57b567f 100644 --- a/core/io/xml_parser.h +++ b/core/io/xml_parser.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/io/zip_io.h b/core/io/zip_io.h index 88e680c0e0..8cf971ee08 100644 --- a/core/io/zip_io.h +++ b/core/io/zip_io.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/list.h b/core/list.h index df69b1dc40..0cad6038ff 100644 --- a/core/list.h +++ b/core/list.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/map.h b/core/map.h index ef0f75fc9b..75a38a3440 100644 --- a/core/map.h +++ b/core/map.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 04e4383f03..21516ac768 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/a_star.h b/core/math/a_star.h index ebf1407c17..d2d2166719 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/audio_frame.cpp b/core/math/audio_frame.cpp index 30a50c8add..555d3536df 100644 --- a/core/math/audio_frame.cpp +++ b/core/math/audio_frame.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/audio_frame.h b/core/math/audio_frame.h index d54f622197..cfc7331767 100644 --- a/core/math/audio_frame.h +++ b/core/math/audio_frame.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp index e22bc2b05e..be950568cf 100644 --- a/core/math/bsp_tree.cpp +++ b/core/math/bsp_tree.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h index 8296e57943..2e762ba4de 100644 --- a/core/math/bsp_tree.h +++ b/core/math/bsp_tree.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index a1666ccd8b..0512cdd798 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -180,19 +180,7 @@ void CameraMatrix::set_orthogonal(real_t p_size, real_t p_aspect, real_t p_znear } void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, real_t p_top, real_t p_near, real_t p_far) { -#if 0 - ///@TODO, give a check to this. I'm not sure if it's working. - set_identity(); - matrix[0][0]=(2*p_near) / (p_right-p_left); - matrix[0][2]=(p_right+p_left) / (p_right-p_left); - matrix[1][1]=(2*p_near) / (p_top-p_bottom); - matrix[1][2]=(p_top+p_bottom) / (p_top-p_bottom); - matrix[2][2]=-(p_far+p_near) / ( p_far-p_near); - matrix[2][3]=-(2*p_far*p_near) / (p_far-p_near); - matrix[3][2]=-1; - matrix[3][3]=0; -#else real_t *te = &matrix[0][0]; real_t x = 2 * p_near / (p_right - p_left); real_t y = 2 * p_near / (p_top - p_bottom); @@ -218,8 +206,6 @@ void CameraMatrix::set_frustum(real_t p_left, real_t p_right, real_t p_bottom, r te[13] = 0; te[14] = d; te[15] = 0; - -#endif } real_t CameraMatrix::get_z_far() const { diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index 4be8ffab8c..175d0cdb1b 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/face3.cpp b/core/math/face3.cpp index 0e292500bf..748faad28f 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/face3.h b/core/math/face3.h index 3d02ae4014..8e4a25fb7a 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index 9a5811244a..7c8fb6f17d 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/geometry.h b/core/math/geometry.h index 909d8164c3..cd069bd7a3 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -105,7 +105,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 1 + //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)) @@ -120,33 +120,6 @@ public: if (mub > 1) mub = 1; c1 = p1.linear_interpolate(p2, mua); c2 = q1.linear_interpolate(q2, mub); -#else - //this is broken do not use - 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) -#endif } 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_2d.cpp b/core/math/math_2d.cpp index 956cfe5258..c77fe96ff2 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -205,33 +205,6 @@ Vector2 Vector2::clamped(real_t p_len) const { return v; } -Vector2 Vector2::cubic_interpolate_soft(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const { -#if 0 - k[0] = ((*this) (vi[0] + 1, vi[1], vi[2])) - ((*this) (vi[0], - vi[1],vi[2])); //fk = a0 - k[1] = (((*this) (vi[0] + 1, vi[1], vi[2])) - ((*this) ((int) (v(0) - - 1), vi[1],vi[2])))*0.5; //dk = a1 - k[2] = (((*this) ((int) (v(0) + 2), vi[1], vi[2])) - ((*this) (vi[0], - vi[1],vi[2])))*0.5; //dk+1 - k[3] = k[0]*3 - k[1]*2 - k[2];//a2 - k[4] = k[1] + k[2] - k[0]*2;//a3 - - //ip = a3(t-tk)³ + a2(t-tk)² + a1(t-tk) + a0 - // - //a3 = dk + dk+1 - Dk - //a2 = 3Dk - 2dk - dk+1 - //a1 = dk - //a0 = fk - // - //dk = (fk+1 - fk-1)*0.5 - //Dk = (fk+1 - fk) - - real_t dk = -#endif - - return Vector2(); -} - Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const { Vector2 p0 = p_pre_a; diff --git a/core/math/math_2d.h b/core/math/math_2d.h index 6fea6c8adb..d215df8a43 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -113,7 +113,6 @@ struct Vector2 { _FORCE_INLINE_ static Vector2 linear_interpolate(const Vector2 &p_a, const Vector2 &p_b, real_t p_t); _FORCE_INLINE_ Vector2 linear_interpolate(const Vector2 &p_b, real_t p_t) const; Vector2 cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const; - Vector2 cubic_interpolate_soft(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const; Vector2 slide(const Vector2 &p_normal) const; Vector2 bounce(const Vector2 &p_normal) const; diff --git a/core/math/math_defs.h b/core/math/math_defs.h index 3d9eb63e11..904cbc1abc 100644 --- a/core/math/math_defs.h +++ b/core/math/math_defs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp index 9f5a9c193a..6fb688f16b 100644 --- a/core/math/math_funcs.cpp +++ b/core/math/math_funcs.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,16 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "math_funcs.h" + #include "core/os/os.h" pcg32_random_t Math::default_pcg = { 12047754176567800795ULL, PCG_DEFAULT_INC_64 }; #define PHI 0x9e3779b9 -#if 0 -static uint32_t Q[4096]; -#endif - // TODO: we should eventually expose pcg.inc too uint32_t Math::rand_from_seed(uint64_t *seed) { pcg32_random_t pcg = { *seed, PCG_DEFAULT_INC_64 }; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 2ce9a88622..9651e37f3e 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index ec82bd30d4..c7e2a8f307 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/matrix3.h b/core/math/matrix3.h index 74e6564578..be85c244bd 100644 --- a/core/math/matrix3.h +++ b/core/math/matrix3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/octree.h b/core/math/octree.h index 2e37056030..95a67943fd 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -851,28 +851,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) { ERR_FAIL_COND(!E); Element &e = E->get(); -#if 0 - - pass++; - if (!e.aabb.has_no_surface()) { - _remove_element(&e); - } - - e.aabb=p_aabb; - - if (!e.aabb.has_no_surface()) { - _ensure_valid_root(p_aabb); - - _insert_element(&e,root); - if (use_pairs) - _element_check_pairs(&e); - - } - - _optimize(); - -#else - bool old_has_surf = !e.aabb.has_no_surface(); bool new_has_surf = !p_aabb.has_no_surface(); @@ -979,7 +957,6 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) { } _optimize(); -#endif } template <class T, bool use_pairs, class AL> diff --git a/core/math/plane.cpp b/core/math/plane.cpp index 17928d07c3..08395ed07b 100644 --- a/core/math/plane.cpp +++ b/core/math/plane.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/plane.h b/core/math/plane.h index 73d584e553..559a735817 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/quat.cpp b/core/math/quat.cpp index 5984cdf657..cebc5b9522 100644 --- a/core/math/quat.cpp +++ b/core/math/quat.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -139,48 +139,6 @@ Quat Quat::inverse() const { Quat Quat::slerp(const Quat &q, const real_t &t) const { -#if 0 - - - Quat dst=q; - Quat src=*this; - - src.normalize(); - dst.normalize(); - - real_t cosine = dst.dot(src); - - if (cosine < 0 && true) { - cosine = -cosine; - dst = -dst; - } else { - dst = dst; - } - - if (Math::abs(cosine) < 1 - CMP_EPSILON) { - // Standard case (slerp) - real_t sine = Math::sqrt(1 - cosine*cosine); - real_t angle = Math::atan2(sine, cosine); - real_t inv_sine = 1.0 / sine; - real_t coeff_0 = Math::sin((1.0 - t) * angle) * inv_sine; - real_t coeff_1 = Math::sin(t * angle) * inv_sine; - Quat ret= src * coeff_0 + dst * coeff_1; - - return ret; - } else { - // There are two situations: - // 1. "rkP" and "q" are very close (cosine ~= +1), so we can do a linear - // interpolation safely. - // 2. "rkP" and "q" are almost invedste of each other (cosine ~= -1), there - // are an infinite number of possibilities interpolation. but we haven't - // have method to fix this case, so just use linear interpolation here. - Quat ret = src * (1.0 - t) + dst *t; - // taking the complement requires renormalisation - ret.normalize(); - return ret; - } -#else - Quat to1; real_t omega, cosom, sinom, scale0, scale1; @@ -221,7 +179,6 @@ Quat Quat::slerp(const Quat &q, const real_t &t) const { scale0 * y + scale1 * to1.y, scale0 * z + scale1 * to1.z, scale0 * w + scale1 * to1.w); -#endif } Quat Quat::slerpni(const Quat &q, const real_t &t) const { @@ -241,53 +198,6 @@ Quat Quat::slerpni(const Quat &q, const real_t &t) const { invFactor * from.y + newFactor * q.y, invFactor * from.z + newFactor * q.z, invFactor * from.w + newFactor * q.w); - -#if 0 - real_t to1[4]; - real_t omega, cosom, sinom, scale0, scale1; - - - // calc cosine - cosom = x * q.x + y * q.y + z * q.z - + w * q.w; - - - // adjust signs (if necessary) - if ( cosom <0.0 && false) { - cosom = -cosom;to1[0] = - q.x; - to1[1] = - q.y; - to1[2] = - q.z; - to1[3] = - q.w; - } else { - to1[0] = q.x; - to1[1] = q.y; - to1[2] = q.z; - to1[3] = q.w; - } - - - // calculate coefficients - - if ( (1.0 - cosom) > CMP_EPSILON ) { - // standard case (slerp) - omega = Math::acos(cosom); - sinom = Math::sin(omega); - scale0 = Math::sin((1.0 - t) * omega) / sinom; - scale1 = Math::sin(t * omega) / sinom; - } else { - // "from" and "to" quaternions are very close - // ... so we can do a linear interpolation - scale0 = 1.0 - t; - scale1 = t; - } - // calculate final values - return Quat( - scale0 * x + scale1 * to1[0], - scale0 * y + scale1 * to1[1], - scale0 * z + scale1 * to1[2], - scale0 * w + scale1 * to1[3] - ); -#endif } Quat Quat::cubic_slerp(const Quat &q, const Quat &prep, const Quat &postq, const real_t &t) const { diff --git a/core/math/quat.h b/core/math/quat.h index 0e378eb4e4..9668f8c7a3 100644 --- a/core/math/quat.h +++ b/core/math/quat.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index 54b97ac38c..e9a383df40 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h index 49600649e3..47ed22615b 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/rect3.cpp b/core/math/rect3.cpp index 973607f565..6f01000f61 100644 --- a/core/math/rect3.cpp +++ b/core/math/rect3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/rect3.h b/core/math/rect3.h index 4890a19d99..c3a2f5fbfb 100644 --- a/core/math/rect3.h +++ b/core/math/rect3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -189,8 +189,6 @@ Vector3 Rect3::get_endpoint(int p_point) const { bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const { -#if 1 - Vector3 half_extents = size * 0.5; Vector3 ofs = position + half_extents; @@ -206,42 +204,6 @@ bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) co } return true; -#else - //cache all points to check against! - // #warning should be easy to optimize, just use the same as when taking the support and use only that point - Vector3 points[8] = { - Vector3(position.x, position.y, position.z), - Vector3(position.x, position.y, position.z + size.z), - Vector3(position.x, position.y + size.y, position.z), - Vector3(position.x, position.y + size.y, position.z + size.z), - Vector3(position.x + size.x, position.y, position.z), - Vector3(position.x + size.x, position.y, position.z + size.z), - Vector3(position.x + size.x, position.y + size.y, position.z), - Vector3(position.x + size.x, position.y + size.y, position.z + size.z), - }; - - for (int i = 0; i < p_plane_count; i++) { //for each plane - - const Plane &plane = p_planes[i]; - bool all_points_over = true; - //test if it has all points over! - - for (int j = 0; j < 8; j++) { - - if (!plane.is_point_over(points[j])) { - - all_points_over = false; - break; - } - } - - if (all_points_over) { - - return false; - } - } - return true; -#endif } bool Rect3::has_point(const Vector3 &p_point) const { diff --git a/core/math/transform.cpp b/core/math/transform.cpp index 3a86fbfc6c..60df69a509 100644 --- a/core/math/transform.cpp +++ b/core/math/transform.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/transform.h b/core/math/transform.h index 48467f2ed7..566bf482a9 100644 --- a/core/math/transform.h +++ b/core/math/transform.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -154,8 +154,7 @@ _FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const { } _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const { -/* define vertices */ -#if 1 + /* define vertices */ Vector3 x = basis.get_axis(0) * p_aabb.size.x; Vector3 y = basis.get_axis(1) * p_aabb.size.y; Vector3 z = basis.get_axis(2) * p_aabb.size.z; @@ -171,31 +170,8 @@ _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const { new_aabb.expand_to(pos + y + z); new_aabb.expand_to(pos + x + y + z); return new_aabb; -#else - - Vector3 vertices[8] = { - Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z), - Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z), - Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z), - Vector3(p_aabb.position.x + p_aabb.size.x, p_aabb.position.y, p_aabb.position.z), - Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z + p_aabb.size.z), - Vector3(p_aabb.position.x, p_aabb.position.y + p_aabb.size.y, p_aabb.position.z), - Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z + p_aabb.size.z), - Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z) - }; - - AABB ret; - - ret.pos = xform(vertices[0]); - - for (int i = 1; i < 8; i++) { - - ret.expand_to(xform(vertices[i])); - } - - return ret; -#endif } + _FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const { /* define vertices */ @@ -222,4 +198,4 @@ _FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const { return ret; } -#endif +#endif // TRANSFORM_H diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 1df3c8c298..614104f698 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h index 166f10c577..2bf67fffcb 100644 --- a/core/math/triangle_mesh.h +++ b/core/math/triangle_mesh.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp index 4a5d0a078e..b20f2e06d5 100644 --- a/core/math/triangulate.cpp +++ b/core/math/triangulate.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/triangulate.h b/core/math/triangulate.h index 3f0ad00033..21e148249e 100644 --- a/core/math/triangulate.h +++ b/core/math/triangulate.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index efffacb36e..144234f4d1 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -125,51 +125,6 @@ Vector3 Vector3::cubic_interpolate(const Vector3 &p_b, const Vector3 &p_pre_a, c return out; } -#if 0 -Vector3 Vector3::cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,real_t p_t) const { - - Vector3 p0=p_pre_a; - Vector3 p1=*this; - Vector3 p2=p_b; - Vector3 p3=p_post_b; - - if (true) { - - real_t ab = p0.distance_to(p1); - real_t bc = p1.distance_to(p2); - real_t cd = p2.distance_to(p3); - - //if (ab>bc) { - if (ab>0) - p0 = p1+(p0-p1)*(bc/ab); - //} - - //if (cd>bc) { - if (cd>0) - p3 = p2+(p3-p2)*(bc/cd); - //} - } - - real_t t = p_t; - real_t t2 = t * t; - real_t t3 = t2 * t; - - Vector3 out; - out.x = 0.5 * ( ( 2.0 * p1.x ) + - ( -p0.x + p2.x ) * t + - ( 2.0 * p0.x - 5.0 * p1.x + 4 * p2.x - p3.x ) * t2 + - ( -p0.x + 3.0 * p1.x - 3.0 * p2.x + p3.x ) * t3 ); - out.y = 0.5 * ( ( 2.0 * p1.y ) + - ( -p0.y + p2.y ) * t + - ( 2.0 * p0.y - 5.0 * p1.y + 4 * p2.y - p3.y ) * t2 + - ( -p0.y + 3.0 * p1.y - 3.0 * p2.y + p3.y ) * t3 ); - out.z = 0.5 * ( ( 2.0 * p1.z ) + - ( -p0.z + p2.z ) * t + - ( 2.0 * p0.z - 5.0 * p1.z + 4 * p2.z - p3.z ) * t2 + - ( -p0.z + 3.0 * p1.z - 3.0 * p2.z + p3.z ) * t3 ); - return out; -} -#endif Vector3::operator String() const { return (rtos(x) + ", " + rtos(y) + ", " + rtos(z)); diff --git a/core/math/vector3.h b/core/math/vector3.h index c58a86fbdb..74c822fcd7 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/message_queue.cpp b/core/message_queue.cpp index 564069d8bb..040fb69805 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -240,47 +240,6 @@ void MessageQueue::statistics() { } } -bool MessageQueue::print() { -#if 0 - uint32_t read_pos=0; - while (read_pos < buffer_end ) { - Message *message = (Message*)&buffer[ read_pos ]; - - Object *target = ObjectDB::get_instance(message->instance_ID); - String cname; - String cfunc; - - if (target==NULL) { - //object was deleted - //WARN_PRINT("Object was deleted while awaiting a callback") - //should it print a warning? - } else if (message->notification>=0) { - - // messages don't expect a return value - cfunc="notification # "+itos(message->notification); - cname=target->get_type(); - - } else if (!message->target.empty()) { - - cfunc="property: "+message->target; - cname=target->get_type(); - - - } else if (message->target) { - - cfunc=String(message->target)+"()"; - cname=target->get_type(); - } - - - read_pos+=sizeof(Message); - if (message->type!=TYPE_NOTIFICATION) - read_pos+=sizeof(Variant)*message->args; - } -#endif - return false; -} - int MessageQueue::get_max_buffer_usage() const { return buffer_max_used; diff --git a/core/message_queue.h b/core/message_queue.h index 843ab17d94..193d2b6907 100644 --- a/core/message_queue.h +++ b/core/message_queue.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -33,6 +33,7 @@ #include "object.h" #include "os/mutex.h" #include "os/thread_safe.h" + class MessageQueue { _THREAD_SAFE_CLASS_ @@ -85,7 +86,6 @@ public: Error push_notification(Object *p_object, int p_notification); Error push_set(Object *p_object, const StringName &p_prop, const Variant &p_value); - bool print(); void statistics(); void flush(); diff --git a/core/method_bind.cpp b/core/method_bind.cpp index 660350b899..8cace0bbaa 100644 --- a/core/method_bind.cpp +++ b/core/method_bind.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/method_bind.h b/core/method_bind.h index 1f4c3ff66b..f6cae6f34d 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -252,28 +252,6 @@ public: _FORCE_INLINE_ int get_argument_count() const { return argument_count; }; -#if 0 - _FORCE_INLINE_ Variant call_safe(const Variant** p_args,int p_arg_count, Variant::CallError& r_error) { - - r_error.error=Variant::CallError::CALL_OK; - check_call( p_args, &errorarg ); - if (!err) - return call(p_object, VARIANT_ARG_PASS ); - - VARIANT_ARGPTRS - String errstr; - String methodname = get_instance_type()+"::"+name; - if (err==CALL_ERROR_ARGUMENT_TYPE) { - errstr="Invalid Argument to call: '"+methodname+"'. Cannot convert argument "+itos(errorarg+1)+" from "+Variant::get_type_name(get_argument_type(errorarg))+" to "+Variant::get_type_name(argptr[errorarg]->get_type())+"."; - } - if (err==CALL_ERROR_EXTRA_ARGUMENT) { - errstr="Invalid call. Member function '"+methodname+"' takes "+itos(get_argument_count())+" argument, but argument "+itos(errorarg+1)+" was received."; - } - - ERR_PRINT(errstr.ascii().get_data()); - return Variant(); - } -#endif virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Variant::CallError &r_error) = 0; #ifdef PTRCALL_ENABLED diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h index d8755fd98b..2875eb912f 100644 --- a/core/method_ptrcall.h +++ b/core/method_ptrcall.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/node_path.cpp b/core/node_path.cpp index ad2eae859d..15f950f605 100644 --- a/core/node_path.cpp +++ b/core/node_path.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/node_path.h b/core/node_path.h index 31446ab9b4..eb5b9eb6cf 100644 --- a/core/node_path.h +++ b/core/node_path.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/object.cpp b/core/object.cpp index cd084a0c4a..b220dc0563 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -342,35 +342,6 @@ void Object::get_valid_parents_static(List<String> *p_parents) { } void Object::_get_valid_parents_static(List<String> *p_parents) { } -#if 0 -//old style set, deprecated - -void Object::set(const String& p_name, const Variant& p_value) { - - _setv(p_name,p_value); - - /* - if (!_use_builtin_script()) - return; - */ - - bool success; - ClassDB::set_property(this,p_name,p_value,success); - if (success) { - return; - } - - if (p_name=="__meta__") { - metadata=p_value; - } else if (p_name=="script") { - set_script(p_value); - } else if (script_instance) { - script_instance->set(p_name,p_value); - } - - -} -#endif void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid) { @@ -489,34 +460,6 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const { } } -#if 0 -//old style get, deprecated -Variant Object::get(const String& p_name) const { - - Variant ret=_getv(p_name); - if (ret.get_type()!=Variant::NIL) - return ret; - - bool success; - ClassDB::get_property(const_cast<Object*>(this),p_name,ret,success); - if (success) { - return ret; - } - - if (p_name=="__meta__") - return metadata; - else if (p_name=="script") - return script; - - if (script_instance) { - return script_instance->get(p_name); - } - - return Variant(); - -} -#endif - void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) const { if (script_instance && p_reversed) { @@ -596,22 +539,6 @@ Variant Object::_call_deferred_bind(const Variant **p_args, int p_argcount, Vari return Variant(); } -#if 0 -Variant Object::_call_bind(const StringName& p_name, const Variant& p_arg1, const Variant& p_arg2, const Variant& p_arg3, const Variant& p_arg4) { - - ERR_FAIL_COND_V(p_argcount<1,Variant()); - - return call(p_name, p_arg1, p_arg2, p_arg3, p_arg4); -}; - - - - -void Object::_call_deferred_bind(const StringName& p_name, const Variant& p_arg1, const Variant& p_arg2, const Variant& p_arg3, const Variant& p_arg4) { - - call_deferred(p_name, p_arg1, p_arg2, p_arg3, p_arg4); -}; -#endif #ifdef DEBUG_ENABLED static bool _test_call_error(const StringName &p_func, const Variant::CallError &error) { @@ -764,54 +691,6 @@ Variant Object::callv(const StringName &p_method, const Array &p_args) { } Variant Object::call(const StringName &p_name, VARIANT_ARG_DECLARE) { -#if 0 - if (p_name==CoreStringNames::get_singleton()->_free) { -#ifdef DEBUG_ENABLED - if (cast_to<Reference>()) { - ERR_EXPLAIN("Can't 'free' a reference."); - ERR_FAIL_V(Variant()); - } -#endif - //must be here, must be before everything, - memdelete(this); - return Variant(); - } - - VARIANT_ARGPTRS; - - int argc=0; - for(int i=0;i<VARIANT_ARG_MAX;i++) { - if (argptr[i]->get_type()==Variant::NIL) - break; - argc++; - } - - Variant::CallError error; - - Variant ret; - - if (script_instance) { - ret = script_instance->call(p_name,argptr,argc,error); - if (_test_call_error(p_name,error)) - return ret; - } - - MethodBind *method=ClassDB::get_method(get_type_name(),p_name); - - if (method) { - - - Variant ret = method->call(this,argptr,argc,error); - if (_test_call_error(p_name,error)) - return ret; - - return ret; - } else { - - } - - return Variant(); -#else VARIANT_ARGPTRS; @@ -826,52 +705,9 @@ Variant Object::call(const StringName &p_name, VARIANT_ARG_DECLARE) { Variant ret = call(p_name, argptr, argc, error); return ret; - -#endif } void Object::call_multilevel(const StringName &p_name, VARIANT_ARG_DECLARE) { -#if 0 - if (p_name==CoreStringNames::get_singleton()->_free) { -#ifdef DEBUG_ENABLED - if (cast_to<Reference>()) { - ERR_EXPLAIN("Can't 'free' a reference."); - ERR_FAIL(); - return; - } -#endif - //must be here, must be before everything, - memdelete(this); - return; - } - - VARIANT_ARGPTRS; - - int argc=0; - for(int i=0;i<VARIANT_ARG_MAX;i++) { - if (argptr[i]->get_type()==Variant::NIL) - break; - argc++; - } - - Variant::CallError error; - - if (script_instance) { - script_instance->call(p_name,argptr,argc,error); - _test_call_error(p_name,error); - - } - - MethodBind *method=ClassDB::get_method(get_type_name(),p_name); - - if (method) { - - method->call(this,argptr,argc,error); - _test_call_error(p_name,error); - - } - -#else VARIANT_ARGPTRS; @@ -884,8 +720,6 @@ void Object::call_multilevel(const StringName &p_name, VARIANT_ARG_DECLARE) { //Variant::CallError error; call_multilevel(p_name, argptr, argc); - -#endif } Variant Object::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { @@ -1130,22 +964,6 @@ struct _ObjectSignalDisconnectData { StringName method; }; -#if 0 -void Object::_emit_signal(const StringName& p_name,const Array& p_pargs){ - - Variant args[VARIANT_ARG_MAX]; - - int count = p_pargs.size(); - - for(int i=0;i<count;i++) { - args[i]=p_pargs[i]; - } - - emit_signal(p_name,VARIANT_ARGS_FROM_ARRAY(args)); -} - -#endif - Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Variant::CallError &r_error) { r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; @@ -1314,21 +1132,7 @@ void Object::_add_user_signal(const String &p_name, const Array &p_args) { add_user_signal(mi); } -#if 0 -void Object::_emit_signal(const StringName& p_name,const Array& p_pargs){ - - Variant args[VARIANT_ARG_MAX]; - int count = p_pargs.size(); - - for(int i=0;i<count;i++) { - args[i]=p_pargs[i]; - } - - emit_signal(p_name,VARIANT_ARGS_FROM_ARRAY(args)); -} - -#endif Array Object::_get_signal_list() const { List<MethodInfo> signal_list; @@ -1342,6 +1146,7 @@ Array Object::_get_signal_list() const { return ret; } + Array Object::_get_signal_connection_list(const String &p_signal) const { List<Connection> conns; diff --git a/core/object.h b/core/object.h index 746450ef6a..8b13477480 100644 --- a/core/object.h +++ b/core/object.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/copymem.h b/core/os/copymem.h index 3ad2403f9c..789dce76e7 100644 --- a/core/os/copymem.h +++ b/core/os/copymem.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 391ae78c85..f24d6d16ca 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/dir_access.h b/core/os/dir_access.h index 4bee229555..6ad8b4c49b 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 9d1fefc925..b969b58bfb 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/file_access.h b/core/os/file_access.h index beed7551fb..8393f0530b 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/input.cpp b/core/os/input.cpp index 81ca31da25..65752662d7 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/input.h b/core/os/input.h index 6759c624e3..f98b97e647 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index c5f787b6c7..88037859aa 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,11 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "input_event.h" + #include "input_map.h" #include "os/keyboard.h" -/** - * - */ void InputEvent::set_id(uint32_t p_id) { id = p_id; @@ -99,25 +97,6 @@ bool InputEvent::is_action_type() const { return false; } -#if 0 -if (String(p_method) == "is_action" && p_argidx == 0) { - - List<PropertyInfo> pinfo; - ProjectSettings::get_singleton()->get_property_list(&pinfo); - - for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { - const PropertyInfo &pi = E->get(); - - if (!pi.name.begins_with("input/")) - continue; - - String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); - result.insert("\"" + name + "\""); - } - -} else -#endif - void InputEvent::_bind_methods() { ClassDB::bind_method(D_METHOD("set_id", "id"), &InputEvent::set_id); diff --git a/core/os/input_event.h b/core/os/input_event.h index 06d157b2b2..5dc0f91d5f 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index 9b3e376ea6..30e7d5e791 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/keyboard.h b/core/os/keyboard.h index 1ef26de183..509ff23a93 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index 6d07e2a39c..b146d370f1 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/main_loop.h b/core/os/main_loop.h index a0125ec13c..fd76d8454f 100644 --- a/core/os/main_loop.h +++ b/core/os/main_loop.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/memory.cpp b/core/os/memory.cpp index acc960acd9..74d5cbbea1 100644 --- a/core/os/memory.cpp +++ b/core/os/memory.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/memory.h b/core/os/memory.h index e1d7138ad5..f8b3da579b 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/mutex.cpp b/core/os/mutex.cpp index 134d313bdf..d3edc2c423 100644 --- a/core/os/mutex.cpp +++ b/core/os/mutex.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/mutex.h b/core/os/mutex.h index 80a30b0b26..9e353df33d 100644 --- a/core/os/mutex.h +++ b/core/os/mutex.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/os.cpp b/core/os/os.cpp index c49ab6f706..1292b7eeed 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/os.h b/core/os/os.h index 0fcf465655..258708eea2 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/power.h b/core/os/power.h index dbf4c75c59..59a091012e 100644 --- a/core/os/power.h +++ b/core/os/power.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/rw_lock.cpp b/core/os/rw_lock.cpp index 0427374de4..d0ad249afa 100644 --- a/core/os/rw_lock.cpp +++ b/core/os/rw_lock.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h index 253bd260ee..c13eb8147c 100644 --- a/core/os/rw_lock.h +++ b/core/os/rw_lock.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/semaphore.cpp b/core/os/semaphore.cpp index ce75186001..ea0a02ae22 100644 --- a/core/os/semaphore.cpp +++ b/core/os/semaphore.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/semaphore.h b/core/os/semaphore.h index f2be966979..c169e0212e 100644 --- a/core/os/semaphore.h +++ b/core/os/semaphore.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/shell.cpp b/core/os/shell.cpp index 9bf2d4466d..07e4924c38 100644 --- a/core/os/shell.cpp +++ b/core/os/shell.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/shell.h b/core/os/shell.h index 33044ee10e..7cb95dd5c8 100644 --- a/core/os/shell.h +++ b/core/os/shell.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread.cpp b/core/os/thread.cpp index bd565334c3..af8ae847dc 100644 --- a/core/os/thread.cpp +++ b/core/os/thread.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread.h b/core/os/thread.h index 1103f67ff2..697494708e 100644 --- a/core/os/thread.h +++ b/core/os/thread.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread_dummy.cpp b/core/os/thread_dummy.cpp index 88c111297d..39b5bdd9b8 100644 --- a/core/os/thread_dummy.cpp +++ b/core/os/thread_dummy.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h index 64941a71f8..56e7061eee 100644 --- a/core/os/thread_dummy.h +++ b/core/os/thread_dummy.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread_safe.cpp b/core/os/thread_safe.cpp index 486e072985..a49d412254 100644 --- a/core/os/thread_safe.cpp +++ b/core/os/thread_safe.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/os/thread_safe.h b/core/os/thread_safe.h index 0cecf33cc2..f9a1d0f62b 100644 --- a/core/os/thread_safe.h +++ b/core/os/thread_safe.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index eb4aeb758a..4040680c6d 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/packed_data_container.h b/core/packed_data_container.h index bab994fc94..e6a674d7ce 100644 --- a/core/packed_data_container.h +++ b/core/packed_data_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/pair.h b/core/pair.h index d517339ddf..f780c79c81 100644 --- a/core/pair.h +++ b/core/pair.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/path_remap.cpp b/core/path_remap.cpp index c5961213e8..d8fa2748bc 100644 --- a/core/path_remap.cpp +++ b/core/path_remap.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/path_remap.h b/core/path_remap.h index 95249c6334..04da4c1510 100644 --- a/core/path_remap.h +++ b/core/path_remap.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp index d563925f3b..c122d21545 100644 --- a/core/pool_allocator.cpp +++ b/core/pool_allocator.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/pool_allocator.h b/core/pool_allocator.h index f62e410e66..12de4d58e8 100644 --- a/core/pool_allocator.h +++ b/core/pool_allocator.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/print_string.cpp b/core/print_string.cpp index 4a4c8093ca..92a04cbf0b 100644 --- a/core/print_string.cpp +++ b/core/print_string.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/print_string.h b/core/print_string.h index c4cd610856..9f8420c31a 100644 --- a/core/print_string.h +++ b/core/print_string.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 4a1b35ea4a..ce1d7918db 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -733,46 +733,6 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust } return OK; - -#if 0 - Error err = file->open(dst_file,FileAccess::WRITE); - if (err) { - memdelete(file); - ERR_EXPLAIN("Couldn't save project.godot"); - ERR_FAIL_COND_V(err,err) - } - - - for(Map<String,List<String> >::Element *E=props.front();E;E=E->next()) { - - if (E!=props.front()) - file->store_string("\n"); - - if (E->key()!="") - file->store_string("["+E->key()+"]\n\n"); - for(List<String>::Element *F=E->get().front();F;F=F->next()) { - - String key = F->get(); - if (E->key()!="") - key=E->key()+"/"+key; - Variant value; - - if (p_custom.has(key)) - value=p_custom[key]; - else - value = get(key); - - file->store_string(F->get()+"="+_encode_variant(value)+"\n"); - - } - } - - file->close(); - memdelete(file); - - - return OK; -#endif } Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) { diff --git a/core/project_settings.h b/core/project_settings.h index cee3b3b5f3..5c8907c74e 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/ref_ptr.cpp b/core/ref_ptr.cpp index 7bd8523292..4a27b523fb 100644 --- a/core/ref_ptr.cpp +++ b/core/ref_ptr.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/ref_ptr.h b/core/ref_ptr.h index b76bbab7fa..bb98f0507a 100644 --- a/core/ref_ptr.h +++ b/core/ref_ptr.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/reference.cpp b/core/reference.cpp index 1380dbd56e..bb70628cbe 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -124,44 +124,3 @@ void WeakRef::_bind_methods() { ClassDB::bind_method(D_METHOD("get_ref"), &WeakRef::get_ref); } -#if 0 - -Reference * RefBase::get_reference_from_ref(const RefBase &p_base) { - - return p_base.get_reference(); -} -void RefBase::ref_inc(Reference *p_reference) { - - p_reference->refcount.ref(); -} -bool RefBase::ref_dec(Reference *p_reference) { - - bool ref = p_reference->refcount.unref(); - return ref; -} - -Reference *RefBase::first_ref(Reference *p_reference) { - - if (p_reference->refcount.ref()) { - - // this may fail in the scenario of two threads assigning the pointer for the FIRST TIME - // at the same time, which is never likely to happen (would be crazy to do) - // so don't do it. - - if (p_reference->refcount_init.get()>0) { - p_reference->refcount_init.unref(); - p_reference->refcount.unref(); // first referencing is already 1, so compensate for the ref above - } - - return p_reference; - } else { - - return 0; - } - -} -char * RefBase::get_refptr_data(const RefPtr &p_refptr) const { - - return p_refptr.data; -} -#endif diff --git a/core/reference.h b/core/reference.h index a8034a73c6..5fe8296314 100644 --- a/core/reference.h +++ b/core/reference.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -59,21 +59,6 @@ public: ~Reference(); }; -#if 0 -class RefBase { -protected: - void ref_inc(Reference *p_reference); - bool ref_dec(Reference *p_reference); - Reference *first_ref(Reference *p_reference); - Reference * get_reference_from_ref(const RefBase &p_base); - virtual Reference * get_reference() const=0; - char * get_refptr_data(const RefPtr &p_refptr) const; -public: - - virtual ~RefBase() {} -}; -#endif - template <class T> class Ref { @@ -151,20 +136,10 @@ public: return refptr; }; -#if 0 - // go to RefPtr - operator RefPtr() const { - - return get_ref_ptr(); - } -#endif - -#if 1 operator Variant() const { return Variant(get_ref_ptr()); } -#endif void operator=(const Ref &p_from) { diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index e5441093ac..27c31127a4 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/register_core_types.h b/core/register_core_types.h index 794c45dff0..cf84d70930 100644 --- a/core/register_core_types.h +++ b/core/register_core_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/resource.cpp b/core/resource.cpp index a0b0fd24e1..37d42226b4 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/resource.h b/core/resource.h index bbf233d53e..7dc3b67291 100644 --- a/core/resource.h +++ b/core/resource.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/rid.cpp b/core/rid.cpp index ca1d2be421..cb16715936 100644 --- a/core/rid.cpp +++ b/core/rid.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/rid.h b/core/rid.h index a93d7d912e..276375167e 100644 --- a/core/rid.h +++ b/core/rid.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/ring_buffer.h b/core/ring_buffer.h index 8b32bb5e10..6c882f1ef9 100644 --- a/core/ring_buffer.h +++ b/core/ring_buffer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/safe_refcount.cpp b/core/safe_refcount.cpp index 971e9ad1d5..c330a983a7 100644 --- a/core/safe_refcount.cpp +++ b/core/safe_refcount.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/safe_refcount.h b/core/safe_refcount.h index ed0620c777..802d84cccc 100644 --- a/core/safe_refcount.h +++ b/core/safe_refcount.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp index d2ccf495ae..c2632da38b 100644 --- a/core/script_debugger_local.cpp +++ b/core/script_debugger_local.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/script_debugger_local.h b/core/script_debugger_local.h index d32edb503b..097c7c41f3 100644 --- a/core/script_debugger_local.h +++ b/core/script_debugger_local.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 9e4f4380c9..8875732b8e 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index cf75c0eb4a..b1ef88b812 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/script_language.cpp b/core/script_language.cpp index 4664049145..9a891f9e52 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/script_language.h b/core/script_language.h index 5baf2e6f80..342d8c8072 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/self_list.h b/core/self_list.h index e229d5bf8e..053ab40162 100644 --- a/core/self_list.h +++ b/core/self_list.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/set.h b/core/set.h index 6e6f07508c..317e180869 100644 --- a/core/set.h +++ b/core/set.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/simple_type.h b/core/simple_type.h index b4a6dd1fa8..96e79966e0 100644 --- a/core/simple_type.h +++ b/core/simple_type.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/sort.h b/core/sort.h index 06c427f61e..a5e23f53df 100644 --- a/core/sort.h +++ b/core/sort.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/string_db.cpp b/core/string_db.cpp index c61fbba9b5..ef38491a6b 100644 --- a/core/string_db.cpp +++ b/core/string_db.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/string_db.h b/core/string_db.h index 18af9fb3a7..2bef29fab8 100644 --- a/core/string_db.h +++ b/core/string_db.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/translation.cpp b/core/translation.cpp index c38d5d8b4d..f1f9c72b85 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/translation.h b/core/translation.h index 8630b8a478..cf59583ad6 100644 --- a/core/translation.h +++ b/core/translation.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/typedefs.h b/core/typedefs.h index 34a1a93a3b..565e28020b 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/ucaps.h b/core/ucaps.h index cd4a581a49..f6c42f37d6 100644 --- a/core/ucaps.h +++ b/core/ucaps.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index 00a468816a..4760047959 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/undo_redo.h b/core/undo_redo.h index 5b79f957da..84133c4eea 100644 --- a/core/undo_redo.h +++ b/core/undo_redo.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/ustring.cpp b/core/ustring.cpp index 0521966943..ee07c7b11b 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1252,66 +1252,7 @@ String String::utf8(const char *p_utf8, int p_len) { return ret; }; -#if 0 -_FORCE_INLINE static int parse_utf8_char(const char *p_utf8,unsigned int *p_ucs4,int p_left) { //return len - - - int len=0; - -/* Determine the number of characters in sequence */ - if ((*p_utf8 & 0x80)==0) - len=1; - else if ((*p_utf8 & 0xE0)==0xC0) - len=2; - else if ((*p_utf8 & 0xF0)==0xE0) - len=3; - else if ((*p_utf8 & 0xF8)==0xF0) - len=4; - else if ((*p_utf8 & 0xFC)==0xF8) - len=5; - else if ((*p_utf8 & 0xFE)==0xFC) - len=6; - else - return -1; //invalid UTF8 - - if (len>p_left) - return -1; //not enough space - - if (len==2 && (*p_utf8&0x1E)==0) { - //printf("overlong rejected\n"); - return -1; //reject overlong - } - - /* Convert the first character */ - - unsigned int unichar=0; - - if (len == 1) - unichar=*p_utf8; - else { - - unichar=(0xFF >> (len +1)) & *p_utf8; - for (int i=1;i<len;i++) { - - if ((p_utf8[i] & 0xC0) != 0x80) { - //printf("invalid utf8\n"); - return -1; //invalid utf8 - } - if (unichar==0 && i==2 && ((p_utf8[i] & 0x7F) >> (7 - len)) == 0) { - //printf("no overlong\n"); - return -1; //no overlong - } - unichar = (unichar << 6) | (p_utf8[i] & 0x3F); - } - } - - *p_ucs4=unichar; - - return len; - -} -#endif bool String::parse_utf8(const char *p_utf8, int p_len) { #define _UNICERROR(m_err) print_line("unicode error: " + String(m_err)); @@ -1998,94 +1939,6 @@ double String::to_double(const char *p_str) { #else return built_in_strtod<char>(p_str); #endif -#if 0 -#if 0 - - - return atof(p_str); -#else - if (!p_str[0]) - return 0; -///@todo make more exact so saving and loading does not lose precision - - double integer=0; - double decimal=0; - double decimal_mult=0.1; - double sign=1.0; - double exp=0; - double exp_sign=1.0; - int reading=READING_SIGN; - - const char *str=p_str; - - while(*str && reading!=READING_DONE) { - - CharType c=*(str++); - switch(reading) { - case READING_SIGN: { - if (c>='0' && c<='9') - reading=READING_INT; - // let it fallthrough - else if (c=='-') { - sign=-1.0; - reading=READING_INT; - break; - } else if (c=='.') { - reading=READING_DEC; - break; - } else { - break; - } - } - case READING_INT: { - - if (c>='0' && c<='9') { - - integer*=10; - integer+=c-'0'; - } else if (c=='.') { - reading=READING_DEC; - } else if (c=='e') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_DEC: { - - if (c>='0' && c<='9') { - - decimal+=(c-'0')*decimal_mult; - decimal_mult*=0.1; - } else if (c=='e') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_EXP: { - - if (c>='0' && c<='9') { - - exp*=10.0; - exp+=(c-'0'); - } else if (c=='-' && exp==0) { - exp_sign=-1.0; - } else if (exp_sign>=0 && c=='+') { - //redundant... - exp_sign=1.0; - } else { - reading=READING_DONE; - } - } break; - } - } - - return sign*(integer+decimal)*Math::pow(10,exp_sign*exp); -#endif -#endif } float String::to_float() const { @@ -2096,100 +1949,6 @@ float String::to_float() const { double String::to_double(const CharType *p_str, const CharType **r_end) { return built_in_strtod<CharType>(p_str, (CharType **)r_end); -#if 0 -#if 0 - //ndef NO_USE_STDLIB - return wcstod(p_str,p_len<0?NULL:p_str+p_len); -#else - if (p_len==0 || !p_str[0]) - return 0; -///@todo make more exact so saving and loading does not lose precision - - double integer=0; - double decimal=0; - double decimal_mult=0.1; - double sign=1.0; - double exp=0; - double exp_sign=1.0; - int reading=READING_SIGN; - - const CharType *str=p_str; - const CharType *limit=&p_str[p_len]; - - while(reading!=READING_DONE && str!=limit) { - - CharType c=*(str++); - switch(reading) { - case READING_SIGN: { - if (c>='0' && c<='9') - reading=READING_INT; - // let it fallthrough - else if (c=='-') { - sign=-1.0; - reading=READING_INT; - break; - } else if (c=='.') { - reading=READING_DEC; - break; - } else if (c==0) { - reading=READING_DONE; - break; - } else { - break; - } - } - case READING_INT: { - - if (c>='0' && c<='9') { - - integer*=10; - integer+=c-'0'; - } else if (c=='.') { - reading=READING_DEC; - } else if (c=='e' || c=='E') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_DEC: { - - if (c>='0' && c<='9') { - - decimal+=(c-'0')*decimal_mult; - decimal_mult*=0.1; - } else if (c=='e' || c=='E') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_EXP: { - - if (c>='0' && c<='9') { - - exp*=10.0; - exp+=(c-'0'); - } else if (c=='-' && exp==0) { - exp_sign=-1.0; - } else if (exp_sign>=0 && c=='+') { - //redundant... - exp_sign=1.0; - } else { - reading=READING_DONE; - } - } break; - } - } - - if (r_end) - *r_end=str-1; - - return sign*(integer+decimal)*Math::pow(10,exp_sign*exp); -#endif -#endif } int64_t String::to_int(const CharType *p_str, int p_len) { @@ -2252,98 +2011,6 @@ double String::to_double() const { #else return built_in_strtod<CharType>(c_str()); #endif -#if 0 -#ifndef NO_USE_STDLIB - - return atof(utf8().get_data()); -#else - - double integer=0; - double decimal=0; - double decimal_mult=0.1; - double sign=1.0; - double exp=0; - double exp_sign=1.0; - int reading=READING_SIGN; - - const CharType *str=&operator[](0); - - while(*str && reading!=READING_DONE) { - - CharType c=*(str++); - switch(reading) { - case READING_SIGN: { - if (c>='0' && c<='9') - reading=READING_INT; - // let it fallthrough - else if (c=='-') { - sign=-1.0; - reading=READING_INT; - break; - } else if (c=='.') { - reading=READING_DEC; - break; - } else { - break; - } - } - case READING_INT: { - - if (c>='0' && c<='9') { - - integer*=10; - integer+=c-'0'; - } else if (c=='.') { - reading=READING_DEC; - } else if (c=='e') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_DEC: { - - if (c>='0' && c<='9') { - - decimal+=(c-'0')*decimal_mult; - decimal_mult*=0.1; - } else if (c=='e') { - reading=READING_EXP; - } else { - reading=READING_DONE; - } - - } break; - case READING_EXP: { - - if (c>='0' && c<='9') { - - exp*=10.0; - exp+=(c-'0'); - } else if (c=='-' && exp==0) { - exp_sign=-1.0; - } else if (exp_sign>=0 && c=='+') { - //redundant... - exp_sign=1.0; - } else { - reading=READING_DONE; - } - } break; - } - } - - return sign*(integer+decimal)*Math::pow(10,exp_sign*exp); -#endif -#if 0 - - - double ret=sign*(integer+decimal)*Math::pow(10,exp_sign*exp); - - print_line(*this +" == "+rtos(ret)); - return ret; -#endif -#endif } bool operator==(const char *p_chr, const String &p_str) { diff --git a/core/ustring.h b/core/ustring.h index 1c61e12e85..ab4e325f2c 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant.cpp b/core/variant.cpp index e6a69edd08..74f6b6a711 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant.h b/core/variant.h index 40de1a9bce..c44608ebfa 100644 --- a/core/variant.h +++ b/core/variant.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 59d31d2586..77372d1e60 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant_construct_string.cpp b/core/variant_construct_string.cpp index fa8a393d08..ccbb70d689 100644 --- a/core/variant_construct_string.cpp +++ b/core/variant_construct_string.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 5fda6b1473..b6e114b853 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index a1b168621c..65c7b7cfec 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/variant_parser.h b/core/variant_parser.h index acbe0e967f..524891cdfd 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/vector.h b/core/vector.h index 966832ac50..03eaf65099 100644 --- a/core/vector.h +++ b/core/vector.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/version.h b/core/version.h index 43f6f1bbf9..436f30ef01 100644 --- a/core/version.h +++ b/core/version.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/vmap.h b/core/vmap.h index 66f935f58d..f0977341ec 100644 --- a/core/vmap.h +++ b/core/vmap.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/core/vset.h b/core/vset.h index 73062e064c..7b12ae0b25 100644 --- a/core/vset.h +++ b/core/vset.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index a6b9748129..40c66b0bc5 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/alsa/audio_driver_alsa.h b/drivers/alsa/audio_driver_alsa.h index 9e9413f3d9..83601be41b 100644 --- a/drivers/alsa/audio_driver_alsa.h +++ b/drivers/alsa/audio_driver_alsa.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/convex_decomp/b2d_decompose.cpp b/drivers/convex_decomp/b2d_decompose.cpp index d9011b8eab..14ab4d1072 100644 --- a/drivers/convex_decomp/b2d_decompose.cpp +++ b/drivers/convex_decomp/b2d_decompose.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/convex_decomp/b2d_decompose.h b/drivers/convex_decomp/b2d_decompose.h index 3a064e08d3..a87f5a656c 100644 --- a/drivers/convex_decomp/b2d_decompose.h +++ b/drivers/convex_decomp/b2d_decompose.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gl_context/context_gl.cpp b/drivers/gl_context/context_gl.cpp index 935391d58e..a453eef227 100644 --- a/drivers/gl_context/context_gl.cpp +++ b/drivers/gl_context/context_gl.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gl_context/context_gl.h b/drivers/gl_context/context_gl.h index c8eb0f93b4..399657eb52 100644 --- a/drivers/gl_context/context_gl.h +++ b/drivers/gl_context/context_gl.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles2/SCsub b/drivers/gles2/SCsub deleted file mode 100644 index dedd794dba..0000000000 --- a/drivers/gles2/SCsub +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.drivers_sources, "*.cpp") - -SConscript("shaders/SCsub") - -Export('env') diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp deleted file mode 100644 index 75d5d01890..0000000000 --- a/drivers/gles2/rasterizer_gles2.cpp +++ /dev/null @@ -1,10766 +0,0 @@ -/*************************************************************************/ -/* rasterizer_gles2.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#ifdef GLES2_ENABLED - -#include "rasterizer_gles2.h" -#include "gl_context/context_gl.h" -#include "os/os.h" -#include "project_settings.h" -#include "servers/visual/particle_system_sw.h" -#include "servers/visual/shader_language.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#ifdef GLEW_ENABLED -#define _GL_HALF_FLOAT_OES 0x140B -#else -#define _GL_HALF_FLOAT_OES 0x8D61 -#endif - -#define _GL_RGBA16F_EXT 0x881A -#define _GL_RGB16F_EXT 0x881B -#define _GL_RG16F_EXT 0x822F -#define _GL_R16F_EXT 0x822D -#define _GL_R32F_EXT 0x822E - -#define _GL_RED_EXT 0x1903 -#define _GL_RG_EXT 0x8227 -#define _GL_R8_EXT 0x8229 -#define _GL_RG8_EXT 0x822B - -#define _DEPTH_COMPONENT24_OES 0x81A6 - -#ifdef GLEW_ENABLED -#define _glClearDepth glClearDepth -#else -#define _glClearDepth glClearDepthf -#endif - -#define _GL_SRGB_EXT 0x8C40 -#define _GL_SRGB_ALPHA_EXT 0x8C42 - -#define _GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define _GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF - -//#define DEBUG_OPENGL - -#ifdef DEBUG_OPENGL - -#define DEBUG_TEST_ERROR(m_section) \ - { \ - print_line("AT: " + String(m_section)); \ - glFlush(); \ - uint32_t err = glGetError(); \ - if (err) { \ - print_line("OpenGL Error #" + itos(err) + " at: " + m_section); \ - } \ - } - -#else - -#define DEBUG_TEST_ERROR(m_section) - -#endif - -static RasterizerGLES2 *_singleton = NULL; - -#ifdef GLES_NO_CLIENT_ARRAYS -static float GlobalVertexBuffer[MAX_POLYGON_VERTICES * 8] = { 0 }; -#endif - -static const GLenum prim_type[] = { GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN }; - -_FORCE_INLINE_ static void _set_color_attrib(const Color &p_color) { - - GLfloat c[4] = { p_color.r, p_color.g, p_color.b, p_color.a }; - glVertexAttrib4fv(VS::ARRAY_COLOR, c); -} - -static _FORCE_INLINE_ uint16_t make_half_float(float f) { - - union { - float fv; - uint32_t ui; - } ci; - ci.fv = f; - - unsigned int x = ci.ui; - unsigned int sign = (unsigned short)(x >> 31); - unsigned int mantissa; - unsigned int exp; - uint16_t hf; - - // get mantissa - mantissa = x & ((1 << 23) - 1); - // get exponent bits - exp = x & (0xFF << 23); - if (exp >= 0x47800000) { - // check if the original single precision float number is a NaN - if (mantissa && (exp == (0xFF << 23))) { - // we have a single precision NaN - mantissa = (1 << 23) - 1; - } else { - // 16-bit half-float representation stores number as Inf - mantissa = 0; - } - hf = (((uint16_t)sign) << 15) | (uint16_t)((0x1F << 10)) | - (uint16_t)(mantissa >> 13); - } - // check if exponent is <= -15 - else if (exp <= 0x38000000) { - - /*// store a denorm half-float value or zero - exp = (0x38000000 - exp) >> 23; - mantissa >>= (14 + exp); - - hf = (((uint16_t)sign) << 15) | (uint16_t)(mantissa); - */ - hf = 0; //denormals do not work for 3D, convert to zero - } else { - hf = (((uint16_t)sign) << 15) | - (uint16_t)((exp - 0x38000000) >> 13) | - (uint16_t)(mantissa >> 13); - } - - return hf; -} - -void RasterizerGLES2::_draw_primitive(int p_points, const Vector3 *p_vertices, const Vector3 *p_normals, const Color *p_colors, const Vector3 *p_uvs, const Plane *p_tangents, int p_instanced) { - - ERR_FAIL_COND(!p_vertices); - ERR_FAIL_COND(p_points < 1 || p_points > 4); - - bool quad = false; - - GLenum type; - switch (p_points) { - - case 1: type = GL_POINTS; break; - case 2: type = GL_LINES; break; - case 4: quad = true; p_points = 3; - case 3: type = GL_TRIANGLES; break; - }; - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - - GLfloat vert_array[18]; - GLfloat normal_array[18]; - GLfloat color_array[24]; - GLfloat tangent_array[24]; - GLfloat uv_array[18]; - - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, false, 0, vert_array); - - for (int i = 0; i < p_points; i++) { - - vert_array[i * 3 + 0] = p_vertices[i].x; - vert_array[i * 3 + 1] = p_vertices[i].y; - vert_array[i * 3 + 2] = p_vertices[i].z; - if (quad) { - int idx = 2 + i; - if (idx == 4) - idx = 0; - vert_array[9 + i * 3 + 0] = p_vertices[idx].x; - vert_array[9 + i * 3 + 1] = p_vertices[idx].y; - vert_array[9 + i * 3 + 2] = p_vertices[idx].z; - } - } - - if (p_normals) { - glEnableVertexAttribArray(VS::ARRAY_NORMAL); - glVertexAttribPointer(VS::ARRAY_NORMAL, 3, GL_FLOAT, false, 0, normal_array); - for (int i = 0; i < p_points; i++) { - - normal_array[i * 3 + 0] = p_normals[i].x; - normal_array[i * 3 + 1] = p_normals[i].y; - normal_array[i * 3 + 2] = p_normals[i].z; - if (quad) { - int idx = 2 + i; - if (idx == 4) - idx = 0; - normal_array[9 + i * 3 + 0] = p_normals[idx].x; - normal_array[9 + i * 3 + 1] = p_normals[idx].y; - normal_array[9 + i * 3 + 2] = p_normals[idx].z; - } - } - } else { - glDisableVertexAttribArray(VS::ARRAY_NORMAL); - } - - if (p_colors) { - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, 0, color_array); - for (int i = 0; i < p_points; i++) { - - color_array[i * 4 + 0] = p_colors[i].r; - color_array[i * 4 + 1] = p_colors[i].g; - color_array[i * 4 + 2] = p_colors[i].b; - color_array[i * 4 + 3] = p_colors[i].a; - if (quad) { - int idx = 2 + i; - if (idx == 4) - idx = 0; - color_array[12 + i * 4 + 0] = p_colors[idx].r; - color_array[12 + i * 4 + 1] = p_colors[idx].g; - color_array[12 + i * 4 + 2] = p_colors[idx].b; - color_array[12 + i * 4 + 3] = p_colors[idx].a; - } - } - } else { - glDisableVertexAttribArray(VS::ARRAY_COLOR); - } - - if (p_tangents) { - glEnableVertexAttribArray(VS::ARRAY_TANGENT); - glVertexAttribPointer(VS::ARRAY_TANGENT, 4, GL_FLOAT, false, 0, tangent_array); - for (int i = 0; i < p_points; i++) { - - tangent_array[i * 4 + 0] = p_tangents[i].normal.x; - tangent_array[i * 4 + 1] = p_tangents[i].normal.y; - tangent_array[i * 4 + 2] = p_tangents[i].normal.z; - tangent_array[i * 4 + 3] = p_tangents[i].d; - if (quad) { - int idx = 2 + i; - if (idx == 4) - idx = 0; - tangent_array[12 + i * 4 + 0] = p_tangents[idx].normal.x; - tangent_array[12 + i * 4 + 1] = p_tangents[idx].normal.y; - tangent_array[12 + i * 4 + 2] = p_tangents[idx].normal.z; - tangent_array[12 + i * 4 + 3] = p_tangents[idx].d; - } - } - } else { - glDisableVertexAttribArray(VS::ARRAY_TANGENT); - } - - if (p_uvs) { - - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 3, GL_FLOAT, false, 0, uv_array); - for (int i = 0; i < p_points; i++) { - - uv_array[i * 3 + 0] = p_uvs[i].x; - uv_array[i * 3 + 1] = p_uvs[i].y; - uv_array[i * 3 + 2] = p_uvs[i].z; - if (quad) { - int idx = 2 + i; - if (idx == 4) - idx = 0; - uv_array[9 + i * 3 + 0] = p_uvs[idx].x; - uv_array[9 + i * 3 + 1] = p_uvs[idx].y; - uv_array[9 + i * 3 + 2] = p_uvs[idx].z; - } - } - - } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); - } - - /* - if (p_instanced>1) - glDrawArraysInstanced(type,0,p_points,p_instanced); - else - */ - - glDrawArrays(type, 0, quad ? 6 : p_points); -}; - -/* TEXTURE API */ -#define _EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define _EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define _EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 - -#define _EXT_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 -#define _EXT_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 -#define _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 -#define _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 - -#define _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define _EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define _EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 - -#define _EXT_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define _EXT_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define _EXT_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define _EXT_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 - -#define _EXT_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define _EXT_COMPRESSED_RED_RGTC1 0x8DBB -#define _EXT_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define _EXT_COMPRESSED_RG_RGTC2 0x8DBD -#define _EXT_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#define _EXT_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define _EXT_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define _EXT_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#define _EXT_ETC1_RGB8_OES 0x8D64 - -#define _EXT_SLUMINANCE_NV 0x8C46 -#define _EXT_SLUMINANCE_ALPHA_NV 0x8C44 -#define _EXT_SRGB8_NV 0x8C41 -#define _EXT_SLUMINANCE8_NV 0x8C47 -#define _EXT_SLUMINANCE8_ALPHA8_NV 0x8C45 - -#define _EXT_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C -#define _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D -#define _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E -#define _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F - -#define _EXT_ATC_RGB_AMD 0x8C92 -#define _EXT_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define _EXT_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE - -/* TEXTURE API */ - -Ref<Image> RasterizerGLES2::_get_gl_image_and_format(const Ref<Image> &p_image, Image::Format p_format, uint32_t p_flags, GLenum &r_gl_format, GLenum &r_gl_internal_format, int &r_gl_components, bool &r_has_alpha_cache, bool &r_compressed) { - - r_has_alpha_cache = false; - r_compressed = false; - r_gl_format = 0; - Ref<Image> image = p_image; - - switch (p_format) { - - case Image::FORMAT_L8: { - r_gl_components = 1; - r_gl_format = GL_LUMINANCE; - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_SLUMINANCE_NV : GL_LUMINANCE; - - } break; - case Image::FORMAT_INTENSITY: { - - if (!image.empty()) - image.convert(Image::FORMAT_RGBA8); - r_gl_components = 4; - r_gl_format = GL_RGBA; - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _GL_SRGB_ALPHA_EXT : GL_RGBA; - r_has_alpha_cache = true; - } break; - case Image::FORMAT_LA8: { - - //image.convert(Image::FORMAT_RGBA8); - r_gl_components = 2; - r_gl_format = GL_LUMINANCE_ALPHA; - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_SLUMINANCE_ALPHA_NV : GL_LUMINANCE_ALPHA; - r_has_alpha_cache = true; - } break; - - case Image::FORMAT_INDEXED: { - - if (!image.empty()) - image.convert(Image::FORMAT_RGB8); - r_gl_components = 3; - r_gl_format = GL_RGB; - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _GL_SRGB_EXT : GL_RGB; - - } break; - - case Image::FORMAT_INDEXED_ALPHA: { - - if (!image.empty()) - image.convert(Image::FORMAT_RGBA8); - r_gl_components = 4; - - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGBA; - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - r_has_alpha_cache = true; - - } break; - case Image::FORMAT_RGB8: { - - r_gl_components = 3; - - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_internal_format = _GL_SRGB_EXT; - r_gl_format = GL_RGB; - } else { - r_gl_internal_format = GL_RGB; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGB; - } - } break; - case Image::FORMAT_RGBA8: { - - r_gl_components = 4; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - r_gl_format = GL_RGBA; - //r_gl_internal_format=GL_RGBA; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - - r_has_alpha_cache = true; - } break; - case Image::FORMAT_DXT1: { - - if (!s3tc_supported || (!s3tc_srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) { - - if (!image.empty()) { - image.decompress(); - } - r_gl_components = 4; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGBA; - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - r_has_alpha_cache = true; - - } else { - - r_gl_components = 1; //doesn't matter much - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT1_EXT; - r_compressed = true; - }; - - } break; - case Image::FORMAT_DXT3: { - - if (!s3tc_supported || (!s3tc_srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) { - - if (!image.empty()) { - image.decompress(); - } - r_gl_components = 4; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGBA; - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - r_has_alpha_cache = true; - - } else { - r_gl_components = 1; //doesn't matter much - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT3_EXT; - - r_has_alpha_cache = true; - r_compressed = true; - }; - - } break; - case Image::FORMAT_DXT5: { - - if (!s3tc_supported || (!s3tc_srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) { - - if (!image.empty()) { - image.decompress(); - } - r_gl_components = 4; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGBA; - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - r_has_alpha_cache = true; - - } else { - r_gl_components = 1; //doesn't matter much - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV : _EXT_COMPRESSED_RGBA_S3TC_DXT5_EXT; - r_has_alpha_cache = true; - r_compressed = true; - }; - - } break; - case Image::FORMAT_ATI1: { - - if (!latc_supported) { - - if (!image.empty()) { - image.decompress(); - } - r_gl_components = 4; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGBA; - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - r_has_alpha_cache = true; - - } else { - - r_gl_internal_format = _EXT_COMPRESSED_LUMINANCE_LATC1_EXT; - r_gl_components = 1; //doesn't matter much - r_compressed = true; - }; - - } break; - case Image::FORMAT_ATI2: { - - if (!latc_supported) { - - if (!image.empty()) { - image.decompress(); - } - r_gl_components = 4; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGBA; - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - r_has_alpha_cache = true; - - } else { - r_gl_internal_format = _EXT_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT; - r_gl_components = 1; //doesn't matter much - r_compressed = true; - }; - } break; - case Image::FORMAT_PVRTC2: { - - if (!pvr_supported || (!pvr_srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) { - - if (!image.empty()) { - image.decompress(); - } - r_gl_components = 4; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGBA; - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - r_has_alpha_cache = true; - - } else { - - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - r_gl_components = 1; //doesn't matter much - r_compressed = true; - } - - } break; - case Image::FORMAT_PVRTC2A: { - - if (!pvr_supported || (!pvr_srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) { - - if (!image.empty()) - image.decompress(); - r_gl_components = 4; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGBA; - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - r_has_alpha_cache = true; - - } else { - - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - r_gl_components = 1; //doesn't matter much - r_compressed = true; - } - - } break; - case Image::FORMAT_PVRTC4: { - - if (!pvr_supported || (!pvr_srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) { - - if (!image.empty()) - image.decompress(); - r_gl_components = 4; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGBA; - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - r_has_alpha_cache = true; - } else { - - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT : _EXT_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - r_gl_components = 1; //doesn't matter much - r_compressed = true; - } - - } break; - case Image::FORMAT_PVRTC4A: { - - if (!pvr_supported || (!pvr_srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR)) { - - if (!image.empty()) - image.decompress(); - r_gl_components = 4; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGBA; - r_gl_internal_format = _GL_SRGB_ALPHA_EXT; - } else { - r_gl_internal_format = GL_RGBA; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGBA; - } - r_has_alpha_cache = true; - - } else { - r_gl_internal_format = (srgb_supported && p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) ? _EXT_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT : _EXT_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - r_gl_components = 1; //doesn't matter much - r_compressed = true; - } - - } break; - case Image::FORMAT_ETC: { - - if (!etc_supported || p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (!image.empty()) { - image.decompress(); - } - r_gl_components = 3; - if (p_flags & VS::TEXTURE_FLAG_CONVERT_TO_LINEAR) { - - if (srgb_supported) { - r_gl_format = GL_RGB; - r_gl_internal_format = _GL_SRGB_EXT; - } else { - r_gl_internal_format = GL_RGB; - if (!image.empty()) - image.srgb_to_linear(); - } - } else { - r_gl_internal_format = GL_RGB; - } - r_gl_internal_format = GL_RGB; - - } else { - - r_gl_internal_format = _EXT_ETC1_RGB8_OES; - r_gl_components = 1; //doesn't matter much - r_compressed = true; - } - - } break; - case Image::FORMAT_ATC: { - - if (!atitc_supported) { - - if (!image.empty()) { - image.decompress(); - } - r_gl_components = 3; - r_gl_internal_format = GL_RGB; - - } else { - - r_gl_internal_format = _EXT_ATC_RGB_AMD; - r_gl_components = 1; //doesn't matter much - r_compressed = true; - } - - } break; - case Image::FORMAT_ATC_ALPHA_EXPLICIT: { - - if (!atitc_supported) { - - if (!image.empty()) { - image.decompress(); - } - r_gl_components = 4; - r_gl_internal_format = GL_RGBA; - - } else { - - r_gl_internal_format = _EXT_ATC_RGBA_EXPLICIT_ALPHA_AMD; - r_gl_components = 1; //doesn't matter much - r_compressed = true; - } - - } break; - case Image::FORMAT_ATC_ALPHA_INTERPOLATED: { - - if (!atitc_supported) { - - if (!image.empty()) { - image.decompress(); - } - r_gl_components = 4; - r_gl_internal_format = GL_RGBA; - - } else { - - r_gl_internal_format = _EXT_ATC_RGBA_INTERPOLATED_ALPHA_AMD; - r_gl_components = 1; //doesn't matter much - r_compressed = true; - } - - } break; - case Image::FORMAT_YUV_422: - case Image::FORMAT_YUV_444: { - - if (!image.empty()) - image.convert(Image::FORMAT_RGB8); - r_gl_internal_format = GL_RGB; - r_gl_components = 3; - - } break; - - default: { - - ERR_FAIL_V(Image()); - } - } - - if (r_gl_format == 0) { - r_gl_format = r_gl_internal_format; - } - - return image; -} - -static const GLenum _cube_side_enum[6] = { - - GL_TEXTURE_CUBE_MAP_NEGATIVE_X, - GL_TEXTURE_CUBE_MAP_POSITIVE_X, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, - GL_TEXTURE_CUBE_MAP_POSITIVE_Y, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, - GL_TEXTURE_CUBE_MAP_POSITIVE_Z, - -}; - -RID RasterizerGLES2::texture_create() { - - Texture *texture = memnew(Texture); - ERR_FAIL_COND_V(!texture, RID()); - glGenTextures(1, &texture->tex_id); - texture->active = false; - texture->total_data_size = 0; - - return texture_owner.make_rid(texture); -} - -void RasterizerGLES2::texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags) { - - bool has_alpha_cache; - int components; - GLenum format; - GLenum internal_format; - bool compressed; - - int po2_width = next_power_of_2(p_width); - int po2_height = next_power_of_2(p_height); - - if (p_flags & VS::TEXTURE_FLAG_VIDEO_SURFACE) { - p_flags &= ~VS::TEXTURE_FLAG_MIPMAPS; // no mipies for video - } - - Texture *texture = texture_owner.get(p_texture); - ERR_FAIL_COND(!texture); - texture->width = p_width; - texture->height = p_height; - texture->format = p_format; - texture->flags = p_flags; - texture->target = (p_flags & VS::TEXTURE_FLAG_CUBEMAP) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D; - - _get_gl_image_and_format(Image(), texture->format, texture->flags, format, internal_format, components, has_alpha_cache, compressed); - - bool scale_textures = !compressed && !(p_flags & VS::TEXTURE_FLAG_VIDEO_SURFACE) && (!npo2_textures_available || p_flags & VS::TEXTURE_FLAG_MIPMAPS); - - if (scale_textures) { - texture->alloc_width = po2_width; - texture->alloc_height = po2_height; - //print_line("scale because npo2: "+itos(npo2_textures_available)+" mm: "+itos(p_format&VS::TEXTURE_FLAG_MIPMAPS)+" "+itos(p_mipmap_count) ); - } else { - - texture->alloc_width = texture->width; - texture->alloc_height = texture->height; - }; - - if (!(p_flags & VS::TEXTURE_FLAG_VIDEO_SURFACE) && shrink_textures_x2) { - texture->alloc_height = MAX(1, texture->alloc_height / 2); - texture->alloc_width = MAX(1, texture->alloc_width / 2); - } - - texture->gl_components_cache = components; - texture->gl_format_cache = format; - texture->gl_internal_format_cache = internal_format; - texture->format_has_alpha = has_alpha_cache; - texture->compressed = compressed; - texture->has_alpha = false; //by default it doesn't have alpha unless something with alpha is blitteds - texture->data_size = 0; - texture->mipmaps = 0; - - glActiveTexture(GL_TEXTURE0); - glBindTexture(texture->target, texture->tex_id); - - if (p_flags & VS::TEXTURE_FLAG_VIDEO_SURFACE) { - //prealloc if video - glTexImage2D(texture->target, 0, internal_format, p_width, p_height, 0, format, GL_UNSIGNED_BYTE, NULL); - } - - texture->active = true; -} - -void RasterizerGLES2::texture_set_data(RID p_texture, const Image &p_image, VS::CubeMapSide p_cube_side) { - - Texture *texture = texture_owner.get(p_texture); - - ERR_FAIL_COND(!texture); - ERR_FAIL_COND(!texture->active); - ERR_FAIL_COND(texture->render_target); - ERR_FAIL_COND(texture->format != p_image.get_format()); - ERR_FAIL_COND(p_image.empty()); - - int components; - GLenum format; - GLenum internal_format; - bool alpha; - bool compressed; - - if (keep_copies && !(texture->flags & VS::TEXTURE_FLAG_VIDEO_SURFACE) && !(use_reload_hooks && texture->reloader)) { - texture->image[p_cube_side] = p_image; - } - - Image img = _get_gl_image_and_format(p_image, p_image.get_format(), texture->flags, format, internal_format, components, alpha, compressed); - - if (texture->alloc_width != img.get_width() || texture->alloc_height != img.get_height()) { - - if (texture->alloc_width == img.get_width() / 2 && texture->alloc_height == img.get_height() / 2) { - - img.shrink_x2(); - } else if (img.get_format() <= Image::FORMAT_INDEXED_ALPHA) { - - img.resize(texture->alloc_width, texture->alloc_height, Image::INTERPOLATE_BILINEAR); - } - }; - - if (!(texture->flags & VS::TEXTURE_FLAG_VIDEO_SURFACE) && img.detect_alpha() == Image::ALPHA_BLEND) { - texture->has_alpha = true; - } - - GLenum blit_target = (texture->target == GL_TEXTURE_CUBE_MAP) ? _cube_side_enum[p_cube_side] : GL_TEXTURE_2D; - - texture->data_size = img.get_data().size(); - PoolVector<uint8_t>::Read read = img.get_data().read(); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(texture->target, texture->tex_id); - - texture->ignore_mipmaps = compressed && img.get_mipmaps() == 0; - - if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) - glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); - else { - if (texture->flags & VS::TEXTURE_FLAG_FILTER) { - glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } else { - glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - } - } - - if (texture->flags & VS::TEXTURE_FLAG_FILTER) { - - glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering - - } else { - - glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering - } - - bool force_clamp_to_edge = !(texture->flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) && (next_power_of_2(texture->alloc_height) != texture->alloc_height || next_power_of_2(texture->alloc_width) != texture->alloc_width); - - if (!force_clamp_to_edge && (texture->flags & VS::TEXTURE_FLAG_REPEAT || texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) && texture->target != GL_TEXTURE_CUBE_MAP) { - - if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); - } else { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - } - } else { - - //glTexParameterf( texture->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); - glTexParameterf(texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } - - if (use_anisotropic_filter) { - - if (texture->flags & VS::TEXTURE_FLAG_ANISOTROPIC_FILTER) { - - glTexParameterf(texture->target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropic_level); - } else { - glTexParameterf(texture->target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); - } - } - - int mipmaps = (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && img.get_mipmaps() > 0) ? img.get_mipmaps() + 1 : 1; - - int w = img.get_width(); - int h = img.get_height(); - - int tsize = 0; - for (int i = 0; i < mipmaps; i++) { - - int size, ofs; - img.get_mipmap_offset_and_size(i, ofs, size); - - //print_line("mipmap: "+itos(i)+" size: "+itos(size)+" w: "+itos(mm_w)+", h: "+itos(mm_h)); - - if (texture->compressed) { - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - glCompressedTexImage2D(blit_target, i, format, w, h, 0, size, &read[ofs]); - - } else { - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - if (texture->flags & VS::TEXTURE_FLAG_VIDEO_SURFACE) { - glTexSubImage2D(blit_target, i, 0, 0, w, h, format, GL_UNSIGNED_BYTE, &read[ofs]); - } else { - glTexImage2D(blit_target, i, internal_format, w, h, 0, format, GL_UNSIGNED_BYTE, &read[ofs]); - } - } - tsize += size; - - w = MAX(1, w >> 1); - h = MAX(1, h >> 1); - } - - _rinfo.texture_mem -= texture->total_data_size; - texture->total_data_size = tsize; - _rinfo.texture_mem += texture->total_data_size; - - //printf("texture: %i x %i - size: %i - total: %i\n",texture->width,texture->height,tsize,_rinfo.texture_mem); - - if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && mipmaps == 1 && !texture->ignore_mipmaps) { - //generate mipmaps if they were requested and the image does not contain them - glGenerateMipmap(texture->target); - } - - texture->mipmaps = mipmaps; - - if (mipmaps > 1) { - - //glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmaps-1 ); - assumed to have all, always - } - - //texture_set_flags(p_texture,texture->flags); -} - -Image RasterizerGLES2::texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side) const { - - Texture *texture = texture_owner.get(p_texture); - - ERR_FAIL_COND_V(!texture, Image()); - ERR_FAIL_COND_V(!texture->active, Image()); - ERR_FAIL_COND_V(texture->data_size == 0, Image()); - ERR_FAIL_COND_V(texture->render_target, Image()); - - return texture->image[p_cube_side]; - -#if 0 - - Texture * texture = texture_owner.get(p_texture); - - ERR_FAIL_COND_V(!texture,Image()); - ERR_FAIL_COND_V(!texture->active,Image()); - ERR_FAIL_COND_V(texture->data_size==0,Image()); - - PoolVector<uint8_t> data; - GLenum format,type=GL_UNSIGNED_BYTE; - Image::Format fmt; - int pixelsize=0; - int pixelshift=0; - int minw=1,minh=1; - bool compressed=false; - - fmt=texture->format; - - switch(texture->format) { - - case Image::FORMAT_L8: { - - format=GL_LUMINANCE; - type=GL_UNSIGNED_BYTE; - data.resize(texture->alloc_width*texture->alloc_height); - pixelsize=1; - - } break; - case Image::FORMAT_INTENSITY: { - return Image(); - } break; - case Image::FORMAT_LA8: { - - format=GL_LUMINANCE_ALPHA; - type=GL_UNSIGNED_BYTE; - pixelsize=2; - - } break; - case Image::FORMAT_RGB8: { - format=GL_RGB; - type=GL_UNSIGNED_BYTE; - pixelsize=3; - } break; - case Image::FORMAT_RGBA8: { - - format=GL_RGBA; - type=GL_UNSIGNED_BYTE; - pixelsize=4; - } break; - case Image::FORMAT_INDEXED: { - - format=GL_RGB; - type=GL_UNSIGNED_BYTE; - fmt=Image::FORMAT_RGB8; - pixelsize=3; - } break; - case Image::FORMAT_INDEXED_ALPHA: { - - format=GL_RGBA; - type=GL_UNSIGNED_BYTE; - fmt=Image::FORMAT_RGBA8; - pixelsize=4; - - } break; - case Image::FORMAT_DXT1: { - - pixelsize=1; //doesn't matter much - format=GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - compressed=true; - pixelshift=1; - minw=minh=4; - - } break; - case Image::FORMAT_DXT3: { - pixelsize=1; //doesn't matter much - format=GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - compressed=true; - minw=minh=4; - - } break; - case Image::FORMAT_DXT5: { - - pixelsize=1; //doesn't matter much - format=GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - compressed=true; - minw=minh=4; - - } break; - case Image::FORMAT_ATI1: { - - format=GL_COMPRESSED_RED_RGTC1; - pixelsize=1; //doesn't matter much - compressed=true; - pixelshift=1; - minw=minh=4; - - } break; - case Image::FORMAT_ATI2: { - - format=GL_COMPRESSED_RG_RGTC2; - pixelsize=1; //doesn't matter much - compressed=true; - minw=minh=4; - - } break; - - default:{} - } - - data.resize(texture->data_size); - PoolVector<uint8_t>::Write wb = data.write(); - - glActiveTexture(GL_TEXTURE0); - int ofs=0; - glBindTexture(texture->target,texture->tex_id); - - int w=texture->alloc_width; - int h=texture->alloc_height; - for(int i=0;i<texture->mipmaps+1;i++) { - - if (compressed) { - - glPixelStorei(GL_PACK_ALIGNMENT, 4); - glGetCompressedTexImage(texture->target,i,&wb[ofs]); - - } else { - glPixelStorei(GL_PACK_ALIGNMENT, 1); - glGetTexImage(texture->target,i,format,type,&wb[ofs]); - } - - int size = (w*h*pixelsize)>>pixelshift; - ofs+=size; - - w=MAX(minw,w>>1); - h=MAX(minh,h>>1); - - } - - - wb=PoolVector<uint8_t>::Write(); - - Image img(texture->alloc_width,texture->alloc_height,texture->mipmaps,fmt,data); - - if (texture->format<Image::FORMAT_INDEXED && (texture->alloc_width!=texture->width || texture->alloc_height!=texture->height)) - img.resize(texture->width,texture->height); - - return img; -#endif -} - -void RasterizerGLES2::texture_set_flags(RID p_texture, uint32_t p_flags) { - - Texture *texture = texture_owner.get(p_texture); - ERR_FAIL_COND(!texture); - if (texture->render_target) { - - p_flags &= VS::TEXTURE_FLAG_FILTER; //can change only filter - } - - bool had_mipmaps = texture->flags & VS::TEXTURE_FLAG_MIPMAPS; - - glActiveTexture(GL_TEXTURE0); - glBindTexture(texture->target, texture->tex_id); - uint32_t cube = texture->flags & VS::TEXTURE_FLAG_CUBEMAP; - texture->flags = p_flags | cube; // can't remove a cube from being a cube - - bool force_clamp_to_edge = !(p_flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) && (next_power_of_2(texture->alloc_height) != texture->alloc_height || next_power_of_2(texture->alloc_width) != texture->alloc_width); - - if (!force_clamp_to_edge && (texture->flags & VS::TEXTURE_FLAG_REPEAT || texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) && texture->target != GL_TEXTURE_CUBE_MAP) { - - if (texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); - } else { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - } - } else { - //glTexParameterf( texture->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); - glTexParameterf(texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } - - if (use_anisotropic_filter) { - - if (texture->flags & VS::TEXTURE_FLAG_ANISOTROPIC_FILTER) { - - glTexParameterf(texture->target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropic_level); - } else { - glTexParameterf(texture->target, _GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); - } - } - - if (texture->flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) { - if (!had_mipmaps && texture->mipmaps == 1) { - glGenerateMipmap(texture->target); - } - glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); - - } else { - if (texture->flags & VS::TEXTURE_FLAG_FILTER) { - glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } else { - glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - } - } - - if (texture->flags & VS::TEXTURE_FLAG_FILTER) { - - glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering - - } else { - - glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering - } -} -uint32_t RasterizerGLES2::texture_get_flags(RID p_texture) const { - - Texture *texture = texture_owner.get(p_texture); - - ERR_FAIL_COND_V(!texture, 0); - - return texture->flags; -} -Image::Format RasterizerGLES2::texture_get_format(RID p_texture) const { - - Texture *texture = texture_owner.get(p_texture); - - ERR_FAIL_COND_V(!texture, Image::FORMAT_L8); - - return texture->format; -} -uint32_t RasterizerGLES2::texture_get_width(RID p_texture) const { - - Texture *texture = texture_owner.get(p_texture); - - ERR_FAIL_COND_V(!texture, 0); - - return texture->width; -} -uint32_t RasterizerGLES2::texture_get_height(RID p_texture) const { - - Texture *texture = texture_owner.get(p_texture); - - ERR_FAIL_COND_V(!texture, 0); - - return texture->height; -} - -bool RasterizerGLES2::texture_has_alpha(RID p_texture) const { - - Texture *texture = texture_owner.get(p_texture); - - ERR_FAIL_COND_V(!texture, 0); - - return texture->has_alpha; -} - -void RasterizerGLES2::texture_set_size_override(RID p_texture, int p_width, int p_height) { - - Texture *texture = texture_owner.get(p_texture); - - ERR_FAIL_COND(!texture); - ERR_FAIL_COND(texture->render_target); - - ERR_FAIL_COND(p_width <= 0 || p_width > 16384); - ERR_FAIL_COND(p_height <= 0 || p_height > 16384); - //real texture size is in alloc width and height - texture->width = p_width; - texture->height = p_height; -} - -void RasterizerGLES2::texture_set_reload_hook(RID p_texture, ObjectID p_owner, const StringName &p_function) const { - - Texture *texture = texture_owner.get(p_texture); - - ERR_FAIL_COND(!texture); - ERR_FAIL_COND(texture->render_target); - - texture->reloader = p_owner; - texture->reloader_func = p_function; - if (use_reload_hooks && p_owner && keep_copies) { - - for (int i = 0; i < 6; i++) - texture->image[i] = Image(); - } -} - -GLuint RasterizerGLES2::_texture_get_name(RID p_tex) { - - Texture *texture = texture_owner.get(p_tex); - ERR_FAIL_COND_V(!texture, 0); - - return texture->tex_id; -}; - -void RasterizerGLES2::texture_set_path(RID p_texture, const String &p_path) { - Texture *texture = texture_owner.get(p_texture); - ERR_FAIL_COND(!texture); - - texture->path = p_path; -} - -String RasterizerGLES2::texture_get_path(RID p_texture) const { - - Texture *texture = texture_owner.get(p_texture); - ERR_FAIL_COND_V(!texture, String()); - return texture->path; -} -void RasterizerGLES2::texture_debug_usage(List<VS::TextureInfo> *r_info) { - - List<RID> textures; - texture_owner.get_owned_list(&textures); - - for (List<RID>::Element *E = textures.front(); E; E = E->next()) { - - Texture *t = texture_owner.get(E->get()); - if (!t) - continue; - VS::TextureInfo tinfo; - tinfo.path = t->path; - tinfo.format = t->format; - tinfo.size.x = t->alloc_width; - tinfo.size.y = t->alloc_height; - tinfo.bytes = t->total_data_size; - r_info->push_back(tinfo); - } -} - -void RasterizerGLES2::texture_set_shrink_all_x2_on_set_data(bool p_enable) { - - shrink_textures_x2 = p_enable; -} - -/* SHADER API */ - -RID RasterizerGLES2::shader_create(VS::ShaderMode p_mode) { - - Shader *shader = memnew(Shader); - shader->mode = p_mode; - RID rid = shader_owner.make_rid(shader); - shader_set_mode(rid, p_mode); - _shader_make_dirty(shader); - - return rid; -} - -void RasterizerGLES2::shader_set_mode(RID p_shader, VS::ShaderMode p_mode) { - - ERR_FAIL_INDEX(p_mode, 3); - Shader *shader = shader_owner.get(p_shader); - ERR_FAIL_COND(!shader); - if (shader->custom_code_id && p_mode == shader->mode) - return; - - if (shader->custom_code_id) { - - switch (shader->mode) { - case VS::SHADER_MATERIAL: { - material_shader.free_custom_shader(shader->custom_code_id); - } break; - case VS::SHADER_CANVAS_ITEM: { - canvas_shader.free_custom_shader(shader->custom_code_id); - } break; - } - - shader->custom_code_id = 0; - } - - shader->mode = p_mode; - - switch (shader->mode) { - case VS::SHADER_MATERIAL: { - shader->custom_code_id = material_shader.create_custom_shader(); - } break; - case VS::SHADER_CANVAS_ITEM: { - shader->custom_code_id = canvas_shader.create_custom_shader(); - } break; - } - _shader_make_dirty(shader); -} -VS::ShaderMode RasterizerGLES2::shader_get_mode(RID p_shader) const { - - Shader *shader = shader_owner.get(p_shader); - ERR_FAIL_COND_V(!shader, VS::SHADER_MATERIAL); - return shader->mode; -} - -void RasterizerGLES2::shader_set_code(RID p_shader, const String &p_vertex, const String &p_fragment, const String &p_light, int p_vertex_ofs, int p_fragment_ofs, int p_light_ofs) { - - Shader *shader = shader_owner.get(p_shader); - ERR_FAIL_COND(!shader); - -#ifdef DEBUG_ENABLED - if (shader->vertex_code == p_vertex && shader->fragment_code == p_fragment && shader->light_code == p_light) - return; -#endif - shader->fragment_code = p_fragment; - shader->vertex_code = p_vertex; - shader->light_code = p_light; - shader->fragment_line = p_fragment_ofs; - shader->vertex_line = p_vertex_ofs; - shader->light_line = p_light_ofs; - _shader_make_dirty(shader); -} - -String RasterizerGLES2::shader_get_vertex_code(RID p_shader) const { - - Shader *shader = shader_owner.get(p_shader); - ERR_FAIL_COND_V(!shader, String()); - return shader->vertex_code; -} - -String RasterizerGLES2::shader_get_fragment_code(RID p_shader) const { - - Shader *shader = shader_owner.get(p_shader); - ERR_FAIL_COND_V(!shader, String()); - return shader->fragment_code; -} - -String RasterizerGLES2::shader_get_light_code(RID p_shader) const { - - Shader *shader = shader_owner.get(p_shader); - ERR_FAIL_COND_V(!shader, String()); - return shader->light_code; -} - -void RasterizerGLES2::_shader_make_dirty(Shader *p_shader) { - - if (p_shader->dirty_list.in_list()) - return; - - _shader_dirty_list.add(&p_shader->dirty_list); -} - -void RasterizerGLES2::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const { - - Shader *shader = shader_owner.get(p_shader); - ERR_FAIL_COND(!shader); - - if (shader->dirty_list.in_list()) - _update_shader(shader); // ok should be not anymore dirty - - Map<int, StringName> order; - - for (Map<StringName, ShaderLanguage::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) { - - order[E->get().order] = E->key(); - } - - for (Map<int, StringName>::Element *E = order.front(); E; E = E->next()) { - - PropertyInfo pi; - ShaderLanguage::Uniform &u = shader->uniforms[E->get()]; - pi.name = E->get(); - switch (u.type) { - - case ShaderLanguage::TYPE_VOID: - case ShaderLanguage::TYPE_BOOL: - case ShaderLanguage::TYPE_FLOAT: - case ShaderLanguage::TYPE_VEC2: - case ShaderLanguage::TYPE_VEC3: - case ShaderLanguage::TYPE_MAT3: - case ShaderLanguage::TYPE_MAT4: - case ShaderLanguage::TYPE_VEC4: - pi.type = u.default_value.get_type(); - break; - case ShaderLanguage::TYPE_TEXTURE: - pi.type = Variant::_RID; - pi.hint = PROPERTY_HINT_RESOURCE_TYPE; - pi.hint_string = "Texture"; - break; - case ShaderLanguage::TYPE_CUBEMAP: - pi.type = Variant::_RID; - pi.hint = PROPERTY_HINT_RESOURCE_TYPE; - pi.hint_string = "CubeMap"; - break; - }; - - p_param_list->push_back(pi); - } -} - -void RasterizerGLES2::shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) { - - Shader *shader = shader_owner.get(p_shader); - ERR_FAIL_COND(!shader); - ERR_FAIL_COND(p_texture.is_valid() && !texture_owner.owns(p_texture)); - - if (p_texture.is_valid()) - shader->default_textures[p_name] = p_texture; - else - shader->default_textures.erase(p_name); - - _shader_make_dirty(shader); -} - -RID RasterizerGLES2::shader_get_default_texture_param(RID p_shader, const StringName &p_name) const { - const Shader *shader = shader_owner.get(p_shader); - ERR_FAIL_COND_V(!shader, RID()); - - const Map<StringName, RID>::Element *E = shader->default_textures.find(p_name); - if (!E) - return RID(); - return E->get(); -} - -Variant RasterizerGLES2::shader_get_default_param(RID p_shader, const StringName &p_name) { - - Shader *shader = shader_owner.get(p_shader); - ERR_FAIL_COND_V(!shader, Variant()); - - //update shader params if necessary - //make sure the shader is compiled and everything - //so the actual parameters can be properly retrieved! - if (shader->dirty_list.in_list()) { - _update_shader(shader); - } - if (shader->valid && shader->uniforms.has(p_name)) - return shader->uniforms[p_name].default_value; - - return Variant(); -} - -/* COMMON MATERIAL API */ - -RID RasterizerGLES2::material_create() { - - RID material = material_owner.make_rid(memnew(Material)); - return material; -} - -void RasterizerGLES2::material_set_shader(RID p_shader_material, RID p_shader) { - - Material *material = material_owner.get(p_shader_material); - ERR_FAIL_COND(!material); - if (material->shader == p_shader) - return; - material->shader = p_shader; - material->shader_version = 0; -} - -RID RasterizerGLES2::material_get_shader(RID p_shader_material) const { - - Material *material = material_owner.get(p_shader_material); - ERR_FAIL_COND_V(!material, RID()); - return material->shader; -} - -void RasterizerGLES2::material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) { - - Material *material = material_owner.get(p_material); - ERR_FAIL_COND(!material); - - Map<StringName, Material::UniformData>::Element *E = material->shader_params.find(p_param); - if (E) { - - if (p_value.get_type() == Variant::NIL) { - - material->shader_params.erase(E); - material->shader_version = 0; //get default! - } else { - E->get().value = p_value; - E->get().inuse = true; - } - } else { - - if (p_value.get_type() == Variant::NIL) - return; - - Material::UniformData ud; - ud.index = -1; - ud.value = p_value; - ud.istexture = p_value.get_type() == Variant::_RID; /// cache it being texture - ud.inuse = true; - material->shader_params[p_param] = ud; //may be got at some point, or erased - } -} -Variant RasterizerGLES2::material_get_param(RID p_material, const StringName &p_param) const { - - Material *material = material_owner.get(p_material); - ERR_FAIL_COND_V(!material, Variant()); - - if (material->shader.is_valid()) { - //update shader params if necessary - //make sure the shader is compiled and everything - //so the actual parameters can be properly retrieved! - material->shader_cache = shader_owner.get(material->shader); - if (!material->shader_cache) { - //invalidate - material->shader = RID(); - material->shader_cache = NULL; - } else { - - if (material->shader_cache->dirty_list.in_list()) - _update_shader(material->shader_cache); - if (material->shader_cache->valid && material->shader_cache->version != material->shader_version) { - //validate - _update_material_shader_params(material); - } - } - } - - if (material->shader_params.has(p_param) && material->shader_params[p_param].inuse) - return material->shader_params[p_param].value; - else - return Variant(); -} - -void RasterizerGLES2::material_set_flag(RID p_material, VS::MaterialFlag p_flag, bool p_enabled) { - - Material *material = material_owner.get(p_material); - ERR_FAIL_COND(!material); - ERR_FAIL_INDEX(p_flag, VS::MATERIAL_FLAG_MAX); - - material->flags[p_flag] = p_enabled; -} -bool RasterizerGLES2::material_get_flag(RID p_material, VS::MaterialFlag p_flag) const { - - Material *material = material_owner.get(p_material); - ERR_FAIL_COND_V(!material, false); - ERR_FAIL_INDEX_V(p_flag, VS::MATERIAL_FLAG_MAX, false); - return material->flags[p_flag]; -} - -void RasterizerGLES2::material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode) { - - Material *material = material_owner.get(p_material); - ERR_FAIL_COND(!material); - material->depth_draw_mode = p_mode; -} - -VS::MaterialDepthDrawMode RasterizerGLES2::material_get_depth_draw_mode(RID p_material) const { - - Material *material = material_owner.get(p_material); - ERR_FAIL_COND_V(!material, VS::MATERIAL_DEPTH_DRAW_ALWAYS); - return material->depth_draw_mode; -} - -void RasterizerGLES2::material_set_blend_mode(RID p_material, VS::MaterialBlendMode p_mode) { - - Material *material = material_owner.get(p_material); - ERR_FAIL_COND(!material); - material->blend_mode = p_mode; -} -VS::MaterialBlendMode RasterizerGLES2::material_get_blend_mode(RID p_material) const { - - Material *material = material_owner.get(p_material); - ERR_FAIL_COND_V(!material, VS::MATERIAL_BLEND_MODE_ADD); - return material->blend_mode; -} - -void RasterizerGLES2::material_set_line_width(RID p_material, float p_line_width) { - - Material *material = material_owner.get(p_material); - ERR_FAIL_COND(!material); - material->line_width = p_line_width; -} -float RasterizerGLES2::material_get_line_width(RID p_material) const { - - Material *material = material_owner.get(p_material); - ERR_FAIL_COND_V(!material, 0); - - return material->line_width; -} - -/* MESH API */ - -RID RasterizerGLES2::mesh_create() { - - return mesh_owner.make_rid(memnew(Mesh)); -} - -void RasterizerGLES2::mesh_add_surface(RID p_mesh, VS::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, bool p_alpha_sort) { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND(!mesh); - - ERR_FAIL_INDEX(p_primitive, VS::PRIMITIVE_MAX); - ERR_FAIL_COND(p_arrays.size() != VS::ARRAY_MAX); - - uint32_t format = 0; - - // validation - int index_array_len = 0; - int array_len = 0; - - for (int i = 0; i < p_arrays.size(); i++) { - - if (p_arrays[i].get_type() == Variant::NIL) - continue; - - format |= (1 << i); - - if (i == VS::ARRAY_VERTEX) { - - array_len = Vector3Array(p_arrays[i]).size(); - ERR_FAIL_COND(array_len == 0); - } else if (i == VS::ARRAY_INDEX) { - - index_array_len = IntArray(p_arrays[i]).size(); - } - } - - ERR_FAIL_COND((format & VS::ARRAY_FORMAT_VERTEX) == 0); // mandatory - - ERR_FAIL_COND(mesh->morph_target_count != p_blend_shapes.size()); - if (mesh->morph_target_count) { - //validate format for morphs - for (int i = 0; i < p_blend_shapes.size(); i++) { - - uint32_t bsformat = 0; - Array arr = p_blend_shapes[i]; - for (int j = 0; j < arr.size(); j++) { - - if (arr[j].get_type() != Variant::NIL) - bsformat |= (1 << j); - } - - ERR_FAIL_COND((bsformat) != (format & (VS::ARRAY_FORMAT_BONES - 1))); - } - } - - Surface *surface = memnew(Surface); - ERR_FAIL_COND(!surface); - - bool use_VBO = true; //glGenBuffersARB!=NULL; // TODO detect if it's in there - if ((!use_hw_skeleton_xform && format & VS::ARRAY_FORMAT_WEIGHTS) || mesh->morph_target_count > 0) { - - use_VBO = false; - } - - //surface->packed=pack_arrays && use_VBO; - - int total_elem_size = 0; - - for (int i = 0; i < VS::ARRAY_MAX; i++) { - - Surface::ArrayData &ad = surface->array[i]; - ad.size = 0; - ad.ofs = 0; - int elem_size = 0; - int elem_count = 0; - bool valid_local = true; - GLenum datatype; - bool normalize = false; - bool bind = false; - - if (!(format & (1 << i))) // no array - continue; - - switch (i) { - - case VS::ARRAY_VERTEX: { - - if (use_VBO && use_half_float) { - elem_size = 3 * sizeof(int16_t); // vertex - datatype = _GL_HALF_FLOAT_OES; - } else { - - elem_size = 3 * sizeof(GLfloat); // vertex - datatype = GL_FLOAT; - } - bind = true; - elem_count = 3; - - } break; - case VS::ARRAY_NORMAL: { - - if (use_VBO) { - elem_size = 4 * sizeof(int8_t); // vertex - datatype = GL_BYTE; - normalize = true; - } else { - elem_size = 3 * sizeof(GLfloat); // vertex - datatype = GL_FLOAT; - } - bind = true; - elem_count = 3; - } break; - case VS::ARRAY_TANGENT: { - if (use_VBO) { - elem_size = 4 * sizeof(int8_t); // vertex - datatype = GL_BYTE; - normalize = true; - } else { - elem_size = 4 * sizeof(GLfloat); // vertex - datatype = GL_FLOAT; - } - bind = true; - elem_count = 4; - - } break; - case VS::ARRAY_COLOR: { - - elem_size = 4 * sizeof(uint8_t); /* RGBA */ - datatype = GL_UNSIGNED_BYTE; - elem_count = 4; - bind = true; - normalize = true; - } break; - case VS::ARRAY_TEX_UV: - case VS::ARRAY_TEX_UV2: { - if (use_VBO && use_half_float) { - elem_size = 2 * sizeof(int16_t); // vertex - datatype = _GL_HALF_FLOAT_OES; - } else { - elem_size = 2 * sizeof(GLfloat); // vertex - datatype = GL_FLOAT; - } - bind = true; - elem_count = 2; - - } break; - case VS::ARRAY_WEIGHTS: { - - if (use_VBO) { - - elem_size = VS::ARRAY_WEIGHTS_SIZE * sizeof(GLushort); - valid_local = false; - bind = true; - normalize = true; - datatype = GL_UNSIGNED_SHORT; - elem_count = 4; - - } else { - elem_size = VS::ARRAY_WEIGHTS_SIZE * sizeof(GLfloat); - valid_local = false; - bind = false; - datatype = GL_FLOAT; - elem_count = 4; - } - - } break; - case VS::ARRAY_BONES: { - - if (use_VBO) { - elem_size = VS::ARRAY_WEIGHTS_SIZE * sizeof(GLubyte); - valid_local = false; - bind = true; - datatype = GL_UNSIGNED_BYTE; - elem_count = 4; - } else { - - elem_size = VS::ARRAY_WEIGHTS_SIZE * sizeof(GLushort); - valid_local = false; - bind = false; - datatype = GL_UNSIGNED_SHORT; - elem_count = 4; - } - - } break; - case VS::ARRAY_INDEX: { - - if (index_array_len <= 0) { - ERR_PRINT("index_array_len==NO_INDEX_ARRAY"); - break; - } - /* determine wether using 16 or 32 bits indices */ - if (array_len > (1 << 16)) { - - elem_size = 4; - datatype = GL_UNSIGNED_INT; - } else { - elem_size = 2; - datatype = GL_UNSIGNED_SHORT; - } - - /* - if (use_VBO) { - - glGenBuffers(1,&surface->index_id); - ERR_FAIL_COND(surface->index_id==0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,surface->index_id); - glBufferData(GL_ELEMENT_ARRAY_BUFFER,index_array_len*elem_size,NULL,GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0); //unbind - } else { - surface->index_array_local = (uint8_t*)memalloc(index_array_len*elem_size); - }; -*/ - surface->index_array_len = index_array_len; // only way it can exist - ad.ofs = 0; - ad.size = elem_size; - - continue; - } break; - default: { - ERR_FAIL(); - } - } - - ad.ofs = total_elem_size; - ad.size = elem_size; - ad.datatype = datatype; - ad.normalize = normalize; - ad.bind = bind; - ad.count = elem_count; - total_elem_size += elem_size; - if (valid_local) { - surface->local_stride += elem_size; - surface->morph_format |= (1 << i); - } - } - - surface->stride = total_elem_size; - surface->array_len = array_len; - surface->format = format; - surface->primitive = p_primitive; - surface->morph_target_count = mesh->morph_target_count; - surface->configured_format = 0; - surface->mesh = mesh; - if (keep_copies) { - surface->data = p_arrays; - surface->morph_data = p_blend_shapes; - } - - uint8_t *array_ptr = NULL; - uint8_t *index_array_ptr = NULL; - PoolVector<uint8_t> array_pre_vbo; - PoolVector<uint8_t>::Write vaw; - PoolVector<uint8_t> index_array_pre_vbo; - PoolVector<uint8_t>::Write iaw; - - /* create pointers */ - if (use_VBO) { - - array_pre_vbo.resize(surface->array_len * surface->stride); - vaw = array_pre_vbo.write(); - array_ptr = vaw.ptr(); - - if (surface->index_array_len) { - - index_array_pre_vbo.resize(surface->index_array_len * surface->array[VS::ARRAY_INDEX].size); - iaw = index_array_pre_vbo.write(); - index_array_ptr = iaw.ptr(); - } - - _surface_set_arrays(surface, array_ptr, index_array_ptr, p_arrays, true); - - } else { - - surface->array_local = (uint8_t *)memalloc(surface->array_len * surface->stride); - array_ptr = (uint8_t *)surface->array_local; - if (surface->index_array_len) { - surface->index_array_local = (uint8_t *)memalloc(index_array_len * surface->array[VS::ARRAY_INDEX].size); - index_array_ptr = (uint8_t *)surface->index_array_local; - } - - _surface_set_arrays(surface, array_ptr, index_array_ptr, p_arrays, true); - - if (mesh->morph_target_count) { - - surface->morph_targets_local = memnew_arr(Surface::MorphTarget, mesh->morph_target_count); - for (int i = 0; i < mesh->morph_target_count; i++) { - - surface->morph_targets_local[i].array = memnew_arr(uint8_t, surface->local_stride * surface->array_len); - surface->morph_targets_local[i].configured_format = surface->morph_format; - _surface_set_arrays(surface, surface->morph_targets_local[i].array, NULL, p_blend_shapes[i], false); - } - } - } - - /* create buffers!! */ - if (use_VBO) { - glGenBuffers(1, &surface->vertex_id); - ERR_FAIL_COND(surface->vertex_id == 0); - glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id); - glBufferData(GL_ARRAY_BUFFER, surface->array_len * surface->stride, array_ptr, GL_STATIC_DRAW); - glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind - if (surface->index_array_len) { - - glGenBuffers(1, &surface->index_id); - ERR_FAIL_COND(surface->index_id == 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, surface->index_id); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, index_array_len * surface->array[VS::ARRAY_INDEX].size, index_array_ptr, GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); //unbind - } - } - - mesh->surfaces.push_back(surface); -} - -Error RasterizerGLES2::_surface_set_arrays(Surface *p_surface, uint8_t *p_mem, uint8_t *p_index_mem, const Array &p_arrays, bool p_main) { - - uint32_t stride = p_main ? p_surface->stride : p_surface->local_stride; - - for (int ai = 0; ai < VS::ARRAY_MAX; ai++) { - if (ai >= p_arrays.size()) - break; - if (p_arrays[ai].get_type() == Variant::NIL) - continue; - Surface::ArrayData &a = p_surface->array[ai]; - - switch (ai) { - - case VS::ARRAY_VERTEX: { - - ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER); - - PoolVector<Vector3> array = p_arrays[ai]; - ERR_FAIL_COND_V(array.size() != p_surface->array_len, ERR_INVALID_PARAMETER); - - PoolVector<Vector3>::Read read = array.read(); - const Vector3 *src = read.ptr(); - - // setting vertices means regenerating the AABB - AABB aabb; - - float scale = 1; - - if (p_surface->array[VS::ARRAY_VERTEX].datatype == _GL_HALF_FLOAT_OES) { - - for (int i = 0; i < p_surface->array_len; i++) { - - uint16_t vector[3] = { make_half_float(src[i].x), make_half_float(src[i].y), make_half_float(src[i].z) }; - - copymem(&p_mem[a.ofs + i * stride], vector, a.size); - - if (i == 0) { - - aabb = AABB(src[i], Vector3()); - } else { - - aabb.expand_to(src[i]); - } - } - - } else { - for (int i = 0; i < p_surface->array_len; i++) { - - GLfloat vector[3] = { src[i].x, src[i].y, src[i].z }; - - copymem(&p_mem[a.ofs + i * stride], vector, a.size); - - if (i == 0) { - - aabb = AABB(src[i], Vector3()); - } else { - - aabb.expand_to(src[i]); - } - } - } - - if (p_main) { - p_surface->aabb = aabb; - p_surface->vertex_scale = scale; - } - - } break; - case VS::ARRAY_NORMAL: { - - ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER); - - PoolVector<Vector3> array = p_arrays[ai]; - ERR_FAIL_COND_V(array.size() != p_surface->array_len, ERR_INVALID_PARAMETER); - - PoolVector<Vector3>::Read read = array.read(); - const Vector3 *src = read.ptr(); - - // setting vertices means regenerating the AABB - - if (p_surface->array[VS::ARRAY_NORMAL].datatype == GL_BYTE) { - - for (int i = 0; i < p_surface->array_len; i++) { - - GLbyte vector[4] = { - CLAMP(src[i].x * 127, -128, 127), - CLAMP(src[i].y * 127, -128, 127), - CLAMP(src[i].z * 127, -128, 127), - 0, - }; - - copymem(&p_mem[a.ofs + i * stride], vector, a.size); - } - - } else { - for (int i = 0; i < p_surface->array_len; i++) { - - GLfloat vector[3] = { src[i].x, src[i].y, src[i].z }; - copymem(&p_mem[a.ofs + i * stride], vector, a.size); - } - } - - } break; - case VS::ARRAY_TANGENT: { - - ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER); - - PoolVector<real_t> array = p_arrays[ai]; - - ERR_FAIL_COND_V(array.size() != p_surface->array_len * 4, ERR_INVALID_PARAMETER); - - PoolVector<real_t>::Read read = array.read(); - const real_t *src = read.ptr(); - - if (p_surface->array[VS::ARRAY_TANGENT].datatype == GL_BYTE) { - - for (int i = 0; i < p_surface->array_len; i++) { - - GLbyte xyzw[4] = { - CLAMP(src[i * 4 + 0] * 127, -128, 127), - CLAMP(src[i * 4 + 1] * 127, -128, 127), - CLAMP(src[i * 4 + 2] * 127, -128, 127), - CLAMP(src[i * 4 + 3] * 127, -128, 127) - }; - - copymem(&p_mem[a.ofs + i * stride], xyzw, a.size); - } - - } else { - for (int i = 0; i < p_surface->array_len; i++) { - - GLfloat xyzw[4] = { - src[i * 4 + 0], - src[i * 4 + 1], - src[i * 4 + 2], - src[i * 4 + 3] - }; - - copymem(&p_mem[a.ofs + i * stride], xyzw, a.size); - } - } - - } break; - case VS::ARRAY_COLOR: { - - ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::COLOR_ARRAY, ERR_INVALID_PARAMETER); - - PoolVector<Color> array = p_arrays[ai]; - - ERR_FAIL_COND_V(array.size() != p_surface->array_len, ERR_INVALID_PARAMETER); - - PoolVector<Color>::Read read = array.read(); - const Color *src = read.ptr(); - bool alpha = false; - - for (int i = 0; i < p_surface->array_len; i++) { - - if (src[i].a < 0.98) // tolerate alpha a bit, for crappy exporters - alpha = true; - - uint8_t colors[4]; - - for (int j = 0; j < 4; j++) { - - colors[j] = CLAMP(int((src[i][j]) * 255.0), 0, 255); - } - - copymem(&p_mem[a.ofs + i * stride], colors, a.size); - } - - if (p_main) - p_surface->has_alpha = alpha; - - } break; - case VS::ARRAY_TEX_UV: - case VS::ARRAY_TEX_UV2: { - - ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::VECTOR2_ARRAY, ERR_INVALID_PARAMETER); - - PoolVector<Vector2> array = p_arrays[ai]; - - ERR_FAIL_COND_V(array.size() != p_surface->array_len, ERR_INVALID_PARAMETER); - - PoolVector<Vector2>::Read read = array.read(); - - const Vector2 *src = read.ptr(); - float scale = 1.0; - - if (p_surface->array[ai].datatype == _GL_HALF_FLOAT_OES) { - - for (int i = 0; i < p_surface->array_len; i++) { - - uint16_t uv[2] = { make_half_float(src[i].x), make_half_float(src[i].y) }; - copymem(&p_mem[a.ofs + i * stride], uv, a.size); - } - - } else { - for (int i = 0; i < p_surface->array_len; i++) { - - GLfloat uv[2] = { src[i].x, src[i].y }; - - copymem(&p_mem[a.ofs + i * stride], uv, a.size); - } - } - - if (p_main) { - - if (ai == VS::ARRAY_TEX_UV) { - - p_surface->uv_scale = scale; - } - if (ai == VS::ARRAY_TEX_UV2) { - - p_surface->uv2_scale = scale; - } - } - - } break; - case VS::ARRAY_WEIGHTS: { - - ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER); - - PoolVector<real_t> array = p_arrays[ai]; - - ERR_FAIL_COND_V(array.size() != p_surface->array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER); - - PoolVector<real_t>::Read read = array.read(); - - const real_t *src = read.ptr(); - - if (p_surface->array[VS::ARRAY_WEIGHTS].datatype == GL_UNSIGNED_SHORT) { - - for (int i = 0; i < p_surface->array_len; i++) { - - GLushort data[VS::ARRAY_WEIGHTS_SIZE]; - for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) { - data[j] = CLAMP(src[i * VS::ARRAY_WEIGHTS_SIZE + j] * 65535, 0, 65535); - } - - copymem(&p_mem[a.ofs + i * stride], data, a.size); - } - } else { - - for (int i = 0; i < p_surface->array_len; i++) { - - GLfloat data[VS::ARRAY_WEIGHTS_SIZE]; - for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) { - data[j] = src[i * VS::ARRAY_WEIGHTS_SIZE + j]; - } - - copymem(&p_mem[a.ofs + i * stride], data, a.size); - } - } - - } break; - case VS::ARRAY_BONES: { - - ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER); - - PoolVector<int> array = p_arrays[ai]; - - ERR_FAIL_COND_V(array.size() != p_surface->array_len * VS::ARRAY_WEIGHTS_SIZE, ERR_INVALID_PARAMETER); - - PoolVector<int>::Read read = array.read(); - - const int *src = read.ptr(); - - p_surface->max_bone = 0; - - if (p_surface->array[VS::ARRAY_BONES].datatype == GL_UNSIGNED_BYTE) { - - for (int i = 0; i < p_surface->array_len; i++) { - - GLubyte data[VS::ARRAY_WEIGHTS_SIZE]; - for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) { - data[j] = CLAMP(src[i * VS::ARRAY_WEIGHTS_SIZE + j], 0, 255); - p_surface->max_bone = MAX(data[j], p_surface->max_bone); - } - - copymem(&p_mem[a.ofs + i * stride], data, a.size); - } - - } else { - for (int i = 0; i < p_surface->array_len; i++) { - - GLushort data[VS::ARRAY_WEIGHTS_SIZE]; - for (int j = 0; j < VS::ARRAY_WEIGHTS_SIZE; j++) { - data[j] = src[i * VS::ARRAY_WEIGHTS_SIZE + j]; - p_surface->max_bone = MAX(data[j], p_surface->max_bone); - } - - copymem(&p_mem[a.ofs + i * stride], data, a.size); - } - } - - } break; - case VS::ARRAY_INDEX: { - - ERR_FAIL_COND_V(p_surface->index_array_len <= 0, ERR_INVALID_DATA); - ERR_FAIL_COND_V(p_arrays[ai].get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER); - - PoolVector<int> indices = p_arrays[ai]; - ERR_FAIL_COND_V(indices.size() == 0, ERR_INVALID_PARAMETER); - ERR_FAIL_COND_V(indices.size() != p_surface->index_array_len, ERR_INVALID_PARAMETER); - - /* determine wether using 16 or 32 bits indices */ - - PoolVector<int>::Read read = indices.read(); - const int *src = read.ptr(); - - for (int i = 0; i < p_surface->index_array_len; i++) { - - if (a.size == 2) { - uint16_t v = src[i]; - - copymem(&p_index_mem[i * a.size], &v, a.size); - } else { - uint32_t v = src[i]; - - copymem(&p_index_mem[i * a.size], &v, a.size); - } - } - - } break; - - default: { ERR_FAIL_V(ERR_INVALID_PARAMETER); } - } - - p_surface->configured_format |= (1 << ai); - } - - if (p_surface->format & VS::ARRAY_FORMAT_BONES) { - //create AABBs for each detected bone - int total_bones = p_surface->max_bone + 1; - if (p_main) { - p_surface->skeleton_bone_aabb.resize(total_bones); - p_surface->skeleton_bone_used.resize(total_bones); - for (int i = 0; i < total_bones; i++) - p_surface->skeleton_bone_used[i] = false; - } - PoolVector<Vector3> vertices = p_arrays[VS::ARRAY_VERTEX]; - PoolVector<int> bones = p_arrays[VS::ARRAY_BONES]; - PoolVector<float> weights = p_arrays[VS::ARRAY_WEIGHTS]; - - bool any_valid = false; - - if (vertices.size() && bones.size() == vertices.size() * 4 && weights.size() == bones.size()) { - //print_line("MAKING SKELETHONG"); - int vs = vertices.size(); - PoolVector<Vector3>::Read rv = vertices.read(); - PoolVector<int>::Read rb = bones.read(); - PoolVector<float>::Read rw = weights.read(); - - Vector<bool> first; - first.resize(total_bones); - for (int i = 0; i < total_bones; i++) { - first[i] = p_main; - } - AABB *bptr = p_surface->skeleton_bone_aabb.ptr(); - bool *fptr = first.ptr(); - bool *usedptr = p_surface->skeleton_bone_used.ptr(); - - for (int i = 0; i < vs; i++) { - - Vector3 v = rv[i]; - for (int j = 0; j < 4; j++) { - - int idx = rb[i * 4 + j]; - float w = rw[i * 4 + j]; - if (w == 0) - continue; //break; - ERR_FAIL_INDEX_V(idx, total_bones, ERR_INVALID_DATA); - - if (fptr[idx]) { - bptr[idx].pos = v; - fptr[idx] = false; - any_valid = true; - } else { - bptr[idx].expand_to(v); - } - usedptr[idx] = true; - } - } - } - - if (p_main && !any_valid) { - - p_surface->skeleton_bone_aabb.clear(); - p_surface->skeleton_bone_used.clear(); - } - } - - return OK; -} - -void RasterizerGLES2::mesh_add_custom_surface(RID p_mesh, const Variant &p_dat) { - - ERR_EXPLAIN("OpenGL Rasterizer does not support custom surfaces. Running on wrong platform?"); - ERR_FAIL(); -} - -Array RasterizerGLES2::mesh_get_surface_arrays(RID p_mesh, int p_surface) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, Array()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Array()); - Surface *surface = mesh->surfaces[p_surface]; - ERR_FAIL_COND_V(!surface, Array()); - - return surface->data; -} -Array RasterizerGLES2::mesh_get_surface_morph_arrays(RID p_mesh, int p_surface) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, Array()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Array()); - Surface *surface = mesh->surfaces[p_surface]; - ERR_FAIL_COND_V(!surface, Array()); - - return surface->morph_data; -} - -void RasterizerGLES2::mesh_set_morph_target_count(RID p_mesh, int p_amount) { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND(!mesh); - ERR_FAIL_COND(mesh->surfaces.size() != 0); - - mesh->morph_target_count = p_amount; -} - -int RasterizerGLES2::mesh_get_morph_target_count(RID p_mesh) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, -1); - - return mesh->morph_target_count; -} - -void RasterizerGLES2::mesh_set_morph_target_mode(RID p_mesh, VS::MorphTargetMode p_mode) { - - ERR_FAIL_INDEX(p_mode, 2); - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND(!mesh); - - mesh->morph_target_mode = p_mode; -} - -VS::MorphTargetMode RasterizerGLES2::mesh_get_morph_target_mode(RID p_mesh) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, VS::MORPH_MODE_NORMALIZED); - - return mesh->morph_target_mode; -} - -void RasterizerGLES2::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material, bool p_owned) { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND(!mesh); - ERR_FAIL_INDEX(p_surface, mesh->surfaces.size()); - Surface *surface = mesh->surfaces[p_surface]; - ERR_FAIL_COND(!surface); - - if (surface->material_owned && surface->material.is_valid()) - free(surface->material); - - surface->material_owned = p_owned; - - surface->material = p_material; -} - -RID RasterizerGLES2::mesh_surface_get_material(RID p_mesh, int p_surface) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, RID()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), RID()); - Surface *surface = mesh->surfaces[p_surface]; - ERR_FAIL_COND_V(!surface, RID()); - - return surface->material; -} - -int RasterizerGLES2::mesh_surface_get_array_len(RID p_mesh, int p_surface) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, -1); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), -1); - Surface *surface = mesh->surfaces[p_surface]; - ERR_FAIL_COND_V(!surface, -1); - - return surface->array_len; -} -int RasterizerGLES2::mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, -1); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), -1); - Surface *surface = mesh->surfaces[p_surface]; - ERR_FAIL_COND_V(!surface, -1); - - return surface->index_array_len; -} -uint32_t RasterizerGLES2::mesh_surface_get_format(RID p_mesh, int p_surface) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, 0); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), 0); - Surface *surface = mesh->surfaces[p_surface]; - ERR_FAIL_COND_V(!surface, 0); - - return surface->format; -} -VS::PrimitiveType RasterizerGLES2::mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, VS::PRIMITIVE_POINTS); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), VS::PRIMITIVE_POINTS); - Surface *surface = mesh->surfaces[p_surface]; - ERR_FAIL_COND_V(!surface, VS::PRIMITIVE_POINTS); - - return surface->primitive; -} - -void RasterizerGLES2::mesh_remove_surface(RID p_mesh, int p_index) { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND(!mesh); - ERR_FAIL_INDEX(p_index, mesh->surfaces.size()); - Surface *surface = mesh->surfaces[p_index]; - ERR_FAIL_COND(!surface); - - if (surface->vertex_id) - glDeleteBuffers(1, &surface->vertex_id); - if (surface->index_id) - glDeleteBuffers(1, &surface->index_id); - - if (mesh->morph_target_count) { - for (int i = 0; i < mesh->morph_target_count; i++) - memfree(surface->morph_targets_local[i].array); - memfree(surface->morph_targets_local); - } - - memdelete(mesh->surfaces[p_index]); - mesh->surfaces.remove(p_index); -} -int RasterizerGLES2::mesh_get_surface_count(RID p_mesh) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, -1); - - return mesh->surfaces.size(); -} - -AABB RasterizerGLES2::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, AABB()); - - if (mesh->custom_aabb != AABB()) - return mesh->custom_aabb; - - Skeleton *sk = NULL; - if (p_skeleton.is_valid()) - sk = skeleton_owner.get(p_skeleton); - - AABB aabb; - if (sk && sk->bones.size() != 0) { - - for (int i = 0; i < mesh->surfaces.size(); i++) { - - AABB laabb; - if (mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES && mesh->surfaces[i]->skeleton_bone_aabb.size()) { - - int bs = mesh->surfaces[i]->skeleton_bone_aabb.size(); - const AABB *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr(); - const bool *skused = mesh->surfaces[i]->skeleton_bone_used.ptr(); - - int sbs = sk->bones.size(); - ERR_CONTINUE(bs > sbs); - Skeleton::Bone *skb = sk->bones.ptr(); - - bool first = true; - for (int j = 0; j < bs; j++) { - - if (!skused[j]) - continue; - AABB baabb = skb[j].transform_aabb(skbones[j]); - if (first) { - laabb = baabb; - first = false; - } else { - laabb.merge_with(baabb); - } - } - - } else { - - laabb = mesh->surfaces[i]->aabb; - } - - if (i == 0) - aabb = laabb; - else - aabb.merge_with(laabb); - } - } else { - - for (int i = 0; i < mesh->surfaces.size(); i++) { - - if (i == 0) - aabb = mesh->surfaces[i]->aabb; - else - aabb.merge_with(mesh->surfaces[i]->aabb); - } - } - - return aabb; -} - -void RasterizerGLES2::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND(!mesh); - - mesh->custom_aabb = p_aabb; -} - -AABB RasterizerGLES2::mesh_get_custom_aabb(RID p_mesh) const { - - const Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, AABB()); - - return mesh->custom_aabb; -} -/* MULTIMESH API */ - -RID RasterizerGLES2::multimesh_create() { - - return multimesh_owner.make_rid(memnew(MultiMesh)); -} - -void RasterizerGLES2::multimesh_set_instance_count(RID p_multimesh, int p_count) { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND(!multimesh); - - //multimesh->elements.clear(); // make sure to delete everything, so it "fails" in all implementations - - if (use_texture_instancing) { - - if (next_power_of_2(p_count) != next_power_of_2(multimesh->elements.size())) { - if (multimesh->tex_id) { - glDeleteTextures(1, &multimesh->tex_id); - multimesh->tex_id = 0; - } - - if (p_count) { - - uint32_t po2 = next_power_of_2(p_count); - if (po2 & 0xAAAAAAAA) { - //half width - - multimesh->tw = Math::sqrt(po2 * 2); - multimesh->th = multimesh->tw / 2; - } else { - - multimesh->tw = Math::sqrt(po2); - multimesh->th = multimesh->tw; - } - multimesh->tw *= 4; - if (multimesh->th == 0) - multimesh->th = 1; - - glGenTextures(1, &multimesh->tex_id); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, multimesh->tex_id); - -#ifdef GLEW_ENABLED - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, multimesh->tw, multimesh->th, 0, GL_RGBA, GL_FLOAT, NULL); -#else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, multimesh->tw, multimesh->th, 0, GL_RGBA, GL_FLOAT, NULL); -#endif - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - //multimesh->pixel_size=1.0/ps; - - glBindTexture(GL_TEXTURE_2D, 0); - } - } - - if (!multimesh->dirty_list.in_list()) { - _multimesh_dirty_list.add(&multimesh->dirty_list); - } - } - - multimesh->elements.resize(p_count); -} -int RasterizerGLES2::multimesh_get_instance_count(RID p_multimesh) const { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND_V(!multimesh, -1); - - return multimesh->elements.size(); -} - -void RasterizerGLES2::multimesh_set_mesh(RID p_multimesh, RID p_mesh) { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND(!multimesh); - - multimesh->mesh = p_mesh; -} -void RasterizerGLES2::multimesh_set_aabb(RID p_multimesh, const AABB &p_aabb) { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND(!multimesh); - multimesh->aabb = p_aabb; -} -void RasterizerGLES2::multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform) { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND(!multimesh); - ERR_FAIL_INDEX(p_index, multimesh->elements.size()); - MultiMesh::Element &e = multimesh->elements[p_index]; - - e.matrix[0] = p_transform.basis.elements[0][0]; - e.matrix[1] = p_transform.basis.elements[1][0]; - e.matrix[2] = p_transform.basis.elements[2][0]; - e.matrix[3] = 0; - e.matrix[4] = p_transform.basis.elements[0][1]; - e.matrix[5] = p_transform.basis.elements[1][1]; - e.matrix[6] = p_transform.basis.elements[2][1]; - e.matrix[7] = 0; - e.matrix[8] = p_transform.basis.elements[0][2]; - e.matrix[9] = p_transform.basis.elements[1][2]; - e.matrix[10] = p_transform.basis.elements[2][2]; - e.matrix[11] = 0; - e.matrix[12] = p_transform.origin.x; - e.matrix[13] = p_transform.origin.y; - e.matrix[14] = p_transform.origin.z; - e.matrix[15] = 1; - - if (!multimesh->dirty_list.in_list()) { - _multimesh_dirty_list.add(&multimesh->dirty_list); - } -} -void RasterizerGLES2::multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND(!multimesh) - ERR_FAIL_INDEX(p_index, multimesh->elements.size()); - MultiMesh::Element &e = multimesh->elements[p_index]; - e.color[0] = CLAMP(p_color.r * 255, 0, 255); - e.color[1] = CLAMP(p_color.g * 255, 0, 255); - e.color[2] = CLAMP(p_color.b * 255, 0, 255); - e.color[3] = CLAMP(p_color.a * 255, 0, 255); - - if (!multimesh->dirty_list.in_list()) { - _multimesh_dirty_list.add(&multimesh->dirty_list); - } -} - -RID RasterizerGLES2::multimesh_get_mesh(RID p_multimesh) const { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND_V(!multimesh, RID()); - - return multimesh->mesh; -} -AABB RasterizerGLES2::multimesh_get_aabb(RID p_multimesh) const { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND_V(!multimesh, AABB()); - - return multimesh->aabb; -} - -Transform RasterizerGLES2::multimesh_instance_get_transform(RID p_multimesh, int p_index) const { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND_V(!multimesh, Transform()); - - ERR_FAIL_INDEX_V(p_index, multimesh->elements.size(), Transform()); - MultiMesh::Element &e = multimesh->elements[p_index]; - - Transform tr; - - tr.basis.elements[0][0] = e.matrix[0]; - tr.basis.elements[1][0] = e.matrix[1]; - tr.basis.elements[2][0] = e.matrix[2]; - tr.basis.elements[0][1] = e.matrix[4]; - tr.basis.elements[1][1] = e.matrix[5]; - tr.basis.elements[2][1] = e.matrix[6]; - tr.basis.elements[0][2] = e.matrix[8]; - tr.basis.elements[1][2] = e.matrix[9]; - tr.basis.elements[2][2] = e.matrix[10]; - tr.origin.x = e.matrix[12]; - tr.origin.y = e.matrix[13]; - tr.origin.z = e.matrix[14]; - - return tr; -} -Color RasterizerGLES2::multimesh_instance_get_color(RID p_multimesh, int p_index) const { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND_V(!multimesh, Color()); - ERR_FAIL_INDEX_V(p_index, multimesh->elements.size(), Color()); - MultiMesh::Element &e = multimesh->elements[p_index]; - Color c; - c.r = e.color[0] / 255.0; - c.g = e.color[1] / 255.0; - c.b = e.color[2] / 255.0; - c.a = e.color[3] / 255.0; - - return c; -} - -void RasterizerGLES2::multimesh_set_visible_instances(RID p_multimesh, int p_visible) { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND(!multimesh); - multimesh->visible = p_visible; -} - -int RasterizerGLES2::multimesh_get_visible_instances(RID p_multimesh) const { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND_V(!multimesh, -1); - return multimesh->visible; -} - -/* IMMEDIATE API */ - -RID RasterizerGLES2::immediate_create() { - - Immediate *im = memnew(Immediate); - return immediate_owner.make_rid(im); -} - -void RasterizerGLES2::immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture) { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!im); - ERR_FAIL_COND(im->building); - - Immediate::Chunk ic; - ic.texture = p_texture; - ic.primitive = p_rimitive; - im->chunks.push_back(ic); - im->mask = 0; - im->building = true; -} -void RasterizerGLES2::immediate_vertex(RID p_immediate, const Vector3 &p_vertex) { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!im); - ERR_FAIL_COND(!im->building); - - Immediate::Chunk *c = &im->chunks.back()->get(); - - if (c->vertices.empty() && im->chunks.size() == 1) { - - im->aabb.pos = p_vertex; - im->aabb.size = Vector3(); - } else { - im->aabb.expand_to(p_vertex); - } - - if (im->mask & VS::ARRAY_FORMAT_NORMAL) - c->normals.push_back(chunk_normal); - if (im->mask & VS::ARRAY_FORMAT_TANGENT) - c->tangents.push_back(chunk_tangent); - if (im->mask & VS::ARRAY_FORMAT_COLOR) - c->colors.push_back(chunk_color); - if (im->mask & VS::ARRAY_FORMAT_TEX_UV) - c->uvs.push_back(chunk_uv); - if (im->mask & VS::ARRAY_FORMAT_TEX_UV2) - c->uvs2.push_back(chunk_uv2); - im->mask |= VS::ARRAY_FORMAT_VERTEX; - c->vertices.push_back(p_vertex); -} - -void RasterizerGLES2::immediate_normal(RID p_immediate, const Vector3 &p_normal) { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!im); - ERR_FAIL_COND(!im->building); - - im->mask |= VS::ARRAY_FORMAT_NORMAL; - chunk_normal = p_normal; -} -void RasterizerGLES2::immediate_tangent(RID p_immediate, const Plane &p_tangent) { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!im); - ERR_FAIL_COND(!im->building); - - im->mask |= VS::ARRAY_FORMAT_TANGENT; - chunk_tangent = p_tangent; -} -void RasterizerGLES2::immediate_color(RID p_immediate, const Color &p_color) { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!im); - ERR_FAIL_COND(!im->building); - - im->mask |= VS::ARRAY_FORMAT_COLOR; - chunk_color = p_color; -} -void RasterizerGLES2::immediate_uv(RID p_immediate, const Vector2 &tex_uv) { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!im); - ERR_FAIL_COND(!im->building); - - im->mask |= VS::ARRAY_FORMAT_TEX_UV; - chunk_uv = tex_uv; -} -void RasterizerGLES2::immediate_uv2(RID p_immediate, const Vector2 &tex_uv) { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!im); - ERR_FAIL_COND(!im->building); - - im->mask |= VS::ARRAY_FORMAT_TEX_UV2; - chunk_uv2 = tex_uv; -} - -void RasterizerGLES2::immediate_end(RID p_immediate) { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!im); - ERR_FAIL_COND(!im->building); - - im->building = false; -} -void RasterizerGLES2::immediate_clear(RID p_immediate) { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!im); - ERR_FAIL_COND(im->building); - - im->chunks.clear(); -} - -AABB RasterizerGLES2::immediate_get_aabb(RID p_immediate) const { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND_V(!im, AABB()); - return im->aabb; -} - -void RasterizerGLES2::immediate_set_material(RID p_immediate, RID p_material) { - - Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!im); - im->material = p_material; -} - -RID RasterizerGLES2::immediate_get_material(RID p_immediate) const { - - const Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND_V(!im, RID()); - return im->material; -} - -/* PARTICLES API */ - -RID RasterizerGLES2::particles_create() { - - Particles *particles = memnew(Particles); - ERR_FAIL_COND_V(!particles, RID()); - return particles_owner.make_rid(particles); -} - -void RasterizerGLES2::particles_set_amount(RID p_particles, int p_amount) { - - ERR_FAIL_COND(p_amount < 1); - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - particles->data.amount = p_amount; -} - -int RasterizerGLES2::particles_get_amount(RID p_particles) const { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, -1); - return particles->data.amount; -} - -void RasterizerGLES2::particles_set_emitting(RID p_particles, bool p_emitting) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - particles->data.emitting = p_emitting; -} -bool RasterizerGLES2::particles_is_emitting(RID p_particles) const { - - const Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, false); - return particles->data.emitting; -} - -void RasterizerGLES2::particles_set_visibility_aabb(RID p_particles, const AABB &p_visibility) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - particles->data.visibility_aabb = p_visibility; -} - -void RasterizerGLES2::particles_set_emission_half_extents(RID p_particles, const Vector3 &p_half_extents) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - - particles->data.emission_half_extents = p_half_extents; -} -Vector3 RasterizerGLES2::particles_get_emission_half_extents(RID p_particles) const { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, Vector3()); - - return particles->data.emission_half_extents; -} - -void RasterizerGLES2::particles_set_emission_base_velocity(RID p_particles, const Vector3 &p_base_velocity) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - - particles->data.emission_base_velocity = p_base_velocity; -} - -Vector3 RasterizerGLES2::particles_get_emission_base_velocity(RID p_particles) const { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, Vector3()); - - return particles->data.emission_base_velocity; -} - -void RasterizerGLES2::particles_set_emission_points(RID p_particles, const PoolVector<Vector3> &p_points) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - - particles->data.emission_points = p_points; -} - -PoolVector<Vector3> RasterizerGLES2::particles_get_emission_points(RID p_particles) const { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, PoolVector<Vector3>()); - - return particles->data.emission_points; -} - -void RasterizerGLES2::particles_set_gravity_normal(RID p_particles, const Vector3 &p_normal) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - - particles->data.gravity_normal = p_normal; -} -Vector3 RasterizerGLES2::particles_get_gravity_normal(RID p_particles) const { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, Vector3()); - - return particles->data.gravity_normal; -} - -AABB RasterizerGLES2::particles_get_visibility_aabb(RID p_particles) const { - - const Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, AABB()); - return particles->data.visibility_aabb; -} - -void RasterizerGLES2::particles_set_variable(RID p_particles, VS::ParticleVariable p_variable, float p_value) { - - ERR_FAIL_INDEX(p_variable, VS::PARTICLE_VAR_MAX); - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - particles->data.particle_vars[p_variable] = p_value; -} -float RasterizerGLES2::particles_get_variable(RID p_particles, VS::ParticleVariable p_variable) const { - - const Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, -1); - return particles->data.particle_vars[p_variable]; -} - -void RasterizerGLES2::particles_set_randomness(RID p_particles, VS::ParticleVariable p_variable, float p_randomness) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - particles->data.particle_randomness[p_variable] = p_randomness; -} -float RasterizerGLES2::particles_get_randomness(RID p_particles, VS::ParticleVariable p_variable) const { - - const Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, -1); - return particles->data.particle_randomness[p_variable]; -} - -void RasterizerGLES2::particles_set_color_phases(RID p_particles, int p_phases) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - ERR_FAIL_COND(p_phases < 0 || p_phases > VS::MAX_PARTICLE_COLOR_PHASES); - particles->data.color_phase_count = p_phases; -} -int RasterizerGLES2::particles_get_color_phases(RID p_particles) const { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, -1); - return particles->data.color_phase_count; -} - -void RasterizerGLES2::particles_set_color_phase_pos(RID p_particles, int p_phase, float p_pos) { - - ERR_FAIL_INDEX(p_phase, VS::MAX_PARTICLE_COLOR_PHASES); - if (p_pos < 0.0) - p_pos = 0.0; - if (p_pos > 1.0) - p_pos = 1.0; - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - particles->data.color_phases[p_phase].pos = p_pos; -} -float RasterizerGLES2::particles_get_color_phase_pos(RID p_particles, int p_phase) const { - - ERR_FAIL_INDEX_V(p_phase, VS::MAX_PARTICLE_COLOR_PHASES, -1.0); - - const Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, -1); - return particles->data.color_phases[p_phase].pos; -} - -void RasterizerGLES2::particles_set_color_phase_color(RID p_particles, int p_phase, const Color &p_color) { - - ERR_FAIL_INDEX(p_phase, VS::MAX_PARTICLE_COLOR_PHASES); - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - particles->data.color_phases[p_phase].color = p_color; - - //update alpha - particles->has_alpha = false; - for (int i = 0; i < VS::MAX_PARTICLE_COLOR_PHASES; i++) { - if (particles->data.color_phases[i].color.a < 0.99) - particles->has_alpha = true; - } -} - -Color RasterizerGLES2::particles_get_color_phase_color(RID p_particles, int p_phase) const { - - ERR_FAIL_INDEX_V(p_phase, VS::MAX_PARTICLE_COLOR_PHASES, Color()); - - const Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, Color()); - return particles->data.color_phases[p_phase].color; -} - -void RasterizerGLES2::particles_set_attractors(RID p_particles, int p_attractors) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - ERR_FAIL_COND(p_attractors < 0 || p_attractors > VisualServer::MAX_PARTICLE_ATTRACTORS); - particles->data.attractor_count = p_attractors; -} -int RasterizerGLES2::particles_get_attractors(RID p_particles) const { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, -1); - return particles->data.attractor_count; -} - -void RasterizerGLES2::particles_set_attractor_pos(RID p_particles, int p_attractor, const Vector3 &p_pos) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - ERR_FAIL_INDEX(p_attractor, particles->data.attractor_count); - particles->data.attractors[p_attractor].pos = p_pos; -} -Vector3 RasterizerGLES2::particles_get_attractor_pos(RID p_particles, int p_attractor) const { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, Vector3()); - ERR_FAIL_INDEX_V(p_attractor, particles->data.attractor_count, Vector3()); - return particles->data.attractors[p_attractor].pos; -} - -void RasterizerGLES2::particles_set_attractor_strength(RID p_particles, int p_attractor, float p_force) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - ERR_FAIL_INDEX(p_attractor, particles->data.attractor_count); - particles->data.attractors[p_attractor].force = p_force; -} - -float RasterizerGLES2::particles_get_attractor_strength(RID p_particles, int p_attractor) const { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, 0); - ERR_FAIL_INDEX_V(p_attractor, particles->data.attractor_count, 0); - return particles->data.attractors[p_attractor].force; -} - -void RasterizerGLES2::particles_set_material(RID p_particles, RID p_material, bool p_owned) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - if (particles->material_owned && particles->material.is_valid()) - free(particles->material); - - particles->material_owned = p_owned; - - particles->material = p_material; -} -RID RasterizerGLES2::particles_get_material(RID p_particles) const { - - const Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, RID()); - return particles->material; -} - -void RasterizerGLES2::particles_set_use_local_coordinates(RID p_particles, bool p_enable) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - particles->data.local_coordinates = p_enable; -} - -bool RasterizerGLES2::particles_is_using_local_coordinates(RID p_particles) const { - - const Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, false); - return particles->data.local_coordinates; -} -bool RasterizerGLES2::particles_has_height_from_velocity(RID p_particles) const { - - const Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, false); - return particles->data.height_from_velocity; -} - -void RasterizerGLES2::particles_set_height_from_velocity(RID p_particles, bool p_enable) { - - Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND(!particles); - particles->data.height_from_velocity = p_enable; -} - -AABB RasterizerGLES2::particles_get_aabb(RID p_particles) const { - - const Particles *particles = particles_owner.get(p_particles); - ERR_FAIL_COND_V(!particles, AABB()); - return particles->data.visibility_aabb; -} - -/* SKELETON API */ - -RID RasterizerGLES2::skeleton_create() { - - Skeleton *skeleton = memnew(Skeleton); - ERR_FAIL_COND_V(!skeleton, RID()); - return skeleton_owner.make_rid(skeleton); -} -void RasterizerGLES2::skeleton_resize(RID p_skeleton, int p_bones) { - - Skeleton *skeleton = skeleton_owner.get(p_skeleton); - ERR_FAIL_COND(!skeleton); - if (p_bones == skeleton->bones.size()) { - return; - }; - if (use_hw_skeleton_xform) { - - if (next_power_of_2(p_bones) != next_power_of_2(skeleton->bones.size())) { - if (skeleton->tex_id) { - glDeleteTextures(1, &skeleton->tex_id); - skeleton->tex_id = 0; - } - - if (p_bones) { - - glGenTextures(1, &skeleton->tex_id); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, skeleton->tex_id); - int ps = next_power_of_2(p_bones * 3); -#ifdef GLEW_ENABLED - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, ps, 1, 0, GL_RGBA, GL_FLOAT, skel_default.ptr()); -#else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ps, 1, 0, GL_RGBA, GL_FLOAT, skel_default.ptr()); -#endif - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - skeleton->pixel_size = 1.0 / ps; - - glBindTexture(GL_TEXTURE_2D, 0); - } - } - - if (!skeleton->dirty_list.in_list()) { - _skeleton_dirty_list.add(&skeleton->dirty_list); - } - } - skeleton->bones.resize(p_bones); -} -int RasterizerGLES2::skeleton_get_bone_count(RID p_skeleton) const { - - Skeleton *skeleton = skeleton_owner.get(p_skeleton); - ERR_FAIL_COND_V(!skeleton, -1); - return skeleton->bones.size(); -} -void RasterizerGLES2::skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform) { - - Skeleton *skeleton = skeleton_owner.get(p_skeleton); - ERR_FAIL_COND(!skeleton); - ERR_FAIL_INDEX(p_bone, skeleton->bones.size()); - - Skeleton::Bone &b = skeleton->bones[p_bone]; - - b.mtx[0][0] = p_transform.basis[0][0]; - b.mtx[0][1] = p_transform.basis[1][0]; - b.mtx[0][2] = p_transform.basis[2][0]; - b.mtx[1][0] = p_transform.basis[0][1]; - b.mtx[1][1] = p_transform.basis[1][1]; - b.mtx[1][2] = p_transform.basis[2][1]; - b.mtx[2][0] = p_transform.basis[0][2]; - b.mtx[2][1] = p_transform.basis[1][2]; - b.mtx[2][2] = p_transform.basis[2][2]; - b.mtx[3][0] = p_transform.origin[0]; - b.mtx[3][1] = p_transform.origin[1]; - b.mtx[3][2] = p_transform.origin[2]; - - if (skeleton->tex_id) { - if (!skeleton->dirty_list.in_list()) { - _skeleton_dirty_list.add(&skeleton->dirty_list); - } - } -} - -Transform RasterizerGLES2::skeleton_bone_get_transform(RID p_skeleton, int p_bone) { - - Skeleton *skeleton = skeleton_owner.get(p_skeleton); - ERR_FAIL_COND_V(!skeleton, Transform()); - ERR_FAIL_INDEX_V(p_bone, skeleton->bones.size(), Transform()); - - const Skeleton::Bone &b = skeleton->bones[p_bone]; - - Transform t; - t.basis[0][0] = b.mtx[0][0]; - t.basis[1][0] = b.mtx[0][1]; - t.basis[2][0] = b.mtx[0][2]; - t.basis[0][1] = b.mtx[1][0]; - t.basis[1][1] = b.mtx[1][1]; - t.basis[2][1] = b.mtx[1][2]; - t.basis[0][2] = b.mtx[2][0]; - t.basis[1][2] = b.mtx[2][1]; - t.basis[2][2] = b.mtx[2][2]; - t.origin[0] = b.mtx[3][0]; - t.origin[1] = b.mtx[3][1]; - t.origin[2] = b.mtx[3][2]; - - return t; -} - -/* LIGHT API */ - -RID RasterizerGLES2::light_create(VS::LightType p_type) { - - Light *light = memnew(Light); - light->type = p_type; - return light_owner.make_rid(light); -} - -VS::LightType RasterizerGLES2::light_get_type(RID p_light) const { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_OMNI); - return light->type; -} - -void RasterizerGLES2::light_set_color(RID p_light, VS::LightColor p_type, const Color &p_color) { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND(!light); - ERR_FAIL_INDEX(p_type, 3); - light->colors[p_type] = p_color; -} -Color RasterizerGLES2::light_get_color(RID p_light, VS::LightColor p_type) const { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, Color()); - ERR_FAIL_INDEX_V(p_type, 3, Color()); - return light->colors[p_type]; -} - -void RasterizerGLES2::light_set_shadow(RID p_light, bool p_enabled) { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND(!light); - light->shadow_enabled = p_enabled; -} - -bool RasterizerGLES2::light_has_shadow(RID p_light) const { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, false); - return light->shadow_enabled; -} - -void RasterizerGLES2::light_set_volumetric(RID p_light, bool p_enabled) { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND(!light); - light->volumetric_enabled = p_enabled; -} -bool RasterizerGLES2::light_is_volumetric(RID p_light) const { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, false); - return light->volumetric_enabled; -} - -void RasterizerGLES2::light_set_projector(RID p_light, RID p_texture) { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND(!light); - light->projector = p_texture; -} -RID RasterizerGLES2::light_get_projector(RID p_light) const { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, RID()); - return light->projector; -} - -void RasterizerGLES2::light_set_var(RID p_light, VS::LightParam p_var, float p_value) { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND(!light); - ERR_FAIL_INDEX(p_var, VS::LIGHT_PARAM_MAX); - - light->vars[p_var] = p_value; -} -float RasterizerGLES2::light_get_var(RID p_light, VS::LightParam p_var) const { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, 0); - - ERR_FAIL_INDEX_V(p_var, VS::LIGHT_PARAM_MAX, 0); - - return light->vars[p_var]; -} - -void RasterizerGLES2::light_set_operator(RID p_light, VS::LightOp p_op){ - -}; - -VS::LightOp RasterizerGLES2::light_get_operator(RID p_light) const { - - return VS::LightOp(); -}; - -void RasterizerGLES2::light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND(!light); - - light->omni_shadow_mode = p_mode; -} -VS::LightOmniShadowMode RasterizerGLES2::light_omni_get_shadow_mode(RID p_light) const { - - const Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_OMNI_SHADOW_DEFAULT); - - return light->omni_shadow_mode; -} - -void RasterizerGLES2::light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND(!light); - - light->directional_shadow_mode = p_mode; -} - -VS::LightDirectionalShadowMode RasterizerGLES2::light_directional_get_shadow_mode(RID p_light) const { - - const Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL); - - return light->directional_shadow_mode; -} - -void RasterizerGLES2::light_directional_set_shadow_param(RID p_light, VS::LightDirectionalShadowParam p_param, float p_value) { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND(!light); - - light->directional_shadow_param[p_param] = p_value; -} - -float RasterizerGLES2::light_directional_get_shadow_param(RID p_light, VS::LightDirectionalShadowParam p_param) const { - - const Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, 0); - return light->directional_shadow_param[p_param]; -} - -AABB RasterizerGLES2::light_get_aabb(RID p_light) const { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, AABB()); - - switch (light->type) { - - case VS::LIGHT_SPOT: { - - float len = light->vars[VS::LIGHT_PARAM_RADIUS]; - float size = Math::tan(Math::deg2rad(light->vars[VS::LIGHT_PARAM_SPOT_ANGLE])) * len; - return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); - } break; - case VS::LIGHT_OMNI: { - - float r = light->vars[VS::LIGHT_PARAM_RADIUS]; - return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2); - } break; - case VS::LIGHT_DIRECTIONAL: { - - return AABB(); - } break; - default: {} - } - - ERR_FAIL_V(AABB()); -} - -RID RasterizerGLES2::light_instance_create(RID p_light) { - - Light *light = light_owner.get(p_light); - ERR_FAIL_COND_V(!light, RID()); - - LightInstance *light_instance = memnew(LightInstance); - - light_instance->light = p_light; - light_instance->base = light; - light_instance->last_pass = 0; - - return light_instance_owner.make_rid(light_instance); -} -void RasterizerGLES2::light_instance_set_transform(RID p_light_instance, const Transform &p_transform) { - - LightInstance *lighti = light_instance_owner.get(p_light_instance); - ERR_FAIL_COND(!lighti); - lighti->transform = p_transform; -} - -Rasterizer::ShadowType RasterizerGLES2::light_instance_get_shadow_type(RID p_light_instance, bool p_far) const { - - LightInstance *lighti = light_instance_owner.get(p_light_instance); - ERR_FAIL_COND_V(!lighti, Rasterizer::SHADOW_NONE); - - switch (lighti->base->type) { - - case VS::LIGHT_DIRECTIONAL: { - switch (lighti->base->directional_shadow_mode) { - case VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL: { - return SHADOW_ORTHOGONAL; - } break; - case VS::LIGHT_DIRECTIONAL_SHADOW_PERSPECTIVE: { - return SHADOW_PSM; - } break; - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS: - case VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS: { - return SHADOW_PSSM; - } break; - } - - } break; - case VS::LIGHT_OMNI: return SHADOW_DUAL_PARABOLOID; break; - case VS::LIGHT_SPOT: return SHADOW_SIMPLE; break; - } - - return Rasterizer::SHADOW_NONE; -} - -int RasterizerGLES2::light_instance_get_shadow_passes(RID p_light_instance) const { - - LightInstance *lighti = light_instance_owner.get(p_light_instance); - ERR_FAIL_COND_V(!lighti, 0); - - if (lighti->base->type == VS::LIGHT_DIRECTIONAL && lighti->base->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { - - return 4; // dp4 - } else if (lighti->base->type == VS::LIGHT_OMNI || (lighti->base->type == VS::LIGHT_DIRECTIONAL && lighti->base->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS)) { - return 2; // dp - } else - return 1; -} - -bool RasterizerGLES2::light_instance_get_pssm_shadow_overlap(RID p_light_instance) const { - - return shadow_filter >= SHADOW_FILTER_ESM; -} - -void RasterizerGLES2::light_instance_set_shadow_transform(RID p_light_instance, int p_index, const CameraMatrix &p_camera, const Transform &p_transform, float p_split_near, float p_split_far) { - - LightInstance *lighti = light_instance_owner.get(p_light_instance); - ERR_FAIL_COND(!lighti); - - ERR_FAIL_COND(lighti->base->type != VS::LIGHT_DIRECTIONAL); - //ERR_FAIL_INDEX(p_index,1); - - lighti->custom_projection[p_index] = p_camera; - lighti->custom_transform[p_index] = p_transform; - lighti->shadow_split[p_index] = 1.0 / p_split_far; -#if 0 - if (p_index==0) { - lighti->custom_projection=p_camera; - lighti->custom_transform=p_transform; - //Plane p(0,0,-p_split_far,1); - //p=camera_projection.xform4(p); - //lighti->shadow_split=p.normal.z/p.d; - lighti->shadow_split=1.0/p_split_far; - - //lighti->shadow_split=-p_split_far; - } else { - - lighti->custom_projection2=p_camera; - lighti->custom_transform2=p_transform; - lighti->shadow_split2=p_split_far; - - } -#endif -} - -int RasterizerGLES2::light_instance_get_shadow_size(RID p_light_instance, int p_index) const { - - LightInstance *lighti = light_instance_owner.get(p_light_instance); - ERR_FAIL_COND_V(!lighti, 1); - ERR_FAIL_COND_V(!lighti->near_shadow_buffer, 256); - return lighti->near_shadow_buffer->size / 2; -} - -void RasterizerGLES2::shadow_clear_near() { - - for (int i = 0; i < near_shadow_buffers.size(); i++) { - - if (near_shadow_buffers[i].owner) - near_shadow_buffers[i].owner->clear_near_shadow_buffers(); - } -} - -bool RasterizerGLES2::shadow_allocate_near(RID p_light) { - - if (!use_shadow_mapping || !use_framebuffers) - return false; - - LightInstance *li = light_instance_owner.get(p_light); - ERR_FAIL_COND_V(!li, false); - ERR_FAIL_COND_V(li->near_shadow_buffer, false); - - int skip = 0; - if (framebuffer.active) { - - int sc = framebuffer.scale; - while (sc > 1) { - sc /= 2; - skip++; - } - } - - for (int i = 0; i < near_shadow_buffers.size(); i++) { - - if (skip > 0) { - skip--; - continue; - } - - if (near_shadow_buffers[i].owner != NULL) - continue; - - near_shadow_buffers[i].owner = li; - li->near_shadow_buffer = &near_shadow_buffers[i]; - return true; - } - - return false; -} - -bool RasterizerGLES2::shadow_allocate_far(RID p_light) { - - return false; -} - -/* PARTICLES INSTANCE */ - -RID RasterizerGLES2::particles_instance_create(RID p_particles) { - - ERR_FAIL_COND_V(!particles_owner.owns(p_particles), RID()); - ParticlesInstance *particles_instance = memnew(ParticlesInstance); - ERR_FAIL_COND_V(!particles_instance, RID()); - particles_instance->particles = p_particles; - return particles_instance_owner.make_rid(particles_instance); -} - -void RasterizerGLES2::particles_instance_set_transform(RID p_particles_instance, const Transform &p_transform) { - - ParticlesInstance *particles_instance = particles_instance_owner.get(p_particles_instance); - ERR_FAIL_COND(!particles_instance); - particles_instance->transform = p_transform; -} - -RID RasterizerGLES2::viewport_data_create() { - - ViewportData *vd = memnew(ViewportData); - - glActiveTexture(GL_TEXTURE0); - glGenFramebuffers(1, &vd->lum_fbo); - glBindFramebuffer(GL_FRAMEBUFFER, vd->lum_fbo); - - GLuint format_luminance = use_fp16_fb ? _GL_RG_EXT : GL_RGBA; - GLuint format_luminance_type = use_fp16_fb ? (full_float_fb_supported ? GL_FLOAT : _GL_HALF_FLOAT_OES) : GL_UNSIGNED_BYTE; - GLuint format_luminance_components = use_fp16_fb ? _GL_RG_EXT : GL_RGBA; - - glGenTextures(1, &vd->lum_color); - glBindTexture(GL_TEXTURE_2D, vd->lum_color); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - /* - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - */ - glTexImage2D(GL_TEXTURE_2D, 0, format_luminance, 1, 1, 0, - format_luminance_components, format_luminance_type, NULL); - - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, vd->lum_color, 0); - - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - - glBindFramebuffer(GL_FRAMEBUFFER, base_framebuffer); - DEBUG_TEST_ERROR("Viewport Data Init"); - if (status != GL_FRAMEBUFFER_COMPLETE) { - WARN_PRINT("Can't create framebuffer for vd"); - } - - return viewport_data_owner.make_rid(vd); -} - -RID RasterizerGLES2::render_target_create() { - - RenderTarget *rt = memnew(RenderTarget); - rt->fbo = 0; - rt->width = 0; - rt->height = 0; - rt->last_pass = 0; - - Texture *texture = memnew(Texture); - texture->active = false; - texture->total_data_size = 0; - texture->render_target = rt; - texture->ignore_mipmaps = true; - rt->texture_ptr = texture; - rt->texture = texture_owner.make_rid(texture); - rt->texture_ptr->active = false; - return render_target_owner.make_rid(rt); -} -void RasterizerGLES2::render_target_set_size(RID p_render_target, int p_width, int p_height) { - - RenderTarget *rt = render_target_owner.get(p_render_target); - - if (p_width == rt->width && p_height == rt->height) - return; - - if (rt->width != 0 && rt->height != 0) { - - glDeleteFramebuffers(1, &rt->fbo); - glDeleteRenderbuffers(1, &rt->depth); - glDeleteTextures(1, &rt->color); - - rt->fbo = 0; - rt->depth = 0; - rt->color = 0; - rt->width = 0; - rt->height = 0; - rt->texture_ptr->tex_id = 0; - rt->texture_ptr->active = false; - } - - if (p_width == 0 || p_height == 0) - return; - - rt->width = p_width; - rt->height = p_height; - - //fbo - glGenFramebuffers(1, &rt->fbo); - glBindFramebuffer(GL_FRAMEBUFFER, rt->fbo); - - //depth - if (!low_memory_2d) { - glGenRenderbuffers(1, &rt->depth); - glBindRenderbuffer(GL_RENDERBUFFER, rt->depth); - - glRenderbufferStorage(GL_RENDERBUFFER, use_depth24 ? _DEPTH_COMPONENT24_OES : GL_DEPTH_COMPONENT16, rt->width, rt->height); - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth); - } - - //color - glGenTextures(1, &rt->color); - glBindTexture(GL_TEXTURE_2D, rt->color); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rt->width, rt->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - - if (rt->texture_ptr->flags & VS::TEXTURE_FLAG_FILTER) { - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } else { - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - } - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rt->color, 0); - - rt->texture_ptr->tex_id = rt->color; - rt->texture_ptr->active = true; - rt->texture_ptr->width = p_width; - rt->texture_ptr->height = p_height; - -# - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - - if (status != GL_FRAMEBUFFER_COMPLETE) { - - glDeleteRenderbuffers(1, &rt->fbo); - glDeleteTextures(1, &rt->depth); - glDeleteTextures(1, &rt->color); - rt->fbo = 0; - rt->width = 0; - rt->height = 0; - rt->color = 0; - rt->depth = 0; - rt->texture_ptr->tex_id = 0; - rt->texture_ptr->active = false; - WARN_PRINT("Could not create framebuffer!!"); - } - - glBindFramebuffer(GL_FRAMEBUFFER, base_framebuffer); -} - -RID RasterizerGLES2::render_target_get_texture(RID p_render_target) const { - - const RenderTarget *rt = render_target_owner.get(p_render_target); - ERR_FAIL_COND_V(!rt, RID()); - return rt->texture; -} -bool RasterizerGLES2::render_target_renedered_in_frame(RID p_render_target) { - - RenderTarget *rt = render_target_owner.get(p_render_target); - ERR_FAIL_COND_V(!rt, false); - return rt->last_pass == frame; -} - -/* RENDER API */ -/* all calls (inside begin/end shadow) are always warranted to be in the following order: */ - -void RasterizerGLES2::begin_frame() { - - _update_framebuffer(); - - glDepthFunc(GL_LEQUAL); - glFrontFace(GL_CW); - -//fragment_lighting=Globals::get_singleton()->get("rasterizer/use_fragment_lighting"); -#ifdef TOOLS_ENABLED - canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/use_2d_pixel_snap", false)); - shadow_filter = ShadowFilterTechnique(int(ProjectSettings::get_singleton()->get("rasterizer/shadow_filter"))); -#endif - - canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_PCF5, shadow_filter == SHADOW_FILTER_PCF5); - canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_PCF13, shadow_filter == SHADOW_FILTER_PCF13); - canvas_shader.set_conditional(CanvasShaderGLES2::SHADOW_ESM, shadow_filter == SHADOW_FILTER_ESM); - - window_size = Size2(OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height); - - double time = (OS::get_singleton()->get_ticks_usec() / 1000); // get msec - time /= 1000.0; // make secs - time_delta = time - last_time; - last_time = time; - frame++; - - _rinfo.vertex_count = 0; - _rinfo.object_count = 0; - _rinfo.mat_change_count = 0; - _rinfo.shader_change_count = 0; - _rinfo.ci_draw_commands = 0; - _rinfo.surface_count = 0; - _rinfo.draw_calls = 0; - - _update_fixed_materials(); - while (_shader_dirty_list.first()) { - - _update_shader(_shader_dirty_list.first()->self()); - } - - while (_skeleton_dirty_list.first()) { - - Skeleton *s = _skeleton_dirty_list.first()->self(); - - float *sk_float = (float *)skinned_buffer; - for (int i = 0; i < s->bones.size(); i++) { - - float *m = &sk_float[i * 12]; - const Skeleton::Bone &b = s->bones[i]; - m[0] = b.mtx[0][0]; - m[1] = b.mtx[1][0]; - m[2] = b.mtx[2][0]; - m[3] = b.mtx[3][0]; - - m[4] = b.mtx[0][1]; - m[5] = b.mtx[1][1]; - m[6] = b.mtx[2][1]; - m[7] = b.mtx[3][1]; - - m[8] = b.mtx[0][2]; - m[9] = b.mtx[1][2]; - m[10] = b.mtx[2][2]; - m[11] = b.mtx[3][2]; - } - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, s->tex_id); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, next_power_of_2(s->bones.size() * 3), 1, GL_RGBA, GL_FLOAT, sk_float); - _skeleton_dirty_list.remove(_skeleton_dirty_list.first()); - } - - while (_multimesh_dirty_list.first()) { - - MultiMesh *s = _multimesh_dirty_list.first()->self(); - - float *sk_float = (float *)skinned_buffer; - for (int i = 0; i < s->elements.size(); i++) { - - float *m = &sk_float[i * 16]; - const float *im = s->elements[i].matrix; - for (int j = 0; j < 16; j++) { - m[j] = im[j]; - } - } - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, s->tex_id); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, s->tw, s->th, GL_RGBA, GL_FLOAT, sk_float); - _multimesh_dirty_list.remove(_multimesh_dirty_list.first()); - } - - draw_next_frame = false; - //material_shader.set_uniform_default(MaterialShaderGLES2::SCREENZ_SCALE, Math::fmod(time, 3600.0)); - /* nehe ?*/ - - //glClearColor(0,0,1,1); - //glClear(GL_COLOR_BUFFER_BIT); //should not clear if anything else cleared.. -} - -void RasterizerGLES2::capture_viewport(Image *r_capture) { -#if 0 - PoolVector<uint8_t> pixels; - pixels.resize(viewport.width*viewport.height*3); - PoolVector<uint8_t>::Write w = pixels.write(); -#ifdef GLEW_ENABLED - glReadBuffer(GL_COLOR_ATTACHMENT0); -#endif - glPixelStorei(GL_PACK_ALIGNMENT, 1); - if (current_rt) - glReadPixels( 0, 0, viewport.width, viewport.height,GL_RGB,GL_UNSIGNED_BYTE,w.ptr() ); - else - glReadPixels( viewport.x, window_size.height-(viewport.height+viewport.y), viewport.width,viewport.height,GL_RGB,GL_UNSIGNED_BYTE,w.ptr()); - - glPixelStorei(GL_PACK_ALIGNMENT, 4); - - w=PoolVector<uint8_t>::Write(); - - r_capture->create(viewport.width,viewport.height,0,Image::FORMAT_RGB8,pixels); -#else - - PoolVector<uint8_t> pixels; - pixels.resize(viewport.width * viewport.height * 4); - PoolVector<uint8_t>::Write w = pixels.write(); - glPixelStorei(GL_PACK_ALIGNMENT, 4); - - //uint64_t time = OS::get_singleton()->get_ticks_usec(); - - if (current_rt) { -#ifdef GLEW_ENABLED - glReadBuffer(GL_COLOR_ATTACHMENT0); -#endif - glReadPixels(0, 0, viewport.width, viewport.height, GL_RGBA, GL_UNSIGNED_BYTE, w.ptr()); - } else { - // back? - glReadPixels(viewport.x, window_size.height - (viewport.height + viewport.y), viewport.width, viewport.height, GL_RGBA, GL_UNSIGNED_BYTE, w.ptr()); - } - - bool flip = current_rt == NULL; - - if (flip) { - uint32_t *imgptr = (uint32_t *)w.ptr(); - for (int y = 0; y < (viewport.height / 2); y++) { - - uint32_t *ptr1 = &imgptr[y * viewport.width]; - uint32_t *ptr2 = &imgptr[(viewport.height - y - 1) * viewport.width]; - - for (int x = 0; x < viewport.width; x++) { - - uint32_t tmp = ptr1[x]; - ptr1[x] = ptr2[x]; - ptr2[x] = tmp; - } - } - } - - w = PoolVector<uint8_t>::Write(); - r_capture->create(viewport.width, viewport.height, 0, Image::FORMAT_RGBA8, pixels); -//r_capture->flip_y(); - -#endif -} - -void RasterizerGLES2::clear_viewport(const Color &p_color) { - - if (current_rt || using_canvas_bg) { - - glScissor(0, 0, viewport.width, viewport.height); - } else { - glScissor(viewport.x, window_size.height - (viewport.height + viewport.y), viewport.width, viewport.height); - } - - glEnable(GL_SCISSOR_TEST); - glClearColor(p_color.r, p_color.g, p_color.b, p_color.a); - glClear(GL_COLOR_BUFFER_BIT); //should not clear if anything else cleared.. - glDisable(GL_SCISSOR_TEST); -}; - -void RasterizerGLES2::set_render_target(RID p_render_target, bool p_transparent_bg, bool p_vflip) { - - if (!p_render_target.is_valid()) { - glBindFramebuffer(GL_FRAMEBUFFER, base_framebuffer); - current_rt = NULL; - current_rt_vflip = false; - - } else { - RenderTarget *rt = render_target_owner.get(p_render_target); - ERR_FAIL_COND(!rt); - ERR_FAIL_COND(rt->fbo == 0); - glBindFramebuffer(GL_FRAMEBUFFER, rt->fbo); - current_rt = rt; - current_rt_transparent = p_transparent_bg; - current_rt_vflip = !p_vflip; - } -} - -void RasterizerGLES2::set_viewport(const VS::ViewportRect &p_viewport) { - - viewport = p_viewport; - //viewport.width/=2; - //viewport.height/=2; - //print_line("viewport: "+itos(p_viewport.x)+","+itos(p_viewport.y)+","+itos(p_viewport.width)+","+itos(p_viewport.height)); - - if (current_rt) { - - glViewport(0, 0, viewport.width, viewport.height); - } else { - glViewport(viewport.x, window_size.height - (viewport.height + viewport.y), viewport.width, viewport.height); - } -} - -void RasterizerGLES2::begin_scene(RID p_viewport_data, RID p_env, VS::ScenarioDebugMode p_debug) { - - current_debug = p_debug; - opaque_render_list.clear(); - alpha_render_list.clear(); - light_instance_count = 0; - current_env = p_env.is_valid() ? environment_owner.get(p_env) : NULL; - scene_pass++; - last_light_id = 0; - directional_light_count = 0; - lights_use_shadow = false; - texscreen_used = false; - current_vd = viewport_data_owner.get(p_viewport_data); - if (current_debug == VS::SCENARIO_DEBUG_WIREFRAME) { -#ifdef GLEW_ENABLED - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); -#endif - } - - //set state - - glCullFace(GL_FRONT); - cull_front = true; -}; - -void RasterizerGLES2::begin_shadow_map(RID p_light_instance, int p_shadow_pass) { - - ERR_FAIL_COND(shadow); - shadow = light_instance_owner.get(p_light_instance); - shadow_pass = p_shadow_pass; - ERR_FAIL_COND(!shadow); - - opaque_render_list.clear(); - alpha_render_list.clear(); - //pre_zpass_render_list.clear(); - light_instance_count = 0; - - glCullFace(GL_FRONT); - cull_front = true; -} - -void RasterizerGLES2::set_camera(const Transform &p_world, const CameraMatrix &p_projection, bool p_ortho_hint) { - - camera_transform = p_world; - if (current_rt && current_rt_vflip) { - camera_transform.basis.set_axis(1, -camera_transform.basis.get_axis(1)); - } - camera_transform_inverse = camera_transform.inverse(); - camera_projection = p_projection; - camera_plane = Plane(camera_transform.origin, -camera_transform.basis.get_axis(2)); - camera_z_near = camera_projection.get_z_near(); - camera_z_far = camera_projection.get_z_far(); - camera_projection.get_viewport_size(camera_vp_size.x, camera_vp_size.y); - camera_ortho = p_ortho_hint; -} - -void RasterizerGLES2::add_light(RID p_light_instance) { - -#define LIGHT_FADE_THRESHOLD 0.05 - - ERR_FAIL_COND(light_instance_count >= MAX_SCENE_LIGHTS); - - LightInstance *li = light_instance_owner.get(p_light_instance); - ERR_FAIL_COND(!li); - - switch (li->base->type) { - - case VS::LIGHT_DIRECTIONAL: { - - ERR_FAIL_COND(directional_light_count >= RenderList::MAX_LIGHTS); - directional_lights[directional_light_count++] = li; - - if (li->base->shadow_enabled) { - CameraMatrix bias; - bias.set_light_bias(); - - int passes = light_instance_get_shadow_passes(p_light_instance); - - for (int i = 0; i < passes; i++) { - Transform modelview = Transform(camera_transform_inverse * li->custom_transform[i]).inverse(); - li->shadow_projection[i] = bias * li->custom_projection[i] * modelview; - } - - lights_use_shadow = true; - } - } break; - case VS::LIGHT_OMNI: { - - if (li->base->shadow_enabled) { - li->shadow_projection[0] = Transform(camera_transform_inverse * li->transform).inverse(); - lights_use_shadow = true; - } - } break; - case VS::LIGHT_SPOT: { - - if (li->base->shadow_enabled) { - CameraMatrix bias; - bias.set_light_bias(); - Transform modelview = Transform(camera_transform_inverse * li->transform).inverse(); - li->shadow_projection[0] = bias * li->projection * modelview; - lights_use_shadow = true; - } - } break; - } - - /* make light hash */ - - // actually, not really a hash, but helps to sort the lights - // and avoid recompiling redudant shader versions - - li->last_pass = scene_pass; - li->sort_key = light_instance_count; - - light_instances[light_instance_count++] = li; -} - -void RasterizerGLES2::_update_shader(Shader *p_shader) const { - - _shader_dirty_list.remove(&p_shader->dirty_list); - - p_shader->valid = false; - - p_shader->uniforms.clear(); - Vector<StringName> uniform_names; - - String vertex_code; - String vertex_globals; - ShaderCompilerGLES2::Flags vertex_flags; - ShaderCompilerGLES2::Flags fragment_flags; - ShaderCompilerGLES2::Flags light_flags; - - if (p_shader->mode == VS::SHADER_MATERIAL) { - Error err = shader_precompiler.compile(p_shader->vertex_code, ShaderLanguage::SHADER_MATERIAL_VERTEX, vertex_code, vertex_globals, vertex_flags, &p_shader->uniforms); - if (err) { - return; //invalid - } - } else if (p_shader->mode == VS::SHADER_CANVAS_ITEM) { - - Error err = shader_precompiler.compile(p_shader->vertex_code, ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX, vertex_code, vertex_globals, vertex_flags, &p_shader->uniforms); - if (err) { - return; //invalid - } - } - - //print_line("compiled vertex: "+vertex_code); - //print_line("compiled vertex globals: "+vertex_globals); - - //print_line("UCV: "+itos(p_shader->uniforms.size())); - String fragment_code; - String fragment_globals; - - if (p_shader->mode == VS::SHADER_MATERIAL) { - Error err = shader_precompiler.compile(p_shader->fragment_code, ShaderLanguage::SHADER_MATERIAL_FRAGMENT, fragment_code, fragment_globals, fragment_flags, &p_shader->uniforms); - if (err) { - return; //invalid - } - } else if (p_shader->mode == VS::SHADER_CANVAS_ITEM) { - Error err = shader_precompiler.compile(p_shader->fragment_code, ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT, fragment_code, fragment_globals, fragment_flags, &p_shader->uniforms); - if (err) { - return; //invalid - } - } - - String light_code; - String light_globals; - - if (p_shader->mode == VS::SHADER_MATERIAL) { - - Error err = shader_precompiler.compile(p_shader->light_code, (ShaderLanguage::SHADER_MATERIAL_LIGHT), light_code, light_globals, light_flags, &p_shader->uniforms); - if (err) { - return; //invalid - } - } else if (p_shader->mode == VS::SHADER_CANVAS_ITEM) { - Error err = shader_precompiler.compile(p_shader->light_code, (ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT), light_code, light_globals, light_flags, &p_shader->uniforms); - if (err) { - return; //invalid - } - } - - fragment_globals += light_globals; //both fragment anyway - - //print_line("compiled fragment: "+fragment_code); - //("compiled fragment globals: "+fragment_globals); - - //print_line("UCF: "+itos(p_shader->uniforms.size())); - - int first_tex_index = 0xFFFFF; - p_shader->first_texture = StringName(); - - for (Map<StringName, ShaderLanguage::Uniform>::Element *E = p_shader->uniforms.front(); E; E = E->next()) { - - uniform_names.push_back("_" + String(E->key())); - if (E->get().type == ShaderLanguage::TYPE_TEXTURE && E->get().order < first_tex_index) { - p_shader->first_texture = E->key(); - first_tex_index = E->get().order; - } - } - - bool uses_time = false; - - if (p_shader->mode == VS::SHADER_MATERIAL) { - //print_line("setting code to id.. "+itos(p_shader->custom_code_id)); - Vector<const char *> enablers; - if (fragment_flags.use_color_interp || vertex_flags.use_color_interp) - enablers.push_back("#define ENABLE_COLOR_INTERP\n"); - if (fragment_flags.use_uv_interp || vertex_flags.use_uv_interp) - enablers.push_back("#define ENABLE_UV_INTERP\n"); - if (fragment_flags.use_uv2_interp || vertex_flags.use_uv2_interp) - enablers.push_back("#define ENABLE_UV2_INTERP\n"); - if (fragment_flags.use_tangent_interp || vertex_flags.use_tangent_interp || fragment_flags.uses_normalmap) - enablers.push_back("#define ENABLE_TANGENT_INTERP\n"); - if (fragment_flags.use_var1_interp || vertex_flags.use_var1_interp) - enablers.push_back("#define ENABLE_VAR1_INTERP\n"); - if (fragment_flags.use_var2_interp || vertex_flags.use_var2_interp) - enablers.push_back("#define ENABLE_VAR2_INTERP\n"); - if (fragment_flags.uses_texscreen) { - enablers.push_back("#define ENABLE_TEXSCREEN\n"); - } - if (fragment_flags.uses_screen_uv) { - enablers.push_back("#define ENABLE_SCREEN_UV\n"); - } - if (fragment_flags.uses_discard) { - enablers.push_back("#define ENABLE_DISCARD\n"); - } - if (fragment_flags.uses_normalmap) { - enablers.push_back("#define ENABLE_NORMALMAP\n"); - } - if (light_flags.uses_light) { - enablers.push_back("#define USE_LIGHT_SHADER_CODE\n"); - } - if (light_flags.uses_shadow_color) { - enablers.push_back("#define USE_OUTPUT_SHADOW_COLOR\n"); - } - if (light_flags.uses_time || fragment_flags.uses_time || vertex_flags.uses_time) { - enablers.push_back("#define USE_TIME\n"); - uses_time = true; - } - if (vertex_flags.vertex_code_writes_position) { - enablers.push_back("#define VERTEX_SHADER_WRITE_POSITION\n"); - } - - material_shader.set_custom_shader_code(p_shader->custom_code_id, vertex_code, vertex_globals, fragment_code, light_code, fragment_globals, uniform_names, enablers); - } else if (p_shader->mode == VS::SHADER_CANVAS_ITEM) { - - Vector<const char *> enablers; - - if (light_flags.uses_time || fragment_flags.uses_time || vertex_flags.uses_time) { - enablers.push_back("#define USE_TIME\n"); - uses_time = true; - } - if (fragment_flags.uses_normal) { - enablers.push_back("#define NORMAL_USED\n"); - } - if (fragment_flags.uses_normalmap) { - enablers.push_back("#define USE_NORMALMAP\n"); - } - - if (light_flags.uses_light) { - enablers.push_back("#define USE_LIGHT_SHADER_CODE\n"); - } - if (fragment_flags.use_var1_interp || vertex_flags.use_var1_interp) - enablers.push_back("#define ENABLE_VAR1_INTERP\n"); - if (fragment_flags.use_var2_interp || vertex_flags.use_var2_interp) - enablers.push_back("#define ENABLE_VAR2_INTERP\n"); - if (fragment_flags.uses_texscreen) { - enablers.push_back("#define ENABLE_TEXSCREEN\n"); - } - if (fragment_flags.uses_screen_uv) { - enablers.push_back("#define ENABLE_SCREEN_UV\n"); - } - if (fragment_flags.uses_texpixel_size) { - enablers.push_back("#define USE_TEXPIXEL_SIZE\n"); - } - if (light_flags.uses_shadow_color) { - enablers.push_back("#define USE_OUTPUT_SHADOW_COLOR\n"); - } - - if (vertex_flags.uses_worldvec) { - enablers.push_back("#define USE_WORLD_VEC\n"); - } - canvas_shader.set_custom_shader_code(p_shader->custom_code_id, vertex_code, vertex_globals, fragment_code, light_code, fragment_globals, uniform_names, enablers); - - //postprocess_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, fragment_globals,uniform_names); - } - - p_shader->valid = true; - p_shader->has_alpha = fragment_flags.uses_alpha || fragment_flags.uses_texscreen; - p_shader->writes_vertex = vertex_flags.vertex_code_writes_vertex; - p_shader->uses_discard = fragment_flags.uses_discard; - p_shader->has_texscreen = fragment_flags.uses_texscreen; - p_shader->has_screen_uv = fragment_flags.uses_screen_uv; - p_shader->can_zpass = !fragment_flags.uses_discard && !vertex_flags.vertex_code_writes_vertex; - p_shader->uses_normal = fragment_flags.uses_normal || light_flags.uses_normal; - p_shader->uses_time = uses_time; - p_shader->uses_texpixel_size = fragment_flags.uses_texpixel_size; - p_shader->version++; -} - -void RasterizerGLES2::_add_geometry(const Geometry *p_geometry, const InstanceData *p_instance, const Geometry *p_geometry_cmp, const GeometryOwner *p_owner, int p_material) { - - Material *m = NULL; - RID m_src = p_instance->material_override.is_valid() ? p_instance->material_override : (p_material >= 0 ? p_instance->materials[p_material] : p_geometry->material); - -#ifdef DEBUG_ENABLED - if (current_debug == VS::SCENARIO_DEBUG_OVERDRAW) { - m_src = overdraw_material; - } - -#endif - - if (m_src) - m = material_owner.get(m_src); - - if (!m) { - m = material_owner.get(default_material); - } - - ERR_FAIL_COND(!m); - - if (m->last_pass != frame) { - - if (m->shader.is_valid()) { - - m->shader_cache = shader_owner.get(m->shader); - if (m->shader_cache) { - - if (!m->shader_cache->valid) { - m->shader_cache = NULL; - } else { - if (m->shader_cache->has_texscreen) - texscreen_used = true; - } - } else { - m->shader = RID(); - } - - } else { - m->shader_cache = NULL; - } - - m->last_pass = frame; - } - - RenderList *render_list = NULL; - - bool has_base_alpha = (m->shader_cache && m->shader_cache->has_alpha); - bool has_blend_alpha = m->blend_mode != VS::MATERIAL_BLEND_MODE_MIX || m->flags[VS::MATERIAL_FLAG_ONTOP]; - bool has_alpha = has_base_alpha || has_blend_alpha; - - if (shadow) { - - if (has_blend_alpha || (has_base_alpha && m->depth_draw_mode != VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA)) - return; //bye - - if (!m->shader_cache || (!m->shader_cache->writes_vertex && !m->shader_cache->uses_discard && m->depth_draw_mode != VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA)) { - //shader does not use discard and does not write a vertex position, use generic material - if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) - m = shadow_mat_double_sided_ptr; - else - m = shadow_mat_ptr; - if (m->last_pass != frame) { - - if (m->shader.is_valid()) { - - m->shader_cache = shader_owner.get(m->shader); - if (m->shader_cache) { - - if (!m->shader_cache->valid) - m->shader_cache = NULL; - } else { - m->shader = RID(); - } - - } else { - m->shader_cache = NULL; - } - - m->last_pass = frame; - } - } - - render_list = &opaque_render_list; - /* notyet - if (!m->shader_cache || m->shader_cache->can_zpass) - render_list = &alpha_render_list; - } else { - render_list = &opaque_render_list; - }*/ - - } else { - if (has_alpha) { - render_list = &alpha_render_list; - } else { - render_list = &opaque_render_list; - } - } - - RenderList::Element *e = render_list->add_element(); - - if (!e) - return; - - e->geometry = p_geometry; - e->geometry_cmp = p_geometry_cmp; - e->material = m; - e->instance = p_instance; - if (camera_ortho) { - e->depth = camera_plane.distance_to(p_instance->transform.origin); - } else { - e->depth = camera_transform.origin.distance_to(p_instance->transform.origin); - } - e->owner = p_owner; - e->light_type = 0; - e->additive = false; - e->additive_ptr = &e->additive; - e->sort_flags = 0; - - if (p_instance->skeleton.is_valid()) { - e->skeleton = skeleton_owner.get(p_instance->skeleton); - if (!e->skeleton) - const_cast<InstanceData *>(p_instance)->skeleton = RID(); - else - e->sort_flags |= RenderList::SORT_FLAG_SKELETON; - } else { - e->skeleton = NULL; - } - - if (e->geometry->type == Geometry::GEOMETRY_MULTISURFACE) - e->sort_flags |= RenderList::SORT_FLAG_INSTANCING; - - e->mirror = p_instance->mirror; - if (m->flags[VS::MATERIAL_FLAG_INVERT_FACES]) - e->mirror = !e->mirror; - - //e->light_type=0xFF; // no lights! - e->light_type = 3; //light type 3 is no light? - e->light = 0xFFFF; - - if (!shadow && !has_blend_alpha && has_alpha && m->depth_draw_mode == VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA) { - - //if nothing exists, add this element as opaque too - RenderList::Element *oe = opaque_render_list.add_element(); - - if (!oe) - return; - - memcpy(oe, e, sizeof(RenderList::Element)); - oe->additive_ptr = &oe->additive; - } - - if (shadow || m->flags[VS::MATERIAL_FLAG_UNSHADED] || current_debug == VS::SCENARIO_DEBUG_SHADELESS) { - - e->light_type = 0x7F; //unshaded is zero - } else { - - bool duplicate = false; - - for (int i = 0; i < directional_light_count; i++) { - uint16_t sort_key = directional_lights[i]->sort_key; - uint8_t light_type = VS::LIGHT_DIRECTIONAL; - if (directional_lights[i]->base->shadow_enabled) { - light_type |= 0x8; - if (directional_lights[i]->base->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) - light_type |= 0x10; - else if (directional_lights[i]->base->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) - light_type |= 0x30; - } - - RenderList::Element *ec; - if (duplicate) { - - ec = render_list->add_element(); - memcpy(ec, e, sizeof(RenderList::Element)); - } else { - - ec = e; - duplicate = true; - } - - ec->light_type = light_type; - ec->light = sort_key; - ec->additive_ptr = &e->additive; - } - - const RID *liptr = p_instance->light_instances.ptr(); - int ilc = p_instance->light_instances.size(); - - for (int i = 0; i < ilc; i++) { - - LightInstance *li = light_instance_owner.get(liptr[i]); - if (!li || li->last_pass != scene_pass) //lit by light not in visible scene - continue; - uint8_t light_type = li->base->type | 0x40; //penalty to ensure directionals always go first - if (li->base->shadow_enabled) { - light_type |= 0x8; - } - uint16_t sort_key = li->sort_key; - - RenderList::Element *ec; - if (duplicate) { - - ec = render_list->add_element(); - memcpy(ec, e, sizeof(RenderList::Element)); - } else { - - duplicate = true; - ec = e; - } - - ec->light_type = light_type; - ec->light = sort_key; - ec->additive_ptr = &e->additive; - } - } - - DEBUG_TEST_ERROR("Add Geometry"); -} - -void RasterizerGLES2::add_mesh(const RID &p_mesh, const InstanceData *p_data) { - - Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND(!mesh); - - int ssize = mesh->surfaces.size(); - - for (int i = 0; i < ssize; i++) { - - int mat_idx = p_data->materials[i].is_valid() ? i : -1; - Surface *s = mesh->surfaces[i]; - _add_geometry(s, p_data, s, NULL, mat_idx); - } - - mesh->last_pass = frame; -} - -void RasterizerGLES2::add_multimesh(const RID &p_multimesh, const InstanceData *p_data) { - - MultiMesh *multimesh = multimesh_owner.get(p_multimesh); - ERR_FAIL_COND(!multimesh); - - if (!multimesh->mesh.is_valid()) - return; - if (multimesh->elements.empty()) - return; - - Mesh *mesh = mesh_owner.get(multimesh->mesh); - ERR_FAIL_COND(!mesh); - - int surf_count = mesh->surfaces.size(); - if (multimesh->last_pass != scene_pass) { - - multimesh->cache_surfaces.resize(surf_count); - for (int i = 0; i < surf_count; i++) { - - multimesh->cache_surfaces[i].material = mesh->surfaces[i]->material; - multimesh->cache_surfaces[i].has_alpha = mesh->surfaces[i]->has_alpha; - multimesh->cache_surfaces[i].surface = mesh->surfaces[i]; - } - - multimesh->last_pass = scene_pass; - } - - for (int i = 0; i < surf_count; i++) { - - _add_geometry(&multimesh->cache_surfaces[i], p_data, multimesh->cache_surfaces[i].surface, multimesh); - } -} - -void RasterizerGLES2::add_immediate(const RID &p_immediate, const InstanceData *p_data) { - - Immediate *immediate = immediate_owner.get(p_immediate); - ERR_FAIL_COND(!immediate); - - _add_geometry(immediate, p_data, immediate, NULL); -} - -void RasterizerGLES2::add_particles(const RID &p_particle_instance, const InstanceData *p_data) { - - //print_line("adding particles"); - ParticlesInstance *particles_instance = particles_instance_owner.get(p_particle_instance); - ERR_FAIL_COND(!particles_instance); - Particles *p = particles_owner.get(particles_instance->particles); - ERR_FAIL_COND(!p); - - _add_geometry(p, p_data, p, particles_instance); - draw_next_frame = true; -} - -Color RasterizerGLES2::_convert_color(const Color &p_color) { - - if (current_env && current_env->fx_enabled[VS::ENV_FX_SRGB]) - return p_color.to_linear(); - else - return p_color; -} - -void RasterizerGLES2::_set_cull(bool p_front, bool p_reverse_cull) { - - bool front = p_front; - if (p_reverse_cull) - front = !front; - - if (front != cull_front) { - - glCullFace(front ? GL_FRONT : GL_BACK); - cull_front = front; - } -} - -_FORCE_INLINE_ void RasterizerGLES2::_update_material_shader_params(Material *p_material) const { - - Map<StringName, Material::UniformData> old_mparams = p_material->shader_params; - Map<StringName, Material::UniformData> &mparams = p_material->shader_params; - mparams.clear(); - int idx = 0; - for (Map<StringName, ShaderLanguage::Uniform>::Element *E = p_material->shader_cache->uniforms.front(); E; E = E->next()) { - - Material::UniformData ud; - - bool keep = true; //keep material value - - Map<StringName, Material::UniformData>::Element *OLD = old_mparams.find(E->key()); - bool has_old = OLD; - bool old_inuse = has_old && old_mparams[E->key()].inuse; - - ud.istexture = (E->get().type == ShaderLanguage::TYPE_TEXTURE || E->get().type == ShaderLanguage::TYPE_CUBEMAP); - - if (!has_old || !old_inuse) { - keep = false; - } else if (OLD->get().value.get_type() != E->value().default_value.get_type()) { - - if (OLD->get().value.get_type() == Variant::INT && E->get().type == ShaderLanguage::TYPE_FLOAT) { - //handle common mistake using shaders (feeding ints instead of float) - OLD->get().value = float(OLD->get().value); - keep = true; - } else if (!ud.istexture && E->value().default_value.get_type() != Variant::NIL) { - - keep = false; - } - //type changed between old and new - /* if (old_mparams[E->key()].value.get_type()==Variant::OBJECT) { - if (E->value().default_value.get_type()!=Variant::_RID) //hackfor textures - keep=false; - } else if (!old_mparams[E->key()].value.is_num() || !E->value().default_value.get_type()) - keep=false;*/ - - //value is invalid because type differs and default is not null - ; - } - - if (keep) { - ud.value = old_mparams[E->key()].value; - - //print_line("KEEP: "+String(E->key())); - } else { - if (ud.istexture && p_material->shader_cache->default_textures.has(E->key())) - ud.value = p_material->shader_cache->default_textures[E->key()]; - else - ud.value = E->value().default_value; - old_inuse = false; //if reverted to default, obviously did not work - - /* - print_line("NEW: "+String(E->key())+" because: hasold-"+itos(old_mparams.has(E->key()))); - if (old_mparams.has(E->key())) - print_line(" told "+Variant::get_type_name(old_mparams[E->key()].value.get_type())+" tnew "+Variant::get_type_name(E->value().default_value.get_type())); - */ - } - - ud.index = idx++; - ud.inuse = old_inuse; - mparams[E->key()] = ud; - } - - p_material->shader_version = p_material->shader_cache->version; -} - -bool RasterizerGLES2::_setup_material(const Geometry *p_geometry, const Material *p_material, bool p_no_const_light, bool p_opaque_pass) { - - if (p_material->flags[VS::MATERIAL_FLAG_DOUBLE_SIDED]) { - glDisable(GL_CULL_FACE); - } else { - glEnable(GL_CULL_FACE); - } - - //glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - - /* - if (p_material->flags[VS::MATERIAL_FLAG_WIREFRAME]) - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - else - glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - */ - - if (p_material->line_width) - glLineWidth(p_material->line_width); - - //all goes to false by default - material_shader.set_conditional(MaterialShaderGLES2::USE_SHADOW_PASS, shadow != NULL); - material_shader.set_conditional(MaterialShaderGLES2::USE_SHADOW_PCF, shadow_filter == SHADOW_FILTER_PCF5 || shadow_filter == SHADOW_FILTER_PCF13); - material_shader.set_conditional(MaterialShaderGLES2::USE_SHADOW_PCF_HQ, shadow_filter == SHADOW_FILTER_PCF13); - material_shader.set_conditional(MaterialShaderGLES2::USE_SHADOW_ESM, shadow_filter == SHADOW_FILTER_ESM); - material_shader.set_conditional(MaterialShaderGLES2::USE_LIGHTMAP_ON_UV2, p_material->flags[VS::MATERIAL_FLAG_LIGHTMAP_ON_UV2]); - material_shader.set_conditional(MaterialShaderGLES2::USE_COLOR_ATTRIB_SRGB_TO_LINEAR, p_material->flags[VS::MATERIAL_FLAG_COLOR_ARRAY_SRGB] && current_env && current_env->fx_enabled[VS::ENV_FX_SRGB]); - - if (p_opaque_pass && p_material->depth_draw_mode == VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA && p_material->shader_cache && p_material->shader_cache->has_alpha) { - - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_CLIP_ALPHA, true); - } else { - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_CLIP_ALPHA, false); - } - - if (!shadow) { - - bool depth_test = !p_material->flags[VS::MATERIAL_FLAG_ONTOP]; - bool depth_write = p_material->depth_draw_mode != VS::MATERIAL_DEPTH_DRAW_NEVER && (p_opaque_pass || p_material->depth_draw_mode == VS::MATERIAL_DEPTH_DRAW_ALWAYS); - //bool depth_write=!p_material->hints[VS::MATERIAL_HINT_NO_DEPTH_DRAW] && (p_opaque_pass || !p_material->hints[VS::MATERIAL_HINT_NO_DEPTH_DRAW_FOR_ALPHA]); - - if (current_depth_mask != depth_write) { - current_depth_mask = depth_write; - glDepthMask(depth_write); - } - - if (current_depth_test != depth_test) { - - current_depth_test = depth_test; - if (depth_test) - glEnable(GL_DEPTH_TEST); - else - glDisable(GL_DEPTH_TEST); - } - - material_shader.set_conditional(MaterialShaderGLES2::USE_FOG, current_env && current_env->fx_enabled[VS::ENV_FX_FOG]); - //glDepthMask( true ); - } - - DEBUG_TEST_ERROR("Pre Shader Bind"); - - bool rebind = false; - - if (p_material->shader_cache && p_material->shader_cache->valid) { - - /* - // reduce amount of conditional compilations - for(int i=0;i<_tex_version_count;i++) - material_shader.set_conditional((MaterialShaderGLES2::Conditionals)_tex_version[i],false); - */ - - //material_shader.set_custom_shader(p_material->shader_cache->custom_code_id); - - if (p_material->shader_version != p_material->shader_cache->version) { - //shader changed somehow, must update uniforms - - _update_material_shader_params((Material *)p_material); - } - material_shader.set_custom_shader(p_material->shader_cache->custom_code_id); - rebind = material_shader.bind(); - - DEBUG_TEST_ERROR("Shader Bind"); - - //set uniforms! - int texcoord = 0; - for (Map<StringName, Material::UniformData>::Element *E = p_material->shader_params.front(); E; E = E->next()) { - - if (E->get().index < 0) - continue; - //print_line(String(E->key())+": "+E->get().value); - if (E->get().istexture) { - //clearly a texture.. - RID rid = E->get().value; - int loc = material_shader.get_custom_uniform_location(E->get().index); //should be automatic.. - - Texture *t = NULL; - if (rid.is_valid()) { - - t = texture_owner.get(rid); - if (!t) { - E->get().value = RID(); //nullify, invalid texture - rid = RID(); - } - } - - glActiveTexture(GL_TEXTURE0 + texcoord); - glUniform1i(loc, texcoord); //TODO - this could happen automatically on compile... - if (t) { - if (t->render_target) - t->render_target->last_pass = frame; - if (E->key() == p_material->shader_cache->first_texture) { - tc0_idx = texcoord; - tc0_id_cache = t->tex_id; - } - glBindTexture(t->target, t->tex_id); - } else - glBindTexture(GL_TEXTURE_2D, white_tex); //no texture - texcoord++; - - } else if (E->get().value.get_type() == Variant::COLOR) { - Color c = E->get().value; - material_shader.set_custom_uniform(E->get().index, _convert_color(c)); - } else { - material_shader.set_custom_uniform(E->get().index, E->get().value); - } - } - - if (p_material->shader_cache->has_texscreen && framebuffer.active) { - material_shader.set_uniform(MaterialShaderGLES2::TEXSCREEN_SCREEN_MULT, Vector2(float(viewport.width) / framebuffer.width, float(viewport.height) / framebuffer.height)); - material_shader.set_uniform(MaterialShaderGLES2::TEXSCREEN_SCREEN_CLAMP, Color(0, 0, float(viewport.width) / framebuffer.width, float(viewport.height) / framebuffer.height)); - material_shader.set_uniform(MaterialShaderGLES2::TEXSCREEN_TEX, texcoord); - glActiveTexture(GL_TEXTURE0 + texcoord); - glBindTexture(GL_TEXTURE_2D, framebuffer.sample_color); - } - if (p_material->shader_cache->has_screen_uv) { - material_shader.set_uniform(MaterialShaderGLES2::SCREEN_UV_MULT, Vector2(1.0 / viewport.width, 1.0 / viewport.height)); - } - DEBUG_TEST_ERROR("Material arameters"); - - if (p_material->shader_cache->uses_time) { - material_shader.set_uniform(MaterialShaderGLES2::TIME, Math::fmod(last_time, shader_time_rollback)); - draw_next_frame = true; - } - //if uses TIME - draw_next_frame=true - - } else { - - material_shader.set_custom_shader(0); - rebind = material_shader.bind(); - - DEBUG_TEST_ERROR("Shader bind2"); - } - - if (shadow) { - - float zofs = shadow->base->vars[VS::LIGHT_PARAM_SHADOW_Z_OFFSET]; - float zslope = shadow->base->vars[VS::LIGHT_PARAM_SHADOW_Z_SLOPE_SCALE]; - if (shadow_pass >= 1 && shadow->base->type == VS::LIGHT_DIRECTIONAL) { - float m = Math::pow(shadow->base->directional_shadow_param[VS::LIGHT_DIRECTIONAL_SHADOW_PARAM_PSSM_ZOFFSET_SCALE], shadow_pass); - zofs *= m; - zslope *= m; - } - material_shader.set_uniform(MaterialShaderGLES2::SHADOW_Z_OFFSET, zofs); - material_shader.set_uniform(MaterialShaderGLES2::SHADOW_Z_SLOPE_SCALE, zslope); - if (shadow->base->type == VS::LIGHT_OMNI) - material_shader.set_uniform(MaterialShaderGLES2::DUAL_PARABOLOID, shadow->dp); - DEBUG_TEST_ERROR("Shadow uniforms"); - } - - if (current_env && current_env->fx_enabled[VS::ENV_FX_FOG]) { - - Color col_begin = current_env->fx_param[VS::ENV_FX_PARAM_FOG_BEGIN_COLOR]; - Color col_end = current_env->fx_param[VS::ENV_FX_PARAM_FOG_END_COLOR]; - col_begin = _convert_color(col_begin); - col_end = _convert_color(col_end); - float from = current_env->fx_param[VS::ENV_FX_PARAM_FOG_BEGIN]; - float zf = camera_z_far; - float curve = current_env->fx_param[VS::ENV_FX_PARAM_FOG_ATTENUATION]; - material_shader.set_uniform(MaterialShaderGLES2::FOG_PARAMS, Vector3(from, zf, curve)); - material_shader.set_uniform(MaterialShaderGLES2::FOG_COLOR_BEGIN, Vector3(col_begin.r, col_begin.g, col_begin.b)); - material_shader.set_uniform(MaterialShaderGLES2::FOG_COLOR_END, Vector3(col_end.r, col_end.g, col_end.b)); - } - - //material_shader.set_uniform(MaterialShaderGLES2::TIME,Math::fmod(last_time,300.0)); - //if uses TIME - draw_next_frame=true - - return rebind; -} - -void RasterizerGLES2::_setup_light(uint16_t p_light) { - - if (shadow) - return; - - if (p_light == 0xFFFF) - return; - - enum { - VL_LIGHT_POS, - VL_LIGHT_DIR, - VL_LIGHT_ATTENUATION, - VL_LIGHT_SPOT_ATTENUATION, - VL_LIGHT_DIFFUSE, - VL_LIGHT_SPECULAR, - VL_LIGHT_MAX - }; - - static const MaterialShaderGLES2::Uniforms light_uniforms[VL_LIGHT_MAX] = { - MaterialShaderGLES2::LIGHT_POS, - MaterialShaderGLES2::LIGHT_DIRECTION, - MaterialShaderGLES2::LIGHT_ATTENUATION, - MaterialShaderGLES2::LIGHT_SPOT_ATTENUATION, - MaterialShaderGLES2::LIGHT_DIFFUSE, - MaterialShaderGLES2::LIGHT_SPECULAR, - }; - - GLfloat light_data[VL_LIGHT_MAX][3]; - memset(light_data, 0, (VL_LIGHT_MAX)*3 * sizeof(GLfloat)); - - LightInstance *li = light_instances[p_light]; - Light *l = li->base; - - Color col_diffuse = _convert_color(l->colors[VS::LIGHT_COLOR_DIFFUSE]); - Color col_specular = _convert_color(l->colors[VS::LIGHT_COLOR_SPECULAR]); - - for (int j = 0; j < 3; j++) { - light_data[VL_LIGHT_DIFFUSE][j] = col_diffuse[j]; - light_data[VL_LIGHT_SPECULAR][j] = col_specular[j]; - } - - if (l->type != VS::LIGHT_OMNI) { - - Vector3 dir = -li->transform.get_basis().get_axis(2); - dir = camera_transform_inverse.basis.xform(dir).normalized(); - for (int j = 0; j < 3; j++) - light_data[VL_LIGHT_DIR][j] = dir[j]; - } - - if (l->type != VS::LIGHT_DIRECTIONAL) { - - Vector3 pos = li->transform.get_origin(); - pos = camera_transform_inverse.xform(pos); - for (int j = 0; j < 3; j++) - light_data[VL_LIGHT_POS][j] = pos[j]; - } - - if (li->near_shadow_buffer) { - - glActiveTexture(GL_TEXTURE0 + max_texture_units - 1); - glBindTexture(GL_TEXTURE_2D, li->near_shadow_buffer->depth); - - material_shader.set_uniform(MaterialShaderGLES2::SHADOW_MATRIX, li->shadow_projection[0]); - material_shader.set_uniform(MaterialShaderGLES2::SHADOW_TEXEL_SIZE, Vector2(1.0, 1.0) / li->near_shadow_buffer->size); - material_shader.set_uniform(MaterialShaderGLES2::SHADOW_TEXTURE, max_texture_units - 1); - if (shadow_filter == SHADOW_FILTER_ESM) - material_shader.set_uniform(MaterialShaderGLES2::ESM_MULTIPLIER, float(li->base->vars[VS::LIGHT_PARAM_SHADOW_ESM_MULTIPLIER])); - - if (li->base->type == VS::LIGHT_DIRECTIONAL) { - - if (li->base->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) { - - material_shader.set_uniform(MaterialShaderGLES2::SHADOW_MATRIX2, li->shadow_projection[1]); - material_shader.set_uniform(MaterialShaderGLES2::LIGHT_PSSM_SPLIT, Vector3(li->shadow_split[0], li->shadow_split[1], li->shadow_split[2])); - } else if (li->base->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { - - material_shader.set_uniform(MaterialShaderGLES2::SHADOW_MATRIX2, li->shadow_projection[1]); - material_shader.set_uniform(MaterialShaderGLES2::SHADOW_MATRIX3, li->shadow_projection[2]); - material_shader.set_uniform(MaterialShaderGLES2::SHADOW_MATRIX4, li->shadow_projection[3]); - material_shader.set_uniform(MaterialShaderGLES2::LIGHT_PSSM_SPLIT, Vector3(li->shadow_split[0], li->shadow_split[1], li->shadow_split[2])); - } - //print_line("shadow split: "+rtos(li->shadow_split)); - } - - material_shader.set_uniform(MaterialShaderGLES2::SHADOW_DARKENING, li->base->vars[VS::LIGHT_PARAM_SHADOW_DARKENING]); - //matrix - } - - light_data[VL_LIGHT_ATTENUATION][0] = l->vars[VS::LIGHT_PARAM_ENERGY]; - - if (l->type == VS::LIGHT_DIRECTIONAL) { - light_data[VL_LIGHT_ATTENUATION][1] = l->directional_shadow_param[VS::LIGHT_DIRECTIONAL_SHADOW_PARAM_MAX_DISTANCE]; - } else { - light_data[VL_LIGHT_ATTENUATION][1] = l->vars[VS::LIGHT_PARAM_RADIUS]; - } - - light_data[VL_LIGHT_ATTENUATION][2] = l->vars[VS::LIGHT_PARAM_ATTENUATION]; - - light_data[VL_LIGHT_SPOT_ATTENUATION][0] = Math::cos(Math::deg2rad(l->vars[VS::LIGHT_PARAM_SPOT_ANGLE])); - light_data[VL_LIGHT_SPOT_ATTENUATION][1] = l->vars[VS::LIGHT_PARAM_SPOT_ATTENUATION]; - - //int uf = material_shader.get_uniform(MaterialShaderGLES2::LIGHT_PARAMS); - for (int i = 0; i < VL_LIGHT_MAX; i++) { - glUniform3f(material_shader.get_uniform(light_uniforms[i]), light_data[i][0], light_data[i][1], light_data[i][2]); - } -} - -template <bool USE_NORMAL, bool USE_TANGENT, bool INPLACE> -void RasterizerGLES2::_skeleton_xform(const uint8_t *p_src_array, int p_src_stride, uint8_t *p_dst_array, int p_dst_stride, int p_elements, const uint8_t *p_src_bones, const uint8_t *p_src_weights, const Skeleton::Bone *p_bone_xforms) { - - uint32_t basesize = 3; - if (USE_NORMAL) - basesize += 3; - if (USE_TANGENT) - basesize += 4; - - uint32_t extra = (p_dst_stride - basesize * 4); - const int dstvec_size = 3 + (USE_NORMAL ? 3 : 0) + (USE_TANGENT ? 4 : 0); - float dstcopy[dstvec_size]; - - for (int i = 0; i < p_elements; i++) { - - uint32_t ss = p_src_stride * i; - uint32_t ds = p_dst_stride * i; - const uint16_t *bi = (const uint16_t *)&p_src_bones[ss]; - const float *bw = (const float *)&p_src_weights[ss]; - const float *src_vec = (const float *)&p_src_array[ss]; - float *dst_vec; - if (INPLACE) - dst_vec = dstcopy; - else - dst_vec = (float *)&p_dst_array[ds]; - - dst_vec[0] = 0.0; - dst_vec[1] = 0.0; - dst_vec[2] = 0.0; - //conditionals simply removed by optimizer - if (USE_NORMAL) { - - dst_vec[3] = 0.0; - dst_vec[4] = 0.0; - dst_vec[5] = 0.0; - - if (USE_TANGENT) { - - dst_vec[6] = 0.0; - dst_vec[7] = 0.0; - dst_vec[8] = 0.0; - dst_vec[9] = src_vec[9]; - } - } else { - - if (USE_TANGENT) { - - dst_vec[3] = 0.0; - dst_vec[4] = 0.0; - dst_vec[5] = 0.0; - dst_vec[6] = src_vec[6]; - } - } - -#define _XFORM_BONE(m_idx) \ - if (bw[m_idx] == 0) \ - goto end; \ - p_bone_xforms[bi[m_idx]].transform_add_mul3(&src_vec[0], &dst_vec[0], bw[m_idx]); \ - if (USE_NORMAL) { \ - p_bone_xforms[bi[m_idx]].transform3_add_mul3(&src_vec[3], &dst_vec[3], bw[m_idx]); \ - if (USE_TANGENT) { \ - p_bone_xforms[bi[m_idx]].transform3_add_mul3(&src_vec[6], &dst_vec[6], bw[m_idx]); \ - } \ - } else { \ - if (USE_TANGENT) { \ - p_bone_xforms[bi[m_idx]].transform3_add_mul3(&src_vec[3], &dst_vec[3], bw[m_idx]); \ - } \ - } - - _XFORM_BONE(0); - _XFORM_BONE(1); - _XFORM_BONE(2); - _XFORM_BONE(3); - - end: - - if (INPLACE) { - - const uint8_t *esp = (const uint8_t *)dstcopy; - uint8_t *edp = (uint8_t *)&p_dst_array[ds]; - - for (uint32_t j = 0; j < dstvec_size * 4; j++) { - - edp[j] = esp[j]; - } - - } else { - //copy extra stuff - const uint8_t *esp = (const uint8_t *)&src_vec[basesize]; - uint8_t *edp = (uint8_t *)&dst_vec[basesize]; - - for (uint32_t j = 0; j < extra; j++) { - - edp[j] = esp[j]; - } - } - } -} - -Error RasterizerGLES2::_setup_geometry(const Geometry *p_geometry, const Material *p_material, const Skeleton *p_skeleton, const float *p_morphs) { - - switch (p_geometry->type) { - - case Geometry::GEOMETRY_MULTISURFACE: - case Geometry::GEOMETRY_SURFACE: { - - const Surface *surf = NULL; - if (p_geometry->type == Geometry::GEOMETRY_SURFACE) - surf = static_cast<const Surface *>(p_geometry); - else if (p_geometry->type == Geometry::GEOMETRY_MULTISURFACE) - surf = static_cast<const MultiMeshSurface *>(p_geometry)->surface; - - if (surf->format != surf->configured_format) { - if (OS::get_singleton()->is_stdout_verbose()) { - - print_line("has format: " + itos(surf->format)); - print_line("configured format: " + itos(surf->configured_format)); - } - ERR_EXPLAIN("Missing arrays (not set) in surface"); - } - ERR_FAIL_COND_V(surf->format != surf->configured_format, ERR_UNCONFIGURED); - uint8_t *base = 0; - int stride = surf->stride; - bool use_VBO = (surf->array_local == 0); - _setup_geometry_vinfo = surf->array_len; - - bool skeleton_valid = p_skeleton && (surf->format & VS::ARRAY_FORMAT_BONES) && (surf->format & VS::ARRAY_FORMAT_WEIGHTS) && !p_skeleton->bones.empty() && p_skeleton->bones.size() > surf->max_bone; - /* - if (surf->packed) { - float scales[4]={surf->vertex_scale,surf->uv_scale,surf->uv2_scale,0.0}; - glVertexAttrib4fv( 7, scales ); - } else { - glVertexAttrib4f( 7, 1,1,1,1 ); - - }*/ - - if (!use_VBO) { - - DEBUG_TEST_ERROR("Draw NO VBO"); - - base = surf->array_local; - glBindBuffer(GL_ARRAY_BUFFER, 0); - bool can_copy_to_local = surf->local_stride * surf->array_len <= skinned_buffer_size; - if (p_morphs && surf->stride * surf->array_len > skinned_buffer_size) - can_copy_to_local = false; - - if (!can_copy_to_local) - skeleton_valid = false; - - /* compute morphs */ - - if (p_morphs && surf->morph_target_count && can_copy_to_local) { - - base = skinned_buffer; - stride = surf->local_stride; - - //copy all first - float coef = 1.0; - - for (int i = 0; i < surf->morph_target_count; i++) { - if (surf->mesh->morph_target_mode == VS::MORPH_MODE_NORMALIZED) - coef -= p_morphs[i]; - ERR_FAIL_COND_V(surf->morph_format != surf->morph_targets_local[i].configured_format, ERR_INVALID_DATA); - } - - int16_t coeffp = CLAMP(coef * 255, 0, 255); - - for (int i = 0; i < VS::ARRAY_MAX - 1; i++) { - - const Surface::ArrayData &ad = surf->array[i]; - if (ad.size == 0) - continue; - - int ofs = ad.ofs; - int src_stride = surf->stride; - int dst_stride = skeleton_valid ? surf->stride : surf->local_stride; - int count = surf->array_len; - - if (!skeleton_valid && i >= VS::ARRAY_MAX - 3) - break; - - switch (i) { - - case VS::ARRAY_VERTEX: - case VS::ARRAY_NORMAL: - case VS::ARRAY_TANGENT: { - - for (int k = 0; k < count; k++) { - - const float *src = (const float *)&surf->array_local[ofs + k * src_stride]; - float *dst = (float *)&base[ofs + k * dst_stride]; - - dst[0] = src[0] * coef; - dst[1] = src[1] * coef; - dst[2] = src[2] * coef; - }; - - } break; - case VS::ARRAY_COLOR: { - - for (int k = 0; k < count; k++) { - - const uint8_t *src = (const uint8_t *)&surf->array_local[ofs + k * src_stride]; - uint8_t *dst = (uint8_t *)&base[ofs + k * dst_stride]; - - dst[0] = (src[0] * coeffp) >> 8; - dst[1] = (src[1] * coeffp) >> 8; - dst[2] = (src[2] * coeffp) >> 8; - dst[3] = (src[3] * coeffp) >> 8; - } - - } break; - case VS::ARRAY_TEX_UV: - case VS::ARRAY_TEX_UV2: { - - for (int k = 0; k < count; k++) { - - const float *src = (const float *)&surf->array_local[ofs + k * src_stride]; - float *dst = (float *)&base[ofs + k * dst_stride]; - - dst[0] = src[0] * coef; - dst[1] = src[1] * coef; - } - - } break; - case VS::ARRAY_BONES: - case VS::ARRAY_WEIGHTS: { - - for (int k = 0; k < count; k++) { - - const float *src = (const float *)&surf->array_local[ofs + k * src_stride]; - float *dst = (float *)&base[ofs + k * dst_stride]; - - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; - } - - } break; - } - } - - for (int j = 0; j < surf->morph_target_count; j++) { - - for (int i = 0; i < VS::ARRAY_MAX - 3; i++) { - - const Surface::ArrayData &ad = surf->array[i]; - if (ad.size == 0) - continue; - - int ofs = ad.ofs; - int src_stride = surf->local_stride; - int dst_stride = skeleton_valid ? surf->stride : surf->local_stride; - int count = surf->array_len; - const uint8_t *morph = surf->morph_targets_local[j].array; - float w = p_morphs[j]; - int16_t wfp = CLAMP(w * 255, 0, 255); - - switch (i) { - - case VS::ARRAY_VERTEX: - case VS::ARRAY_NORMAL: - case VS::ARRAY_TANGENT: { - - for (int k = 0; k < count; k++) { - - const float *src_morph = (const float *)&morph[ofs + k * src_stride]; - float *dst = (float *)&base[ofs + k * dst_stride]; - - dst[0] += src_morph[0] * w; - dst[1] += src_morph[1] * w; - dst[2] += src_morph[2] * w; - } - - } break; - case VS::ARRAY_COLOR: { - for (int k = 0; k < count; k++) { - - const uint8_t *src = (const uint8_t *)&morph[ofs + k * src_stride]; - uint8_t *dst = (uint8_t *)&base[ofs + k * dst_stride]; - - dst[0] = (src[0] * wfp) >> 8; - dst[1] = (src[1] * wfp) >> 8; - dst[2] = (src[2] * wfp) >> 8; - dst[3] = (src[3] * wfp) >> 8; - } - - } break; - case VS::ARRAY_TEX_UV: - case VS::ARRAY_TEX_UV2: { - - for (int k = 0; k < count; k++) { - - const float *src_morph = (const float *)&morph[ofs + k * src_stride]; - float *dst = (float *)&base[ofs + k * dst_stride]; - - dst[0] += src_morph[0] * w; - dst[1] += src_morph[1] * w; - } - - } break; - } - } - } - - if (skeleton_valid) { - - const uint8_t *src_weights = &surf->array_local[surf->array[VS::ARRAY_WEIGHTS].ofs]; - const uint8_t *src_bones = &surf->array_local[surf->array[VS::ARRAY_BONES].ofs]; - const Skeleton::Bone *skeleton = &p_skeleton->bones[0]; - - if (surf->format & VS::ARRAY_FORMAT_NORMAL && surf->format & VS::ARRAY_FORMAT_TANGENT) - _skeleton_xform<true, true, true>(base, surf->stride, base, surf->stride, surf->array_len, src_bones, src_weights, skeleton); - else if (surf->format & (VS::ARRAY_FORMAT_NORMAL)) - _skeleton_xform<true, false, true>(base, surf->stride, base, surf->stride, surf->array_len, src_bones, src_weights, skeleton); - else if (surf->format & (VS::ARRAY_FORMAT_TANGENT)) - _skeleton_xform<false, true, true>(base, surf->stride, base, surf->stride, surf->array_len, src_bones, src_weights, skeleton); - else - _skeleton_xform<false, false, true>(base, surf->stride, base, surf->stride, surf->array_len, src_bones, src_weights, skeleton); - } - - stride = skeleton_valid ? surf->stride : surf->local_stride; - -#if 0 - { - //in-place skeleton tansformation, only used for morphs, slow. - //should uptimize some day.... - - const uint8_t *src_weights=&surf->array_local[surf->array[VS::ARRAY_WEIGHTS].ofs]; - const uint8_t *src_bones=&surf->array_local[surf->array[VS::ARRAY_BONES].ofs]; - int src_stride = surf->stride; - int count = surf->array_len; - const Transform *skeleton = &p_skeleton->bones[0]; - - for(int i=0;i<VS::ARRAY_MAX-1;i++) { - - const Surface::ArrayData& ad=surf->array[i]; - if (ad.size==0) - continue; - - int ofs = ad.ofs; - - - switch(i) { - - case VS::ARRAY_VERTEX: { - for(int k=0;k<count;k++) { - - float *ptr= (float*)&base[ofs+k*stride]; - const GLfloat* weights = reinterpret_cast<const GLfloat*>(&src_weights[k*src_stride]); - const GLfloat *bones = reinterpret_cast<const GLfloat*>(&src_bones[k*src_stride]); - - Vector3 src( ptr[0], ptr[1], ptr[2] ); - Vector3 dst; - for(int j=0;j<VS::ARRAY_WEIGHTS_SIZE;j++) { - - float w = weights[j]; - if (w==0) - break; - - //print_line("accum "+itos(i)+" += "+rtos(Math::ftoi(bones[j]))+" * "+skeleton[ Math::ftoi(bones[j]) ]+" * "+rtos(w)); - int bidx = Math::fast_ftoi(bones[j]); - dst+=skeleton[ bidx ].xform(src) * w; - } - - ptr[0]=dst.x; - ptr[1]=dst.y; - ptr[2]=dst.z; - - } break; - - } break; - case VS::ARRAY_NORMAL: - case VS::ARRAY_TANGENT: { - for(int k=0;k<count;k++) { - - float *ptr= (float*)&base[ofs+k*stride]; - const GLfloat* weights = reinterpret_cast<const GLfloat*>(&src_weights[k*src_stride]); - const GLfloat *bones = reinterpret_cast<const GLfloat*>(&src_bones[k*src_stride]); - - Vector3 src( ptr[0], ptr[1], ptr[2] ); - Vector3 dst; - for(int j=0;j<VS::ARRAY_WEIGHTS_SIZE;j++) { - - float w = weights[j]; - if (w==0) - break; - - //print_line("accum "+itos(i)+" += "+rtos(Math::ftoi(bones[j]))+" * "+skeleton[ Math::ftoi(bones[j]) ]+" * "+rtos(w)); - int bidx=Math::fast_ftoi(bones[j]); - dst+=skeleton[ bidx ].basis.xform(src) * w; - } - - ptr[0]=dst.x; - ptr[1]=dst.y; - ptr[2]=dst.z; - - } break; - - } break; - } - } - } -#endif - - } else if (skeleton_valid) { - - base = skinned_buffer; - //copy stuff and get it ready for the skeleton - - int dst_stride = surf->stride - (surf->array[VS::ARRAY_BONES].size + surf->array[VS::ARRAY_WEIGHTS].size); - const uint8_t *src_weights = &surf->array_local[surf->array[VS::ARRAY_WEIGHTS].ofs]; - const uint8_t *src_bones = &surf->array_local[surf->array[VS::ARRAY_BONES].ofs]; - const Skeleton::Bone *skeleton = &p_skeleton->bones[0]; - - if (surf->format & VS::ARRAY_FORMAT_NORMAL && surf->format & VS::ARRAY_FORMAT_TANGENT) - _skeleton_xform<true, true, false>(surf->array_local, surf->stride, base, dst_stride, surf->array_len, src_bones, src_weights, skeleton); - else if (surf->format & (VS::ARRAY_FORMAT_NORMAL)) - _skeleton_xform<true, false, false>(surf->array_local, surf->stride, base, dst_stride, surf->array_len, src_bones, src_weights, skeleton); - else if (surf->format & (VS::ARRAY_FORMAT_TANGENT)) - _skeleton_xform<false, true, false>(surf->array_local, surf->stride, base, dst_stride, surf->array_len, src_bones, src_weights, skeleton); - else - _skeleton_xform<false, false, false>(surf->array_local, surf->stride, base, dst_stride, surf->array_len, src_bones, src_weights, skeleton); - - stride = dst_stride; - } - - } else { - - glBindBuffer(GL_ARRAY_BUFFER, surf->vertex_id); - }; - - for (int i = 0; i < (VS::ARRAY_MAX - 1); i++) { - - const Surface::ArrayData &ad = surf->array[i]; - - /* - if (!gl_texcoord_shader[i]) - continue; - */ - - if (ad.size == 0 || !ad.bind) { - glDisableVertexAttribArray(i); - if (i == VS::ARRAY_COLOR) { - _set_color_attrib(Color(1, 1, 1, 1)); - }; - //print_line("disable: "+itos(i)); - continue; // this one is disabled. - } - - glEnableVertexAttribArray(i); - //print_line("set: "+itos(i)+" - count: "+itos(ad.count)+" datatype: "+itos(ad.datatype)+" ofs: "+itos(ad.ofs)+" stride: "+itos(stride)+" total len: "+itos(surf->array_len)); - glVertexAttribPointer(i, ad.count, ad.datatype, ad.normalize, stride, &base[ad.ofs]); - } -#ifdef GLEW_ENABLED - //"desktop" opengl needs this. - if (surf->primitive == VS::PRIMITIVE_POINTS) { - glEnable(GL_POINT_SPRITE); - glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); - - } else { - glDisable(GL_POINT_SPRITE); - glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); - } -#endif - } break; - - default: break; - }; - - return OK; -}; - -static const GLenum gl_primitive[] = { - GL_POINTS, - GL_LINES, - GL_LINE_STRIP, - GL_LINE_LOOP, - GL_TRIANGLES, - GL_TRIANGLE_STRIP, - GL_TRIANGLE_FAN -}; - -void RasterizerGLES2::_render(const Geometry *p_geometry, const Material *p_material, const Skeleton *p_skeleton, const GeometryOwner *p_owner, const Transform &p_xform) { - - _rinfo.object_count++; - - switch (p_geometry->type) { - - case Geometry::GEOMETRY_SURFACE: { - - Surface *s = (Surface *)p_geometry; - - _rinfo.vertex_count += s->array_len; - - if (s->index_array_len > 0) { - - if (s->index_array_local) { - - //print_line("LOCAL F: "+itos(s->format)+" C: "+itos(s->index_array_len)+" VC: "+itos(s->array_len)); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->array_len > (1 << 16)) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, s->index_array_local); - - } else { - //print_line("indices: "+itos(s->index_array_local) ); - - //print_line("VBO F: "+itos(s->format)+" C: "+itos(s->index_array_len)+" VC: "+itos(s->array_len)); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id); - glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->array_len > (1 << 16)) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0); - } - - } else { - - glDrawArrays(gl_primitive[s->primitive], 0, s->array_len); - }; - - _rinfo.draw_calls++; - } break; - - case Geometry::GEOMETRY_MULTISURFACE: { - - material_shader.bind_uniforms(); - Surface *s = static_cast<const MultiMeshSurface *>(p_geometry)->surface; - const MultiMesh *mm = static_cast<const MultiMesh *>(p_owner); - int element_count = mm->elements.size(); - - if (element_count == 0) - return; - - if (mm->visible >= 0) { - element_count = MIN(element_count, mm->visible); - } - - const MultiMesh::Element *elements = &mm->elements[0]; - - _rinfo.vertex_count += s->array_len * element_count; - - _rinfo.draw_calls += element_count; - - if (use_texture_instancing) { - //this is probably the fastest all around way if vertex texture fetch is supported - - float twd = (1.0 / mm->tw) * 4.0; - float thd = 1.0 / mm->th; - float parm[3] = { 0.0, 01.0, (1.0f / mm->tw) }; - glActiveTexture(GL_TEXTURE0 + max_texture_units - 2); - glDisableVertexAttribArray(6); - glBindTexture(GL_TEXTURE_2D, mm->tex_id); - material_shader.set_uniform(MaterialShaderGLES2::INSTANCE_MATRICES, GL_TEXTURE0 + max_texture_units - 2); - - if (s->index_array_len > 0) { - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id); - for (int i = 0; i < element_count; i++) { - parm[0] = (i % (mm->tw >> 2)) * twd; - parm[1] = (i / (mm->tw >> 2)) * thd; - glVertexAttrib3fv(6, parm); - glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->array_len > (1 << 16)) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0); - } - - } else { - - for (int i = 0; i < element_count; i++) { - //parm[0]=(i%(mm->tw>>2))*twd; - //parm[1]=(i/(mm->tw>>2))*thd; - glVertexAttrib3fv(6, parm); - glDrawArrays(gl_primitive[s->primitive], 0, s->array_len); - } - }; - - } else if (use_attribute_instancing) { - //if not, using attributes instead of uniforms can be really fast in forward rendering architectures - if (s->index_array_len > 0) { - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id); - for (int i = 0; i < element_count; i++) { - glVertexAttrib4fv(8, &elements[i].matrix[0]); - glVertexAttrib4fv(9, &elements[i].matrix[4]); - glVertexAttrib4fv(10, &elements[i].matrix[8]); - glVertexAttrib4fv(11, &elements[i].matrix[12]); - glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->array_len > (1 << 16)) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0); - } - - } else { - - for (int i = 0; i < element_count; i++) { - glVertexAttrib4fv(8, &elements[i].matrix[0]); - glVertexAttrib4fv(9, &elements[i].matrix[4]); - glVertexAttrib4fv(10, &elements[i].matrix[8]); - glVertexAttrib4fv(11, &elements[i].matrix[12]); - glDrawArrays(gl_primitive[s->primitive], 0, s->array_len); - } - }; - - } else { - - //nothing to do, slow path (hope no hardware has to use it... but you never know) - - if (s->index_array_len > 0) { - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->index_id); - for (int i = 0; i < element_count; i++) { - - glUniformMatrix4fv(material_shader.get_uniform_location(MaterialShaderGLES2::INSTANCE_TRANSFORM), 1, false, elements[i].matrix); - glDrawElements(gl_primitive[s->primitive], s->index_array_len, (s->array_len > (1 << 16)) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0); - } - - } else { - - for (int i = 0; i < element_count; i++) { - glUniformMatrix4fv(material_shader.get_uniform_location(MaterialShaderGLES2::INSTANCE_TRANSFORM), 1, false, elements[i].matrix); - glDrawArrays(gl_primitive[s->primitive], 0, s->array_len); - } - }; - } - } break; - case Geometry::GEOMETRY_IMMEDIATE: { - - bool restore_tex = false; - const Immediate *im = static_cast<const Immediate *>(p_geometry); - if (im->building) { - return; - } - - glBindBuffer(GL_ARRAY_BUFFER, 0); - - for (const List<Immediate::Chunk>::Element *E = im->chunks.front(); E; E = E->next()) { - - const Immediate::Chunk &c = E->get(); - if (c.vertices.empty()) { - continue; - } - for (int i = 0; i < c.vertices.size(); i++) - - if (c.texture.is_valid() && texture_owner.owns(c.texture)) { - - const Texture *t = texture_owner.get(c.texture); - glActiveTexture(GL_TEXTURE0 + tc0_idx); - glBindTexture(t->target, t->tex_id); - restore_tex = true; - - } else if (restore_tex) { - - glActiveTexture(GL_TEXTURE0 + tc0_idx); - glBindTexture(GL_TEXTURE_2D, tc0_id_cache); - restore_tex = false; - } - - if (!c.normals.empty()) { - - glEnableVertexAttribArray(VS::ARRAY_NORMAL); - glVertexAttribPointer(VS::ARRAY_NORMAL, 3, GL_FLOAT, false, sizeof(Vector3), c.normals.ptr()); - - } else { - - glDisableVertexAttribArray(VS::ARRAY_NORMAL); - } - - if (!c.tangents.empty()) { - - glEnableVertexAttribArray(VS::ARRAY_TANGENT); - glVertexAttribPointer(VS::ARRAY_TANGENT, 4, GL_FLOAT, false, sizeof(Plane), c.tangents.ptr()); - - } else { - - glDisableVertexAttribArray(VS::ARRAY_TANGENT); - } - - if (!c.colors.empty()) { - - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(Color), c.colors.ptr()); - - } else { - - glDisableVertexAttribArray(VS::ARRAY_COLOR); - _set_color_attrib(Color(1, 1, 1, 1)); - } - - if (!c.uvs.empty()) { - - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(Vector2), c.uvs.ptr()); - - } else { - - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); - } - - if (!c.uvs2.empty()) { - - glEnableVertexAttribArray(VS::ARRAY_TEX_UV2); - glVertexAttribPointer(VS::ARRAY_TEX_UV2, 2, GL_FLOAT, false, sizeof(Vector2), c.uvs2.ptr()); - - } else { - - glDisableVertexAttribArray(VS::ARRAY_TEX_UV2); - } - - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, false, sizeof(Vector3), c.vertices.ptr()); - glDrawArrays(gl_primitive[c.primitive], 0, c.vertices.size()); - } - - if (restore_tex) { - - glActiveTexture(GL_TEXTURE0 + tc0_idx); - glBindTexture(GL_TEXTURE_2D, tc0_id_cache); - restore_tex = false; - } - - } break; - case Geometry::GEOMETRY_PARTICLES: { - - //print_line("particulinas"); - const Particles *particles = static_cast<const Particles *>(p_geometry); - ERR_FAIL_COND(!p_owner); - ParticlesInstance *particles_instance = (ParticlesInstance *)p_owner; - - ParticleSystemProcessSW &pp = particles_instance->particles_process; - float td = time_delta; //MIN(time_delta,1.0/10.0); - pp.process(&particles->data, particles_instance->transform, td); - ERR_EXPLAIN("A parameter in the particle system is not correct."); - ERR_FAIL_COND(!pp.valid); - - Transform camera; - if (shadow) - camera = shadow->transform; - else - camera = camera_transform; - - particle_draw_info.prepare(&particles->data, &pp, particles_instance->transform, camera); - _rinfo.draw_calls += particles->data.amount; - - _rinfo.vertex_count += 4 * particles->data.amount; - - { - static const Vector3 points[4] = { - Vector3(-1.0, 1.0, 0), - Vector3(1.0, 1.0, 0), - Vector3(1.0, -1.0, 0), - Vector3(-1.0, -1.0, 0) - }; - static const Vector3 uvs[4] = { - Vector3(0.0, 0.0, 0.0), - Vector3(1.0, 0.0, 0.0), - Vector3(1.0, 1.0, 0.0), - Vector3(0, 1.0, 0.0) - }; - static const Vector3 normals[4] = { - Vector3(0, 0, 1), - Vector3(0, 0, 1), - Vector3(0, 0, 1), - Vector3(0, 0, 1) - }; - - static const Plane tangents[4] = { - Plane(Vector3(1, 0, 0), 0), - Plane(Vector3(1, 0, 0), 0), - Plane(Vector3(1, 0, 0), 0), - Plane(Vector3(1, 0, 0), 0) - }; - - for (int i = 0; i < particles->data.amount; i++) { - - ParticleSystemDrawInfoSW::ParticleDrawInfo &pinfo = *particle_draw_info.draw_info_order[i]; - if (!pinfo.data->active) - continue; - - material_shader.set_uniform(MaterialShaderGLES2::WORLD_TRANSFORM, pinfo.transform); - _set_color_attrib(pinfo.color); - _draw_primitive(4, points, normals, NULL, uvs, tangents); - } - } - - } break; - default: break; - }; -}; - -void RasterizerGLES2::_setup_shader_params(const Material *p_material) { - -#if 0 - int idx=0; - int tex_idx=0; - for(Map<StringName,Variant>::Element *E=p_material->shader_cache->params.front();E;E=E->next(),idx++) { - - Variant v; // - v = E->get(); - const Map<StringName,Variant>::Element *F=p_material->shader_params.find(E->key()); - if (F) - v=F->get(); - - switch(v.get_type() ) { - case Variant::OBJECT: - case Variant::_RID: { - - RID tex=v; - if (!tex.is_valid()) - break; - - Texture *texture = texture_owner.get(tex); - if (!texture) - break; - glUniform1i( material_shader.get_custom_uniform_location(idx), tex_idx); - glActiveTexture(tex_idx); - glBindTexture(texture->target,texture->tex_id); - - } break; - case Variant::COLOR: { - - Color c=v; - material_shader.set_custom_uniform(idx,Vector3(c.r,c.g,c.b)); - } break; - default: { - - material_shader.set_custom_uniform(idx,v); - } break; - } - - } -#endif -} - -void RasterizerGLES2::_setup_skeleton(const Skeleton *p_skeleton) { - - material_shader.set_conditional(MaterialShaderGLES2::USE_SKELETON, p_skeleton != NULL); - if (p_skeleton && p_skeleton->tex_id) { - - glActiveTexture(GL_TEXTURE0 + max_texture_units - 2); - glBindTexture(GL_TEXTURE_2D, p_skeleton->tex_id); - } -} - -void RasterizerGLES2::_render_list_forward(RenderList *p_render_list, const Transform &p_view_transform, const Transform &p_view_transform_inverse, const CameraMatrix &p_projection, bool p_reverse_cull, bool p_fragment_light, bool p_alpha_pass) { - - if (current_rt && current_rt_vflip) { - //p_reverse_cull=!p_reverse_cull; - glFrontFace(GL_CCW); - } - - const Material *prev_material = NULL; - uint16_t prev_light = 0x777E; - const Geometry *prev_geometry_cmp = NULL; - uint8_t prev_light_type = 0xEF; - const Skeleton *prev_skeleton = NULL; - uint8_t prev_sort_flags = 0xFF; - const BakedLightData *prev_baked_light = NULL; - RID prev_baked_light_texture; - const float *prev_morph_values = NULL; - int prev_receive_shadows_state = -1; - - material_shader.set_conditional(MaterialShaderGLES2::USE_VERTEX_LIGHTING, !shadow && !p_fragment_light); - material_shader.set_conditional(MaterialShaderGLES2::USE_FRAGMENT_LIGHTING, !shadow && p_fragment_light); - material_shader.set_conditional(MaterialShaderGLES2::USE_SKELETON, false); - - if (shadow) { - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_DIRECTIONAL, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_OMNI, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_SPOT, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_SHADOW, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM4, false); - material_shader.set_conditional(MaterialShaderGLES2::SHADELESS, false); - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_OCTREE, false); - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP, false); - //material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_TEXTURE,false); - } - - bool stores_glow = !shadow && (current_env && current_env->fx_enabled[VS::ENV_FX_GLOW]) && !p_alpha_pass; - float sampled_light_dp_multiplier = 1.0; - - bool prev_blend = false; - glDisable(GL_BLEND); - for (int i = 0; i < p_render_list->element_count; i++) { - - RenderList::Element *e = p_render_list->elements[i]; - const Material *material = e->material; - uint16_t light = e->light; - uint8_t light_type = e->light_type; - uint8_t sort_flags = e->sort_flags; - const Skeleton *skeleton = e->skeleton; - const Geometry *geometry_cmp = e->geometry_cmp; - const BakedLightData *baked_light = e->instance->baked_light; - const float *morph_values = e->instance->morph_values.ptr(); - int receive_shadows_state = e->instance->receive_shadows == true ? 1 : 0; - - bool rebind = false; - bool bind_baked_light_octree = false; - bool bind_baked_lightmap = false; - bool additive = false; - bool bind_dp_sampler = false; - - if (!shadow) { - - if (texscreen_used && !texscreen_copied && material->shader_cache && material->shader_cache->valid && material->shader_cache->has_texscreen) { - texscreen_copied = true; - _copy_to_texscreen(); - - //force reset state - prev_material = NULL; - prev_light = 0x777E; - prev_geometry_cmp = NULL; - prev_light_type = 0xEF; - prev_skeleton = NULL; - prev_sort_flags = 0xFF; - prev_morph_values = NULL; - prev_receive_shadows_state = -1; - glEnable(GL_BLEND); - glDepthMask(GL_TRUE); - glEnable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - } - - if (light_type != prev_light_type || receive_shadows_state != prev_receive_shadows_state) { - - if (material->flags[VS::MATERIAL_FLAG_UNSHADED] || current_debug == VS::SCENARIO_DEBUG_SHADELESS) { - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_DIRECTIONAL, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_OMNI, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_SPOT, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_SHADOW, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM4, false); - material_shader.set_conditional(MaterialShaderGLES2::SHADELESS, true); - } else { - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_DIRECTIONAL, (light_type & 0x3) == VS::LIGHT_DIRECTIONAL); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_OMNI, (light_type & 0x3) == VS::LIGHT_OMNI); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_TYPE_SPOT, (light_type & 0x3) == VS::LIGHT_SPOT); - if (receive_shadows_state == 1) { - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_SHADOW, (light_type & 0x8)); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM, (light_type & 0x10)); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM4, (light_type & 0x20)); - } else { - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_SHADOW, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM, false); - material_shader.set_conditional(MaterialShaderGLES2::LIGHT_USE_PSSM4, false); - } - material_shader.set_conditional(MaterialShaderGLES2::SHADELESS, false); - } - - rebind = true; - } - - if (!*e->additive_ptr) { - - additive = false; - *e->additive_ptr = true; - } else { - additive = true; - } - - if (stores_glow) - material_shader.set_conditional(MaterialShaderGLES2::USE_GLOW, !additive); - - bool desired_blend = false; - VS::MaterialBlendMode desired_blend_mode = VS::MATERIAL_BLEND_MODE_MIX; - - if (additive) { - desired_blend = true; - desired_blend_mode = VS::MATERIAL_BLEND_MODE_ADD; - } else { - desired_blend = p_alpha_pass; - desired_blend_mode = material->blend_mode; - } - - if (prev_blend != desired_blend) { - - if (desired_blend) { - glEnable(GL_BLEND); - if (!current_rt || !current_rt_transparent) - glColorMask(1, 1, 1, 0); - } else { - glDisable(GL_BLEND); - glColorMask(1, 1, 1, 1); - } - - prev_blend = desired_blend; - } - - if (desired_blend && desired_blend_mode != current_blend_mode) { - - switch (desired_blend_mode) { - - case VS::MATERIAL_BLEND_MODE_MIX: { - glBlendEquation(GL_FUNC_ADD); - if (current_rt && current_rt_transparent) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } else { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - - } break; - case VS::MATERIAL_BLEND_MODE_ADD: { - - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(p_alpha_pass ? GL_SRC_ALPHA : GL_ONE, GL_ONE); - - } break; - case VS::MATERIAL_BLEND_MODE_SUB: { - - glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - } break; - case VS::MATERIAL_BLEND_MODE_MUL: { - glBlendEquation(GL_FUNC_ADD); - if (current_rt && current_rt_transparent) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } else { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - - } break; - } - - current_blend_mode = desired_blend_mode; - } - - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_OCTREE, false); - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP, false); - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_DP_SAMPLER, false); - - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_COLOR, false); - - if (material->flags[VS::MATERIAL_FLAG_UNSHADED] == false && current_debug != VS::SCENARIO_DEBUG_SHADELESS) { - - if (baked_light != NULL) { - if (baked_light->realtime_color_enabled) { - float realtime_energy = baked_light->realtime_energy; - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_COLOR, true); - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_COLOR, Vector3(baked_light->realtime_color.r * realtime_energy, baked_light->realtime_color.g * realtime_energy, baked_light->realtime_color.b * realtime_energy)); - } - } - - if (e->instance->sampled_light.is_valid()) { - - SampledLight *sl = sampled_light_owner.get(e->instance->sampled_light); - if (sl) { - - baked_light = NULL; //can't mix - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_DP_SAMPLER, true); - glActiveTexture(GL_TEXTURE0 + max_texture_units - 3); - glBindTexture(GL_TEXTURE_2D, sl->texture); //bind the texture - sampled_light_dp_multiplier = sl->multiplier; - bind_dp_sampler = true; - } - } - - if (!additive && baked_light) { - - if (baked_light->mode == VS::BAKED_LIGHT_OCTREE && baked_light->octree_texture.is_valid() && e->instance->baked_light_octree_xform) { - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_OCTREE, true); - bind_baked_light_octree = true; - if (prev_baked_light != baked_light) { - Texture *tex = texture_owner.get(baked_light->octree_texture); - if (tex) { - - glActiveTexture(GL_TEXTURE0 + max_texture_units - 3); - glBindTexture(tex->target, tex->tex_id); //bind the texture - } - if (baked_light->light_texture.is_valid()) { - Texture *texl = texture_owner.get(baked_light->light_texture); - if (texl) { - glActiveTexture(GL_TEXTURE0 + max_texture_units - 4); - glBindTexture(texl->target, texl->tex_id); //bind the light texture - } - } - } - } else if (baked_light->mode == VS::BAKED_LIGHT_LIGHTMAPS) { - - int lightmap_idx = e->instance->baked_lightmap_id; - - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP, false); - bind_baked_lightmap = false; - - if (baked_light->lightmaps.has(lightmap_idx)) { - - RID texid = baked_light->lightmaps[lightmap_idx]; - - if (prev_baked_light != baked_light || texid != prev_baked_light_texture) { - - Texture *tex = texture_owner.get(texid); - if (tex) { - - glActiveTexture(GL_TEXTURE0 + max_texture_units - 3); - glBindTexture(tex->target, tex->tex_id); //bind the texture - } - - prev_baked_light_texture = texid; - } - - if (texid.is_valid()) { - material_shader.set_conditional(MaterialShaderGLES2::ENABLE_AMBIENT_LIGHTMAP, true); - bind_baked_lightmap = true; - } - } - } - } - - if (int(prev_baked_light != NULL) ^ int(baked_light != NULL)) { - rebind = true; - } - } - } - - if (sort_flags != prev_sort_flags) { - - if (sort_flags & RenderList::SORT_FLAG_INSTANCING) { - material_shader.set_conditional(MaterialShaderGLES2::USE_UNIFORM_INSTANCING, !use_texture_instancing && !use_attribute_instancing); - material_shader.set_conditional(MaterialShaderGLES2::USE_ATTRIBUTE_INSTANCING, use_attribute_instancing); - material_shader.set_conditional(MaterialShaderGLES2::USE_TEXTURE_INSTANCING, use_texture_instancing); - } else { - material_shader.set_conditional(MaterialShaderGLES2::USE_UNIFORM_INSTANCING, false); - material_shader.set_conditional(MaterialShaderGLES2::USE_ATTRIBUTE_INSTANCING, false); - material_shader.set_conditional(MaterialShaderGLES2::USE_TEXTURE_INSTANCING, false); - } - rebind = true; - } - - if (use_hw_skeleton_xform && (skeleton != prev_skeleton || morph_values != prev_morph_values)) { - if (!prev_skeleton || !skeleton) - rebind = true; //went from skeleton <-> no skeleton, needs rebind - - if (morph_values == NULL) - _setup_skeleton(skeleton); - else - _setup_skeleton(NULL); - } - - if (material != prev_material || rebind) { - - rebind = _setup_material(e->geometry, material, additive, !p_alpha_pass); - - DEBUG_TEST_ERROR("Setup material"); - _rinfo.mat_change_count++; - //_setup_material_overrides(e->material,NULL,material_overrides); - //_setup_material_skeleton(material,skeleton); - } else { - - if (prev_skeleton != skeleton) { - //_setup_material_skeleton(material,skeleton); - }; - } - - if (geometry_cmp != prev_geometry_cmp || prev_skeleton != skeleton) { - - _setup_geometry(e->geometry, material, e->skeleton, e->instance->morph_values.ptr()); - _rinfo.surface_count++; - DEBUG_TEST_ERROR("Setup geometry"); - }; - - if (i == 0 || light != prev_light || rebind) { - if (e->light != 0xFFFF) { - _setup_light(e->light); - } - } - - if (bind_baked_light_octree && (baked_light != prev_baked_light || rebind)) { - - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_INVERSE_TRANSFORM, *e->instance->baked_light_octree_xform); - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_LATTICE_SIZE, baked_light->octree_lattice_size); - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_LATTICE_DIVIDE, baked_light->octree_lattice_divide); - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_STEPS, baked_light->octree_steps); - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_TEX, max_texture_units - 3); - if (baked_light->light_texture.is_valid()) { - - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_LIGHT_TEX, max_texture_units - 4); - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_LIGHT_PIX_SIZE, baked_light->light_tex_pixel_size); - } else { - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_LIGHT_TEX, max_texture_units - 3); - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_LIGHT_PIX_SIZE, baked_light->octree_tex_pixel_size); - } - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_MULTIPLIER, baked_light->texture_multiplier); - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_OCTREE_PIX_SIZE, baked_light->octree_tex_pixel_size); - } - - if (bind_baked_lightmap && (baked_light != prev_baked_light || rebind)) { - - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_LIGHTMAP, max_texture_units - 3); - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_LIGHTMAP_MULTIPLIER, baked_light->lightmap_multiplier); - } - - if (bind_dp_sampler) { - - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_DP_SAMPLER_MULTIPLIER, sampled_light_dp_multiplier); - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_DP_SAMPLER, max_texture_units - 3); - } - - _set_cull(e->mirror, p_reverse_cull); - - if (i == 0 || rebind) { - material_shader.set_uniform(MaterialShaderGLES2::CAMERA_INVERSE_TRANSFORM, p_view_transform_inverse); - material_shader.set_uniform(MaterialShaderGLES2::PROJECTION_TRANSFORM, p_projection); - if (!shadow) { - - if (!additive && current_env && current_env->fx_enabled[VS::ENV_FX_AMBIENT_LIGHT]) { - Color ambcolor = _convert_color(current_env->fx_param[VS::ENV_FX_PARAM_AMBIENT_LIGHT_COLOR]); - float ambnrg = current_env->fx_param[VS::ENV_FX_PARAM_AMBIENT_LIGHT_ENERGY]; - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_LIGHT, Vector3(ambcolor.r * ambnrg, ambcolor.g * ambnrg, ambcolor.b * ambnrg)); - } else { - material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_LIGHT, Vector3()); - } - } - - _rinfo.shader_change_count++; - } - - if (skeleton != prev_skeleton || rebind) { - if (skeleton && morph_values == NULL) { - material_shader.set_uniform(MaterialShaderGLES2::SKELETON_MATRICES, max_texture_units - 2); - material_shader.set_uniform(MaterialShaderGLES2::SKELTEX_PIXEL_SIZE, skeleton->pixel_size); - } - } - - if (e->instance->billboard || e->instance->billboard_y || e->instance->depth_scale) { - - Transform xf = e->instance->transform; - if (e->instance->depth_scale) { - - if (p_projection.matrix[3][3]) { - //orthogonal matrix, try to do about the same - //with viewport size - //real_t w = Math::abs( 1.0/(2.0*(p_projection.matrix[0][0])) ); - real_t h = Math::abs(1.0 / (2.0 * p_projection.matrix[1][1])); - float sc = (h * 2.0); //consistent with Y-fov - xf.basis.scale(Vector3(sc, sc, sc)); - } else { - //just scale by depth - real_t sc = -camera_plane.distance_to(xf.origin); - xf.basis.scale(Vector3(sc, sc, sc)); - } - } - - if (e->instance->billboard) { - - Vector3 scale = xf.basis.get_scale(); - - if (current_rt && current_rt_vflip) { - xf.set_look_at(xf.origin, xf.origin + p_view_transform.get_basis().get_axis(2), -p_view_transform.get_basis().get_axis(1)); - } else { - xf.set_look_at(xf.origin, xf.origin + p_view_transform.get_basis().get_axis(2), p_view_transform.get_basis().get_axis(1)); - } - - xf.basis.scale(scale); - } - - if (e->instance->billboard_y) { - - Vector3 scale = xf.basis.get_scale(); - Vector3 look_at = p_view_transform.get_origin(); - look_at.y = 0.0; - Vector3 look_at_norm = look_at.normalized(); - - if (current_rt && current_rt_vflip) { - xf.set_look_at(xf.origin, xf.origin + look_at_norm, Vector3(0.0, -1.0, 0.0)); - } else { - xf.set_look_at(xf.origin, xf.origin + look_at_norm, Vector3(0.0, 1.0, 0.0)); - } - xf.basis.scale(scale); - } - material_shader.set_uniform(MaterialShaderGLES2::WORLD_TRANSFORM, xf); - - } else { - material_shader.set_uniform(MaterialShaderGLES2::WORLD_TRANSFORM, e->instance->transform); - } - - material_shader.set_uniform(MaterialShaderGLES2::NORMAL_MULT, e->mirror ? -1.0 : 1.0); - material_shader.set_uniform(MaterialShaderGLES2::CONST_LIGHT_MULT, additive ? 0.0 : 1.0); - - _render(e->geometry, material, skeleton, e->owner, e->instance->transform); - DEBUG_TEST_ERROR("Rendering"); - - prev_material = material; - prev_skeleton = skeleton; - prev_geometry_cmp = geometry_cmp; - prev_light = e->light; - prev_light_type = e->light_type; - prev_sort_flags = sort_flags; - prev_baked_light = baked_light; - prev_morph_values = morph_values; - prev_receive_shadows_state = receive_shadows_state; - } - - //print_line("shaderchanges: "+itos(p_alpha_pass)+": "+itos(_rinfo.shader_change_count)); - - if (current_rt && current_rt_vflip) { - glFrontFace(GL_CW); - } -}; - -void RasterizerGLES2::_copy_to_texscreen() { - - //what am i missing? - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); -#ifdef GLEW_ENABLED - glDisable(GL_POINT_SPRITE); - glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); -#endif - glDisable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - if (current_rt && current_rt_transparent) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } else { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - //glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - - for (int i = 0; i < VS::ARRAY_MAX; i++) { - glDisableVertexAttribArray(i); - } - - glActiveTexture(GL_TEXTURE0); - - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.sample_fbo); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, framebuffer.color); - copy_shader.bind(); - _copy_screen_quad(); - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.fbo); -} - -void RasterizerGLES2::_copy_screen_quad() { - - Vector2 dst_pos[4] = { - Vector2(-1, 1), - Vector2(1, 1), - Vector2(1, -1), - Vector2(-1, -1) - }; - - Size2 uvscale( - (viewport.width / float(framebuffer.scale)) / framebuffer.width, - (viewport.height / float(framebuffer.scale)) / framebuffer.height); - - Vector2 src_uv[4] = { - Vector2(0, 1) * uvscale, - Vector2(1, 1) * uvscale, - Vector2(1, 0) * uvscale, - Vector2(0, 0) * uvscale - }; - - Vector2 full_uv[4] = { - Vector2(0, 1), - Vector2(1, 1), - Vector2(1, 0), - Vector2(0, 0) - }; - - _draw_gui_primitive2(4, dst_pos, NULL, src_uv, full_uv); -} - -void RasterizerGLES2::_process_glow_bloom() { - - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.blur[0].fbo); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, framebuffer.color); - copy_shader.set_conditional(CopyShaderGLES2::USE_GLOW_COPY, true); - if (current_vd && current_env->fx_enabled[VS::ENV_FX_HDR]) { - - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR, true); - } - - copy_shader.bind(); - copy_shader.set_uniform(CopyShaderGLES2::BLOOM, float(current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM])); - copy_shader.set_uniform(CopyShaderGLES2::BLOOM_THRESHOLD, float(current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_THRESHOLD])); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE), 0); - - if (current_vd && current_env->fx_enabled[VS::ENV_FX_HDR]) { - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, current_vd->lum_color); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::HDR_SOURCE), 2); - copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_EXPOSURE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE])); - copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_WHITE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_WHITE])); - //copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_WHITE,1.0); - copy_shader.set_uniform(CopyShaderGLES2::HDR_GLOW_THRESHOLD, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_THRESHOLD])); - copy_shader.set_uniform(CopyShaderGLES2::HDR_GLOW_SCALE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE])); - - glActiveTexture(GL_TEXTURE0); - } - - glViewport(0, 0, framebuffer.blur_size, framebuffer.blur_size); - _copy_screen_quad(); - - copy_shader.set_conditional(CopyShaderGLES2::USE_GLOW_COPY, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR, false); - int passes = current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_PASSES]; - Vector2 psize(1.0 / framebuffer.blur_size, 1.0 / framebuffer.blur_size); - float pscale = current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_SCALE]; - float pmag = current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_STRENGTH]; - - for (int i = 0; i < passes; i++) { - - static const Vector2 src_uv[4] = { - Vector2(0, 1), - Vector2(1, 1), - Vector2(1, 0), - Vector2(0, 0) - }; - static const Vector2 dst_pos[4] = { - Vector2(-1, 1), - Vector2(1, 1), - Vector2(1, -1), - Vector2(-1, -1) - }; - - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.blur[1].fbo); - glBindTexture(GL_TEXTURE_2D, framebuffer.blur[0].color); - copy_shader.set_conditional(CopyShaderGLES2::BLUR_V_PASS, true); - copy_shader.set_conditional(CopyShaderGLES2::BLUR_H_PASS, false); - copy_shader.bind(); - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SIZE, psize); - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SCALE, pscale); - copy_shader.set_uniform(CopyShaderGLES2::BLUR_MAGNITUDE, pmag); - - _draw_gui_primitive(4, dst_pos, NULL, src_uv); - - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.blur[0].fbo); - glBindTexture(GL_TEXTURE_2D, framebuffer.blur[1].color); - copy_shader.set_conditional(CopyShaderGLES2::BLUR_V_PASS, false); - copy_shader.set_conditional(CopyShaderGLES2::BLUR_H_PASS, true); - copy_shader.bind(); - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SIZE, psize); - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SCALE, pscale); - copy_shader.set_uniform(CopyShaderGLES2::BLUR_MAGNITUDE, pmag); - - _draw_gui_primitive(4, dst_pos, NULL, src_uv); - } - - copy_shader.set_conditional(CopyShaderGLES2::BLUR_V_PASS, false); - copy_shader.set_conditional(CopyShaderGLES2::BLUR_H_PASS, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR, false); - - //blur it -} - -void RasterizerGLES2::_process_hdr() { - - if (framebuffer.luminance.empty()) { - return; - } - - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.luminance[0].fbo); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, framebuffer.color); - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR_COPY, true); - copy_shader.bind(); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE), 0); - glViewport(0, 0, framebuffer.luminance[0].size, framebuffer.luminance[0].size); - _copy_screen_quad(); - - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR_COPY, false); - //int passes = current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_PASSES]; - - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR_REDUCE, true); - copy_shader.bind(); - - for (int i = 1; i < framebuffer.luminance.size(); i++) { - - static const Vector2 src_uv[4] = { - Vector2(0, 1), - Vector2(1, 1), - Vector2(1, 0), - Vector2(0, 0) - }; - static const Vector2 dst_pos[4] = { - Vector2(-1, 1), - Vector2(1, 1), - Vector2(1, -1), - Vector2(-1, -1) - }; - - Vector2 psize(1.0 / framebuffer.luminance[i - 1].size, 1.0 / framebuffer.luminance[i - 1].size); - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.luminance[i].fbo); - glBindTexture(GL_TEXTURE_2D, framebuffer.luminance[i - 1].color); - glViewport(0, 0, framebuffer.luminance[i].size, framebuffer.luminance[i].size); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE), 0); - - if (framebuffer.luminance[i].size == 1) { - //last step - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR_STORE, true); - copy_shader.bind(); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, current_vd->lum_color); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE_VD_LUM), 1); - copy_shader.set_uniform(CopyShaderGLES2::HDR_TIME_DELTA, time_delta); - copy_shader.set_uniform(CopyShaderGLES2::HDR_EXP_ADJ_SPEED, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED])); - copy_shader.set_uniform(CopyShaderGLES2::MIN_LUMINANCE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE])); - copy_shader.set_uniform(CopyShaderGLES2::MAX_LUMINANCE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE])); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE), 0); - - //swap them - SWAP(current_vd->lum_color, framebuffer.luminance[i].color); - SWAP(current_vd->lum_fbo, framebuffer.luminance[i].fbo); - } - - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SIZE, psize); - - _draw_gui_primitive(4, dst_pos, NULL, src_uv); - } - - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR_REDUCE, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR_STORE, false); - - draw_next_frame = true; -} - -void RasterizerGLES2::_draw_tex_bg() { - - glDepthMask(GL_TRUE); - glEnable(GL_DEPTH_TEST); - glDisable(GL_CULL_FACE); - glDisable(GL_BLEND); - glColorMask(1, 1, 1, 1); - - RID texture; - - if (current_env->bg_mode == VS::ENV_BG_TEXTURE) { - texture = current_env->bg_param[VS::ENV_BG_PARAM_TEXTURE]; - } else { - texture = current_env->bg_param[VS::ENV_BG_PARAM_CUBEMAP]; - } - - if (!texture_owner.owns(texture)) { - return; - } - - Texture *t = texture_owner.get(texture); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(t->target, t->tex_id); - - copy_shader.set_conditional(CopyShaderGLES2::USE_ENERGY, true); - - if (current_env->bg_mode == VS::ENV_BG_TEXTURE) { - copy_shader.set_conditional(CopyShaderGLES2::USE_CUBEMAP, false); - - } else { - copy_shader.set_conditional(CopyShaderGLES2::USE_CUBEMAP, true); - } - - copy_shader.set_conditional(CopyShaderGLES2::USE_CUSTOM_ALPHA, true); - - copy_shader.bind(); - - if (current_env->bg_mode == VS::ENV_BG_TEXTURE) { - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE), 0); - } else { - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE_CUBE), 0); - } - - float nrg = float(current_env->bg_param[VS::ENV_BG_PARAM_ENERGY]); - if (current_env->fx_enabled[VS::ENV_FX_HDR] && !use_fp16_fb) - nrg *= 0.25; //go down a quarter for hdr - copy_shader.set_uniform(CopyShaderGLES2::ENERGY, nrg); - copy_shader.set_uniform(CopyShaderGLES2::CUSTOM_ALPHA, float(current_env->bg_param[VS::ENV_BG_PARAM_GLOW])); - - float flip_sign = (current_env->bg_mode == VS::ENV_BG_TEXTURE && current_rt && current_rt_vflip) ? -1 : 1; - - Vector3 vertices[4] = { - Vector3(-1, -1 * flip_sign, 1), - Vector3(1, -1 * flip_sign, 1), - Vector3(1, 1 * flip_sign, 1), - Vector3(-1, 1 * flip_sign, 1) - }; - - Vector3 src_uv[4] = { - Vector3(0, 1, 0), - Vector3(1, 1, 0), - Vector3(1, 0, 0), - Vector3(0, 0, 0) - }; - - if (current_env->bg_mode == VS::ENV_BG_TEXTURE) { - - //regular texture - //adjust aspect - - float aspect_t = t->width / float(t->height); - float aspect_v = viewport.width / float(viewport.height); - - if (aspect_v > aspect_t) { - //wider than texture - for (int i = 0; i < 4; i++) { - src_uv[i].y = (src_uv[i].y - 0.5) * (aspect_t / aspect_v) + 0.5; - } - - } else { - //narrower than texture - for (int i = 0; i < 4; i++) { - src_uv[i].x = (src_uv[i].x - 0.5) * (aspect_v / aspect_t) + 0.5; - } - } - - float scale = current_env->bg_param[VS::ENV_BG_PARAM_SCALE]; - for (int i = 0; i < 4; i++) { - - src_uv[i].x *= scale; - src_uv[i].y *= scale; - } - } else { - - //skybox uv vectors - float vw, vh, zn; - camera_projection.get_viewport_size(vw, vh); - zn = camera_projection.get_z_near(); - - float scale = current_env->bg_param[VS::ENV_BG_PARAM_SCALE]; - - for (int i = 0; i < 4; i++) { - - Vector3 uv = src_uv[i]; - uv.x = (uv.x * 2.0 - 1.0) * vw * scale; - uv.y = -(uv.y * 2.0 - 1.0) * vh * scale; - uv.z = -zn; - src_uv[i] = camera_transform.basis.xform(uv).normalized(); - src_uv[i].z = -src_uv[i].z; - } - } - - _draw_primitive(4, vertices, NULL, NULL, src_uv); - - copy_shader.set_conditional(CopyShaderGLES2::USE_ENERGY, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_RGBE, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_CUBEMAP, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_CUSTOM_ALPHA, false); -} - -void RasterizerGLES2::end_scene() { - - glEnable(GL_BLEND); - glDepthMask(GL_TRUE); - glEnable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); - - bool use_fb = false; - - if (framebuffer.active) { - - //detect when to use the framebuffer object - if (using_canvas_bg || texscreen_used || framebuffer.scale != 1) { - use_fb = true; - } else if (current_env) { - use_fb = false; - for (int i = 0; i < VS::ENV_FX_MAX; i++) { - - if (i == VS::ENV_FX_FOG) //does not need fb - continue; - - if (current_env->fx_enabled[i]) { - use_fb = true; - break; - } - } - } - } - - if (use_fb) { - - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.fbo); - glViewport(0, 0, viewport.width / framebuffer.scale, viewport.height / framebuffer.scale); - glScissor(0, 0, viewport.width / framebuffer.scale, viewport.height / framebuffer.scale); - - material_shader.set_conditional(MaterialShaderGLES2::USE_8BIT_HDR, !use_fp16_fb && current_env && current_env->fx_enabled[VS::ENV_FX_HDR]); - - } else { - if (current_rt) { - glScissor(0, 0, viewport.width, viewport.height); - } else { - glScissor(viewport.x, window_size.height - (viewport.height + viewport.y), viewport.width, viewport.height); - } - } - - glEnable(GL_SCISSOR_TEST); - _glClearDepth(1.0); - - bool draw_tex_background = false; - - if (current_debug == VS::SCENARIO_DEBUG_OVERDRAW) { - - glClearColor(0, 0, 0, 1); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } else if (current_rt && current_rt_transparent) { - - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - } else if (current_env) { - - switch (current_env->bg_mode) { - - case VS::ENV_BG_CANVAS: - case VS::ENV_BG_KEEP: { - //copy from framebuffer if framebuffer - glClear(GL_DEPTH_BUFFER_BIT); - } break; - case VS::ENV_BG_DEFAULT_COLOR: - case VS::ENV_BG_COLOR: { - - Color bgcolor; - if (current_env->bg_mode == VS::ENV_BG_COLOR) - bgcolor = current_env->bg_param[VS::ENV_BG_PARAM_COLOR]; - else - bgcolor = ProjectSettings::get_singleton()->get("render/default_clear_color"); - bgcolor = _convert_color(bgcolor); - float a = use_fb ? float(current_env->bg_param[VS::ENV_BG_PARAM_GLOW]) : 1.0; - glClearColor(bgcolor.r, bgcolor.g, bgcolor.b, a); - _glClearDepth(1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - } break; - case VS::ENV_BG_TEXTURE: - case VS::ENV_BG_CUBEMAP: { - - glClear(GL_DEPTH_BUFFER_BIT); - draw_tex_background = true; - } break; - } - } else { - - Color c = _convert_color(Color(0.3, 0.3, 0.3)); - glClearColor(c.r, c.g, c.b, 0.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } - - glDisable(GL_SCISSOR_TEST); - - //material_shader.set_uniform_camera(MaterialShaderGLES2::PROJECTION_MATRIX, camera_projection); - - /* - printf("setting projection to "); - for (int i=0; i<16; i++) { - printf("%f, ", ((float*)camera_projection.matrix)[i]); - }; - printf("\n"); - - print_line(String("setting camera to ")+camera_transform_inverse); - */ - //material_shader.set_uniform_default(MaterialShaderGLES2::CAMERA_INVERSE, camera_transform_inverse); - - current_depth_test = true; - current_depth_mask = true; - texscreen_copied = false; - glBlendEquation(GL_FUNC_ADD); - if (current_rt && current_rt_transparent) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } else { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - glDisable(GL_BLEND); - current_blend_mode = VS::MATERIAL_BLEND_MODE_MIX; - - //material_shader.set_conditional(MaterialShaderGLES2::USE_GLOW,current_env && current_env->fx_enabled[VS::ENV_FX_GLOW]); - opaque_render_list.sort_mat_light_type_flags(); - _render_list_forward(&opaque_render_list, camera_transform, camera_transform_inverse, camera_projection, false, fragment_lighting); - - if (draw_tex_background) { - - //most 3D vendors recommend drawing a texture bg or skybox here, - //after opaque geometry has been drawn - //so the zbuffer can get rid of most pixels - _draw_tex_bg(); - } - - glBlendEquation(GL_FUNC_ADD); - if (current_rt && current_rt_transparent) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } else { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - glDisable(GL_BLEND); - current_blend_mode = VS::MATERIAL_BLEND_MODE_MIX; - material_shader.set_conditional(MaterialShaderGLES2::USE_GLOW, false); - if (current_env && current_env->fx_enabled[VS::ENV_FX_GLOW]) { - glColorMask(1, 1, 1, 0); //don't touch alpha - } - - alpha_render_list.sort_z(); - _render_list_forward(&alpha_render_list, camera_transform, camera_transform_inverse, camera_projection, false, fragment_lighting, true); - glColorMask(1, 1, 1, 1); - - //material_shader.set_conditional( MaterialShaderGLES2::USE_FOG,false); - - DEBUG_TEST_ERROR("Drawing Scene"); - -#ifdef GLEW_ENABLED - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); -#endif - - if (use_fb) { - - for (int i = 0; i < VS::ARRAY_MAX; i++) { - glDisableVertexAttribArray(i); - } - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glDisable(GL_CULL_FACE); - glDisable(GL_SCISSOR_TEST); - glDepthMask(false); - - if (current_env && current_env->fx_enabled[VS::ENV_FX_HDR]) { - - int hdr_tm = current_env->fx_param[VS::ENV_FX_PARAM_HDR_TONEMAPPER]; - switch (hdr_tm) { - case VS::ENV_FX_HDR_TONE_MAPPER_LINEAR: { - - } break; - case VS::ENV_FX_HDR_TONE_MAPPER_LOG: { - copy_shader.set_conditional(CopyShaderGLES2::USE_LOG_TONEMAPPER, true); - - } break; - case VS::ENV_FX_HDR_TONE_MAPPER_REINHARDT: { - copy_shader.set_conditional(CopyShaderGLES2::USE_REINHARDT_TONEMAPPER, true); - } break; - case VS::ENV_FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE: { - - copy_shader.set_conditional(CopyShaderGLES2::USE_REINHARDT_TONEMAPPER, true); - copy_shader.set_conditional(CopyShaderGLES2::USE_AUTOWHITE, true); - } break; - } - - _process_hdr(); - } - if (current_env && current_env->fx_enabled[VS::ENV_FX_GLOW]) { - _process_glow_bloom(); - int glow_transfer_mode = current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_BLEND_MODE]; - if (glow_transfer_mode == 1) - copy_shader.set_conditional(CopyShaderGLES2::USE_GLOW_SCREEN, true); - if (glow_transfer_mode == 2) - copy_shader.set_conditional(CopyShaderGLES2::USE_GLOW_SOFTLIGHT, true); - } - - glBindFramebuffer(GL_FRAMEBUFFER, current_rt ? current_rt->fbo : base_framebuffer); - - Size2 size; - if (current_rt) { - glBindFramebuffer(GL_FRAMEBUFFER, current_rt->fbo); - glViewport(0, 0, viewport.width, viewport.height); - size = Size2(viewport.width, viewport.height); - } else { - glBindFramebuffer(GL_FRAMEBUFFER, base_framebuffer); - glViewport(viewport.x, window_size.height - (viewport.height + viewport.y), viewport.width, viewport.height); - size = Size2(viewport.width, viewport.height); - } - - //time to copy!!! - copy_shader.set_conditional(CopyShaderGLES2::USE_BCS, current_env && current_env->fx_enabled[VS::ENV_FX_BCS]); - copy_shader.set_conditional(CopyShaderGLES2::USE_SRGB, current_env && current_env->fx_enabled[VS::ENV_FX_SRGB]); - copy_shader.set_conditional(CopyShaderGLES2::USE_GLOW, current_env && current_env->fx_enabled[VS::ENV_FX_GLOW]); - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR, current_env && current_env->fx_enabled[VS::ENV_FX_HDR]); - copy_shader.set_conditional(CopyShaderGLES2::USE_NO_ALPHA, true); - copy_shader.set_conditional(CopyShaderGLES2::USE_FXAA, current_env && current_env->fx_enabled[VS::ENV_FX_FXAA]); - - copy_shader.bind(); - //copy_shader.set_uniform(CopyShaderGLES2::SOURCE,0); - - if (current_env && current_env->fx_enabled[VS::ENV_FX_GLOW]) { - - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, framebuffer.blur[0].color); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::GLOW_SOURCE), 1); - } - - if (current_env && current_env->fx_enabled[VS::ENV_FX_HDR]) { - - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, current_vd->lum_color); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::HDR_SOURCE), 2); - copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_EXPOSURE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE])); - copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_WHITE, float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_WHITE])); - } - - if (current_env && current_env->fx_enabled[VS::ENV_FX_FXAA]) - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SIZE, Size2(1.0 / size.x, 1.0 / size.y)); - - if (current_env && current_env->fx_enabled[VS::ENV_FX_BCS]) { - - Vector3 bcs; - bcs.x = current_env->fx_param[VS::ENV_FX_PARAM_BCS_BRIGHTNESS]; - bcs.y = current_env->fx_param[VS::ENV_FX_PARAM_BCS_CONTRAST]; - bcs.z = current_env->fx_param[VS::ENV_FX_PARAM_BCS_SATURATION]; - copy_shader.set_uniform(CopyShaderGLES2::BCS, bcs); - } - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, framebuffer.color); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE), 0); - - _copy_screen_quad(); - - copy_shader.set_conditional(CopyShaderGLES2::USE_BCS, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_SRGB, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_GLOW, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_HDR, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_NO_ALPHA, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_FXAA, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_GLOW_SCREEN, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_GLOW_SOFTLIGHT, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_REINHARDT_TONEMAPPER, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_AUTOWHITE, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_LOG_TONEMAPPER, false); - - material_shader.set_conditional(MaterialShaderGLES2::USE_8BIT_HDR, false); - - if (current_env && current_env->fx_enabled[VS::ENV_FX_HDR] && GLOBAL_DEF("rasterizer/debug_hdr", false)) { - _debug_luminances(); - } - } - - current_env = NULL; - current_debug = VS::SCENARIO_DEBUG_DISABLED; - if (GLOBAL_DEF("rasterizer/debug_shadow_maps", false)) { - _debug_shadows(); - } - //_debug_luminances(); - //_debug_samplers(); - - if (using_canvas_bg) { - using_canvas_bg = false; - glColorMask(1, 1, 1, 1); //don't touch alpha - } -} -void RasterizerGLES2::end_shadow_map() { - - ERR_FAIL_COND(!shadow); - - glDisable(GL_BLEND); - glDisable(GL_SCISSOR_TEST); - glDisable(GL_DITHER); - glEnable(GL_DEPTH_TEST); - glDepthMask(true); - - ShadowBuffer *sb = shadow->near_shadow_buffer; - - ERR_FAIL_COND(!sb); - - glBindFramebuffer(GL_FRAMEBUFFER, sb->fbo); - - if (!use_rgba_shadowmaps) - glColorMask(0, 0, 0, 0); - - //glEnable(GL_POLYGON_OFFSET_FILL); - //glPolygonOffset( 8.0f, 16.0f); - - CameraMatrix cm; - float z_near, z_far; - Transform light_transform; - - float dp_direction = 0.0; - bool flip_facing = false; - Rect2 vp_rect; - - switch (shadow->base->type) { - - case VS::LIGHT_DIRECTIONAL: { - - if (shadow->base->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_4_SPLITS) { - - cm = shadow->custom_projection[shadow_pass]; - light_transform = shadow->custom_transform[shadow_pass]; - - if (shadow_pass == 0) { - - vp_rect = Rect2(0, sb->size / 2, sb->size / 2, sb->size / 2); - glViewport(0, sb->size / 2, sb->size / 2, sb->size / 2); - glScissor(0, sb->size / 2, sb->size / 2, sb->size / 2); - } else if (shadow_pass == 1) { - - vp_rect = Rect2(0, 0, sb->size / 2, sb->size / 2); - glViewport(0, 0, sb->size / 2, sb->size / 2); - glScissor(0, 0, sb->size / 2, sb->size / 2); - - } else if (shadow_pass == 2) { - - vp_rect = Rect2(sb->size / 2, sb->size / 2, sb->size / 2, sb->size / 2); - glViewport(sb->size / 2, sb->size / 2, sb->size / 2, sb->size / 2); - glScissor(sb->size / 2, sb->size / 2, sb->size / 2, sb->size / 2); - } else if (shadow_pass == 3) { - - vp_rect = Rect2(sb->size / 2, 0, sb->size / 2, sb->size / 2); - glViewport(sb->size / 2, 0, sb->size / 2, sb->size / 2); - glScissor(sb->size / 2, 0, sb->size / 2, sb->size / 2); - } - - glEnable(GL_SCISSOR_TEST); - - } else if (shadow->base->directional_shadow_mode == VS::LIGHT_DIRECTIONAL_SHADOW_PARALLEL_2_SPLITS) { - - if (shadow_pass == 0) { - - cm = shadow->custom_projection[0]; - light_transform = shadow->custom_transform[0]; - vp_rect = Rect2(0, sb->size / 2, sb->size, sb->size / 2); - glViewport(0, sb->size / 2, sb->size, sb->size / 2); - glScissor(0, sb->size / 2, sb->size, sb->size / 2); - } else { - - cm = shadow->custom_projection[1]; - light_transform = shadow->custom_transform[1]; - vp_rect = Rect2(0, 0, sb->size, sb->size / 2); - glViewport(0, 0, sb->size, sb->size / 2); - glScissor(0, 0, sb->size, sb->size / 2); - } - - glEnable(GL_SCISSOR_TEST); - - } else { - cm = shadow->custom_projection[0]; - light_transform = shadow->custom_transform[0]; - vp_rect = Rect2(0, 0, sb->size, sb->size); - glViewport(0, 0, sb->size, sb->size); - } - - z_near = cm.get_z_near(); - z_far = cm.get_z_far(); - - _glClearDepth(1.0f); - glClearColor(1, 1, 1, 1); - - if (use_rgba_shadowmaps) - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - else - glClear(GL_DEPTH_BUFFER_BIT); - - glDisable(GL_SCISSOR_TEST); - - } break; - case VS::LIGHT_OMNI: { - - material_shader.set_conditional(MaterialShaderGLES2::USE_DUAL_PARABOLOID, true); - dp_direction = shadow_pass ? 1.0 : -1.0; - flip_facing = (shadow_pass == 1); - light_transform = shadow->transform; - z_near = 0; - z_far = shadow->base->vars[VS::LIGHT_PARAM_RADIUS]; - shadow->dp.x = 1.0 / z_far; - shadow->dp.y = dp_direction; - - if (shadow_pass == 0) { - vp_rect = Rect2(0, sb->size / 2, sb->size, sb->size / 2); - glViewport(0, sb->size / 2, sb->size, sb->size / 2); - glScissor(0, sb->size / 2, sb->size, sb->size / 2); - } else { - vp_rect = Rect2(0, 0, sb->size, sb->size / 2); - glViewport(0, 0, sb->size, sb->size / 2); - glScissor(0, 0, sb->size, sb->size / 2); - } - glEnable(GL_SCISSOR_TEST); - shadow->projection = cm; - - glClearColor(1, 1, 1, 1); - _glClearDepth(1.0f); - if (use_rgba_shadowmaps) - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - else - glClear(GL_DEPTH_BUFFER_BIT); - glDisable(GL_SCISSOR_TEST); - - } break; - case VS::LIGHT_SPOT: { - - float far = shadow->base->vars[VS::LIGHT_PARAM_RADIUS]; - ERR_FAIL_COND(far <= 0); - float near = far / 200.0; - if (near < 0.05) - near = 0.05; - - float angle = shadow->base->vars[VS::LIGHT_PARAM_SPOT_ANGLE]; - - cm.set_perspective(angle * 2.0, 1.0, near, far); - - shadow->projection = cm; // cache - light_transform = shadow->transform; - z_near = cm.get_z_near(); - z_far = cm.get_z_far(); - - glViewport(0, 0, sb->size, sb->size); - vp_rect = Rect2(0, 0, sb->size, sb->size); - _glClearDepth(1.0f); - glClearColor(1, 1, 1, 1); - if (use_rgba_shadowmaps) - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); - else - glClear(GL_DEPTH_BUFFER_BIT); - - } break; - } - - Transform light_transform_inverse = light_transform.affine_inverse(); - - opaque_render_list.sort_mat_geom(); - _render_list_forward(&opaque_render_list, light_transform, light_transform_inverse, cm, flip_facing, false); - - material_shader.set_conditional(MaterialShaderGLES2::USE_DUAL_PARABOLOID, false); - - //if (!use_rgba_shadowmaps) - - if (shadow_filter == SHADOW_FILTER_ESM) { - - copy_shader.set_conditional(CopyShaderGLES2::USE_RGBA_DEPTH, use_rgba_shadowmaps); - copy_shader.set_conditional(CopyShaderGLES2::USE_HIGHP_SOURCE, !use_rgba_shadowmaps); - - Vector2 psize(1.0 / sb->size, 1.0 / sb->size); - float pscale = 1.0; - int passes = shadow->base->vars[VS::LIGHT_PARAM_SHADOW_BLUR_PASSES]; - glDisable(GL_BLEND); - glDisable(GL_CULL_FACE); -#ifdef GLEW_ENABLED - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); -#endif - - for (int i = 0; i < VS::ARRAY_MAX; i++) { - glDisableVertexAttribArray(i); - } - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glDisable(GL_SCISSOR_TEST); - - if (!use_rgba_shadowmaps) { - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_ALWAYS); - glDepthMask(true); - } else { - glDisable(GL_DEPTH_TEST); - } - - for (int i = 0; i < passes; i++) { - - Vector2 src_sb_uv[4] = { - (vp_rect.pos + Vector2(0, vp_rect.size.y)) / sb->size, - (vp_rect.pos + vp_rect.size) / sb->size, - (vp_rect.pos + Vector2(vp_rect.size.x, 0)) / sb->size, - (vp_rect.pos) / sb->size - }; - /* - Vector2 src_uv[4]={ - Vector2( 0, 1), - Vector2( 1, 1), - Vector2( 1, 0), - Vector2( 0, 0) - }; -*/ - static const Vector2 dst_pos[4] = { - Vector2(-1, 1), - Vector2(1, 1), - Vector2(1, -1), - Vector2(-1, -1) - }; - - glBindFramebuffer(GL_FRAMEBUFFER, blur_shadow_buffer.fbo); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, sb->depth); -#ifdef GLEW_ENABLED -//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); -#endif - - copy_shader.set_conditional(CopyShaderGLES2::SHADOW_BLUR_V_PASS, true); - copy_shader.set_conditional(CopyShaderGLES2::SHADOW_BLUR_H_PASS, false); - - copy_shader.bind(); - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SIZE, psize); - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SCALE, pscale); - copy_shader.set_uniform(CopyShaderGLES2::BLUR_MAGNITUDE, 1); - //copy_shader.set_uniform(CopyShaderGLES2::SOURCE,0); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE), 0); - - _draw_gui_primitive(4, dst_pos, NULL, src_sb_uv); - - Vector2 src_bb_uv[4] = { - (vp_rect.pos + Vector2(0, vp_rect.size.y)) / blur_shadow_buffer.size, - (vp_rect.pos + vp_rect.size) / blur_shadow_buffer.size, - (vp_rect.pos + Vector2(vp_rect.size.x, 0)) / blur_shadow_buffer.size, - (vp_rect.pos) / blur_shadow_buffer.size, - }; - - glBindFramebuffer(GL_FRAMEBUFFER, sb->fbo); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, blur_shadow_buffer.depth); -#ifdef GLEW_ENABLED - -//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); -#endif - - copy_shader.set_conditional(CopyShaderGLES2::SHADOW_BLUR_V_PASS, false); - copy_shader.set_conditional(CopyShaderGLES2::SHADOW_BLUR_H_PASS, true); - copy_shader.bind(); - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SIZE, psize); - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SCALE, pscale); - copy_shader.set_uniform(CopyShaderGLES2::BLUR_MAGNITUDE, 1); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE), 0); - - _draw_gui_primitive(4, dst_pos, NULL, src_bb_uv); - } - - glDepthFunc(GL_LEQUAL); - copy_shader.set_conditional(CopyShaderGLES2::USE_RGBA_DEPTH, false); - copy_shader.set_conditional(CopyShaderGLES2::USE_HIGHP_SOURCE, false); - copy_shader.set_conditional(CopyShaderGLES2::SHADOW_BLUR_V_PASS, false); - copy_shader.set_conditional(CopyShaderGLES2::SHADOW_BLUR_H_PASS, false); - } - - DEBUG_TEST_ERROR("Drawing Shadow"); - shadow = NULL; - glBindFramebuffer(GL_FRAMEBUFFER, current_rt ? current_rt->fbo : base_framebuffer); - glColorMask(1, 1, 1, 1); - //glDisable(GL_POLYGON_OFFSET_FILL); -} - -void RasterizerGLES2::_debug_draw_shadow(GLuint tex, const Rect2 &p_rect) { - - Transform2D modelview; - modelview.translate(p_rect.pos.x, p_rect.pos.y); - canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, modelview); - glBindTexture(GL_TEXTURE_2D, tex); - - Vector3 coords[4] = { - Vector3(p_rect.pos.x, p_rect.pos.y, 0), - Vector3(p_rect.pos.x + p_rect.size.width, - p_rect.pos.y, 0), - Vector3(p_rect.pos.x + p_rect.size.width, - p_rect.pos.y + p_rect.size.height, 0), - Vector3(p_rect.pos.x, - p_rect.pos.y + p_rect.size.height, 0) - }; - - Vector3 texcoords[4] = { - Vector3(0.0f, 0.0f, 0), - Vector3(1.0f, 0.0f, 0), - Vector3(1.0f, 1.0f, 0), - Vector3(0.0f, 1.0f, 0), - }; - - _draw_primitive(4, coords, 0, 0, texcoords); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); -} - -void RasterizerGLES2::_debug_draw_shadows_type(Vector<ShadowBuffer> &p_shadows, Point2 &ofs) { - - Size2 debug_size(128, 128); - //Size2 debug_size(512,512); - - int useblur = shadow_filter == SHADOW_FILTER_ESM ? 1 : 0; - for (int i = 0; i < p_shadows.size() + useblur; i++) { - - ShadowBuffer *sb = i == p_shadows.size() ? &blur_shadow_buffer : &p_shadows[i]; - - if (!sb->owner && i != p_shadows.size()) - continue; - - _debug_draw_shadow(sb->depth, Rect2(ofs, debug_size)); - ofs.x += debug_size.x; - if ((ofs.x + debug_size.x) > viewport.width) { - - ofs.x = 0; - ofs.y += debug_size.y; - } - } -} - -void RasterizerGLES2::_debug_luminances() { - - canvas_shader.set_conditional(CanvasShaderGLES2::DEBUG_ENCODED_32, !use_fp16_fb); - canvas_begin(); - glDisable(GL_BLEND); - canvas_shader.bind(); - - Size2 debug_size(128, 128); - Size2 ofs; - - for (int i = 0; i <= framebuffer.luminance.size(); i++) { - - if (i == framebuffer.luminance.size()) { - if (!current_vd) - break; - _debug_draw_shadow(current_vd->lum_color, Rect2(ofs, debug_size)); - } else { - _debug_draw_shadow(framebuffer.luminance[i].color, Rect2(ofs, debug_size)); - } - ofs.x += debug_size.x / 2; - if ((ofs.x + debug_size.x) > viewport.width) { - - ofs.x = 0; - ofs.y += debug_size.y; - } - } - - canvas_shader.set_conditional(CanvasShaderGLES2::DEBUG_ENCODED_32, false); -} - -void RasterizerGLES2::_debug_samplers() { - canvas_shader.set_conditional(CanvasShaderGLES2::DEBUG_ENCODED_32, false); - canvas_begin(); - glDisable(GL_BLEND); - _set_color_attrib(Color(1, 1, 1, 1)); - canvas_shader.bind(); - - List<RID> samplers; - sampled_light_owner.get_owned_list(&samplers); - - Size2 debug_size(128, 128); - Size2 ofs; - - for (List<RID>::Element *E = samplers.front(); E; E = E->next()) { - - SampledLight *sl = sampled_light_owner.get(E->get()); - - _debug_draw_shadow(sl->texture, Rect2(ofs, debug_size)); - - ofs.x += debug_size.x / 2; - if ((ofs.x + debug_size.x) > viewport.width) { - - ofs.x = 0; - ofs.y += debug_size.y; - } - } -} -void RasterizerGLES2::_debug_shadows() { - - canvas_begin(); - glDisable(GL_BLEND); - Size2 ofs; - - /* - for(int i=0;i<16;i++) { - glActiveTexture(GL_TEXTURE0+i); - //glDisable(GL_TEXTURE_2D); - } - glActiveTexture(GL_TEXTURE0); - //glEnable(GL_TEXTURE_2D); - */ - - _debug_draw_shadows_type(near_shadow_buffers, ofs); - //_debug_draw_shadows_type(far_shadow_buffers,ofs); -} - -void RasterizerGLES2::end_frame() { - - //print_line("VTX: "+itos(_rinfo.vertex_count)+" OBJ: "+itos(_rinfo.object_count)+" MAT: "+itos(_rinfo.mat_change_count)+" SHD: "+itos(_rinfo.shader_change_count)+" CI: "+itos(_rinfo.ci_draw_commands)); - - //print_line("TOTAL VTX: "+itos(_rinfo.vertex_count)); - OS::get_singleton()->swap_buffers(); -} - -void RasterizerGLES2::flush_frame() { - - glFlush(); -} - -/* CANVAS API */ - -void RasterizerGLES2::begin_canvas_bg() { - - if (framebuffer.active) { - using_canvas_bg = true; - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.fbo); - glViewport(0, 0, viewport.width, viewport.height); - } else { - using_canvas_bg = false; - } -} - -void RasterizerGLES2::canvas_begin() { - - if (using_canvas_bg) { - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.fbo); - glColorMask(1, 1, 1, 0); //don't touch alpha - } - - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glDisable(GL_SCISSOR_TEST); -#ifdef GLEW_ENABLED - glDisable(GL_POINT_SPRITE); - glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); -#endif - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - if (current_rt && current_rt_transparent) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } else { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - //glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - glLineWidth(1.0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - for (int i = 0; i < VS::ARRAY_MAX; i++) { - glDisableVertexAttribArray(i); - } - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, white_tex); - canvas_tex = RID(); - //material_shader.unbind(); - canvas_shader.unbind(); - canvas_shader.set_custom_shader(0); - canvas_shader.set_conditional(CanvasShaderGLES2::USE_MODULATE, false); - canvas_shader.bind(); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXTURE, 0); - canvas_use_modulate = false; - _set_color_attrib(Color(1, 1, 1)); - canvas_transform = Transform(); - canvas_transform.translate(-(viewport.width / 2.0f), -(viewport.height / 2.0f), 0.0f); - float csy = 1.0; - if (current_rt && current_rt_vflip) - csy = -1.0; - - canvas_transform.scale(Vector3(2.0f / viewport.width, csy * -2.0f / viewport.height, 1.0f)); - canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX, canvas_transform); - canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, Transform2D()); - canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX, Transform2D()); - - canvas_opacity = 1.0; - canvas_blend_mode = VS::MATERIAL_BLEND_MODE_MIX; - canvas_texscreen_used = false; - uses_texpixel_size = false; - - canvas_last_material = NULL; -} - -void RasterizerGLES2::canvas_disable_blending() { - - glDisable(GL_BLEND); -} - -void RasterizerGLES2::canvas_set_opacity(float p_opacity) { - - canvas_opacity = p_opacity; -} - -void RasterizerGLES2::canvas_set_blend_mode(VS::MaterialBlendMode p_mode) { - - if (p_mode == canvas_blend_mode) - return; - switch (p_mode) { - - case VS::MATERIAL_BLEND_MODE_MIX: { - glBlendEquation(GL_FUNC_ADD); - if (current_rt && current_rt_transparent) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } else { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - - } break; - case VS::MATERIAL_BLEND_MODE_ADD: { - - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - } break; - case VS::MATERIAL_BLEND_MODE_SUB: { - - glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - } break; - case VS::MATERIAL_BLEND_MODE_MUL: { - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_DST_COLOR, GL_ZERO); - } break; - case VS::MATERIAL_BLEND_MODE_PREMULT_ALPHA: { - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } break; - } - - canvas_blend_mode = p_mode; -} - -void RasterizerGLES2::canvas_begin_rect(const Transform2D &p_transform) { - - canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, p_transform); - canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX, Transform2D()); -} - -void RasterizerGLES2::canvas_set_clip(bool p_clip, const Rect2 &p_rect) { - - if (p_clip) { - - glEnable(GL_SCISSOR_TEST); - //glScissor(viewport.x+p_rect.pos.x,viewport.y+ (viewport.height-(p_rect.pos.y+p_rect.size.height)), - - int x = p_rect.pos.x; - int y = window_size.height - (p_rect.pos.y + p_rect.size.y); - int w = p_rect.size.x; - int h = p_rect.size.y; - - glScissor(x, y, w, h); - - } else { - - glDisable(GL_SCISSOR_TEST); - } -} - -void RasterizerGLES2::canvas_end_rect() { - - //glPopMatrix(); -} - -RasterizerGLES2::Texture *RasterizerGLES2::_bind_canvas_texture(const RID &p_texture) { - - if (p_texture == canvas_tex && !rebind_texpixel_size) { - if (canvas_tex.is_valid()) { - Texture *texture = texture_owner.get(p_texture); - return texture; - } - return NULL; - } - - rebind_texpixel_size = false; - - if (p_texture.is_valid()) { - - Texture *texture = texture_owner.get(p_texture); - if (!texture) { - canvas_tex = RID(); - glBindTexture(GL_TEXTURE_2D, white_tex); - - return NULL; - } - - if (texture->render_target) - texture->render_target->last_pass = frame; - - glBindTexture(GL_TEXTURE_2D, texture->tex_id); - canvas_tex = p_texture; - if (uses_texpixel_size) { - canvas_shader.set_uniform(CanvasShaderGLES2::TEXPIXEL_SIZE, Size2(1.0 / texture->width, 1.0 / texture->height)); - } - return texture; - - } else { - - glBindTexture(GL_TEXTURE_2D, white_tex); - canvas_tex = p_texture; - } - - return NULL; -} - -void RasterizerGLES2::canvas_draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width, bool p_antialiased) { - - _bind_canvas_texture(RID()); - Color c = p_color; - c.a *= canvas_opacity; - _set_color_attrib(c); - - Vector3 verts[2] = { - Vector3(p_from.x, p_from.y, 0), - Vector3(p_to.x, p_to.y, 0) - }; - -#ifdef GLEW_ENABLED - if (p_antialiased) - glEnable(GL_LINE_SMOOTH); -#endif - glLineWidth(p_width); - _draw_primitive(2, verts, 0, 0, 0); - -#ifdef GLEW_ENABLED - if (p_antialiased) - glDisable(GL_LINE_SMOOTH); -#endif - - _rinfo.ci_draw_commands++; -} - -void RasterizerGLES2::_draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs) { - - static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN }; - -//#define GLES_USE_PRIMITIVE_BUFFER - -#ifndef GLES_NO_CLIENT_ARRAYS - - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, false, sizeof(Vector2), p_vertices); - - if (p_colors) { - - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(Color), p_colors); - } else { - glDisableVertexAttribArray(VS::ARRAY_COLOR); - } - - if (p_uvs) { - - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(Vector2), p_uvs); - } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); - } - - glDrawArrays(prim[p_points], 0, p_points); - -#else - - glBindBuffer(GL_ARRAY_BUFFER, gui_quad_buffer); - float b[32]; - int ofs = 0; - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, false, sizeof(float) * 2, ((float *)0) + ofs); - for (int i = 0; i < p_points; i++) { - b[ofs++] = p_vertices[i].x; - b[ofs++] = p_vertices[i].y; - } - - if (p_colors) { - - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(float) * 4, ((float *)0) + ofs); - for (int i = 0; i < p_points; i++) { - b[ofs++] = p_colors[i].r; - b[ofs++] = p_colors[i].g; - b[ofs++] = p_colors[i].b; - b[ofs++] = p_colors[i].a; - } - - } else { - glDisableVertexAttribArray(VS::ARRAY_COLOR); - } - - if (p_uvs) { - - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(float) * 2, ((float *)0) + ofs); - for (int i = 0; i < p_points; i++) { - b[ofs++] = p_uvs[i].x; - b[ofs++] = p_uvs[i].y; - } - - } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); - } - - glBufferSubData(GL_ARRAY_BUFFER, 0, ofs * 4, &b[0]); - glDrawArrays(prim[p_points], 0, p_points); - glBindBuffer(GL_ARRAY_BUFFER, 0); - -#endif - _rinfo.ci_draw_commands++; -} - -void RasterizerGLES2::_draw_gui_primitive2(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const Vector2 *p_uvs2) { - - static const GLenum prim[5] = { GL_POINTS, GL_POINTS, GL_LINES, GL_TRIANGLES, GL_TRIANGLE_FAN }; - - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, false, sizeof(Vector2), p_vertices); - if (p_colors) { - - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(Color), p_colors); - } else { - glDisableVertexAttribArray(VS::ARRAY_COLOR); - } - - if (p_uvs) { - - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(Vector2), p_uvs); - } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); - } - - if (p_uvs2) { - - glEnableVertexAttribArray(VS::ARRAY_TEX_UV2); - glVertexAttribPointer(VS::ARRAY_TEX_UV2, 2, GL_FLOAT, false, sizeof(Vector2), p_uvs2); - } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV2); - } - - glDrawArrays(prim[p_points], 0, p_points); - _rinfo.ci_draw_commands++; -} - -void RasterizerGLES2::_draw_textured_quad(const Rect2 &p_rect, const Rect2 &p_src_region, const Size2 &p_tex_size, bool p_h_flip, bool p_v_flip, bool p_transpose) { - - Vector2 texcoords[4] = { - Vector2(p_src_region.pos.x / p_tex_size.width, - p_src_region.pos.y / p_tex_size.height), - - Vector2((p_src_region.pos.x + p_src_region.size.width) / p_tex_size.width, - p_src_region.pos.y / p_tex_size.height), - - Vector2((p_src_region.pos.x + p_src_region.size.width) / p_tex_size.width, - (p_src_region.pos.y + p_src_region.size.height) / p_tex_size.height), - - Vector2(p_src_region.pos.x / p_tex_size.width, - (p_src_region.pos.y + p_src_region.size.height) / p_tex_size.height) - }; - - if (p_transpose) { - SWAP(texcoords[1], texcoords[3]); - } - if (p_h_flip) { - SWAP(texcoords[0], texcoords[1]); - SWAP(texcoords[2], texcoords[3]); - } - if (p_v_flip) { - SWAP(texcoords[1], texcoords[2]); - SWAP(texcoords[0], texcoords[3]); - } - - Vector2 coords[4] = { - Vector2(p_rect.pos.x, p_rect.pos.y), - Vector2(p_rect.pos.x + p_rect.size.width, p_rect.pos.y), - Vector2(p_rect.pos.x + p_rect.size.width, p_rect.pos.y + p_rect.size.height), - Vector2(p_rect.pos.x, p_rect.pos.y + p_rect.size.height) - }; - - _draw_gui_primitive(4, coords, 0, texcoords); - _rinfo.ci_draw_commands++; -} - -void RasterizerGLES2::_draw_quad(const Rect2 &p_rect) { - - Vector2 coords[4] = { - Vector2(p_rect.pos.x, p_rect.pos.y), - Vector2(p_rect.pos.x + p_rect.size.width, p_rect.pos.y), - Vector2(p_rect.pos.x + p_rect.size.width, p_rect.pos.y + p_rect.size.height), - Vector2(p_rect.pos.x, p_rect.pos.y + p_rect.size.height) - }; - - _draw_gui_primitive(4, coords, 0, 0); - _rinfo.ci_draw_commands++; -} - -void RasterizerGLES2::canvas_draw_rect(const Rect2 &p_rect, int p_flags, const Rect2 &p_source, RID p_texture, const Color &p_modulate) { - - Color m = p_modulate; - m.a *= canvas_opacity; - _set_color_attrib(m); - Texture *texture = _bind_canvas_texture(p_texture); - - if (texture) { - - bool untile = false; - - if (p_flags & CANVAS_RECT_TILE && !(texture->flags & VS::TEXTURE_FLAG_REPEAT)) { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - untile = true; - } - - if (!(p_flags & CANVAS_RECT_REGION)) { - - Rect2 region = Rect2(0, 0, texture->width, texture->height); - _draw_textured_quad(p_rect, region, region.size, p_flags & CANVAS_RECT_FLIP_H, p_flags & CANVAS_RECT_FLIP_V, p_flags & CANVAS_RECT_TRANSPOSE); - - } else { - - _draw_textured_quad(p_rect, p_source, Size2(texture->width, texture->height), p_flags & CANVAS_RECT_FLIP_H, p_flags & CANVAS_RECT_FLIP_V, p_flags & CANVAS_RECT_TRANSPOSE); - } - - if (untile) { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - } - - } else { - - //glDisable(GL_TEXTURE_2D); - _draw_quad(p_rect); - //print_line("rect: "+p_rect); - } - - _rinfo.ci_draw_commands++; -} - -void RasterizerGLES2::canvas_draw_style_box(const Rect2 &p_rect, const Rect2 &p_src_region, RID p_texture, const float *p_margins, bool p_draw_center, const Color &p_modulate) { - - Color m = p_modulate; - m.a *= canvas_opacity; - _set_color_attrib(m); - - Texture *texture = _bind_canvas_texture(p_texture); - ERR_FAIL_COND(!texture); - - Rect2 region = p_src_region; - if (region.size.width <= 0) - region.size.width = texture->width; - if (region.size.height <= 0) - region.size.height = texture->height; - /* CORNERS */ - _draw_textured_quad( // top left - Rect2(p_rect.pos, Size2(p_margins[MARGIN_LEFT], p_margins[MARGIN_TOP])), - Rect2(region.pos, Size2(p_margins[MARGIN_LEFT], p_margins[MARGIN_TOP])), - Size2(texture->width, texture->height)); - - _draw_textured_quad( // top right - Rect2(Point2(p_rect.pos.x + p_rect.size.width - p_margins[MARGIN_RIGHT], p_rect.pos.y), Size2(p_margins[MARGIN_RIGHT], p_margins[MARGIN_TOP])), - Rect2(Point2(region.pos.x + region.size.width - p_margins[MARGIN_RIGHT], region.pos.y), Size2(p_margins[MARGIN_RIGHT], p_margins[MARGIN_TOP])), - Size2(texture->width, texture->height)); - - _draw_textured_quad( // bottom left - Rect2(Point2(p_rect.pos.x, p_rect.pos.y + p_rect.size.height - p_margins[MARGIN_BOTTOM]), Size2(p_margins[MARGIN_LEFT], p_margins[MARGIN_BOTTOM])), - Rect2(Point2(region.pos.x, region.pos.y + region.size.height - p_margins[MARGIN_BOTTOM]), Size2(p_margins[MARGIN_LEFT], p_margins[MARGIN_BOTTOM])), - Size2(texture->width, texture->height)); - - _draw_textured_quad( // bottom right - Rect2(Point2(p_rect.pos.x + p_rect.size.width - p_margins[MARGIN_RIGHT], p_rect.pos.y + p_rect.size.height - p_margins[MARGIN_BOTTOM]), Size2(p_margins[MARGIN_RIGHT], p_margins[MARGIN_BOTTOM])), - Rect2(Point2(region.pos.x + region.size.width - p_margins[MARGIN_RIGHT], region.pos.y + region.size.height - p_margins[MARGIN_BOTTOM]), Size2(p_margins[MARGIN_RIGHT], p_margins[MARGIN_BOTTOM])), - Size2(texture->width, texture->height)); - - Rect2 rect_center(p_rect.pos + Point2(p_margins[MARGIN_LEFT], p_margins[MARGIN_TOP]), Size2(p_rect.size.width - p_margins[MARGIN_LEFT] - p_margins[MARGIN_RIGHT], p_rect.size.height - p_margins[MARGIN_TOP] - p_margins[MARGIN_BOTTOM])); - - Rect2 src_center(Point2(region.pos.x + p_margins[MARGIN_LEFT], region.pos.y + p_margins[MARGIN_TOP]), Size2(region.size.width - p_margins[MARGIN_LEFT] - p_margins[MARGIN_RIGHT], region.size.height - p_margins[MARGIN_TOP] - p_margins[MARGIN_BOTTOM])); - - _draw_textured_quad( // top - Rect2(Point2(rect_center.pos.x, p_rect.pos.y), Size2(rect_center.size.width, p_margins[MARGIN_TOP])), - Rect2(Point2(src_center.pos.x, region.pos.y), Size2(src_center.size.width, p_margins[MARGIN_TOP])), - Size2(texture->width, texture->height)); - - _draw_textured_quad( // bottom - Rect2(Point2(rect_center.pos.x, rect_center.pos.y + rect_center.size.height), Size2(rect_center.size.width, p_margins[MARGIN_BOTTOM])), - Rect2(Point2(src_center.pos.x, src_center.pos.y + src_center.size.height), Size2(src_center.size.width, p_margins[MARGIN_BOTTOM])), - Size2(texture->width, texture->height)); - - _draw_textured_quad( // left - Rect2(Point2(p_rect.pos.x, rect_center.pos.y), Size2(p_margins[MARGIN_LEFT], rect_center.size.height)), - Rect2(Point2(region.pos.x, region.pos.y + p_margins[MARGIN_TOP]), Size2(p_margins[MARGIN_LEFT], src_center.size.height)), - Size2(texture->width, texture->height)); - - _draw_textured_quad( // right - Rect2(Point2(rect_center.pos.x + rect_center.size.width, rect_center.pos.y), Size2(p_margins[MARGIN_RIGHT], rect_center.size.height)), - Rect2(Point2(src_center.pos.x + src_center.size.width, region.pos.y + p_margins[MARGIN_TOP]), Size2(p_margins[MARGIN_RIGHT], src_center.size.height)), - Size2(texture->width, texture->height)); - - if (p_draw_center) { - - _draw_textured_quad( - rect_center, - src_center, - Size2(texture->width, texture->height)); - } - - _rinfo.ci_draw_commands++; -} - -void RasterizerGLES2::canvas_draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width) { - - ERR_FAIL_COND(p_points.size() < 1); - _set_color_attrib(Color(1, 1, 1, canvas_opacity)); - _bind_canvas_texture(p_texture); - _draw_gui_primitive(p_points.size(), p_points.ptr(), p_colors.ptr(), p_uvs.ptr()); - - _rinfo.ci_draw_commands++; -} - -void RasterizerGLES2::canvas_draw_polygon(int p_vertex_count, const int *p_indices, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, const RID &p_texture, bool p_singlecolor) { - - bool do_colors = false; - Color m; - if (p_singlecolor) { - m = *p_colors; - m.a *= canvas_opacity; - _set_color_attrib(m); - } else if (!p_colors) { - m = Color(1, 1, 1, canvas_opacity); - _set_color_attrib(m); - } else - do_colors = true; - - Texture *texture = _bind_canvas_texture(p_texture); - -#ifndef GLES_NO_CLIENT_ARRAYS - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, false, sizeof(Vector2), p_vertices); - if (do_colors) { - - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(Color), p_colors); - } else { - glDisableVertexAttribArray(VS::ARRAY_COLOR); - } - - if (texture && p_uvs) { - - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(Vector2), p_uvs); - } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); - } - - if (p_indices) { -#ifdef GLEW_ENABLED - glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_INT, p_indices); -#else - static const int _max_draw_poly_indices = 16 * 1024; // change this size if needed!!! - ERR_FAIL_COND(p_vertex_count > _max_draw_poly_indices); - static uint16_t _draw_poly_indices[_max_draw_poly_indices]; - for (int i = 0; i < p_vertex_count; i++) { - _draw_poly_indices[i] = p_indices[i]; - }; - glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_SHORT, _draw_poly_indices); -#endif - } else { - glDrawArrays(GL_TRIANGLES, 0, p_vertex_count); - } - -#else //WebGL specific impl. - glBindBuffer(GL_ARRAY_BUFFER, gui_quad_buffer); - float *b = GlobalVertexBuffer; - int ofs = 0; - if (p_vertex_count > MAX_POLYGON_VERTICES) { - print_line("Too many vertices to render"); - return; - } - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, false, sizeof(float) * 2, ((float *)0) + ofs); - for (int i = 0; i < p_vertex_count; i++) { - b[ofs++] = p_vertices[i].x; - b[ofs++] = p_vertices[i].y; - } - - if (p_colors && do_colors) { - - glEnableVertexAttribArray(VS::ARRAY_COLOR); - glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(float) * 4, ((float *)0) + ofs); - for (int i = 0; i < p_vertex_count; i++) { - b[ofs++] = p_colors[i].r; - b[ofs++] = p_colors[i].g; - b[ofs++] = p_colors[i].b; - b[ofs++] = p_colors[i].a; - } - - } else { - glDisableVertexAttribArray(VS::ARRAY_COLOR); - } - - if (p_uvs) { - - glEnableVertexAttribArray(VS::ARRAY_TEX_UV); - glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(float) * 2, ((float *)0) + ofs); - for (int i = 0; i < p_vertex_count; i++) { - b[ofs++] = p_uvs[i].x; - b[ofs++] = p_uvs[i].y; - } - - } else { - glDisableVertexAttribArray(VS::ARRAY_TEX_UV); - } - - glBufferSubData(GL_ARRAY_BUFFER, 0, ofs * 4, &b[0]); - - //bind the indices buffer. - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indices_buffer); - - static const int _max_draw_poly_indices = 16 * 1024; // change this size if needed!!! - ERR_FAIL_COND(p_vertex_count > _max_draw_poly_indices); - static uint16_t _draw_poly_indices[_max_draw_poly_indices]; - for (int i = 0; i < p_vertex_count; i++) { - _draw_poly_indices[i] = p_indices[i]; - //OS::get_singleton()->print("ind: %d ", p_indices[i]); - }; - - //copy the data to GPU. - glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, p_vertex_count * sizeof(uint16_t), &_draw_poly_indices[0]); - - //draw the triangles. - glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_SHORT, 0); - - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -#endif - - _rinfo.ci_draw_commands++; -}; - -void RasterizerGLES2::canvas_set_transform(const Transform2D &p_transform) { - - canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX, p_transform); - - //canvas_transform = Variant(p_transform); -} - -RID RasterizerGLES2::canvas_light_occluder_create() { - - CanvasOccluder *co = memnew(CanvasOccluder); - co->index_id = 0; - co->vertex_id = 0; - co->len = 0; - - return canvas_occluder_owner.make_rid(co); -} - -void RasterizerGLES2::canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2> &p_lines) { - - CanvasOccluder *co = canvas_occluder_owner.get(p_occluder); - ERR_FAIL_COND(!co); - - co->lines = p_lines; - - if (p_lines.size() != co->len) { - - if (co->index_id) - glDeleteBuffers(1, &co->index_id); - if (co->vertex_id) - glDeleteBuffers(1, &co->vertex_id); - - co->index_id = 0; - co->vertex_id = 0; - co->len = 0; - } - - if (p_lines.size()) { - - PoolVector<float> geometry; - PoolVector<uint16_t> indices; - int lc = p_lines.size(); - - geometry.resize(lc * 6); - indices.resize(lc * 3); - - PoolVector<float>::Write vw = geometry.write(); - PoolVector<uint16_t>::Write iw = indices.write(); - - PoolVector<Vector2>::Read lr = p_lines.read(); - - const int POLY_HEIGHT = 16384; - - for (int i = 0; i < lc / 2; i++) { - - vw[i * 12 + 0] = lr[i * 2 + 0].x; - vw[i * 12 + 1] = lr[i * 2 + 0].y; - vw[i * 12 + 2] = POLY_HEIGHT; - - vw[i * 12 + 3] = lr[i * 2 + 1].x; - vw[i * 12 + 4] = lr[i * 2 + 1].y; - vw[i * 12 + 5] = POLY_HEIGHT; - - vw[i * 12 + 6] = lr[i * 2 + 1].x; - vw[i * 12 + 7] = lr[i * 2 + 1].y; - vw[i * 12 + 8] = -POLY_HEIGHT; - - vw[i * 12 + 9] = lr[i * 2 + 0].x; - vw[i * 12 + 10] = lr[i * 2 + 0].y; - vw[i * 12 + 11] = -POLY_HEIGHT; - - iw[i * 6 + 0] = i * 4 + 0; - iw[i * 6 + 1] = i * 4 + 1; - iw[i * 6 + 2] = i * 4 + 2; - - iw[i * 6 + 3] = i * 4 + 2; - iw[i * 6 + 4] = i * 4 + 3; - iw[i * 6 + 5] = i * 4 + 0; - } - - //if same buffer len is being set, just use BufferSubData to avoid a pipeline flush - - if (!co->vertex_id) { - glGenBuffers(1, &co->vertex_id); - glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id); - glBufferData(GL_ARRAY_BUFFER, lc * 6 * sizeof(real_t), vw.ptr(), GL_STATIC_DRAW); - } else { - - glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id); - glBufferSubData(GL_ARRAY_BUFFER, 0, lc * 6 * sizeof(real_t), vw.ptr()); - } - - glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind - - if (!co->index_id) { - - glGenBuffers(1, &co->index_id); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, co->index_id); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, lc * 3 * sizeof(uint16_t), iw.ptr(), GL_STATIC_DRAW); - } else { - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, co->index_id); - glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, lc * 3 * sizeof(uint16_t), iw.ptr()); - } - - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); //unbind - - co->len = lc; - } -} - -RID RasterizerGLES2::canvas_light_shadow_buffer_create(int p_width) { - - CanvasLightShadow *cls = memnew(CanvasLightShadow); - if (p_width > max_texture_size) - p_width = max_texture_size; - - cls->size = p_width; - glActiveTexture(GL_TEXTURE0); - - glGenFramebuffers(1, &cls->fbo); - glBindFramebuffer(GL_FRAMEBUFFER, cls->fbo); - - // Create a render buffer - glGenRenderbuffers(1, &cls->rbo); - glBindRenderbuffer(GL_RENDERBUFFER, cls->rbo); - - // Create a texture for storing the depth - glGenTextures(1, &cls->depth); - glBindTexture(GL_TEXTURE_2D, cls->depth); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - // Remove artifact on the edges of the shadowmap - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - cls->height = 16; - - //print_line("ERROR? "+itos(glGetError())); - if (read_depth_supported) { - - // We'll use a depth texture to store the depths in the shadow map - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, cls->size, cls->height, 0, - GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); - -#ifdef GLEW_ENABLED - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -#endif - - // Attach the depth texture to FBO depth attachment point - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_TEXTURE_2D, cls->depth, 0); - -#ifdef GLEW_ENABLED - glDrawBuffer(GL_NONE); -#endif - - } else { - // We'll use a RGBA texture into which we pack the depth info - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, cls->size, cls->height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - - // Attach the RGBA texture to FBO color attachment point - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, cls->depth, 0); - cls->rgba = cls->depth; - - // Allocate 16-bit depth buffer - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, cls->size, cls->height); - - // Attach the render buffer as depth buffer - will be ignored - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_RENDERBUFFER, cls->rbo); - } - - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); -//printf("errnum: %x\n",status); -#ifdef GLEW_ENABLED - if (read_depth_supported) { - //glDrawBuffer(GL_BACK); - } -#endif - glBindFramebuffer(GL_FRAMEBUFFER, base_framebuffer); - DEBUG_TEST_ERROR("2D Shadow Buffer Init"); - ERR_FAIL_COND_V(status != GL_FRAMEBUFFER_COMPLETE, RID()); - -#ifdef GLEW_ENABLED - if (read_depth_supported) { - //glDrawBuffer(GL_BACK); - } -#endif - - return canvas_light_shadow_owner.make_rid(cls); -} - -void RasterizerGLES2::canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, CanvasLightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) { - - CanvasLightShadow *cls = canvas_light_shadow_owner.get(p_buffer); - ERR_FAIL_COND(!cls); - - glDisable(GL_BLEND); - glDisable(GL_SCISSOR_TEST); - glDisable(GL_DITHER); - glDisable(GL_CULL_FACE); - glDepthFunc(GL_LEQUAL); - glEnable(GL_DEPTH_TEST); - glDepthMask(true); - - glBindFramebuffer(GL_FRAMEBUFFER, cls->fbo); - - if (!use_rgba_shadowmaps) - glColorMask(0, 0, 0, 0); - - glEnableVertexAttribArray(VS::ARRAY_VERTEX); - canvas_shadow_shader.bind(); - - glViewport(0, 0, cls->size, cls->height); - _glClearDepth(1.0f); - glClearColor(1, 1, 1, 1); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - VS::CanvasOccluderPolygonCullMode cull = VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; - - for (int i = 0; i < 4; i++) { - - //make sure it remains orthogonal, makes easy to read angle later - - Transform light; - light.origin[0] = p_light_xform[2][0]; - light.origin[1] = p_light_xform[2][1]; - light.basis[0][0] = p_light_xform[0][0]; - light.basis[0][1] = p_light_xform[1][0]; - light.basis[1][0] = p_light_xform[0][1]; - light.basis[1][1] = p_light_xform[1][1]; - - //light.basis.scale(Vector3(to_light.elements[0].length(),to_light.elements[1].length(),1)); - - / //p_near=1; - CameraMatrix projection; - { - real_t fov = 90; - real_t near = p_near; - real_t far = p_far; - real_t aspect = 1.0; - - real_t ymax = near * Math::tan(Math::deg2rad(fov * 0.5)); - real_t ymin = -ymax; - real_t xmin = ymin * aspect; - real_t xmax = ymax * aspect; - - projection.set_frustum(xmin, xmax, ymin, ymax, near, far); - } - - Vector3 cam_target = Matrix3(Vector3(0, 0, Math_PI * 2 * (i / 4.0))).xform(Vector3(0, 1, 0)); - projection = projection * CameraMatrix(Transform().looking_at(cam_target, Vector3(0, 0, -1)).affine_inverse()); - - canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::PROJECTION_MATRIX, projection); - canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::LIGHT_MATRIX, light); - - if (i == 0) - *p_xform_cache = projection; - - glViewport(0, (cls->height / 4) * i, cls->size, cls->height / 4); - - CanvasLightOccluderInstance *instance = p_occluders; - - while (instance) { - - CanvasOccluder *cc = canvas_occluder_owner.get(instance->polygon_buffer); - if (!cc || cc->len == 0 || !(p_light_mask & instance->light_mask)) { - - instance = instance->next; - continue; - } - - canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::WORLD_MATRIX, instance->xform_cache); - if (cull != instance->cull_cache) { - - cull = instance->cull_cache; - switch (cull) { - case VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: { - - glDisable(GL_CULL_FACE); - - } break; - case VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE: { - - glEnable(GL_CULL_FACE); - glCullFace(GL_FRONT); - } break; - case VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE: { - - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); - - } break; - } - } - /* - if (i==0) { - for(int i=0;i<cc->lines.size();i++) { - Vector2 p = instance->xform_cache.xform(cc->lines.get(i)); - Plane pp(Vector3(p.x,p.y,0),1); - pp.normal = light.xform(pp.normal); - pp = projection.xform4(pp); - print_line(itos(i)+": "+pp.normal/pp.d); - //pp=light_mat.xform4(pp); - //print_line(itos(i)+": "+pp.normal/pp.d); - } - } -*/ - glBindBuffer(GL_ARRAY_BUFFER, cc->vertex_id); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, cc->index_id); - glVertexAttribPointer(VS::ARRAY_VERTEX, 3, GL_FLOAT, false, 0, 0); - glDrawElements(GL_TRIANGLES, cc->len * 3, GL_UNSIGNED_SHORT, 0); - - instance = instance->next; - } - } - - glDisableVertexAttribArray(VS::ARRAY_VERTEX); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - - if (shadow_filter == SHADOW_FILTER_ESM) { -//blur the buffer -#if 0 - //this is ignord, it did not make any difference.. - if (read_depth_supported) { - glDepthFunc(GL_ALWAYS); - } else { - glDisable(GL_DEPTH_TEST); - glDepthMask(false); - } - glDisable(GL_CULL_FACE); - glViewport(0, 0, cls->size,cls->height); - - int passes=1; - CanvasLightShadow *blur = canvas_light_shadow_owner.get(canvas_shadow_blur); - - copy_shader.set_conditional(CopyShaderGLES2::SHADOW_BLUR_H_PASS,true); - copy_shader.bind(); - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SCALE,1); - copy_shader.set_uniform(CopyShaderGLES2::BLUR_MAGNITUDE,1); - glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::SOURCE),0); - - for(int i=0;i<passes;i++) { - - glBindFramebuffer(GL_FRAMEBUFFER, blur->fbo); - glActiveTexture(GL_TEXTURE0); - - if (read_depth_supported) - glBindTexture(GL_TEXTURE_2D,cls->depth); - else - glBindTexture(GL_TEXTURE_2D,cls->rgba); - - - { - Vector2 src_sb_uv[4]={ - Vector2( 0, 1), - Vector2( 1, 1), - Vector2( 1, 0), - Vector2( 0, 0) - }; - static const Vector2 dst_pos[4]={ - Vector2(-1, 1), - Vector2( 1, 1), - Vector2( 1,-1), - Vector2(-1,-1) - }; - - - - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SIZE,Vector2(1.0,1.0)/cls->size); - _draw_gui_primitive(4,dst_pos,NULL,src_sb_uv); - } - - glActiveTexture(GL_TEXTURE0); - if (read_depth_supported) - glBindTexture(GL_TEXTURE_2D,blur->depth); - else - glBindTexture(GL_TEXTURE_2D,blur->rgba); - - glBindFramebuffer(GL_FRAMEBUFFER, cls->fbo); - - { - float hlimit = float(cls->size) / blur->size; - //hlimit*=2.0; - Vector2 src_sb_uv[4]={ - Vector2( 0, 1), - Vector2( hlimit, 1), - Vector2( hlimit, 0), - Vector2( 0, 0) - }; - static const Vector2 dst_pos[4]={ - Vector2(-1, 1), - Vector2( 1, 1), - Vector2( 1,-1), - Vector2(-1,-1) - }; - - - copy_shader.set_uniform(CopyShaderGLES2::PIXEL_SIZE,Vector2(1.0,1.0)/blur->size); - _draw_gui_primitive(4,dst_pos,NULL,src_sb_uv); - } - - } - copy_shader.set_conditional(CopyShaderGLES2::SHADOW_BLUR_H_PASS,false); - glDepthFunc(GL_LEQUAL); -#endif - } - - glBindFramebuffer(GL_FRAMEBUFFER, current_rt ? current_rt->fbo : base_framebuffer); - glColorMask(1, 1, 1, 1); -} - -void RasterizerGLES2::canvas_debug_viewport_shadows(CanvasLight *p_lights_with_shadow) { - - CanvasLight *light = p_lights_with_shadow; - - canvas_begin(); //reset - - int h = 10; - int w = viewport.width; - int ofs = h; - - //print_line(" debug lights "); - while (light) { - - //print_line("debug light"); - if (light->shadow_buffer.is_valid()) { - - //print_line("sb is valid"); - CanvasLightShadow *sb = canvas_light_shadow_owner.get(light->shadow_buffer); - if (sb) { - glActiveTexture(GL_TEXTURE0); - if (read_depth_supported) - glBindTexture(GL_TEXTURE_2D, sb->depth); - else - glBindTexture(GL_TEXTURE_2D, sb->rgba); - _draw_textured_quad(Rect2(h, ofs, w - h * 2, h), Rect2(0, 0, sb->size, 10), Size2(sb->size, 10), false, false); - ofs += h * 2; - } - } - - light = light->shadows_next_ptr; - } -} - -void RasterizerGLES2::_canvas_normal_set_flip(const Vector2 &p_flip) { - - if (p_flip == normal_flip) - return; - normal_flip = p_flip; - canvas_shader.set_uniform(CanvasShaderGLES2::NORMAL_FLIP, normal_flip); -} - -template <bool use_normalmap> -void RasterizerGLES2::_canvas_item_render_commands(CanvasItem *p_item, CanvasItem *current_clip, bool &reclip) { - - int cc = p_item->commands.size(); - CanvasItem::Command **commands = p_item->commands.ptr(); - - for (int i = 0; i < cc; i++) { - - CanvasItem::Command *c = commands[i]; - - switch (c->type) { - case CanvasItem::Command::TYPE_LINE: { - - CanvasItem::CommandLine *line = static_cast<CanvasItem::CommandLine *>(c); - canvas_draw_line(line->from, line->to, line->color, line->width, line->antialiased); - } break; - case CanvasItem::Command::TYPE_RECT: { - - CanvasItem::CommandRect *rect = static_cast<CanvasItem::CommandRect *>(c); -//canvas_draw_rect(rect->rect,rect->region,rect->source,rect->flags&CanvasItem::CommandRect::FLAG_TILE,rect->flags&CanvasItem::CommandRect::FLAG_FLIP_H,rect->flags&CanvasItem::CommandRect::FLAG_FLIP_V,rect->texture,rect->modulate); -#if 0 - int flags=0; - - if (rect->flags&CanvasItem::CommandRect::FLAG_REGION) { - flags|=Rasterizer::CANVAS_RECT_REGION; - } - if (rect->flags&CanvasItem::CommandRect::FLAG_TILE) { - flags|=Rasterizer::CANVAS_RECT_TILE; - } - if (rect->flags&CanvasItem::CommandRect::FLAG_FLIP_H) { - - flags|=Rasterizer::CANVAS_RECT_FLIP_H; - } - if (rect->flags&CanvasItem::CommandRect::FLAG_FLIP_V) { - - flags|=Rasterizer::CANVAS_RECT_FLIP_V; - } -#else - - int flags = rect->flags; -#endif - if (use_normalmap) - _canvas_normal_set_flip(Vector2((flags & CANVAS_RECT_FLIP_H) ? -1 : 1, (flags & CANVAS_RECT_FLIP_V) ? -1 : 1)); - canvas_draw_rect(rect->rect, flags, rect->source, rect->texture, rect->modulate); - - } break; - case CanvasItem::Command::TYPE_STYLE: { - - CanvasItem::CommandStyle *style = static_cast<CanvasItem::CommandStyle *>(c); - if (use_normalmap) - _canvas_normal_set_flip(Vector2(1, 1)); - canvas_draw_style_box(style->rect, style->source, style->texture, style->margin, style->draw_center, style->color); - - } break; - case CanvasItem::Command::TYPE_PRIMITIVE: { - - if (use_normalmap) - _canvas_normal_set_flip(Vector2(1, 1)); - CanvasItem::CommandPrimitive *primitive = static_cast<CanvasItem::CommandPrimitive *>(c); - canvas_draw_primitive(primitive->points, primitive->colors, primitive->uvs, primitive->texture, primitive->width); - } break; - case CanvasItem::Command::TYPE_POLYGON: { - - if (use_normalmap) - _canvas_normal_set_flip(Vector2(1, 1)); - CanvasItem::CommandPolygon *polygon = static_cast<CanvasItem::CommandPolygon *>(c); - canvas_draw_polygon(polygon->count, polygon->indices.ptr(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->texture, polygon->colors.size() == 1); - - } break; - - case CanvasItem::Command::TYPE_POLYGON_PTR: { - - if (use_normalmap) - _canvas_normal_set_flip(Vector2(1, 1)); - CanvasItem::CommandPolygonPtr *polygon = static_cast<CanvasItem::CommandPolygonPtr *>(c); - canvas_draw_polygon(polygon->count, polygon->indices, polygon->points, polygon->uvs, polygon->colors, polygon->texture, false); - } break; - case CanvasItem::Command::TYPE_CIRCLE: { - - CanvasItem::CommandCircle *circle = static_cast<CanvasItem::CommandCircle *>(c); - static const int numpoints = 32; - Vector2 points[numpoints + 1]; - points[numpoints] = circle->pos; - int indices[numpoints * 3]; - - for (int i = 0; i < numpoints; i++) { - - points[i] = circle->pos + Vector2(Math::sin(i * Math_PI * 2.0 / numpoints), Math::cos(i * Math_PI * 2.0 / numpoints)) * circle->radius; - indices[i * 3 + 0] = i; - indices[i * 3 + 1] = (i + 1) % numpoints; - indices[i * 3 + 2] = numpoints; - } - canvas_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 CanvasItem::Command::TYPE_TRANSFORM: { - - CanvasItem::CommandTransform *transform = static_cast<CanvasItem::CommandTransform *>(c); - canvas_set_transform(transform->xform); - } break; - case CanvasItem::Command::TYPE_BLEND_MODE: { - - CanvasItem::CommandBlendMode *bm = static_cast<CanvasItem::CommandBlendMode *>(c); - canvas_set_blend_mode(bm->blend_mode); - - } break; - case CanvasItem::Command::TYPE_CLIP_IGNORE: { - - CanvasItem::CommandClipIgnore *ci = static_cast<CanvasItem::CommandClipIgnore *>(c); - if (current_clip) { - - if (ci->ignore != reclip) { - if (ci->ignore) { - - glDisable(GL_SCISSOR_TEST); - reclip = true; - } else { - - glEnable(GL_SCISSOR_TEST); - //glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)), - //current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height); - - int x; - int y; - int w; - int h; - - if (current_rt) { - x = current_clip->final_clip_rect.pos.x; - y = current_clip->final_clip_rect.pos.y; - w = current_clip->final_clip_rect.size.x; - h = current_clip->final_clip_rect.size.y; - } else { - x = current_clip->final_clip_rect.pos.x; - y = window_size.height - (current_clip->final_clip_rect.pos.y + current_clip->final_clip_rect.size.y); - w = current_clip->final_clip_rect.size.x; - h = current_clip->final_clip_rect.size.y; - } - - glScissor(x, y, w, h); - - reclip = false; - } - } - } - - } break; - } - } -} - -void RasterizerGLES2::_canvas_item_setup_shader_params(ShaderMaterial *material, Shader *p_shader) { - - if (canvas_shader.bind()) - rebind_texpixel_size = true; - - if (material->shader_version != p_shader->version) { - //todo optimize uniforms - material->shader_version = p_shader->version; - } - - if (p_shader->has_texscreen && framebuffer.active) { - - int x = viewport.x; - int y = window_size.height - (viewport.height + viewport.y); - - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_MULT, Vector2(float(viewport.width) / framebuffer.width, float(viewport.height) / framebuffer.height)); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_CLAMP, Color(float(x) / framebuffer.width, float(y) / framebuffer.height, float(x + viewport.width) / framebuffer.width, float(y + viewport.height) / framebuffer.height)); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_TEX, max_texture_units - 1); - glActiveTexture(GL_TEXTURE0 + max_texture_units - 1); - glBindTexture(GL_TEXTURE_2D, framebuffer.sample_color); - if (framebuffer.scale == 1 && !canvas_texscreen_used) { -#ifdef GLEW_ENABLED - if (current_rt) { - glReadBuffer(GL_COLOR_ATTACHMENT0); - } else { - glReadBuffer(GL_BACK); - } -#endif - if (current_rt) { - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, viewport.x, viewport.y, viewport.x, viewport.y, viewport.width, viewport.height); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_CLAMP, Color(float(x) / framebuffer.width, float(viewport.y) / framebuffer.height, float(x + viewport.width) / framebuffer.width, float(y + viewport.height) / framebuffer.height)); - //window_size.height-(viewport.height+viewport.y) - } else { - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, x, y, viewport.width, viewport.height); - } - - canvas_texscreen_used = true; - } - - glActiveTexture(GL_TEXTURE0); - } - - if (p_shader->has_screen_uv) { - canvas_shader.set_uniform(CanvasShaderGLES2::SCREEN_UV_MULT, Vector2(1.0 / viewport.width, 1.0 / viewport.height)); - } - - uses_texpixel_size = p_shader->uses_texpixel_size; -} - -void RasterizerGLES2::_canvas_item_setup_shader_uniforms(ShaderMaterial *material, Shader *p_shader) { - - //this can be optimized.. - int tex_id = 1; - int idx = 0; - for (Map<StringName, ShaderLanguage::Uniform>::Element *E = p_shader->uniforms.front(); E; E = E->next()) { - - Map<StringName, Variant>::Element *F = material->shader_param.find(E->key()); - - if ((E->get().type == ShaderLanguage::TYPE_TEXTURE || E->get().type == ShaderLanguage::TYPE_CUBEMAP)) { - - RID rid; - if (F) { - rid = F->get(); - } - - if (!rid.is_valid()) { - - Map<StringName, RID>::Element *DT = p_shader->default_textures.find(E->key()); - if (DT) { - rid = DT->get(); - } - } - - if (rid.is_valid()) { - - int loc = canvas_shader.get_custom_uniform_location(idx); //should be automatic.. - - glActiveTexture(GL_TEXTURE0 + tex_id); - Texture *t = texture_owner.get(rid); - if (!t) - glBindTexture(GL_TEXTURE_2D, white_tex); - else - glBindTexture(t->target, t->tex_id); - - glUniform1i(loc, tex_id); - tex_id++; - } - } else { - Variant &v = F ? F->get() : E->get().default_value; - canvas_shader.set_custom_uniform(idx, v); - } - - idx++; - } - - if (tex_id > 1) { - glActiveTexture(GL_TEXTURE0); - } - - if (p_shader->uses_time) { - canvas_shader.set_uniform(CanvasShaderGLES2::TIME, Math::fmod(last_time, shader_time_rollback)); - draw_next_frame = true; - } - //if uses TIME - draw_next_frame=true -} - -void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list, int p_z, const Color &p_modulate, CanvasLight *p_light) { - - CanvasItem *current_clip = NULL; - Shader *shader_cache = NULL; - - bool rebind_shader = true; - - canvas_opacity = 1.0; - canvas_use_modulate = p_modulate != Color(1, 1, 1, 1); - canvas_modulate = p_modulate; - canvas_shader.set_conditional(CanvasShaderGLES2::USE_MODULATE, canvas_use_modulate); - canvas_shader.set_conditional(CanvasShaderGLES2::USE_DISTANCE_FIELD, false); - - bool reset_modulate = false; - bool prev_distance_field = false; - - while (p_item_list) { - - CanvasItem *ci = p_item_list; - - if (ci->vp_render) { - if (draw_viewport_func) { - draw_viewport_func(ci->vp_render->owner, ci->vp_render->udata, ci->vp_render->rect); - } - memdelete(ci->vp_render); - ci->vp_render = NULL; - canvas_last_material = NULL; - canvas_use_modulate = p_modulate != Color(1, 1, 1, 1); - canvas_modulate = p_modulate; - canvas_shader.set_conditional(CanvasShaderGLES2::USE_MODULATE, canvas_use_modulate); - canvas_shader.set_conditional(CanvasShaderGLES2::USE_DISTANCE_FIELD, false); - prev_distance_field = false; - rebind_shader = true; - reset_modulate = true; - } - - if (prev_distance_field != ci->distance_field) { - - canvas_shader.set_conditional(CanvasShaderGLES2::USE_DISTANCE_FIELD, ci->distance_field); - prev_distance_field = ci->distance_field; - rebind_shader = true; - } - - if (current_clip != ci->final_clip_owner) { - - current_clip = ci->final_clip_owner; - - //setup clip - if (current_clip) { - - glEnable(GL_SCISSOR_TEST); - //glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)), - //current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height); - - /* int x = viewport.x+current_clip->final_clip_rect.pos.x; - int y = window_size.height-(viewport.y+current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.y); - int w = current_clip->final_clip_rect.size.x; - int h = current_clip->final_clip_rect.size.y; -*/ - int x; - int y; - int w; - int h; - - if (current_rt) { - x = current_clip->final_clip_rect.pos.x; - y = current_clip->final_clip_rect.pos.y; - w = current_clip->final_clip_rect.size.x; - h = current_clip->final_clip_rect.size.y; - } else { - x = current_clip->final_clip_rect.pos.x; - y = window_size.height - (current_clip->final_clip_rect.pos.y + current_clip->final_clip_rect.size.y); - w = current_clip->final_clip_rect.size.x; - h = current_clip->final_clip_rect.size.y; - } - - glScissor(x, y, w, h); - - } else { - - glDisable(GL_SCISSOR_TEST); - } - } - - if (ci->copy_back_buffer && framebuffer.active && framebuffer.scale == 1) { - - Rect2 rect; - int x, y; - - if (ci->copy_back_buffer->full) { - - x = viewport.x; - y = window_size.height - (viewport.height + viewport.y); - } else { - x = viewport.x + ci->copy_back_buffer->screen_rect.pos.x; - y = window_size.height - (viewport.y + ci->copy_back_buffer->screen_rect.pos.y + ci->copy_back_buffer->screen_rect.size.y); - } - glActiveTexture(GL_TEXTURE0 + max_texture_units - 1); - glBindTexture(GL_TEXTURE_2D, framebuffer.sample_color); - -#ifdef GLEW_ENABLED - if (current_rt) { - glReadBuffer(GL_COLOR_ATTACHMENT0); - } else { - glReadBuffer(GL_BACK); - } -#endif - if (current_rt) { - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, viewport.x, viewport.y, viewport.x, viewport.y, viewport.width, viewport.height); - //window_size.height-(viewport.height+viewport.y) - } else { - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, x, y, x, y, viewport.width, viewport.height); - } - - canvas_texscreen_used = true; - glActiveTexture(GL_TEXTURE0); - } - - //begin rect - CanvasItem *material_owner = ci->material_owner ? ci->material_owner : ci; - ShaderMaterial *material = material_owner->material; - - if (material != canvas_last_material || rebind_shader) { - - Shader *shader = NULL; - if (material && material->shader.is_valid()) { - shader = shader_owner.get(material->shader); - if (shader && !shader->valid) { - shader = NULL; - } - } - - shader_cache = shader; - - if (shader) { - canvas_shader.set_custom_shader(shader->custom_code_id); - _canvas_item_setup_shader_params(material, shader); - } else { - shader_cache = NULL; - canvas_shader.set_custom_shader(0); - canvas_shader.bind(); - uses_texpixel_size = false; - } - - canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX, canvas_transform); - if (canvas_use_modulate) - reset_modulate = true; - canvas_last_material = material; - rebind_shader = false; - } - - if (material && shader_cache) { - - _canvas_item_setup_shader_uniforms(material, shader_cache); - } - - bool unshaded = (material && material->shading_mode == VS::CANVAS_ITEM_SHADING_UNSHADED) || ci->blend_mode != VS::MATERIAL_BLEND_MODE_MIX; - - if (unshaded) { - canvas_shader.set_uniform(CanvasShaderGLES2::MODULATE, Color(1, 1, 1, 1)); - reset_modulate = true; - } else if (reset_modulate) { - canvas_shader.set_uniform(CanvasShaderGLES2::MODULATE, canvas_modulate); - reset_modulate = false; - } - - canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, ci->final_transform); - canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX, Transform2D()); - - bool reclip = false; - - if (ci == p_item_list || ci->blend_mode != canvas_blend_mode) { - - switch (ci->blend_mode) { - - case VS::MATERIAL_BLEND_MODE_MIX: { - glBlendEquation(GL_FUNC_ADD); - if (current_rt && current_rt_transparent) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } else { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - - } break; - case VS::MATERIAL_BLEND_MODE_ADD: { - - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - } break; - case VS::MATERIAL_BLEND_MODE_SUB: { - - glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - } break; - case VS::MATERIAL_BLEND_MODE_MUL: { - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_DST_COLOR, GL_ZERO); - } break; - case VS::MATERIAL_BLEND_MODE_PREMULT_ALPHA: { - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } break; - } - - canvas_blend_mode = ci->blend_mode; - } - - canvas_opacity = ci->final_opacity; - - if (unshaded || (p_modulate.a > 0.001 && (!material || material->shading_mode != VS::CANVAS_ITEM_SHADING_ONLY_LIGHT) && !ci->light_masked)) - _canvas_item_render_commands<false>(ci, current_clip, reclip); - - if (canvas_blend_mode == VS::MATERIAL_BLEND_MODE_MIX && p_light && !unshaded) { - - CanvasLight *light = p_light; - bool light_used = false; - VS::CanvasLightMode mode = VS::CANVAS_LIGHT_MODE_ADD; - - while (light) { - - if (ci->light_mask & light->item_mask && p_z >= light->z_min && p_z <= light->z_max && ci->global_rect_cache.intersects_transformed(light->xform_cache, light->rect_cache)) { - - //intersects this light - - if (!light_used || mode != light->mode) { - - mode = light->mode; - - switch (mode) { - - case VS::CANVAS_LIGHT_MODE_ADD: { - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - - } break; - case VS::CANVAS_LIGHT_MODE_SUB: { - glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - } break; - case VS::CANVAS_LIGHT_MODE_MIX: - case VS::CANVAS_LIGHT_MODE_MASK: { - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - } break; - } - } - - if (!light_used) { - - canvas_shader.set_conditional(CanvasShaderGLES2::USE_LIGHTING, true); - canvas_shader.set_conditional(CanvasShaderGLES2::USE_MODULATE, false); - light_used = true; - normal_flip = Vector2(1, 1); - } - - bool has_shadow = light->shadow_buffer.is_valid() && ci->light_mask & light->item_shadow_mask; - - canvas_shader.set_conditional(CanvasShaderGLES2::USE_SHADOWS, has_shadow); - - bool light_rebind = canvas_shader.bind(); - - if (light_rebind) { - - if (material && shader_cache) { - _canvas_item_setup_shader_params(material, shader_cache); - _canvas_item_setup_shader_uniforms(material, shader_cache); - } - - canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, ci->final_transform); - canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX, Transform2D()); - canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX, canvas_transform); - if (canvas_use_modulate) - canvas_shader.set_uniform(CanvasShaderGLES2::MODULATE, canvas_modulate); - canvas_shader.set_uniform(CanvasShaderGLES2::NORMAL_FLIP, Vector2(1, 1)); - canvas_shader.set_uniform(CanvasShaderGLES2::SHADOWPIXEL_SIZE, 1.0 / light->shadow_buffer_size); - } - - canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_MATRIX, light->light_shader_xform); - canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_POS, light->light_shader_pos); - canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_COLOR, Color(light->color.r * light->energy, light->color.g * light->energy, light->color.b * light->energy, light->color.a)); - canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_HEIGHT, light->height); - canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_LOCAL_MATRIX, light->xform_cache.affine_inverse()); - canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_OUTSIDE_ALPHA, light->mode == VS::CANVAS_LIGHT_MODE_MASK ? 1.0 : 0.0); - - if (has_shadow) { - - CanvasLightShadow *cls = canvas_light_shadow_owner.get(light->shadow_buffer); - glActiveTexture(GL_TEXTURE0 + max_texture_units - 3); - if (read_depth_supported) - glBindTexture(GL_TEXTURE_2D, cls->depth); - else - glBindTexture(GL_TEXTURE_2D, cls->rgba); - - canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_TEXTURE, max_texture_units - 3); - canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_MATRIX, light->shadow_matrix_cache); - canvas_shader.set_uniform(CanvasShaderGLES2::SHADOW_ESM_MULTIPLIER, light->shadow_esm_mult); - canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_SHADOW_COLOR, light->shadow_color); - } - - glActiveTexture(GL_TEXTURE0 + max_texture_units - 2); - canvas_shader.set_uniform(CanvasShaderGLES2::LIGHT_TEXTURE, max_texture_units - 2); - Texture *t = texture_owner.get(light->texture); - if (!t) { - glBindTexture(GL_TEXTURE_2D, white_tex); - } else { - - glBindTexture(t->target, t->tex_id); - } - - glActiveTexture(GL_TEXTURE0); - _canvas_item_render_commands<true>(ci, current_clip, reclip); //redraw using light - } - - light = light->next_ptr; - } - - if (light_used) { - - canvas_shader.set_conditional(CanvasShaderGLES2::USE_LIGHTING, false); - canvas_shader.set_conditional(CanvasShaderGLES2::USE_MODULATE, canvas_use_modulate); - canvas_shader.set_conditional(CanvasShaderGLES2::USE_SHADOWS, false); - - canvas_shader.bind(); - - if (material && shader_cache) { - _canvas_item_setup_shader_params(material, shader_cache); - _canvas_item_setup_shader_uniforms(material, shader_cache); - } - - canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX, ci->final_transform); - canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX, Transform2D()); - if (canvas_use_modulate) - canvas_shader.set_uniform(CanvasShaderGLES2::MODULATE, canvas_modulate); - - glBlendEquation(GL_FUNC_ADD); - if (current_rt && current_rt_transparent) { - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } else { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - } - } - - if (reclip) { - - glEnable(GL_SCISSOR_TEST); - //glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)), - //current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height); - - int x; - int y; - int w; - int h; - - if (current_rt) { - x = current_clip->final_clip_rect.pos.x; - y = current_clip->final_clip_rect.pos.y; - w = current_clip->final_clip_rect.size.x; - h = current_clip->final_clip_rect.size.y; - } else { - x = current_clip->final_clip_rect.pos.x; - y = window_size.height - (current_clip->final_clip_rect.pos.y + current_clip->final_clip_rect.size.y); - w = current_clip->final_clip_rect.size.x; - h = current_clip->final_clip_rect.size.y; - } - - glScissor(x, y, w, h); - } - - p_item_list = p_item_list->next; - } - - if (current_clip) { - glDisable(GL_SCISSOR_TEST); - } -} - -/* ENVIRONMENT */ - -RID RasterizerGLES2::environment_create() { - - Environment *env = memnew(Environment); - return environment_owner.make_rid(env); -} - -void RasterizerGLES2::environment_set_background(RID p_env, VS::EnvironmentBG p_bg) { - - ERR_FAIL_INDEX(p_bg, VS::ENV_BG_MAX); - Environment *env = environment_owner.get(p_env); - ERR_FAIL_COND(!env); - env->bg_mode = p_bg; -} - -VS::EnvironmentBG RasterizerGLES2::environment_get_background(RID p_env) const { - - const Environment *env = environment_owner.get(p_env); - ERR_FAIL_COND_V(!env, VS::ENV_BG_MAX); - return env->bg_mode; -} - -void RasterizerGLES2::environment_set_background_param(RID p_env, VS::EnvironmentBGParam p_param, const Variant &p_value) { - - ERR_FAIL_INDEX(p_param, VS::ENV_BG_PARAM_MAX); - Environment *env = environment_owner.get(p_env); - ERR_FAIL_COND(!env); - env->bg_param[p_param] = p_value; -} -Variant RasterizerGLES2::environment_get_background_param(RID p_env, VS::EnvironmentBGParam p_param) const { - - ERR_FAIL_INDEX_V(p_param, VS::ENV_BG_PARAM_MAX, Variant()); - const Environment *env = environment_owner.get(p_env); - ERR_FAIL_COND_V(!env, Variant()); - return env->bg_param[p_param]; -} - -void RasterizerGLES2::environment_set_enable_fx(RID p_env, VS::EnvironmentFx p_effect, bool p_enabled) { - - ERR_FAIL_INDEX(p_effect, VS::ENV_FX_MAX); - Environment *env = environment_owner.get(p_env); - ERR_FAIL_COND(!env); - env->fx_enabled[p_effect] = p_enabled; -} -bool RasterizerGLES2::environment_is_fx_enabled(RID p_env, VS::EnvironmentFx p_effect) const { - - ERR_FAIL_INDEX_V(p_effect, VS::ENV_FX_MAX, false); - const Environment *env = environment_owner.get(p_env); - ERR_FAIL_COND_V(!env, false); - return env->fx_enabled[p_effect]; -} - -void RasterizerGLES2::environment_fx_set_param(RID p_env, VS::EnvironmentFxParam p_param, const Variant &p_value) { - - ERR_FAIL_INDEX(p_param, VS::ENV_FX_PARAM_MAX); - Environment *env = environment_owner.get(p_env); - ERR_FAIL_COND(!env); - env->fx_param[p_param] = p_value; -} -Variant RasterizerGLES2::environment_fx_get_param(RID p_env, VS::EnvironmentFxParam p_param) const { - - ERR_FAIL_INDEX_V(p_param, VS::ENV_FX_PARAM_MAX, Variant()); - const Environment *env = environment_owner.get(p_env); - ERR_FAIL_COND_V(!env, Variant()); - return env->fx_param[p_param]; -} - -RID RasterizerGLES2::sampled_light_dp_create(int p_width, int p_height) { - - SampledLight *slight = memnew(SampledLight); - slight->w = p_width; - slight->h = p_height; - slight->multiplier = 1.0; - slight->is_float = float_linear_supported; - - glActiveTexture(GL_TEXTURE0); - glGenTextures(1, &slight->texture); - glBindTexture(GL_TEXTURE_2D, slight->texture); - // for debug, but glitchy - //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_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - // Remove artifact on the edges of the shadowmap - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - if (slight->is_float) { -#ifdef GLEW_ENABLED - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, p_width, p_height, 0, GL_RGBA, GL_FLOAT, NULL); -#else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, p_width, p_height, 0, GL_RGBA, GL_FLOAT, NULL); -#endif - } else { - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, p_width, p_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - } - - return sampled_light_owner.make_rid(slight); -} - -void RasterizerGLES2::sampled_light_dp_update(RID p_sampled_light, const Color *p_data, float p_multiplier) { - - SampledLight *slight = sampled_light_owner.get(p_sampled_light); - ERR_FAIL_COND(!slight); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, slight->texture); - - if (slight->is_float) { - -#ifdef GLEW_ENABLED - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, slight->w, slight->h, GL_RGBA, GL_FLOAT, p_data); -#else - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, slight->w, slight->h, GL_RGBA, GL_FLOAT, p_data); -#endif - - } else { - //convert to bytes - uint8_t *tex8 = (uint8_t *)alloca(slight->w * slight->h * 4); - const float *src = (const float *)p_data; - - for (int i = 0; i < slight->w * slight->h * 4; i++) { - - tex8[i] = Math::fast_ftoi(CLAMP(src[i] * 255.0, 0.0, 255.0)); - } - - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, slight->w, slight->h, GL_RGBA, GL_UNSIGNED_BYTE, p_data); - } - - slight->multiplier = p_multiplier; -} - -/*MISC*/ - -bool RasterizerGLES2::is_texture(const RID &p_rid) const { - - return texture_owner.owns(p_rid); -} -bool RasterizerGLES2::is_material(const RID &p_rid) const { - - return material_owner.owns(p_rid); -} -bool RasterizerGLES2::is_mesh(const RID &p_rid) const { - - return mesh_owner.owns(p_rid); -} -bool RasterizerGLES2::is_immediate(const RID &p_rid) const { - - return immediate_owner.owns(p_rid); -} -bool RasterizerGLES2::is_multimesh(const RID &p_rid) const { - - return multimesh_owner.owns(p_rid); -} -bool RasterizerGLES2::is_particles(const RID &p_beam) const { - - return particles_owner.owns(p_beam); -} - -bool RasterizerGLES2::is_light(const RID &p_rid) const { - - return light_owner.owns(p_rid); -} -bool RasterizerGLES2::is_light_instance(const RID &p_rid) const { - - return light_instance_owner.owns(p_rid); -} -bool RasterizerGLES2::is_particles_instance(const RID &p_rid) const { - - return particles_instance_owner.owns(p_rid); -} -bool RasterizerGLES2::is_skeleton(const RID &p_rid) const { - - return skeleton_owner.owns(p_rid); -} -bool RasterizerGLES2::is_environment(const RID &p_rid) const { - - return environment_owner.owns(p_rid); -} -bool RasterizerGLES2::is_shader(const RID &p_rid) const { - - return shader_owner.owns(p_rid); -} - -bool RasterizerGLES2::is_canvas_light_occluder(const RID &p_rid) const { - - return false; -} - -void RasterizerGLES2::free(const RID &p_rid) { - if (texture_owner.owns(p_rid)) { - - // delete the texture - Texture *texture = texture_owner.get(p_rid); - - //glDeleteTextures( 1,&texture->tex_id ); - _rinfo.texture_mem -= texture->total_data_size; - texture_owner.free(p_rid); - memdelete(texture); - - } else if (shader_owner.owns(p_rid)) { - - // delete the texture - Shader *shader = shader_owner.get(p_rid); - - switch (shader->mode) { - case VS::SHADER_MATERIAL: { - material_shader.free_custom_shader(shader->custom_code_id); - } break; - case VS::SHADER_POST_PROCESS: { - //postprocess_shader.free_custom_shader(shader->custom_code_id); - } break; - } - - if (shader->dirty_list.in_list()) - _shader_dirty_list.remove(&shader->dirty_list); - - //material_shader.free_custom_shader(shader->custom_code_id); - shader_owner.free(p_rid); - memdelete(shader); - - } else if (material_owner.owns(p_rid)) { - - Material *material = material_owner.get(p_rid); - ERR_FAIL_COND(!material); - - _free_fixed_material(p_rid); //just in case - material_owner.free(p_rid); - memdelete(material); - - } else if (mesh_owner.owns(p_rid)) { - - Mesh *mesh = mesh_owner.get(p_rid); - ERR_FAIL_COND(!mesh); - for (int i = 0; i < mesh->surfaces.size(); i++) { - - Surface *surface = mesh->surfaces[i]; - if (surface->array_local != 0) { - memfree(surface->array_local); - }; - if (surface->index_array_local != 0) { - memfree(surface->index_array_local); - }; - - if (mesh->morph_target_count > 0) { - - for (int i = 0; i < mesh->morph_target_count; i++) { - - memdelete_arr(surface->morph_targets_local[i].array); - } - memdelete_arr(surface->morph_targets_local); - surface->morph_targets_local = NULL; - } - - if (surface->vertex_id) - glDeleteBuffers(1, &surface->vertex_id); - if (surface->index_id) - glDeleteBuffers(1, &surface->index_id); - - memdelete(surface); - }; - - mesh->surfaces.clear(); - - mesh_owner.free(p_rid); - memdelete(mesh); - - } else if (multimesh_owner.owns(p_rid)) { - - MultiMesh *multimesh = multimesh_owner.get(p_rid); - ERR_FAIL_COND(!multimesh); - - if (multimesh->tex_id) { - glDeleteTextures(1, &multimesh->tex_id); - } - - multimesh_owner.free(p_rid); - memdelete(multimesh); - - } else if (immediate_owner.owns(p_rid)) { - - Immediate *immediate = immediate_owner.get(p_rid); - ERR_FAIL_COND(!immediate); - - immediate_owner.free(p_rid); - memdelete(immediate); - } else if (particles_owner.owns(p_rid)) { - - Particles *particles = particles_owner.get(p_rid); - ERR_FAIL_COND(!particles); - - particles_owner.free(p_rid); - memdelete(particles); - } else if (particles_instance_owner.owns(p_rid)) { - - ParticlesInstance *particles_isntance = particles_instance_owner.get(p_rid); - ERR_FAIL_COND(!particles_isntance); - - particles_instance_owner.free(p_rid); - memdelete(particles_isntance); - - } else if (skeleton_owner.owns(p_rid)) { - - Skeleton *skeleton = skeleton_owner.get(p_rid); - ERR_FAIL_COND(!skeleton); - - if (skeleton->dirty_list.in_list()) - _skeleton_dirty_list.remove(&skeleton->dirty_list); - if (skeleton->tex_id) { - glDeleteTextures(1, &skeleton->tex_id); - } - skeleton_owner.free(p_rid); - memdelete(skeleton); - - } else if (light_owner.owns(p_rid)) { - - Light *light = light_owner.get(p_rid); - ERR_FAIL_COND(!light) - - light_owner.free(p_rid); - memdelete(light); - - } else if (light_instance_owner.owns(p_rid)) { - - LightInstance *light_instance = light_instance_owner.get(p_rid); - ERR_FAIL_COND(!light_instance); - light_instance->clear_shadow_buffers(); - light_instance_owner.free(p_rid); - memdelete(light_instance); - - } else if (environment_owner.owns(p_rid)) { - - Environment *env = environment_owner.get(p_rid); - ERR_FAIL_COND(!env); - - environment_owner.free(p_rid); - memdelete(env); - - } else if (viewport_data_owner.owns(p_rid)) { - - ViewportData *viewport_data = viewport_data_owner.get(p_rid); - ERR_FAIL_COND(!viewport_data); - glDeleteFramebuffers(1, &viewport_data->lum_fbo); - glDeleteTextures(1, &viewport_data->lum_color); - viewport_data_owner.free(p_rid); - memdelete(viewport_data); - - } else if (render_target_owner.owns(p_rid)) { - - RenderTarget *render_target = render_target_owner.get(p_rid); - ERR_FAIL_COND(!render_target); - render_target_set_size(p_rid, 0, 0); //clears framebuffer - texture_owner.free(render_target->texture); - memdelete(render_target->texture_ptr); - render_target_owner.free(p_rid); - memdelete(render_target); - } else if (sampled_light_owner.owns(p_rid)) { - - SampledLight *sampled_light = sampled_light_owner.get(p_rid); - ERR_FAIL_COND(!sampled_light); - glDeleteTextures(1, &sampled_light->texture); - sampled_light_owner.free(p_rid); - memdelete(sampled_light); - } else if (canvas_occluder_owner.owns(p_rid)) { - - CanvasOccluder *co = canvas_occluder_owner.get(p_rid); - if (co->index_id) - glDeleteBuffers(1, &co->index_id); - if (co->vertex_id) - glDeleteBuffers(1, &co->vertex_id); - - canvas_occluder_owner.free(p_rid); - memdelete(co); - - } else if (canvas_light_shadow_owner.owns(p_rid)) { - - CanvasLightShadow *cls = canvas_light_shadow_owner.get(p_rid); - glDeleteFramebuffers(1, &cls->fbo); - glDeleteRenderbuffers(1, &cls->rbo); - glDeleteTextures(1, &cls->depth); - /* - if (!read_depth_supported) { - glDeleteTextures(1,&cls->rgba); - } - */ - - canvas_light_shadow_owner.free(p_rid); - memdelete(cls); - }; -} - -bool RasterizerGLES2::ShadowBuffer::init(int p_size, bool p_use_depth) { - - size = p_size; - // Create a framebuffer object - glGenFramebuffers(1, &fbo); - glBindFramebuffer(GL_FRAMEBUFFER, fbo); - - // Create a render buffer - glGenRenderbuffers(1, &rbo); - glBindRenderbuffer(GL_RENDERBUFFER, rbo); - - // Create a texture for storing the depth - glGenTextures(1, &depth); - glBindTexture(GL_TEXTURE_2D, depth); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - // Remove artifact on the edges of the shadowmap - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - //print_line("ERROR? "+itos(glGetError())); - if (p_use_depth) { - - // We'll use a depth texture to store the depths in the shadow map - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size, size, 0, - GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); - -#ifdef GLEW_ENABLED - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -#endif - - // Attach the depth texture to FBO depth attachment point - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_TEXTURE_2D, depth, 0); - -#ifdef GLEW_ENABLED - glDrawBuffer(GL_NONE); -#endif - } else { - // We'll use a RGBA texture into which we pack the depth info - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - - // Attach the RGBA texture to FBO color attachment point - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, depth, 0); - - // Allocate 16-bit depth buffer - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size, size); - - // Attach the render buffer as depth buffer - will be ignored - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_RENDERBUFFER, rbo); - } - -#if 0 - - if (!p_use_depth) { - - - print_line("try no depth!"); - - glGenTextures(1, &rgba); - glBindTexture(GL_TEXTURE_2D, rgba); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rgba, 0); -/* - glGenRenderbuffers(1, &depth); - glBindRenderbuffer(GL_RENDERBUFFER, depth); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, p_size, p_size); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); -*/ - glGenTextures(1, &depth); - glBindTexture(GL_TEXTURE_2D, depth); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, size, size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth, 0); - - } else { - - //glGenRenderbuffers(1, &rbo); - //glBindRenderbuffer(GL_RENDERBUFFER, rbo); - - glGenTextures(1, &depth); - glBindTexture(GL_TEXTURE_2D, depth); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size, size, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth, 0); - - } - -#endif - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); -//printf("errnum: %x\n",status); -#ifdef GLEW_ENABLED - if (p_use_depth) { - //glDrawBuffer(GL_BACK); - } -#endif - glBindFramebuffer(GL_FRAMEBUFFER, 0); - DEBUG_TEST_ERROR("Shadow Buffer Init"); - ERR_FAIL_COND_V(status != GL_FRAMEBUFFER_COMPLETE, false); - -#ifdef GLEW_ENABLED - if (p_use_depth) { - //glDrawBuffer(GL_BACK); - } -#endif - -#if 0 - glGenFramebuffers(1, &fbo_blur); - glBindFramebuffer(GL_FRAMEBUFFER, fbo_blur); - - glGenRenderbuffers(1, &rbo_blur); - glBindRenderbuffer(GL_RENDERBUFFER, rbo_blur); - - glGenTextures(1, &blur); - glBindTexture(GL_TEXTURE_2D, blur); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - //glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, size, size, 0, - //GL_DEPTH_COMPONENT16, GL_UNSIGNED_SHORT, NULL); - - // Attach the RGBA texture to FBO color attachment point - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, blur, 0); - - // Allocate 16-bit depth buffer - /* - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, size, size); - - // Attach the render buffer as depth buffer - will be ignored - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_RENDERBUFFER, rbo_blur); - */ - status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - OS::get_singleton()->print("Status: %x\n",status); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - DEBUG_TEST_ERROR("Shadow Blur Buffer Init"); - ERR_FAIL_COND_V( status != GL_FRAMEBUFFER_COMPLETE,false ); -#endif - - return true; -} - -void RasterizerGLES2::_update_framebuffer() { - - if (!use_framebuffers) - return; - - int scale = GLOBAL_DEF("rasterizer/framebuffer_shrink", 1); - if (scale < 1) - scale = 1; - - int dwidth = OS::get_singleton()->get_video_mode().width / scale; - int dheight = OS::get_singleton()->get_video_mode().height / scale; - - if (framebuffer.fbo && dwidth == framebuffer.width && dheight == framebuffer.height) - return; - - bool use_fbo = true; - - if (framebuffer.fbo != 0) { - - glDeleteFramebuffers(1, &framebuffer.fbo); -#if 0 - glDeleteTextures(1,&framebuffer.depth); -#else - glDeleteRenderbuffers(1, &framebuffer.depth); - -#endif - glDeleteTextures(1, &framebuffer.color); - - for (int i = 0; i < framebuffer.luminance.size(); i++) { - - glDeleteTextures(1, &framebuffer.luminance[i].color); - glDeleteFramebuffers(1, &framebuffer.luminance[i].fbo); - } - - for (int i = 0; i < 3; i++) { - - glDeleteTextures(1, &framebuffer.blur[i].color); - glDeleteFramebuffers(1, &framebuffer.blur[i].fbo); - } - - glDeleteTextures(1, &framebuffer.sample_color); - glDeleteFramebuffers(1, &framebuffer.sample_fbo); - framebuffer.luminance.clear(); - framebuffer.blur_size = 0; - framebuffer.fbo = 0; - } - -#ifdef TOOLS_ENABLED - framebuffer.active = use_fbo; -#else - framebuffer.active = use_fbo && !low_memory_2d; -#endif - framebuffer.width = dwidth; - framebuffer.height = dheight; - framebuffer.scale = scale; - - if (!framebuffer.active) - return; - - glGenFramebuffers(1, &framebuffer.fbo); - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.fbo); - -//print_line("generating fbo, id: "+itos(framebuffer.fbo)); -//depth - -// Create a render buffer - -#if 0 - glGenTextures(1, &framebuffer.depth); - glBindTexture(GL_TEXTURE_2D, framebuffer.depth); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, framebuffer.width, framebuffer.height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE ); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, framebuffer.depth, 0); - -#else - - glGenRenderbuffers(1, &framebuffer.depth); - glBindRenderbuffer(GL_RENDERBUFFER, framebuffer.depth); - - glRenderbufferStorage(GL_RENDERBUFFER, use_depth24 ? _DEPTH_COMPONENT24_OES : GL_DEPTH_COMPONENT16, framebuffer.width, framebuffer.height); - - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, framebuffer.depth); - -#endif - //color - - //GLuint format_rgba = use_fp16_fb?_GL_RGBA16F_EXT:GL_RGBA; - GLuint format_rgba = GL_RGBA; - GLuint format_type = use_fp16_fb ? _GL_HALF_FLOAT_OES : GL_UNSIGNED_BYTE; - GLuint format_internal = GL_RGBA; - - if (use_16bits_fbo) { - format_type = GL_UNSIGNED_SHORT_5_6_5; - format_rgba = GL_RGB; - format_internal = GL_RGB; - } - /*GLuint format_luminance = use_fp16_fb?GL_RGB16F:GL_RGBA; - GLuint format_luminance_type = use_fp16_fb?(use_fu_GL_HALF_FLOAT_OES):GL_UNSIGNED_BYTE; - GLuint format_luminance_components = use_fp16_fb?GL_RGB:GL_RGBA;*/ - - GLuint format_luminance = use_fp16_fb ? _GL_RG_EXT : GL_RGBA; - GLuint format_luminance_type = use_fp16_fb ? (full_float_fb_supported ? GL_FLOAT : _GL_HALF_FLOAT_OES) : GL_UNSIGNED_BYTE; - GLuint format_luminance_components = use_fp16_fb ? _GL_RG_EXT : GL_RGBA; - - glGenTextures(1, &framebuffer.color); - glBindTexture(GL_TEXTURE_2D, framebuffer.color); - glTexImage2D(GL_TEXTURE_2D, 0, format_rgba, framebuffer.width, framebuffer.height, 0, format_internal, format_type, NULL); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, framebuffer.color, 0); -# - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - if (status != GL_FRAMEBUFFER_COMPLETE) { - - glDeleteFramebuffers(1, &framebuffer.fbo); -#if 0 - glDeleteTextures(1,&framebuffer.depth); -#else - glDeleteRenderbuffers(1, &framebuffer.depth); - -#endif - glDeleteTextures(1, &framebuffer.color); - framebuffer.fbo = 0; - framebuffer.active = false; - //print_line("**************** NO FAMEBUFFEEEERRRR????"); - WARN_PRINT(String("Could not create framebuffer!!, code: " + itos(status)).ascii().get_data()); - } - - //sample - - glGenFramebuffers(1, &framebuffer.sample_fbo); - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.sample_fbo); - glGenTextures(1, &framebuffer.sample_color); - glBindTexture(GL_TEXTURE_2D, framebuffer.sample_color); - glTexImage2D(GL_TEXTURE_2D, 0, format_rgba, framebuffer.width, framebuffer.height, 0, format_internal, format_type, NULL); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, framebuffer.sample_color, 0); -# - status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - if (status != GL_FRAMEBUFFER_COMPLETE) { - - glDeleteFramebuffers(1, &framebuffer.fbo); -#if 0 - glDeleteTextures(1,&framebuffer.depth); -#else - glDeleteRenderbuffers(1, &framebuffer.depth); - -#endif - glDeleteTextures(1, &framebuffer.color); - glDeleteTextures(1, &framebuffer.sample_color); - glDeleteFramebuffers(1, &framebuffer.sample_fbo); - framebuffer.fbo = 0; - framebuffer.active = false; - //print_line("**************** NO FAMEBUFFEEEERRRR????"); - WARN_PRINT("Could not create framebuffer!!"); - } - //blur - - int size = GLOBAL_DEF("rasterizer/blur_buffer_size", 256); - - if (size != framebuffer.blur_size) { - - for (int i = 0; i < 3; i++) { - - if (framebuffer.blur[i].fbo) { - glDeleteFramebuffers(1, &framebuffer.blur[i].fbo); - glDeleteTextures(1, &framebuffer.blur[i].color); - framebuffer.blur[i].fbo = 0; - framebuffer.blur[i].color = 0; - } - } - - framebuffer.blur_size = size; - - for (int i = 0; i < 3; i++) { - - glGenFramebuffers(1, &framebuffer.blur[i].fbo); - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.blur[i].fbo); - - glGenTextures(1, &framebuffer.blur[i].color); - glBindTexture(GL_TEXTURE_2D, framebuffer.blur[i].color); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexImage2D(GL_TEXTURE_2D, 0, format_rgba, size, size, 0, - format_internal, format_type, NULL); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, framebuffer.blur[i].color, 0); - - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - DEBUG_TEST_ERROR("Shadow Buffer Init"); - ERR_CONTINUE(status != GL_FRAMEBUFFER_COMPLETE); - } - } - - // luminance - - int base_size = GLOBAL_DEF("rasterizer/luminance_buffer_size", 81); - - if (framebuffer.luminance.empty() || framebuffer.luminance[0].size != base_size) { - - for (int i = 0; i < framebuffer.luminance.size(); i++) { - - glDeleteFramebuffers(1, &framebuffer.luminance[i].fbo); - glDeleteTextures(1, &framebuffer.luminance[i].color); - } - - framebuffer.luminance.clear(); - - while (base_size > 0) { - - FrameBuffer::Luminance lb; - lb.size = base_size; - - glGenFramebuffers(1, &lb.fbo); - glBindFramebuffer(GL_FRAMEBUFFER, lb.fbo); - - glGenTextures(1, &lb.color); - glBindTexture(GL_TEXTURE_2D, lb.color); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexImage2D(GL_TEXTURE_2D, 0, format_luminance, lb.size, lb.size, 0, - format_luminance_components, format_luminance_type, NULL); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, lb.color, 0); - - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - - base_size /= 3; - - DEBUG_TEST_ERROR("Shadow Buffer Init"); - ERR_CONTINUE(status != GL_FRAMEBUFFER_COMPLETE); - - framebuffer.luminance.push_back(lb); - } - } -} - -void RasterizerGLES2::set_base_framebuffer(GLuint p_id, Vector2 p_size) { - - base_framebuffer = p_id; - - if (p_size.x != 0) { - window_size = p_size; - }; -} - -#if 0 -void RasterizerGLES2::_update_blur_buffer() { - - int size = GLOBAL_DEF("rasterizer/blur_buffer_size",256); - if (size!=framebuffer.blur_size) { - - for(int i=0;i<3;i++) { - - if (framebuffer.blur[i].fbo) { - glDeleteFramebuffers(1,&framebuffer.blur[i].fbo); - glDeleteTextures(1,&framebuffer.blur[i].color); - framebuffer.blur[i].fbo=0; - framebuffer.blur[i].color=0; - } - } - - framebuffer.blur_size=size; - - for(int i=0;i<3;i++) { - - glGenFramebuffers(1, &framebuffer.blur[i].fbo); - glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.blur[i].fbo); - - glGenTextures(1, &framebuffer.blur[i].color); - glBindTexture(GL_TEXTURE_2D, framebuffer.blur[i].color); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0, - GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, framebuffer.blur[i].color, 0); - - - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - - glBindFramebuffer(GL_FRAMEBUFFER, 0); - DEBUG_TEST_ERROR("Shadow Buffer Init"); - ERR_CONTINUE( status != GL_FRAMEBUFFER_COMPLETE ); - - - } - - } - - - - - -} -#endif - -bool RasterizerGLES2::_test_depth_shadow_buffer() { - - int size = 16; - - GLuint fbo; - GLuint rbo; - GLuint depth; - - glActiveTexture(GL_TEXTURE0); - - glGenFramebuffers(1, &fbo); - glBindFramebuffer(GL_FRAMEBUFFER, fbo); - - // Create a render buffer - glGenRenderbuffers(1, &rbo); - glBindRenderbuffer(GL_RENDERBUFFER, rbo); - - // Create a texture for storing the depth - glGenTextures(1, &depth); - glBindTexture(GL_TEXTURE_2D, depth); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - // Remove artifact on the edges of the shadowmap - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - // We'll use a depth texture to store the depths in the shadow map - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size, size, 0, - GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL); - -#ifdef GLEW_ENABLED - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -#endif - - // Attach the depth texture to FBO depth attachment point - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, - GL_TEXTURE_2D, depth, 0); - - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - - glDeleteFramebuffers(1, &fbo); - glDeleteRenderbuffers(1, &rbo); - glDeleteTextures(1, &depth); - - return status == GL_FRAMEBUFFER_COMPLETE; -} - -void RasterizerGLES2::init() { - - if (OS::get_singleton()->is_stdout_verbose()) { - print_line("Using GLES2 video driver"); - } - -#ifdef GLEW_ENABLED - GLuint res = glewInit(); - ERR_FAIL_COND(res != GLEW_OK); - if (OS::get_singleton()->is_stdout_verbose()) { - print_line(String("GLES2: Using GLEW ") + (const char *)glewGetString(GLEW_VERSION)); - } - - // Godot makes use of functions from ARB_framebuffer_object extension which is not implemented by all drivers. - // On the other hand, these drivers might implement the older EXT_framebuffer_object extension - // with which current source code is backward compatible. - - bool framebuffer_object_is_supported = glewIsSupported("GL_ARB_framebuffer_object"); - - if (!framebuffer_object_is_supported) { - WARN_PRINT("GL_ARB_framebuffer_object not supported by your graphics card."); - - if (glewIsSupported("GL_EXT_framebuffer_object")) { - // falling-back to the older EXT function if present - WARN_PRINT("Falling-back to GL_EXT_framebuffer_object."); - - glIsRenderbuffer = glIsRenderbufferEXT; - glBindRenderbuffer = glBindRenderbufferEXT; - glDeleteRenderbuffers = glDeleteRenderbuffersEXT; - glGenRenderbuffers = glGenRenderbuffersEXT; - glRenderbufferStorage = glRenderbufferStorageEXT; - glGetRenderbufferParameteriv = glGetRenderbufferParameterivEXT; - glIsFramebuffer = glIsFramebufferEXT; - glBindFramebuffer = glBindFramebufferEXT; - glDeleteFramebuffers = glDeleteFramebuffersEXT; - glGenFramebuffers = glGenFramebuffersEXT; - glCheckFramebufferStatus = glCheckFramebufferStatusEXT; - glFramebufferTexture1D = glFramebufferTexture1DEXT; - glFramebufferTexture2D = glFramebufferTexture2DEXT; - glFramebufferTexture3D = glFramebufferTexture3DEXT; - glFramebufferRenderbuffer = glFramebufferRenderbufferEXT; - glGetFramebufferAttachmentParameteriv = glGetFramebufferAttachmentParameterivEXT; - glGenerateMipmap = glGenerateMipmapEXT; - - framebuffer_object_is_supported = true; - } else { - ERR_PRINT("Framebuffer Object is not supported by your graphics card."); - } - } - - // Check for GL 2.1 compatibility, if not bail out - if (!(glewIsSupported("GL_VERSION_2_1") && framebuffer_object_is_supported)) { - ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 2.1 / GLES 2.0, sorry :(\n" - "Try a drivers update, buy a new GPU or try software rendering on Linux; Godot is now going to terminate."); - OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 2.1 / GLES 2.0, sorry :(\n" - "Godot Engine will self-destruct as soon as you acknowledge this error message.", - "Fatal error: Insufficient OpenGL / GLES drivers"); - exit(1); - } -#endif - - scene_pass = 1; - - if (extensions.size() == 0) { - - set_extensions((const char *)glGetString(GL_EXTENSIONS)); - } - - GLint tmp = 0; - glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &tmp); - //print_line("GL_MAX_VERTEX_ATTRIBS "+itos(tmp)); - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); - glFrontFace(GL_CW); - //glEnable(GL_TEXTURE_2D); - - default_material = create_default_material(); - - material_shader.init(); - canvas_shader.init(); - copy_shader.init(); - canvas_shadow_shader.init(); - -#ifdef GLEW_ENABLED - material_shader.set_conditional(MaterialShaderGLES2::USE_GLES_OVER_GL, true); - canvas_shader.set_conditional(CanvasShaderGLES2::USE_GLES_OVER_GL, true); - canvas_shadow_shader.set_conditional(CanvasShadowShaderGLES2::USE_GLES_OVER_GL, true); - copy_shader.set_conditional(CopyShaderGLES2::USE_GLES_OVER_GL, true); -#endif - -#ifdef ANGLE_ENABLED - // Fix for ANGLE - material_shader.set_conditional(MaterialShaderGLES2::DISABLE_FRONT_FACING, true); -#endif - - shadow = NULL; - shadow_pass = 0; - - framebuffer.fbo = 0; - framebuffer.width = 0; - framebuffer.height = 0; - //framebuffer.buff16=false; - //framebuffer.blur[0].fbo=false; - //framebuffer.blur[1].fbo=false; - framebuffer.active = false; - - //do a single initial clear - glClearColor(0, 0, 0, 1); - //glClearDepth(1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glGenTextures(1, &white_tex); - unsigned char whitetexdata[8 * 8 * 3]; - for (int i = 0; i < 8 * 8 * 3; i++) { - whitetexdata[i] = 255; - } - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, white_tex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, whitetexdata); - glGenerateMipmap(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, 0); - -#ifdef GLEW_ENABLED - - pvr_supported = false; - etc_supported = false; - use_depth24 = true; - s3tc_supported = true; - atitc_supported = false; - //use_texture_instancing=false; - //use_attribute_instancing=true; - use_texture_instancing = false; - use_attribute_instancing = true; - full_float_fb_supported = true; - srgb_supported = true; - latc_supported = true; - s3tc_srgb_supported = true; - use_anisotropic_filter = true; - float_linear_supported = true; - - GLint vtf; - glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &vtf); - float_supported = extensions.has("GL_OES_texture_float") || extensions.has("GL_ARB_texture_float"); - use_hw_skeleton_xform = vtf > 0 && float_supported; - - read_depth_supported = _test_depth_shadow_buffer(); - use_rgba_shadowmaps = !read_depth_supported; - //print_line("read depth support? "+itos(read_depth_supported)); - - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &anisotropic_level); - anisotropic_level = MIN(anisotropic_level, float(GLOBAL_DEF("rasterizer/anisotropic_filter_level", 4.0))); -#ifdef OSX_ENABLED - use_rgba_shadowmaps = true; - use_fp16_fb = false; -#else - -#endif - use_half_float = true; - -#else - - for (Set<String>::Element *E = extensions.front(); E; E = E->next()) { - print_line(E->get()); - } - read_depth_supported = extensions.has("GL_OES_depth_texture"); - use_rgba_shadowmaps = !read_depth_supported; - if (shadow_filter >= SHADOW_FILTER_ESM && !extensions.has("GL_EXT_frag_depth")) { - use_rgba_shadowmaps = true; //no other way, go back to rgba - } - pvr_supported = extensions.has("GL_IMG_texture_compression_pvrtc"); - pvr_srgb_supported = extensions.has("GL_EXT_pvrtc_sRGB"); - etc_supported = extensions.has("GL_OES_compressed_ETC1_RGB8_texture"); - use_depth24 = extensions.has("GL_OES_depth24"); - s3tc_supported = extensions.has("GL_EXT_texture_compression_dxt1") || extensions.has("GL_EXT_texture_compression_s3tc") || extensions.has("WEBGL_compressed_texture_s3tc"); - use_half_float = extensions.has("GL_OES_vertex_half_float"); - atitc_supported = extensions.has("GL_AMD_compressed_ATC_texture"); - - srgb_supported = extensions.has("GL_EXT_sRGB"); -#ifndef ANGLE_ENABLED - s3tc_srgb_supported = s3tc_supported && extensions.has("GL_EXT_texture_compression_s3tc"); -#else - s3tc_srgb_supported = s3tc_supported; -#endif - latc_supported = extensions.has("GL_EXT_texture_compression_latc"); - anisotropic_level = 1.0; - use_anisotropic_filter = extensions.has("GL_EXT_texture_filter_anisotropic"); - if (use_anisotropic_filter) { - glGetFloatv(_GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &anisotropic_level); - anisotropic_level = MIN(anisotropic_level, float(GLOBAL_DEF("rasterizer/anisotropic_filter_level", 4.0))); - } - - print_line("S3TC: " + itos(s3tc_supported) + " ATITC: " + itos(atitc_supported)); - - GLint vtf; - glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &vtf); - float_supported = extensions.has("GL_OES_texture_float") || extensions.has("GL_ARB_texture_float"); - use_hw_skeleton_xform = vtf > 0 && float_supported; - float_linear_supported = extensions.has("GL_OES_texture_float_linear"); - - /* - if (extensions.has("GL_QCOM_tiled_rendering")) - use_hw_skeleton_xform=false; - */ - GLint mva; - glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &mva); - if (vtf == 0 && mva > 8) { - //tegra 3, mali 400 - use_attribute_instancing = true; - use_texture_instancing = false; - } else if (vtf > 0 && extensions.has("GL_OES_texture_float")) { - //use_texture_instancing=true; - use_texture_instancing = false; // i don't get it, uniforms are faster. - use_attribute_instancing = false; - - } else { - - use_texture_instancing = false; - use_attribute_instancing = false; - } - - if (use_fp16_fb) { - use_fp16_fb = extensions.has("GL_OES_texture_half_float") && extensions.has("GL_EXT_color_buffer_half_float") && extensions.has("GL_EXT_texture_rg"); - } - - full_float_fb_supported = extensions.has("GL_EXT_color_buffer_float"); - -//etc_supported=false; - -#endif - - //use_rgba_shadowmaps=true; - - glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units); - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); - //read_depth_supported=false; - - canvas_shadow_blur = canvas_light_shadow_buffer_create(max_texture_size); - - { - //shadowmaps - - //don't use a shadowbuffer too big in GLES, this should be the maximum - int max_shadow_size = GLOBAL_DEF("rasterizer/max_shadow_buffer_size", 1024); - int smsize = max_shadow_size; - while (smsize >= 16) { - - ShadowBuffer sb; - bool s = sb.init(smsize, !use_rgba_shadowmaps); - if (s) - near_shadow_buffers.push_back(sb); - smsize /= 2; - } - - blur_shadow_buffer.init(max_shadow_size, !use_rgba_shadowmaps); - - //material_shader - material_shader.set_conditional(MaterialShaderGLES2::USE_DEPTH_SHADOWS, !use_rgba_shadowmaps); - canvas_shadow_shader.set_conditional(CanvasShadowShaderGLES2::USE_DEPTH_SHADOWS, !use_rgba_shadowmaps); - } - - shadow_material = material_create(); //empty with nothing - shadow_mat_ptr = material_owner.get(shadow_material); - - // Now create a second shadow material for double-sided shadow instances - shadow_material_double_sided = material_create(); - shadow_mat_double_sided_ptr = material_owner.get(shadow_material_double_sided); - shadow_mat_double_sided_ptr->flags[VS::MATERIAL_FLAG_DOUBLE_SIDED] = true; - - overdraw_material = create_overdraw_debug_material(); - copy_shader.set_conditional(CopyShaderGLES2::USE_8BIT_HDR, !use_fp16_fb); - canvas_shader.set_conditional(CanvasShaderGLES2::USE_DEPTH_SHADOWS, read_depth_supported); - - canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/use_2d_pixel_snap", false)); - - npo2_textures_available = true; - //fragment_lighting=false; - _rinfo.texture_mem = 0; - current_env = NULL; - current_rt = NULL; - current_vd = NULL; - current_debug = VS::SCENARIO_DEBUG_DISABLED; - camera_ortho = false; - - glGenBuffers(1, &gui_quad_buffer); - glBindBuffer(GL_ARRAY_BUFFER, gui_quad_buffer); -#ifdef GLES_NO_CLIENT_ARRAYS //WebGL specific implementation. - glBufferData(GL_ARRAY_BUFFER, 8 * MAX_POLYGON_VERTICES, NULL, GL_DYNAMIC_DRAW); -#else - glBufferData(GL_ARRAY_BUFFER, 128, NULL, GL_DYNAMIC_DRAW); -#endif - glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind - -#ifdef GLES_NO_CLIENT_ARRAYS //webgl indices buffer - glGenBuffers(1, &indices_buffer); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indices_buffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, 16 * 1024, NULL, GL_DYNAMIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); // unbind -#endif - - shader_time_rollback = GLOBAL_DEF("rasterizer/shader_time_rollback", 300); - - using_canvas_bg = false; - _update_framebuffer(); - DEBUG_TEST_ERROR("Initializing"); -} - -void RasterizerGLES2::finish() { - - free(default_material); - free(shadow_material); - free(shadow_material_double_sided); - free(canvas_shadow_blur); - free(overdraw_material); -} - -int RasterizerGLES2::get_render_info(VS::RenderInfo p_info) { - - switch (p_info) { - - case VS::INFO_OBJECTS_IN_FRAME: { - - return _rinfo.object_count; - } break; - case VS::INFO_VERTICES_IN_FRAME: { - - return _rinfo.vertex_count; - } break; - case VS::INFO_MATERIAL_CHANGES_IN_FRAME: { - - return _rinfo.mat_change_count; - } break; - case VS::INFO_SHADER_CHANGES_IN_FRAME: { - - return _rinfo.shader_change_count; - } break; - case VS::INFO_DRAW_CALLS_IN_FRAME: { - - return _rinfo.draw_calls; - } break; - case VS::INFO_SURFACE_CHANGES_IN_FRAME: { - - return _rinfo.surface_count; - } break; - case VS::INFO_USAGE_VIDEO_MEM_TOTAL: { - - return 0; - } break; - case VS::INFO_VIDEO_MEM_USED: { - - return get_render_info(VS::INFO_TEXTURE_MEM_USED) + get_render_info(VS::INFO_VERTEX_MEM_USED); - } break; - case VS::INFO_TEXTURE_MEM_USED: { - - return _rinfo.texture_mem; - } break; - case VS::INFO_VERTEX_MEM_USED: { - - return 0; - } break; - } - - return 0; -} - -void RasterizerGLES2::set_extensions(const char *p_strings) { - - Vector<String> strings = String(p_strings).split(" ", false); - for (int i = 0; i < strings.size(); i++) { - - extensions.insert(strings[i]); - //print_line(strings[i]); - } -} - -bool RasterizerGLES2::needs_to_draw_next_frame() const { - - return draw_next_frame; -} - -bool RasterizerGLES2::has_feature(VS::Features p_feature) const { - - switch (p_feature) { - case VS::FEATURE_SHADERS: return true; - case VS::FEATURE_NEEDS_RELOAD_HOOK: return use_reload_hooks; - default: return false; - } -} - -void RasterizerGLES2::reload_vram() { - - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); - glFrontFace(GL_CW); - - //do a single initial clear - glClearColor(0, 0, 0, 1); - //glClearDepth(1.0); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glGenTextures(1, &white_tex); - unsigned char whitetexdata[8 * 8 * 3]; - for (int i = 0; i < 8 * 8 * 3; i++) { - whitetexdata[i] = 255; - } - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, white_tex); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 8, 8, 0, GL_RGB, GL_UNSIGNED_BYTE, whitetexdata); - glGenerateMipmap(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, 0); - - List<RID> textures; - texture_owner.get_owned_list(&textures); - keep_copies = false; - for (List<RID>::Element *E = textures.front(); E; E = E->next()) { - - RID tid = E->get(); - Texture *t = texture_owner.get(tid); - ERR_CONTINUE(!t); - t->tex_id = 0; - t->data_size = 0; - glGenTextures(1, &t->tex_id); - t->active = false; - if (t->render_target) - continue; - texture_allocate(tid, t->width, t->height, t->format, t->flags); - bool had_image = false; - for (int i = 0; i < 6; i++) { - if (!t->image[i].empty()) { - texture_set_data(tid, t->image[i], VS::CubeMapSide(i)); - had_image = true; - } - } - - if (!had_image && t->reloader) { - Object *rl = ObjectDB::get_instance(t->reloader); - if (rl) - rl->call(t->reloader_func, tid); - } - } - keep_copies = true; - - List<RID> render_targets; - render_target_owner.get_owned_list(&render_targets); - for (List<RID>::Element *E = render_targets.front(); E; E = E->next()) { - RenderTarget *rt = render_target_owner.get(E->get()); - - int w = rt->width; - int h = rt->height; - rt->width = 0; - rt->height = 0; - render_target_set_size(E->get(), w, h); - } - - List<RID> meshes; - mesh_owner.get_owned_list(&meshes); - for (List<RID>::Element *E = meshes.front(); E; E = E->next()) { - - Mesh *mesh = mesh_owner.get(E->get()); - Vector<Surface *> surfaces = mesh->surfaces; - mesh->surfaces.clear(); - for (int i = 0; i < surfaces.size(); i++) { - mesh_add_surface(E->get(), surfaces[i]->primitive, surfaces[i]->data, surfaces[i]->morph_data, surfaces[i]->alpha_sort); - mesh_surface_set_material(E->get(), i, surfaces[i]->material); - - if (surfaces[i]->array_local != 0) { - memfree(surfaces[i]->array_local); - }; - if (surfaces[i]->index_array_local != 0) { - memfree(surfaces[i]->index_array_local); - }; - - memdelete(surfaces[i]); - } - } - - List<RID> skeletons; - skeleton_owner.get_owned_list(&skeletons); - for (List<RID>::Element *E = skeletons.front(); E; E = E->next()) { - - Skeleton *sk = skeleton_owner.get(E->get()); - if (!sk->tex_id) - continue; //does not use hw transform, leave alone - - Vector<Skeleton::Bone> bones = sk->bones; - sk->bones.clear(); - sk->tex_id = 0; - sk->pixel_size = 1.0; - skeleton_resize(E->get(), bones.size()); - sk->bones = bones; - } - - List<RID> multimeshes; - multimesh_owner.get_owned_list(&multimeshes); - for (List<RID>::Element *E = multimeshes.front(); E; E = E->next()) { - - MultiMesh *mm = multimesh_owner.get(E->get()); - if (!mm->tex_id) - continue; //does not use hw transform, leave alone - - Vector<MultiMesh::Element> elements = mm->elements; - mm->elements.clear(); - - mm->tw = 1; - mm->th = 1; - mm->tex_id = 0; - mm->last_pass = 0; - mm->visible = -1; - - multimesh_set_instance_count(E->get(), elements.size()); - mm->elements = elements; - } - - if (framebuffer.fbo != 0) { - - framebuffer.fbo = 0; - framebuffer.depth = 0; - framebuffer.color = 0; - - for (int i = 0; i < 3; i++) { - framebuffer.blur[i].fbo = 0; - framebuffer.blur[i].color = 0; - } - - framebuffer.luminance.clear(); - } - - for (int i = 0; i < near_shadow_buffers.size(); i++) { - near_shadow_buffers[i].init(near_shadow_buffers[i].size, !use_rgba_shadowmaps); - } - - blur_shadow_buffer.init(near_shadow_buffers[0].size, !use_rgba_shadowmaps); - - canvas_shader.clear_caches(); - material_shader.clear_caches(); - blur_shader.clear_caches(); - copy_shader.clear_caches(); - - List<RID> shaders; - shader_owner.get_owned_list(&shaders); - for (List<RID>::Element *E = shaders.front(); E; E = E->next()) { - - Shader *s = shader_owner.get(E->get()); - s->custom_code_id = 0; - s->version = 1; - s->valid = false; - shader_set_mode(E->get(), s->mode); - } - - List<RID> materials; - material_owner.get_owned_list(&materials); - for (List<RID>::Element *E = materials.front(); E; E = E->next()) { - - Material *m = material_owner.get(E->get()); - RID shader = m->shader; - m->shader_version = 0; - material_set_shader(E->get(), shader); - } -} - -void RasterizerGLES2::set_use_framebuffers(bool p_use) { - - use_framebuffers = p_use; -} - -RasterizerGLES2 *RasterizerGLES2::get_singleton() { - - return _singleton; -}; - -int RasterizerGLES2::RenderList::max_elements = RenderList::DEFAULT_MAX_ELEMENTS; - -void RasterizerGLES2::set_force_16_bits_fbo(bool p_force) { - - use_16bits_fbo = p_force; -} - -RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays, bool p_keep_ram_copy, bool p_default_fragment_lighting, bool p_use_reload_hooks) { - - _singleton = this; - shrink_textures_x2 = false; - RenderList::max_elements = GLOBAL_DEF("rasterizer/max_render_elements", (int)RenderList::DEFAULT_MAX_ELEMENTS); - if (RenderList::max_elements > 64000) - RenderList::max_elements = 64000; - if (RenderList::max_elements < 1024) - RenderList::max_elements = 1024; - - opaque_render_list.init(); - alpha_render_list.init(); - - skinned_buffer_size = GLOBAL_DEF("rasterizer/skeleton_buffer_size_kb", DEFAULT_SKINNED_BUFFER_SIZE); - if (skinned_buffer_size < 256) - skinned_buffer_size = 256; - if (skinned_buffer_size > 16384) - skinned_buffer_size = 16384; - skinned_buffer_size *= 1024; - skinned_buffer = memnew_arr(uint8_t, skinned_buffer_size); - - keep_copies = p_keep_ram_copy; - use_reload_hooks = p_use_reload_hooks; - pack_arrays = p_compress_arrays; - p_default_fragment_lighting = false; - fragment_lighting = GLOBAL_DEF("rasterizer/use_fragment_lighting", true); - read_depth_supported = true; //todo check for extension - shadow_filter = ShadowFilterTechnique((int)(GLOBAL_DEF("rasterizer/shadow_filter", SHADOW_FILTER_PCF5))); - ProjectSettings::get_singleton()->set_custom_property_info("rasterizer/shadow_filter", PropertyInfo(Variant::INT, "rasterizer/shadow_filter", PROPERTY_HINT_ENUM, "None,PCF5,PCF13,ESM")); - use_fp16_fb = bool(GLOBAL_DEF("rasterizer/fp16_framebuffer", true)); - use_shadow_mapping = true; - use_fast_texture_filter = !bool(GLOBAL_DEF("rasterizer/trilinear_mipmap_filter", true)); - low_memory_2d = bool(GLOBAL_DEF("rasterizer/low_memory_2d_mode", false)); - skel_default.resize(1024 * 4); - for (int i = 0; i < 1024 / 3; i++) { - - float *ptr = skel_default.ptr(); - ptr += i * 4 * 4; - ptr[0] = 1.0; - ptr[1] = 0.0; - ptr[2] = 0.0; - ptr[3] = 0.0; - - ptr[4] = 0.0; - ptr[5] = 1.0; - ptr[6] = 0.0; - ptr[7] = 0.0; - - ptr[8] = 0.0; - ptr[9] = 0.0; - ptr[10] = 1.0; - ptr[12] = 0.0; - } - - base_framebuffer = 0; - frame = 0; - draw_next_frame = false; - use_framebuffers = true; - framebuffer.active = false; - tc0_id_cache = 0; - tc0_idx = 0; - use_16bits_fbo = false; -}; - -void RasterizerGLES2::restore_framebuffer() { - - glBindFramebuffer(GL_FRAMEBUFFER, base_framebuffer); -} - -RasterizerGLES2::~RasterizerGLES2() { - - memdelete_arr(skinned_buffer); -}; - -#endif diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h deleted file mode 100644 index ca6a0fce26..0000000000 --- a/drivers/gles2/rasterizer_gles2.h +++ /dev/null @@ -1,1686 +0,0 @@ -/*************************************************************************/ -/* rasterizer_gles2.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 RASTERIZER_GLES2_H -#define RASTERIZER_GLES2_H - -#include "servers/visual/rasterizer.h" - -#define MAX_POLYGON_VERTICES 4096 //used for WebGL canvas_draw_polygon call. - -#ifdef GLES2_ENABLED - -#include "camera_matrix.h" -#include "image.h" -#include "list.h" -#include "map.h" -#include "rid.h" -#include "self_list.h" -#include "servers/visual_server.h" -#include "sort.h" - -#include "platform_config.h" -#ifndef GLES2_INCLUDE_H -#include <GLES2/gl2.h> -#else -#include GLES2_INCLUDE_H -#endif - -#include "drivers/gles2/shader_compiler_gles2.h" -#include "drivers/gles2/shaders/blur.glsl.h" -#include "drivers/gles2/shaders/canvas.glsl.h" -#include "drivers/gles2/shaders/canvas_shadow.glsl.h" -#include "drivers/gles2/shaders/copy.glsl.h" -#include "drivers/gles2/shaders/material.glsl.h" -#include "servers/visual/particle_system_sw.h" - -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ -class RasterizerGLES2 : public Rasterizer { - - enum { - - MAX_SCENE_LIGHTS = 2048, - LIGHT_SPOT_BIT = 0x80, - DEFAULT_SKINNED_BUFFER_SIZE = 2048, // 10k vertices - MAX_HW_LIGHTS = 1, - }; - - uint8_t *skinned_buffer; - int skinned_buffer_size; - bool pvr_supported; - bool pvr_srgb_supported; - bool s3tc_supported; - bool s3tc_srgb_supported; - bool latc_supported; - bool etc_supported; - bool atitc_supported; - bool npo2_textures_available; - bool read_depth_supported; - bool use_framebuffers; - bool full_float_fb_supported; - bool use_shadow_mapping; - bool use_fp16_fb; - bool srgb_supported; - bool float_supported; - bool float_linear_supported; - bool use_16bits_fbo; - - ShadowFilterTechnique shadow_filter; - - bool use_shadow_esm; - bool use_shadow_pcf; - bool use_hw_skeleton_xform; - bool use_depth24; - bool use_texture_instancing; - bool use_attribute_instancing; - bool use_rgba_shadowmaps; - bool use_anisotropic_filter; - float anisotropic_level; - - bool use_half_float; - bool low_memory_2d; - - bool shrink_textures_x2; - - Vector<float> skel_default; - - Image _get_gl_image_and_format(const Image &p_image, Image::Format p_format, uint32_t p_flags, GLenum &r_gl_format, GLenum &r_gl_internal_format, int &r_gl_components, bool &r_has_alpha_cache, bool &r_compressed); - - struct RenderTarget; - - struct Texture { - - String path; - uint32_t flags; - int width, height; - int alloc_width, alloc_height; - Image::Format format; - - GLenum target; - GLenum gl_format_cache; - GLenum gl_internal_format_cache; - int gl_components_cache; - int data_size; //original data size, useful for retrieving back - bool has_alpha; - bool format_has_alpha; - bool compressed; - bool disallow_mipmaps; - int total_data_size; - bool ignore_mipmaps; - - ObjectID reloader; - StringName reloader_func; - Image image[6]; - - int mipmaps; - - bool active; - GLuint tex_id; - - RenderTarget *render_target; - - Texture() { - - ignore_mipmaps = false; - render_target = NULL; - flags = width = height = 0; - tex_id = 0; - data_size = 0; - format = Image::FORMAT_L8; - gl_components_cache = 0; - format_has_alpha = false; - has_alpha = false; - active = false; - disallow_mipmaps = false; - compressed = false; - total_data_size = 0; - target = GL_TEXTURE_2D; - mipmaps = 0; - - reloader = 0; - } - - ~Texture() { - - if (tex_id != 0) { - - glDeleteTextures(1, &tex_id); - } - } - }; - - mutable RID_Owner<Texture> texture_owner; - - struct Shader { - - String vertex_code; - String fragment_code; - String light_code; - int vertex_line; - int fragment_line; - int light_line; - VS::ShaderMode mode; - - uint32_t custom_code_id; - uint32_t version; - - bool valid; - bool has_alpha; - bool can_zpass; - bool has_texscreen; - bool has_screen_uv; - bool writes_vertex; - bool uses_discard; - bool uses_time; - bool uses_normal; - bool uses_texpixel_size; - - Map<StringName, ShaderLanguage::Uniform> uniforms; - StringName first_texture; - - Map<StringName, RID> default_textures; - - SelfList<Shader> dirty_list; - - Shader() - : dirty_list(this) { - - valid = false; - custom_code_id = 0; - has_alpha = false; - version = 1; - vertex_line = 0; - fragment_line = 0; - light_line = 0; - can_zpass = true; - has_texscreen = false; - has_screen_uv = false; - writes_vertex = false; - uses_discard = false; - uses_time = false; - uses_normal = false; - } - }; - - mutable RID_Owner<Shader> shader_owner; - mutable SelfList<Shader>::List _shader_dirty_list; - _FORCE_INLINE_ void _shader_make_dirty(Shader *p_shader); - void _update_shader(Shader *p_shader) const; - - struct Material { - - bool flags[VS::MATERIAL_FLAG_MAX]; - - VS::MaterialBlendMode blend_mode; - VS::MaterialDepthDrawMode depth_draw_mode; - - float line_width; - bool has_alpha; - - mutable uint32_t shader_version; - - RID shader; // shader material - Shader *shader_cache; - - struct UniformData { - - bool inuse; - bool istexture; - Variant value; - int index; - }; - - mutable Map<StringName, UniformData> shader_params; - - uint64_t last_pass; - - Material() { - - for (int i = 0; i < VS::MATERIAL_FLAG_MAX; i++) - flags[i] = false; - flags[VS::MATERIAL_FLAG_VISIBLE] = true; - - line_width = 1; - has_alpha = false; - depth_draw_mode = VS::MATERIAL_DEPTH_DRAW_OPAQUE_ONLY; - blend_mode = VS::MATERIAL_BLEND_MODE_MIX; - last_pass = 0; - shader_version = 0; - shader_cache = NULL; - } - }; - - _FORCE_INLINE_ void _update_material_shader_params(Material *p_material) const; - mutable RID_Owner<Material> material_owner; - - struct Geometry { - - enum Type { - GEOMETRY_INVALID, - GEOMETRY_SURFACE, - GEOMETRY_IMMEDIATE, - GEOMETRY_PARTICLES, - GEOMETRY_MULTISURFACE, - }; - - Type type; - RID material; - bool has_alpha; - bool material_owned; - - Geometry() { - has_alpha = false; - material_owned = false; - } - virtual ~Geometry(){}; - }; - - struct GeometryOwner { - - virtual ~GeometryOwner() {} - }; - - struct Mesh; - - struct Surface : public Geometry { - - struct ArrayData { - - uint32_t ofs, size, datatype, count; - bool normalize; - bool bind; - - ArrayData() { - ofs = 0; - size = 0; - count = 0; - datatype = 0; - normalize = 0; - bind = false; - } - }; - - Mesh *mesh; - - Array data; - Array morph_data; - ArrayData array[VS::ARRAY_MAX]; - // support for vertex array objects - GLuint array_object_id; - // support for vertex buffer object - GLuint vertex_id; // 0 means, unconfigured - GLuint index_id; // 0 means, unconfigured - // no support for the above, array in localmem. - uint8_t *array_local; - uint8_t *index_array_local; - Vector<AABB> skeleton_bone_aabb; - Vector<bool> skeleton_bone_used; - - //bool packed; - - struct MorphTarget { - uint32_t configured_format; - uint8_t *array; - }; - - MorphTarget *morph_targets_local; - int morph_target_count; - AABB aabb; - - int array_len; - int index_array_len; - int max_bone; - - float vertex_scale; - float uv_scale; - float uv2_scale; - - bool alpha_sort; - - VS::PrimitiveType primitive; - - uint32_t format; - uint32_t configured_format; - - int stride; - int local_stride; - uint32_t morph_format; - - bool active; - - Point2 uv_min; - Point2 uv_max; - - Surface() { - - array_len = 0; - local_stride = 0; - morph_format = 0; - type = GEOMETRY_SURFACE; - primitive = VS::PRIMITIVE_POINTS; - index_array_len = 0; - vertex_scale = 1.0; - uv_scale = 1.0; - uv2_scale = 1.0; - - alpha_sort = false; - - format = 0; - stride = 0; - morph_targets_local = 0; - morph_target_count = 0; - - array_local = index_array_local = 0; - vertex_id = index_id = 0; - - active = false; - //packed=false; - } - - ~Surface() { - } - }; - - struct Mesh { - - bool active; - Vector<Surface *> surfaces; - int morph_target_count; - VS::MorphTargetMode morph_target_mode; - AABB custom_aabb; - - mutable uint64_t last_pass; - Mesh() { - morph_target_mode = VS::MORPH_MODE_NORMALIZED; - morph_target_count = 0; - last_pass = 0; - active = false; - } - }; - mutable RID_Owner<Mesh> mesh_owner; - - Error _surface_set_arrays(Surface *p_surface, uint8_t *p_mem, uint8_t *p_index_mem, const Array &p_arrays, bool p_main); - - struct MultiMesh; - - struct MultiMeshSurface : public Geometry { - - Surface *surface; - MultiMeshSurface() { type = GEOMETRY_MULTISURFACE; } - }; - - struct MultiMesh : public GeometryOwner { - - struct Element { - - float matrix[16]; - uint8_t color[4]; - Element() { - matrix[0] = 1; - matrix[1] = 0; - matrix[2] = 0; - matrix[3] = 0; - - matrix[4] = 0; - matrix[5] = 1; - matrix[6] = 0; - matrix[7] = 0; - - matrix[8] = 0; - matrix[9] = 0; - matrix[10] = 1; - matrix[11] = 0; - - matrix[12] = 0; - matrix[13] = 0; - matrix[14] = 0; - matrix[15] = 1; - }; - }; - - AABB aabb; - RID mesh; - int visible; - - //IDirect3DVertexBuffer9* instance_buffer; - Vector<Element> elements; - Vector<MultiMeshSurface> cache_surfaces; - mutable uint64_t last_pass; - GLuint tex_id; - int tw; - int th; - - SelfList<MultiMesh> dirty_list; - - MultiMesh() - : dirty_list(this) { - - tw = 1; - th = 1; - tex_id = 0; - last_pass = 0; - visible = -1; - } - }; - - mutable RID_Owner<MultiMesh> multimesh_owner; - mutable SelfList<MultiMesh>::List _multimesh_dirty_list; - - struct Immediate : public Geometry { - - struct Chunk { - - RID texture; - VS::PrimitiveType primitive; - Vector<Vector3> vertices; - Vector<Vector3> normals; - Vector<Plane> tangents; - Vector<Color> colors; - Vector<Vector2> uvs; - Vector<Vector2> uvs2; - }; - - List<Chunk> chunks; - bool building; - int mask; - AABB aabb; - - Immediate() { - type = GEOMETRY_IMMEDIATE; - building = false; - } - }; - - mutable RID_Owner<Immediate> immediate_owner; - - struct Particles : public Geometry { - - ParticleSystemSW data; // software particle system - - Particles() { - type = GEOMETRY_PARTICLES; - } - }; - - mutable RID_Owner<Particles> particles_owner; - - struct ParticlesInstance : public GeometryOwner { - - RID particles; - - ParticleSystemProcessSW particles_process; - Transform transform; - - ParticlesInstance() {} - }; - - mutable RID_Owner<ParticlesInstance> particles_instance_owner; - ParticleSystemDrawInfoSW particle_draw_info; - - struct Skeleton { - - struct Bone { - - float mtx[4][4]; //used - - Bone() { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - - mtx[i][j] = (i == j) ? 1 : 0; - } - } - } - - _ALWAYS_INLINE_ void transform_add_mul3(const float *p_src, float *r_dst, float p_weight) const { - - r_dst[0] += ((mtx[0][0] * p_src[0]) + (mtx[1][0] * p_src[1]) + (mtx[2][0] * p_src[2]) + mtx[3][0]) * p_weight; - r_dst[1] += ((mtx[0][1] * p_src[0]) + (mtx[1][1] * p_src[1]) + (mtx[2][1] * p_src[2]) + mtx[3][1]) * p_weight; - r_dst[2] += ((mtx[0][2] * p_src[0]) + (mtx[1][2] * p_src[1]) + (mtx[2][2] * p_src[2]) + mtx[3][2]) * p_weight; - } - _ALWAYS_INLINE_ void transform3_add_mul3(const float *p_src, float *r_dst, float p_weight) const { - - r_dst[0] += ((mtx[0][0] * p_src[0]) + (mtx[1][0] * p_src[1]) + (mtx[2][0] * p_src[2])) * p_weight; - r_dst[1] += ((mtx[0][1] * p_src[0]) + (mtx[1][1] * p_src[1]) + (mtx[2][1] * p_src[2])) * p_weight; - r_dst[2] += ((mtx[0][2] * p_src[0]) + (mtx[1][2] * p_src[1]) + (mtx[2][2] * p_src[2])) * p_weight; - } - - _ALWAYS_INLINE_ AABB transform_aabb(const AABB &p_aabb) const { - - float vertices[8][3] = { - { p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z }, - { p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z }, - { p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z }, - { p_aabb.pos.x + p_aabb.size.x, p_aabb.pos.y, p_aabb.pos.z }, - { p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z + p_aabb.size.z }, - { p_aabb.pos.x, p_aabb.pos.y + p_aabb.size.y, p_aabb.pos.z }, - { p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z + p_aabb.size.z }, - { p_aabb.pos.x, p_aabb.pos.y, p_aabb.pos.z } - }; - - AABB ret; - - for (int i = 0; i < 8; i++) { - - Vector3 xv( - - ((mtx[0][0] * vertices[i][0]) + (mtx[1][0] * vertices[i][1]) + (mtx[2][0] * vertices[i][2]) + mtx[3][0]), - ((mtx[0][1] * vertices[i][0]) + (mtx[1][1] * vertices[i][1]) + (mtx[2][1] * vertices[i][2]) + mtx[3][1]), - ((mtx[0][2] * vertices[i][0]) + (mtx[1][2] * vertices[i][1]) + (mtx[2][2] * vertices[i][2]) + mtx[3][2])); - - if (i == 0) - ret.pos = xv; - else - ret.expand_to(xv); - } - - return ret; - } - }; - - GLuint tex_id; - float pixel_size; //for texture - Vector<Bone> bones; - - SelfList<Skeleton> dirty_list; - - Skeleton() - : dirty_list(this) { - tex_id = 0; - pixel_size = 1.0; - } - }; - - mutable RID_Owner<Skeleton> skeleton_owner; - mutable SelfList<Skeleton>::List _skeleton_dirty_list; - - template <bool USE_NORMAL, bool USE_TANGENT, bool INPLACE> - void _skeleton_xform(const uint8_t *p_src_array, int p_src_stride, uint8_t *p_dst_array, int p_dst_stride, int p_elements, const uint8_t *p_src_bones, const uint8_t *p_src_weights, const Skeleton::Bone *p_bone_xforms); - - struct Light { - - VS::LightType type; - float vars[VS::LIGHT_PARAM_MAX]; - Color colors[3]; - bool shadow_enabled; - RID projector; - bool volumetric_enabled; - Color volumetric_color; - VS::LightOmniShadowMode omni_shadow_mode; - VS::LightDirectionalShadowMode directional_shadow_mode; - float directional_shadow_param[3]; - - Light() { - - vars[VS::LIGHT_PARAM_SPOT_ATTENUATION] = 1; - vars[VS::LIGHT_PARAM_SPOT_ANGLE] = 45; - vars[VS::LIGHT_PARAM_ATTENUATION] = 1.0; - vars[VS::LIGHT_PARAM_ENERGY] = 1.0; - vars[VS::LIGHT_PARAM_RADIUS] = 1.0; - vars[VS::LIGHT_PARAM_SHADOW_DARKENING] = 0.0; - vars[VS::LIGHT_PARAM_SHADOW_Z_OFFSET] = 0.2; - vars[VS::LIGHT_PARAM_SHADOW_Z_SLOPE_SCALE] = 1.4; - vars[VS::LIGHT_PARAM_SHADOW_ESM_MULTIPLIER] = 60.0; - vars[VS::LIGHT_PARAM_SHADOW_BLUR_PASSES] = 1; - colors[VS::LIGHT_COLOR_DIFFUSE] = Color(1, 1, 1); - colors[VS::LIGHT_COLOR_SPECULAR] = Color(1, 1, 1); - shadow_enabled = false; - volumetric_enabled = false; - - directional_shadow_param[VS::LIGHT_DIRECTIONAL_SHADOW_PARAM_PSSM_SPLIT_WEIGHT] = 0.5; - directional_shadow_param[VS::LIGHT_DIRECTIONAL_SHADOW_PARAM_MAX_DISTANCE] = 0; - directional_shadow_param[VS::LIGHT_DIRECTIONAL_SHADOW_PARAM_PSSM_ZOFFSET_SCALE] = 2.0; - omni_shadow_mode = VS::LIGHT_OMNI_SHADOW_DEFAULT; - directional_shadow_mode = VS::LIGHT_DIRECTIONAL_SHADOW_ORTHOGONAL; - } - }; - - struct Environment { - - VS::EnvironmentBG bg_mode; - Variant bg_param[VS::ENV_BG_PARAM_MAX]; - bool fx_enabled[VS::ENV_FX_MAX]; - Variant fx_param[VS::ENV_FX_PARAM_MAX]; - - Environment() { - - bg_mode = VS::ENV_BG_DEFAULT_COLOR; - bg_param[VS::ENV_BG_PARAM_COLOR] = Color(0, 0, 0); - bg_param[VS::ENV_BG_PARAM_TEXTURE] = RID(); - bg_param[VS::ENV_BG_PARAM_CUBEMAP] = RID(); - bg_param[VS::ENV_BG_PARAM_ENERGY] = 1.0; - bg_param[VS::ENV_BG_PARAM_SCALE] = 1.0; - bg_param[VS::ENV_BG_PARAM_GLOW] = 0.0; - bg_param[VS::ENV_BG_PARAM_CANVAS_MAX_LAYER] = 0; - - for (int i = 0; i < VS::ENV_FX_MAX; i++) - fx_enabled[i] = false; - - fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_PASSES] = 1; - fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_SCALE] = 1.0; - fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_STRENGTH] = 1.0; - fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_BLEND_MODE] = 0; - fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM] = 0.0; - fx_param[VS::ENV_FX_PARAM_GLOW_BLOOM_THRESHOLD] = 0.5; - fx_param[VS::ENV_FX_PARAM_DOF_BLUR_PASSES] = 1; - fx_param[VS::ENV_FX_PARAM_DOF_BLUR_BEGIN] = 100.0; - fx_param[VS::ENV_FX_PARAM_DOF_BLUR_RANGE] = 10.0; - fx_param[VS::ENV_FX_PARAM_HDR_TONEMAPPER] = VS::ENV_FX_HDR_TONE_MAPPER_LINEAR; - fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE] = 0.4; - fx_param[VS::ENV_FX_PARAM_HDR_WHITE] = 1.0; - fx_param[VS::ENV_FX_PARAM_HDR_GLOW_THRESHOLD] = 0.95; - fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE] = 0.2; - fx_param[VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE] = 0.4; - fx_param[VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE] = 8.0; - fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED] = 0.5; - fx_param[VS::ENV_FX_PARAM_FOG_BEGIN] = 100.0; - fx_param[VS::ENV_FX_PARAM_FOG_ATTENUATION] = 1.0; - fx_param[VS::ENV_FX_PARAM_FOG_BEGIN_COLOR] = Color(0, 0, 0); - fx_param[VS::ENV_FX_PARAM_FOG_END_COLOR] = Color(0, 0, 0); - fx_param[VS::ENV_FX_PARAM_FOG_BG] = true; - fx_param[VS::ENV_FX_PARAM_BCS_BRIGHTNESS] = 1.0; - fx_param[VS::ENV_FX_PARAM_BCS_CONTRAST] = 1.0; - fx_param[VS::ENV_FX_PARAM_BCS_SATURATION] = 1.0; - } - }; - - mutable RID_Owner<Environment> environment_owner; - - struct SampledLight { - - int w, h; - GLuint texture; - float multiplier; - bool is_float; - }; - - mutable RID_Owner<SampledLight> sampled_light_owner; - - struct ViewportData { - - //1x1 fbo+texture for storing previous HDR value - GLuint lum_fbo; - GLuint lum_color; - - ViewportData() { - lum_fbo = 0; - lum_color = 0; - } - }; - - mutable RID_Owner<ViewportData> viewport_data_owner; - - struct RenderTarget { - - Texture *texture_ptr; - RID texture; - GLuint fbo; - GLuint color; - GLuint depth; - int width, height; - uint64_t last_pass; - }; - - mutable RID_Owner<RenderTarget> render_target_owner; - - struct ShadowBuffer; - - struct LightInstance { - - struct SplitInfo { - - CameraMatrix camera; - Transform transform; - float near; - float far; - }; - - RID light; - Light *base; - Transform transform; - CameraMatrix projection; - - Transform custom_transform[4]; - CameraMatrix custom_projection[4]; - - Vector3 light_vector; - Vector3 spot_vector; - float linear_att; - - uint64_t shadow_pass; - uint64_t last_pass; - uint16_t sort_key; - - Vector2 dp; - - CameraMatrix shadow_projection[4]; - float shadow_split[4]; - - ShadowBuffer *near_shadow_buffer; - - void clear_shadow_buffers() { - - clear_near_shadow_buffers(); - } - - void clear_near_shadow_buffers() { - - if (near_shadow_buffer) { - near_shadow_buffer->owner = NULL; - near_shadow_buffer = NULL; - } - } - - LightInstance() { - shadow_pass = 0; - last_pass = 0; - sort_key = 0; - near_shadow_buffer = NULL; - } - }; - mutable RID_Owner<Light> light_owner; - mutable RID_Owner<LightInstance> light_instance_owner; - - LightInstance *light_instances[MAX_SCENE_LIGHTS]; - LightInstance *directional_lights[4]; - int light_instance_count; - int directional_light_count; - int last_light_id; - bool current_depth_test; - bool current_depth_mask; - VS::MaterialBlendMode current_blend_mode; - bool use_fast_texture_filter; - int max_texture_size; - - bool fragment_lighting; - RID shadow_material; - RID shadow_material_double_sided; - Material *shadow_mat_ptr; - Material *shadow_mat_double_sided_ptr; - - int max_texture_units; - GLuint base_framebuffer; - - GLuint gui_quad_buffer; - GLuint indices_buffer; - - struct RenderList { - - enum { - DEFAULT_MAX_ELEMENTS = 4096, - MAX_LIGHTS = 4, - SORT_FLAG_SKELETON = 1, - SORT_FLAG_INSTANCING = 2, - }; - - static int max_elements; - - struct Element { - - float depth; - const InstanceData *instance; - const Skeleton *skeleton; - const Geometry *geometry; - const Geometry *geometry_cmp; - const Material *material; - const GeometryOwner *owner; - bool *additive_ptr; - bool additive; - bool mirror; - union { -#ifdef BIG_ENDIAN_ENABLED - struct { - uint8_t sort_flags; - uint8_t light_type; - uint16_t light; - }; -#else - struct { - uint16_t light; - uint8_t light_type; - uint8_t sort_flags; - }; -#endif - uint32_t sort_key; - }; - }; - - Element *_elements; - Element **elements; - int element_count; - - void clear() { - - element_count = 0; - } - - struct SortZ { - - _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const { - - return A->depth > B->depth; - } - }; - - void sort_z() { - - SortArray<Element *, SortZ> sorter; - sorter.sort(elements, element_count); - } - - struct SortMatGeom { - - _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const { - // TODO move to a single uint64 (one comparison) - if (A->material->shader_cache == B->material->shader_cache) { - if (A->material == B->material) { - - return A->geometry_cmp < B->geometry_cmp; - } else { - - return (A->material < B->material); - } - } else { - - return A->material->shader_cache < B->material->shader_cache; - } - } - }; - - void sort_mat_geom() { - - SortArray<Element *, SortMatGeom> sorter; - sorter.sort(elements, element_count); - } - - struct SortMatLight { - - _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const { - - if (A->geometry_cmp == B->geometry_cmp) { - - if (A->material == B->material) { - - return A->light < B->light; - } else { - - return (A->material < B->material); - } - } else { - - return (A->geometry_cmp < B->geometry_cmp); - } - } - }; - - void sort_mat_light() { - - SortArray<Element *, SortMatLight> sorter; - sorter.sort(elements, element_count); - } - - struct SortMatLightType { - - _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const { - - if (A->light_type == B->light_type) { - if (A->material->shader_cache == B->material->shader_cache) { - if (A->material == B->material) { - - return (A->geometry_cmp < B->geometry_cmp); - } else { - - return (A->material < B->material); - } - } else { - - return (A->material->shader_cache < B->material->shader_cache); - } - } else { - - return A->light_type < B->light_type; - } - } - }; - - void sort_mat_light_type() { - - SortArray<Element *, SortMatLightType> sorter; - sorter.sort(elements, element_count); - } - - struct SortMatLightTypeFlags { - - _FORCE_INLINE_ bool operator()(const Element *A, const Element *B) const { - - if (A->sort_key == B->sort_key) { - if (A->material->shader_cache == B->material->shader_cache) { - if (A->material == B->material) { - - return (A->geometry_cmp < B->geometry_cmp); - } else { - - return (A->material < B->material); - } - } else { - - return (A->material->shader_cache < B->material->shader_cache); - } - } else { - - return A->sort_key < B->sort_key; //one is null and one is not - } - } - }; - - void sort_mat_light_type_flags() { - - SortArray<Element *, SortMatLightTypeFlags> sorter; - sorter.sort(elements, element_count); - } - _FORCE_INLINE_ Element *add_element() { - - if (element_count >= max_elements) - return NULL; - elements[element_count] = &_elements[element_count]; - return elements[element_count++]; - } - - void init() { - - element_count = 0; - elements = memnew_arr(Element *, max_elements); - _elements = memnew_arr(Element, max_elements); - for (int i = 0; i < max_elements; i++) - elements[i] = &_elements[i]; // assign elements - } - - RenderList() { - } - ~RenderList() { - memdelete_arr(elements); - memdelete_arr(_elements); - } - }; - - RenderList opaque_render_list; - RenderList alpha_render_list; - - RID default_material; - - CameraMatrix camera_projection; - Transform camera_transform; - Transform camera_transform_inverse; - float camera_z_near; - float camera_z_far; - Size2 camera_vp_size; - bool camera_ortho; - Set<String> extensions; - bool texscreen_copied; - bool texscreen_used; - - Plane camera_plane; - - void _add_geometry(const Geometry *p_geometry, const InstanceData *p_instance, const Geometry *p_geometry_cmp, const GeometryOwner *p_owner, int p_material = -1); - void _render_list_forward(RenderList *p_render_list, const Transform &p_view_transform, const Transform &p_view_transform_inverse, const CameraMatrix &p_projection, bool p_reverse_cull = false, bool p_fragment_light = false, bool p_alpha_pass = false); - - //void _setup_light(LightInstance* p_instance, int p_idx); - void _setup_light(uint16_t p_light); - - _FORCE_INLINE_ void _setup_shader_params(const Material *p_material); - bool _setup_material(const Geometry *p_geometry, const Material *p_material, bool p_no_const_light, bool p_opaque_pass); - void _setup_skeleton(const Skeleton *p_skeleton); - - Error _setup_geometry(const Geometry *p_geometry, const Material *p_material, const Skeleton *p_skeleton, const float *p_morphs); - void _render(const Geometry *p_geometry, const Material *p_material, const Skeleton *p_skeleton, const GeometryOwner *p_owner, const Transform &p_xform); - - /***********/ - /* SHADOWS */ - /***********/ - - struct ShadowBuffer { - - int size; - GLuint fbo; - GLuint rbo; - GLuint depth; - GLuint rgba; //for older devices -#if 0 - GLuint fbo_blur; - GLuint rbo_blur; - GLuint blur; -#endif - - LightInstance *owner; - bool init(int p_size, bool p_use_depth); - ShadowBuffer() { - size = 0; - depth = 0; - owner = NULL; - } - }; - - Vector<ShadowBuffer> near_shadow_buffers; - ShadowBuffer blur_shadow_buffer; - - Vector<ShadowBuffer> far_shadow_buffers; - - LightInstance *shadow; - int shadow_pass; - - float shadow_near_far_split_size_ratio; - bool _allocate_shadow_buffers(LightInstance *p_instance, Vector<ShadowBuffer> &p_buffers); - void _debug_draw_shadow(GLuint tex, const Rect2 &p_rect); - void _debug_draw_shadows_type(Vector<ShadowBuffer> &p_shadows, Point2 &ofs); - void _debug_shadows(); - void _debug_luminances(); - void _debug_samplers(); - - /***********/ - /* FBOs */ - /***********/ - - struct FrameBuffer { - - GLuint fbo; - GLuint color; - GLuint depth; - - int width, height; - int scale; - bool active; - - int blur_size; - - struct Blur { - - GLuint fbo; - GLuint color; - - Blur() { - fbo = 0; - color = 0; - } - } blur[3]; - - struct Luminance { - - int size; - GLuint fbo; - GLuint color; - - Luminance() { - fbo = 0; - color = 0; - size = 0; - } - }; - - Vector<Luminance> luminance; - - GLuint sample_fbo; - GLuint sample_color; - - FrameBuffer() { - blur_size = 0; - } - - } framebuffer; - - void _update_framebuffer(); - void _process_glow_and_bloom(); - //void _update_blur_buffer(); - - /*********/ - /* FRAME */ - /*********/ - - struct _Rinfo { - - int texture_mem; - int vertex_count; - int object_count; - int mat_change_count; - int surface_count; - int shader_change_count; - int ci_draw_commands; - int draw_calls; - - } _rinfo; - - /*******************/ - /* CANVAS OCCLUDER */ - /*******************/ - - struct CanvasOccluder { - - GLuint vertex_id; // 0 means, unconfigured - GLuint index_id; // 0 means, unconfigured - DVector<Vector2> lines; - int len; - }; - - RID_Owner<CanvasOccluder> canvas_occluder_owner; - - /***********************/ - /* CANVAS LIGHT SHADOW */ - /***********************/ - - struct CanvasLightShadow { - - int size; - int height; - GLuint fbo; - GLuint rbo; - GLuint depth; - GLuint rgba; //for older devices - - GLuint blur; - }; - - RID_Owner<CanvasLightShadow> canvas_light_shadow_owner; - - RID canvas_shadow_blur; - - /* ETC */ - - RenderTarget *current_rt; - bool current_rt_transparent; - bool current_rt_vflip; - ViewportData *current_vd; - - GLuint white_tex; - RID canvas_tex; - float canvas_opacity; - Color canvas_modulate; - bool canvas_use_modulate; - bool uses_texpixel_size; - bool rebind_texpixel_size; - Transform canvas_transform; - ShaderMaterial *canvas_last_material; - bool canvas_texscreen_used; - Vector2 normal_flip; - _FORCE_INLINE_ void _canvas_normal_set_flip(const Vector2 &p_flip); - - _FORCE_INLINE_ Texture *_bind_canvas_texture(const RID &p_texture); - VS::MaterialBlendMode canvas_blend_mode; - - int _setup_geometry_vinfo; - - bool pack_arrays; - bool keep_copies; - bool use_reload_hooks; - bool cull_front; - bool lights_use_shadow; - _FORCE_INLINE_ void _set_cull(bool p_front, bool p_reverse_cull = false); - _FORCE_INLINE_ Color _convert_color(const Color &p_color); - - void _process_glow_bloom(); - void _process_hdr(); - void _draw_tex_bg(); - - bool using_canvas_bg; - Size2 window_size; - VS::ViewportRect viewport; - double last_time; - double time_delta; - uint64_t frame; - uint64_t scene_pass; - bool draw_next_frame; - Environment *current_env; - VS::ScenarioDebugMode current_debug; - RID overdraw_material; - float shader_time_rollback; - - mutable MaterialShaderGLES2 material_shader; - mutable CanvasShaderGLES2 canvas_shader; - BlurShaderGLES2 blur_shader; - CopyShaderGLES2 copy_shader; - mutable CanvasShadowShaderGLES2 canvas_shadow_shader; - - mutable ShaderCompilerGLES2 shader_precompiler; - - void _draw_primitive(int p_points, const Vector3 *p_vertices, const Vector3 *p_normals, const Color *p_colors, const Vector3 *p_uvs, const Plane *p_tangents = NULL, int p_instanced = 1); - _FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs); - _FORCE_INLINE_ void _draw_gui_primitive2(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs, const Vector2 *p_uvs2); - void _draw_textured_quad(const Rect2 &p_rect, const Rect2 &p_src_region, const Size2 &p_tex_size, bool p_h_flip = false, bool p_v_flip = false, bool p_transpose = false); - void _draw_quad(const Rect2 &p_rect); - void _copy_screen_quad(); - void _copy_to_texscreen(); - - bool _test_depth_shadow_buffer(); - - Vector3 chunk_vertex; - Vector3 chunk_normal; - Plane chunk_tangent; - Color chunk_color; - Vector2 chunk_uv; - Vector2 chunk_uv2; - GLuint tc0_id_cache; - GLuint tc0_idx; - - template <bool use_normalmap> - _FORCE_INLINE_ void _canvas_item_render_commands(CanvasItem *p_item, CanvasItem *current_clip, bool &reclip); - _FORCE_INLINE_ void _canvas_item_setup_shader_params(ShaderMaterial *material, Shader *p_shader); - _FORCE_INLINE_ void _canvas_item_setup_shader_uniforms(ShaderMaterial *material, Shader *p_shader); - -public: - /* TEXTURE API */ - - virtual RID texture_create(); - virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT); - virtual void texture_set_data(RID p_texture, const Image &p_image, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT); - virtual Image texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) const; - virtual void texture_set_flags(RID p_texture, uint32_t p_flags); - virtual uint32_t texture_get_flags(RID p_texture) const; - virtual Image::Format texture_get_format(RID p_texture) const; - virtual uint32_t texture_get_width(RID p_texture) const; - virtual uint32_t texture_get_height(RID p_texture) const; - virtual bool texture_has_alpha(RID p_texture) const; - virtual void texture_set_size_override(RID p_texture, int p_width, int p_height); - virtual void texture_set_reload_hook(RID p_texture, ObjectID p_owner, const StringName &p_function) const; - - virtual void texture_set_path(RID p_texture, const String &p_path); - virtual String texture_get_path(RID p_texture) const; - virtual void texture_debug_usage(List<VS::TextureInfo> *r_info); - - virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable); - - GLuint _texture_get_name(RID p_tex); - - /* SHADER API */ - - virtual RID shader_create(VS::ShaderMode p_mode = VS::SHADER_MATERIAL); - - virtual void shader_set_mode(RID p_shader, VS::ShaderMode p_mode); - virtual VS::ShaderMode shader_get_mode(RID p_shader) const; - - virtual void shader_set_code(RID p_shader, const String &p_vertex, const String &p_fragment, const String &p_light, int p_vertex_ofs = 0, int p_fragment_ofs = 0, int p_light_ofs = 0); - virtual String shader_get_fragment_code(RID p_shader) const; - virtual String shader_get_vertex_code(RID p_shader) const; - virtual String shader_get_light_code(RID p_shader) const; - - virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const; - - virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture); - virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const; - - virtual Variant shader_get_default_param(RID p_shader, const StringName &p_name); - - /* COMMON MATERIAL API */ - - virtual RID material_create(); - - virtual void material_set_shader(RID p_shader_material, RID p_shader); - virtual RID material_get_shader(RID p_shader_material) const; - - virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value); - virtual Variant material_get_param(RID p_material, const StringName &p_param) const; - - virtual void material_set_flag(RID p_material, VS::MaterialFlag p_flag, bool p_enabled); - virtual bool material_get_flag(RID p_material, VS::MaterialFlag p_flag) const; - - virtual void material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode); - virtual VS::MaterialDepthDrawMode material_get_depth_draw_mode(RID p_material) const; - - virtual void material_set_blend_mode(RID p_material, VS::MaterialBlendMode p_mode); - virtual VS::MaterialBlendMode material_get_blend_mode(RID p_material) const; - - virtual void material_set_line_width(RID p_material, float p_line_width); - virtual float material_get_line_width(RID p_material) const; - - /* MESH API */ - - virtual RID mesh_create(); - - virtual void mesh_add_surface(RID p_mesh, VS::PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), bool p_alpha_sort = false); - virtual Array mesh_get_surface_arrays(RID p_mesh, int p_surface) const; - virtual Array mesh_get_surface_morph_arrays(RID p_mesh, int p_surface) const; - virtual void mesh_add_custom_surface(RID p_mesh, const Variant &p_dat); - - virtual void mesh_set_morph_target_count(RID p_mesh, int p_amount); - virtual int mesh_get_morph_target_count(RID p_mesh) const; - - virtual void mesh_set_morph_target_mode(RID p_mesh, VS::MorphTargetMode p_mode); - virtual VS::MorphTargetMode mesh_get_morph_target_mode(RID p_mesh) const; - - virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material, bool p_owned = false); - virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const; - - virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const; - virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const; - virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const; - virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const; - - virtual void mesh_remove_surface(RID p_mesh, int p_index); - virtual int mesh_get_surface_count(RID p_mesh) const; - - virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton = RID()) const; - - virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb); - virtual AABB mesh_get_custom_aabb(RID p_mesh) const; - - /* MULTIMESH API */ - - virtual RID multimesh_create(); - - virtual void multimesh_set_instance_count(RID p_multimesh, int p_count); - virtual int multimesh_get_instance_count(RID p_multimesh) const; - - virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh); - virtual void multimesh_set_aabb(RID p_multimesh, const AABB &p_aabb); - virtual void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform &p_transform); - virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color); - - virtual RID multimesh_get_mesh(RID p_multimesh) const; - virtual AABB multimesh_get_aabb(RID p_multimesh) const; - - virtual Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const; - virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const; - - virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible); - virtual int multimesh_get_visible_instances(RID p_multimesh) const; - - /* IMMEDIATE API */ - - virtual RID immediate_create(); - virtual void immediate_begin(RID p_immediate, VS::PrimitiveType p_rimitive, RID p_texture = RID()); - virtual void immediate_vertex(RID p_immediate, const Vector3 &p_vertex); - virtual void immediate_normal(RID p_immediate, const Vector3 &p_normal); - virtual void immediate_tangent(RID p_immediate, const Plane &p_tangent); - virtual void immediate_color(RID p_immediate, const Color &p_color); - virtual void immediate_uv(RID p_immediate, const Vector2 &tex_uv); - virtual void immediate_uv2(RID p_immediate, const Vector2 &tex_uv); - virtual void immediate_end(RID p_immediate); - virtual void immediate_clear(RID p_immediate); - virtual AABB immediate_get_aabb(RID p_immediate) const; - virtual void immediate_set_material(RID p_immediate, RID p_material); - virtual RID immediate_get_material(RID p_immediate) const; - - /* PARTICLES API */ - - virtual RID particles_create(); - - virtual void particles_set_amount(RID p_particles, int p_amount); - virtual int particles_get_amount(RID p_particles) const; - - virtual void particles_set_emitting(RID p_particles, bool p_emitting); - virtual bool particles_is_emitting(RID p_particles) const; - - virtual void particles_set_visibility_aabb(RID p_particles, const AABB &p_visibility); - virtual AABB particles_get_visibility_aabb(RID p_particles) const; - - virtual void particles_set_emission_half_extents(RID p_particles, const Vector3 &p_half_extents); - virtual Vector3 particles_get_emission_half_extents(RID p_particles) const; - - virtual void particles_set_emission_base_velocity(RID p_particles, const Vector3 &p_base_velocity); - virtual Vector3 particles_get_emission_base_velocity(RID p_particles) const; - - virtual void particles_set_emission_points(RID p_particles, const DVector<Vector3> &p_points); - virtual DVector<Vector3> particles_get_emission_points(RID p_particles) const; - - virtual void particles_set_gravity_normal(RID p_particles, const Vector3 &p_normal); - virtual Vector3 particles_get_gravity_normal(RID p_particles) const; - - virtual void particles_set_variable(RID p_particles, VS::ParticleVariable p_variable, float p_value); - virtual float particles_get_variable(RID p_particles, VS::ParticleVariable p_variable) const; - - virtual void particles_set_randomness(RID p_particles, VS::ParticleVariable p_variable, float p_randomness); - virtual float particles_get_randomness(RID p_particles, VS::ParticleVariable p_variable) const; - - virtual void particles_set_color_phase_pos(RID p_particles, int p_phase, float p_pos); - virtual float particles_get_color_phase_pos(RID p_particles, int p_phase) const; - - virtual void particles_set_color_phases(RID p_particles, int p_phases); - virtual int particles_get_color_phases(RID p_particles) const; - - virtual void particles_set_color_phase_color(RID p_particles, int p_phase, const Color &p_color); - virtual Color particles_get_color_phase_color(RID p_particles, int p_phase) const; - - virtual void particles_set_attractors(RID p_particles, int p_attractors); - virtual int particles_get_attractors(RID p_particles) const; - - virtual void particles_set_attractor_pos(RID p_particles, int p_attractor, const Vector3 &p_pos); - virtual Vector3 particles_get_attractor_pos(RID p_particles, int p_attractor) const; - - virtual void particles_set_attractor_strength(RID p_particles, int p_attractor, float p_force); - virtual float particles_get_attractor_strength(RID p_particles, int p_attractor) const; - - virtual void particles_set_material(RID p_particles, RID p_material, bool p_owned = false); - virtual RID particles_get_material(RID p_particles) const; - - virtual AABB particles_get_aabb(RID p_particles) const; - - virtual void particles_set_height_from_velocity(RID p_particles, bool p_enable); - virtual bool particles_has_height_from_velocity(RID p_particles) const; - - virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable); - virtual bool particles_is_using_local_coordinates(RID p_particles) const; - - /* SKELETON API */ - - virtual RID skeleton_create(); - virtual void skeleton_resize(RID p_skeleton, int p_bones); - virtual int skeleton_get_bone_count(RID p_skeleton) const; - virtual void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform &p_transform); - virtual Transform skeleton_bone_get_transform(RID p_skeleton, int p_bone); - - /* LIGHT API */ - - virtual RID light_create(VS::LightType p_type); - virtual VS::LightType light_get_type(RID p_light) const; - - virtual void light_set_color(RID p_light, VS::LightColor p_type, const Color &p_color); - virtual Color light_get_color(RID p_light, VS::LightColor p_type) const; - - virtual void light_set_shadow(RID p_light, bool p_enabled); - virtual bool light_has_shadow(RID p_light) const; - - virtual void light_set_volumetric(RID p_light, bool p_enabled); - virtual bool light_is_volumetric(RID p_light) const; - - virtual void light_set_projector(RID p_light, RID p_texture); - virtual RID light_get_projector(RID p_light) const; - - virtual void light_set_var(RID p_light, VS::LightParam p_var, float p_value); - virtual float light_get_var(RID p_light, VS::LightParam p_var) const; - - virtual void light_set_operator(RID p_light, VS::LightOp p_op); - virtual VS::LightOp light_get_operator(RID p_light) const; - - virtual void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode); - virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) const; - - virtual void light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode); - virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) const; - virtual void light_directional_set_shadow_param(RID p_light, VS::LightDirectionalShadowParam p_param, float p_value); - virtual float light_directional_get_shadow_param(RID p_light, VS::LightDirectionalShadowParam p_param) const; - - virtual AABB light_get_aabb(RID p_light) const; - - virtual RID light_instance_create(RID p_light); - virtual void light_instance_set_transform(RID p_light_instance, const Transform &p_transform); - - virtual ShadowType light_instance_get_shadow_type(RID p_light_instance, bool p_far = false) const; - virtual int light_instance_get_shadow_passes(RID p_light_instance) const; - virtual bool light_instance_get_pssm_shadow_overlap(RID p_light_instance) const; - virtual void light_instance_set_shadow_transform(RID p_light_instance, int p_index, const CameraMatrix &p_camera, const Transform &p_transform, float p_split_near = 0, float p_split_far = 0); - virtual int light_instance_get_shadow_size(RID p_light_instance, int p_index = 0) const; - - virtual void shadow_clear_near(); - virtual bool shadow_allocate_near(RID p_light); - virtual bool shadow_allocate_far(RID p_light); - - /* SHADOW */ - - virtual RID particles_instance_create(RID p_particles); - virtual void particles_instance_set_transform(RID p_particles_instance, const Transform &p_transform); - - /* VIEWPORT */ - - virtual RID viewport_data_create(); - - virtual RID render_target_create(); - virtual void render_target_set_size(RID p_render_target, int p_width, int p_height); - virtual RID render_target_get_texture(RID p_render_target) const; - virtual bool render_target_renedered_in_frame(RID p_render_target); - - /* RENDER API */ - /* all calls (inside begin/end shadow) are always warranted to be in the following order: */ - - virtual void begin_frame(); - - virtual void set_viewport(const VS::ViewportRect &p_viewport); - virtual void set_render_target(RID p_render_target, bool p_transparent_bg = false, bool p_vflip = false); - virtual void clear_viewport(const Color &p_color); - virtual void capture_viewport(Image *r_capture); - - virtual void begin_scene(RID p_viewport_data, RID p_env, VS::ScenarioDebugMode p_debug); - - virtual void begin_shadow_map(RID p_light_instance, int p_shadow_pass); - - virtual void set_camera(const Transform &p_world, const CameraMatrix &p_projection, bool p_ortho_hint); - - virtual void add_light(RID p_light_instance); ///< all "add_light" calls happen before add_geometry calls - - typedef Map<StringName, Variant> ParamOverrideMap; - - virtual void add_mesh(const RID &p_mesh, const InstanceData *p_data); - virtual void add_multimesh(const RID &p_multimesh, const InstanceData *p_data); - virtual void add_immediate(const RID &p_immediate, const InstanceData *p_data); - virtual void add_particles(const RID &p_particle_instance, const InstanceData *p_data); - - virtual void end_scene(); - virtual void end_shadow_map(); - - virtual void end_frame(); - - /* CANVAS API */ - - virtual void begin_canvas_bg(); - - virtual void canvas_begin(); - virtual void canvas_disable_blending(); - - virtual void canvas_set_opacity(float p_opacity); - virtual void canvas_set_blend_mode(VS::MaterialBlendMode p_mode); - virtual void canvas_begin_rect(const Transform2D &p_transform); - virtual void canvas_set_clip(bool p_clip, const Rect2 &p_rect); - virtual void canvas_end_rect(); - virtual void canvas_draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width, bool p_antialiased); - virtual void canvas_draw_rect(const Rect2 &p_rect, int p_flags, const Rect2 &p_source, RID p_texture, const Color &p_modulate); - virtual void canvas_draw_style_box(const Rect2 &p_rect, const Rect2 &p_src_region, RID p_texture, const float *p_margins, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1)); - virtual void canvas_draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width); - virtual void canvas_draw_polygon(int p_vertex_count, const int *p_indices, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, const RID &p_texture, bool p_singlecolor); - virtual void canvas_set_transform(const Transform2D &p_transform); - - virtual void canvas_render_items(CanvasItem *p_item_list, int p_z, const Color &p_modulate, CanvasLight *p_light); - virtual void canvas_debug_viewport_shadows(CanvasLight *p_lights_with_shadow); - - /* CANVAS LIGHT SHADOW */ - - //buffer - virtual RID canvas_light_shadow_buffer_create(int p_width); - virtual void canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, CanvasLightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache); - - //occluder - virtual RID canvas_light_occluder_create(); - virtual void canvas_light_occluder_set_polylines(RID p_occluder, const DVector<Vector2> &p_lines); - - /* ENVIRONMENT */ - - virtual RID environment_create(); - - virtual void environment_set_background(RID p_env, VS::EnvironmentBG p_bg); - virtual VS::EnvironmentBG environment_get_background(RID p_env) const; - - virtual void environment_set_background_param(RID p_env, VS::EnvironmentBGParam p_param, const Variant &p_value); - virtual Variant environment_get_background_param(RID p_env, VS::EnvironmentBGParam p_param) const; - - virtual void environment_set_enable_fx(RID p_env, VS::EnvironmentFx p_effect, bool p_enabled); - virtual bool environment_is_fx_enabled(RID p_env, VS::EnvironmentFx p_effect) const; - - virtual void environment_fx_set_param(RID p_env, VS::EnvironmentFxParam p_param, const Variant &p_value); - virtual Variant environment_fx_get_param(RID p_env, VS::EnvironmentFxParam p_param) const; - - /* SAMPLED LIGHT */ - virtual RID sampled_light_dp_create(int p_width, int p_height); - virtual void sampled_light_dp_update(RID p_sampled_light, const Color *p_data, float p_multiplier); - - /*MISC*/ - - virtual bool is_texture(const RID &p_rid) const; - virtual bool is_material(const RID &p_rid) const; - virtual bool is_mesh(const RID &p_rid) const; - virtual bool is_immediate(const RID &p_rid) const; - virtual bool is_multimesh(const RID &p_rid) const; - virtual bool is_particles(const RID &p_beam) const; - - virtual bool is_light(const RID &p_rid) const; - virtual bool is_light_instance(const RID &p_rid) const; - virtual bool is_particles_instance(const RID &p_rid) const; - virtual bool is_skeleton(const RID &p_rid) const; - virtual bool is_environment(const RID &p_rid) const; - virtual bool is_shader(const RID &p_rid) const; - - virtual bool is_canvas_light_occluder(const RID &p_rid) const; - - virtual void free(const RID &p_rid); - - virtual void init(); - virtual void finish(); - - virtual int get_render_info(VS::RenderInfo p_info); - - void set_base_framebuffer(GLuint p_id, Vector2 p_size = Vector2(0, 0)); - - virtual void flush_frame(); //not necessary in most cases - void set_extensions(const char *p_strings); - - virtual bool needs_to_draw_next_frame() const; - - void set_use_framebuffers(bool p_use); - void reload_vram(); - - virtual bool has_feature(VS::Features p_feature) const; - - virtual void restore_framebuffer(); - - static RasterizerGLES2 *get_singleton(); - - virtual void set_force_16_bits_fbo(bool p_force); - - RasterizerGLES2(bool p_compress_arrays = false, bool p_keep_ram_copy = true, bool p_default_fragment_lighting = true, bool p_use_reload_hooks = false); - virtual ~RasterizerGLES2(); -}; - -#endif -#endif diff --git a/drivers/gles2/rasterizer_instance_gles2.cpp b/drivers/gles2/rasterizer_instance_gles2.cpp deleted file mode 100644 index 8aedd4def0..0000000000 --- a/drivers/gles2/rasterizer_instance_gles2.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************/ -/* rasterizer_instance_gles2.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "rasterizer_instance_gles2.h" -#include "rasterizer_gles2.h" - -#ifdef GLES2_ENABLED - -Rasterizer *instance_RasterizerGLES2() { - - return memnew(RasterizerGLES2); -} - -#endif diff --git a/drivers/gles2/rasterizer_instance_gles2.h b/drivers/gles2/rasterizer_instance_gles2.h deleted file mode 100644 index 09e9716b50..0000000000 --- a/drivers/gles2/rasterizer_instance_gles2.h +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************/ -/* rasterizer_instance_gles2.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 RASTERIZER_INSTANCE_GLES2_H -#define RASTERIZER_INSTANCE_GLES2_H - -#include "servers/visual/rasterizer.h" - -#ifdef GLES2_ENABLED - -Rasterizer *instance_RasterizerGLES2(); - -#endif - -#endif // RASTERIZER_INSTANCE_gles2_H diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp deleted file mode 100644 index 778d28fb99..0000000000 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ /dev/null @@ -1,939 +0,0 @@ -/*************************************************************************/ -/* shader_compiler_gles2.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "shader_compiler_gles2.h" -#include "print_string.h" - -#include "stdio.h" - -//#define DEBUG_SHADER_ENABLED - -typedef ShaderLanguage SL; - -struct CodeGLSL2 { - - String code; -}; - -static String _mktab(int p_level) { - - String tb; - for (int i = 0; i < p_level; i++) { - tb += "\t"; - } - - return tb; -} - -static String _typestr(SL::DataType p_type) { - - switch (p_type) { - - case SL::TYPE_VOID: return "void"; - case SL::TYPE_BOOL: return "bool"; - case SL::TYPE_FLOAT: return "float"; - case SL::TYPE_VEC2: return "vec2"; - case SL::TYPE_VEC3: return "vec3"; - case SL::TYPE_VEC4: return "vec4"; - case SL::TYPE_MAT2: return "mat2"; - case SL::TYPE_MAT3: return "mat3"; - case SL::TYPE_MAT4: return "mat4"; - case SL::TYPE_TEXTURE: return "sampler2D"; - case SL::TYPE_CUBEMAP: return "samplerCube"; - } - - return ""; -} - -static String _mknum(float p_num) { - return String::num_real(p_num); -} - -static String _opstr(SL::Operator p_op) { - - switch (p_op) { - case SL::OP_ASSIGN: return "="; - case SL::OP_ADD: return "+"; - case SL::OP_SUB: return "-"; - case SL::OP_MUL: return "*"; - case SL::OP_DIV: return "/"; - case SL::OP_ASSIGN_ADD: return "+="; - case SL::OP_ASSIGN_SUB: return "-="; - case SL::OP_ASSIGN_MUL: return "*="; - case SL::OP_ASSIGN_DIV: return "/="; - case SL::OP_NEG: return "-"; - case SL::OP_NOT: return "!"; - case SL::OP_CMP_EQ: return "=="; - case SL::OP_CMP_NEQ: return "!="; - case SL::OP_CMP_LEQ: return "<="; - case SL::OP_CMP_GEQ: return ">="; - case SL::OP_CMP_LESS: return "<"; - case SL::OP_CMP_GREATER: return ">"; - case SL::OP_CMP_OR: return "||"; - case SL::OP_CMP_AND: return "&&"; - default: return ""; - } - - return ""; -} - -//#ifdef DEBUG_SHADER_ENABLED -#if 1 -#define ENDL "\n" -#else -#define ENDL "" -#endif - -String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node, int p_level, bool p_assign_left) { - - String code; - - switch (p_node->type) { - - case SL::Node::TYPE_PROGRAM: { - - SL::ProgramNode *pnode = (SL::ProgramNode *)p_node; - - code += dump_node_code(pnode->body, p_level); - } break; - case SL::Node::TYPE_FUNCTION: { - - } break; - case SL::Node::TYPE_BLOCK: { - SL::BlockNode *bnode = (SL::BlockNode *)p_node; - - //variables - code += "{" ENDL; - for (Map<StringName, SL::DataType>::Element *E = bnode->variables.front(); E; E = E->next()) { - - code += _mktab(p_level) + _typestr(E->value()) + " " + replace_string(E->key()) + ";" ENDL; - } - - for (int i = 0; i < bnode->statements.size(); i++) { - - code += _mktab(p_level) + dump_node_code(bnode->statements[i], p_level) + ";" ENDL; - } - - code += "}" ENDL; - - } break; - case SL::Node::TYPE_VARIABLE: { - SL::VariableNode *vnode = (SL::VariableNode *)p_node; - - if (type == ShaderLanguage::SHADER_MATERIAL_VERTEX) { - - if (vnode->name == vname_vertex && p_assign_left) { - vertex_code_writes_vertex = true; - } - if (vnode->name == vname_position && p_assign_left) { - vertex_code_writes_position = true; - } - if (vnode->name == vname_color_interp) { - flags->use_color_interp = true; - } - if (vnode->name == vname_uv_interp) { - flags->use_uv_interp = true; - } - if (vnode->name == vname_uv2_interp) { - flags->use_uv2_interp = true; - } - if (vnode->name == vname_var1_interp) { - flags->use_var1_interp = true; - } - if (vnode->name == vname_var2_interp) { - flags->use_var2_interp = true; - } - if (vnode->name == vname_tangent_interp || vnode->name == vname_binormal_interp) { - flags->use_tangent_interp = true; - } - } - - if (type == ShaderLanguage::SHADER_MATERIAL_FRAGMENT) { - - if (vnode->name == vname_discard) { - uses_discard = true; - } - if (vnode->name == vname_normalmap) { - uses_normalmap = true; - } - if (vnode->name == vname_screen_uv) { - uses_screen_uv = true; - } - if (vnode->name == vname_diffuse_alpha && p_assign_left) { - uses_alpha = true; - } - if (vnode->name == vname_color_interp) { - flags->use_color_interp = true; - } - if (vnode->name == vname_uv_interp) { - flags->use_uv_interp = true; - } - if (vnode->name == vname_uv2_interp) { - flags->use_uv2_interp = true; - } - if (vnode->name == vname_var1_interp) { - flags->use_var1_interp = true; - } - if (vnode->name == vname_var2_interp) { - flags->use_var2_interp = true; - } - if (vnode->name == vname_tangent_interp || vnode->name == vname_binormal_interp) { - flags->use_tangent_interp = true; - } - } - if (type == ShaderLanguage::SHADER_MATERIAL_LIGHT) { - - if (vnode->name == vname_light) { - uses_light = true; - } - - if (vnode->name == vname_shadow) { - uses_shadow_color = true; - } - } - if (type == ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX) { - - if (vnode->name == vname_var1_interp) { - flags->use_var1_interp = true; - } - if (vnode->name == vname_var2_interp) { - flags->use_var2_interp = true; - } - if (vnode->name == vname_world_vec) { - uses_worldvec = true; - } - } - - if (type == ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT) { - - if (vnode->name == vname_texpixel_size) { - uses_texpixel_size = true; - } - if (vnode->name == vname_normal) { - uses_normal = true; - } - if (vnode->name == vname_normalmap || vnode->name == vname_normalmap_depth) { - uses_normalmap = true; - uses_normal = true; - } - - if (vnode->name == vname_screen_uv) { - uses_screen_uv = true; - } - - if (vnode->name == vname_var1_interp) { - flags->use_var1_interp = true; - } - if (vnode->name == vname_var2_interp) { - flags->use_var2_interp = true; - } - } - - if (type == ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT) { - - if (vnode->name == vname_light) { - uses_light = true; - } - - if (vnode->name == vname_normal) { - uses_normal = true; - } - - if (vnode->name == vname_shadow) { - uses_shadow_color = true; - } - } - - if (vnode->name == vname_time) { - uses_time = true; - } - code = replace_string(vnode->name); - - } break; - case SL::Node::TYPE_CONSTANT: { - SL::ConstantNode *cnode = (SL::ConstantNode *)p_node; - switch (cnode->datatype) { - - case SL::TYPE_BOOL: code = cnode->value.operator bool() ? "true" : "false"; break; - case SL::TYPE_FLOAT: - code = _mknum(cnode->value); - break; //force zeros, so GLSL doesn't confuse with integer. - case SL::TYPE_VEC2: { - Vector2 v = cnode->value; - code = "vec2(" + _mknum(v.x) + ", " + _mknum(v.y) + ")"; - } break; - case SL::TYPE_VEC3: { - Vector3 v = cnode->value; - code = "vec3(" + _mknum(v.x) + ", " + _mknum(v.y) + ", " + _mknum(v.z) + ")"; - } break; - case SL::TYPE_VEC4: { - Plane v = cnode->value; - code = "vec4(" + _mknum(v.normal.x) + ", " + _mknum(v.normal.y) + ", " + _mknum(v.normal.z) + ", " + _mknum(v.d) + ")"; - } break; - case SL::TYPE_MAT2: { - Transform2D x = cnode->value; - code = "mat2( vec2(" + _mknum(x[0][0]) + ", " + _mknum(x[0][1]) + "), vec2(" + _mknum(x[1][0]) + ", " + _mknum(x[1][1]) + "))"; - } break; - case SL::TYPE_MAT3: { - Basis x = cnode->value; - code = "mat3( vec3(" + _mknum(x.get_axis(0).x) + ", " + _mknum(x.get_axis(0).y) + ", " + _mknum(x.get_axis(0).z) + "), vec3(" + _mknum(x.get_axis(1).x) + ", " + _mknum(x.get_axis(1).y) + ", " + _mknum(x.get_axis(1).z) + "), vec3(" + _mknum(x.get_axis(2).x) + ", " + _mknum(x.get_axis(2).y) + ", " + _mknum(x.get_axis(2).z) + "))"; - } break; - case SL::TYPE_MAT4: { - Transform x = cnode->value; - code = "mat4( vec4(" + _mknum(x.basis.get_axis(0).x) + ", " + _mknum(x.basis.get_axis(0).y) + ", " + _mknum(x.basis.get_axis(0).z) + ",0.0), vec4(" + _mknum(x.basis.get_axis(1).x) + ", " + _mknum(x.basis.get_axis(1).y) + ", " + _mknum(x.basis.get_axis(1).z) + ",0.0), vec4(" + _mknum(x.basis.get_axis(2).x) + ", " + _mknum(x.basis.get_axis(2).y) + ", " + _mknum(x.basis.get_axis(2).z) + ",0.0), vec4(" + _mknum(x.origin.x) + ", " + _mknum(x.origin.y) + ", " + _mknum(x.origin.z) + ",1.0))"; - } break; - default: code = "<error: " + Variant::get_type_name(cnode->value.get_type()) + " (" + itos(cnode->datatype) + ">"; - } - - } break; - case SL::Node::TYPE_OPERATOR: { - SL::OperatorNode *onode = (SL::OperatorNode *)p_node; - - switch (onode->op) { - - case SL::OP_ASSIGN_MUL: { - - if (onode->arguments[0]->get_datatype() == SL::TYPE_VEC3 && onode->arguments[1]->get_datatype() == SL::TYPE_MAT4) { - - String mul_l = dump_node_code(onode->arguments[0], p_level, true); - String mul_r = dump_node_code(onode->arguments[1], p_level); - code = mul_l + "=(vec4(" + mul_l + ",1.0)*(" + mul_r + ")).xyz"; - break; - } else if (onode->arguments[0]->get_datatype() == SL::TYPE_MAT4 && onode->arguments[1]->get_datatype() == SL::TYPE_VEC3) { - - String mul_l = dump_node_code(onode->arguments[0], p_level, true); - String mul_r = dump_node_code(onode->arguments[1], p_level); - code = mul_l + "=((" + mul_l + ")*vec4(" + mul_r + ",1.0)).xyz"; - break; - } else if (onode->arguments[0]->get_datatype() == SL::TYPE_VEC2 && onode->arguments[1]->get_datatype() == SL::TYPE_MAT4) { - - String mul_l = dump_node_code(onode->arguments[0], p_level, true); - String mul_r = dump_node_code(onode->arguments[1], p_level); - code = mul_l + "=(vec4(" + mul_l + ",0.0,1.0)*(" + mul_r + ")).xy"; - break; - } else if (onode->arguments[0]->get_datatype() == SL::TYPE_MAT4 && onode->arguments[1]->get_datatype() == SL::TYPE_VEC2) { - - String mul_l = dump_node_code(onode->arguments[0], p_level, true); - String mul_r = dump_node_code(onode->arguments[1], p_level); - code = mul_l + "=((" + mul_l + ")*vec4(" + mul_r + ",0.0,1.0)).xy"; - break; - } else if (onode->arguments[0]->get_datatype() == SL::TYPE_VEC2 && onode->arguments[1]->get_datatype() == SL::TYPE_MAT3) { - String mul_l = dump_node_code(onode->arguments[0], p_level, true); - String mul_r = dump_node_code(onode->arguments[1], p_level); - code = mul_l + "=((" + mul_l + ")*vec3(" + mul_r + ",1.0)).xy"; - break; - } - }; - case SL::OP_ASSIGN: - case SL::OP_ASSIGN_ADD: - case SL::OP_ASSIGN_SUB: - case SL::OP_ASSIGN_DIV: - code = "(" + dump_node_code(onode->arguments[0], p_level, true) + _opstr(onode->op) + dump_node_code(onode->arguments[1], p_level) + ")"; - break; - - case SL::OP_MUL: - - if (onode->arguments[0]->get_datatype() == SL::TYPE_MAT4 && onode->arguments[1]->get_datatype() == SL::TYPE_VEC3) { - - code = "(" + dump_node_code(onode->arguments[0], p_level) + "*vec4(" + dump_node_code(onode->arguments[1], p_level) + ",1.0)).xyz"; - break; - } else if (onode->arguments[0]->get_datatype() == SL::TYPE_VEC3 && onode->arguments[1]->get_datatype() == SL::TYPE_MAT4) { - - code = "(vec4(" + dump_node_code(onode->arguments[0], p_level) + ",1.0)*" + dump_node_code(onode->arguments[1], p_level) + ").xyz"; - break; - } else if (onode->arguments[0]->get_datatype() == SL::TYPE_MAT4 && onode->arguments[1]->get_datatype() == SL::TYPE_VEC2) { - - code = "(" + dump_node_code(onode->arguments[0], p_level) + "*vec4(" + dump_node_code(onode->arguments[1], p_level) + ",0.0,1.0)).xy"; - break; - } else if (onode->arguments[0]->get_datatype() == SL::TYPE_VEC2 && onode->arguments[1]->get_datatype() == SL::TYPE_MAT4) { - - code = "(vec4(" + dump_node_code(onode->arguments[0], p_level) + ",0.0,1.0)*" + dump_node_code(onode->arguments[1], p_level) + ").xy"; - break; - } else if (onode->arguments[0]->get_datatype() == SL::TYPE_MAT3 && onode->arguments[1]->get_datatype() == SL::TYPE_VEC2) { - - code = "(" + dump_node_code(onode->arguments[0], p_level) + "*vec3(" + dump_node_code(onode->arguments[1], p_level) + ",1.0)).xy"; - break; - } else if (onode->arguments[0]->get_datatype() == SL::TYPE_VEC2 && onode->arguments[1]->get_datatype() == SL::TYPE_MAT3) { - - code = "(vec3(" + dump_node_code(onode->arguments[0], p_level) + ",1.0)*" + dump_node_code(onode->arguments[1], p_level) + ").xy"; - break; - } - - case SL::OP_ADD: - case SL::OP_SUB: - case SL::OP_DIV: - case SL::OP_CMP_EQ: - case SL::OP_CMP_NEQ: - case SL::OP_CMP_LEQ: - case SL::OP_CMP_GEQ: - case SL::OP_CMP_LESS: - case SL::OP_CMP_GREATER: - case SL::OP_CMP_OR: - case SL::OP_CMP_AND: - //handle binary - code = "(" + dump_node_code(onode->arguments[0], p_level) + _opstr(onode->op) + dump_node_code(onode->arguments[1], p_level) + ")"; - break; - case SL::OP_NEG: - case SL::OP_NOT: - //handle unary - code = _opstr(onode->op) + dump_node_code(onode->arguments[0], p_level); - break; - case SL::OP_CONSTRUCT: - case SL::OP_CALL: { - String callfunc = dump_node_code(onode->arguments[0], p_level); - - code = callfunc + "("; - /*if (callfunc=="mat4") { - //fix constructor for mat4 - for(int i=1;i<onode->arguments.size();i++) { - if (i>1) - code+=", "; - //transform - code+="vec4( "+dump_node_code(onode->arguments[i],p_level)+(i==4?",1.0)":",0.0)"); - - } - } else*/ if (callfunc == "tex") { - - code = "texture2D( " + dump_node_code(onode->arguments[1], p_level) + "," + dump_node_code(onode->arguments[2], p_level) + ")"; - break; - } else if (callfunc == "texcube") { - - code = "(textureCube( " + dump_node_code(onode->arguments[1], p_level) + ",(" + dump_node_code(onode->arguments[2], p_level) + ")).xyz"; - break; - } else if (callfunc == "texscreen") { - //create the call to sample the screen, and clamp it - uses_texscreen = true; - code = "(texture2D( texscreen_tex, clamp((" + dump_node_code(onode->arguments[1], p_level) + ").xy*texscreen_screen_mult,texscreen_screen_clamp.xy,texscreen_screen_clamp.zw))).rgb"; - //code="(texture2D( screen_texture, ("+dump_node_code(onode->arguments[1],p_level)+").xy).rgb"; - break; - } else if (callfunc == "texpos") { - //create the call to sample the screen, and clamp it - uses_texpos = true; - code = "get_texpos(" + dump_node_code(onode->arguments[1], p_level) + ""; - //code="get_texpos(gl_ProjectionMatrixInverse * texture2D( depth_texture, clamp(("+dump_node_code(onode->arguments[1],p_level)+").xy,vec2(0.0),vec2(1.0))*gl_LightSource[5].specular.zw+gl_LightSource[5].specular.xy)"; - //code="(texture2D( screen_texture, ("+dump_node_code(onode->arguments[1],p_level)+").xy).rgb"; - break; - } else if (custom_h && callfunc == "cosh_custom") { - - if (!cosh_used) { - global_code = - "float cosh_custom(float val)\n" - "{\n" - " float tmp = exp(val);\n" - " float cosH = (tmp + 1.0 / tmp) / 2.0;\n" - " return cosH;\n" - "}\n" + - global_code; - cosh_used = true; - } - code = "cosh_custom(" + dump_node_code(onode->arguments[1], p_level) + ""; - } else if (custom_h && callfunc == "sinh_custom") { - - if (!sinh_used) { - global_code = - "float sinh_custom(float val)\n" - "{\n" - " float tmp = exp(val);\n" - " float sinH = (tmp - 1.0 / tmp) / 2.0;\n" - " return sinH;\n" - "}\n" + - global_code; - sinh_used = true; - } - code = "sinh_custom(" + dump_node_code(onode->arguments[1], p_level) + ""; - } else if (custom_h && callfunc == "tanh_custom") { - - if (!tanh_used) { - global_code = - "float tanh_custom(float val)\n" - "{\n" - " float tmp = exp(val);\n" - " float tanH = (tmp - 1.0 / tmp) / (tmp + 1.0 / tmp);\n" - " return tanH;\n" - "}\n" + - global_code; - tanh_used = true; - } - code = "tanh_custom(" + dump_node_code(onode->arguments[1], p_level) + ""; - - } else { - - for (int i = 1; i < onode->arguments.size(); i++) { - if (i > 1) - code += ", "; - //transform - code += dump_node_code(onode->arguments[i], p_level); - } - } - code += ")"; - break; - } break; - default: {} - } - - } break; - case SL::Node::TYPE_CONTROL_FLOW: { - SL::ControlFlowNode *cfnode = (SL::ControlFlowNode *)p_node; - if (cfnode->flow_op == SL::FLOW_OP_IF) { - - code += "if (" + dump_node_code(cfnode->statements[0], p_level) + ") {" ENDL; - code += dump_node_code(cfnode->statements[1], p_level + 1); - if (cfnode->statements.size() == 3) { - - code += "} else {" ENDL; - code += dump_node_code(cfnode->statements[2], p_level + 1); - } - - code += "}" ENDL; - - } else if (cfnode->flow_op == SL::FLOW_OP_RETURN) { - - if (cfnode->statements.size()) { - code = "return " + dump_node_code(cfnode->statements[0], p_level); - } else { - code = "return"; - } - } - - } break; - case SL::Node::TYPE_MEMBER: { - SL::MemberNode *mnode = (SL::MemberNode *)p_node; - String m; - if (mnode->basetype == SL::TYPE_MAT4) { - if (mnode->name == "x") - m = "[0]"; - else if (mnode->name == "y") - m = "[1]"; - else if (mnode->name == "z") - m = "[2]"; - else if (mnode->name == "w") - m = "[3]"; - } else if (mnode->basetype == SL::TYPE_MAT2) { - if (mnode->name == "x") - m = "[0]"; - else if (mnode->name == "y") - m = "[1]"; - - } else if (mnode->basetype == SL::TYPE_MAT3) { - if (mnode->name == "x") - m = "[0]"; - else if (mnode->name == "y") - m = "[1]"; - else if (mnode->name == "z") - m = "[2]"; - - } else { - m = "." + mnode->name; - } - code = dump_node_code(mnode->owner, p_level) + m; - - } break; - } - - return code; -} - -Error ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) { - - // feed the local replace table and global code - global_code = ""; - - // uniforms first! - - int ubase = 0; - if (uniforms) - ubase = uniforms->size(); - for (Map<StringName, SL::Uniform>::Element *E = p_program->uniforms.front(); E; E = E->next()) { - - String uline = "uniform " + _typestr(E->get().type) + " _" + E->key().operator String() + ";" ENDL; - - global_code += uline; - if (uniforms) { - /* - if (uniforms->has(E->key())) { - //repeated uniform, error - ERR_EXPLAIN("Uniform already exists from other shader: "+String(E->key())); - ERR_FAIL_COND_V(uniforms->has(E->key()),ERR_ALREADY_EXISTS); - } - */ - SL::Uniform u = E->get(); - u.order += ubase; - uniforms->insert(E->key(), u); - } - } - - for (int i = 0; i < p_program->functions.size(); i++) { - - SL::FunctionNode *fnode = p_program->functions[i].function; - - StringName funcname = fnode->name; - String newfuncname = replace_string(funcname); - - String header; - header = _typestr(fnode->return_type) + " " + newfuncname + "("; - for (int i = 0; i < fnode->arguments.size(); i++) { - - if (i > 0) - header += ", "; - header += _typestr(fnode->arguments[i].type) + " " + replace_string(fnode->arguments[i].name); - } - - header += ") {" ENDL; - String fcode = header; - fcode += dump_node_code(fnode->body, 1); - fcode += "}" ENDL; - global_code += fcode; - } - - /* for(Map<StringName,SL::DataType>::Element *E=p_program->preexisting_variables.front();E;E=E->next()) { - - StringName varname=E->key(); - String newvarname=replace_string(varname); - global_code+="uniform "+_typestr(E->get())+" "+newvarname+";" ENDL; - }*/ - - code = dump_node_code(p_program, 0); - -#ifdef DEBUG_SHADER_ENABLED - - print_line("GLOBAL CODE:\n\n"); - print_line(global_code); - global_code = global_code.replace("\n", ""); - print_line("CODE:\n\n"); - print_line(code); - code = code.replace("\n", ""); -#endif - - return OK; -} - -Error ShaderCompilerGLES2::create_glsl_120_code(void *p_str, SL::ProgramNode *p_program) { - - ShaderCompilerGLES2 *compiler = (ShaderCompilerGLES2 *)p_str; - return compiler->compile_node(p_program); -} - -String ShaderCompilerGLES2::replace_string(const StringName &p_string) { - - Map<StringName, StringName>::Element *E = NULL; - E = replace_table.find(p_string); - if (E) - return E->get(); - - E = mode_replace_table[type].find(p_string); - if (E) - return E->get(); - - return "_" + p_string.operator String(); -} - -Error ShaderCompilerGLES2::compile(const String &p_code, ShaderLanguage::ShaderType p_type, String &r_code_line, String &r_globals_line, Flags &r_flags, Map<StringName, ShaderLanguage::Uniform> *r_uniforms) { - - uses_texscreen = false; - uses_texpos = false; - uses_alpha = false; - uses_discard = false; - uses_screen_uv = false; - uses_light = false; - uses_time = false; - uses_normalmap = false; - uses_normal = false; - uses_texpixel_size = false; - uses_worldvec = false; - vertex_code_writes_vertex = false; - vertex_code_writes_position = false; - uses_shadow_color = false; - uniforms = r_uniforms; - flags = &r_flags; - r_flags.use_color_interp = false; - r_flags.use_uv_interp = false; - r_flags.use_uv2_interp = false; - r_flags.use_tangent_interp = false; - r_flags.use_var1_interp = false; - r_flags.use_var2_interp = false; - r_flags.uses_normalmap = false; - r_flags.uses_normal = false; - sinh_used = false; - tanh_used = false; - cosh_used = false; - - String error; - int errline, errcol; - - type = p_type; - Error err = SL::compile(p_code, p_type, create_glsl_120_code, this, &error, &errline, &errcol); - - if (err) { - print_line("***Error precompiling shader: " + error); - print_line("error " + itos(errline) + ":" + itos(errcol)); - return err; - } - - r_flags.uses_alpha = uses_alpha; - r_flags.uses_texscreen = uses_texscreen; - r_flags.uses_texpos = uses_texpos; - r_flags.vertex_code_writes_vertex = vertex_code_writes_vertex; - r_flags.vertex_code_writes_position = vertex_code_writes_position; - r_flags.uses_discard = uses_discard; - r_flags.uses_screen_uv = uses_screen_uv; - r_flags.uses_light = uses_light; - r_flags.uses_time = uses_time; - r_flags.uses_normalmap = uses_normalmap; - r_flags.uses_normal = uses_normal; - r_flags.uses_texpixel_size = uses_texpixel_size; - r_flags.uses_worldvec = uses_worldvec; - r_flags.uses_shadow_color = uses_shadow_color; - r_code_line = code; - r_globals_line = global_code; - return OK; -} - -ShaderCompilerGLES2::ShaderCompilerGLES2() { - -#ifdef GLEW_ENABLED - //use custom functions because they are not supported in GLSL120 - custom_h = true; -#else - custom_h = false; -#endif - - replace_table["bool"] = "bool"; - replace_table["float"] = "float"; - replace_table["vec2"] = "vec2"; - replace_table["vec3"] = "vec3"; - replace_table["vec4"] = "vec4"; - replace_table["mat2"] = "mat2"; - replace_table["mat3"] = "mat3"; - replace_table["mat4"] = "mat4"; - replace_table["texture"] = "sampler2D"; - replace_table["cubemap"] = "samplerCube"; - - replace_table["sin"] = "sin"; - replace_table["cos"] = "cos"; - replace_table["tan"] = "tan"; - replace_table["asin"] = "asin"; - replace_table["acos"] = "acos"; - replace_table["atan"] = "atan"; - replace_table["atan2"] = "atan"; - - if (custom_h) { - replace_table["sinh"] = "sinh_custom"; - replace_table["cosh"] = "cosh_custom"; - replace_table["tanh"] = "tanh_custom"; - } else { - replace_table["sinh"] = "sinh"; - replace_table["cosh"] = "cosh"; - replace_table["tanh"] = "tanh"; - } - - replace_table["pow"] = "pow"; - replace_table["exp"] = "exp"; - replace_table["log"] = "log"; - replace_table["sqrt"] = "sqrt"; - replace_table["abs"] = "abs"; - replace_table["sign"] = "sign"; - replace_table["floor"] = "floor"; - replace_table["trunc"] = "trunc"; -#ifdef GLEW_ENABLED - replace_table["round"] = "roundfix"; -#else - replace_table["round"] = "round"; -#endif - replace_table["ceil"] = "ceil"; - replace_table["fract"] = "fract"; - replace_table["mod"] = "mod"; - replace_table["min"] = "min"; - replace_table["max"] = "max"; - replace_table["clamp"] = "clamp"; - replace_table["mix"] = "mix"; - replace_table["step"] = "step"; - replace_table["smoothstep"] = "smoothstep"; - replace_table["length"] = "length"; - replace_table["distance"] = "distance"; - replace_table["dot"] = "dot"; - replace_table["cross"] = "cross"; - replace_table["normalize"] = "normalize"; - replace_table["reflect"] = "reflect"; - replace_table["refract"] = "refract"; - replace_table["tex"] = "tex"; - replace_table["texa"] = "texa"; - replace_table["tex2"] = "tex2"; - replace_table["texcube"] = "textureCube"; - replace_table["texscreen"] = "texscreen"; - replace_table["texpos"] = "texpos"; - - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_VERTEX"] = "vertex_in.xyz"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_NORMAL"] = "normal_in"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_TANGENT"] = "tangent_in"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_BINORMALF"] = "binormalf"; - - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["POSITION"] = "gl_Position"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VERTEX"] = "vertex_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["NORMAL"] = "normal_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TANGENT"] = "tangent_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["BINORMAL"] = "binormal_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["UV"] = "uv_interp.xy"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["UV2"] = "uv_interp.zw"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["COLOR"] = "color_interp"; - //@TODO convert to glsl stuff - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SPEC_EXP"] = "vertex_specular_exp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["WORLD_MATRIX"] = "world_transform"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INV_CAMERA_MATRIX"] = "camera_inverse_transform"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["PROJECTION_MATRIX"] = "projection_transform"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["MODELVIEW_MATRIX"] = "modelview"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["POINT_SIZE"] = "gl_PointSize"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR1"] = "var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR2"] = "var2_interp"; - - //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_POS"]="SCREEN_POS"; - //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_SIZE"]="SCREEN_SIZE"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INSTANCE_ID"] = "instance_id"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TIME"] = "time"; - - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VERTEX"] = "vertex"; - //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POSITION"]="IN_POSITION"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMAL"] = "normal"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["TANGENT"] = "tangent"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POSITION"] = "gl_Position"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["BINORMAL"] = "binormal"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMALMAP"] = "normalmap"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMALMAP_DEPTH"] = "normaldepth"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR1"] = "var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR2"] = "var2_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["UV"] = "uv"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["UV2"] = "uv2"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_UV"] = "screen_uv"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR1"] = "var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR2"] = "var2_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["COLOR"] = "color"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DIFFUSE"] = "diffuse.rgb"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DIFFUSE_ALPHA"] = "diffuse"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SPECULAR"] = "specular"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["EMISSION"] = "emission"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SHADE_PARAM"] = "shade_param"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SPEC_EXP"] = "specular_exp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["GLOW"] = "glow"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DISCARD"] = "discard_"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POINT_COORD"] = "gl_PointCoord"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["INV_CAMERA_MATRIX"] = "camera_inverse_transform"; - - //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_POS"]="SCREEN_POS"; - //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["TIME"] = "time"; - - ////////////// - - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["NORMAL"] = "normal"; - //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["POSITION"]="IN_POSITION"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_DIR"] = "light_dir"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_DIFFUSE"] = "light_diffuse"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_SPECULAR"] = "light_specular"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["EYE_VEC"] = "eye_vec"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["DIFFUSE"] = "mdiffuse"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SPECULAR"] = "specular"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SPECULAR_EXP"] = "specular_exp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SHADE_PARAM"] = "shade_param"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT"] = "light"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["POINT_COORD"] = "gl_PointCoord"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["TIME"] = "time"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SHADOW"] = "shadow_color"; - - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["SRC_VERTEX"] = "src_vtx"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VERTEX"] = "outvec.xy"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["WORLD_VERTEX"] = "outvec.xy"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["UV"] = "uv_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["COLOR"] = "color_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VAR1"] = "var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VAR2"] = "var2_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["POINT_SIZE"] = "gl_PointSize"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["WORLD_MATRIX"] = "modelview_matrix"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["PROJECTION_MATRIX"] = "projection_matrix"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["EXTRA_MATRIX"] = "extra_matrix"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["TIME"] = "time"; - - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["POSITION"] = "gl_Position"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMAL"] = "normal"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMALMAP"] = "normal_map"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMALMAP_DEPTH"] = "normal_depth"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["UV"] = "uv_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["SRC_COLOR"] = "color_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["COLOR"] = "color"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TEXTURE"] = "texture"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TEXTURE_PIXEL_SIZE"] = "texpixel_size"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["VAR1"] = "var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["VAR2"] = "var2_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["SCREEN_UV"] = "screen_uv"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["POINT_COORD"] = "gl_PointCoord"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TIME"] = "time"; - - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["POSITION"] = "gl_Position"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["NORMAL"] = "normal"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["UV"] = "uv_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["COLOR"] = "color"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TEXTURE"] = "texture"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TEXTURE_PIXEL_SIZE"] = "texpixel_size"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["VAR1"] = "var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["VAR2"] = "var2_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_VEC"] = "light_vec"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_HEIGHT"] = "light_height"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_COLOR"] = "light"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_SHADOW"] = "light_shadow_color"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_UV"] = "light_uv"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT"] = "light_out"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SHADOW"] = "shadow_color"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SCREEN_UV"] = "screen_uv"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["POINT_COORD"] = "gl_PointCoord"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TIME"] = "time"; - - //mode_replace_table[2]["SCREEN_POS"]="SCREEN_POS"; - //mode_replace_table[2]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE"; - - out_vertex_name = "VERTEX"; - - vname_discard = "DISCARD"; - vname_screen_uv = "SCREEN_UV"; - vname_diffuse_alpha = "DIFFUSE_ALPHA"; - vname_color_interp = "COLOR"; - vname_uv_interp = "UV"; - vname_uv2_interp = "UV2"; - vname_tangent_interp = "TANGENT"; - vname_binormal_interp = "BINORMAL"; - vname_var1_interp = "VAR1"; - vname_var2_interp = "VAR2"; - vname_vertex = "VERTEX"; - vname_position = "POSITION"; - vname_light = "LIGHT"; - vname_time = "TIME"; - vname_normalmap = "NORMALMAP"; - vname_normalmap_depth = "NORMALMAP_DEPTH"; - vname_normal = "NORMAL"; - vname_texpixel_size = "TEXTURE_PIXEL_SIZE"; - vname_world_vec = "WORLD_VERTEX"; - vname_shadow = "SHADOW"; -} diff --git a/drivers/gles2/shader_compiler_gles2.h b/drivers/gles2/shader_compiler_gles2.h deleted file mode 100644 index 02f9e58978..0000000000 --- a/drivers/gles2/shader_compiler_gles2.h +++ /dev/null @@ -1,134 +0,0 @@ -/*************************************************************************/ -/* shader_compiler_gles2.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 SHADER_COMPILER_GLES2_H -#define SHADER_COMPILER_GLES2_H - -#include "servers/visual/shader_language.h" -class ShaderCompilerGLES2 { - - class Uniform; - -public: - struct Flags; - -private: - ShaderLanguage::ProgramNode *program_node; - String dump_node_code(ShaderLanguage::Node *p_node, int p_level, bool p_assign_left = false); - Error compile_node(ShaderLanguage::ProgramNode *p_program); - static Error create_glsl_120_code(void *p_str, ShaderLanguage::ProgramNode *p_program); - - bool uses_light; - bool uses_texscreen; - bool uses_texpos; - bool uses_alpha; - bool uses_discard; - bool uses_time; - bool uses_screen_uv; - bool uses_normalmap; - bool uses_normal; - bool uses_texpixel_size; - bool uses_worldvec; - bool vertex_code_writes_vertex; - bool vertex_code_writes_position; - bool uses_shadow_color; - - bool sinh_used; - bool tanh_used; - bool cosh_used; - - bool custom_h; - - Flags *flags; - - StringName vname_discard; - StringName vname_screen_uv; - StringName vname_diffuse_alpha; - StringName vname_color_interp; - StringName vname_uv_interp; - StringName vname_uv2_interp; - StringName vname_tangent_interp; - StringName vname_binormal_interp; - StringName vname_var1_interp; - StringName vname_var2_interp; - StringName vname_vertex; - StringName vname_position; - StringName vname_light; - StringName vname_time; - StringName vname_normalmap; - StringName vname_normalmap_depth; - StringName vname_normal; - StringName vname_texpixel_size; - StringName vname_world_vec; - StringName vname_shadow; - - Map<StringName, ShaderLanguage::Uniform> *uniforms; - - StringName out_vertex_name; - - String global_code; - String code; - ShaderLanguage::ShaderType type; - - String replace_string(const StringName &p_string); - - Map<StringName, StringName> mode_replace_table[9]; - Map<StringName, StringName> replace_table; - -public: - struct Flags { - - bool uses_alpha; - bool uses_texscreen; - bool uses_texpos; - bool uses_normalmap; - bool vertex_code_writes_vertex; - bool vertex_code_writes_position; - bool uses_discard; - bool uses_screen_uv; - bool use_color_interp; - bool use_uv_interp; - bool use_uv2_interp; - bool use_tangent_interp; - bool use_var1_interp; - bool use_var2_interp; - bool uses_light; - bool uses_time; - bool uses_normal; - bool uses_texpixel_size; - bool uses_worldvec; - bool uses_shadow_color; - }; - - Error compile(const String &p_code, ShaderLanguage::ShaderType p_type, String &r_code_line, String &r_globals_line, Flags &r_flags, Map<StringName, ShaderLanguage::Uniform> *r_uniforms = NULL); - - ShaderCompilerGLES2(); -}; - -#endif // SHADER_COMPILERL_GL_H diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp deleted file mode 100644 index 8764ae3895..0000000000 --- a/drivers/gles2/shader_gles2.cpp +++ /dev/null @@ -1,736 +0,0 @@ -/*************************************************************************/ -/* shader_gles2.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "shader_gles2.h" - -#ifdef GLES2_ENABLED -#include "print_string.h" - -//#define DEBUG_OPENGL - -#ifdef DEBUG_OPENGL - -#define DEBUG_TEST_ERROR(m_section) \ - { \ - uint32_t err = glGetError(); \ - if (err) { \ - print_line("OpenGL Error #" + itos(err) + " at: " + m_section); \ - } \ - } -#else - -#define DEBUG_TEST_ERROR(m_section) - -#endif - -ShaderGLES2 *ShaderGLES2::active = NULL; - -//#define DEBUG_SHADER - -#ifdef DEBUG_SHADER - -#define DEBUG_PRINT(m_text) print_line(m_text); - -#else - -#define DEBUG_PRINT(m_text) - -#endif - -void ShaderGLES2::bind_uniforms() { - - if (!uniforms_dirty) { - return; - }; - - // upload default uniforms - const Map<uint32_t, Variant>::Element *E = uniform_defaults.front(); - - while (E) { - int idx = E->key(); - int location = version->uniform_location[idx]; - - if (location < 0) { - E = E->next(); - continue; - } - - const Variant &v = E->value(); - _set_uniform_variant(location, v); - //print_line("uniform "+itos(location)+" value "+v+ " type "+Variant::get_type_name(v.get_type())); - E = E->next(); - }; - - const Map<uint32_t, CameraMatrix>::Element *C = uniform_cameras.front(); - while (C) { - - int location = version->uniform_location[C->key()]; - if (location < 0) { - C = C->next(); - continue; - } - - glUniformMatrix4fv(location, 1, false, &(C->get().matrix[0][0])); - C = C->next(); - }; - - uniforms_dirty = false; -}; - -GLint ShaderGLES2::get_uniform_location(int p_index) const { - - ERR_FAIL_COND_V(!version, -1); - - return version->uniform_location[p_index]; -}; - -bool ShaderGLES2::bind() { - - if (active != this || !version || new_conditional_version.key != conditional_version.key) { - conditional_version = new_conditional_version; - version = get_current_version(); - } else { - - return false; - } - - ERR_FAIL_COND_V(!version, false); - - glUseProgram(version->id); - - DEBUG_TEST_ERROR("Use Program"); - - active = this; - uniforms_dirty = true; - /* - * why on earth is this code here? - for (int i=0;i<texunit_pair_count;i++) { - - glUniform1i(texunit_pairs[i].location, texunit_pairs[i].index); - DEBUG_TEST_ERROR("Uniform 1 i"); - } - -*/ - return true; -} - -void ShaderGLES2::unbind() { - - version = NULL; - glUseProgram(0); - uniforms_dirty = true; - active = NULL; -} - -static String _fix_error_code_line(const String &p_error, int p_code_start, int p_offset) { - - int last_find_pos = -1; - // NVIDIA - String error = p_error; - while ((last_find_pos = p_error.find("(", last_find_pos + 1)) != -1) { - - int end_pos = last_find_pos + 1; - - while (true) { - - if (p_error[end_pos] >= '0' && p_error[end_pos] <= '9') { - - end_pos++; - continue; - } else if (p_error[end_pos] == ')') { - break; - } else { - - end_pos = -1; - break; - } - } - - if (end_pos == -1) - continue; - - String numstr = error.substr(last_find_pos + 1, (end_pos - last_find_pos) - 1); - String begin = error.substr(0, last_find_pos + 1); - String end = error.substr(end_pos, error.length()); - int num = numstr.to_int() + p_code_start - p_offset; - error = begin + itos(num) + end; - } - - // ATI - last_find_pos = -1; - while ((last_find_pos = p_error.find("ERROR: ", last_find_pos + 1)) != -1) { - - last_find_pos += 6; - int end_pos = last_find_pos + 1; - - while (true) { - - if (p_error[end_pos] >= '0' && p_error[end_pos] <= '9') { - - end_pos++; - continue; - } else if (p_error[end_pos] == ':') { - break; - } else { - - end_pos = -1; - break; - } - } - continue; - if (end_pos == -1) - continue; - - String numstr = error.substr(last_find_pos + 1, (end_pos - last_find_pos) - 1); - print_line("numstr: " + numstr); - String begin = error.substr(0, last_find_pos + 1); - String end = error.substr(end_pos, error.length()); - int num = numstr.to_int() + p_code_start - p_offset; - error = begin + itos(num) + end; - } - return error; -} - -ShaderGLES2::Version *ShaderGLES2::get_current_version() { - - Version *_v = version_map.getptr(conditional_version); - - if (_v) { - - if (conditional_version.code_version != 0) { - CustomCode *cc = custom_code_map.getptr(conditional_version.code_version); - ERR_FAIL_COND_V(!cc, _v); - if (cc->version == _v->code_version) - return _v; - } else { - return _v; - } - } - - if (!_v) - version_map[conditional_version] = Version(); - - Version &v = version_map[conditional_version]; - - if (!_v) { - - v.uniform_location = memnew_arr(GLint, uniform_count); - - } else { - if (v.ok) { - //bye bye shaders - glDeleteShader(v.vert_id); - glDeleteShader(v.frag_id); - glDeleteProgram(v.id); - v.id = 0; - } - } - - v.ok = false; - /* SETUP CONDITIONALS */ - - Vector<const char *> strings; -#ifdef GLEW_ENABLED - strings.push_back("#version 120\n"); //ATI requieres this before anything -#endif - int define_line_ofs = 1; - - for (int j = 0; j < conditional_count; j++) { - - bool enable = ((1 << j) & conditional_version.version); - strings.push_back(enable ? conditional_defines[j] : ""); - if (enable) - define_line_ofs++; - - if (enable) { - DEBUG_PRINT(conditional_defines[j]); - } - } - - //keep them around during the function - CharString code_string; - CharString code_string2; - CharString code_globals; - - //print_line("code version? "+itos(conditional_version.code_version)); - - CustomCode *cc = NULL; - - if (conditional_version.code_version > 0) { - //do custom code related stuff - - ERR_FAIL_COND_V(!custom_code_map.has(conditional_version.code_version), NULL); - cc = &custom_code_map[conditional_version.code_version]; - v.code_version = cc->version; - define_line_ofs += 2; - } - - /* CREATE PROGRAM */ - - v.id = glCreateProgram(); - - ERR_FAIL_COND_V(v.id == 0, NULL); - - /* VERTEX SHADER */ - - if (cc) { - for (int i = 0; i < cc->custom_defines.size(); i++) { - - strings.push_back(cc->custom_defines[i]); - DEBUG_PRINT("CD #" + itos(i) + ": " + String(cc->custom_defines[i])); - } - } - - int strings_base_size = strings.size(); -#if 0 - if (cc) { - - String _code_string = "#define VERTEX_SHADER_CODE "+cc->vertex+"\n"; - String _code_globals = "#define VERTEX_SHADER_GLOBALS "+cc->vertex_globals+"\n"; - - code_string=_code_string.ascii(); - code_globals=_code_globals.ascii(); - DEBUG_PRINT( code_globals.get_data() ); - DEBUG_PRINT( code_string.get_data() ); - strings.push_back(code_globals); - strings.push_back(code_string); - } -#endif - - strings.push_back(vertex_code0.get_data()); - if (cc) { - code_globals = cc->vertex_globals.ascii(); - strings.push_back(code_globals.get_data()); - } - strings.push_back(vertex_code1.get_data()); - - if (cc) { - code_string = cc->vertex.ascii(); - strings.push_back(code_string.get_data()); - } - - strings.push_back(vertex_code2.get_data()); -#ifdef DEBUG_SHADER - - DEBUG_PRINT("\nVertex Code:\n\n" + String(code_string.get_data())); - for (int i = 0; i < strings.size(); i++) { - - //print_line("vert strings "+itos(i)+":"+String(strings[i])); - } -#endif - - v.vert_id = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(v.vert_id, strings.size(), &strings[0], NULL); - glCompileShader(v.vert_id); - - GLint status; - - glGetShaderiv(v.vert_id, GL_COMPILE_STATUS, &status); - if (status == GL_FALSE) { - // error compiling - GLsizei iloglen; - glGetShaderiv(v.vert_id, GL_INFO_LOG_LENGTH, &iloglen); - - if (iloglen < 0) { - - glDeleteShader(v.vert_id); - glDeleteProgram(v.id); - v.id = 0; - - ERR_PRINT("NO LOG, WTF"); - } else { - - if (iloglen == 0) { - - iloglen = 4096; //buggy driver (Adreno 220+....) - } - - char *ilogmem = (char *)Memory::alloc_static(iloglen + 1); - ilogmem[iloglen] = 0; - glGetShaderInfoLog(v.vert_id, iloglen, &iloglen, ilogmem); - - String err_string = get_shader_name() + ": Vertex Program Compilation Failed:\n"; - - err_string += ilogmem; - err_string = _fix_error_code_line(err_string, vertex_code_start, define_line_ofs); - ERR_PRINT(err_string.ascii().get_data()); - Memory::free_static(ilogmem); - glDeleteShader(v.vert_id); - glDeleteProgram(v.id); - v.id = 0; - } - - ERR_FAIL_V(NULL); - } - - /* FRAGMENT SHADER */ - - strings.resize(strings_base_size); -#if 0 - if (cc) { - - String _code_string = "#define FRAGMENT_SHADER_CODE "+cc->fragment+"\n"; - String _code_globals = "#define FRAGMENT_SHADER_GLOBALS "+cc->fragment_globals+"\n"; - - code_string=_code_string.ascii(); - code_globals=_code_globals.ascii(); - DEBUG_PRINT( code_globals.get_data() ); - DEBUG_PRINT( code_string.get_data() ); - strings.push_back(code_globals); - strings.push_back(code_string); - } -#endif - - strings.push_back(fragment_code0.get_data()); - if (cc) { - code_globals = cc->fragment_globals.ascii(); - strings.push_back(code_globals.get_data()); - } - strings.push_back(fragment_code1.get_data()); - - if (cc) { - code_string = cc->fragment.ascii(); - strings.push_back(code_string.get_data()); - } - - strings.push_back(fragment_code2.get_data()); - - if (cc) { - code_string2 = cc->light.ascii(); - strings.push_back(code_string2.get_data()); - } - - strings.push_back(fragment_code3.get_data()); - -#ifdef DEBUG_SHADER - DEBUG_PRINT("\nFragment Code:\n\n" + String(code_string.get_data())); - for (int i = 0; i < strings.size(); i++) { - - //print_line("frag strings "+itos(i)+":"+String(strings[i])); - } -#endif - - v.frag_id = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(v.frag_id, strings.size(), &strings[0], NULL); - glCompileShader(v.frag_id); - - glGetShaderiv(v.frag_id, GL_COMPILE_STATUS, &status); - if (status == GL_FALSE) { - // error compiling - GLsizei iloglen; - glGetShaderiv(v.frag_id, GL_INFO_LOG_LENGTH, &iloglen); - - if (iloglen < 0) { - - glDeleteShader(v.frag_id); - glDeleteShader(v.vert_id); - glDeleteProgram(v.id); - v.id = 0; - ERR_PRINT("NO LOG, WTF"); - } else { - - if (iloglen == 0) { - - iloglen = 4096; //buggy driver (Adreno 220+....) - } - - char *ilogmem = (char *)Memory::alloc_static(iloglen + 1); - ilogmem[iloglen] = 0; - glGetShaderInfoLog(v.frag_id, iloglen, &iloglen, ilogmem); - - String err_string = get_shader_name() + ": Fragment Program Compilation Failed:\n"; - - err_string += ilogmem; - err_string = _fix_error_code_line(err_string, fragment_code_start, define_line_ofs); - ERR_PRINT(err_string.ascii().get_data()); - Memory::free_static(ilogmem); - glDeleteShader(v.frag_id); - glDeleteShader(v.vert_id); - glDeleteProgram(v.id); - v.id = 0; - } - - ERR_FAIL_V(NULL); - } - - glAttachShader(v.id, v.frag_id); - glAttachShader(v.id, v.vert_id); - - // bind attributes before linking - for (int i = 0; i < attribute_pair_count; i++) { - - glBindAttribLocation(v.id, attribute_pairs[i].index, attribute_pairs[i].name); - } - - glLinkProgram(v.id); - - glGetProgramiv(v.id, GL_LINK_STATUS, &status); - - if (status == GL_FALSE) { - // error linking - GLsizei iloglen; - glGetProgramiv(v.id, GL_INFO_LOG_LENGTH, &iloglen); - - if (iloglen < 0) { - - glDeleteShader(v.frag_id); - glDeleteShader(v.vert_id); - glDeleteProgram(v.id); - v.id = 0; - ERR_FAIL_COND_V(iloglen <= 0, NULL); - } - - if (iloglen == 0) { - - iloglen = 4096; //buggy driver (Adreno 220+....) - } - - char *ilogmem = (char *)Memory::alloc_static(iloglen + 1); - ilogmem[iloglen] = 0; - glGetProgramInfoLog(v.id, iloglen, &iloglen, ilogmem); - - String err_string = get_shader_name() + ": Program LINK FAILED:\n"; - - err_string += ilogmem; - err_string = _fix_error_code_line(err_string, fragment_code_start, define_line_ofs); - ERR_PRINT(err_string.ascii().get_data()); - Memory::free_static(ilogmem); - glDeleteShader(v.frag_id); - glDeleteShader(v.vert_id); - glDeleteProgram(v.id); - v.id = 0; - - ERR_FAIL_V(NULL); - } - - /* UNIFORMS */ - - glUseProgram(v.id); - - //print_line("uniforms: "); - for (int j = 0; j < uniform_count; j++) { - - v.uniform_location[j] = glGetUniformLocation(v.id, uniform_names[j]); - //print_line("uniform "+String(uniform_names[j])+" location "+itos(v.uniform_location[j])); - } - - // set texture uniforms - for (int i = 0; i < texunit_pair_count; i++) { - - GLint loc = glGetUniformLocation(v.id, texunit_pairs[i].name); - if (loc >= 0) - glUniform1i(loc, texunit_pairs[i].index); - } - - if (cc) { - - v.custom_uniform_locations.resize(cc->custom_uniforms.size()); - for (int i = 0; i < cc->custom_uniforms.size(); i++) { - - v.custom_uniform_locations[i] = glGetUniformLocation(v.id, String(cc->custom_uniforms[i]).ascii().get_data()); - } - } - - glUseProgram(0); - - v.ok = true; - - return &v; -} - -GLint ShaderGLES2::get_uniform_location(const String &p_name) const { - - ERR_FAIL_COND_V(!version, -1); - return glGetUniformLocation(version->id, p_name.ascii().get_data()); -} - -void ShaderGLES2::setup(const char **p_conditional_defines, int p_conditional_count, const char **p_uniform_names, int p_uniform_count, const AttributePair *p_attribute_pairs, int p_attribute_count, const TexUnitPair *p_texunit_pairs, int p_texunit_pair_count, const char *p_vertex_code, const char *p_fragment_code, int p_vertex_code_start, int p_fragment_code_start) { - - ERR_FAIL_COND(version); - conditional_version.key = 0; - new_conditional_version.key = 0; - uniform_count = p_uniform_count; - conditional_count = p_conditional_count; - conditional_defines = p_conditional_defines; - uniform_names = p_uniform_names; - vertex_code = p_vertex_code; - fragment_code = p_fragment_code; - texunit_pairs = p_texunit_pairs; - texunit_pair_count = p_texunit_pair_count; - vertex_code_start = p_vertex_code_start; - fragment_code_start = p_fragment_code_start; - attribute_pairs = p_attribute_pairs; - attribute_pair_count = p_attribute_count; - - //split vertex and shader code (thank you, retarded shader compiler programmers from you know what company). - { - String globals_tag = "\nVERTEX_SHADER_GLOBALS"; - String code_tag = "\nVERTEX_SHADER_CODE"; - String code = vertex_code; - int cpos = code.find(globals_tag); - if (cpos == -1) { - vertex_code0 = code.ascii(); - } else { - vertex_code0 = code.substr(0, cpos).ascii(); - code = code.substr(cpos + globals_tag.length(), code.length()); - - cpos = code.find(code_tag); - - if (cpos == -1) { - vertex_code1 = code.ascii(); - } else { - - vertex_code1 = code.substr(0, cpos).ascii(); - vertex_code2 = code.substr(cpos + code_tag.length(), code.length()).ascii(); - } - } - } - - { - String globals_tag = "\nFRAGMENT_SHADER_GLOBALS"; - String code_tag = "\nFRAGMENT_SHADER_CODE"; - String light_code_tag = "\nLIGHT_SHADER_CODE"; - String code = fragment_code; - int cpos = code.find(globals_tag); - if (cpos == -1) { - fragment_code0 = code.ascii(); - } else { - fragment_code0 = code.substr(0, cpos).ascii(); - code = code.substr(cpos + globals_tag.length(), code.length()); - - cpos = code.find(code_tag); - - if (cpos == -1) { - fragment_code1 = code.ascii(); - } else { - - fragment_code1 = code.substr(0, cpos).ascii(); - String code2 = code.substr(cpos + code_tag.length(), code.length()); - - cpos = code2.find(light_code_tag); - if (cpos == -1) { - fragment_code2 = code2.ascii(); - } else { - - fragment_code2 = code2.substr(0, cpos).ascii(); - fragment_code3 = code2.substr(cpos + light_code_tag.length(), code2.length()).ascii(); - } - } - } - } -} - -void ShaderGLES2::finish() { - - const VersionKey *V = NULL; - while ((V = version_map.next(V))) { - - Version &v = version_map[*V]; - glDeleteShader(v.vert_id); - glDeleteShader(v.frag_id); - glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); - } -} - -void ShaderGLES2::clear_caches() { - - const VersionKey *V = NULL; - while ((V = version_map.next(V))) { - - Version &v = version_map[*V]; - glDeleteShader(v.vert_id); - glDeleteShader(v.frag_id); - glDeleteProgram(v.id); - memdelete_arr(v.uniform_location); - } - - version_map.clear(); - - custom_code_map.clear(); - version = NULL; - last_custom_code = 1; - uniforms_dirty = true; -} - -uint32_t ShaderGLES2::create_custom_shader() { - - custom_code_map[last_custom_code] = CustomCode(); - custom_code_map[last_custom_code].version = 1; - return last_custom_code++; -} - -void ShaderGLES2::set_custom_shader_code(uint32_t p_code_id, const String &p_vertex, const String &p_vertex_globals, const String &p_fragment, const String &p_light, const String &p_fragment_globals, const Vector<StringName> &p_uniforms, const Vector<const char *> &p_custom_defines) { - - ERR_FAIL_COND(!custom_code_map.has(p_code_id)); - CustomCode *cc = &custom_code_map[p_code_id]; - - cc->vertex = p_vertex; - cc->vertex_globals = p_vertex_globals; - cc->fragment = p_fragment; - cc->fragment_globals = p_fragment_globals; - cc->light = p_light; - cc->custom_uniforms = p_uniforms; - cc->custom_defines = p_custom_defines; - cc->version++; -} - -void ShaderGLES2::set_custom_shader(uint32_t p_code_id) { - - new_conditional_version.code_version = p_code_id; -} - -void ShaderGLES2::free_custom_shader(uint32_t p_code_id) { - - /* if (! custom_code_map.has( p_code_id )) { - print_line("no code id "+itos(p_code_id)); - } else { - print_line("freed code id "+itos(p_code_id)); - - }*/ - - ERR_FAIL_COND(!custom_code_map.has(p_code_id)); - if (conditional_version.code_version == p_code_id) - conditional_version.code_version = 0; //bye - - custom_code_map.erase(p_code_id); -} - -ShaderGLES2::ShaderGLES2() { - version = NULL; - last_custom_code = 1; - uniforms_dirty = true; -} - -ShaderGLES2::~ShaderGLES2() { - - finish(); -} - -#endif diff --git a/drivers/gles2/shader_gles2.h b/drivers/gles2/shader_gles2.h deleted file mode 100644 index 32b979807d..0000000000 --- a/drivers/gles2/shader_gles2.h +++ /dev/null @@ -1,359 +0,0 @@ -/*************************************************************************/ -/* shader_gles2.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 SHADER_GLES2_H -#define SHADER_GLES2_H - -#ifdef GLES2_ENABLED - -#include "platform_config.h" -#ifndef GLES2_INCLUDE_H -#include <GLES2/gl2.h> -#else -#include GLES2_INCLUDE_H -#endif - -#include "camera_matrix.h" -#include "hash_map.h" -#include "map.h" -#include "variant.h" - -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - -class ShaderGLES2 { -protected: - struct Enum { - - uint64_t mask; - uint64_t shift; - const char *defines[16]; - }; - - struct EnumValue { - - uint64_t set_mask; - uint64_t clear_mask; - }; - - struct AttributePair { - - const char *name; - int index; - }; - - struct UniformPair { - const char *name; - Variant::Type type_hint; - }; - - struct TexUnitPair { - - const char *name; - int index; - }; - - bool uniforms_dirty; - -private: - //@TODO Optimize to a fixed set of shader pools and use a LRU - int uniform_count; - int texunit_pair_count; - int conditional_count; - int vertex_code_start; - int fragment_code_start; - int attribute_pair_count; - - struct CustomCode { - - String vertex; - String vertex_globals; - String fragment; - String fragment_globals; - String light; - uint32_t version; - Vector<StringName> custom_uniforms; - Vector<const char *> custom_defines; - }; - - struct Version { - - GLuint id; - GLuint vert_id; - GLuint frag_id; - GLint *uniform_location; - Vector<GLint> custom_uniform_locations; - uint32_t code_version; - bool ok; - Version() { - code_version = 0; - ok = false; - uniform_location = NULL; - } - }; - - Version *version; - - union VersionKey { - - struct { - uint32_t version; - uint32_t code_version; - }; - uint64_t key; - bool operator==(const VersionKey &p_key) const { return key == p_key.key; } - bool operator<(const VersionKey &p_key) const { return key < p_key.key; } - }; - - struct VersionKeyHash { - - static _FORCE_INLINE_ uint32_t hash(const VersionKey &p_key) { return HashMapHasherDefault::hash(p_key.key); }; - }; - - //this should use a way more cachefriendly version.. - HashMap<VersionKey, Version, VersionKeyHash> version_map; - - HashMap<uint32_t, CustomCode> custom_code_map; - uint32_t last_custom_code; - - VersionKey conditional_version; - VersionKey new_conditional_version; - - virtual String get_shader_name() const = 0; - - const char **conditional_defines; - const char **uniform_names; - const AttributePair *attribute_pairs; - const TexUnitPair *texunit_pairs; - const char *vertex_code; - const char *fragment_code; - CharString fragment_code0; - CharString fragment_code1; - CharString fragment_code2; - CharString fragment_code3; - - CharString vertex_code0; - CharString vertex_code1; - CharString vertex_code2; - - Version *get_current_version(); - - static ShaderGLES2 *active; - - _FORCE_INLINE_ void _set_uniform_variant(GLint p_uniform, const Variant &p_value) { - - if (p_uniform < 0) - return; // do none - switch (p_value.get_type()) { - - case Variant::BOOL: - case Variant::INT: /* { - - int val=p_value; - glUniform1i( p_uniform, val ); - } break; */ - case Variant::REAL: { - - real_t val = p_value; - glUniform1f(p_uniform, val); - } break; - case Variant::COLOR: { - - Color val = p_value; - glUniform4f(p_uniform, val.r, val.g, val.b, val.a); - } break; - case Variant::VECTOR2: { - - Vector2 val = p_value; - glUniform2f(p_uniform, val.x, val.y); - } break; - case Variant::VECTOR3: { - - Vector3 val = p_value; - glUniform3f(p_uniform, val.x, val.y, val.z); - } break; - case Variant::PLANE: { - - Plane val = p_value; - glUniform4f(p_uniform, val.normal.x, val.normal.y, val.normal.z, val.d); - } break; - case Variant::QUAT: { - - Quat val = p_value; - glUniform4f(p_uniform, val.x, val.y, val.z, val.w); - } break; - - case Variant::MATRIX32: { - - Transform2D tr = p_value; - GLfloat matrix[16] = { /* build a 16x16 matrix */ - tr.elements[0][0], - tr.elements[0][1], - 0, - 0, - tr.elements[1][0], - tr.elements[1][1], - 0, - 0, - 0, - 0, - 1, - 0, - tr.elements[2][0], - tr.elements[2][1], - 0, - 1 - }; - - glUniformMatrix4fv(p_uniform, 1, false, matrix); - - } break; - case Variant::MATRIX3: - case Variant::TRANSFORM: { - - Transform tr = p_value; - GLfloat matrix[16] = { /* build a 16x16 matrix */ - tr.basis.elements[0][0], - tr.basis.elements[1][0], - tr.basis.elements[2][0], - 0, - tr.basis.elements[0][1], - tr.basis.elements[1][1], - tr.basis.elements[2][1], - 0, - tr.basis.elements[0][2], - tr.basis.elements[1][2], - tr.basis.elements[2][2], - 0, - tr.origin.x, - tr.origin.y, - tr.origin.z, - 1 - }; - - glUniformMatrix4fv(p_uniform, 1, false, matrix); - } break; - default: { ERR_FAIL(); } // do nothing - } - } - - Map<uint32_t, Variant> uniform_defaults; - Map<uint32_t, CameraMatrix> uniform_cameras; - -protected: - _FORCE_INLINE_ int _get_uniform(int p_which) const; - _FORCE_INLINE_ void _set_conditional(int p_which, bool p_value); - - void setup(const char **p_conditional_defines, int p_conditional_count, const char **p_uniform_names, int p_uniform_count, const AttributePair *p_attribute_pairs, int p_attribute_count, const TexUnitPair *p_texunit_pairs, int p_texunit_pair_count, const char *p_vertex_code, const char *p_fragment_code, int p_vertex_code_start, int p_fragment_code_start); - - ShaderGLES2(); - -public: - enum { - CUSTOM_SHADER_DISABLED = 0 - }; - - GLint get_uniform_location(const String &p_name) const; - GLint get_uniform_location(int p_index) const; - - static _FORCE_INLINE_ ShaderGLES2 *get_active() { return active; }; - bool bind(); - void unbind(); - void bind_uniforms(); - - inline GLuint get_program() const { return version ? version->id : 0; } - - void clear_caches(); - - uint32_t create_custom_shader(); - void set_custom_shader_code(uint32_t p_code_id, const String &p_vertex, const String &p_vertex_globals, const String &p_fragment, const String &p_light, const String &p_fragment_globals, const Vector<StringName> &p_uniforms, const Vector<const char *> &p_custom_defines); - void set_custom_shader(uint32_t p_code_id); - void free_custom_shader(uint32_t p_code_id); - - void set_uniform_default(int p_idx, const Variant &p_value) { - - if (p_value.get_type() == Variant::NIL) { - - uniform_defaults.erase(p_idx); - } else { - - uniform_defaults[p_idx] = p_value; - } - uniforms_dirty = true; - }; - - uint32_t get_version() const { return new_conditional_version.version; } - - void set_uniform_camera(int p_idx, const CameraMatrix &p_mat) { - - uniform_cameras[p_idx] = p_mat; - uniforms_dirty = true; - }; - - _FORCE_INLINE_ void set_custom_uniform(int p_idx, const Variant &p_value) { - - ERR_FAIL_COND(!version); - ERR_FAIL_INDEX(p_idx, version->custom_uniform_locations.size()); - _set_uniform_variant(version->custom_uniform_locations[p_idx], p_value); - } - - _FORCE_INLINE_ GLint get_custom_uniform_location(int p_idx) { - - ERR_FAIL_COND_V(!version, -1); - ERR_FAIL_INDEX_V(p_idx, version->custom_uniform_locations.size(), -1); - return version->custom_uniform_locations[p_idx]; - } - - virtual void init() = 0; - void finish(); - - virtual ~ShaderGLES2(); -}; - -// called a lot, made inline - -int ShaderGLES2::_get_uniform(int p_which) const { - - ERR_FAIL_INDEX_V(p_which, uniform_count, -1); - ERR_FAIL_COND_V(!version, -1); - return version->uniform_location[p_which]; -} - -void ShaderGLES2::_set_conditional(int p_which, bool p_value) { - - ERR_FAIL_INDEX(p_which, conditional_count); - if (p_value) - new_conditional_version.version |= (1 << p_which); - else - new_conditional_version.version &= ~(1 << p_which); -} - -#endif -#endif diff --git a/drivers/gles2/shaders/SCsub b/drivers/gles2/shaders/SCsub deleted file mode 100644 index bf4ec9485d..0000000000 --- a/drivers/gles2/shaders/SCsub +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -if env['BUILDERS'].has_key('GLSL120GLES'): - env.GLSL120GLES('material.glsl') - env.GLSL120GLES('canvas.glsl') - env.GLSL120GLES('canvas_shadow.glsl') - env.GLSL120GLES('blur.glsl') - env.GLSL120GLES('copy.glsl') - -Export('env') diff --git a/drivers/gles2/shaders/blur.glsl b/drivers/gles2/shaders/blur.glsl deleted file mode 100644 index b68a55aee7..0000000000 --- a/drivers/gles2/shaders/blur.glsl +++ /dev/null @@ -1,51 +0,0 @@ -[vertex] - -#ifdef USE_GLES_OVER_GL -#define mediump -#define highp -#else -precision mediump float; -precision mediump int; -#endif - -attribute highp vec4 vertex_attrib; // attrib:0 -attribute vec2 uv_in; // attrib:4 - -varying vec2 uv_out; - - - -void main() { - - color_interp = color_attrib; - uv_interp = uv_attrib; - vec4 outvec = vec4(vertex, 1.0); - outvec = extra_matrix * outvec; - outvec = modelview_matrix * outvec; - gl_Position = projection_matrix * outvec; -} - -[fragment] - -#ifdef USE_GLES_OVER_GL -#define mediump -#define highp -#else -precision mediump float; -precision mediump int; -#endif - - // texunit:0 -uniform sampler2D texture; -varying vec2 uv_out; - - -void main() { - - vec4 color = color_interp; - - color *= texture2D( texture, uv_interp ); - - gl_FragColor = color; -} - diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl deleted file mode 100644 index 4b8c553b60..0000000000 --- a/drivers/gles2/shaders/canvas.glsl +++ /dev/null @@ -1,391 +0,0 @@ -[vertex] - -#ifdef USE_GLES_OVER_GL -#define mediump -#define highp -#else -precision mediump float; -precision mediump int; -#endif - -uniform highp mat4 projection_matrix; -uniform highp mat4 modelview_matrix; -uniform highp mat4 extra_matrix; -attribute highp vec3 vertex; // attrib:0 -attribute vec4 color_attrib; // attrib:3 -attribute highp vec2 uv_attrib; // attrib:4 - -varying vec2 uv_interp; -varying vec4 color_interp; - -#if defined(USE_TIME) -uniform float time; -#endif - - -#ifdef USE_LIGHTING - -uniform highp mat4 light_matrix; -uniform highp mat4 light_local_matrix; -uniform vec2 light_pos; -varying vec4 light_uv_interp; - -varying vec4 local_rot; -uniform vec2 normal_flip; - -#ifdef USE_SHADOWS -varying highp vec2 pos; -#endif - -#endif - -#if defined(ENABLE_VAR1_INTERP) -varying vec4 var1_interp; -#endif - -#if defined(ENABLE_VAR2_INTERP) -varying vec4 var2_interp; -#endif - -//uniform bool snap_pixels; - -VERTEX_SHADER_GLOBALS - -void main() { - - color_interp = color_attrib; - uv_interp = uv_attrib; - highp vec4 outvec = vec4(vertex, 1.0); -{ - vec2 src_vtx=outvec.xy; -VERTEX_SHADER_CODE - -} -#if !defined(USE_WORLD_VEC) - outvec = extra_matrix * outvec; - outvec = modelview_matrix * outvec; -#endif - - - -#ifdef USE_PIXEL_SNAP - - outvec.xy=floor(outvec.xy+0.5); -#endif - - - gl_Position = projection_matrix * outvec; - -#ifdef USE_LIGHTING - - light_uv_interp.xy = (light_matrix * outvec).xy; - light_uv_interp.zw =(light_local_matrix * outvec).xy; -#ifdef USE_SHADOWS - pos=outvec.xy; -#endif - - local_rot.xy=normalize( (modelview_matrix * ( extra_matrix * vec4(1.0,0.0,0.0,0.0) )).xy )*normal_flip.x; - local_rot.zw=normalize( (modelview_matrix * ( extra_matrix * vec4(0.0,1.0,0.0,0.0) )).xy )*normal_flip.y; - -#endif - -} - -[fragment] - -#ifdef USE_GLES_OVER_GL -#define mediump -#define highp -#else -precision mediump float; -precision mediump int; -#endif - - -uniform sampler2D texture; // texunit:0 -uniform sampler2D normal_texture; // texunit:0 - -varying vec2 uv_interp; -varying vec4 color_interp; - -#ifdef MOMO - -#endif - -#if defined(ENABLE_SCREEN_UV) - -uniform vec2 screen_uv_mult; - -#endif - -#if defined(ENABLE_TEXSCREEN) - -uniform vec2 texscreen_screen_mult; -uniform vec4 texscreen_screen_clamp; -uniform sampler2D texscreen_tex; - -#endif - - -#if defined(ENABLE_VAR1_INTERP) -varying vec4 var1_interp; -#endif - -#if defined(ENABLE_VAR2_INTERP) -varying vec4 var2_interp; -#endif - -#if defined(USE_TIME) -uniform float time; -#endif - -#ifdef USE_MODULATE - -uniform vec4 modulate; - -#endif - -#ifdef USE_LIGHTING - -uniform sampler2D light_texture; -uniform vec4 light_color; -uniform vec4 light_shadow_color; -uniform float light_height; -varying vec4 light_uv_interp; -uniform float light_outside_alpha; - -varying vec4 local_rot; - -#ifdef USE_SHADOWS - -uniform highp sampler2D shadow_texture; -uniform float shadow_attenuation; - -uniform highp mat4 shadow_matrix; -varying highp vec2 pos; -uniform float shadowpixel_size; - -#ifdef SHADOW_ESM -uniform float shadow_esm_multiplier; -#endif - -#endif - -#endif - -#if defined(USE_TEXPIXEL_SIZE) -uniform vec2 texpixel_size; -#endif - - -FRAGMENT_SHADER_GLOBALS - - -void main() { - - vec4 color = color_interp; - -#ifdef USE_DISTANCE_FIELD - const float smoothing = 1.0/32.0; - float distance = textureLod(texture, uv_interp,0.0).a; - color.a = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance) * color.a; -#else - color *= texture2D( texture, uv_interp ); - -#endif - - vec3 normal; - normal.xy = textureLod( normal_texture, uv_interp, 0.0 ).xy * 2.0 - 1.0; - normal.z = sqrt(1.0-dot(normal.xy,normal.xy)); - -#if defined(ENABLE_SCREEN_UV) - vec2 screen_uv = gl_FragCoord.xy*screen_uv_mult; -#endif - - -{ -#if defined(USE_NORMALMAP) - vec3 normal_map=vec3(0.0,0.0,1.0); - float normal_depth=1.0; -#endif - -FRAGMENT_SHADER_CODE - -#if defined(USE_NORMALMAP) - normal = mix(vec3(0.0,0.0,1.0), normal_map * vec3(2.0,-2.0,1.0) - vec3( 1.0, -1.0, 0.0 ), normal_depth ); -#endif - -} -#ifdef DEBUG_ENCODED_32 - highp float enc32 = dot( color,highp vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1) ); - color = vec4(vec3(enc32),1.0); -#endif - -#ifdef USE_MODULATE - - color*=modulate; -#endif - - -#ifdef USE_LIGHTING - - vec2 light_vec = light_uv_interp.zw;; //for shadow and normal mapping - - normal.xy = mat2(local_rot.xy,local_rot.zw) * normal.xy; - - float att=1.0; - - vec2 light_uv = light_uv_interp.xy; - vec4 light = texture2D(light_texture,light_uv) * light_color; -#if defined(USE_OUTPUT_SHADOW_COLOR) - vec4 shadow_color=vec4(0.0,0.0,0.0,0.0); -#endif - - if (any(lessThan(light_uv_interp.xy,vec2(0.0,0.0))) || any(greaterThanEqual(light_uv_interp.xy,vec2(1.0,1.0)))) { - color.a*=light_outside_alpha; //invisible - - } else { - -#if defined(USE_LIGHT_SHADER_CODE) -//light is written by the light shader - { - vec4 light_out=light*color; -LIGHT_SHADER_CODE - color=light_out; - } - -#else - - vec3 light_normal = normalize(vec3(light_vec,-light_height)); - light*=max(dot(-light_normal,normal),0.0); - - color*=light; -/* -#ifdef USE_NORMAL - color.xy=local_rot.xy;//normal.xy; - color.zw=vec2(0.0,1.0); -#endif -*/ - -//light shader code -#endif - - -#ifdef USE_SHADOWS - - float angle_to_light = -atan(light_vec.x,light_vec.y); - float PI = 3.14159265358979323846264; - /*int i = int(mod(floor((angle_to_light+7.0*PI/6.0)/(4.0*PI/6.0))+1.0, 3.0)); // +1 pq os indices estao em ordem 2,0,1 nos arrays - float ang*/ - - float su,sz; - - float abs_angle = abs(angle_to_light); - vec2 point; - float sh; - if (abs_angle<45.0*PI/180.0) { - point = light_vec; - sh=0.0+(1.0/8.0); - } else if (abs_angle>135.0*PI/180.0) { - point = -light_vec; - sh = 0.5+(1.0/8.0); - } else if (angle_to_light>0.0) { - - point = vec2(light_vec.y,-light_vec.x); - sh = 0.25+(1.0/8.0); - } else { - - point = vec2(-light_vec.y,light_vec.x); - sh = 0.75+(1.0/8.0); - - } - - - highp vec4 s = shadow_matrix * vec4(point,0.0,1.0); - s.xyz/=s.w; - su=s.x*0.5+0.5; - sz=s.z*0.5+0.5; - - highp float shadow_attenuation=0.0; - -#ifdef USE_DEPTH_SHADOWS - -#define SHADOW_DEPTH(m_tex,m_uv) (texture2D((m_tex),(m_uv)).r) - -#else - -//#define SHADOW_DEPTH(m_tex,m_uv) dot(texture2D((m_tex),(m_uv)),highp vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1) ) -#define SHADOW_DEPTH(m_tex,m_uv) dot(texture2D((m_tex),(m_uv)),vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1) ) - -#endif - - - -#ifdef SHADOW_PCF5 - - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*2.0,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*2.0,sh))<sz?0.0:1.0; - shadow_attenuation/=5.0; - -#endif - -#ifdef SHADOW_PCF13 - - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*2.0,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*3.0,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*4.0,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*5.0,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size*6.0,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*2.0,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*3.0,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*4.0,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*5.0,sh))<sz?0.0:1.0; - shadow_attenuation += SHADOW_DEPTH(shadow_texture,vec2(su-shadowpixel_size*6.0,sh))<sz?0.0:1.0; - shadow_attenuation/=13.0; - -#endif - -#ifdef SHADOW_ESM - - - { - float unnormalized = su/shadowpixel_size; - float fractional = fract(unnormalized); - unnormalized = floor(unnormalized); - float zc = SHADOW_DEPTH(shadow_texture,vec2((unnormalized-0.5)*shadowpixel_size,sh)); - float zn = SHADOW_DEPTH(shadow_texture,vec2((unnormalized+0.5)*shadowpixel_size,sh)); - float z = mix(zc,zn,fractional); - shadow_attenuation=clamp(exp(shadow_esm_multiplier* ( z - sz )),0.0,1.0); - } - -#endif - -#if !defined(SHADOW_PCF5) && !defined(SHADOW_PCF13) && !defined(SHADOW_ESM) - - shadow_attenuation = SHADOW_DEPTH(shadow_texture,vec2(su+shadowpixel_size,sh))<sz?0.0:1.0; - -#endif - -#if defined(USE_OUTPUT_SHADOW_COLOR) - color=mix(shadow_color,color,shadow_attenuation); -#else - //color*=shadow_attenuation; - color=mix(light_shadow_color,color,shadow_attenuation); -#endif -//use shadows -#endif - } - -//use lighting -#endif - //color.rgb*=color.a; - gl_FragColor = color; - - -} - diff --git a/drivers/gles2/shaders/canvas_shadow.glsl b/drivers/gles2/shaders/canvas_shadow.glsl deleted file mode 100644 index 40cf321dce..0000000000 --- a/drivers/gles2/shaders/canvas_shadow.glsl +++ /dev/null @@ -1,62 +0,0 @@ -[vertex] - -#ifdef USE_GLES_OVER_GL -#define mediump -#define highp -#else -precision mediump float; -precision mediump int; -#endif - -uniform highp mat4 projection_matrix; -uniform highp mat4 light_matrix; -uniform highp mat4 world_matrix; - -attribute highp vec3 vertex; // attrib:0 - -#ifndef USE_DEPTH_SHADOWS - -varying vec4 position_interp; - -#endif - - -void main() { - - gl_Position = projection_matrix * (light_matrix * (world_matrix * vec4(vertex,1.0))); - -#ifndef USE_DEPTH_SHADOWS - position_interp = gl_Position; -#endif - -} - -[fragment] - -#ifdef USE_GLES_OVER_GL -#define mediump -#define highp -#else -precision mediump float; -precision mediump int; -#endif - -#ifndef USE_DEPTH_SHADOWS - -varying vec4 position_interp; - -#endif - -void main() { - -#ifdef USE_DEPTH_SHADOWS - -#else - highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0;//bias; - highp vec4 comp = fract(depth * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0)); - comp -= comp.xxyz * vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); - gl_FragColor = comp; -#endif - -} - diff --git a/drivers/gles2/shaders/copy.glsl b/drivers/gles2/shaders/copy.glsl deleted file mode 100644 index 23680ffe91..0000000000 --- a/drivers/gles2/shaders/copy.glsl +++ /dev/null @@ -1,557 +0,0 @@ -[vertex] - -#ifdef USE_GLES_OVER_GL -#define mediump -#define highp -#else -precision mediump float; -precision mediump int; -#endif - -attribute highp vec4 vertex_attrib; // attrib:0 -#ifdef USE_CUBEMAP -attribute vec3 cube_in; // attrib:4 -#else -attribute vec2 uv_in; // attrib:4 -#endif -attribute vec2 uv2_in; // attrib:5 - - -#ifdef USE_CUBEMAP -varying vec3 cube_interp; -#else -varying vec2 uv_interp; -#endif - -varying vec2 uv2_interp; - -void main() { - -#ifdef USE_CUBEMAP - cube_interp = cube_in; -#else - uv_interp = uv_in; -#endif - uv2_interp = uv2_in; - gl_Position = vertex_attrib; -} - -[fragment] - -#ifdef USE_GLES_OVER_GL -#define mediump -#define highp -#else -precision mediump float; -precision mediump int; -#endif - - - -float sRGB_gamma_correct(float c){ - float a = 0.055; - if(c < 0.0031308) - return 12.92*c; - else - return (1.0+a)*pow(c, 1.0/2.4) - a; -} - -#define LUM_RANGE 4.0 - - -#ifdef USE_ARRAY -uniform sampler2DArray source; -#elif defined(USE_CUBEMAP) -varying vec3 cube_interp; -uniform samplerCube source_cube; -#else -varying vec2 uv_interp; -#ifdef HIGHP_SOURCE -uniform highp sampler2D source; -#else -uniform sampler2D source; -#endif -#endif -varying vec2 uv2_interp; - - -#ifdef USE_DEPTH -uniform highp sampler2D source_depth; //texunit:1 -#endif - -#ifdef USE_GLOW - -uniform sampler2D glow_source; - -#endif - - -#if defined(USE_HDR) && defined(USE_GLOW_COPY) -uniform highp float hdr_glow_threshold; -uniform highp float hdr_glow_scale; -#endif - -#ifdef USE_HDR - -uniform sampler2D hdr_source; -uniform highp float tonemap_exposure; -uniform highp float tonemap_white; -#endif - -#ifdef USE_BCS - -uniform vec3 bcs; - -#endif - -#ifdef USE_GLOW_COPY - -uniform float bloom; -uniform float bloom_threshold; - -#endif - -#if defined(SHADOW_BLUR_V_PASS) || defined(SHADOW_BLUR_H_PASS) || defined(BLUR_V_PASS) || defined(BLUR_H_PASS) || defined(USE_HDR_REDUCE) - -uniform vec2 pixel_size; -uniform float pixel_scale; -uniform float blur_magnitude; - -#ifdef USE_HDR_STORE - -uniform highp float hdr_time_delta; -uniform highp float hdr_exp_adj_speed; -uniform highp float min_luminance; -uniform highp float max_luminance; -uniform sampler2D source_vd_lum; - -#endif - -//endif -#elif defined(USE_FXAA) - -uniform vec2 pixel_size; - -#endif - -#ifdef USE_ENERGY - -uniform highp float energy; - -#endif - -#ifdef USE_CUSTOM_ALPHA -uniform float custom_alpha; -#endif - - -void main() { - - //vec4 color = color_interp; - - -#ifdef USE_ARRAY - highp vec4 color = textureLod( source, vec3(uv_interp,0.0),0.0 ); -#elif defined(USE_CUBEMAP) - highp vec4 color = textureCube( source_cube, normalize(cube_interp) ); - -#else - highp vec4 color = texture2D( source, uv_interp ); -#endif - - - -#endif - -#ifdef USE_FXAA - -#define FXAA_REDUCE_MIN (1.0/ 128.0) -#define FXAA_REDUCE_MUL (1.0 / 8.0) -#define FXAA_SPAN_MAX 8.0 - - { - vec3 rgbNW = texture2D(source, uv_interp + vec2(-1.0, -1.0) * pixel_size).xyz; - vec3 rgbNE = texture2D(source, uv_interp + vec2(1.0, -1.0) * pixel_size).xyz; - vec3 rgbSW = texture2D(source, uv_interp + vec2(-1.0, 1.0) * pixel_size).xyz; - vec3 rgbSE = texture2D(source, uv_interp + vec2(1.0, 1.0) * pixel_size).xyz; - vec3 rgbM = color.rgb; - vec3 luma = vec3(0.299, 0.587, 0.114); - float lumaNW = dot(rgbNW, luma); - float lumaNE = dot(rgbNE, luma); - float lumaSW = dot(rgbSW, luma); - float lumaSE = dot(rgbSE, luma); - float lumaM = dot(rgbM, luma); - float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); - float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); - - vec2 dir; - dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); - dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); - - float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * - (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); - - float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); - dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), - max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), - dir * rcpDirMin)) * pixel_size; - - vec3 rgbA = 0.5 * ( - texture2D(source, uv_interp + dir * (1.0 / 3.0 - 0.5)).xyz + - texture2D(source, uv_interp + dir * (2.0 / 3.0 - 0.5)).xyz); - vec3 rgbB = rgbA * 0.5 + 0.25 * ( - texture2D(source, uv_interp + dir * -0.5).xyz + - texture2D(source, uv_interp + dir * 0.5).xyz); - - float lumaB = dot(rgbB, luma); - if ((lumaB < lumaMin) || (lumaB > lumaMax)) - color.rgb = rgbA; - else - color.rgb = rgbB; - } - -#endif - //color.rg=uv_interp; - -#ifdef USE_BCS - - color.rgb = mix(vec3(0.0),color.rgb,bcs.x); - color.rgb = mix(vec3(0.5),color.rgb,bcs.y); - color.rgb = mix(vec3(dot(vec3(1.0),color.rgb)*0.33333),color.rgb,bcs.z); - -#endif - -#ifdef BLUR_V_PASS - - color+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*-3.0)*pixel_scale); - color+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*-2.0)*pixel_scale); - color+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*-1.0)*pixel_scale); - color+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*1.0)*pixel_scale); - color+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*2.0)*pixel_scale); - color+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*3.0)*pixel_scale); - - color*=(1.0/7.0)*blur_magnitude; - -#endif - -#ifdef BLUR_H_PASS - - - color+=texture2D(source,uv_interp+vec2(pixel_size.x*-3.0,0.0)*pixel_scale); - color+=texture2D(source,uv_interp+vec2(pixel_size.x*-2.0,0.0)*pixel_scale); - color+=texture2D(source,uv_interp+vec2(pixel_size.x*-1.0,0.0)*pixel_scale); - color+=texture2D(source,uv_interp+vec2(pixel_size.x*1.0,0.0)*pixel_scale); - color+=texture2D(source,uv_interp+vec2(pixel_size.x*2.0,0.0)*pixel_scale); - color+=texture2D(source,uv_interp+vec2(pixel_size.x*3.0,0.0)*pixel_scale); - - color*=(1.0/7.0)*blur_magnitude; - -#endif - -#ifdef SHADOW_BLUR_V_PASS - -#ifdef USE_RGBA_DEPTH - -#define VEC42DEPTH(m_vec4) dot(m_vec4,vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1)) - - highp float depth = VEC42DEPTH(color)*0.383; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(0.0,pixel_size.y*-3.0)*pixel_scale))*0.006; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(0.0,pixel_size.y*-2.0)*pixel_scale))*0.061; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(0.0,pixel_size.y*-1.0)*pixel_scale))*0.242; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(0.0,pixel_size.y*1.0)*pixel_scale))*0.242; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(0.0,pixel_size.y*2.0)*pixel_scale))*0.061; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(0.0,pixel_size.y*3.0)*pixel_scale))*0.006; - highp vec4 comp = fract(depth * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0)); - comp -= comp.xxyz * vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); - color=comp; - -#else - - highp float depth = color.r*0.383; - depth+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*-3.0)*pixel_scale).r*0.006; - depth+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*-2.0)*pixel_scale).r*0.061; - depth+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*-1.0)*pixel_scale).r*0.242; - depth+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*1.0)*pixel_scale).r*0.242; - depth+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*2.0)*pixel_scale).r*0.061; - depth+=texture2D(source,uv_interp+vec2(0.0,pixel_size.y*3.0)*pixel_scale).r*0.006; - -#ifdef USE_GLES_OVER_GL - gl_FragDepth = depth; - -#else - gl_FragDepthEXT = depth; -#endif - - return; -#endif - -#endif - -#ifdef SHADOW_BLUR_H_PASS - - -#ifdef USE_RGBA_DEPTH - -#define VEC42DEPTH(m_vec4) dot(m_vec4,vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1)) - - highp float depth = VEC42DEPTH(color)*0.383; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(pixel_size.x*-3.0,0.0)*pixel_scale))*0.006; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(pixel_size.x*-2.0,0.0)*pixel_scale))*0.061; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(pixel_size.x*-1.0,0.0)*pixel_scale))*0.242; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(pixel_size.x*1.0,0.0)*pixel_scale))*0.242; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(pixel_size.x*2.0,0.0)*pixel_scale))*0.061; - depth+=VEC42DEPTH(texture2D(source,uv_interp+vec2(pixel_size.x*3.0,0.0)*pixel_scale))*0.006; - highp vec4 comp = fract(depth * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0)); - comp -= comp.xxyz * vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); - color=comp; -#else - - - highp float depth = color.r*0.383; - depth+=texture2D(source,uv_interp+vec2(pixel_size.x*-3.0,0.0)*pixel_scale).r*0.006; - depth+=texture2D(source,uv_interp+vec2(pixel_size.x*-2.0,0.0)*pixel_scale).r*0.061; - depth+=texture2D(source,uv_interp+vec2(pixel_size.x*-1.0,0.0)*pixel_scale).r*0.242; - depth+=texture2D(source,uv_interp+vec2(pixel_size.x*1.0,0.0)*pixel_scale).r*0.242; - depth+=texture2D(source,uv_interp+vec2(pixel_size.x*2.0,0.0)*pixel_scale).r*0.061; - depth+=texture2D(source,uv_interp+vec2(pixel_size.x*3.0,0.0)*pixel_scale).r*0.006; - -#ifdef USE_GLES_OVER_GL - gl_FragDepth = depth; -#else - gl_FragDepthEXT = depth; -#endif - - return; - -#endif - -#endif - -#ifdef USE_HDR - - highp float white_mult = 1.0; - -#ifdef USE_8BIT_HDR - highp vec4 _mult = vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1); - highp float hdr_lum = dot(texture2D( hdr_source, vec2(0.0) ), _mult ); - color.rgb*=LUM_RANGE; - hdr_lum*=LUM_RANGE; //restore to full range -#else - - highp vec2 lv = texture2D( hdr_source, vec2(0.0) ).rg; - highp float hdr_lum = lv.r; -#ifdef USE_AUTOWHITE - white_mult=lv.g; -#endif - -#endif - -#ifdef USE_REINHARDT_TONEMAPPER - float src_lum = dot(color.rgb,vec3(0.3, 0.58, 0.12)); - float lp = tonemap_exposure/hdr_lum*src_lum; - float white = tonemap_white; -#ifdef USE_AUTOWHITE - white_mult = (white_mult + 1.0 * white_mult); - white_mult*=white_mult; - white*=white_mult; -#endif - lp = ( lp * ( 1.0 + ( lp / ( white) ) ) ) / ( 1.0 + lp ); - color.rgb*=lp; - -#else - -#ifdef USE_LOG_TONEMAPPER - color.rgb = tonemap_exposure * log(color.rgb+1.0)/log(hdr_lum+1.0); -#else - highp float tone_scale = tonemap_exposure / hdr_lum; //only linear supported - color.rgb*=tone_scale; -#endif - -#endif - -#endif - - -#ifdef USE_GLOW_COPY - - highp vec3 glowcol = color.rgb*color.a+step(bloom_threshold,dot(vec3(0.3333,0.3333,0.3333),color.rgb))*bloom*color.rgb; - -#ifdef USE_HDR - highp float collum = max(color.r,max(color.g,color.b)); - glowcol+=color.rgb*max(collum-hdr_glow_threshold,0.0)*hdr_glow_scale; -#endif - color.rgb=glowcol; - color.a=0.0; - -#endif - - -#ifdef USE_GLOW - - vec4 glow = texture2D( glow_source, uv2_interp ); - -#ifdef USE_GLOW_SCREEN - - color.rgb = clamp((color.rgb + glow.rgb) - (color.rgb * glow.rgb), 0.0, 1.0); - -#endif - -#ifdef USE_GLOW_SOFTLIGHT - - { - - glow.rgb = (glow.rgb * 0.5) + 0.5; - color.r = (glow.r <= 0.5) ? (color.r - (1.0 - 2.0 * glow.r) * color.r * (1.0 - color.r)) : (((glow.r > 0.5) && (color.r <= 0.25)) ? (color.r + (2.0 * glow.r - 1.0) * (4.0 * color.r * (4.0 * color.r + 1.0) * (color.r - 1.0) + 7.0 * color.r)) : (color.r + (2.0 * glow.r - 1.0) * (sqrt(color.r) - color.r))); - color.g = (glow.g <= 0.5) ? (color.g - (1.0 - 2.0 * glow.g) * color.g * (1.0 - color.g)) : (((glow.g > 0.5) && (color.g <= 0.25)) ? (color.g + (2.0 * glow.g - 1.0) * (4.0 * color.g * (4.0 * color.g + 1.0) * (color.g - 1.0) + 7.0 * color.g)) : (color.g + (2.0 * glow.g - 1.0) * (sqrt(color.g) - color.g))); - color.b = (glow.b <= 0.5) ? (color.b - (1.0 - 2.0 * glow.b) * color.b * (1.0 - color.b)) : (((glow.b > 0.5) && (color.b <= 0.25)) ? (color.b + (2.0 * glow.b - 1.0) * (4.0 * color.b * (4.0 * color.b + 1.0) * (color.b - 1.0) + 7.0 * color.b)) : (color.b + (2.0 * glow.b - 1.0) * (sqrt(color.b) - color.b))); - } - -#endif - -#if !defined(USE_GLOW_SCREEN) && !defined(USE_GLOW_SOFTLIGHT) - color.rgb+=glow.rgb; -#endif - - - -#endif - -#ifdef USE_SRGB - -#if 0 - //this was fast, but was commented out because it looked kind of shitty, might it be fixable? - - { //i have my doubts about how fast this is - - color.rgb = min(color.rgb,vec3(1.0)); //clamp just in case - vec3 S1 = sqrt(color.rgb); - vec3 S2 = sqrt(S1); - vec3 S3 = sqrt(S2); - color.rgb = 0.662002687 * S1 + 0.684122060 * S2 - 0.323583601 * S3 - 0.225411470 * color.rgb; - } -#else - - color.r=sRGB_gamma_correct(color.r); - color.g=sRGB_gamma_correct(color.g); - color.b=sRGB_gamma_correct(color.b); - -#endif - -#endif - -#ifdef USE_HDR_COPY - - //highp float lum = dot(color.rgb,highp vec3(1.0/3.0,1.0/3.0,1.0/3.0)); - //highp float lum = max(color.r,max(color.g,color.b)); - highp float lum = dot(color.rgb,vec3(0.3, 0.58, 0.12)); - - //lum=log(lum+0.0001); //everyone does it - -#ifdef USE_8BIT_HDR - highp vec4 comp = fract(lum * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0)); - comp -= comp.xxyz * vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); - color=comp; -#else - color.rgb=vec3(lum); -#endif - - -#endif - -#ifdef USE_HDR_REDUCE - -#ifdef USE_8BIT_HDR - highp vec4 _multcv = vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0, 1.0); - highp float lum_accum = dot(color,_multcv ); - lum_accum += dot(texture2D( source, uv_interp+vec2(-pixel_size.x,-pixel_size.y) ),_multcv ); - lum_accum += dot(texture2D( source, uv_interp+vec2(0.0,-pixel_size.y) ),_multcv ); - lum_accum += dot(texture2D( source, uv_interp+vec2(pixel_size.x,-pixel_size.y) ),_multcv ); - lum_accum += dot(texture2D( source, uv_interp+vec2(-pixel_size.x,0.0) ),_multcv ); - lum_accum += dot(texture2D( source, uv_interp+vec2(pixel_size.x,0.0) ),_multcv ); - lum_accum += dot(texture2D( source, uv_interp+vec2(-pixel_size.x,pixel_size.y) ),_multcv ); - lum_accum += dot(texture2D( source, uv_interp+vec2(0.0,pixel_size.y) ),_multcv ); - lum_accum += dot(texture2D( source, uv_interp+vec2(pixel_size.x,pixel_size.y) ),_multcv ); - lum_accum/=9.0; -#else - - highp float lum_accum = color.r; - highp float lum_max = color.g; - -#define LUM_REDUCE(m_uv) \ - {\ - vec2 val = texture2D( source, uv_interp+m_uv ).rg;\ - lum_accum+=val.x;\ - lum_max=max(val.y,lum_max);\ - } - - LUM_REDUCE( vec2(-pixel_size.x,-pixel_size.y) ); - LUM_REDUCE( vec2(0.0,-pixel_size.y) ); - LUM_REDUCE( vec2(pixel_size.x,-pixel_size.y) ); - LUM_REDUCE( vec2(-pixel_size.x,0.0) ); - LUM_REDUCE( vec2(pixel_size.x,0.0) ); - LUM_REDUCE( vec2(-pixel_size.x,pixel_size.y) ); - LUM_REDUCE( vec2(0.0,pixel_size.y) ); - LUM_REDUCE( vec2(pixel_size.x,pixel_size.y) ); - lum_accum/=9.0; - -#endif - -#ifdef USE_HDR_STORE - - //lum_accum=exp(lum_accum); - -#ifdef USE_8BIT_HDR - - highp float vd_lum = dot(texture2D( source_vd_lum, vec2(0.0) ), _multcv ); - lum_accum = clamp( vd_lum + (lum_accum-vd_lum)*hdr_time_delta*hdr_exp_adj_speed,min_luminance*(1.0/LUM_RANGE),max_luminance*(1.0/LUM_RANGE)); -#else - highp float vd_lum=texture2D( source_vd_lum, vec2(0.0) ).r; - lum_accum = clamp( vd_lum + (lum_accum-vd_lum)*hdr_time_delta*hdr_exp_adj_speed,min_luminance,max_luminance); -#endif - -#endif - -#ifdef USE_8BIT_HDR - highp vec4 comp = fract(lum_accum * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0)); - comp -= comp.xxyz * vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); - color=comp; -#else -#ifdef USE_AUTOWHITE - color.r=lum_accum; - color.g=lum_max; -#else - color.rgb=vec3(lum_accum); -#endif - - -#endif - -#endif - - - -#ifdef USE_RGBE - - color.rgb = pow(color.rgb,color.a*255.0-(8.0+128.0)); -#endif - -#ifdef USE_ENERGY - color.rgb*=energy; -#endif - -#ifdef USE_NO_ALPHA - color.a=1.0; -#endif - -#ifdef USE_CUSTOM_ALPHA - color.a=custom_alpha; -#endif - - - gl_FragColor = color; - -#ifdef USE_DEPTH - gl_FragDepth = texture(source_depth,uv_interp).r; -#endif - -} diff --git a/drivers/gles2/shaders/material.glsl b/drivers/gles2/shaders/material.glsl deleted file mode 100644 index 704a22c5d1..0000000000 --- a/drivers/gles2/shaders/material.glsl +++ /dev/null @@ -1,1326 +0,0 @@ -[vertex] - - -#ifdef USE_GLES_OVER_GL -#define mediump -#define highp -#define roundfix( m_val ) floor( (m_val) + 0.5 ) -#else -precision mediump float; -precision mediump int; -#endif - - - -/* -from VisualServer: - -ARRAY_VERTEX=0, -ARRAY_NORMAL=1, -ARRAY_TANGENT=2, -ARRAY_COLOR=3, -ARRAY_TEX_UV=4, -ARRAY_TEX_UV2=5, -ARRAY_BONES=6, -ARRAY_WEIGHTS=7, -ARRAY_INDEX=8, -*/ - -//hack to use uv if no uv present so it works with lightmap -#ifdef ENABLE_AMBIENT_LIGHTMAP - -#ifdef USE_LIGHTMAP_ON_UV2 - -#ifndef ENABLE_UV2_INTERP -#define ENABLE_UV2_INTERP -#endif - -#else - -#ifndef ENABLE_UV_INTERP -#define ENABLE_UV_INTERP -#endif - -#endif - -#endif - - -/* INPUT ATTRIBS */ - -attribute highp vec4 vertex_attrib; // attrib:0 -attribute vec3 normal_attrib; // attrib:1 -attribute vec4 tangent_attrib; // attrib:2 -attribute vec4 color_attrib; // attrib:3 -attribute vec2 uv_attrib; // attrib:4 -attribute vec2 uv2_attrib; // attrib:5 - -uniform float normal_mult; - -#ifdef USE_SKELETON -attribute vec4 bone_indices; // attrib:6 -attribute vec4 bone_weights; // attrib:7 -uniform highp sampler2D skeleton_matrices; -uniform highp float skeltex_pixel_size; -#endif - -#ifdef USE_ATTRIBUTE_INSTANCING - -attribute highp vec4 instance_row0; // attrib:8 -attribute highp vec4 instance_row1; // attrib:9 -attribute highp vec4 instance_row2; // attrib:10 -attribute highp vec4 instance_row3; // attrib:11 - -#endif - -#ifdef USE_TEXTURE_INSTANCING - -attribute highp vec3 instance_uv; // attrib:6 -uniform highp sampler2D instance_matrices; - -#endif - -uniform highp mat4 world_transform; -uniform highp mat4 camera_inverse_transform; -uniform highp mat4 projection_transform; - -#ifdef USE_UNIFORM_INSTANCING -//shittiest form of instancing (but most compatible) -uniform highp mat4 instance_transform; -#endif - -/* Varyings */ - -varying vec3 vertex_interp; -varying vec3 normal_interp; - -#if defined(ENABLE_COLOR_INTERP) -varying vec4 color_interp; -#endif - -#if defined(ENABLE_UV_INTERP) -varying vec2 uv_interp; -#endif - -#if defined(ENABLE_UV2_INTERP) -varying vec2 uv2_interp; -#endif - -#if defined(ENABLE_VAR1_INTERP) -varying vec4 var1_interp; -#endif - -#if defined(ENABLE_VAR2_INTERP) -varying vec4 var2_interp; -#endif - -#if defined(ENABLE_TANGENT_INTERP) -varying vec3 tangent_interp; -varying vec3 binormal_interp; -#endif - -#ifdef ENABLE_AMBIENT_OCTREE - -uniform highp mat4 ambient_octree_inverse_transform; -varying highp vec3 ambient_octree_coords; - -#endif - -#ifdef USE_FOG - -varying vec4 fog_interp; -uniform highp vec3 fog_params; -uniform vec3 fog_color_begin; -uniform vec3 fog_color_end; - -#endif - -#ifdef USE_VERTEX_LIGHTING - -uniform vec3 light_pos; -uniform vec3 light_direction; -uniform vec3 light_attenuation; -uniform vec3 light_spot_attenuation; -uniform vec3 light_diffuse; -uniform vec3 light_specular; - - - -#endif - -varying vec4 diffuse_interp; -varying vec3 specular_interp; -//intended for static branching -//pretty much all meaningful platforms support -//static branching - -uniform float time; -uniform float instance_id; - -uniform vec3 ambient_light; - -#if !defined(USE_DEPTH_SHADOWS) && defined(USE_SHADOW_PASS) - -varying vec4 position_interp; - -#endif - -#ifdef LIGHT_USE_SHADOW - -uniform highp mat4 shadow_matrix; -varying highp vec4 shadow_coord; -#ifdef LIGHT_USE_PSSM -uniform highp mat4 shadow_matrix2; -varying highp vec4 shadow_coord2; -#endif -#ifdef LIGHT_USE_PSSM4 -uniform highp mat4 shadow_matrix3; -varying highp vec4 shadow_coord3; -uniform highp mat4 shadow_matrix4; -varying highp vec4 shadow_coord4; -#endif - - -#endif - -#ifdef USE_SHADOW_PASS - -uniform highp float shadow_z_offset; -uniform highp float shadow_z_slope_scale; - -#endif - -#ifdef USE_DUAL_PARABOLOID -uniform highp vec2 dual_paraboloid; -varying float dp_clip; -#endif - - - -VERTEX_SHADER_GLOBALS - - - - -void main() { -#ifdef USE_UNIFORM_INSTANCING - - highp mat4 modelview = (camera_inverse_transform * (world_transform * instance_transform)); -#ifdef ENABLE_AMBIENT_OCTREE - highp mat4 ambient_octree_transform = (ambient_octree_inverse_transform * (world_transform * instance_transform)); -#endif - -#else - -#ifdef USE_ATTRIBUTE_INSTANCING - - highp mat4 minst=mat4(instance_row0,instance_row1,instance_row2,instance_row3); - highp mat4 modelview = (camera_inverse_transform * (world_transform * minst)); -#ifdef ENABLE_AMBIENT_OCTREE - highp mat4 ambient_octree_transform = (ambient_octree_inverse_transform * (world_transform * minst)); -#endif - -#else - -#ifdef USE_TEXTURE_INSTANCING - - highp vec2 ins_ofs=vec2(instance_uv.z,0.0); - - highp mat4 minst=mat4( - texture2D(instance_matrices,instance_uv.xy), - texture2D(instance_matrices,instance_uv.xy+ins_ofs), - texture2D(instance_matrices,instance_uv.xy+ins_ofs*2.0), - texture2D(instance_matrices,instance_uv.xy+ins_ofs*3.0) - ); - - /*highp mat4 minst=mat4( - vec4(1.0,0.0,0.0,0.0), - vec4(0.0,1.0,0.0,0.0), - vec4(0.0,0.0,1.0,0.0), - vec4(0.0,0.0,0.0,1.0) - );*/ - - highp mat4 modelview = (camera_inverse_transform * (world_transform * minst)); -#ifdef ENABLE_AMBIENT_OCTREE - highp mat4 ambient_octree_transform = (ambient_octree_inverse_transform * (world_transform * minst)); -#endif - -#else - highp mat4 modelview = (camera_inverse_transform * world_transform); -#ifdef ENABLE_AMBIENT_OCTREE - highp mat4 ambient_octree_transform = (ambient_octree_inverse_transform * world_transform); -#endif - -#endif - -#endif - -#endif - highp vec4 vertex_in = vertex_attrib; // vec4(vertex_attrib.xyz * data_attrib.x,1.0); - vec3 normal_in = normal_attrib; - normal_in*=normal_mult; -#if defined(ENABLE_TANGENT_INTERP) - vec3 tangent_in = tangent_attrib.xyz; - tangent_in*=normal_mult; - float binormalf = tangent_attrib.a; -#endif - -#ifdef USE_SKELETON - - { - //skeleton transform - highp mat4 m=mat4(texture2D(skeleton_matrices,vec2((bone_indices.x*3.0+0.0)*skeltex_pixel_size,0.0)),texture2D(skeleton_matrices,vec2((bone_indices.x*3.0+1.0)*skeltex_pixel_size,0.0)),texture2D(skeleton_matrices,vec2((bone_indices.x*3.0+2.0)*skeltex_pixel_size,0.0)),vec4(0.0,0.0,0.0,1.0))*bone_weights.x; - m+=mat4(texture2D(skeleton_matrices,vec2((bone_indices.y*3.0+0.0)*skeltex_pixel_size,0.0)),texture2D(skeleton_matrices,vec2((bone_indices.y*3.0+1.0)*skeltex_pixel_size,0.0)),texture2D(skeleton_matrices,vec2((bone_indices.y*3.0+2.0)*skeltex_pixel_size,0.0)),vec4(0.0,0.0,0.0,1.0))*bone_weights.y; - m+=mat4(texture2D(skeleton_matrices,vec2((bone_indices.z*3.0+0.0)*skeltex_pixel_size,0.0)),texture2D(skeleton_matrices,vec2((bone_indices.z*3.0+1.0)*skeltex_pixel_size,0.0)),texture2D(skeleton_matrices,vec2((bone_indices.z*3.0+2.0)*skeltex_pixel_size,0.0)),vec4(0.0,0.0,0.0,1.0))*bone_weights.z; - m+=mat4(texture2D(skeleton_matrices,vec2((bone_indices.w*3.0+0.0)*skeltex_pixel_size,0.0)),texture2D(skeleton_matrices,vec2((bone_indices.w*3.0+1.0)*skeltex_pixel_size,0.0)),texture2D(skeleton_matrices,vec2((bone_indices.w*3.0+2.0)*skeltex_pixel_size,0.0)),vec4(0.0,0.0,0.0,1.0))*bone_weights.w; - - vertex_in = vertex_in * m; - normal_in = (vec4(normal_in,0.0) * m).xyz; -#if defined(ENABLE_TANGENT_INTERP) - tangent_in = (vec4(tangent_in,0.0) * m).xyz; -#endif - } - -#endif - -#ifdef ENABLE_AMBIENT_OCTREE - - ambient_octree_coords = (ambient_octree_transform * vertex_in).xyz; -#endif - - vertex_interp = (modelview * vertex_in).xyz; - normal_interp = normalize((modelview * vec4(normal_in,0.0)).xyz); - -#if defined(ENABLE_COLOR_INTERP) -#ifdef USE_COLOR_ATTRIB_SRGB_TO_LINEAR - - color_interp = vec4( - color_attrib.r<0.04045 ? color_attrib.r * (1.0 / 12.92) : pow((color_attrib.r + 0.055) * (1.0 / (1 + 0.055)), 2.4), - color_attrib.g<0.04045 ? color_attrib.g * (1.0 / 12.92) : pow((color_attrib.g + 0.055) * (1.0 / (1 + 0.055)), 2.4), - color_attrib.b<0.04045 ? color_attrib.b * (1.0 / 12.92) : pow((color_attrib.b + 0.055) * (1.0 / (1 + 0.055)), 2.4), - color_attrib.a - ); -#else - color_interp = color_attrib; -#endif -#endif - -#if defined(ENABLE_TANGENT_INTERP) - tangent_interp=normalize((modelview * vec4(tangent_in,0.0)).xyz); - binormal_interp = normalize( cross(normal_interp,tangent_interp) * binormalf ); -#endif - -#if defined(ENABLE_UV_INTERP) - uv_interp = uv_attrib; -#endif -#if defined(ENABLE_UV2_INTERP) - uv2_interp = uv2_attrib; -#endif - - float vertex_specular_exp = 40.0; //material_specular.a; - - - -VERTEX_SHADER_CODE - - -#ifdef USE_DUAL_PARABOLOID -//for dual paraboloid shadow mapping - highp vec3 vtx = vertex_interp; - vtx.z*=dual_paraboloid.y; //side to affect - vtx.z+=0.01; - dp_clip=vtx.z; - highp float len=length( vtx ); - vtx=normalize(vtx); - vtx.xy/=1.0+vtx.z; - vtx.z = len*dual_paraboloid.x; // it's a reciprocal(len - z_near) / (z_far - z_near); - vtx+=normalize(vtx)*0.025; - vtx.z = vtx.z * 2.0 - 1.0; // fit to clipspace - vertex_interp=vtx; - - //vertex_interp.w = z_clip; - -#endif - -#ifdef USE_SHADOW_PASS - - float z_ofs = shadow_z_offset; - z_ofs += (1.0-abs(normal_interp.z))*shadow_z_slope_scale; - vertex_interp.z-=z_ofs; -#endif - -#ifdef LIGHT_USE_SHADOW - - shadow_coord = shadow_matrix * vec4(vertex_interp,1.0); - shadow_coord.xyz/=shadow_coord.w; - -#ifdef LIGHT_USE_PSSM - shadow_coord.y*=0.5; - shadow_coord.y+=0.5; - shadow_coord2 = shadow_matrix2 * vec4(vertex_interp,1.0); - shadow_coord2.xyz/=shadow_coord2.w; - shadow_coord2.y*=0.5; -#endif -#ifdef LIGHT_USE_PSSM4 - shadow_coord.x*=0.5; - shadow_coord2.x*=0.5; - - shadow_coord3 = shadow_matrix3 * vec4(vertex_interp,1.0); - shadow_coord3.xyz/=shadow_coord3.w; - shadow_coord3.xy*=vec2(0.5); - shadow_coord3.xy+=vec2(0.5); - - shadow_coord4 = shadow_matrix4 * vec4(vertex_interp,1.0); - shadow_coord4.xyz/=shadow_coord4.w; - shadow_coord4.xy*=vec2(0.5); - shadow_coord4.x+=0.5; - -#endif - -#endif - -#ifdef USE_FOG - - fog_interp.a = pow( clamp( (length(vertex_interp)-fog_params.x)/(fog_params.y-fog_params.x), 0.0, 1.0 ), fog_params.z ); - fog_interp.rgb = mix( fog_color_begin, fog_color_end, fog_interp.a ); -#endif - -#ifndef VERTEX_SHADER_WRITE_POSITION -//vertex shader might write a position - gl_Position = projection_transform * vec4(vertex_interp,1.0); -#endif - - - -#if !defined(USE_DEPTH_SHADOWS) && defined(USE_SHADOW_PASS) - - position_interp=gl_Position; - -#endif - - -#ifdef USE_VERTEX_LIGHTING - - vec3 eye_vec = -normalize(vertex_interp); - -#ifdef LIGHT_TYPE_DIRECTIONAL - - vec3 light_dir = -light_direction; - float attenuation = light_attenuation.r; - - -#endif - -#ifdef LIGHT_TYPE_OMNI - vec3 light_dir = light_pos-vertex_interp; - float radius = light_attenuation.g; - float dist = min(length(light_dir),radius); - light_dir=normalize(light_dir); - float attenuation = pow( max(1.0 - dist/radius, 0.0), light_attenuation.b ) * light_attenuation.r; - -#endif - -#ifdef LIGHT_TYPE_SPOT - - vec3 light_dir = light_pos-vertex_interp; - float radius = light_attenuation.g; - float dist = min(length(light_dir),radius); - light_dir=normalize(light_dir); - float attenuation = pow( max(1.0 - dist/radius, 0.0), light_attenuation.b ) * light_attenuation.r; - vec3 spot_dir = light_direction; - float spot_cutoff=light_spot_attenuation.r; - float scos = max(dot(-light_dir, spot_dir),spot_cutoff); - float rim = (1.0 - scos) / (1.0 - spot_cutoff); - attenuation *= 1.0 - pow( rim, light_spot_attenuation.g); - - -#endif - -#if defined(LIGHT_TYPE_DIRECTIONAL) || defined(LIGHT_TYPE_OMNI) || defined(LIGHT_TYPE_SPOT) - - //process_shade(normal_interp,light_dir,eye_vec,vertex_specular_exp,attenuation,diffuse_interp,specular_interp); - { - float NdotL = max(0.0,dot( normal_interp, light_dir )); - vec3 half_vec = normalize(light_dir + eye_vec); - float eye_light = max(dot(normal_interp, half_vec),0.0); - diffuse_interp.rgb=light_diffuse * NdotL * attenuation; - diffuse_interp.a=attenuation; - if (NdotL > 0.0) { - specular_interp=light_specular * pow( eye_light, vertex_specular_exp ) * attenuation; - } else { - specular_interp=vec3(0.0); - } - } - -#else - -#ifdef SHADELESS - - diffuse_interp=vec4(vec3(1.0),0.0); - specular_interp=vec3(0.0); -# else - - diffuse_interp=vec4(0.0); - specular_interp=vec3(0.0); -# endif - -#endif - - - - -#endif - - -} - - -[fragment] - - -#ifdef USE_GLES_OVER_GL -#define mediump -#define highp -#define roundfix( m_val ) floor( (m_val) + 0.5 ) -#else - -precision mediump float; -precision mediump int; - -#endif - - -//hack to use uv if no uv present so it works with lightmap -#ifdef ENABLE_AMBIENT_LIGHTMAP - -#ifdef USE_LIGHTMAP_ON_UV2 - -#ifndef ENABLE_UV2_INTERP -#define ENABLE_UV2_INTERP -#endif - -#else - -#ifndef ENABLE_UV_INTERP -#define ENABLE_UV_INTERP -#endif - -#endif - -#endif - - -/* Varyings */ - -#if defined(ENABLE_COLOR_INTERP) -varying vec4 color_interp; -#endif - -#if defined(ENABLE_UV_INTERP) -varying vec2 uv_interp; -#endif - -#if defined(ENABLE_UV2_INTERP) -varying vec2 uv2_interp; -#endif - -#if defined(ENABLE_TANGENT_INTERP) -varying vec3 tangent_interp; -varying vec3 binormal_interp; -#endif - -#if defined(ENABLE_VAR1_INTERP) -varying vec4 var1_interp; -#endif - -#if defined(ENABLE_VAR2_INTERP) -varying vec4 var2_interp; -#endif - -#ifdef LIGHT_USE_PSSM -uniform vec3 light_pssm_split; -#endif - -varying vec3 vertex_interp; -varying vec3 normal_interp; - -#ifdef USE_FOG - -varying vec4 fog_interp; - -#endif - -/* Material Uniforms */ - -#ifdef USE_VERTEX_LIGHTING - -varying vec4 diffuse_interp; -varying vec3 specular_interp; - -#endif - -#if !defined(USE_DEPTH_SHADOWS) && defined(USE_SHADOW_PASS) - -varying vec4 position_interp; - -#endif - - - -uniform vec3 light_pos; -uniform vec3 light_direction; -uniform vec3 light_attenuation; -uniform vec3 light_spot_attenuation; -uniform vec3 light_diffuse; -uniform vec3 light_specular; - -uniform vec3 ambient_light; - - -#ifdef USE_FRAGMENT_LIGHTING - - - -# ifdef USE_DEPTH_SHADOWS -# else -# endif - -#endif - -uniform float const_light_mult; -uniform float time; - -#ifdef ENABLE_AMBIENT_OCTREE - -varying highp vec3 ambient_octree_coords; -uniform highp float ambient_octree_lattice_size; -uniform highp vec2 ambient_octree_pix_size; -uniform highp vec2 ambient_octree_light_pix_size; -uniform highp float ambient_octree_lattice_divide; -uniform highp sampler2D ambient_octree_tex; -uniform highp sampler2D ambient_octree_light_tex; -uniform float ambient_octree_multiplier; -uniform int ambient_octree_steps; - -#endif - -#ifdef ENABLE_AMBIENT_LIGHTMAP - -uniform highp sampler2D ambient_lightmap; -uniform float ambient_lightmap_multiplier; - -#endif - -#ifdef ENABLE_AMBIENT_DP_SAMPLER - -uniform highp sampler2D ambient_dp_sampler; -uniform float ambient_dp_sampler_multiplier; - -#endif - -#ifdef ENABLE_AMBIENT_COLOR - -uniform vec3 ambient_color; - -#endif - -FRAGMENT_SHADER_GLOBALS - - - -#ifdef LIGHT_USE_SHADOW - -varying highp vec4 shadow_coord; -#ifdef LIGHT_USE_PSSM -varying highp vec4 shadow_coord2; -#endif -#ifdef LIGHT_USE_PSSM4 -varying highp vec4 shadow_coord3; -varying highp vec4 shadow_coord4; -#endif - -uniform highp sampler2D shadow_texture; -uniform highp vec2 shadow_texel_size; - -uniform float shadow_darkening; - -#ifdef USE_DEPTH_SHADOWS - -#define SHADOW_DEPTH(m_tex,m_uv) (texture2D((m_tex),(m_uv)).z) - -#else - -//#define SHADOW_DEPTH(m_tex,m_uv) dot(texture2D((m_tex),(m_uv)),highp vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1) ) -#define SHADOW_DEPTH(m_tex,m_uv) dot(texture2D((m_tex),(m_uv)),vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1) ) - -#endif - -#ifdef USE_SHADOW_PCF - - -#ifdef USE_SHADOW_PCF_HQ - - -float SAMPLE_SHADOW_TEX( highp vec2 coord, highp float refdepth) { - - float avg=(SHADOW_DEPTH(shadow_texture,coord) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(shadow_texel_size.x,0.0)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(-shadow_texel_size.x,0.0)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(0.0,shadow_texel_size.y)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(0.0,-shadow_texel_size.y)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(shadow_texel_size.x,shadow_texel_size.y)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(-shadow_texel_size.x,shadow_texel_size.y)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(shadow_texel_size.x,-shadow_texel_size.y)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(-shadow_texel_size.x,-shadow_texel_size.y)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(shadow_texel_size.x*2.0,0.0)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(-shadow_texel_size.x*2.0,0.0)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(0.0,shadow_texel_size.y*2.0)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(0.0,-shadow_texel_size.y*2.0)) < refdepth ? 0.0 : 1.0); - return avg*(1.0/13.0); -} - -#else - -float SAMPLE_SHADOW_TEX( highp vec2 coord, highp float refdepth) { - - float avg=(SHADOW_DEPTH(shadow_texture,coord) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(shadow_texel_size.x,0.0)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(-shadow_texel_size.x,0.0)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(0.0,shadow_texel_size.y)) < refdepth ? 0.0 : 1.0); - avg+=(SHADOW_DEPTH(shadow_texture,coord+vec2(0.0,-shadow_texel_size.y)) < refdepth ? 0.0 : 1.0); - return avg*0.2; -} - -#endif - - - - -/* - 16x averaging -float SAMPLE_SHADOW_TEX( highp vec2 coord, highp float refdepth) { - - vec2 offset = vec2( - lessThan(vec2(0.25),fract(gl_FragCoord.xy * 0.5)) - ); - offset.y += offset.x; // y ^= x in floating point - - if (offset.y > 1.1) - offset.y = 0.0; - float avg = step( refdepth, SHADOW_DEPTH(shadow_texture, coord+ (offset + vec2(-1.5, 0.5))*shadow_texel_size) ); - avg+=step(refdepth, SHADOW_DEPTH(shadow_texture, coord+ (offset + vec2(0.5, 0.5))*shadow_texel_size) ); - avg+=step(refdepth, SHADOW_DEPTH(shadow_texture, coord+ (offset + vec2(-1.5, -1.5))*shadow_texel_size) ); - avg+=step(refdepth, SHADOW_DEPTH(shadow_texture, coord+ (offset + vec2(0.5, -1.5))*shadow_texel_size) ); - return avg * 0.25; -} -*/ - -/* -float SAMPLE_SHADOW_TEX( highp vec2 coord, highp float refdepth) { - - vec2 offset = vec2( - lessThan(vec2(0.25),fract(gl_FragCoord.xy * 0.5)) - ); - offset.y += offset.x; // y ^= x in floating point - - if (offset.y > 1.1) - offset.y = 0.0; - return step( refdepth, SHADOW_DEPTH(shadow_texture, coord+ offset*shadow_texel_size) ); - -} - -*/ -/* simple pcf4 */ -//#define SAMPLE_SHADOW_TEX(m_coord,m_depth) ((step(m_depth,SHADOW_DEPTH(shadow_texture,m_coord))+step(m_depth,SHADOW_DEPTH(shadow_texture,m_coord+vec2(0.0,shadow_texel_size.y)))+step(m_depth,SHADOW_DEPTH(shadow_texture,m_coord+vec2(shadow_texel_size.x,0.0)))+step(m_depth,SHADOW_DEPTH(shadow_texture,m_coord+shadow_texel_size)))/4.0) - -#endif - -#ifdef USE_SHADOW_ESM - -uniform float esm_multiplier; - -float SAMPLE_SHADOW_TEX(vec2 p_uv,float p_depth) { - -#if defined (USE_DEPTH_SHADOWS) - //these only are used if interpolation exists - highp float occluder = SHADOW_DEPTH(shadow_texture, p_uv); -#else - vec2 unnormalized = p_uv/shadow_texel_size; - vec2 fractional = fract(unnormalized); - unnormalized = floor(unnormalized); - - vec4 exponent; - exponent.x = SHADOW_DEPTH(shadow_texture, (unnormalized + vec2( -0.5, 0.5 )) * shadow_texel_size ); - exponent.y = SHADOW_DEPTH(shadow_texture, (unnormalized + vec2( 0.5, 0.5 )) * shadow_texel_size ); - exponent.z = SHADOW_DEPTH(shadow_texture, (unnormalized + vec2( 0.5, -0.5 )) * shadow_texel_size ); - exponent.w = SHADOW_DEPTH(shadow_texture, (unnormalized + vec2( -0.5, -0.5 )) * shadow_texel_size ); - - highp float occluder = (exponent.w + (exponent.x - exponent.w) * fractional.y); - occluder = occluder + ((exponent.z + (exponent.y - exponent.z) * fractional.y) - occluder)*fractional.x; -#endif - return clamp(exp(esm_multiplier* ( occluder - p_depth )),0.0,1.0); - -} - - -#endif - -#if !defined(USE_SHADOW_PCF) && !defined(USE_SHADOW_ESM) - -#define SAMPLE_SHADOW_TEX(m_coord,m_depth) (SHADOW_DEPTH(shadow_texture,m_coord) < m_depth ? 0.0 : 1.0) - -#endif - - -#endif - -#ifdef USE_DUAL_PARABOLOID - -varying float dp_clip; - -#endif - -uniform highp mat4 camera_inverse_transform; - -#if defined(ENABLE_TEXSCREEN) - -uniform vec2 texscreen_screen_mult; -uniform vec4 texscreen_screen_clamp; -uniform sampler2D texscreen_tex; - -#endif - -#if defined(ENABLE_SCREEN_UV) - -uniform vec2 screen_uv_mult; - -#endif - -void main() { - -#ifdef USE_DUAL_PARABOLOID - if (dp_clip<0.0) - discard; -#endif - - //lay out everything, whathever is unused is optimized away anyway - vec3 vertex = vertex_interp; - vec4 diffuse = vec4(0.9,0.9,0.9,1.0); - vec3 specular = vec3(0.0,0.0,0.0); - vec3 emission = vec3(0.0,0.0,0.0); - float specular_exp=1.0; - float glow=0.0; - float shade_param=0.0; -#ifdef DISABLE_FRONT_FACING - float side=float(1)*2.0-1.0; -#else - float side=float(gl_FrontFacing)*2.0-1.0; -#endif -#if defined(ENABLE_TANGENT_INTERP) - vec3 binormal = normalize(binormal_interp)*side; - vec3 tangent = normalize(tangent_interp)*side; -#endif - //vec3 normal = abs(normalize(normal_interp))*side; - vec3 normal = normalize(normal_interp)*side; -#if defined(ENABLE_SCREEN_UV) - vec2 screen_uv = gl_FragCoord.xy*screen_uv_mult; -#endif - -#if defined(ENABLE_UV_INTERP) - vec2 uv = uv_interp; -#endif - -#if defined(ENABLE_UV2_INTERP) - vec2 uv2 = uv2_interp; -#endif - -#if defined(ENABLE_COLOR_INTERP) - vec4 color = color_interp; -#endif - -#if defined(ENABLE_NORMALMAP) - - vec3 normalmap = vec3(0.0); -#endif - - float normaldepth=1.0; - - - -#if defined(ENABLE_DISCARD) - bool discard_=false; -#endif - -{ - - -FRAGMENT_SHADER_CODE - -} - -#if defined(ENABLE_NORMALMAP) - - normal = normalize( mix(normal_interp,tangent_interp * normalmap.x + binormal_interp * normalmap.y + normal_interp * normalmap.z,normaldepth) ) * side; - -#endif - -#if defined(ENABLE_DISCARD) - if (discard_) { - //easy to eliminate dead code - discard; - } -#endif - -#ifdef ENABLE_CLIP_ALPHA - if (diffuse.a<0.99) { - //used for doublepass and shadowmapping - discard; - } -#endif - - float shadow_attenuation = 1.0; - -#ifdef ENABLE_AMBIENT_LIGHTMAP - - vec3 ambientmap_color = vec3(0.0,0.0,0.0); - vec2 ambientmap_uv = vec2(0.0,0.0); - -#ifdef USE_LIGHTMAP_ON_UV2 - - ambientmap_uv = uv2_interp; - -#else - - ambientmap_uv = uv_interp; - -#endif - - vec4 amcol = texture2D(ambient_lightmap,ambientmap_uv); - shadow_attenuation=amcol.a; - ambientmap_color = amcol.rgb; - ambientmap_color*=ambient_lightmap_multiplier; - ambientmap_color*=diffuse.rgb; - - - -#endif - - -#ifdef ENABLE_AMBIENT_OCTREE - - vec3 ambientmap_color = vec3(0.0,0.0,0.0); - - - { - - //read position from initial lattice grid - highp vec3 lattice_pos = floor(ambient_octree_coords*ambient_octree_lattice_size); - highp vec2 octant_uv = highp vec2(lattice_pos.x+ambient_octree_lattice_size*lattice_pos.z,lattice_pos.y); - octant_uv=(octant_uv*highp vec2(2.0,4.0)+highp vec2(0.0,4.0)); - highp float ld = 1.0/ambient_octree_lattice_size; - - - //go down the octree - - for(int i=0;i<ambient_octree_steps;i++) { - - - highp vec3 sub=mod(ambient_octree_coords,ld); - ld*=0.5; - highp vec3 s = step(ld,sub); - octant_uv+=s.xy; - octant_uv.y+=s.z*2.0; - octant_uv=(octant_uv+0.5)*ambient_octree_pix_size; - highp vec4 new_uv = texture2D(ambient_octree_tex,octant_uv); - octant_uv=floor(highp vec2( dot(new_uv.xy,highp vec2(65280.0,255.0)), dot(new_uv.zw,highp vec2(65280.0,255.0)) )+0.5);//+ambient_octree_pix_size*0.5; - - } - - //sample color - octant_uv=(octant_uv+0.5)*ambient_octree_light_pix_size; - highp vec3 sub=(mod(ambient_octree_coords,ld)/ld); - octant_uv.xy+=sub.xy*ambient_octree_light_pix_size.xy; - vec3 col_up=texture2D(ambient_octree_light_tex,octant_uv).rgb; - octant_uv.y+=ambient_octree_light_pix_size.y*2.0; - vec3 col_down=texture2D(ambient_octree_light_tex,octant_uv).rgb; - ambientmap_color=mix(col_up,col_down,sub.z)*ambient_octree_multiplier; - - ambientmap_color*=diffuse.rgb; - - } - -#endif - - - -#ifdef ENABLE_AMBIENT_DP_SAMPLER - - vec3 ambientmap_color = vec3(0.0,0.0,0.0); - - { - - vec3 dp_normal = normalize((vec4(normal,0) * camera_inverse_transform).xyz); - vec2 ambient_uv = (dp_normal.xy / (1.0+abs(dp_normal.z)))*0.5+0.5; //dual paraboloid - ambient_uv.y*=0.5; - if (dp_normal.z<0) { - - ambient_uv.y=(0.5-ambient_uv.y)+0.5; - - } - - ambientmap_color = texture2D(ambient_dp_sampler,ambient_uv ).rgb * ambient_dp_sampler_multiplier; - ambientmap_color*=diffuse.rgb; - } - -#endif - - - - -#ifdef LIGHT_USE_SHADOW -#ifdef LIGHT_TYPE_DIRECTIONAL - - float shadow_fade_exponent=5.0; //hardcoded for now - float shadow_fade=pow(length(vertex_interp)/light_attenuation.g,shadow_fade_exponent); - -// optimization - skip shadows outside visible range - if(shadow_fade<1.0){ - -#ifdef LIGHT_USE_PSSM - - - //if (vertex_interp.z > light_pssm_split) { -#if 0 - highp vec3 splane = vec3(0.0,0.0,0.0); - - if (gl_FragCoord.w > light_pssm_split.x) { - - splane = shadow_coord.xyz; - splane.y+=1.0; - } else { - splane = shadow_coord2.xyz; - } - splane.y*=0.5; - shadow_attenuation=SAMPLE_SHADOW_TEX(splane.xy,splane.z); - -#else -/* - float sa_a = SAMPLE_SHADOW_TEX(shadow_coord.xy,shadow_coord.z); - float sa_b = SAMPLE_SHADOW_TEX(shadow_coord2.xy,shadow_coord2.z); - if (gl_FragCoord.w > light_pssm_split.x) { - shadow_attenuation=sa_a; - } else { - shadow_attenuation=sa_b; - } -*/ - - vec2 pssm_coord; - float pssm_z; - -#if defined(LIGHT_USE_PSSM) && defined(USE_SHADOW_ESM) -#define USE_PSSM_BLEND - float pssm_blend; - vec2 pssm_coord_2; - float pssm_z_2; - vec3 light_pssm_split_inv = 1.0/light_pssm_split; - float w_inv = 1.0/gl_FragCoord.w; -#endif - -#ifdef LIGHT_USE_PSSM4 - - - if (gl_FragCoord.w > light_pssm_split.y) { - - if (gl_FragCoord.w > light_pssm_split.x) { - pssm_coord=shadow_coord.xy; - pssm_z=shadow_coord.z; -#if defined(USE_PSSM_BLEND) - pssm_coord_2=shadow_coord2.xy; - pssm_z_2=shadow_coord2.z; - pssm_blend=smoothstep(0.0,light_pssm_split_inv.x,w_inv); -#endif - - } else { - pssm_coord=shadow_coord2.xy; - pssm_z=shadow_coord2.z; -#if defined(USE_PSSM_BLEND) - pssm_coord_2=shadow_coord3.xy; - pssm_z_2=shadow_coord3.z; - pssm_blend=smoothstep(light_pssm_split_inv.x,light_pssm_split_inv.y,w_inv); -#endif - - } - } else { - - - if (gl_FragCoord.w > light_pssm_split.z) { - pssm_coord=shadow_coord3.xy; - pssm_z=shadow_coord3.z; -#if defined(USE_PSSM_BLEND) - pssm_coord_2=shadow_coord4.xy; - pssm_z_2=shadow_coord4.z; - pssm_blend=smoothstep(light_pssm_split_inv.y,light_pssm_split_inv.z,w_inv); -#endif - - } else { - pssm_coord=shadow_coord4.xy; - pssm_z=shadow_coord4.z; -#if defined(USE_PSSM_BLEND) - pssm_coord_2=shadow_coord4.xy; - pssm_z_2=shadow_coord4.z; - pssm_blend=0.0; -#endif - - } - } - -#else - - if (gl_FragCoord.w > light_pssm_split.x) { - pssm_coord=shadow_coord.xy; - pssm_z=shadow_coord.z; -#if defined(USE_PSSM_BLEND) - pssm_coord_2=shadow_coord2.xy; - pssm_z_2=shadow_coord2.z; - pssm_blend=smoothstep(0.0,light_pssm_split_inv.x,w_inv); -#endif - - } else { - pssm_coord=shadow_coord2.xy; - pssm_z=shadow_coord2.z; -#if defined(USE_PSSM_BLEND) - pssm_coord_2=shadow_coord2.xy; - pssm_z_2=shadow_coord2.z; - pssm_blend=0.0; -#endif - - } - -#endif - - //one one sample - shadow_attenuation=SAMPLE_SHADOW_TEX(pssm_coord,pssm_z); -#if defined(USE_PSSM_BLEND) - shadow_attenuation=mix(shadow_attenuation,SAMPLE_SHADOW_TEX(pssm_coord_2,pssm_z_2),pssm_blend); -#endif - - -#endif - -#else - - shadow_attenuation=SAMPLE_SHADOW_TEX(shadow_coord.xy,shadow_coord.z); -#endif - - shadow_attenuation=mix(shadow_attenuation,1.0,shadow_fade); - }else{ - shadow_attenuation=1.0; - }; - -#endif - -#ifdef LIGHT_TYPE_OMNI - - vec3 splane=shadow_coord.xyz;///shadow_coord.w; - float shadow_len=length(splane); - splane=normalize(splane); - float vofs=0.0; - - if (splane.z>=0.0) { - - splane.z+=1.0; - } else { - - splane.z=1.0 - splane.z; - vofs=0.5; - } - splane.xy/=splane.z; - splane.xy=splane.xy * 0.5 + 0.5; - float lradius = light_attenuation.g; - splane.z = shadow_len / lradius; - splane.y=clamp(splane.y,0.0,1.0)*0.5+vofs; - - shadow_attenuation=SAMPLE_SHADOW_TEX(splane.xy,splane.z); -#endif - -#ifdef LIGHT_TYPE_SPOT - - shadow_attenuation=SAMPLE_SHADOW_TEX(shadow_coord.xy,shadow_coord.z); -#endif - - shadow_attenuation=mix(shadow_attenuation,1.0,shadow_darkening); -#endif - - -#ifdef USE_FRAGMENT_LIGHTING - - vec3 eye_vec = -normalize(vertex); - -#ifdef LIGHT_TYPE_DIRECTIONAL - - vec3 light_dir = -light_direction; - float attenuation = light_attenuation.r; - - -#endif - -#ifdef LIGHT_TYPE_OMNI - - vec3 light_dir = light_pos-vertex; - float radius = light_attenuation.g; - float dist = min(length(light_dir),radius); - light_dir=normalize(light_dir); - float attenuation = pow( max(1.0 - dist/radius, 0.0), light_attenuation.b ) * light_attenuation.r; - -#endif - - -#ifdef LIGHT_TYPE_SPOT - - vec3 light_dir = light_pos-vertex; - float radius = light_attenuation.g; - float dist = min(length(light_dir),radius); - light_dir=normalize(light_dir); - float attenuation = pow( max(1.0 - dist/radius, 0.0), light_attenuation.b ) * light_attenuation.r; - vec3 spot_dir = light_direction; - float spot_cutoff=light_spot_attenuation.r; - float scos = max(dot(-light_dir, spot_dir),spot_cutoff); - float rim = (1.0 - scos) / (1.0 - spot_cutoff); - attenuation *= 1.0 - pow( rim, light_spot_attenuation.g); - -#endif - -# if defined(LIGHT_TYPE_DIRECTIONAL) || defined(LIGHT_TYPE_OMNI) || defined (LIGHT_TYPE_SPOT) - - { - - vec3 mdiffuse = diffuse.rgb; - vec3 light; - -#if defined(USE_OUTPUT_SHADOW_COLOR) - vec3 shadow_color=vec3(0.0,0.0,0.0); -#endif - -#if defined(USE_LIGHT_SHADER_CODE) -//light is written by the light shader -{ - -LIGHT_SHADER_CODE - -} -#else -//traditional lambert + blinn - float NdotL = max(0.0,dot( normal, light_dir )); - vec3 half_vec = normalize(light_dir + eye_vec); - float eye_light = max(dot(normal, half_vec),0.0); - - light = light_diffuse * mdiffuse * NdotL; - if (NdotL > 0.0) { - light+=specular * light_specular * pow( eye_light, specular_exp ); - } -#endif - diffuse.rgb = const_light_mult * ambient_light *diffuse.rgb + light * attenuation * shadow_attenuation; - -#if defined(USE_OUTPUT_SHADOW_COLOR) - diffuse.rgb += light * shadow_color * attenuation * (1.0 - shadow_attenuation); -#endif - -#ifdef USE_FOG - - diffuse.rgb = mix(diffuse.rgb,fog_interp.rgb,fog_interp.a); - -# if defined(LIGHT_TYPE_OMNI) || defined (LIGHT_TYPE_SPOT) - diffuse.rgb = mix(mix(vec3(0.0),diffuse.rgb,attenuation),diffuse.rgb,const_light_mult); -# endif - - -#endif - - - } - - -# endif - -# if !defined(LIGHT_TYPE_DIRECTIONAL) && !defined(LIGHT_TYPE_OMNI) && !defined (LIGHT_TYPE_SPOT) -//none -#ifndef SHADELESS - diffuse.rgb=ambient_light *diffuse.rgb; -#endif - -# endif - - diffuse.rgb+=const_light_mult*emission; - -#endif - - - - -#ifdef USE_VERTEX_LIGHTING - - vec3 ambient = const_light_mult*ambient_light*diffuse.rgb; -# if defined(LIGHT_TYPE_OMNI) || defined (LIGHT_TYPE_SPOT) - //ambient*=diffuse_interp.a; //attenuation affects ambient too - -# endif - - //diffuse.rgb=(diffuse.rgb * diffuse_interp.rgb + specular * specular_interp)*shadow_attenuation + ambient; - //diffuse.rgb+=emission * const_light_mult; - diffuse.rgb=(diffuse.rgb * diffuse_interp.rgb + specular * specular_interp)*shadow_attenuation + ambient; - diffuse.rgb+=emission * const_light_mult; - -#ifdef USE_FOG - - diffuse.rgb = mix(diffuse.rgb,fog_interp.rgb,fog_interp.a); - -# if defined(LIGHT_TYPE_OMNI) || defined (LIGHT_TYPE_SPOT) - diffuse.rgb = mix(mix(vec3(0.0),diffuse.rgb,diffuse_interp.a),diffuse.rgb,const_light_mult); -# endif - -#endif - -#endif - - -#if defined(ENABLE_AMBIENT_OCTREE) || defined(ENABLE_AMBIENT_LIGHTMAP) || defined(ENABLE_AMBIENT_DP_SAMPLER) -#if defined(ENABLE_AMBIENT_COLOR) - ambientmap_color*=ambient_color; -#endif - diffuse.rgb+=ambientmap_color; -#endif - - -#ifdef USE_SHADOW_PASS - -#ifdef USE_DEPTH_SHADOWS - - //do nothing, depth is just written -#else - // pack depth to rgba - //highp float bias = 0.0005; - highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0;//bias; - highp vec4 comp = fract(depth * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0)); - comp -= comp.xxyz * vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); - gl_FragColor = comp; - -#endif - -#else - - - -#ifdef USE_GLOW - - diffuse.a=glow; -#endif - -#ifdef USE_8BIT_HDR - diffuse.rgb*=0.25; -#endif - - gl_FragColor = diffuse; -#endif -} - - diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 376a208559..74e844836e 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h index 29f889cc88..bf07b8b08b 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 274782c997..d1c8ccfe21 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/rasterizer_gles3.h b/drivers/gles3/rasterizer_gles3.h index 4bc267ec7e..4bfec09bf3 100644 --- a/drivers/gles3/rasterizer_gles3.h +++ b/drivers/gles3/rasterizer_gles3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 1035e9293a..9c7a1dd859 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index 94781c53e8..1ab2afe664 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index dcf8ef2277..c5c9140874 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index b0cb04569e..c74b127b23 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index c014caee8d..d793ea446d 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -626,13 +626,11 @@ Error ShaderCompilerGLES3::compile(VS::ShaderMode p_mode, const String &p_code, Error err = parser.compile(p_code, ShaderTypes::get_singleton()->get_functions(p_mode), ShaderTypes::get_singleton()->get_modes(p_mode), ShaderTypes::get_singleton()->get_types()); if (err != OK) { -#if 1 Vector<String> shader = p_code.split("\n"); for (int i = 0; i < shader.size(); i++) { print_line(itos(i) + " " + shader[i]); } -#endif _err_print_error(NULL, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER); return err; diff --git a/drivers/gles3/shader_compiler_gles3.h b/drivers/gles3/shader_compiler_gles3.h index e79fdb3ba3..46bb6b1b9e 100644 --- a/drivers/gles3/shader_compiler_gles3.h +++ b/drivers/gles3/shader_compiler_gles3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 20956ad644..d4ef256a33 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h index 6a399a74cc..3be0e86496 100644 --- a/drivers/gles3/shader_gles3.h +++ b/drivers/gles3/shader_gles3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/gles3/shaders/SCsub b/drivers/gles3/shaders/SCsub index 0c69c8cf74..f1811fa7b5 100644 --- a/drivers/gles3/shaders/SCsub +++ b/drivers/gles3/shaders/SCsub @@ -2,7 +2,7 @@ Import('env') -if env['BUILDERS'].has_key('GLES3_GLSL'): +if 'GLES3_GLSL' in env['BUILDERS']: env.GLES3_GLSL('copy.glsl'); env.GLES3_GLSL('resolve.glsl'); env.GLES3_GLSL('canvas.glsl'); diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index c9e9dacdb5..c1504593cb 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1971,7 +1971,6 @@ FRAGMENT_SHADER_CODE #ifdef SHADELESS - frag_color=vec4(albedo,alpha); diffuse_buffer=vec4(albedo.rgb,0.0); specular_buffer=vec4(0.0); diff --git a/drivers/png/image_loader_png.cpp b/drivers/png/image_loader_png.cpp index 30ec8cd036..46c9442ffc 100644 --- a/drivers/png/image_loader_png.cpp +++ b/drivers/png/image_loader_png.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/png/image_loader_png.h b/drivers/png/image_loader_png.h index c11e25e1a4..fe14108194 100644 --- a/drivers/png/image_loader_png.h +++ b/drivers/png/image_loader_png.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index 876fb820b2..98a3f21245 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/png/resource_saver_png.h b/drivers/png/resource_saver_png.h index 31ec35c192..a9ff6db86a 100644 --- a/drivers/png/resource_saver_png.h +++ b/drivers/png/resource_saver_png.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index 5acf9bf46e..356b1ad958 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h index 3ce031e616..2f56726617 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.h +++ b/drivers/pulseaudio/audio_driver_pulseaudio.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp index ca2f03c75a..ffe7d77a4a 100644 --- a/drivers/register_driver_types.cpp +++ b/drivers/register_driver_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/register_driver_types.h b/drivers/register_driver_types.h index 63c50f6720..f02db428ce 100644 --- a/drivers/register_driver_types.h +++ b/drivers/register_driver_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp index 8466f55afc..8e52b53ad6 100644 --- a/drivers/rtaudio/audio_driver_rtaudio.cpp +++ b/drivers/rtaudio/audio_driver_rtaudio.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/rtaudio/audio_driver_rtaudio.h b/drivers/rtaudio/audio_driver_rtaudio.h index c2a18b2731..858a51eb73 100644 --- a/drivers/rtaudio/audio_driver_rtaudio.h +++ b/drivers/rtaudio/audio_driver_rtaudio.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/SCsub b/drivers/unix/SCsub index 96efc91b7a..5ced44dfda 100644 --- a/drivers/unix/SCsub +++ b/drivers/unix/SCsub @@ -8,7 +8,7 @@ g_set_p += 'String OS_Unix::get_global_settings_path() const {\n' g_set_p += '\treturn "' + env["unix_global_settings_path"] + '";\n' g_set_p += '}\n' g_set_p += '#endif' -f = open("os_unix_global_settings_path.gen.cpp", "wb") +f = open("os_unix_global_settings_path.gen.cpp", "w") f.write(g_set_p) f.close() diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp index cf54f3fea0..ddc3b2ed33 100644 --- a/drivers/unix/dir_access_unix.cpp +++ b/drivers/unix/dir_access_unix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -194,21 +194,9 @@ Error DirAccessUnix::make_dir(String p_dir) { p_dir = fix_path(p_dir); -#if 1 - - bool success = (mkdir(p_dir.utf8().get_data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0); - int err = errno; - -#else - char real_current_dir_name[2048]; - getcwd(real_current_dir_name, 2048); - chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants - bool success = (mkdir(p_dir.utf8().get_data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0); int err = errno; - chdir(real_current_dir_name); -#endif if (success) { return OK; }; diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h index e4b294a802..ea0df2fa3f 100644 --- a/drivers/unix/dir_access_unix.h +++ b/drivers/unix/dir_access_unix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index e2f04aec63..d5a66d9a1c 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h index 3c4b9c0c25..6e5110431f 100644 --- a/drivers/unix/file_access_unix.h +++ b/drivers/unix/file_access_unix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index f55b75c1d9..77c942c673 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/ip_unix.h b/drivers/unix/ip_unix.h index 952d3a8771..1f3b885635 100644 --- a/drivers/unix/ip_unix.h +++ b/drivers/unix/ip_unix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/mutex_posix.cpp b/drivers/unix/mutex_posix.cpp index 94cfcf78e3..c8fe9e0749 100644 --- a/drivers/unix/mutex_posix.cpp +++ b/drivers/unix/mutex_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/mutex_posix.h b/drivers/unix/mutex_posix.h index b3c0cbe051..20d546c72a 100644 --- a/drivers/unix/mutex_posix.h +++ b/drivers/unix/mutex_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 0f4e8f757c..992b12b7cd 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 115bdc2d65..19e79728fb 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp index b21990a866..b743990b92 100644 --- a/drivers/unix/packet_peer_udp_posix.cpp +++ b/drivers/unix/packet_peer_udp_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/packet_peer_udp_posix.h b/drivers/unix/packet_peer_udp_posix.h index d8b08818b0..e580d336b2 100644 --- a/drivers/unix/packet_peer_udp_posix.h +++ b/drivers/unix/packet_peer_udp_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/rw_lock_posix.cpp b/drivers/unix/rw_lock_posix.cpp index 25bc8f0bd3..ab2d6495bd 100644 --- a/drivers/unix/rw_lock_posix.cpp +++ b/drivers/unix/rw_lock_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/rw_lock_posix.h b/drivers/unix/rw_lock_posix.h index f8199aeb54..40b41ce171 100644 --- a/drivers/unix/rw_lock_posix.h +++ b/drivers/unix/rw_lock_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/semaphore_posix.cpp b/drivers/unix/semaphore_posix.cpp index 8b553194db..093c6b663a 100644 --- a/drivers/unix/semaphore_posix.cpp +++ b/drivers/unix/semaphore_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/semaphore_posix.h b/drivers/unix/semaphore_posix.h index c7a7f9bd87..e33de78545 100644 --- a/drivers/unix/semaphore_posix.h +++ b/drivers/unix/semaphore_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/socket_helpers.h b/drivers/unix/socket_helpers.h index 5fa727a9b9..3fc0144294 100644 --- a/drivers/unix/socket_helpers.h +++ b/drivers/unix/socket_helpers.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp index 30843e4947..3bc2397e6f 100644 --- a/drivers/unix/stream_peer_tcp_posix.cpp +++ b/drivers/unix/stream_peer_tcp_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/stream_peer_tcp_posix.h b/drivers/unix/stream_peer_tcp_posix.h index 3f28f82b50..4c3504714c 100644 --- a/drivers/unix/stream_peer_tcp_posix.h +++ b/drivers/unix/stream_peer_tcp_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/tcp_server_posix.cpp b/drivers/unix/tcp_server_posix.cpp index a8554d07a3..f3f9ab82f1 100644 --- a/drivers/unix/tcp_server_posix.cpp +++ b/drivers/unix/tcp_server_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/tcp_server_posix.h b/drivers/unix/tcp_server_posix.h index 947050ab8a..a10bafcafe 100644 --- a/drivers/unix/tcp_server_posix.h +++ b/drivers/unix/tcp_server_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp index 3b895ff9c1..2dd0b4a70a 100644 --- a/drivers/unix/thread_posix.cpp +++ b/drivers/unix/thread_posix.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/unix/thread_posix.h b/drivers/unix/thread_posix.h index 21e1d290a9..a188d9c346 100644 --- a/drivers/unix/thread_posix.h +++ b/drivers/unix/thread_posix.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 76665f0203..6d6a6027d9 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/dir_access_windows.h b/drivers/windows/dir_access_windows.h index a352415fd6..cb0fffdd47 100644 --- a/drivers/windows/dir_access_windows.h +++ b/drivers/windows/dir_access_windows.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index bb133b9899..30c8332fa3 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h index de5fc2bc09..6956e7855a 100644 --- a/drivers/windows/file_access_windows.h +++ b/drivers/windows/file_access_windows.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/mutex_windows.cpp b/drivers/windows/mutex_windows.cpp index 7d9bc22e51..d862d528e3 100644 --- a/drivers/windows/mutex_windows.cpp +++ b/drivers/windows/mutex_windows.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/mutex_windows.h b/drivers/windows/mutex_windows.h index 2e000a43f5..2f436b5754 100644 --- a/drivers/windows/mutex_windows.h +++ b/drivers/windows/mutex_windows.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/rw_lock_windows.cpp b/drivers/windows/rw_lock_windows.cpp index e2213be9c1..5cbedeba2f 100644 --- a/drivers/windows/rw_lock_windows.cpp +++ b/drivers/windows/rw_lock_windows.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/rw_lock_windows.h b/drivers/windows/rw_lock_windows.h index eb030d6029..15911c21e7 100644 --- a/drivers/windows/rw_lock_windows.h +++ b/drivers/windows/rw_lock_windows.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/semaphore_windows.cpp b/drivers/windows/semaphore_windows.cpp index 3a5c0b054c..c88329d56c 100644 --- a/drivers/windows/semaphore_windows.cpp +++ b/drivers/windows/semaphore_windows.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/semaphore_windows.h b/drivers/windows/semaphore_windows.h index 90aacc7e26..8e242ae148 100644 --- a/drivers/windows/semaphore_windows.h +++ b/drivers/windows/semaphore_windows.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/shell_windows.cpp b/drivers/windows/shell_windows.cpp index 17ff9fe962..139a8756fb 100644 --- a/drivers/windows/shell_windows.cpp +++ b/drivers/windows/shell_windows.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/shell_windows.h b/drivers/windows/shell_windows.h index d94c5812d1..de4fdc4d73 100644 --- a/drivers/windows/shell_windows.h +++ b/drivers/windows/shell_windows.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/thread_windows.cpp b/drivers/windows/thread_windows.cpp index 01ddf42649..2ff4715b1c 100644 --- a/drivers/windows/thread_windows.cpp +++ b/drivers/windows/thread_windows.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/windows/thread_windows.h b/drivers/windows/thread_windows.h index 143825039c..2c3a325f88 100644 --- a/drivers/windows/thread_windows.h +++ b/drivers/windows/thread_windows.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp index 42c4c40300..1bd338ead9 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.cpp +++ b/drivers/xaudio2/audio_driver_xaudio2.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h index 7c1d31b57c..27ef2ebcb8 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.h +++ b/drivers/xaudio2/audio_driver_xaudio2.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/SCsub b/editor/SCsub index fd56c9d772..172447147c 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -4,6 +4,7 @@ Import('env') env.editor_sources = [] import os +from compat import encode_utf8, byte_to_str, open_utf8 def make_certs_header(target, source, env): @@ -11,7 +12,7 @@ def make_certs_header(target, source, env): src = source[0].srcnode().abspath dst = target[0].srcnode().abspath f = open(src, "rb") - g = open(dst, "wb") + g = open_utf8(dst, "w") buf = f.read() decomp_size = len(buf) import zlib @@ -24,7 +25,7 @@ def make_certs_header(target, source, env): g.write("static const int _certs_uncompressed_size=" + str(decomp_size) + ";\n") g.write("static const unsigned char _certs_compressed[]={\n") for i in range(len(buf)): - g.write(str(ord(buf[i])) + ",\n") + g.write(byte_to_str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") @@ -32,20 +33,20 @@ def make_certs_header(target, source, env): def make_doc_header(target, source, env): dst = target[0].srcnode().abspath - g = open(dst, "wb") + g = open_utf8(dst, "w") buf = "" docbegin = "" docend = "" for s in source: src = s.srcnode().abspath - f = open(src, "rb") + f = open_utf8(src, "r") content = f.read() buf += content[content.find("<class"): content.rfind("</doc>")] if len(docbegin) == 0: docbegin = content[0: content.find("<class")] if len(docend) == 0: docend = content[content.rfind("</doc>"): len(buf)] - buf = docbegin + buf + docend + buf = encode_utf8(docbegin + buf + docend) decomp_size = len(buf) import zlib buf = zlib.compress(buf) @@ -57,7 +58,7 @@ def make_doc_header(target, source, env): g.write("static const int _doc_data_uncompressed_size=" + str(decomp_size) + ";\n") g.write("static const unsigned char _doc_data_compressed[]={\n") for i in range(len(buf)): - g.write(str(ord(buf[i])) + ",\n") + g.write(byte_to_str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") @@ -66,7 +67,7 @@ def make_fonts_header(target, source, env): dst = target[0].srcnode().abspath - g = open(dst, "wb") + g = open_utf8(dst, "w") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _EDITOR_FONTS_H\n") @@ -75,7 +76,6 @@ def make_fonts_header(target, source, env): # saving uncompressed, since freetype will reference from memory pointer xl_names = [] for i in range(len(source)): - print("Appending font: " + source[i].srcnode().abspath) f = open(source[i].srcnode().abspath, "rb") buf = f.read() import os.path @@ -85,7 +85,7 @@ def make_fonts_header(target, source, env): g.write("static const int _font_" + name + "_size=" + str(len(buf)) + ";\n") g.write("static const unsigned char _font_" + name + "[]={\n") for i in range(len(buf)): - g.write(str(ord(buf[i])) + ",\n") + g.write(byte_to_str(buf[i]) + ",\n") g.write("};\n") @@ -96,7 +96,7 @@ def make_translations_header(target, source, env): dst = target[0].srcnode().abspath - g = open(dst, "wb") + g = open_utf8(dst, "w") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _EDITOR_TRANSLATIONS_H\n") @@ -110,7 +110,6 @@ def make_translations_header(target, source, env): xl_names = [] for i in range(len(sorted_paths)): - print("Appending translation: " + sorted_paths[i]) f = open(sorted_paths[i], "rb") buf = f.read() decomp_size = len(buf) @@ -121,7 +120,7 @@ def make_translations_header(target, source, env): #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n") g.write("static const unsigned char _translation_" + name + "_compressed[]={\n") for i in range(len(buf)): - g.write(str(ord(buf[i])) + ",\n") + g.write(byte_to_str(buf[i]) + ",\n") g.write("};\n") @@ -148,8 +147,8 @@ def make_authors_header(target, source, env): src = source[0].srcnode().abspath dst = target[0].srcnode().abspath - f = open(src, "rb") - g = open(dst, "wb") + f = open_utf8(src, "r") + g = open_utf8(dst, "w") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _EDITOR_AUTHORS_H\n") @@ -190,9 +189,9 @@ def make_license_header(target, source, env): src_copyright = source[0].srcnode().abspath src_license = source[1].srcnode().abspath dst = target[0].srcnode().abspath - f = open(src_license, "rb") - fc = open(src_copyright, "rb") - g = open(dst, "wb") + f = open_utf8(src_license, "r") + fc = open_utf8(src_copyright, "r") + g = open_utf8(dst, "w") g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _EDITOR_LICENSE_H\n") @@ -353,10 +352,10 @@ 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 += '\tregister_' + 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.gen.cpp", "wb") + f = open_utf8("register_exporters.gen.cpp", "w") f.write(reg_exporters_inc) f.write(reg_exporters) f.close() @@ -381,14 +380,12 @@ if (env["tools"] == "yes"): # Translations tlist = glob.glob(path + "/translations/*.po") - print("translations: ", tlist) env.Depends('#editor/translations.gen.h', tlist) env.Command('#editor/translations.gen.h', tlist, make_translations_header) # Fonts flist = glob.glob(path + "/../thirdparty/fonts/*.ttf") flist.append(glob.glob(path + "/../thirdparty/fonts/*.otf")) - print("fonts: ", flist) env.Depends('#editor/builtin_fonts.gen.h', flist) env.Command('#editor/builtin_fonts.gen.h', flist, make_fonts_header) @@ -408,7 +405,6 @@ if (env["tools"] == "yes"): SConscript('fileserver/SCsub') SConscript('icons/SCsub') SConscript('import/SCsub') - SConscript('io_plugins/SCsub') SConscript('plugins/SCsub') lib = env.Library("editor", env.editor_sources) diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 5b24baabea..702adf0c68 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -38,6 +38,7 @@ #include "pair.h" #include "scene/gui/separator.h" #include "scene/main/viewport.h" + /* Missing to fix: *Set @@ -2684,17 +2685,6 @@ void AnimationKeyEditor::_track_editor_gui_input(const Ref<InputEvent> &p_input) Point2 mpos = mm->get_position() - ofs; if (mpos.y < h) { -#if 0 - //seek - //int zoomw = settings_limit-name_limit; - float scale = _get_zoom_scale(); - float pos = h_scroll->get_val() + (mpos.y-name_limit) / scale; - if (pos<0 ) - pos=0; - if (pos>=animation->get_length()) - pos=animation->get_length(); - timeline->set_val(pos); -#endif return; } diff --git a/editor/animation_editor.h b/editor/animation_editor.h index 9eacafb021..c16072502b 100644 --- a/editor/animation_editor.h +++ b/editor/animation_editor.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/array_property_edit.cpp b/editor/array_property_edit.cpp index 7ef24cf627..bcf1600b36 100644 --- a/editor/array_property_edit.cpp +++ b/editor/array_property_edit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/array_property_edit.h b/editor/array_property_edit.h index 1bc82e22a1..c028c45b04 100644 --- a/editor/array_property_edit.h +++ b/editor/array_property_edit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/call_dialog.cpp b/editor/call_dialog.cpp deleted file mode 100644 index 32b9fc1254..0000000000 --- a/editor/call_dialog.cpp +++ /dev/null @@ -1,342 +0,0 @@ -/*************************************************************************/ -/* call_dialog.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "call_dialog.h" - -#if 0 -#include "class_db.h" -#include "print_string.h" -#include "scene/gui/label.h" - - -class CallDialogParams : public Object { - - GDCLASS( CallDialogParams, Object ); -public: - - bool _set(const StringName& p_name, const Variant& p_value) { - - values[p_name]=p_value; - return true; - } - - bool _get(const StringName& p_name,Variant &r_ret) const { - - if (values.has(p_name)) { - r_ret=values[p_name]; - return true; - } - return false; - } - - void _get_property_list( List<PropertyInfo> *p_list) const { - - for(int i=0;i<method.arguments.size();i++) - p_list->push_back(method.arguments[i]); - } - - MethodInfo method; - HashMap<String,Variant> values; - - CallDialogParams() {} -}; - - -void CallDialog::_notification(int p_what) { - - if (p_what==NOTIFICATION_READY) { - - call->connect("pressed", this,"_call"); - cancel->connect("pressed", this,"_cancel"); - //filter->get_path()->connect("text_changed", this,"_text_changed"); - _update_method_list(); - } - - if (p_what==NOTIFICATION_EXIT_TREE) { - - call->disconnect("pressed", this,"_call"); - cancel->disconnect("pressed", this,"_cancel"); - - //filter->get_path()->connect("text_changed", this,"_text_changed"); - _update_method_list(); - } - - if (p_what==NOTIFICATION_DRAW) { - - RID ci = get_canvas_item(); - get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size())); - } -} - - -void CallDialog::_call() { - - if (!tree->get_selected()) - return; - - TreeItem* item=tree->get_selected(); - ERR_FAIL_COND(!item); - int idx=item->get_metadata(0); - ERR_FAIL_INDEX(idx,methods.size()); - MethodInfo &m = methods[idx]; - - Variant args[VARIANT_ARG_MAX]; - - for(int i=0;i<VARIANT_ARG_MAX;i++) { - - if (i>=m.arguments.size()) - continue; - - if (call_params->values.has(m.arguments[i].name)) - args[i]=call_params->values[m.arguments[i].name]; - } - - Variant ret = object->call(m.name,args[0],args[1],args[2],args[3],args[4]); - if (ret.get_type()!=Variant::NIL) - return_value->set_text(ret); - else - return_value->set_text(""); -} - -void CallDialog::_cancel() { - - hide(); -} - - -void CallDialog::_item_selected() { - - TreeItem* item=tree->get_selected(); - ERR_FAIL_COND(!item); - - if (item->get_metadata(0).get_type()==Variant::NIL) { - - call->set_disabled(true); - return; - } - - call->set_disabled(false); - - int idx=item->get_metadata(0); - ERR_FAIL_INDEX(idx,methods.size()); - - MethodInfo &m = methods[idx]; - - call_params->values.clear(); - call_params->method=m; - - property_editor->edit(call_params); - property_editor->update_tree(); - - -} - -void CallDialog::_update_method_list() { - - tree->clear(); - if (!object) - return; - - TreeItem *root = tree->create_item(); - - List<MethodInfo> method_list; - object->get_method_list(&method_list); - method_list.sort(); - methods.clear(); - - List<String> inheritance_list; - - String type = object->get_class(); - - while(type!="") { - inheritance_list.push_back( type ); - type=ClassDB::get_parent_class(type); - } - - TreeItem *selected_item=NULL; - - for(int i=0;i<inheritance_list.size();i++) { - - String type=inheritance_list[i]; - String parent_type=ClassDB::get_parent_class(type); - - TreeItem *type_item=NULL; - - List<MethodInfo>::Element *N,*E=method_list.front(); - - while(E) { - - N=E->next(); - - if (parent_type!="" && ClassDB::get_method(parent_type,E->get().name)!=NULL) { - E=N; - continue; - } - - if (!type_item) { - type_item=tree->create_item(root); - type_item->set_text(0,type); - if (has_icon(type,"EditorIcons")) - type_item->set_icon(0,get_icon(type,"EditorIcons")); - } - - TreeItem *method_item = tree->create_item(type_item); - method_item->set_text(0,E->get().name); - method_item->set_metadata(0,methods.size()); - if (E->get().name==selected) - selected_item=method_item; - methods.push_back( E->get() ); - - method_list.erase(E); - E=N; - } - } - - - - if (selected_item) - selected_item->select(0); -} - -void CallDialog::_bind_methods() { - - ClassDB::bind_method("_call",&CallDialog::_call); - ClassDB::bind_method("_cancel",&CallDialog::_cancel); - ClassDB::bind_method("_item_selected", &CallDialog::_item_selected); - -} - -void CallDialog::set_object(Object *p_object,StringName p_selected) { - - object=p_object; - selected=p_selected; - property_editor->edit(NULL); - call->set_disabled(true); - return_value->clear(); - - _update_method_list(); - method_label->set_text(vformat(TTR("Method List For '%s':"),p_object->get_class())); -} - -CallDialog::CallDialog() { - - object=NULL; - - call = memnew( Button ); - call->set_anchor( MARGIN_LEFT, ANCHOR_END ); - call->set_anchor( MARGIN_TOP, ANCHOR_END ); - call->set_anchor( MARGIN_RIGHT, ANCHOR_END ); - call->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - call->set_begin( Point2( -70, -29 ) ); - call->set_end( Point2( -15, -15 ) ); - call->set_text(TTR("Call")); - - add_child(call); - - cancel = memnew( Button ); - cancel->set_anchor( MARGIN_TOP, ANCHOR_END ); - cancel->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - cancel->set_begin( Point2( -15, 29 ) ); - cancel->set_end( Point2( 70, -15 ) ); - cancel->set_text(TTR("Close")); - - add_child(cancel); - - tree = memnew( Tree ); - - tree->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - tree->set_begin( Point2( 20,50 ) ); - tree->set_margin(MARGIN_BOTTOM, -44 ); - tree->set_margin(MARGIN_RIGHT, 0.5 ); - tree->set_select_mode( Tree::SELECT_ROW ); - add_child(tree); - - tree->connect("item_selected", this,"_item_selected"); - tree->set_hide_root(true); - - property_editor = memnew( PropertyEditor ); - - property_editor->set_anchor_and_margin( MARGIN_RIGHT, ANCHOR_END, -15 ); - property_editor->set_anchor_and_margin( MARGIN_TOP, ANCHOR_BEGIN, 50 ); - //property_editor->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.55 ); - property_editor->set_anchor_and_margin( MARGIN_BOTTOM, ANCHOR_END, -90 ); - property_editor->get_scene_tree()->set_hide_root( true ); - property_editor->hide_top_label(); - - add_child(property_editor); - method_label = memnew(Label); - method_label->set_position(Point2( 15,25)); - method_label->set_text(TTR("Method List:")); - - add_child(method_label); - - Label *label = memnew( Label ); - //label->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.53 ); - label->set_anchor_and_margin( MARGIN_TOP, ANCHOR_BEGIN, 25 ); - label->set_text(TTR("Arguments:")); - - add_child(label); - - return_label = memnew( Label ); - //return_label->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.53 ); - return_label->set_anchor_and_margin( MARGIN_TOP, ANCHOR_END, -85 ); - return_label->set_text(TTR("Return:")); - - add_child(return_label); - - return_value = memnew( LineEdit ); - //return_value->set_anchor_and_margin( MARGIN_LEFT, ANCHOR_RATIO, 0.55 ); - return_value->set_anchor_and_margin( MARGIN_RIGHT, ANCHOR_END, -15 ); - return_value->set_anchor_and_margin( MARGIN_TOP, ANCHOR_END, -65 ); - - add_child(return_value); - - /* - label = memnew( Label ); - label->set_anchor( MARGIN_TOP, ANCHOR_END ); - label->set_anchor( MARGIN_BOTTOM, ANCHOR_END ); - - label->set_begin( Point2( 15,54) ); - label->set_end( Point2( 16,44) ); - label->set_text("Parameters:"); - - add_child(label); - */ - - - call_params = memnew( CallDialogParams ); - set_as_toplevel(true); -} - - -CallDialog::~CallDialog() -{ - memdelete(call_params); -} -#endif diff --git a/editor/call_dialog.h b/editor/call_dialog.h deleted file mode 100644 index ab833c8dd3..0000000000 --- a/editor/call_dialog.h +++ /dev/null @@ -1,86 +0,0 @@ -/*************************************************************************/ -/* call_dialog.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 CALL_DIALOG_H -#define CALL_DIALOG_H - -#include "editor/property_editor.h" -#include "scene/gui/button.h" -#include "scene/gui/label.h" -#include "scene/gui/line_edit.h" -#include "scene/gui/popup.h" -#include "scene/gui/tree.h" -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - -#if 0 - -class CallDialogParams; - -class CallDialog : public Popup { - - GDCLASS( CallDialog, Popup ); - - - Label* method_label; - Tree *tree; - Button *call; - Button *cancel; - - CallDialogParams *call_params; - PropertyEditor *property_editor; - - Label *return_label; - LineEdit *return_value; - Object *object; - StringName selected; - - Vector<MethodInfo> methods; - - - void _item_selected(); - void _update_method_list(); - void _call(); - void _cancel(); - -protected: - static void _bind_methods(); - void _notification(int p_what); -public: - - void set_object(Object *p_object,StringName p_selected=""); - - CallDialog(); - ~CallDialog(); - -}; - -#endif -#endif diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index a9dc81dc54..305e2e9159 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/code_editor.h b/editor/code_editor.h index e56d7f7fab..410dd99878 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/collada/collada.cpp b/editor/collada/collada.cpp index 169c34782d..4986d97e8f 100644 --- a/editor/collada/collada.cpp +++ b/editor/collada/collada.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -31,7 +31,7 @@ #include "collada.h" -#include "stdio.h" +#include <stdio.h> //#define DEBUG_DEFAULT_ANIMATION //#define DEBUG_COLLADA @@ -671,15 +671,7 @@ void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String & } } else if (what == "shininess") { -#if 1 effect.shininess = _parse_param(parser); -#else - - parser.read(); - float shininess = parser.get_node_data().to_double(); - effect.shininess = shininess; - COLLADA_PRINT("shininess: " + rtos(shininess)); -#endif } } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && (parser.get_node_name() == "constant" || parser.get_node_name() == "lambert" || @@ -2505,7 +2497,7 @@ void Collada::_optimize() { for (int i = 0; i < vs.root_nodes.size(); i++) { _create_skeletons(&vs.root_nodes[i]); } -#if 1 + for (int i = 0; i < vs.root_nodes.size(); i++) { _merge_skeletons(&vs, vs.root_nodes[i]); } @@ -2531,7 +2523,7 @@ void Collada::_optimize() { mgeom.pop_front(); } } -#endif + for (int i = 0; i < vs.root_nodes.size(); i++) { _find_morph_nodes(&vs, vs.root_nodes[i]); } diff --git a/editor/collada/collada.h b/editor/collada/collada.h index f94f9ed197..d41a72d7c5 100644 --- a/editor/collada/collada.h +++ b/editor/collada/collada.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index c2e173c040..b4c2ac95cc 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -113,33 +113,7 @@ void ConnectDialog::_tree_node_selected() { make_callback->hide(); else make_callback->show(); -#if 0 - List<MethodInfo> methods; - current->get_method_list(&methods); - for (List<MethodInfo>::Element *E=methods.front();E;E=E->next()) { - - if (E->get().name.length() && E->get().name[0]=='_') - continue; // hidden method, not show! - - if (ClassDB::has_method(node->get_type(),"Node") || ClassDB::has_method(node->get_type(),"Control",true)) - continue; //avoid too much unnecessary stuff - - String method=E->get().name+"("; - for(int i=0;i<E->get().arguments.size();i++) { - - if (i!=0) - method+=", "; - method+=Variant::get_type_name(E->get().arguments[i].type); - if (E->get().arguments[i].name.length()) { - method+=" "; - method+=E->get().arguments[i].name; - } - } - method+=")"; - //dst_method_list->get_popup()->add_item(method); - } -#endif dst_path->set_text(node->get_path_to(current)); } diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h index 849bb880d4..53f4d857bf 100644 --- a/editor/connections_dialog.h +++ b/editor/connections_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 1089068344..344cb87aa6 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/create_dialog.h b/editor/create_dialog.h index 02ce762726..31f106ea22 100644 --- a/editor/create_dialog.h +++ b/editor/create_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 78773ce3a6..890c3d8091 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h index 5fdd2b72a8..4dfb9de268 100644 --- a/editor/dependency_editor.h +++ b/editor/dependency_editor.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 70cba66827..208341add3 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/doc/doc_data.h b/editor/doc/doc_data.h index 40141dd935..efb4ea3040 100644 --- a/editor/doc/doc_data.h +++ b/editor/doc/doc_data.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp index 79a8f79a7c..2ba7e3c779 100644 --- a/editor/doc/doc_dump.cpp +++ b/editor/doc/doc_dump.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/doc/doc_dump.h b/editor/doc/doc_dump.h index 300ce916ee..4764a0e0d4 100644 --- a/editor/doc/doc_dump.h +++ b/editor/doc/doc_dump.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/doc_code_font.h b/editor/doc_code_font.h index 8fbfa7b1d6..e962351daf 100644 --- a/editor/doc_code_font.h +++ b/editor/doc_code_font.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/doc_font.h b/editor/doc_font.h index a3d41bb8ef..4ec8c39db2 100644 --- a/editor/doc_font.h +++ b/editor/doc_font.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/doc_title_font.h b/editor/doc_title_font.h index 14da323aa7..dd1bb7ca8e 100644 --- a/editor/doc_title_font.h +++ b/editor/doc_title_font.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index fd90c766fd..8bd7bfb4bd 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_about.h b/editor/editor_about.h index 0bde94531a..d7047c03a3 100644 --- a/editor/editor_about.h +++ b/editor/editor_about.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index caed426b2d..a8eee24fe2 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_asset_installer.h b/editor/editor_asset_installer.h index e74bd6925b..cda1b4d2b5 100644 --- a/editor/editor_asset_installer.h +++ b/editor/editor_asset_installer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 9df952b017..b3eb3e23a9 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index 9d80ff67d1..e04ba7b89d 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index f0f6aac089..82a7fa734a 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h index 9f8e3526b4..2e0ce8835e 100644 --- a/editor/editor_autoload_settings.h +++ b/editor/editor_autoload_settings.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 0a5220497a..cb74a7b852 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_data.h b/editor/editor_data.h index 2b336c4716..cbba4d60ad 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_dir_dialog.cpp b/editor/editor_dir_dialog.cpp index 80d3abcf0c..1b213501aa 100644 --- a/editor/editor_dir_dialog.cpp +++ b/editor/editor_dir_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_dir_dialog.h b/editor/editor_dir_dialog.h index 0fdb71b0a1..b8347f75fb 100644 --- a/editor/editor_dir_dialog.h +++ b/editor/editor_dir_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 14d713bb36..e761dce8ab 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1169,2205 +1169,3 @@ void EditorExportPlatformPC::get_platform_features(List<String> *r_features) { EditorExportPlatformPC::EditorExportPlatformPC() { } - -//////// - -#if 0 -#include "editor/editor_file_system.h" -#include "editor/plugins/script_editor_plugin.h" -#include "editor_node.h" -#include "editor_settings.h" -#include "io/config_file.h" -#include "io/md5.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "io/zip_io.h" -#include "io_plugins/editor_texture_import_plugin.h" -#include "os/dir_access.h" -#include "os/file_access.h" -#include "project_settings.h" -#include "script_language.h" -#include "version.h" - - -String EditorImportPlugin::validate_source_path(const String& p_path) { - - String gp = ProjectSettings::get_singleton()->globalize_path(p_path); - String rp = ProjectSettings::get_singleton()->get_resource_path(); - if (!rp.ends_with("/")) - rp+="/"; - - return rp.path_to_file(gp); -} - -String EditorImportPlugin::expand_source_path(const String& p_path) { - - if (p_path.is_rel_path()) { - return ProjectSettings::get_singleton()->get_resource_path().plus_file(p_path).simplify_path(); - } else { - return p_path; - } -} - - -String EditorImportPlugin::_validate_source_path(const String& p_path) { - - return validate_source_path(p_path); -} - -String EditorImportPlugin::_expand_source_path(const String& p_path) { - - return expand_source_path(p_path); -} - -void EditorImportPlugin::_bind_methods() { - - - ClassDB::bind_method(D_METHOD("validate_source_path","path"),&EditorImportPlugin::_validate_source_path); - ClassDB::bind_method(D_METHOD("expand_source_path","path"),&EditorImportPlugin::_expand_source_path); - - ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::STRING,"get_name")); - ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::STRING,"get_visible_name")); - ClassDB::add_virtual_method(get_class_static(),MethodInfo("import_dialog",PropertyInfo(Variant::STRING,"from"))); - ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::INT,"import",PropertyInfo(Variant::STRING,"path"),PropertyInfo(Variant::OBJECT,"from",PROPERTY_HINT_RESOURCE_TYPE,"ResourceImportMetadata"))); - ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::POOL_BYTE_ARRAY,"custom_export",PropertyInfo(Variant::STRING,"path"),PropertyInfo(Variant::OBJECT,"platform",PROPERTY_HINT_RESOURCE_TYPE,"EditorExportPlatform"))); - ClassDB::add_virtual_method(get_class_static(),MethodInfo("import_from_drop",PropertyInfo(Variant::POOL_STRING_ARRAY,"files"),PropertyInfo(Variant::STRING,"dest_path"))); - ClassDB::add_virtual_method(get_class_static(),MethodInfo("reimport_multiple_files",PropertyInfo(Variant::POOL_STRING_ARRAY,"files"))); - ClassDB::add_virtual_method(get_class_static(),MethodInfo(Variant::BOOL,"can_reimport_multiple_files")); - - //BIND_VMETHOD( mi ); -} - -String EditorImportPlugin::get_name() const { - - if (get_script_instance() && get_script_instance()->has_method("get_name")) { - return get_script_instance()->call("get_name"); - } - - ERR_FAIL_V(""); -} - -String EditorImportPlugin::get_visible_name() const { - - if (get_script_instance() && get_script_instance()->has_method("get_visible_name")) { - return get_script_instance()->call("get_visible_name"); - } - - ERR_FAIL_V(""); -} - - -void EditorImportPlugin::import_dialog(const String& p_from) { - - if (get_script_instance() && get_script_instance()->has_method("import_dialog")) { - get_script_instance()->call("import_dialog",p_from); - return; - } - - ERR_FAIL(); - -} - -Error EditorImportPlugin::import(const String& p_path, const Ref<ResourceImportMetadata>& p_from) { - - if (get_script_instance() && get_script_instance()->has_method("import")) { - return Error(get_script_instance()->call("import",p_path,p_from).operator int()); - } - - ERR_FAIL_V(ERR_UNAVAILABLE); -} - -Vector<uint8_t> EditorImportPlugin::custom_export(const String& p_path, const Ref<EditorExportPlatform> &p_platform) { - - if (get_script_instance() && get_script_instance()->has_method("custom_export")) { - get_script_instance()->call("custom_export",p_path,p_platform); - } - - return Vector<uint8_t>(); -} - -bool EditorImportPlugin::can_reimport_multiple_files() const { - - if (get_script_instance() && get_script_instance()->has_method("can_reimport_multiple_files")) { - return get_script_instance()->call("can_reimport_multiple_files"); - } - - return false; -} -void EditorImportPlugin::reimport_multiple_files(const Vector<String>& p_list) { - - if (get_script_instance() && get_script_instance()->has_method("reimport_multiple_files")) { - get_script_instance()->call("reimport_multiple_files",p_list); - } - -} - -void EditorImportPlugin::import_from_drop(const Vector<String>& p_drop, const String &p_dest_path) { - - if (get_script_instance() && get_script_instance()->has_method("import_from_drop")) { - get_script_instance()->call("import_from_drop",p_drop,p_dest_path); - } - -} - -EditorImportPlugin::EditorImportPlugin() { - - -} - -///////////////////////////////////////////////////////////////////////////////////////////////////// - - -void EditorExportPlugin::_bind_methods() { - - MethodInfo mi = MethodInfo("custom_export:Variant",PropertyInfo(Variant::STRING,"name"),PropertyInfo(Variant::OBJECT,"platform",PROPERTY_HINT_RESOURCE_TYPE,"EditorExportPlatform")); - mi.return_val.type=Variant::POOL_BYTE_ARRAY; - - BIND_VMETHOD( mi ); -} - - -Vector<uint8_t> EditorExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) { - - if (get_script_instance()) { - - Variant d = get_script_instance()->call("custom_export",p_path,p_platform); - if (d.get_type()==Variant::NIL) - return Vector<uint8_t>(); - if (d.get_type()==Variant::POOL_BYTE_ARRAY) - return d; - - ERR_FAIL_COND_V(d.get_type()!=Variant::DICTIONARY,Vector<uint8_t>()); - Dictionary dict=d; - ERR_FAIL_COND_V(!dict.has("name"),Vector<uint8_t>()); - ERR_FAIL_COND_V(!dict.has("data"),Vector<uint8_t>()); - p_path=dict["name"]; - return dict["data"]; - } - - return Vector<uint8_t>(); - -} - - -EditorExportPlugin::EditorExportPlugin() { - - -} - -///////////////////////////////////////////////////////////////////////////////////////////////////// - - - -static void _add_to_list(EditorFileSystemDirectory *p_efsd,Set<StringName>& r_list) { - - for(int i=0;i<p_efsd->get_subdir_count();i++) { - - _add_to_list(p_efsd->get_subdir(i),r_list); - } - - for(int i=0;i<p_efsd->get_file_count();i++) { - r_list.insert(p_efsd->get_file_path(i)); - } -} - - -struct __EESortDepCmp { - - _FORCE_INLINE_ bool operator()(const StringName& p_l,const StringName& p_r) const { - return p_l.operator String() < p_r.operator String(); - } -}; - - - - -static void _edit_files_with_filter(DirAccess *da,const List<String>& p_filters,Set<StringName>& r_list,bool exclude) { - - - List<String> files; - List<String> dirs; - - da->list_dir_begin(); - - String f = da->get_next(); - while(f!="") { - - print_line("HOHO: "+f); - if (da->current_is_dir()) - dirs.push_back(f); - else - files.push_back(f); - - f=da->get_next(); - } - - String r = da->get_current_dir().replace("\\","/"); - if (!r.ends_with("/")) - r+="/"; - - print_line("AT: "+r); - - for(List<String>::Element *E=files.front();E;E=E->next()) { - String fullpath=r+E->get(); - for(const List<String>::Element *F=p_filters.front();F;F=F->next()) { - - if (fullpath.matchn(F->get())) { - String act = TTR("Added:")+" "; - - if (!exclude) { - r_list.insert(fullpath); - } else { - act = TTR("Removed:")+" "; - r_list.erase(fullpath); - } - - - print_line(act+fullpath); - } - } - } - - da->list_dir_end(); - - for(List<String>::Element *E=dirs.front();E;E=E->next()) { - if (E->get().begins_with(".")) - continue; - da->change_dir(E->get()); - _edit_files_with_filter(da,p_filters,r_list,exclude); - da->change_dir(".."); - } - -} - -static void _edit_filter_list(Set<StringName>& r_list,const String& p_filter,bool exclude) { - - if (p_filter=="") - return; - Vector<String> split = p_filter.split(","); - List<String> filters; - for(int i=0;i<split.size();i++) { - String f = split[i].strip_edges(); - if (f.empty()) - continue; - filters.push_back(f); - } - - DirAccess *da = DirAccess::open("res://"); - ERR_FAIL_NULL(da); - _edit_files_with_filter(da,filters,r_list,exclude); - memdelete(da); -} - -static void _add_filter_to_list(Set<StringName>& r_list,const String& p_filter) { - _edit_filter_list(r_list,p_filter,false); -} - -static void _remove_filter_from_list(Set<StringName>& r_list,const String& p_filter) { - _edit_filter_list(r_list,p_filter,true); -} - -bool EditorExportPlatform::_set(const StringName& p_name, const Variant& p_value) { - - String n = p_name; - - if (n=="debug/debugging_enabled") { - set_debugging_enabled(p_value); - } else { - return false; - } - - return true; - -} - -bool EditorExportPlatform::_get(const StringName& p_name,Variant &r_ret) const { - - String n = p_name; - - if (n=="debug/debugging_enabled") { - r_ret=is_debugging_enabled(); - } else { - return false; - } - - return true; - -} - -void EditorExportPlatform::_get_property_list( List<PropertyInfo> *p_list) const { - - p_list->push_front( PropertyInfo( Variant::BOOL, "debug/debugging_enabled")); -} - -Vector<uint8_t> EditorExportPlatform::get_exported_file_default(String& p_fname) const { - - FileAccess *f = FileAccess::open(p_fname,FileAccess::READ); - ERR_FAIL_COND_V(!f,Vector<uint8_t>()); - Vector<uint8_t> ret; - ret.resize(f->get_len()); - int rbs = f->get_buffer(ret.ptr(),ret.size()); - memdelete(f); - return ret; -} - -Vector<uint8_t> EditorExportPlatform::get_exported_file(String& p_fname) const { - - Ref<EditorExportPlatform> ep=EditorImportExport::get_singleton()->get_export_platform(get_name()); - - for(int i=0;i<EditorImportExport::get_singleton()->get_export_plugin_count();i++) { - - Vector<uint8_t> data = EditorImportExport::get_singleton()->get_export_plugin(i)->custom_export(p_fname,ep); - if (data.size()) - return data; - - } - - - return get_exported_file_default(p_fname); - - -} - -Vector<StringName> EditorExportPlatform::get_dependencies(bool p_bundles) const { - - - Set<StringName> exported; - - if (FileAccess::exists("res://project.godot")) - exported.insert("res://project.godot"); - - if (EditorImportExport::get_singleton()->get_export_filter()!=EditorImportExport::EXPORT_SELECTED) { - - String filter; - if (EditorImportExport::get_singleton()->get_export_filter()==EditorImportExport::EXPORT_ALL) { - _add_filter_to_list(exported,"*"); - } else { - _add_to_list(EditorFileSystem::get_singleton()->get_filesystem(),exported); - String cf = EditorImportExport::get_singleton()->get_export_custom_filter(); - if (cf!="") - cf+=","; - cf+="*.flags"; - _add_filter_to_list(exported,cf); - - cf = EditorImportExport::get_singleton()->get_export_custom_filter_exclude(); - _remove_filter_from_list(exported,cf); - } - - - } else { - - - 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()); - } - } - - - List<StringName> toexport; - - EditorImportExport::get_singleton()->get_export_file_list(&toexport); - - print_line("TO EXPORT: "+itos(toexport.size())); - - - for (List<StringName>::Element *E=toexport.front();E;E=E->next()) { - - print_line("DEP: "+String(E->get())); - exported.insert(E->get()); - if (p_bundles && EditorImportExport::get_singleton()->get_export_file_action(E->get())==EditorImportExport::ACTION_BUNDLE) { - print_line("NO BECAUSE OF BUNDLE!"); - continue; //no dependencies needed to be copied - } - - List<String> testsubs; - testsubs.push_back(E->get()); - - while(testsubs.size()) { - //recursive subdep search! - List<String> deplist; - ResourceLoader::get_dependencies(testsubs.front()->get(),&deplist); - testsubs.pop_front(); - - List<String> subdeps; - - for (List<String>::Element *F=deplist.front();F;F=F->next()) { - - StringName dep = F->get(); - - if (exported.has(dep) || EditorImportExport::get_singleton()->get_export_file_action(dep)!=EditorImportExport::ACTION_NONE) - continue; //dependency added or to be added - print_line(" SUBDEP: "+String(dep)); - - exported.insert(dep); - testsubs.push_back(dep); - } - } - } - String cf = EditorImportExport::get_singleton()->get_export_custom_filter(); - if (cf!="") - cf+=","; - cf+="*.flags"; - _add_filter_to_list(exported,cf); - - cf = EditorImportExport::get_singleton()->get_export_custom_filter_exclude(); - _remove_filter_from_list(exported,cf); - - - } - - Vector<StringName> ret; - ret.resize(exported.size()); - - - int idx=0; - for(Set<StringName>::Element *E=exported.front();E;E=E->next()) { - - ret[idx++]=E->get(); - - } - - SortArray<StringName,__EESortDepCmp> sort; //some platforms work better if this is sorted - sort.sort(ret.ptr(),ret.size()); - - return ret; - -} - -/////////////////////////////////////// - - - -bool EditorExportPlatform::is_debugging_enabled() const { - - return debugging_enabled; -} - -void EditorExportPlatform::set_debugging_enabled(bool p_enabled) { - - debugging_enabled = p_enabled; -} - -bool EditorExportPlatformPC::_set(const StringName& p_name, const Variant& p_value) { - - String n = p_name; - - if (n=="custom_binary/release") { - - custom_release_binary=p_value; - } else if (n=="custom_binary/debug") { - - custom_debug_binary=p_value; - } else if (n=="resources/pack_mode") { - - export_mode=ExportMode(int(p_value)); - } else if (n=="resources/bundle_dependencies_(for_optical_disc)") { - - bundle=p_value; - } else if (n=="binary/64_bits") { - - use64=p_value; - } else - return false; - - return true; - -} - -bool EditorExportPlatformPC::_get(const StringName& p_name,Variant &r_ret) const { - - String n = p_name; - - if (n=="custom_binary/release") { - - r_ret=custom_release_binary; - } else if (n=="custom_binary/debug") { - - r_ret=custom_debug_binary; - } else if (n=="resources/pack_mode") { - - r_ret=export_mode; - } else if (n=="resources/bundle_dependencies_(for_optical_disc)") { - - r_ret=bundle; - } else if (n=="binary/64_bits") { - - r_ret=use64; - } else - return false; - - return true; - -} - -void EditorExportPlatformPC::_get_property_list( List<PropertyInfo> *p_list) const { - - p_list->push_back( PropertyInfo( Variant::STRING, "custom_binary/debug", PROPERTY_HINT_GLOBAL_FILE,binary_extension)); - p_list->push_back( PropertyInfo( Variant::STRING, "custom_binary/release", PROPERTY_HINT_GLOBAL_FILE,binary_extension)); - p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Pack into executable,Pack into binary file (.pck),Pack into archive file (.zip)")); - p_list->push_back( PropertyInfo( Variant::BOOL, "resources/bundle_dependencies_(for_optical_disc)")); - p_list->push_back( PropertyInfo( Variant::BOOL, "binary/64_bits")); -} - - - -static void _exp_add_dep(Map<StringName,List<StringName> > &deps,const StringName& p_path) { - - - if (deps.has(p_path)) - return; //already done - - deps.insert(p_path,List<StringName>()); - - List<StringName> &deplist=deps[p_path]; - Set<StringName> depset; - - List<String> dl; - ResourceLoader::get_dependencies(p_path,&dl); - - //added in order so child dependencies are always added bfore parent dependencies - for (List<String>::Element *E=dl.front();E;E=E->next()) { - - - if (!deps.has(E->get())) - _exp_add_dep(deps,E->get()); - - for(List<StringName>::Element *F=deps[E->get()].front();F;F=F->next()) { - - - if (!depset.has(F->get())) { - depset.insert(F->get()); - deplist.push_back(F->get()); - } - } - - if (!depset.has(E->get())) { - depset.insert(E->get()); - deplist.push_back(E->get()); - } - - } -} - - - -Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func, void* p_udata,bool p_make_bundles) { - -/* ALL FILES AND DEPENDENCIES */ - - Vector<StringName> files=get_dependencies(p_make_bundles); - - Map<StringName,List<StringName> > deps; - - if (false) { - for(int i=0;i<files.size();i++) { - - _exp_add_dep(deps,files[i]); - - } - } - - - -/* GROUP ATLAS */ - - - List<StringName> groups; - - EditorImportExport::get_singleton()->image_export_get_groups(&groups); - - Map<StringName,StringName> remap_files; - Set<StringName> saved; - - int counter=0; - - for(List<StringName>::Element *E=groups.front();E;E=E->next()) { - - if (!EditorImportExport::get_singleton()->image_export_group_get_make_atlas(E->get())) - continue; //uninterested, only process for atlas! - - List<StringName> atlas_images; - EditorImportExport::get_singleton()->image_export_get_images_in_group(E->get(),&atlas_images); - atlas_images.sort_custom<StringName::AlphCompare>(); - - for (List<StringName>::Element *F=atlas_images.front();F;) { - - List<StringName>::Element *N=F->next(); - - if (!FileAccess::exists(F->get())) { - atlas_images.erase(F); - } - - F=N; - - } - - if (atlas_images.size()<=1) - continue; - - int group_format=0; - float group_lossy_quality=EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(E->get()); - int group_shrink=EditorImportExport::get_singleton()->image_export_group_get_shrink(E->get()); - group_shrink*=EditorImportExport::get_singleton()->get_export_image_shrink(); - - switch(EditorImportExport::get_singleton()->image_export_group_get_image_action(E->get())) { - case EditorImportExport::IMAGE_ACTION_KEEP: - case EditorImportExport::IMAGE_ACTION_NONE: { - - switch(EditorImportExport::get_singleton()->get_export_image_action()) { - case EditorImportExport::IMAGE_ACTION_NONE: { - - group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS; //? - - } break; //use default - case EditorImportExport::IMAGE_ACTION_COMPRESS_DISK: { - group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY; - } break; //use default - case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: { - group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM; - } break; //use default - } - - group_lossy_quality=EditorImportExport::get_singleton()->get_export_image_quality(); - - } break; //use default - case EditorImportExport::IMAGE_ACTION_COMPRESS_DISK: { - group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY; - } break; //use default - case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: { - group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM; - } break; //use default - } - - String image_list_md5; - - { - MD5_CTX ctx; - MD5Init(&ctx); - for (List<StringName>::Element *F=atlas_images.front();F;F=F->next()) { - - String p = F->get(); - MD5Update(&ctx,(unsigned char*)p.utf8().get_data(),p.utf8().length()); - - } - - MD5Final(&ctx); - image_list_md5=String::md5(ctx.digest); - } - //ok see if cached - String md5; - bool atlas_valid=true; - String atlas_name; - - { - MD5_CTX ctx; - MD5Init(&ctx); - String path = ProjectSettings::get_singleton()->get_resource_path()+"::"+String(E->get())+"::"+get_name(); - MD5Update(&ctx,(unsigned char*)path.utf8().get_data(),path.utf8().length()); - MD5Final(&ctx); - md5 = String::md5(ctx.digest); - } - - FileAccess *f=NULL; - - if (!FileAccess::exists(EditorSettings::get_singleton()->get_settings_path()+"/tmp/atlas-"+md5)) { - print_line("NO MD5 INVALID"); - atlas_valid=false; - } - - if (atlas_valid) - f=FileAccess::open(EditorSettings::get_singleton()->get_settings_path()+"/tmp/atlas-"+md5,FileAccess::READ); - - if (atlas_valid) { - //compare options - /*Dictionary options; - options.parse_json(f->get_line()); - if (!options.has("lossy_quality") || float(options["lossy_quality"])!=group_lossy_quality) - atlas_valid=false; - else if (!options.has("shrink") || int(options["shrink"])!=group_shrink) - atlas_valid=false; - else if (!options.has("image_format") || int(options["image_format"])!=group_format) - atlas_valid=false; - - if (!atlas_valid) - print_line("JSON INVALID"); -*/ - } - - - if (atlas_valid) { - //check md5 of list of image /names/ - if (f->get_line().strip_edges()!=image_list_md5) { - atlas_valid=false; - print_line("IMAGE MD5 INVALID!"); - } - - } - - Vector<Rect2> rects; - bool resave_deps=false; - - if (atlas_valid) { - - //check if images were not modified - for (List<StringName>::Element *F=atlas_images.front();F;F=F->next()) { - - Vector<String> slices = f->get_line().strip_edges().split("::"); - - if (slices.size()!=10) { - atlas_valid=false; - print_line("CAN'T SLICE IN 10"); - break; - } - uint64_t mod_time = slices[0].to_int64(); - uint64_t file_mod_time = FileAccess::get_modified_time(F->get()); - if (mod_time!=file_mod_time) { - - String image_md5 = slices[1]; - String file_md5 = FileAccess::get_md5(F->get()); - - if (image_md5!=file_md5) { - atlas_valid=false; - print_line("IMAGE INVALID "+slices[0]); - break; - } else { - resave_deps=true; - } - } - - if (atlas_valid) { - //push back region and margin - rects.push_back(Rect2(slices[2].to_float(),slices[3].to_float(),slices[4].to_float(),slices[5].to_float())); - rects.push_back(Rect2(slices[6].to_float(),slices[7].to_float(),slices[8].to_float(),slices[9].to_float())); - } - } - - } - - if (f) { - memdelete(f); - f=NULL; - } - - print_line("ATLAS VALID? "+itos(atlas_valid)+" RESAVE DEPS? "+itos(resave_deps)); - if (!atlas_valid) { - rects.clear(); - //oh well, atlas is not valid. need to make new one.... - - String dst_file = EditorSettings::get_singleton()->get_settings_path()+"/tmp/atlas-"+md5+".tex"; - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - //imd->set_editor(); - - - for (List<StringName>::Element *F=atlas_images.front();F;F=F->next()) { - - imd->add_source(EditorImportPlugin::validate_source_path(F->get()),FileAccess::get_md5(F->get())); - - } - - - imd->set_option("format",group_format); - - - int flags=0; - - if (ProjectSettings::get_singleton()->get("image_loader/filter")) - flags|=EditorTextureImportPlugin::IMAGE_FLAG_FILTER; - if (!ProjectSettings::get_singleton()->get("image_loader/gen_mipmaps")) - flags|=EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS; - if (!ProjectSettings::get_singleton()->get("image_loader/repeat")) - flags|=EditorTextureImportPlugin::IMAGE_FLAG_REPEAT; - - flags|=EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA; - - imd->set_option("flags",flags); - imd->set_option("quality",group_lossy_quality); - imd->set_option("atlas",true); - imd->set_option("crop",true); - imd->set_option("shrink",group_shrink); - - - - Ref<EditorTextureImportPlugin> plugin = EditorImportExport::get_singleton()->get_import_plugin_by_name("texture"); - Error err = plugin->import2(dst_file,imd,get_image_compression(),true); - if (err) { - - EditorNode::add_io_error(TTR("Error saving atlas:")+" "+dst_file.get_file()); - return ERR_CANT_CREATE; - } - - ERR_FAIL_COND_V(imd->get_option("rects")==Variant(),ERR_BUG); - - Array r_rects=imd->get_option("rects"); - rects.resize(r_rects.size()); - for(int i=0;i<r_rects.size();i++) { - //get back region and margins - rects[i]=r_rects[i]; - } - - - resave_deps=true; - } - - - //atlas is valid (or it was just saved i guess), create the atex files and save them - - if (resave_deps) { - f=FileAccess::open(EditorSettings::get_singleton()->get_settings_path()+"/tmp/atlas-"+md5,FileAccess::WRITE); - Dictionary options; - options["lossy_quality"]=group_lossy_quality; - options["shrink"]=EditorImportExport::get_singleton()->image_export_group_get_shrink(E->get()); - options["image_format"]=group_format; - //f->store_line(options.to_json()); - f->store_line(image_list_md5); - } - - //go through all ATEX files - - { - Ref<ImageTexture> atlas = memnew( ImageTexture ); //fake atlas! - String atlas_path="res://atlas-"+md5+".tex"; - atlas->set_path(atlas_path); - int idx=0; - for (List<StringName>::Element *F=atlas_images.front();F;F=F->next()) { - - String p = F->get(); - Ref<AtlasTexture> atex = memnew(AtlasTexture); - atex->set_atlas(atlas); - Rect2 region=rects[idx++]; - Rect2 margin=rects[idx++]; - atex->set_region(region); - atex->set_margin(margin); - - String path = EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmpatlas.atlastex"; - Error err = ResourceSaver::save(path,atex); - if (err!=OK) { - EditorNode::add_io_error(TTR("Could not save atlas subtexture:")+" "+path); - return ERR_CANT_CREATE; - } - Vector<uint8_t> data = FileAccess::get_file_as_array(path); - String dst_path = F->get().operator String().get_basename()+".atlastex"; - err = p_func(p_udata,dst_path,data,counter++,files.size()); - saved.insert(dst_path); - if (err) - return err; - - if (f) { - //recreating deps.. - String depline; - //depline=String(F->get())+"::"+itos(FileAccess::get_modified_time(F->get()))+"::"+FileAccess::get_md5(F->get()); name unnecessary by top md5 - depline=itos(FileAccess::get_modified_time(F->get()))+"::"+FileAccess::get_md5(F->get()); - depline+="::"+itos(region.pos.x)+"::"+itos(region.pos.y)+"::"+itos(region.size.x)+"::"+itos(region.size.y); - depline+="::"+itos(margin.pos.x)+"::"+itos(margin.pos.y)+"::"+itos(margin.size.x)+"::"+itos(margin.size.y); - f->store_line(depline); - } - - remap_files[F->get()]=dst_path; - } - - Vector<uint8_t> atlas_data = FileAccess::get_file_as_array(EditorSettings::get_singleton()->get_settings_path()+"/tmp/atlas-"+md5+".tex"); - Error err = p_func(p_udata,atlas_path,atlas_data,counter,files.size()); - saved.insert(atlas_path); - if (err) - return err; - - } - - - if (f) { - memdelete(f); - } - - } - - - StringName engine_cfg="res://project.godot"; - StringName boot_splash; - { - String splash=ProjectSettings::get_singleton()->get("application/boot_splash"); //avoid splash from being converted - splash=splash.strip_edges(); - if (splash!=String()) { - if (!splash.begins_with("res://")) - splash="res://"+splash; - splash=splash.simplify_path(); - boot_splash=splash; - } - } - StringName custom_cursor; - { - String splash=ProjectSettings::get_singleton()->get("display/custom_mouse_cursor"); //avoid splash from being converted - splash=splash.strip_edges(); - if (splash!=String()) { - if (!splash.begins_with("res://")) - splash="res://"+splash; - splash=splash.simplify_path(); - custom_cursor=splash; - } - } - - - - - for(int i=0;i<files.size();i++) { - - if (remap_files.has(files[i]) || files[i]==engine_cfg) //gonna be remapped (happened before!) - continue; //from atlas? - String src=files[i]; - Vector<uint8_t> buf; - - if (src==boot_splash || src==custom_cursor) - buf = get_exported_file_default(src); //bootsplash must be kept if used - else - buf = get_exported_file(src); - - ERR_CONTINUE( saved.has(src) ); - - Error err = p_func(p_udata,src,buf,counter++,files.size()); - if (err) - return err; - - saved.insert(src); - if (src!=String(files[i])) - remap_files[files[i]]=src; - - } - - - { - - //make binary project.godot config - Map<String,Variant> custom; - - - if (remap_files.size()) { - Vector<String> remapsprop; - for(Map<StringName,StringName>::Element *E=remap_files.front();E;E=E->next()) { - print_line("REMAP: "+String(E->key())+" -> "+E->get()); - remapsprop.push_back(E->key()); - remapsprop.push_back(E->get()); - } - - custom["remap/all"]=remapsprop; - } - - //add presaved dependencies - for(Map<StringName,List<StringName> >::Element *E=deps.front();E;E=E->next()) { - - if (E->get().size()==0) - continue; //no deps - String key; - Vector<StringName> deps; - //if bundle continue (when bundles supported obviously) - - if (remap_files.has(E->key())) { - key=remap_files[E->key()]; - } else { - key=E->key(); - } - - deps.resize(E->get().size()); - int i=0; - - for(List<StringName>::Element *F=E->get().front();F;F=F->next()) { - deps[i++]=F->get(); - print_line(" -"+String(F->get())); - } - - NodePath prop(deps,true,String()); //seems best to use this for performance - - custom["deps/"+key.md5_text()]=prop; - - } - - String remap_file="project.binary"; - String engine_cfb =EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmp"+remap_file; - ProjectSettings::get_singleton()->save_custom(engine_cfb,custom); - Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb); - - Error err = p_func(p_udata,"res://"+remap_file,data,counter,files.size()); - if (err) - return err; - - } - - return OK; -} - -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; -}; - -void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags) { - - String host = EditorSettings::get_singleton()->get("network/debug/remote_host"); - int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); - - if (p_flags&EXPORT_REMOTE_DEBUG_LOCALHOST) - host="localhost"; - - if (p_flags&EXPORT_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("--remote-fs"); - r_flags.push_back(host+":"+itos(port)); - if (passwd!="") { - r_flags.push_back("--remote-fs-password"); - r_flags.push_back(passwd); - } - } - - if (p_flags&EXPORT_REMOTE_DEBUG) { - - r_flags.push_back("--remote-debug"); - - r_flags.push_back(host+":"+String::num(remote_port)); - - List<String> breakpoints; - ScriptEditor::get_singleton()->get_breakpoints(&breakpoints); - - - if (breakpoints.size()) { - - r_flags.push_back("--breakpoints"); - 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&EXPORT_VIEW_COLLISONS) { - - r_flags.push_back("--debug-collisions"); - } - - if (p_flags&EXPORT_VIEW_NAVIGATION) { - - r_flags.push_back("--debug-navigation"); - } - - -} - -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; - - CharString cs=p_path.utf8(); - pd->f->store_32(cs.length()); - pd->f->store_buffer((uint8_t*)cs.get_data(),cs.length()); - TempData td; - td.pos=pd->f->get_pos(); - td.ofs=pd->ftmp->get_pos(); - td.size=p_data.size(); - pd->file_ofs.push_back(td); - pd->f->store_64(0); //ofs - pd->f->store_64(0); //size - { - MD5_CTX ctx; - MD5Init(&ctx); - MD5Update(&ctx,(unsigned char*)p_data.ptr(),p_data.size()); - MD5Final(&ctx); - pd->f->store_buffer(ctx.digest,16); - } - pd->ep->step(TTR("Storing File:")+" "+p_path,2+p_file*100/p_total,false); - pd->count++; - pd->ftmp->store_buffer(p_data.ptr(),p_data.size()); - if (pd->alignment > 1) { - - int pad = _get_pad(pd->alignment, pd->ftmp->get_pos()); - for (int i=0; i<pad; i++) { - - pd->ftmp->store_8(0); - }; - }; - 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); - zd->count++; - return OK; - -} - -Error EditorExportPlatform::save_zip(const String& p_path, bool p_make_bundles) { - - 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.count=0; - zd.ep=&ep; - zd.zip=zip; - - - Error err = export_project_files(save_zip_file,&zd,p_make_bundles); - - zipClose(zip,NULL); - - return err; -} - -Error EditorExportPlatform::save_pack(FileAccess *dst,bool p_make_bundles, int p_alignment) { - - EditorProgress ep("savepack",TTR("Packing"),102); - - String tmppath = EditorSettings::get_singleton()->get_settings_path()+"/tmp/packtmp"; - FileAccess *tmp = FileAccess::open(tmppath,FileAccess::WRITE); - uint64_t ofs_begin = dst->get_pos(); - - dst->store_32(0x43504447); //GDPK - dst->store_32(0); //pack version - dst->store_32(VERSION_MAJOR); - dst->store_32(VERSION_MINOR); - dst->store_32(0); //hmph - for(int i=0;i<16;i++) { - //reserved - dst->store_32(0); - } - - size_t fcountpos = dst->get_pos(); - dst->store_32(0); - - PackData pd; - pd.ep=&ep; - pd.f=dst; - pd.ftmp=tmp; - pd.count=0; - pd.alignment = p_alignment; - Error err = export_project_files(save_pack_file,&pd,p_make_bundles); - memdelete(tmp); - if (err) - return err; - - if (p_alignment > 1) { - int pad = _get_pad(p_alignment, dst->get_pos()); - for (int i=0; i<pad; i++) { - - dst->store_8(0); - }; - }; - - size_t ofsplus = dst->get_pos(); - //append file - - tmp = FileAccess::open(tmppath,FileAccess::READ); - - ERR_FAIL_COND_V(!tmp,ERR_CANT_OPEN;) - const int bufsize=16384; - uint8_t buf[bufsize]; - - while(true) { - - int got = tmp->get_buffer(buf,bufsize); - if (got<=0) - break; - dst->store_buffer(buf,got); - } - - memdelete(tmp); - - dst->store_64(dst->get_pos()-ofs_begin); - dst->store_32(0x43504447); //GDPK - - //fix offsets - - dst->seek(fcountpos); - dst->store_32(pd.count); - for(int i=0;i<pd.file_ofs.size();i++) { - - dst->seek(pd.file_ofs[i].pos); - dst->store_64(pd.file_ofs[i].ofs+ofsplus); - dst->store_64(pd.file_ofs[i].size); - } - - return OK; -} - -EditorExportPlatform::EditorExportPlatform() { - - debugging_enabled = true; -} - -Error EditorExportPlatformPC::export_project(const String& p_path, bool p_debug, int p_flags) { - - - - EditorProgress ep("export",vformat(TTR("Exporting for %s"),get_name()),102); - - const int BUFSIZE = 32768; - - - - ep.step(TTR("Setting Up.."),0); - - String exe_path=""; - - if (p_debug) - exe_path=custom_debug_binary; - else - exe_path=custom_release_binary; - - if (exe_path=="") { - String fname; - if (use64) { - if (p_debug) - fname=debug_binary64; - else - fname=release_binary64; - } else { - if (p_debug) - fname=debug_binary32; - else - fname=release_binary32; - } - String err=""; - exe_path=find_export_template(fname,&err); - if (exe_path=="") { - EditorNode::add_io_error(err); - return ERR_FILE_CANT_READ; - } - } - - FileAccess *src_exe=FileAccess::open(exe_path,FileAccess::READ); - if (!src_exe) { - - EditorNode::add_io_error("Couldn't read source executable at:\n "+exe_path); - return ERR_FILE_CANT_READ; - } - - FileAccess *dst=FileAccess::open(p_path,FileAccess::WRITE); - if (!dst) { - - EditorNode::add_io_error("Can't copy executable file to:\n "+p_path); - return ERR_FILE_CANT_WRITE; - } - - uint8_t buff[32768]; - - while(true) { - - int c = src_exe->get_buffer(buff,BUFSIZE); - if (c>0) { - - dst->store_buffer(buff,c); - } else { - break; - } - } - - String dstfile = p_path.replace_first("res://","").replace("\\","/"); - if (export_mode!=EXPORT_EXE) { - - String dstfile_extension=export_mode==EXPORT_ZIP?".zip":".pck"; - if (dstfile.find("/")!=-1) - dstfile=dstfile.get_base_dir()+"/data"+dstfile_extension; - else - dstfile="data"+dstfile_extension; - if (export_mode==EXPORT_PACK) { - - memdelete(dst); - - dst=FileAccess::open(dstfile,FileAccess::WRITE); - if (!dst) { - - EditorNode::add_io_error("Can't write data pack to:\n "+p_path); - return ERR_FILE_CANT_WRITE; - } - } - } - - - - memdelete(src_exe); - - Error err = export_mode==EXPORT_ZIP?save_zip(dstfile,bundle):save_pack(dst,bundle); - memdelete(dst); - return err; -} - -void EditorExportPlatformPC::set_binary_extension(const String& p_extension) { - - binary_extension=p_extension; -} - -EditorExportPlatformPC::EditorExportPlatformPC() { - - export_mode=EXPORT_PACK; - use64=true; -} - - - - - - - - - - -/////////////////////////////////////////////////////////////////////////////////////////////////////// - - -EditorImportExport* EditorImportExport::singleton=NULL; - -void EditorImportExport::add_import_plugin(const Ref<EditorImportPlugin>& p_plugin) { - - // Need to make sure the name is unique if we are going to lookup by it - ERR_FAIL_COND(by_idx.has(p_plugin->get_name())); - - by_idx[ p_plugin->get_name() ]=plugins.size(); - plugins.push_back(p_plugin); -} - -void EditorImportExport::remove_import_plugin(const Ref<EditorImportPlugin>& p_plugin) { - - String plugin_name = p_plugin->get_name(); - - // Keep the indices the same - // Find the index of the target plugin - ERR_FAIL_COND(!by_idx.has(plugin_name)); - int idx = by_idx[plugin_name]; - int last_idx = plugins.size() - 1; - - // Swap the last plugin and the target one - SWAP(plugins[idx], plugins[last_idx]); - - // Update the index of the old last one - by_idx[plugins[idx]->get_name()] = idx; - - // Remove the target plugin's by_idx entry - by_idx.erase(plugin_name); - - // Erase the plugin - plugins.remove(last_idx); -} - -int EditorImportExport::get_import_plugin_count() const{ - - return plugins.size(); -} -Ref<EditorImportPlugin> EditorImportExport::get_import_plugin(int p_idx) const{ - - ERR_FAIL_INDEX_V(p_idx,plugins.size(),Ref<EditorImportPlugin>()); - return plugins[p_idx]; - -} - - - -Ref<EditorImportPlugin> EditorImportExport::get_import_plugin_by_name(const String& p_string) const{ - - ERR_FAIL_COND_V( !by_idx.has(p_string), Ref<EditorImportPlugin>()); - return plugins[ by_idx[p_string] ]; -} - -void EditorImportExport::add_export_plugin(const Ref<EditorExportPlugin>& p_plugin) { - - ERR_FAIL_COND( p_plugin.is_null() ); - - export_plugins.push_back(p_plugin); -} - -void EditorImportExport::remove_export_plugin(const Ref<EditorExportPlugin>& p_plugin) { - - ERR_FAIL_COND( p_plugin.is_null() ); - export_plugins.erase(p_plugin); -} - -int EditorImportExport::get_export_plugin_count() const{ - - return export_plugins.size(); -} -Ref<EditorExportPlugin> EditorImportExport::get_export_plugin(int p_idx) const{ - - ERR_FAIL_INDEX_V(p_idx,export_plugins.size(),Ref<EditorExportPlugin>()); - return export_plugins[p_idx]; -} - -void EditorImportExport::set_export_file_action(const StringName& p_file, FileAction p_action) { - - if (p_action==ACTION_NONE) { - - files.erase(p_file); - } else { - - files[p_file]=p_action; - } - -} - -EditorImportExport::FileAction EditorImportExport::get_export_file_action(const StringName& p_file) const{ - - - if (files.has(p_file)) - return files[p_file]; - - - return ACTION_NONE; -} - -void EditorImportExport::get_export_file_list(List<StringName> *p_files){ - - - for (Map<StringName,FileAction>::Element *E=files.front();E;E=E->next()) { - - p_files->push_back(E->key()); - } - -} - -void EditorImportExport::add_export_platform(const Ref<EditorExportPlatform>& p_export) { - - exporters[p_export->get_name()]=p_export; -} - - -void EditorImportExport::get_export_platforms(List<StringName> *r_platforms) { - - for (Map<StringName,Ref<EditorExportPlatform> >::Element *E=exporters.front();E;E=E->next()) { - - r_platforms->push_back(E->key()); - } -} - -Ref<EditorExportPlatform> EditorImportExport::get_export_platform(const StringName& p_platform) { - - if (exporters.has(p_platform)) { - return exporters[p_platform]; - } else { - return Ref<EditorExportPlatform>(); - } -} - - -bool EditorImportExport::poll_export_platforms() { - - bool changed=false; - for (Map<StringName,Ref<EditorExportPlatform> >::Element *E=exporters.front();E;E=E->next()) { - - if (E->get()->poll_devices()) - changed=true; - } - - return changed; - -} - -void EditorImportExport::set_export_filter(ExportFilter p_enable) { - - export_filter=p_enable; -} - -EditorImportExport::ExportFilter EditorImportExport::get_export_filter() const{ - - return export_filter; -} - -void EditorImportExport::set_export_custom_filter(const String& p_custom_filter){ - export_custom_filter=p_custom_filter; -} -void EditorImportExport::set_export_custom_filter_exclude(const String& p_custom_filter){ - export_custom_filter_exclude=p_custom_filter; -} -String EditorImportExport::get_export_custom_filter() const{ - return export_custom_filter; -} -String EditorImportExport::get_export_custom_filter_exclude() const{ - return export_custom_filter_exclude; -} - -void EditorImportExport::set_export_image_action(ImageAction p_action) { - - image_action=p_action; -} - -EditorImportExport::ImageAction EditorImportExport::get_export_image_action() const{ - - return image_action; -} - -void EditorImportExport::set_export_image_shrink(float p_shrink) { - - image_shrink=p_shrink; -} - -float EditorImportExport::get_export_image_shrink() const{ - - return image_shrink; -} - - -void EditorImportExport::set_export_image_quality(float p_quality){ - - image_action_compress_quality=p_quality; -} - -float EditorImportExport::get_export_image_quality() const{ - - return image_action_compress_quality; -} - -void EditorImportExport::image_export_group_create(const StringName& p_name) { - - ERR_FAIL_COND(image_groups.has(p_name)); - ImageGroup ig; - ig.action=IMAGE_ACTION_NONE; //default - ig.make_atlas=false; - ig.shrink=1; - ig.lossy_quality=0.7; - image_groups[p_name]=ig; - - -} - - -bool EditorImportExport::image_export_has_group(const StringName& p_name) const { - - return image_groups.has(p_name); -} -void EditorImportExport::image_export_get_groups(List<StringName> *r_name) const { - - for (Map<StringName,ImageGroup>::Element *E=image_groups.front();E;E=E->next()) { - - r_name->push_back(E->key()); - } -} - -void EditorImportExport::image_export_group_remove(const StringName& p_name){ - - ERR_FAIL_COND(!image_groups.has(p_name)); - image_groups.erase(p_name); -} -void EditorImportExport::image_export_group_set_image_action(const StringName& p_export_group,ImageAction p_action){ - - ERR_FAIL_COND(!image_groups.has(p_export_group)); - image_groups[p_export_group].action=p_action; - -} -EditorImportExport::ImageAction EditorImportExport::image_export_group_get_image_action(const StringName& p_export_group) const{ - - ERR_FAIL_COND_V(!image_groups.has(p_export_group),IMAGE_ACTION_NONE); - return image_groups[p_export_group].action; - -} -void EditorImportExport::image_export_group_set_make_atlas(const StringName& p_export_group,bool p_make){ - - ERR_FAIL_COND(!image_groups.has(p_export_group)); - image_groups[p_export_group].make_atlas=p_make; - -} -bool EditorImportExport::image_export_group_get_make_atlas(const StringName& p_export_group) const{ - - ERR_FAIL_COND_V(!image_groups.has(p_export_group),false); - return image_groups[p_export_group].make_atlas; - -} -void EditorImportExport::image_export_group_set_shrink(const StringName& p_export_group,float p_amount){ - ERR_FAIL_COND(!image_groups.has(p_export_group)); - image_groups[p_export_group].shrink=p_amount; - -} -float EditorImportExport::image_export_group_get_shrink(const StringName& p_export_group) const{ - - ERR_FAIL_COND_V(!image_groups.has(p_export_group),1); - return image_groups[p_export_group].shrink; - -} - -void EditorImportExport::image_export_group_set_lossy_quality(const StringName& p_export_group,float p_amount){ - ERR_FAIL_COND(!image_groups.has(p_export_group)); - image_groups[p_export_group].lossy_quality=p_amount; - -} -float EditorImportExport::image_export_group_get_lossy_quality(const StringName& p_export_group) const{ - - ERR_FAIL_COND_V(!image_groups.has(p_export_group),1); - return image_groups[p_export_group].lossy_quality; - -} - -StringName EditorImportExport::image_get_export_group(const StringName& p_image) const { - - if (image_group_files.has(p_image)) - return image_group_files[p_image]; - else - return StringName(); - -} - -void EditorImportExport::image_add_to_export_group(const StringName& p_image,const StringName& p_export_group) { - - - bool emptygroup = String(p_export_group)==String(); - ERR_FAIL_COND(!emptygroup && !image_groups.has(p_export_group)); - - if (emptygroup) - image_group_files.erase(p_image); - else - image_group_files[p_image]=p_export_group; -} - -void EditorImportExport::image_export_get_images_in_group(const StringName& p_group,List<StringName> *r_images) const { - - for (Map<StringName,StringName>::Element *E=image_group_files.front();E;E=E->next()) { - - if (p_group==E->get()) - r_images->push_back(E->key()); - } -} - -void EditorImportExport::set_convert_text_scenes(bool p_convert) { - - convert_text_scenes=p_convert; -} - -bool EditorImportExport::get_convert_text_scenes() const{ - - return convert_text_scenes; -} - - -void EditorImportExport::load_config() { - - Ref<ConfigFile> cf = memnew( ConfigFile ); - - Error err = cf->load("res://export.cfg"); - if (err!=OK) - return; //no export config to be loaded! - - - export_custom_filter=cf->get_value("export_filter","filter"); - export_custom_filter_exclude=cf->get_value("export_filter","filter_exclude"); - String t=cf->get_value("export_filter","type"); - if (t=="selected") - export_filter=EXPORT_SELECTED; - else if (t=="resources") - export_filter=EXPORT_RESOURCES; - else if (t=="all") - export_filter=EXPORT_ALL; - - if (cf->has_section("convert_images")) { - - String ci = "convert_images"; - String action = cf->get_value(ci,"action"); - if (action=="none") - image_action=IMAGE_ACTION_NONE; - else if (action=="compress_ram") - image_action=IMAGE_ACTION_COMPRESS_RAM; - else if (action=="compress_disk") - image_action=IMAGE_ACTION_COMPRESS_DISK; - - image_action_compress_quality = cf->get_value(ci,"compress_quality"); - if (cf->has_section_key(ci,"shrink")) - image_shrink = cf->get_value(ci,"shrink"); - else - image_shrink=1; - String formats=cf->get_value(ci,"formats"); - Vector<String> f = formats.split(","); - image_formats.clear(); - for(int i=0;i<f.size();i++) { - image_formats.insert(f[i].strip_edges()); - } - } - - if (cf->has_section("convert_scenes")) { - - convert_text_scenes = cf->get_value("convert_scenes","convert_text_scenes"); - } - - - if (cf->has_section("export_filter_files")) { - - - String eff = "export_filter_files"; - List<String> k; - cf->get_section_keys(eff,&k); - for(List<String>::Element *E=k.front();E;E=E->next()) { - - String val = cf->get_value(eff,E->get()); - if (val=="copy") { - files[E->get()]=ACTION_COPY; - } else if (val=="bundle") { - files[E->get()]=ACTION_BUNDLE; - } - } - } - - List<String> sect; - - cf->get_sections(§); - - for(List<String>::Element *E=sect.front();E;E=E->next()) { - - String s = E->get(); - if (!s.begins_with("platform:")) - continue; - String p = s.substr(s.find(":")+1,s.length()); - - if (!exporters.has(p)) - continue; - - Ref<EditorExportPlatform> ep = exporters[p]; - if (!ep.is_valid()) { - continue; - } - List<String> keys; - cf->get_section_keys(s,&keys); - for(List<String>::Element *F=keys.front();F;F=F->next()) { - ep->set(F->get(),cf->get_value(s,F->get())); - } - } - - //save image groups - - if (cf->has_section("image_groups")) { - - sect.clear(); - cf->get_section_keys("image_groups",§); - for(List<String>::Element *E=sect.front();E;E=E->next()) { - - Dictionary d = cf->get_value("image_groups",E->get()); - ImageGroup g; - g.action=IMAGE_ACTION_NONE; - g.make_atlas=false; - g.lossy_quality=0.7; - g.shrink=1; - - if (d.has("action")) { - String action=d["action"]; - if (action=="compress_ram") - g.action=IMAGE_ACTION_COMPRESS_RAM; - else if (action=="compress_disk") - g.action=IMAGE_ACTION_COMPRESS_DISK; - else if (action=="keep") - g.action=IMAGE_ACTION_KEEP; - } - - if (d.has("atlas")) - g.make_atlas=d["atlas"]; - if (d.has("lossy_quality")) - g.lossy_quality=d["lossy_quality"]; - if (d.has("shrink")) { - - g.shrink=d["shrink"]; - g.shrink=CLAMP(g.shrink,1,8); - } - - image_groups[E->get()]=g; - - } - - if (cf->has_section_key("image_group_files","files")) { - - Vector<String> sa=cf->get_value("image_group_files","files"); - if (sa.size()%2==0) { - for(int i=0;i<sa.size();i+=2) { - image_group_files[sa[i]]=sa[i+1]; - } - } - } - - } - - - if (cf->has_section("script")) { - - if (cf->has_section_key("script","action")) { - - String action = cf->get_value("script","action"); - if (action=="compile") - script_action=SCRIPT_ACTION_COMPILE; - else if (action=="encrypt") - script_action=SCRIPT_ACTION_ENCRYPT; - else - script_action=SCRIPT_ACTION_NONE; - - } - - if (cf->has_section_key("script","encrypt_key")) { - - script_key = cf->get_value("script","encrypt_key"); - } - } - - if (cf->has_section("convert_samples")) { - - if (cf->has_section_key("convert_samples","action")) { - String action = cf->get_value("convert_samples","action"); - if (action=="none") { - sample_action=SAMPLE_ACTION_NONE; - } else if (action=="compress_ram") { - sample_action=SAMPLE_ACTION_COMPRESS_RAM; - } - } - - if (cf->has_section_key("convert_samples","max_hz")) - sample_action_max_hz=cf->get_value("convert_samples","max_hz"); - - if (cf->has_section_key("convert_samples","trim")) - sample_action_trim=cf->get_value("convert_samples","trim"); - } - - - -} - - - - - -void EditorImportExport::save_config() { - - Ref<ConfigFile> cf = memnew( ConfigFile ); - - switch(export_filter) { - case EXPORT_SELECTED: cf->set_value("export_filter","type","selected"); break; - case EXPORT_RESOURCES: cf->set_value("export_filter","type","resources"); break; - case EXPORT_ALL: cf->set_value("export_filter","type","all"); break; - } - - cf->set_value("export_filter","filter",export_custom_filter); - cf->set_value("export_filter", "filter_exclude",export_custom_filter_exclude); - - String file_action_section = "export_filter_files"; - - for (Map<StringName,FileAction>::Element *E=files.front();E;E=E->next()) { - - String f=E->key(); - String a; - switch (E->get()) { - case ACTION_NONE: {} - case ACTION_COPY: a="copy"; break; - case ACTION_BUNDLE: a="bundle"; break; - } - - cf->set_value(file_action_section,f,a); - } - - - for (Map<StringName,Ref<EditorExportPlatform> >::Element *E=exporters.front();E;E=E->next()) { - - String pname = "platform:"+String(E->key()); - - Ref<EditorExportPlatform> ep = E->get(); - - List<PropertyInfo> pl; - ep->get_property_list(&pl); - - for (List<PropertyInfo>::Element *F=pl.front();F;F=F->next()) { - - cf->set_value(pname,F->get().name,ep->get(F->get().name)); - } - - } - - switch(image_action) { - case IMAGE_ACTION_NONE: cf->set_value("convert_images","action","none"); break; - case IMAGE_ACTION_COMPRESS_RAM: cf->set_value("convert_images","action","compress_ram"); break; - case IMAGE_ACTION_COMPRESS_DISK: cf->set_value("convert_images","action","compress_disk"); break; - } - - cf->set_value("convert_images","shrink",image_shrink); - cf->set_value("convert_images","compress_quality",image_action_compress_quality); - - String formats; - for(Set<String>::Element *E=image_formats.front();E;E=E->next()) { - - if (E!=image_formats.front()) - formats+=","; - formats+=E->get(); - } - - cf->set_value("convert_images","formats",formats); - - //save image groups - - for(Map<StringName,ImageGroup>::Element *E=image_groups.front();E;E=E->next()) { - - Dictionary d; - switch(E->get().action) { - case IMAGE_ACTION_NONE: d["action"]="default"; break; - case IMAGE_ACTION_COMPRESS_RAM: d["action"]="compress_ram"; break; - case IMAGE_ACTION_COMPRESS_DISK: d["action"]="compress_disk"; break; - case IMAGE_ACTION_KEEP: d["action"]="keep"; break; - } - - - d["atlas"]=E->get().make_atlas; - d["shrink"]=E->get().shrink; - d["lossy_quality"]=E->get().lossy_quality; - cf->set_value("image_groups",E->key(),d); - - } - - if (image_groups.size() && image_group_files.size()){ - - Vector<String> igfkeys; - igfkeys.resize(image_group_files.size()); - int idx=0; - for (Map<StringName,StringName>::Element *E=image_group_files.front();E;E=E->next()) { - igfkeys[idx++]=E->key(); - } - igfkeys.sort(); - - Vector<String> igfsave; - igfsave.resize(image_group_files.size()*2); - idx=0; - for (int i=0;i<igfkeys.size();++i) { - - igfsave[idx++]=igfkeys[i]; - igfsave[idx++]=image_group_files[igfkeys[i]]; - } - cf->set_value("image_group_files","files",igfsave); - } - - switch(script_action) { - case SCRIPT_ACTION_NONE: cf->set_value("script","action","none"); break; - case SCRIPT_ACTION_COMPILE: cf->set_value("script","action","compile"); break; - case SCRIPT_ACTION_ENCRYPT: cf->set_value("script","action","encrypt"); break; - } - - cf->set_value("convert_scenes","convert_text_scenes",convert_text_scenes); - - cf->set_value("script","encrypt_key",script_key); - - switch(sample_action) { - case SAMPLE_ACTION_NONE: cf->set_value("convert_samples","action","none"); break; - case SAMPLE_ACTION_COMPRESS_RAM: cf->set_value("convert_samples","action","compress_ram"); break; - } - - cf->set_value("convert_samples","max_hz",sample_action_max_hz); - cf->set_value("convert_samples","trim",sample_action_trim); - - cf->save("res://export.cfg"); - -} - - -void EditorImportExport::script_set_action(ScriptAction p_action) { - - script_action=p_action; -} - -EditorImportExport::ScriptAction EditorImportExport::script_get_action() const{ - - return script_action; -} - -void EditorImportExport::script_set_encryption_key(const String& p_key){ - - script_key=p_key; -} -String EditorImportExport::script_get_encryption_key() const{ - - return script_key; -} - - -void EditorImportExport::sample_set_action(SampleAction p_action) { - - sample_action=p_action; -} - -EditorImportExport::SampleAction EditorImportExport::sample_get_action() const{ - - return sample_action; -} - -void EditorImportExport::sample_set_max_hz(int p_hz){ - - sample_action_max_hz=p_hz; -} -int EditorImportExport::sample_get_max_hz() const{ - - return sample_action_max_hz; -} - -void EditorImportExport::sample_set_trim(bool p_trim){ - - sample_action_trim=p_trim; -} -bool EditorImportExport::sample_get_trim() const{ - - return sample_action_trim; -} - -PoolVector<String> EditorImportExport::_get_export_file_list() { - - PoolVector<String> fl; - for (Map<StringName,FileAction>::Element *E=files.front();E;E=E->next()) { - - fl.push_back(E->key()); - } - - return fl; -} - -PoolVector<String> EditorImportExport::_get_export_platforms() { - - PoolVector<String> ep; - for (Map<StringName,Ref<EditorExportPlatform> >::Element *E=exporters.front();E;E=E->next()) { - - ep.push_back(E->key()); - } - - return ep; - -} - -void EditorImportExport::_bind_methods() { - - ClassDB::bind_method(D_METHOD("add_import_plugin","plugin"),&EditorImportExport::add_import_plugin); - ClassDB::bind_method(D_METHOD("remove_import_plugin","plugin"),&EditorImportExport::remove_import_plugin); - ClassDB::bind_method(D_METHOD("get_import_plugin_count"),&EditorImportExport::get_import_plugin_count); - ClassDB::bind_method(D_METHOD("get_import_plugin","idx"),&EditorImportExport::get_import_plugin); - ClassDB::bind_method(D_METHOD("get_import_plugin_by_name","name"),&EditorImportExport::get_import_plugin_by_name); - - ClassDB::bind_method(D_METHOD("add_export_plugin","plugin"),&EditorImportExport::add_export_plugin); - ClassDB::bind_method(D_METHOD("remove_export_plugin","plugin"),&EditorImportExport::remove_export_plugin); - ClassDB::bind_method(D_METHOD("get_export_plugin_count"),&EditorImportExport::get_export_plugin_count); - ClassDB::bind_method(D_METHOD("get_export_plugin","idx"),&EditorImportExport::get_export_plugin); - - ClassDB::bind_method(D_METHOD("set_export_file_action","file","action"),&EditorImportExport::set_export_file_action); - ClassDB::bind_method(D_METHOD("get_export_file_action","file"),&EditorImportExport::get_export_file_action); - ClassDB::bind_method(D_METHOD("get_export_file_list"),&EditorImportExport::_get_export_file_list); - - ClassDB::bind_method(D_METHOD("add_export_platform","platform"),&EditorImportExport::add_export_platform); - //ClassDB::bind_method(D_METHOD("remove_export_platform","platform"),&EditorImportExport::add_export_platform); - ClassDB::bind_method(D_METHOD("get_export_platform","name"),&EditorImportExport::get_export_platform); - ClassDB::bind_method(D_METHOD("get_export_platforms"),&EditorImportExport::_get_export_platforms); - - ClassDB::bind_method(D_METHOD("set_export_filter","filter"),&EditorImportExport::set_export_filter); - ClassDB::bind_method(D_METHOD("get_export_filter"),&EditorImportExport::get_export_filter); - - ClassDB::bind_method(D_METHOD("set_export_custom_filter","filter"),&EditorImportExport::set_export_custom_filter); - ClassDB::bind_method(D_METHOD("get_export_custom_filter"),&EditorImportExport::get_export_custom_filter); - - ClassDB::bind_method(D_METHOD("set_export_custom_filter_exclude","filter_exclude"),&EditorImportExport::set_export_custom_filter_exclude); - ClassDB::bind_method(D_METHOD("get_export_custom_filter_exclude"),&EditorImportExport::get_export_custom_filter_exclude); - - - ClassDB::bind_method(D_METHOD("image_export_group_create"),&EditorImportExport::image_export_group_create); - ClassDB::bind_method(D_METHOD("image_export_group_remove"),&EditorImportExport::image_export_group_remove); - ClassDB::bind_method(D_METHOD("image_export_group_set_image_action"),&EditorImportExport::image_export_group_set_image_action); - ClassDB::bind_method(D_METHOD("image_export_group_set_make_atlas"),&EditorImportExport::image_export_group_set_make_atlas); - ClassDB::bind_method(D_METHOD("image_export_group_set_shrink"),&EditorImportExport::image_export_group_set_shrink); - ClassDB::bind_method(D_METHOD("image_export_group_get_image_action"),&EditorImportExport::image_export_group_get_image_action); - ClassDB::bind_method(D_METHOD("image_export_group_get_make_atlas"),&EditorImportExport::image_export_group_get_make_atlas); - ClassDB::bind_method(D_METHOD("image_export_group_get_shrink"),&EditorImportExport::image_export_group_get_shrink); - ClassDB::bind_method(D_METHOD("image_add_to_export_group"),&EditorImportExport::image_add_to_export_group); - ClassDB::bind_method(D_METHOD("script_set_action"),&EditorImportExport::script_set_action); - ClassDB::bind_method(D_METHOD("script_set_encryption_key"),&EditorImportExport::script_set_encryption_key); - ClassDB::bind_method(D_METHOD("script_get_action"),&EditorImportExport::script_get_action); - ClassDB::bind_method(D_METHOD("script_get_encryption_key"),&EditorImportExport::script_get_encryption_key); - - - - BIND_ENUM_CONSTANT( ACTION_NONE ); - BIND_ENUM_CONSTANT( ACTION_COPY ); - BIND_ENUM_CONSTANT( ACTION_BUNDLE ); - - BIND_ENUM_CONSTANT( EXPORT_SELECTED ); - BIND_ENUM_CONSTANT( EXPORT_RESOURCES ); - BIND_ENUM_CONSTANT( EXPORT_ALL ); - - BIND_ENUM_CONSTANT( IMAGE_ACTION_NONE ); - BIND_ENUM_CONSTANT( IMAGE_ACTION_COMPRESS_DISK ); - BIND_ENUM_CONSTANT( IMAGE_ACTION_COMPRESS_RAM ); - BIND_ENUM_CONSTANT( IMAGE_ACTION_KEEP ); - - BIND_ENUM_CONSTANT( SCRIPT_ACTION_NONE ); - BIND_ENUM_CONSTANT( SCRIPT_ACTION_COMPILE ); - BIND_ENUM_CONSTANT( SCRIPT_ACTION_ENCRYPT ); -}; - - - -EditorImportExport::EditorImportExport() { - - export_filter=EXPORT_RESOURCES; - singleton=this; - image_action=IMAGE_ACTION_NONE; - image_action_compress_quality=0.7; - image_formats.insert("png"); - image_shrink=1; - - - script_action=SCRIPT_ACTION_COMPILE; - - sample_action=SAMPLE_ACTION_NONE; - sample_action_max_hz=44100; - sample_action_trim=false; - - convert_text_scenes=true; - -} - - - -EditorImportExport::~EditorImportExport() { - - - -} -#endif diff --git a/editor/editor_export.h b/editor/editor_export.h index df42b0d95d..feff9678af 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 6e4a848517..ab994dbe75 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index f44193c70b..3b22189014 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 9d194e0501..9d110c7136 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h index fd62b06d07..4d9a96d233 100644 --- a/editor/editor_file_system.h +++ b/editor/editor_file_system.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 4a85b4e2ef..c4ac4cbca5 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_fonts.h b/editor/editor_fonts.h index 1698093cca..6a55876fd0 100644 --- a/editor/editor_fonts.h +++ b/editor/editor_fonts.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 17105606df..c7c3a88684 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -530,49 +530,6 @@ void EditorHelp::_search(const String &) { prev_search = stext; } -#if 0 -void EditorHelp::_button_pressed(int p_idx) { - - if (p_idx==PAGE_CLASS_LIST) { - - //edited_class->set_pressed(false); - //class_list_button->set_pressed(true); - //tabs->set_current_tab(PAGE_CLASS_LIST); - - } else if (p_idx==PAGE_CLASS_DESC) { - - //edited_class->set_pressed(true); - //class_list_button->set_pressed(false); - //tabs->set_current_tab(PAGE_CLASS_DESC); - - } else if (p_idx==PAGE_CLASS_PREV) { - - if (history_pos<2) - return; - history_pos--; - ERR_FAIL_INDEX(history_pos-1,history.size()); - _goto_desc(history[history_pos-1].c,false,history[history_pos-1].scroll); - _update_history_buttons(); - - - } else if (p_idx==PAGE_CLASS_NEXT) { - - if (history_pos>=history.size()) - return; - - history_pos++; - ERR_FAIL_INDEX(history_pos-1,history.size()); - _goto_desc(history[history_pos-1].c,false,history[history_pos-1].scroll); - _update_history_buttons(); - - } else if (p_idx==PAGE_SEARCH) { - - _search(""); - } -} - -#endif - void EditorHelp::_class_list_select(const String &p_select) { _goto_desc(p_select); diff --git a/editor/editor_help.h b/editor/editor_help.h index db97ab9b28..30a535a535 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_initialize_ssl.cpp b/editor/editor_initialize_ssl.cpp index 290ade277e..4bc194a47c 100644 --- a/editor/editor_initialize_ssl.cpp +++ b/editor/editor_initialize_ssl.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_initialize_ssl.h b/editor/editor_initialize_ssl.h index fb289f5dfd..cad219c56b 100644 --- a/editor/editor_initialize_ssl.h +++ b/editor/editor_initialize_ssl.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index c5e15b97b0..a1f416a17c 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_log.h b/editor/editor_log.h index 1c180df5f7..fd919fd692 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_name_dialog.cpp b/editor/editor_name_dialog.cpp index 74bb526ccc..9f3593c269 100644 --- a/editor/editor_name_dialog.cpp +++ b/editor/editor_name_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_name_dialog.h b/editor/editor_name_dialog.h index 57586951d1..2ec8c67169 100644 --- a/editor/editor_name_dialog.h +++ b/editor/editor_name_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 06e9860552..c376efca34 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -56,7 +56,6 @@ #include "editor/editor_help.h" #include "editor/editor_initialize_ssl.h" #include "editor/editor_settings.h" -#include "editor/editor_settings.h" #include "editor/editor_themes.h" #include "editor/import/editor_import_collada.h" #include "editor/import/editor_scene_importer_gltf.h" @@ -65,18 +64,9 @@ #include "editor/import/resource_importer_scene.h" #include "editor/import/resource_importer_texture.h" #include "editor/import/resource_importer_wav.h" -#include "editor/io_plugins/editor_bitmask_import_plugin.h" -#include "editor/io_plugins/editor_export_scene.h" -#include "editor/io_plugins/editor_font_import_plugin.h" -#include "editor/io_plugins/editor_mesh_import_plugin.h" -#include "editor/io_plugins/editor_scene_import_plugin.h" -#include "editor/io_plugins/editor_scene_importer_fbxconv.h" -#include "editor/io_plugins/editor_texture_import_plugin.h" -#include "editor/io_plugins/editor_translation_import_plugin.h" #include "editor/plugins/animation_player_editor_plugin.h" #include "editor/plugins/animation_tree_editor_plugin.h" #include "editor/plugins/asset_library_editor_plugin.h" -#include "editor/plugins/baked_light_editor_plugin.h" #include "editor/plugins/camera_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" #include "editor/plugins/collision_polygon_2d_editor_plugin.h" @@ -107,7 +97,6 @@ #include "editor/plugins/shader_graph_editor_plugin.h" #include "editor/plugins/spatial_editor_plugin.h" #include "editor/plugins/sprite_frames_editor_plugin.h" -#include "editor/plugins/stream_editor_plugin.h" #include "editor/plugins/style_box_editor_plugin.h" #include "editor/plugins/texture_editor_plugin.h" #include "editor/plugins/texture_region_editor_plugin.h" @@ -982,26 +971,6 @@ void EditorNode::_dialog_action(String p_file) { //would be nice to show the project manager opened with the highlighted field.. _run(false, ""); // automatically run the project } break; - case FILE_RUN_SCRIPT: { - - Ref<Script> scr = ResourceLoader::load(p_file, "Script", true); - if (scr.is_null()) { - add_io_error("Script Failed to Load:\n" + p_file); - return; - } - if (!scr->is_tool()) { - - add_io_error("Script is not tool, will not be able to run:\n" + p_file); - return; - } - - Ref<EditorScript> es = memnew(EditorScript); - es->set_script(scr.get_ref_ptr()); - es->set_editor(this); - es->_run(); - - get_undo_redo()->clear_history(); - } break; case FILE_CLOSE: case FILE_CLOSE_ALL_AND_QUIT: case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER: @@ -1662,10 +1631,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { quick_open->set_title(TTR("Quick Open Script..")); } break; - case FILE_RUN_SCRIPT: { - - file_script->popup_centered_ratio(); - } break; case FILE_OPEN_PREV: { if (previous_scenes.empty()) @@ -4816,7 +4781,7 @@ EditorNode::EditorNode() { p->add_item(TTR("Project Settings"), RUN_SETTINGS); p->add_separator(); p->connect("id_pressed", this, "_menu_option"); - p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R); + //p->add_item(TTR("Run Script"), FILE_RUN_SCRIPT, KEY_MASK_SHIFT + KEY_MASK_CMD + KEY_R); p->add_item(TTR("Export"), FILE_EXPORT_PROJECT); PopupMenu *tool_menu = memnew(PopupMenu); diff --git a/editor/editor_node.h b/editor/editor_node.h index 8a02b16ca2..08c7e11c85 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -30,7 +30,6 @@ #ifndef EDITOR_NODE_H #define EDITOR_NODE_H -#include "editor/call_dialog.h" #include "editor/connections_dialog.h" #include "editor/create_dialog.h" #include "editor/editor_about.h" @@ -40,7 +39,6 @@ #include "editor/editor_name_dialog.h" #include "editor/editor_path.h" #include "editor/editor_plugin.h" -#include "editor/editor_reimport_dialog.h" #include "editor/editor_resource_preview.h" #include "editor/editor_run.h" #include "editor/editor_run_native.h" @@ -131,7 +129,6 @@ private: FILE_OPEN_OLD_SCENE, FILE_QUICK_OPEN_SCENE, FILE_QUICK_OPEN_SCRIPT, - FILE_RUN_SCRIPT, FILE_OPEN_PREV, FILE_CLOSE, FILE_CLOSE_ALL_AND_QUIT, diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index 24206b0f0d..92768dfe91 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_path.h b/editor/editor_path.h index 7b73e7ebb6..c79968c5e3 100644 --- a/editor/editor_path.h +++ b/editor/editor_path.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index a6e28e045e..06e4bb5aa6 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index df094f4c50..ce75cfd27a 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp index 712a3ac001..6732d7048f 100644 --- a/editor/editor_plugin_settings.cpp +++ b/editor/editor_plugin_settings.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h index 472be4c007..f24b2b8781 100644 --- a/editor/editor_plugin_settings.h +++ b/editor/editor_plugin_settings.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index 78bc99caae..6b972262b9 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_profiler.h b/editor/editor_profiler.h index 4998d45a89..e2d781f125 100644 --- a/editor/editor_profiler.h +++ b/editor/editor_profiler.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_reimport_dialog.cpp b/editor/editor_reimport_dialog.cpp deleted file mode 100644 index 4b71f7046f..0000000000 --- a/editor/editor_reimport_dialog.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/*************************************************************************/ -/* editor_reimport_dialog.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_reimport_dialog.h" - -#include "editor_file_system.h" -#include "editor_node.h" - -#if 0 -void EditorReImportDialog::popup_reimport() { - - if (EditorFileSystem::get_singleton()->is_scanning()) { - error->set_text(TTR("Please wait for scan to complete.")); - error->popup_centered_minsize(); - return; - } - - tree->clear(); - items.clear(); - List<String> ril; - EditorFileSystem::get_singleton()->get_changed_sources(&ril); - - scene_must_save=false; - - - TreeItem *root = tree->create_item(); - for(List<String>::Element *E=ril.front();E;E=E->next()) { - - TreeItem *item = tree->create_item(root); - item->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); - item->set_metadata(0,E->get()); - item->set_text(0,E->get().replace_first("res://","")); - item->set_tooltip(0,E->get()); - item->set_checked(0,true); - item->set_editable(0,true); - items.push_back(item); - - String name = E->get(); - - if (EditorFileSystem::get_singleton()->get_file_type(name)=="PackedScene" && EditorNode::get_singleton()->is_scene_in_use(name)) { - - scene_must_save=true; - } - } - - - if (scene_must_save) { - if (EditorNode::get_singleton()->get_edited_scene() && EditorNode::get_singleton()->get_edited_scene()->get_filename()=="") { - - error->set_text(TTR("Current scene must be saved to re-import.")); - error->popup_centered_minsize(); - get_ok()->set_text(TTR("Re-Import")); - get_ok()->set_disabled(true); - return; - - } - get_ok()->set_disabled(false); - get_ok()->set_text(TTR("Save & Re-Import")); - } else { - get_ok()->set_text(TTR("Re-Import")); - get_ok()->set_disabled(false); - } - - popup_centered(Size2(600,400)); - - -} - - -void EditorReImportDialog::ok_pressed() { - - if (EditorFileSystem::get_singleton()->is_scanning()) { - error->set_text(TTR("Please wait for scan to complete.")); - error->popup_centered_minsize(); - return; - } - - - - EditorProgress ep("reimport",TTR("Re-Importing"),items.size()); - String reload_fname; - if (scene_must_save && EditorNode::get_singleton()->get_edited_scene()) { - reload_fname = EditorNode::get_singleton()->get_edited_scene()->get_filename(); - EditorNode::get_singleton()->save_scene(reload_fname); - EditorNode::get_singleton()->clear_scene(); - } - - for(int i=0;i<items.size();i++) { - - String it = items[i]->get_metadata(0); - ep.step(items[i]->get_text(0),i); - print_line("reload import from: "+it); - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(it); - ERR_CONTINUE(rimd.is_null()); - String editor = rimd->get_editor(); - Ref<EditorImportPlugin> eip = EditorImportExport::get_singleton()->get_import_plugin_by_name(editor); - ERR_CONTINUE(eip.is_null()); - Error err = eip->import(it,rimd); - if (err!=OK) { - EditorNode::add_io_error("Error Importing:\n "+it); - } - - } - if (reload_fname!="") { - EditorNode::get_singleton()->load_scene(reload_fname); - } - - EditorFileSystem::get_singleton()->scan_sources(); -} - -EditorReImportDialog::EditorReImportDialog() { - - tree = memnew( Tree ); - add_child(tree); - tree->set_hide_root(true); - //set_child_rect(tree); - set_title(TTR("Re-Import Changed Resources")); - error = memnew( AcceptDialog); - add_child(error); - scene_must_save=false; - -} -#endif diff --git a/editor/editor_reimport_dialog.h b/editor/editor_reimport_dialog.h deleted file mode 100644 index b067630ded..0000000000 --- a/editor/editor_reimport_dialog.h +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************/ -/* editor_reimport_dialog.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_REIMPORT_DIALOG_H -#define EDITOR_REIMPORT_DIALOG_H - -#if 0 -#include "scene/gui/dialogs.h" -#include "scene/gui/tree.h" - -class EditorReImportDialog : public ConfirmationDialog { - - GDCLASS(EditorReImportDialog,ConfirmationDialog); - - Tree *tree; - Vector<TreeItem*> items; - AcceptDialog *error; - bool scene_must_save; - - void ok_pressed(); -public: - - void popup_reimport(); - EditorReImportDialog(); -}; - -#endif // EDITOR_REIMPORT_DIALOG_H -#endif diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 99ce843880..ee477b7c18 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_resource_preview.h b/editor/editor_resource_preview.h index cedd571194..60eaee9c5e 100644 --- a/editor/editor_resource_preview.h +++ b/editor/editor_resource_preview.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 9a0731eb55..e377fa1a8e 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_run.h b/editor/editor_run.h index aa698ffad1..3745a76ea3 100644 --- a/editor/editor_run.h +++ b/editor/editor_run.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 8c04ea8f9c..95700915d5 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_run_native.h b/editor/editor_run_native.h index 9dcfd88eb8..de0cec7f34 100644 --- a/editor/editor_run_native.h +++ b/editor/editor_run_native.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_run_script.cpp b/editor/editor_run_script.cpp index 990c0cfbe9..87eba78a3e 100644 --- a/editor/editor_run_script.cpp +++ b/editor/editor_run_script.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_run_script.h b/editor/editor_run_script.h index 9bb9917c1c..52905ccc86 100644 --- a/editor/editor_run_script.h +++ b/editor/editor_run_script.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_scale.cpp b/editor/editor_scale.cpp index 1238cbb405..6b4d6192f5 100644 --- a/editor/editor_scale.cpp +++ b/editor/editor_scale.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_scale.h b/editor/editor_scale.h index 953be2ef81..a47539dc31 100644 --- a/editor/editor_scale.h +++ b/editor/editor_scale.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index c30ffd4b4e..b9a6414b08 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -674,6 +674,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { set("editors/3d/warped_mouse_panning", true); set("editors/3d/orbit_sensitivity", 0.4); + set("editors/3d/freelook_inertia", 3); set("editors/3d/freelook_base_speed", 1); diff --git a/editor/editor_settings.h b/editor/editor_settings.h index b479d21dfb..177ec4760d 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -35,7 +35,7 @@ #include "core/io/config_file.h" #include "os/thread_safe.h" #include "resource.h" -#include "scene/gui/input_action.h" +#include "scene/gui/shortcut.h" #include "translation.h" class EditorPlugin; diff --git a/editor/editor_sub_scene.cpp b/editor/editor_sub_scene.cpp index c107d3687e..b81dfd3f46 100644 --- a/editor/editor_sub_scene.cpp +++ b/editor/editor_sub_scene.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_sub_scene.h b/editor/editor_sub_scene.h index 3a11a13b53..13ce19bbb2 100644 --- a/editor/editor_sub_scene.h +++ b/editor/editor_sub_scene.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index f628a23d5f..a527701563 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/editor_themes.h b/editor/editor_themes.h index 8a652ba6f1..a644c5936f 100644 --- a/editor/editor_themes.h +++ b/editor/editor_themes.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 5ff9b795d7..147d5f90c6 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -313,77 +313,6 @@ void ExportTemplateManager::_bind_methods() { ClassDB::bind_method("_uninstall_template", &ExportTemplateManager::_uninstall_template); ClassDB::bind_method("_uninstall_template_confirm", &ExportTemplateManager::_uninstall_template_confirm); ClassDB::bind_method("_install_from_file", &ExportTemplateManager::_install_from_file); - -#if 0 - FileAccess *fa = NULL; - zlib_filefunc_def io = zipio_create_io_from_file(&fa); - - unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io); - if (!pkg) { - - current_option = -1; - //confirmation->get_cancel()->hide(); - accept->get_ok()->set_text(TTR("I see..")); - accept->set_text(TTR("Can't open export templates zip.")); - accept->popup_centered_minsize(); - return; - } - int ret = unzGoToFirstFile(pkg); - - int fc = 0; //count them - - while (ret == UNZ_OK) { - fc++; - ret = unzGoToNextFile(pkg); - } - - ret = unzGoToFirstFile(pkg); - - EditorProgress p("ltask", TTR("Loading Export Templates"), fc); - - fc = 0; - - while (ret == UNZ_OK) { - - //get filename - unz_file_info info; - char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); - - String file = fname; - - Vector<uint8_t> data; - data.resize(info.uncompressed_size); - - //read - ret = unzOpenCurrentFile(pkg); - ret = unzReadCurrentFile(pkg, data.ptr(), data.size()); - unzCloseCurrentFile(pkg); - - print_line(fname); - /* - for(int i=0;i<512;i++) { - print_line(itos(data[i])); - } - */ - - file = file.get_file(); - - p.step(TTR("Importing:") + " " + file, fc); - - FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_settings_path() + "/templates/" + file, FileAccess::WRITE); - - ERR_CONTINUE(!f); - f->store_buffer(data.ptr(), data.size()); - - memdelete(f); - - ret = unzGoToNextFile(pkg); - fc++; - } - - unzClose(pkg); -#endif } ExportTemplateManager::ExportTemplateManager() { diff --git a/editor/export_template_manager.h b/editor/export_template_manager.h index 480c73e123..ce6d8024ae 100644 --- a/editor/export_template_manager.h +++ b/editor/export_template_manager.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/file_type_cache.cpp b/editor/file_type_cache.cpp index 728e80bba7..c8b21acb36 100644 --- a/editor/file_type_cache.cpp +++ b/editor/file_type_cache.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/file_type_cache.h b/editor/file_type_cache.h index a434384eb4..307e8e27bb 100644 --- a/editor/file_type_cache.h +++ b/editor/file_type_cache.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index 7e168c54be..ba90beee22 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/fileserver/editor_file_server.h b/editor/fileserver/editor_file_server.h index 01b84627b7..32c28b4358 100644 --- a/editor/fileserver/editor_file_server.h +++ b/editor/fileserver/editor_file_server.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 889f1e1e3f..d0d8b0f0cd 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 2ec0c38815..c33a745ce4 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index fbbbf91395..dcb96f3531 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/groups_editor.h b/editor/groups_editor.h index acbe60c21f..c9b37a405d 100644 --- a/editor/groups_editor.h +++ b/editor/groups_editor.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/icons/SCsub b/editor/icons/SCsub index 86c51a50f3..07fe45ce11 100644 --- a/editor/icons/SCsub +++ b/editor/icons/SCsub @@ -1,18 +1,17 @@ #!/usr/bin/env python Import('env') - +from compat import StringIO def make_editor_icons_action(target, source, env): import os - import cStringIO dst = target[0].srcnode().abspath svg_icons = source - whites = cStringIO.StringIO() - darks = cStringIO.StringIO() + whites = StringIO() + darks = StringIO() for f in svg_icons: @@ -48,7 +47,7 @@ def make_editor_icons_action(target, source, env): whites.write('\n') darks.write('\n') - s = cStringIO.StringIO() + s = StringIO() s.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") s.write("#ifndef _EDITOR_ICONS_H\n") s.write("#define _EDITOR_ICONS_H\n") @@ -75,7 +74,7 @@ def make_editor_icons_action(target, source, env): s.write("#endif\n") - f = open(dst, "wb") + f = open(dst, "w") f.write(s.getvalue()) f.close() s.close() diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 1680b32509..86482dad5a 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -41,6 +41,7 @@ #include "scene/animation/animation_player.h" #include "scene/resources/animation.h" #include "scene/resources/packed_scene.h" + #include <iostream> struct ColladaImport { @@ -1238,173 +1239,10 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me Array mr; -//////////////////////////// -// THEN THE MORPH TARGETS // -//////////////////////////// -#if 0 - if (p_morph_data) { - - //add morphie target - ERR_FAIL_COND_V( !p_morph_data->targets.has("MORPH_TARGET"), ERR_INVALID_DATA ); - String mt = p_morph_data->targets["MORPH_TARGET"]; - ERR_FAIL_COND_V( !p_morph_data->sources.has(mt), ERR_INVALID_DATA); - int morph_targets = p_morph_data->sources[mt].sarray.size(); - mr.resize(morph_targets); - - for(int j=0;j<morph_targets;j++) { - - Array mrt; - mrt.resize(VS::ARRAY_MAX); - - String target = p_morph_data->sources[mt].sarray[j]; - ERR_FAIL_COND_V( !collada.state.mesh_data_map.has(target), ERR_INVALID_DATA ); - String name = collada.state.mesh_data_map[target].name; - Collada::MeshData &md = collada.state.mesh_data_map[target]; - - // collada in itself supports morphing everything. However, the spec is unclear and no examples or exporters that - // morph anything but "POSITIONS" seem to exit. Because of this, normals and binormals/tangents have to be regenerated here, - // which may result in inaccurate (but most of the time good enough) results. - - PoolVector<Vector3> vertices; - vertices.resize(vlen); - - ERR_FAIL_COND_V( md.vertices.size() != 1, ERR_INVALID_DATA); - String vertex_src_id=md.vertices.front()->key(); - ERR_FAIL_COND_V(!md.vertices[vertex_src_id].sources.has("POSITION"),ERR_INVALID_DATA); - String position_src_id = md.vertices[vertex_src_id].sources["POSITION"]; - - ERR_FAIL_COND_V(!md.sources.has(position_src_id),ERR_INVALID_DATA); - - const Collada::MeshData::Source *m=&md.sources[position_src_id]; - - ERR_FAIL_COND_V( m->array.size() != vertex_src->array.size(), ERR_INVALID_DATA); - int stride=m->stride; - if (stride==0) - stride=3; - - - //read vertices from morph target - PoolVector<Vector3>::Write vertw = vertices.write(); - - for(int m_i=0;m_i<m->array.size()/stride;m_i++) { - - int pos = m_i*stride; - Vector3 vtx( m->array[pos+0], m->array[pos+1], m->array[pos+2] ); - -#ifndef NO_UP_AXIS_SWAP - if (collada.state.up_axis==Vector3::AXIS_Z) { - - SWAP( vtx.z, vtx.y ); - vtx.z = -vtx.z; - - } -#endif - - Collada::Vertex vertex; - vertex.vertex=vtx; - vertex.fix_unit_scale(collada); - vtx=vertex.vertex; - - vtx = p_local_xform.xform(vtx); - - - if (vertex_map.has(m_i)) { //vertex may no longer be here, don't bother converting - - - for (Set<int> ::Element *E=vertex_map[m_i].front() ; E; E=E->next() ) { - - vertw[E->get()]=vtx; - } - } - } - - - //vertices are in place, now generate everything else - vertw = PoolVector<Vector3>::Write(); - PoolVector<Vector3> normals; - PoolVector<float> tangents; - print_line("vertex source id: "+vertex_src_id); - if(md.vertices[vertex_src_id].sources.has("NORMAL")){ - //has normals - normals.resize(vlen); - //std::cout << "has normals" << std::endl; - String normal_src_id = md.vertices[vertex_src_id].sources["NORMAL"]; - //std::cout << "normals source: "<< normal_src_id.utf8().get_data() <<std::endl; - ERR_FAIL_COND_V(!md.sources.has(normal_src_id),ERR_INVALID_DATA); - - const Collada::MeshData::Source *m=&md.sources[normal_src_id]; - - ERR_FAIL_COND_V( m->array.size() != vertex_src->array.size(), ERR_INVALID_DATA); - int stride=m->stride; - if (stride==0) - stride=3; - - - //read normals from morph target - PoolVector<Vector3>::Write vertw = normals.write(); - - for(int m_i=0;m_i<m->array.size()/stride;m_i++) { - - int pos = m_i*stride; - Vector3 vtx( m->array[pos+0], m->array[pos+1], m->array[pos+2] ); - -#ifndef NO_UP_AXIS_SWAP - if (collada.state.up_axis==Vector3::AXIS_Z) { - - SWAP( vtx.z, vtx.y ); - vtx.z = -vtx.z; - - } -#endif - - Collada::Vertex vertex; - vertex.vertex=vtx; - vertex.fix_unit_scale(collada); - vtx=vertex.vertex; - - vtx = p_local_xform.xform(vtx); - - - if (vertex_map.has(m_i)) { //vertex may no longer be here, don't bother converting - - - for (Set<int> ::Element *E=vertex_map[m_i].front() ; E; E=E->next() ) { - - vertw[E->get()]=vtx; - } - } - } - - print_line("using built-in normals"); - }else{ - print_line("generating normals"); - _generate_normals(index_array,vertices,normals);//no normals - } - if (final_tangent_array.size() && final_uv_array.size()) { - - _generate_tangents_and_binormals(index_array,vertices,final_uv_array,normals,tangents); - - } - - mrt[Mesh::ARRAY_VERTEX]=vertices; - - mrt[Mesh::ARRAY_NORMAL]=normals; - if (tangents.size()) - mrt[Mesh::ARRAY_TANGENT]=tangents; - if (final_uv_array.size()) - mrt[Mesh::ARRAY_TEX_UV]=final_uv_array; - if (final_uv2_array.size()) - mrt[Mesh::ARRAY_TEX_UV2]=final_uv2_array; - if (final_color_array.size()) - mrt[Mesh::ARRAY_COLOR]=final_color_array; - - mr[j]=mrt; - - } - - } + //////////////////////////// + // THEN THE MORPH TARGETS // + //////////////////////////// -#endif for (int mi = 0; mi < p_morph_meshes.size(); mi++) { //print_line("want surface "+itos(mi)+" has "+itos(p_morph_meshes[mi]->get_surface_count())); diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h index 2c60916d52..865a72739f 100644 --- a/editor/import/editor_import_collada.h +++ b/editor/import/editor_import_collada.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/editor_import_plugin.cpp b/editor/import/editor_import_plugin.cpp index 4ebbcb1610..8af4ab63c7 100644 --- a/editor/import/editor_import_plugin.cpp +++ b/editor/import/editor_import_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/editor_import_plugin.h b/editor/import/editor_import_plugin.h index b60813db61..08d6de5531 100644 --- a/editor/import/editor_import_plugin.h +++ b/editor/import/editor_import_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index 226565f69f..4bbf5ba316 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -73,16 +73,25 @@ String ResourceImporterCSVTranslation::get_preset_name(int p_idx) const { void ResourceImporterCSVTranslation::get_import_options(List<ImportOption> *r_options, int p_preset) const { r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "delimiter", PROPERTY_HINT_ENUM, "Comma,Semicolon,Tab"), 0)); } Error ResourceImporterCSVTranslation::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) { bool compress = p_options["compress"]; + + String delimiter; + switch ((int)p_options["delimiter"]) { + case 0: delimiter = ","; break; + case 1: delimiter = ";"; break; + case 2: delimiter = "\t"; break; + } + FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ); ERR_FAIL_COND_V(!f, ERR_INVALID_PARAMETER); - Vector<String> line = f->get_csv_line(); + Vector<String> line = f->get_csv_line(delimiter); ERR_FAIL_COND_V(line.size() <= 1, ERR_PARSE_ERROR); Vector<String> locales; @@ -101,7 +110,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const translations.push_back(translation); } - line = f->get_csv_line(); + line = f->get_csv_line(delimiter); while (line.size() == locales.size() + 1) { @@ -113,7 +122,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const } } - line = f->get_csv_line(); + line = f->get_csv_line(delimiter); } for (int i = 0; i < translations.size(); i++) { diff --git a/editor/import/resource_importer_csv_translation.h b/editor/import/resource_importer_csv_translation.h index 748c6264df..8919f4ed33 100644 --- a/editor/import/resource_importer_csv_translation.h +++ b/editor/import/resource_importer_csv_translation.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 8f86e64cf2..6a936649c3 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index c8285ce6c9..247d58e148 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 59cd16c0b8..dd98494504 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -171,38 +171,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array memdelete(p_node); return NULL; } -#if 0 - if (Object::cast_to<MeshInstance>(p_node)) { - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - bool bb = false; - - if ((_teststr(name, "bb"))) { - bb = true; - } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(), "bb"))) { - bb = true; - } - - if (bb) { - mi->set_flag(GeometryInstance::FLAG_BILLBOARD, true); - if (mi->get_mesh().is_valid()) { - Ref<ArrayMesh> m = mi->get_mesh(); - for (int i = 0; i < m->get_surface_count(); i++) { - - Ref<SpatialMaterial> fm = m->surface_get_material(i); - if (fm.is_valid()) { - //fm->set_flag(Material::FLAG_UNSHADED,true); - //fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - //fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - //fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - } - } - } - } - } -#endif if (Object::cast_to<MeshInstance>(p_node)) { MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); @@ -256,115 +225,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array } } } -#if 0 - if (Object::cast_to<MeshInstance>(p_node)) { - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - String str; - - if ((_teststr(name, "imp"))) { - str = name; - } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(), "imp"))) { - str = mi->get_mesh()->get_name(); - } - - if (Object::cast_to<MeshInstance>(p_node->get_parent())) { - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent()); - String d = str.substr(str.find("imp") + 3, str.length()); - if (d != "") { - if ((d[0] < '0' || d[0] > '9')) - d = d.substr(1, d.length()); - if (d.length() && d[0] >= '0' && d[0] <= '9') { - float dist = d.to_double(); - mi->set_flag(GeometryInstance::FLAG_BILLBOARD, true); - mi->set_flag(GeometryInstance::FLAG_BILLBOARD_FIX_Y, true); - //mi->set_draw_range_begin(dist); - //mi->set_draw_range_end(100000); - - //mip->set_draw_range_begin(0); - //mip->set_draw_range_end(dist); - - if (mi->get_mesh().is_valid()) { - - Ref<ArrayMesh> m = mi->get_mesh(); - for (int i = 0; i < m->get_surface_count(); i++) { - - Ref<SpatialMaterial> fm = m->surface_get_material(i); - if (fm.is_valid()) { - //fm->set_flag(Material::FLAG_UNSHADED,true); - //fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - //fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - //fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - } - } - } - } - } - } - } -#endif -#if 0 - if (p_flags&SCENE_FLAG_CREATE_LODS && Object::cast_to<MeshInstance>(p_node)) { - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - String str; - - if ((_teststr(name,"lod"))) { - str=name; - } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(),"lod"))) { - str=mi->get_mesh()->get_name(); - - } - - - if (Object::cast_to<MeshInstance>(p_node->get_parent())) { - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent()); - String d=str.substr(str.find("lod")+3,str.length()); - if (d!="") { - if ((d[0]<'0' || d[0]>'9')) - d=d.substr(1,d.length()); - if (d.length() && d[0]>='0' && d[0]<='9') { - float dist = d.to_double(); - /// mi->set_draw_range_begin(dist); - // mi->set_draw_range_end(100000); - - // mip->set_draw_range_begin(0); - // mip->set_draw_range_end(dist); - - /*if (mi->get_mesh().is_valid()) { - - Ref<ArrayMesh> m = mi->get_mesh(); - for(int i=0;i<m->get_surface_count();i++) { - - Ref<SpatialMaterial> fm = m->surface_get_material(i); - if (fm.is_valid()) { - fm->set_flag(Material::FLAG_UNSHADED,true); - fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - fm->set_hint(Material::HINT_NO_DEPTH_DRAW,true); - fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - } - } - }*/ - } - } - } - } - - - if (p_flags&SCENE_FLAG_DETECT_LIGHTMAP_LAYER && _teststr(name,"lm") && Object::cast_to<MeshInstance>(p_node)) { - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - String str=name; - int layer = str.substr(str.find("lm")+3,str.length()).to_int(); - //mi->set_baked_light_texture_id(layer); - } -#endif if (_teststr(name, "colonly")) { if (isroot) @@ -681,38 +542,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array if (!shape.is_null()) collision_map[mesh] = shape; } - - if (!shape.is_null()) { -#if 0 - StaticBody* static_body = memnew( StaticBody ); - ERR_FAIL_COND_V(!static_body,NULL); - static_body->set_name( String(mesh->get_name()) + "_col" ); - shape->set_name(static_body->get_name()); - static_body->add_shape(shape); - - mi->add_child(static_body); - if (mi->get_owner()) - static_body->set_owner( mi->get_owner() ); -#endif - } - } - - for (int i = 0; i < mesh->get_surface_count(); i++) { - - Ref<SpatialMaterial> fm = mesh->surface_get_material(i); - if (fm.is_valid()) { - String name = fm->get_name(); - /* if (_teststr(name,"alpha")) { - fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - name=_fixstr(name,"alpha"); - } - - if (_teststr(name,"vcol")) { - fm->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY,true); - name=_fixstr(name,"vcol"); - }*/ - fm->set_name(name); - } } } } diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index f404582d7e..bf8d88ce0a 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index 060e683077..6de523736b 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_texture.h b/editor/import/resource_importer_texture.h index 31bd0f29b0..b374a9bc04 100644 --- a/editor/import/resource_importer_texture.h +++ b/editor/import/resource_importer_texture.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp index 07f1f4dd9f..25185149b1 100644 --- a/editor/import/resource_importer_wav.cpp +++ b/editor/import/resource_importer_wav.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import/resource_importer_wav.h b/editor/import/resource_importer_wav.h index 6b4f86e641..f58392e820 100644 --- a/editor/import/resource_importer_wav.h +++ b/editor/import/resource_importer_wav.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index a4f744aa84..6662fa9f21 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/import_dock.h b/editor/import_dock.h index 4844fc07ea..afb899d9c9 100644 --- a/editor/import_dock.h +++ b/editor/import_dock.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp deleted file mode 100644 index a644558521..0000000000 --- a/editor/inspector_dock.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************/ -/* inspector_dock.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "inspector_dock.h" - -#if 0 -void InspectorDock::_go_next() { - - -} - -void InspectorDock::_go_prev() { - - -} - -void InspectorDock::_bind_methods() { - -} - -InspectorDock::InspectorDock() { - - -} -#endif diff --git a/editor/inspector_dock.h b/editor/inspector_dock.h deleted file mode 100644 index cee18f2d49..0000000000 --- a/editor/inspector_dock.h +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************/ -/* inspector_dock.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 INSPECTOR_DOCK_H -#define INSPECTOR_DOCK_H - -#include "property_editor.h" -#include "scene/gui/box_container.h" - -//this is for now bundled in EditorNode, will be moved away here eventually - -#if 0 -class InspectorDock : public VBoxContainer -{ - GDCLASS(InspectorDock,VBoxContainer); - - PropertyEditor *property_editor; - - EditorHistory editor_history; - - void _go_next(); - void _go_prev(); - -protected: - - static void _bind_methods(); -public: - - EditorHistory &get_editor_history(); - - PropertyEditor *get_property_editor(); - - InspectorDock(); -}; - -#endif -#endif // INSPECTOR_DOCK_H diff --git a/editor/io_plugins/SCsub b/editor/io_plugins/SCsub deleted file mode 100644 index f1fa50148f..0000000000 --- a/editor/io_plugins/SCsub +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python - -Import('env') -Export('env') -env.add_source_files(env.editor_sources, "*.cpp") diff --git a/editor/io_plugins/editor_atlas.cpp b/editor/io_plugins/editor_atlas.cpp deleted file mode 100644 index 42800ee80d..0000000000 --- a/editor/io_plugins/editor_atlas.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/*************************************************************************/ -/* editor_atlas.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_atlas.h" - -#include "print_string.h" - -struct _EditorAtlasWorkRect { - - Size2i s; - Point2i p; - int idx; - _FORCE_INLINE_ bool operator<(const _EditorAtlasWorkRect &p_r) const { return s.width > p_r.s.width; }; -}; - -struct _EditorAtlasWorkRectResult { - - Vector<_EditorAtlasWorkRect> result; - int max_w; - int max_h; -}; - -void EditorAtlas::fit(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size) { - - //super simple, almost brute force scanline stacking fitter - //it's pretty basic for now, but it tries to make sure that the aspect ratio of the - //resulting atlas is somehow square. This is necessary because video cards have limits - //on texture size (usually 2048 or 4096), so the more square a texture, the more chances - //it will work in every hardware. - // for example, it will prioritize a 1024x1024 atlas (works everywhere) instead of a - // 256x8192 atlas (won't work anywhere). - - ERR_FAIL_COND(p_rects.size() == 0); - - Vector<_EditorAtlasWorkRect> wrects; - wrects.resize(p_rects.size()); - for (int i = 0; i < p_rects.size(); i++) { - wrects[i].s = p_rects[i]; - wrects[i].idx = i; - } - wrects.sort(); - int widest = wrects[0].s.width; - - Vector<_EditorAtlasWorkRectResult> results; - - for (int i = 0; i <= 12; i++) { - - int w = 1 << i; - int max_h = 0; - int max_w = 0; - if (w < widest) - continue; - - Vector<int> hmax; - hmax.resize(w); - for (int j = 0; j < w; j++) - hmax[j] = 0; - - //place them - int ofs = 0; - - for (int j = 0; j < wrects.size(); j++) { - - if (ofs + wrects[j].s.width > w) { - - ofs = 0; - } - - int from_y = 0; - for (int k = 0; k < wrects[j].s.width; k++) { - - if (hmax[ofs + k] > from_y) - from_y = hmax[ofs + k]; - } - - wrects[j].p.x = ofs; - wrects[j].p.y = from_y; - - int end_h = from_y + wrects[j].s.height; - int end_w = ofs + wrects[j].s.width; - - for (int k = 0; k < wrects[j].s.width; k++) { - - hmax[ofs + k] = end_h; - } - - if (end_h > max_h) - max_h = end_h; - - if (end_w > max_w) - max_w = end_w; - - ofs += wrects[j].s.width; - } - - _EditorAtlasWorkRectResult result; - result.result = wrects; - result.max_h = max_h; - result.max_w = max_w; - results.push_back(result); - } - - //find the result with the best aspect ratio - - int best = -1; - float best_aspect = 1e20; - - for (int i = 0; i < results.size(); i++) { - - float h = results[i].max_h; - float w = results[i].max_w; - float aspect = h > w ? h / w : w / h; - if (aspect < best_aspect) { - best = i; - best_aspect = aspect; - } - } - - r_result.resize(p_rects.size()); - - for (int i = 0; i < p_rects.size(); i++) { - - r_result[results[best].result[i].idx] = results[best].result[i].p; - } - - r_size = Size2(results[best].max_w, results[best].max_h); -} diff --git a/editor/io_plugins/editor_atlas.h b/editor/io_plugins/editor_atlas.h deleted file mode 100644 index 206897c8e5..0000000000 --- a/editor/io_plugins/editor_atlas.h +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************/ -/* editor_atlas.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_ATLAS_H -#define EDITOR_ATLAS_H - -#include "math_2d.h" -#include "vector.h" - -class EditorAtlas { -public: - static void fit(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size); -}; - -#endif // EDITOR_ATLAS_H diff --git a/editor/io_plugins/editor_bitmask_import_plugin.cpp b/editor/io_plugins/editor_bitmask_import_plugin.cpp deleted file mode 100644 index e508dc0a9d..0000000000 --- a/editor/io_plugins/editor_bitmask_import_plugin.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/*************************************************************************/ -/* editor_bitmask_import_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_bitmask_import_plugin.h" -#if 0 -#include "editor/editor_dir_dialog.h" -#include "editor/editor_file_dialog.h" -#include "editor/editor_node.h" -#include "editor/editor_settings.h" -#include "editor/property_editor.h" -#include "io/image_loader.h" -#include "io/marshalls.h" -#include "io/resource_saver.h" -#include "os/file_access.h" - -class _EditorBitMaskImportOptions : public Object { - - GDCLASS(_EditorBitMaskImportOptions, Object); -public: - - bool _set(const StringName& p_name, const Variant& p_value) { - - return false; - } - - bool _get(const StringName& p_name, Variant &r_ret) const{ - - return false; - } - - void _get_property_list(List<PropertyInfo> *p_list) const{ - - } - - static void _bind_methods() { - - ADD_SIGNAL(MethodInfo("changed")); - } - - - _EditorBitMaskImportOptions() { - - } - -}; - -class EditorBitMaskImportDialog : public ConfirmationDialog { - - GDCLASS(EditorBitMaskImportDialog, ConfirmationDialog); - - EditorBitMaskImportPlugin *plugin; - - LineEdit *import_path; - LineEdit *save_path; - EditorFileDialog *file_select; - EditorDirDialog *save_select; - ConfirmationDialog *error_dialog; - PropertyEditor *option_editor; - -public: - - void _choose_files(const Vector<String>& p_path) { - - String files; - for (int i = 0; i<p_path.size(); i++) { - - if (i>0) - files += ","; - files += p_path[i]; - } - - import_path->set_text(files); - - } - void _choose_save_dir(const String& p_path) { - - save_path->set_text(p_path); - } - - void _browse() { - - file_select->popup_centered_ratio(); - } - - void _browse_target() { - - save_select->popup_centered_ratio(); - - } - - - void popup_import(const String& p_path) { - - popup_centered(Size2(400, 100)*EDSCALE); - if (p_path != "") { - - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path); - ERR_FAIL_COND(!rimd.is_valid()); - - save_path->set_text(p_path.get_base_dir()); - - String src = ""; - for (int i = 0; i<rimd->get_source_count(); i++) { - if (i>0) - src += ","; - src += EditorImportPlugin::expand_source_path(rimd->get_source_path(i)); - } - import_path->set_text(src); - } - } - - - void _import() { - - Vector<String> bitmasks = import_path->get_text().split(","); - - if (bitmasks.size() == 0) { - error_dialog->set_text(TTR("No bit masks to import!")); - error_dialog->popup_centered(Size2(200, 100)*EDSCALE); - } - - if (save_path->get_text().strip_edges() == "") { - error_dialog->set_text(TTR("Target path is empty.")); - error_dialog->popup_centered_minsize(); - return; - } - - if (!save_path->get_text().begins_with("res://")) { - error_dialog->set_text(TTR("Target path must be a complete resource path.")); - error_dialog->popup_centered_minsize(); - return; - } - - if (!DirAccess::exists(save_path->get_text())) { - error_dialog->set_text(TTR("Target path must exist.")); - error_dialog->popup_centered_minsize(); - return; - } - - for (int i = 0; i<bitmasks.size(); i++) { - - Ref<ResourceImportMetadata> imd = memnew(ResourceImportMetadata); - - imd->add_source(EditorImportPlugin::validate_source_path(bitmasks[i])); - - String dst = save_path->get_text(); - if (dst == "") { - error_dialog->set_text(TTR("Save path is empty!")); - error_dialog->popup_centered(Size2(200, 100)*EDSCALE); - } - - dst = dst.plus_file(bitmasks[i].get_file().get_basename() + ".pbm"); - - plugin->import(dst, imd); - } - - hide(); - - } - - - void _notification(int p_what) { - - } - - static void _bind_methods() { - - - ClassDB::bind_method("_choose_files", &EditorBitMaskImportDialog::_choose_files); - ClassDB::bind_method("_choose_save_dir", &EditorBitMaskImportDialog::_choose_save_dir); - ClassDB::bind_method("_import", &EditorBitMaskImportDialog::_import); - ClassDB::bind_method("_browse", &EditorBitMaskImportDialog::_browse); - ClassDB::bind_method("_browse_target", &EditorBitMaskImportDialog::_browse_target); - //ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) ); - } - - EditorBitMaskImportDialog(EditorBitMaskImportPlugin *p_plugin) { - - plugin = p_plugin; - - - set_title(TTR("Import BitMasks")); - - VBoxContainer *vbc = memnew(VBoxContainer); - add_child(vbc); - //set_child_rect(vbc); - - - HBoxContainer *hbc = memnew(HBoxContainer); - vbc->add_margin_child(TTR("Source Texture(s):"), hbc); - - import_path = memnew(LineEdit); - import_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(import_path); - - Button * import_choose = memnew(Button); - import_choose->set_text(" .. "); - hbc->add_child(import_choose); - - import_choose->connect("pressed", this, "_browse"); - - hbc = memnew(HBoxContainer); - vbc->add_margin_child(TTR("Target Path:"), hbc); - - save_path = memnew(LineEdit); - save_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(save_path); - - Button * save_choose = memnew(Button); - save_choose->set_text(" .. "); - hbc->add_child(save_choose); - - save_choose->connect("pressed", this, "_browse_target"); - - file_select = memnew(EditorFileDialog); - file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - add_child(file_select); - file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES); - file_select->connect("files_selected", this, "_choose_files"); - - List<String> extensions; - ImageLoader::get_recognized_extensions(&extensions); - file_select->clear_filters(); - for (int i = 0; i<extensions.size(); i++) { - - file_select->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); - } - - save_select = memnew(EditorDirDialog); - add_child(save_select); - - //save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR); - save_select->connect("dir_selected", this, "_choose_save_dir"); - - get_ok()->connect("pressed", this, "_import"); - get_ok()->set_text(TTR("Import")); - - - error_dialog = memnew(ConfirmationDialog); - add_child(error_dialog); - error_dialog->get_ok()->set_text(TTR("Accept")); - //error_dialog->get_cancel()->hide(); - - set_hide_on_ok(false); - } - - ~EditorBitMaskImportDialog() { - } - -}; - - -String EditorBitMaskImportPlugin::get_name() const { - - return "bitmask"; -} -String EditorBitMaskImportPlugin::get_visible_name() const{ - - return TTR("Bit Mask"); -} -void EditorBitMaskImportPlugin::import_dialog(const String& p_from){ - - dialog->popup_import(p_from); -} -Error EditorBitMaskImportPlugin::import(const String& p_path, const Ref<ResourceImportMetadata>& p_from){ - - ERR_FAIL_COND_V(p_from->get_source_count() != 1, ERR_INVALID_PARAMETER); - - Ref<ResourceImportMetadata> from = p_from; - - String src_path = EditorImportPlugin::expand_source_path(from->get_source_path(0)); - Ref<ImageTexture> it = ResourceLoader::load(src_path); - ERR_FAIL_COND_V(it.is_null(), ERR_CANT_OPEN); - - Ref<BitMap> target = memnew(BitMap); - target->create_from_image_alpha(it.ptr()->get_data()); - - from->set_source_md5(0, FileAccess::get_md5(src_path)); - from->set_editor(get_name()); - target->set_import_metadata(from); - - - Error err = ResourceSaver::save(p_path, target); - - return err; - -} - - -EditorBitMaskImportPlugin* EditorBitMaskImportPlugin::singleton = NULL; - - -void EditorBitMaskImportPlugin::import_from_drop(const Vector<String>& p_drop, const String &p_dest_path) { - - Vector<String> files; - - List<String> valid_extensions; - ImageLoader::get_recognized_extensions(&valid_extensions); - for(int i=0;i<p_drop.size();i++) { - - String extension=p_drop[i].get_extension().to_lower(); - - for (List<String>::Element *E=valid_extensions.front();E;E=E->next()) { - - if (E->get()==extension) { - files.push_back(p_drop[i]); - break; - } - } - } - - if (files.size()) { - import_dialog(); - dialog->_choose_files(files); - dialog->_choose_save_dir(p_dest_path); - } -} - -void EditorBitMaskImportPlugin::reimport_multiple_files(const Vector<String>& p_list) { - - if (p_list.size() == 0) - return; - - Vector<String> sources; - for (int i = 0; i<p_list.size(); i++) { - int idx; - EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->find_file(p_list[i], &idx); - if (efsd) { - for (int j = 0; j<efsd->get_source_count(idx); j++) { - String file = expand_source_path(efsd->get_source_file(idx, j)); - if (sources.find(file) == -1) { - sources.push_back(file); - } - - } - } - } - - if (sources.size()) { - - dialog->popup_import(p_list[0]); - dialog->_choose_files(sources); - dialog->_choose_save_dir(p_list[0].get_base_dir()); - } -} - -bool EditorBitMaskImportPlugin::can_reimport_multiple_files() const { - - return true; -} - -EditorBitMaskImportPlugin::EditorBitMaskImportPlugin(EditorNode* p_editor) { - - singleton = this; - dialog = memnew(EditorBitMaskImportDialog(this)); - p_editor->get_gui_base()->add_child(dialog); -} - -EditorBitMaskExportPlugin::EditorBitMaskExportPlugin() { - -} -#endif diff --git a/editor/io_plugins/editor_bitmask_import_plugin.h b/editor/io_plugins/editor_bitmask_import_plugin.h deleted file mode 100644 index b31ee9c86a..0000000000 --- a/editor/io_plugins/editor_bitmask_import_plugin.h +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************/ -/* editor_bitmask_import_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_BITMASK_IMPORT_PLUGIN_H -#define EDITOR_BITMASK_IMPORT_PLUGIN_H -#if 0 -#include "editor/editor_import_export.h" -#include "scene/resources/font.h" - -class EditorNode; -class EditorBitMaskImportDialog; - -class EditorBitMaskImportPlugin : public EditorImportPlugin { - - GDCLASS(EditorBitMaskImportPlugin, EditorImportPlugin); - - EditorBitMaskImportDialog *dialog; -public: - - static EditorBitMaskImportPlugin *singleton; - - 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); - 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; - - - EditorBitMaskImportPlugin(EditorNode* p_editor); -}; - -class EditorBitMaskExportPlugin : public EditorExportPlugin { - - GDCLASS(EditorBitMaskExportPlugin, EditorExportPlugin); - - -public: - - EditorBitMaskExportPlugin(); -}; - -#endif -#endif // EDITOR_SAMPLE_IMPORT_PLUGIN_H diff --git a/editor/io_plugins/editor_export_scene.cpp b/editor/io_plugins/editor_export_scene.cpp deleted file mode 100644 index 6392b4a715..0000000000 --- a/editor/io_plugins/editor_export_scene.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/*************************************************************************/ -/* editor_export_scene.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_export_scene.h" -#if 0 -#include "editor/editor_settings.h" -#include "io/resource_loader.h" -#include "io/resource_saver.h" -#include "os/dir_access.h" -#include "os/file_access.h" -#include "project_settings.h" -#include "scene/resources/packed_scene.h" - -Vector<uint8_t> EditorSceneExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) { - - if (!EditorImportExport::get_singleton()->get_convert_text_scenes()) { - return Vector<uint8_t>(); - } - - - String extension = p_path.get_extension(); - - //step 1 check if scene - - if (extension=="xml" || extension=="xres") { - - String type = ResourceLoader::get_resource_type(p_path); - - if (type!="PackedScene") - return Vector<uint8_t>(); - - } else if (extension!="tscn" && extension!="xscn") { - return Vector<uint8_t>(); - } - - //step 2 check if cached - - uint64_t sd=0; - String smd5; - String gp = ProjectSettings::get_singleton()->globalize_path(p_path); - String md5=gp.md5_text(); - String tmp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/"); - - bool valid=false; - { - //if existing, make sure it's valid - FileAccessRef f = FileAccess::open(tmp_path+"scnexp-"+md5+".txt",FileAccess::READ); - if (f) { - - uint64_t d = f->get_line().strip_edges().to_int64(); - sd = FileAccess::get_modified_time(p_path); - - if (d==sd) { - valid=true; - } else { - String cmd5 = f->get_line().strip_edges(); - smd5 = FileAccess::get_md5(p_path); - if (cmd5==smd5) { - valid=true; - } - } - - - } - } - - if (!valid) { - //cache failed, convert - DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - - String copy = p_path+".convert."+extension; - - // a copy will allow loading the internal resources without conflicting with opened scenes - da->copy(p_path,copy); - - //@todo for tscn use something more efficient - - Ref<PackedScene> copyres = ResourceLoader::load(copy,"PackedScene"); - - da->remove(copy); - - memdelete(da); - - ERR_FAIL_COND_V(!copyres.is_valid(),Vector<uint8_t>()); - - Error err = ResourceSaver::save(tmp_path+"scnexp-"+md5+".scn",copyres); - - copyres=Ref<PackedScene>(); - - ERR_FAIL_COND_V(err!=OK,Vector<uint8_t>()); - - FileAccessRef f = FileAccess::open(tmp_path+"scnexp-"+md5+".txt",FileAccess::WRITE); - - if (sd==0) - sd = FileAccess::get_modified_time(p_path); - if (smd5==String()) - smd5 = FileAccess::get_md5(p_path); - - f->store_line(String::num(sd)); - f->store_line(smd5); - f->store_line(gp); //source path for reference - } - - - Vector<uint8_t> ret = FileAccess::get_file_as_array(tmp_path+"scnexp-"+md5+".scn"); - - p_path+=".converted.scn"; - - return ret; - -} - - -EditorSceneExportPlugin::EditorSceneExportPlugin() -{ -} -#endif diff --git a/editor/io_plugins/editor_export_scene.h b/editor/io_plugins/editor_export_scene.h deleted file mode 100644 index d8fe21adfc..0000000000 --- a/editor/io_plugins/editor_export_scene.h +++ /dev/null @@ -1,45 +0,0 @@ -/*************************************************************************/ -/* editor_export_scene.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_SCENE_H -#define EDITOR_EXPORT_SCENE_H - -#include "editor/editor_export.h" - -#if 0 -class EditorSceneExportPlugin : public EditorExportPlugin { - GDCLASS( EditorSceneExportPlugin, EditorExportPlugin ); -public: - - virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform); - - EditorSceneExportPlugin(); -}; -#endif -#endif // EDITOR_EXPORT_SCENE_H diff --git a/editor/io_plugins/editor_font_import_plugin.cpp b/editor/io_plugins/editor_font_import_plugin.cpp deleted file mode 100644 index f7975e53ea..0000000000 --- a/editor/io_plugins/editor_font_import_plugin.cpp +++ /dev/null @@ -1,1705 +0,0 @@ -/*************************************************************************/ -/* editor_font_import_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_font_import_plugin.h" -#if 0 -#include "editor/editor_file_dialog.h" -#include "editor/editor_node.h" -#include "editor_atlas.h" -#include "io/image_loader.h" -#include "io/resource_saver.h" -#include "os/file_access.h" -#include "scene/gui/dialogs.h" - -#ifdef FREETYPE_ENABLED -#include <ft2build.h> -#include FT_FREETYPE_H -#endif - - -class _EditorFontImportOptions : public Object { - - GDCLASS(_EditorFontImportOptions,Object); -public: - - enum FontMode { - - FONT_BITMAP, - FONT_DISTANCE_FIELD - }; - - enum ColorType { - COLOR_WHITE, - COLOR_CUSTOM, - COLOR_GRADIENT_RANGE, - COLOR_GRADIENT_IMAGE - }; - - - int char_extra_spacing; - int top_extra_spacing; - int bottom_extra_spacing; - int space_extra_spacing; - - enum CharacterSet { - - CHARSET_ASCII, - CHARSET_LATIN, - CHARSET_UNICODE, - CHARSET_CUSTOM, - CHARSET_CUSTOM_LATIN - }; - - - FontMode font_mode; - - CharacterSet character_set; - String custom_file; - - bool shadow; - Vector2 shadow_offset; - int shadow_radius; - Color shadow_color; - float shadow_transition; - - bool shadow2; - Vector2 shadow2_offset; - int shadow2_radius; - Color shadow2_color; - float shadow2_transition; - - ColorType color_type; - Color color; - Color gradient_begin; - Color gradient_end; - bool color_use_monochrome; - String gradient_image; - - bool enable_filter; - bool round_advance; - bool premultiply_alpha; - - - - bool _set(const StringName& p_name, const Variant& p_value) { - - String n = p_name; - if (n=="mode/mode") { - font_mode=FontMode(int(p_value)); - _change_notify(); - } else if (n=="extra_space/char") - char_extra_spacing=p_value; - else if (n=="extra_space/space") - space_extra_spacing=p_value; - else if (n=="extra_space/top") - top_extra_spacing=p_value; - else if (n=="extra_space/bottom") - bottom_extra_spacing=p_value; - - else if (n=="character_set/mode") { - character_set=CharacterSet(int(p_value)); - _change_notify(); - } else if (n=="character_set/custom") - custom_file=p_value; - - else if (n=="shadow/enabled") { - shadow=p_value; - _change_notify(); - }else if (n=="shadow/radius") - shadow_radius=p_value; - else if (n=="shadow/offset") - shadow_offset=p_value; - else if (n=="shadow/color") - shadow_color=p_value; - else if (n=="shadow/transition") - shadow_transition=p_value; - - else if (n=="shadow2/enabled") { - shadow2=p_value; - _change_notify(); - }else if (n=="shadow2/radius") - shadow2_radius=p_value; - else if (n=="shadow2/offset") - shadow2_offset=p_value; - else if (n=="shadow2/color") - shadow2_color=p_value; - else if (n=="shadow2/transition") - shadow2_transition=p_value; - - else if (n=="color/mode") { - color_type=ColorType(int(p_value)); - _change_notify(); - }else if (n=="color/color") - color=p_value; - else if (n=="color/begin") - gradient_begin=p_value; - else if (n=="color/end") - gradient_end=p_value; - else if (n=="color/image") - gradient_image=p_value; - else if (n=="color/monochrome") - color_use_monochrome=p_value; - else if (n=="advanced/round_advance") - round_advance=p_value; - else if (n=="advanced/enable_filter") - enable_filter=p_value; - else if (n=="advanced/premultiply_alpha") - premultiply_alpha=p_value; - else - return false; - - emit_signal("changed"); - - - return true; - - } - - bool _get(const StringName& p_name,Variant &r_ret) const{ - - String n = p_name; - if (n=="mode/mode") - r_ret=font_mode; - else if (n=="extra_space/char") - r_ret=char_extra_spacing; - else if (n=="extra_space/space") - r_ret=space_extra_spacing; - else if (n=="extra_space/top") - r_ret=top_extra_spacing; - else if (n=="extra_space/bottom") - r_ret=bottom_extra_spacing; - - else if (n=="character_set/mode") - r_ret=character_set; - else if (n=="character_set/custom") - r_ret=custom_file; - - else if (n=="shadow/enabled") - r_ret=shadow; - else if (n=="shadow/radius") - r_ret=shadow_radius; - else if (n=="shadow/offset") - r_ret=shadow_offset; - else if (n=="shadow/color") - r_ret=shadow_color; - else if (n=="shadow/transition") - r_ret=shadow_transition; - - else if (n=="shadow2/enabled") - r_ret=shadow2; - else if (n=="shadow2/radius") - r_ret=shadow2_radius; - else if (n=="shadow2/offset") - r_ret=shadow2_offset; - else if (n=="shadow2/color") - r_ret=shadow2_color; - else if (n=="shadow2/transition") - r_ret=shadow2_transition; - - - else if (n=="color/mode") - r_ret=color_type; - else if (n=="color/color") - r_ret=color; - else if (n=="color/begin") - r_ret=gradient_begin; - else if (n=="color/end") - r_ret=gradient_end; - else if (n=="color/image") - r_ret=gradient_image; - else if (n=="color/monochrome") - r_ret=color_use_monochrome; - else if (n=="advanced/round_advance") - r_ret=round_advance; - else if (n=="advanced/enable_filter") - r_ret=enable_filter; - else if (n=="advanced/premultiply_alpha") - r_ret=premultiply_alpha; - else - return false; - - return true; - - } - - void _get_property_list( List<PropertyInfo> *p_list) const{ - - - p_list->push_back(PropertyInfo(Variant::INT,"mode/mode",PROPERTY_HINT_ENUM,"Bitmap,Distance Field")); - - p_list->push_back(PropertyInfo(Variant::INT,"extra_space/char",PROPERTY_HINT_RANGE,"-64,64,1")); - p_list->push_back(PropertyInfo(Variant::INT,"extra_space/space",PROPERTY_HINT_RANGE,"-64,64,1")); - p_list->push_back(PropertyInfo(Variant::INT,"extra_space/top",PROPERTY_HINT_RANGE,"-64,64,1")); - p_list->push_back(PropertyInfo(Variant::INT,"extra_space/bottom",PROPERTY_HINT_RANGE,"-64,64,1")); - p_list->push_back(PropertyInfo(Variant::INT,"character_set/mode",PROPERTY_HINT_ENUM,"Ascii,Latin,Unicode,Custom,Custom&Latin")); - - if (character_set>=CHARSET_CUSTOM) - p_list->push_back(PropertyInfo(Variant::STRING,"character_set/custom",PROPERTY_HINT_GLOBAL_FILE)); - - int usage = PROPERTY_USAGE_DEFAULT; - - if (font_mode==FONT_DISTANCE_FIELD) { - usage = PROPERTY_USAGE_NOEDITOR; - } - - { - - p_list->push_back(PropertyInfo(Variant::BOOL,"shadow/enabled",PROPERTY_HINT_NONE,"",usage)); - if (shadow) { - p_list->push_back(PropertyInfo(Variant::INT,"shadow/radius",PROPERTY_HINT_RANGE,"-64,64,1",usage)); - p_list->push_back(PropertyInfo(Variant::VECTOR2,"shadow/offset",PROPERTY_HINT_NONE,"",usage)); - p_list->push_back(PropertyInfo(Variant::COLOR,"shadow/color",PROPERTY_HINT_NONE,"",usage)); - p_list->push_back(PropertyInfo(Variant::REAL,"shadow/transition",PROPERTY_HINT_EXP_EASING,"",usage)); - } - - p_list->push_back(PropertyInfo(Variant::BOOL,"shadow2/enabled",PROPERTY_HINT_NONE,"",usage)); - if (shadow2) { - p_list->push_back(PropertyInfo(Variant::INT,"shadow2/radius",PROPERTY_HINT_RANGE,"-64,64,1",usage)); - p_list->push_back(PropertyInfo(Variant::VECTOR2,"shadow2/offset",PROPERTY_HINT_NONE,"",usage)); - p_list->push_back(PropertyInfo(Variant::COLOR,"shadow2/color",PROPERTY_HINT_NONE,"",usage)); - p_list->push_back(PropertyInfo(Variant::REAL,"shadow2/transition",PROPERTY_HINT_EXP_EASING,"",usage)); - } - - p_list->push_back(PropertyInfo(Variant::INT,"color/mode",PROPERTY_HINT_ENUM,"White,Color,Gradient,Gradient Image",usage)); - if (color_type==COLOR_CUSTOM) { - p_list->push_back(PropertyInfo(Variant::COLOR,"color/color",PROPERTY_HINT_NONE,"",usage)); - - } - if (color_type==COLOR_GRADIENT_RANGE) { - p_list->push_back(PropertyInfo(Variant::COLOR,"color/begin",PROPERTY_HINT_NONE,"",usage)); - p_list->push_back(PropertyInfo(Variant::COLOR,"color/end",PROPERTY_HINT_NONE,"",usage)); - } - if (color_type==COLOR_GRADIENT_IMAGE) { - p_list->push_back(PropertyInfo(Variant::STRING,"color/image",PROPERTY_HINT_GLOBAL_FILE,"",usage)); - } - p_list->push_back(PropertyInfo(Variant::BOOL,"color/monochrome",PROPERTY_HINT_NONE,"",usage)); - } - - p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/round_advance")); - p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/enable_filter")); - p_list->push_back(PropertyInfo(Variant::BOOL,"advanced/premultiply_alpha")); - - } - - - static void _bind_methods() { - - - ADD_SIGNAL( MethodInfo("changed")); - } - - - void reset() { - - char_extra_spacing=0; - top_extra_spacing=0; - bottom_extra_spacing=0; - space_extra_spacing=0; - - character_set=CHARSET_LATIN; - - shadow=false; - shadow_radius=2; - shadow_color=Color(0,0,0,0.3); - shadow_transition=1.0; - - shadow2=false; - shadow2_radius=2; - shadow2_color=Color(0,0,0,0.3); - shadow2_transition=1.0; - - color_type=COLOR_WHITE; - color=Color(1,1,1,1); - gradient_begin=Color(1,1,1,1); - gradient_end=Color(0.5,0.5,0.5,1); - color_use_monochrome=false; - - font_mode=FONT_BITMAP; - round_advance=true; - enable_filter=true; - premultiply_alpha=false; - - } - - _EditorFontImportOptions() { - - font_mode=FONT_BITMAP; - - char_extra_spacing=0; - top_extra_spacing=0; - bottom_extra_spacing=0; - space_extra_spacing=0; - - character_set=CHARSET_LATIN; - - shadow=false; - shadow_radius=2; - shadow_color=Color(0,0,0,0.3); - shadow_transition=1.0; - - shadow2=false; - shadow2_radius=2; - shadow2_color=Color(0,0,0,0.3); - shadow2_transition=1.0; - - color_type=COLOR_WHITE; - color=Color(1,1,1,1); - gradient_begin=Color(1,1,1,1); - gradient_end=Color(0.5,0.5,0.5,1); - color_use_monochrome=false; - - round_advance=true; - enable_filter=true; - premultiply_alpha=false; - } - - -}; - - -class EditorFontImportDialog : public ConfirmationDialog { - - GDCLASS(EditorFontImportDialog, ConfirmationDialog); - - - EditorLineEditFileChooser *source; - EditorLineEditFileChooser *dest; - SpinBox *font_size; - LineEdit *test_string; - ColorPickerButton *test_color; - Label *test_label; - PropertyEditor *prop_edit; - Timer *timer; - ConfirmationDialog *error_dialog; - - - Ref<ResourceImportMetadata> get_rimd() { - - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - List<PropertyInfo> pl; - options->_get_property_list(&pl); - for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { - - Variant v; - String opt=E->get().name; - options->_get(opt,v); - if (opt=="color/image" || opt=="character_set/custom") { - v = EditorImportPlugin::validate_source_path(v); - } - imd->set_option(opt,v); - } - - String src_path = EditorImportPlugin::validate_source_path(source->get_line_edit()->get_text()); - //print_line("pre src path "+source->get_line_edit()->get_text()); - //print_line("src path "+src_path); - imd->add_source(src_path); - imd->set_option("font/size",font_size->get_value()); - - return imd; - - } - - void _src_changed(String) { - _prop_changed(); - } - - void _update_text2(String) { - _update_text(); - } - void _update_text3(Color) { - _update_text(); - } - - void _update_text() { - - test_label->set_text(""); - test_label->set_text(test_string->get_text()); - test_label->add_color_override("font_color",test_color->get_pick_color()); - } - - void _update() { - - Ref<ResourceImportMetadata> imd = get_rimd(); - Ref<BitmapFont> font = plugin->generate_font(imd); - test_label->add_font_override("font",font); - _update_text(); - } - - void _font_size_changed(double) { - - _prop_changed(); - } - - void _prop_changed() { - - timer->start(); - } - - void _import_inc(String p_font) { - - Ref<BitmapFont> font = ResourceLoader::load(p_font); - if (!font.is_valid()) - return; - Ref<ImageTexture> tex = font->get_texture(0); - if (tex.is_null()) - return; - FileAccessRef f=FileAccess::open(p_font.get_basename()+".inc",FileAccess::WRITE); - Vector<CharType> ck = font->get_char_keys(); - - f->store_line("static const int _builtin_font_height="+itos(font->get_height())+";"); - f->store_line("static const int _builtin_font_ascent="+itos(font->get_ascent())+";"); - f->store_line("static const int _builtin_font_charcount="+itos(ck.size())+";"); - f->store_line("static const int _builtin_font_charrects["+itos(ck.size())+"][8]={"); - f->store_line("/* charidx , ofs_x, ofs_y, size_x, size_y, valign, halign, advance */"); - - for(int i=0;i<ck.size();i++) { - CharType k=ck[i]; - BitmapFont::Character c=font->get_character(k); - f->store_line("{"+itos(k)+","+rtos(c.rect.pos.x)+","+rtos(c.rect.pos.y)+","+rtos(c.rect.size.x)+","+rtos(c.rect.size.y)+","+rtos(c.v_align)+","+rtos(c.h_align)+","+rtos(c.advance)+"},"); - } - f->store_line("};"); - - Vector<BitmapFont::KerningPairKey> kp=font->get_kerning_pair_keys(); - f->store_line("static const int _builtin_font_kerning_pair_count="+itos(kp.size())+";"); - f->store_line("static const int _builtin_font_kerning_pairs["+itos(kp.size())+"][3]={"); - for(int i=0;i<kp.size();i++) { - - int d = font->get_kerning_pair(kp[i].A,kp[i].B); - f->store_line("{"+itos(kp[i].A)+","+itos(kp[i].B)+","+itos(d)+"},"); - } - - f->store_line("};"); - Image img = tex->get_data(); - - f->store_line("static const int _builtin_font_img_width="+itos(img.get_width())+";"); - f->store_line("static const int _builtin_font_img_height="+itos(img.get_height())+";"); - - String fname = p_font.get_basename()+".sv.png"; - ResourceSaver::save(fname,tex); - Vector<uint8_t> data=FileAccess::get_file_as_array(fname); - - - f->store_line("static const int _builtin_font_img_data_size="+itos(data.size())+";"); - f->store_line("static const unsigned char _builtin_font_img_data["+itos(data.size())+"]={"); - - - - for(int i=0;i<data.size();i++) { - - f->store_line(itos(data[i])+","); - - } - f->store_line("};"); - - } - - void _import() { - - if (source->get_line_edit()->get_text()=="") { - error_dialog->set_text(TTR("No source font file!")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - } - - if (dest->get_line_edit()->get_text()=="") { - error_dialog->set_text(TTR("No target font resource!")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - } - - if (dest->get_line_edit()->get_text().get_file()==".font") { - dest->get_line_edit()->set_text(dest->get_line_edit()->get_text().get_base_dir() + "/" + source->get_line_edit()->get_text().get_file().get_basename() + ".font" ); - } - - if (dest->get_line_edit()->get_text().get_extension() == dest->get_line_edit()->get_text()) { - dest->get_line_edit()->set_text(dest->get_line_edit()->get_text() + ".font"); - } - - if (dest->get_line_edit()->get_text().get_extension().to_lower() != "font") { - error_dialog->set_text(TTR("Invalid file extension.\nPlease use .font.")); - error_dialog->popup_centered(Size2(200,100)); - return; - } - - Ref<ResourceImportMetadata> rimd = get_rimd(); - - if (rimd.is_null()) { - error_dialog->set_text(TTR("Can't load/process source font.")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - } - - Error err = plugin->import(dest->get_line_edit()->get_text(),rimd); - - if (err!=OK) { - error_dialog->set_text(TTR("Couldn't save font.")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - } - - _import_inc(dest->get_line_edit()->get_text()); - - hide(); - } - - EditorFontImportPlugin *plugin; - _EditorFontImportOptions *options; - - static void _bind_methods() { - - ClassDB::bind_method("_update",&EditorFontImportDialog::_update); - ClassDB::bind_method("_update_text",&EditorFontImportDialog::_update_text); - ClassDB::bind_method("_update_text2",&EditorFontImportDialog::_update_text2); - ClassDB::bind_method("_update_text3",&EditorFontImportDialog::_update_text3); - ClassDB::bind_method("_prop_changed",&EditorFontImportDialog::_prop_changed); - ClassDB::bind_method("_src_changed",&EditorFontImportDialog::_src_changed); - ClassDB::bind_method("_font_size_changed",&EditorFontImportDialog::_font_size_changed); - ClassDB::bind_method("_import",&EditorFontImportDialog::_import); - - } - -public: - - void _notification(int p_what) { - - if (p_what==NOTIFICATION_ENTER_TREE) { - prop_edit->edit(options); - _update_text(); - } - } - - void popup_import(const String& p_path) { - - popup_centered(Size2(600,500)*EDSCALE); - - if (p_path!="") { - - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path); - ERR_FAIL_COND(!rimd.is_valid()); - - dest->get_line_edit()->set_text(p_path); - List<String> opts; - rimd->get_options(&opts); - options->reset(); - for(List<String>::Element *E=opts.front();E;E=E->next()) { - - options->_set(E->get(),rimd->get_option(E->get())); - } - - String src = ""; - for(int i=0;i<rimd->get_source_count();i++) { - if (i>0) - src+=","; - src+=EditorImportPlugin::expand_source_path(rimd->get_source_path(i)); - } - source->get_line_edit()->set_text(src); - - font_size->set_value(rimd->get_option("font/size")); - } - } - - - void set_source_and_dest(const String& p_font,const String& p_dest) { - source->get_line_edit()->set_text(p_font); - dest->get_line_edit()->set_text(p_dest); - _prop_changed(); - } - - EditorFontImportDialog(EditorFontImportPlugin *p_plugin) { - plugin=p_plugin; - VBoxContainer *vbc = memnew( VBoxContainer ); - add_child(vbc); - //set_child_rect(vbc); - HBoxContainer *hbc = memnew( HBoxContainer); - vbc->add_child(hbc); - VBoxContainer *vbl = memnew( VBoxContainer ); - hbc->add_child(vbl); - hbc->set_v_size_flags(SIZE_EXPAND_FILL); - vbl->set_h_size_flags(SIZE_EXPAND_FILL); - VBoxContainer *vbr = memnew( VBoxContainer ); - hbc->add_child(vbr); - vbr->set_h_size_flags(SIZE_EXPAND_FILL); - - source = memnew( EditorLineEditFileChooser ); - source->get_file_dialog()->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - source->get_file_dialog()->set_mode(EditorFileDialog::MODE_OPEN_FILE); - source->get_file_dialog()->add_filter("*.ttf;TrueType"); - source->get_file_dialog()->add_filter("*.otf;OpenType"); - source->get_file_dialog()->add_filter("*.fnt;BMFont"); - source->get_line_edit()->connect("text_entered",this,"_src_changed"); - - vbl->add_margin_child(TTR("Source Font:"),source); - font_size = memnew( SpinBox ); - vbl->add_margin_child(TTR("Source Font Size:"),font_size); - font_size->set_min(3); - font_size->set_max(256); - font_size->set_value(16); - font_size->connect("value_changed",this,"_font_size_changed"); - dest = memnew( EditorLineEditFileChooser ); - // - List<String> fl; - Ref<BitmapFont> font= memnew(BitmapFont); - dest->get_file_dialog()->add_filter("*.font ; Font" ); - /* - ResourceSaver::get_recognized_extensions(font,&fl); - for(List<String>::Element *E=fl.front();E;E=E->next()) { - dest->get_file_dialog()->add_filter("*."+E->get()); - } - */ - - vbl->add_margin_child(TTR("Dest Resource:"),dest); - HBoxContainer *testhb = memnew( HBoxContainer ); - test_string = memnew( LineEdit ); - test_string->set_text(TTR("The quick brown fox jumps over the lazy dog.")); - test_string->set_h_size_flags(SIZE_EXPAND_FILL); - test_string->set_stretch_ratio(5); - - testhb->add_child(test_string); - test_color = memnew( ColorPickerButton ); - test_color->set_pick_color(get_color("font_color","Label")); - test_color->set_h_size_flags(SIZE_EXPAND_FILL); - test_color->set_stretch_ratio(1); - test_color->connect("color_changed",this,"_update_text3"); - testhb->add_child(test_color); - - vbl->add_spacer(); - vbl->add_margin_child(TTR("Test:")+" ",testhb); - /* - HBoxContainer *upd_hb = memnew( HBoxContainer ); - //vbl->add_child(upd_hb); - upd_hb->add_spacer(); - Button *update = memnew( Button); - upd_hb->add_child(update); - update->set_text("Update"); - update->connect("pressed",this,"_update"); -*/ - options = memnew( _EditorFontImportOptions ); - prop_edit = memnew( PropertyEditor() ); - vbr->add_margin_child(TTR("Options:"),prop_edit,true); - options->connect("changed",this,"_prop_changed"); - - prop_edit->hide_top_label(); - - Panel *panel = memnew( Panel ); - vbc->add_child(panel); - test_label = memnew( Label ); - test_label->set_autowrap(true); - panel->add_child(test_label); - test_label->set_area_as_parent_rect(); - panel->set_v_size_flags(SIZE_EXPAND_FILL); - test_string->connect("text_changed",this,"_update_text2"); - set_title(TTR("Font Import")); - timer = memnew( Timer ); - add_child(timer); - timer->connect("timeout",this,"_update"); - timer->set_wait_time(0.4); - timer->set_one_shot(true); - - get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text(TTR("Import")); - - error_dialog = memnew ( ConfirmationDialog ); - add_child(error_dialog); - error_dialog->get_ok()->set_text(TTR("Accept")); - set_hide_on_ok(false); - - - } - - ~EditorFontImportDialog() { - memdelete(options); - } -}; - - -/////////////////////////////////////// - - - -struct _EditorFontData { - - Vector<uint8_t> bitmap; - int width,height; - int ofs_x; //offset to center, from ABOVE - int ofs_y; //offset to beginning, from LEFT - int valign; //vertical alignment - int halign; - float advance; - int character; - int glyph; - - int texture; - Image blit; - Point2i blit_ofs; - //bool printable; - -}; - - -struct _EditorFontDataSort { - - bool operator()(const _EditorFontData *p_A,const _EditorFontData *p_B) const { - return p_A->height > p_B->height; - }; -}; - -struct _EditorKerningKey { - - CharType A,B; - bool operator<(const _EditorKerningKey& p_k) const { return (A==p_k.A)?(B<p_k.B):(A<p_k.A); } - -}; - - -static unsigned char get_SDF_radial( - unsigned char *fontmap, - int w, int h, - int x, int y, - int max_radius ) -{ - //hideous brute force method - float d2 = max_radius*max_radius+1.0; - unsigned char v = fontmap[x+y*w]; - for( int radius = 1; (radius <= max_radius) && (radius*radius < d2); ++radius ) - { - int line, lo, hi; - //north - line = y - radius; - if( (line >= 0) && (line < h) ) - { - lo = x - radius; - hi = x + radius; - if( lo < 0 ) { lo = 0; } - if( hi >= w ) { hi = w-1; } - int idx = line * w + lo; - for( int i = lo; i <= hi; ++i ) - { - //check this pixel - if( fontmap[idx] != v ) - { - float nx = i - x; - float ny = line - y; - float nd2 = nx*nx+ny*ny; - if( nd2 < d2 ) - { - d2 = nd2; - } - } - //move on - ++idx; - } - } - //south - line = y + radius; - if( (line >= 0) && (line < h) ) - { - lo = x - radius; - hi = x + radius; - if( lo < 0 ) { lo = 0; } - if( hi >= w ) { hi = w-1; } - int idx = line * w + lo; - for( int i = lo; i <= hi; ++i ) - { - //check this pixel - if( fontmap[idx] != v ) - { - float nx = i - x; - float ny = line - y; - float nd2 = nx*nx+ny*ny; - if( nd2 < d2 ) - { - d2 = nd2; - } - } - //move on - ++idx; - } - } - //west - line = x - radius; - if( (line >= 0) && (line < w) ) - { - lo = y - radius + 1; - hi = y + radius - 1; - if( lo < 0 ) { lo = 0; } - if( hi >= h ) { hi = h-1; } - int idx = lo * w + line; - for( int i = lo; i <= hi; ++i ) - { - //check this pixel - if( fontmap[idx] != v ) - { - float nx = line - x; - float ny = i - y; - float nd2 = nx*nx+ny*ny; - if( nd2 < d2 ) - { - d2 = nd2; - } - } - //move on - idx += w; - } - } - //east - line = x + radius; - if( (line >= 0) && (line < w) ) - { - lo = y - radius + 1; - hi = y + radius - 1; - if( lo < 0 ) { lo = 0; } - if( hi >= h ) { hi = h-1; } - int idx = lo * w + line; - for( int i = lo; i <= hi; ++i ) - { - //check this pixel - if( fontmap[idx] != v ) - { - float nx = line - x; - float ny = i - y; - float nd2 = nx*nx+ny*ny; - if( nd2 < d2 ) - { - d2 = nd2; - } - } - //move on - idx += w; - } - } - } - d2 = sqrtf( d2 ); - if( v==0 ) - { - d2 = -d2; - } - d2 *= 127.5 / max_radius; - d2 += 127.5; - if( d2 < 0.0 ) d2 = 0.0; - if( d2 > 255.0 ) d2 = 255.0; - return (unsigned char)(d2 + 0.5); -} - - -Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMetadata>& p_from, const String &p_existing) { - - - - Ref<ResourceImportMetadata> from = p_from; - ERR_FAIL_COND_V(from->get_source_count()!=1,Ref<BitmapFont>()); - - String src_path = EditorImportPlugin::expand_source_path(from->get_source_path(0)); - - if (src_path.get_extension().to_lower()=="fnt") { - - if (ResourceLoader::load(src_path).is_valid()) { - EditorNode::get_singleton()->show_warning(TTR("Path:")+" "+src_path+"\n"+TTR("This file is already a Godot font file, please supply a BMFont type file instead.")); - return Ref<BitmapFont>(); - } - - Ref<BitmapFont> font; - font.instance(); - Error err = font->create_from_fnt(src_path); - if (err) { - EditorNode::get_singleton()->show_warning(TTR("Path:")+" "+src_path+"\n"+TTR("Failed opening as BMFont file.")); - return Ref<BitmapFont>(); - } - - return font; - } - - int size = from->get_option("font/size"); - -#ifdef FREETYPE_ENABLED - FT_Library library; /* handle to library */ - FT_Face face; /* handle to face object */ - - Vector<_EditorFontData*> font_data_list; - - int error = FT_Init_FreeType( &library ); - - ERR_EXPLAIN(TTR("Error initializing FreeType.")); - ERR_FAIL_COND_V( error !=0, Ref<BitmapFont>() ); - - print_line("loadfrom: "+src_path); - error = FT_New_Face( library, src_path.utf8().get_data(),0,&face ); - - if ( error == FT_Err_Unknown_File_Format ) { - ERR_EXPLAIN(TTR("Unknown font format.")); - FT_Done_FreeType( library ); - } else if ( error ) { - - ERR_EXPLAIN(TTR("Error loading font.")); - FT_Done_FreeType( library ); - - } - - ERR_FAIL_COND_V(error,Ref<BitmapFont>()); - - - int height=0; - int ascent=0; - int font_spacing=0; - - error = FT_Set_Char_Size(face,0,64*size,512,512); - - if ( error ) { - FT_Done_FreeType( library ); - ERR_EXPLAIN(TTR("Invalid font size.")); - ERR_FAIL_COND_V( error,Ref<BitmapFont>() ); - - } - - int font_mode = from->get_option("mode/mode"); - - int scaler=(font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD)?16:1; - - error = FT_Set_Pixel_Sizes(face,0,size*scaler); - - FT_GlyphSlot slot = face->glyph; - - //error = FT_Set_Charmap(face,ft_encoding_unicode ); /* encoding.. */ - - - /* PRINT CHARACTERS TO INDIVIDUAL BITMAPS */ - - - //int space_size=5; //size for space, if none found.. 5! - //int min_valign=500; //some ridiculous number - - FT_ULong charcode; - FT_UInt gindex; - - int max_up=-1324345; ///gibberish - int max_down=124232; - - Map<_EditorKerningKey,int> kerning_map; - - charcode = FT_Get_First_Char( face, &gindex ); - - Set<CharType> import_chars; - - int import_mode = from->get_option("character_set/mode"); - bool round_advance = from->get_option("advanced/round_advance"); - - if (import_mode>=_EditorFontImportOptions::CHARSET_CUSTOM) { - - //load from custom text - String path = from->get_option("character_set/custom"); - - FileAccess *fa = FileAccess::open(EditorImportPlugin::expand_source_path(path),FileAccess::READ); - - if ( !fa ) { - - FT_Done_FreeType( library ); - ERR_EXPLAIN(TTR("Invalid font custom source.")); - ERR_FAIL_COND_V( !fa,Ref<BitmapFont>() ); - - } - - - while(!fa->eof_reached()) { - - String line = fa->get_line(); - for(int i=0;i<line.length();i++) { - import_chars.insert(line[i]); - } - } - - if (import_mode==_EditorFontImportOptions::CHARSET_CUSTOM_LATIN) { - - for(int i=32;i<128;i++) - import_chars.insert(i); - } - - memdelete(fa); - } - - int xsize=0; - while ( gindex != 0 ) - { - - bool skip=false; - error = FT_Load_Char( face, charcode, font_mode==_EditorFontImportOptions::FONT_BITMAP?FT_LOAD_RENDER:FT_LOAD_MONOCHROME ); - if (error) skip=true; - else error = FT_Render_Glyph( face->glyph, font_mode==_EditorFontImportOptions::FONT_BITMAP?ft_render_mode_normal:ft_render_mode_mono ); - if (error) { - skip=true; - } else if (!skip) { - - switch(import_mode) { - - case _EditorFontImportOptions::CHARSET_ASCII: skip = charcode>127; break; - case _EditorFontImportOptions::CHARSET_LATIN: skip = charcode>255 ;break; - case _EditorFontImportOptions::CHARSET_UNICODE: break; //none - case _EditorFontImportOptions::CHARSET_CUSTOM: - case _EditorFontImportOptions::CHARSET_CUSTOM_LATIN: skip = !import_chars.has(charcode); break; - - } - } - - if (charcode<=32) //?? - skip=true; - - if (skip) { - charcode=FT_Get_Next_Char(face,charcode,&gindex); - continue; - } - - _EditorFontData * fdata = memnew( _EditorFontData ); - - - int w = slot->bitmap.width; - int h = slot->bitmap.rows; - int p = slot->bitmap.pitch; - - //print_line("W: "+itos(w)+" P: "+itos(slot->bitmap.pitch)); - - if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) { - - //oversize the holding buffer so I can smooth it! - int sw = w + scaler * 4; - int sh = h + scaler * 4; - //do the SDF - int sdfw = sw / scaler; - int sdfh = sh / scaler; - - fdata->width=sdfw; - fdata->height=sdfh; - } else { - fdata->width=w; - fdata->height=h; - } - - fdata->character=charcode; - fdata->glyph=FT_Get_Char_Index(face,charcode); - if (charcode=='x') - xsize=w/scaler; - - - - fdata->valign=slot->bitmap_top; - fdata->halign=slot->bitmap_left; - - if (round_advance) - fdata->advance=(slot->advance.x+(1<<5))>>6; - else - fdata->advance=slot->advance.x/float(1<<6); - - if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) { - - fdata->halign = fdata->halign / scaler - 1.5; - fdata->valign = fdata->valign / scaler + 1.5; - fdata->advance/=scaler; - - } - - fdata->advance+=font_spacing; - - - if (charcode<127) { - int top = fdata->valign; - int hmax = h/scaler; - - if (top>max_up) { - - max_up=top; - } - - - if ( (top - hmax)<max_down ) { - - max_down=top - hmax; - } - } - - if (font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD) { - - - //oversize the holding buffer so I can smooth it! - int sw = w + scaler * 4; - int sh = h + scaler * 4; - - unsigned char *smooth_buf = new unsigned char[sw*sh]; - - for( int i = 0; i < sw*sh; ++i ) { - smooth_buf[i] = 0; - } - - // copy the glyph into the buffer to be smoothed - unsigned char *buf = slot->bitmap.buffer; - for( int j = 0; j < h; ++j ) { - for( int i = 0; i < w; ++i ) { - smooth_buf[scaler*2+i+(j+scaler*2)*sw] = 255 * ((buf[j*p+(i>>3)] >> (7 - (i & 7))) & 1); - } - } - - // do the SDF - int sdfw = fdata->width; - int sdfh = fdata->height; - - fdata->bitmap.resize( sdfw*sdfh ); - - for( int j = 0; j < sdfh; ++j ) { - for( int i = 0; i < sdfw; ++i ) { - int pd_idx = j*sdfw+i; - - //fdata->bitmap[j*slot->bitmap.width+i]=slot->bitmap.buffer[j*slot->bitmap.width+i]; - - fdata->bitmap[pd_idx] = - //get_SDF - get_SDF_radial - ( smooth_buf, sw, sh, - i*scaler + (scaler >>1), j*scaler + (scaler >>1), - 2*scaler ); - - } - } - - delete [] smooth_buf; - - } else { - fdata->bitmap.resize( slot->bitmap.width*slot->bitmap.rows ); - for (int i=0;i<slot->bitmap.width;i++) { - for (int j=0;j<slot->bitmap.rows;j++) { - - fdata->bitmap[j*slot->bitmap.width+i]=slot->bitmap.buffer[j*slot->bitmap.width+i]; - } - } - } - - font_data_list.push_back(fdata); - charcode=FT_Get_Next_Char(face,charcode,&gindex); -// printf("reading char %i\n",charcode); - } - - /* SPACE */ - - _EditorFontData *spd = memnew( _EditorFontData ); - spd->advance=0; - spd->character=' '; - spd->halign=0; - spd->valign=0; - spd->width=0; - spd->height=0; - spd->ofs_x=0; - spd->ofs_y=0; - - if (!FT_Load_Char( face, ' ', FT_LOAD_RENDER ) && !FT_Render_Glyph( face->glyph, font_mode==_EditorFontImportOptions::FONT_BITMAP?ft_render_mode_normal:ft_render_mode_mono )) { - - spd->advance = slot->advance.x>>6; //round to nearest or store as float - spd->advance/=scaler; - spd->advance+=font_spacing; - } else { - - spd->advance=xsize; - spd->advance+=font_spacing; - } - - font_data_list.push_back(spd); - - Set<CharType> exported; - for (int i=0; i<font_data_list.size(); i++) { - exported.insert(font_data_list[i]->character); - }; - int missing = 0; - for(Set<CharType>::Element *E=import_chars.front();E;E=E->next()) { - CharType c = E->get(); - if (!exported.has(c)) { - CharType str[2] = {c, 0}; - printf("** Warning: character %i (%ls) not exported\n", (int)c, str); - ++missing; - }; - }; - print_line("total_chars: "+itos(font_data_list.size())); - - /* KERNING */ - - - for(int i=0;i<font_data_list.size();i++) { - - if (font_data_list[i]->character>512) - continue; - for(int j=0;j<font_data_list.size();j++) { - - if (font_data_list[j]->character>512) - continue; - - FT_Vector delta; - FT_Get_Kerning( face, font_data_list[i]->glyph,font_data_list[j]->glyph, FT_KERNING_DEFAULT, &delta ); - - if (delta.x!=0) { - - _EditorKerningKey kpk; - kpk.A = font_data_list[i]->character; - kpk.B = font_data_list[j]->character; - int kern = ((-delta.x)+(1<<5))>>6; - - if (kern==0) - continue; - kerning_map[kpk]=kern/scaler; - } - } - } - - height=max_up-max_down; - ascent=max_up; - - /* FIND OUT WHAT THE FONT HEIGHT FOR THIS IS */ - - /* ADJUST THE VALIGN FOR EACH CHARACTER */ - - for (int i=0;i<(int)font_data_list.size();i++) { - - font_data_list[i]->valign=max_up-font_data_list[i]->valign; - } - - - - /* ADD THE SPACEBAR CHARACTER */ -/* - _EditorFontData * fdata = new _EditorFontData; - - fdata->character=32; - fdata->bitmap=0; - fdata->width=xsize; - fdata->height=1; - fdata->valign=0; - - font_data_list.push_back(fdata); -*/ - /* SORT BY HEIGHT, SO THEY FIT BETTER ON THE TEXTURE */ - - font_data_list.sort_custom<_EditorFontDataSort>(); - Color *color=memnew_arr(Color,height); - - int gradient_type=from->get_option("color/mode"); - switch(gradient_type) { - case _EditorFontImportOptions::COLOR_WHITE: { - - for(int i=0;i<height;i++){ - color[i]=Color(1,1,1,1); - } - - } break; - case _EditorFontImportOptions::COLOR_CUSTOM: { - - Color cc = from->get_option("color/color"); - for(int i=0;i<height;i++){ - color[i]=cc; - } - - } break; - case _EditorFontImportOptions::COLOR_GRADIENT_RANGE: { - - Color src=from->get_option("color/begin"); - Color to=from->get_option("color/end"); - for(int i=0;i<height;i++){ - color[i]=src.linear_interpolate(to,i/float(height)); - } - - } break; - case _EditorFontImportOptions::COLOR_GRADIENT_IMAGE: { - - String fp = EditorImportPlugin::expand_source_path(from->get_option("color/image")); - Image img; - Error err = ImageLoader::load_image(fp,&img); - if (err==OK) { - - for(int i=0;i<height;i++){ - //color[i]=img.get_pixel(0,i*img.get_height()/height); - } - } else { - - for(int i=0;i<height;i++){ - color[i]=Color(1,1,1,1); - } - } - - } break; - } - - - for(int i=0;i<font_data_list.size();i++) { - - if (font_data_list[i]->bitmap.size()==0) - continue; - - int margin[4]={0,0,0,0}; - - if (from->get_option("shadow/enabled").operator bool()) { - int r=from->get_option("shadow/radius"); - Point2i ofs=Point2(from->get_option("shadow/offset")); - margin[ MARGIN_LEFT ] = MAX( r - ofs.x, 0); - margin[ MARGIN_RIGHT ] = MAX( r + ofs.x, 0); - margin[ MARGIN_TOP ] = MAX( r - ofs.y, 0); - margin[ MARGIN_BOTTOM ] = MAX( r + ofs.y, 0); - - } - - if (from->get_option("shadow2/enabled").operator bool()) { - int r=from->get_option("shadow2/radius"); - Point2i ofs=Point2(from->get_option("shadow2/offset")); - margin[ MARGIN_LEFT ] = MAX( r - ofs.x, margin[ MARGIN_LEFT ]); - margin[ MARGIN_RIGHT ] = MAX( r + ofs.x, margin[ MARGIN_RIGHT ]); - margin[ MARGIN_TOP ] = MAX( r - ofs.y, margin[ MARGIN_TOP ]); - margin[ MARGIN_BOTTOM ] = MAX( r + ofs.y, margin[ MARGIN_BOTTOM ]); - - } - - Size2i s; - s.width=font_data_list[i]->width+margin[MARGIN_LEFT]+margin[MARGIN_RIGHT]; - s.height=font_data_list[i]->height+margin[MARGIN_TOP]+margin[MARGIN_BOTTOM]; - Point2i o; - o.x=margin[MARGIN_LEFT]; - o.y=margin[MARGIN_TOP]; - - int ow=font_data_list[i]->width; - int oh=font_data_list[i]->height; - - PoolVector<uint8_t> pixels; - pixels.resize(s.x*s.y*4); - - PoolVector<uint8_t>::Write w = pixels.write(); - //print_line("val: "+itos(font_data_list[i]->valign)); - for(int y=0;y<s.height;y++) { - - int yc=CLAMP(y-o.y+font_data_list[i]->valign,0,height-1); - Color c=color[yc]; - c.a=0; - - for(int x=0;x<s.width;x++) { - - int ofs=y*s.x+x; - w[ofs*4+0]=c.r*255.0; - w[ofs*4+1]=c.g*255.0; - w[ofs*4+2]=c.b*255.0; - w[ofs*4+3]=c.a*255.0; - } - } - - - for(int si=0;si<2;si++) { - -#define S_VAR(m_v) (String(si == 0 ? "shadow/" : "shadow2/") + m_v) - if (from->get_option(S_VAR("enabled")).operator bool()) { - int r = from->get_option(S_VAR("radius")); - - Color sc = from->get_option(S_VAR("color")); - Point2i so=Point2(from->get_option(S_VAR("offset"))); - - float tr = from->get_option(S_VAR("transition")); - print_line("shadow enabled: "+itos(si)); - - Vector<uint8_t> s2buf; - s2buf.resize(s.x*s.y); - uint8_t *wa=s2buf.ptr(); - - for(int j=0;j<s.x*s.y;j++){ - - wa[j]=0; - } - - // blit shadowa - for(int x=0;x<ow;x++) { - for(int y=0;y<oh;y++) { - int ofs = (o.y+y+so.y)*s.x+x+o.x+so.x; - wa[ofs]=font_data_list[i]->bitmap[y*ow+x]; - } - } - //blur shadow2 with separatable convolution - - if (r>0) { - - Vector<uint8_t> pixels2; - pixels2.resize(s2buf.size()); - uint8_t *w2=pixels2.ptr(); - //vert - for(int x=0;x<s.width;x++) { - for(int y=0;y<s.height;y++) { - - int ofs = y*s.width+x; - int sum=wa[ofs]; - - for(int k=1;k<=r;k++) { - - int ofs_d=MIN(y+k,s.height-1)*s.width+x; - int ofs_u=MAX(y-k,0)*s.width+x; - sum+=wa[ofs_d]; - sum+=wa[ofs_u]; - } - - w2[ofs]=sum/(r*2+1); - - } - } - //horiz - for(int x=0;x<s.width;x++) { - for(int y=0;y<s.height;y++) { - - int ofs = y*s.width+x; - int sum=w2[ofs]; - - for(int k=1;k<=r;k++) { - - int ofs_r=MIN(x+k,s.width-1)+s.width*y; - int ofs_l=MAX(x-k,0)+s.width*y; - sum+=w2[ofs_r]; - sum+=w2[ofs_l]; - } - - wa[ofs]=Math::pow(float(sum/(r*2+1))/255.0f,tr)*255.0f; - - } - } - - } - - //blend back - - for(int j=0;j<s.x*s.y;j++){ - Color wd(w[j*4+0]/255.0,w[j*4+1]/255.0,w[j*4+2]/255.0,w[j*4+3]/255.0); - Color ws(sc.r,sc.g,sc.b,sc.a*(wa[j]/255.0)); - Color b = wd.blend(ws); - - w[j*4+0]=b.r*255.0; - w[j*4+1]=b.g*255.0; - w[j*4+2]=b.b*255.0; - w[j*4+3]=b.a*255.0; - - } - } - } - - for(int y=0;y<oh;y++) { - int yc=CLAMP(y+font_data_list[i]->valign,0,height-1); - Color sc=color[yc]; - for(int x=0;x<ow;x++) { - int ofs = (o.y+y)*s.x+x+o.x; - float c = font_data_list[i]->bitmap[y*ow+x]/255.0; - Color src_col=sc; - src_col.a*=c; - Color dst_col(w[ofs*4+0]/255.0,w[ofs*4+1]/255.0,w[ofs*4+2]/255.0,w[ofs*4+3]/255.0); - dst_col = dst_col.blend(src_col); - w[ofs*4+0]=dst_col.r*255.0; - w[ofs*4+1]=dst_col.g*255.0; - w[ofs*4+2]=dst_col.b*255.0; - w[ofs*4+3]=dst_col.a*255.0; - } - } - - - w=PoolVector<uint8_t>::Write(); - - Image img(s.width,s.height,0,Image::FORMAT_RGBA8,pixels); - - font_data_list[i]->blit=img; - font_data_list[i]->blit_ofs=o; - - } - - //make atlas - int spacing=2; - Vector<Size2i> sizes; - sizes.resize(font_data_list.size()); - for(int i=0;i<font_data_list.size();i++) { - - sizes[i]=Size2(font_data_list[i]->blit.get_width()+spacing*2,font_data_list[i]->blit.get_height()+spacing*2); - - } - Vector<Point2i> res; - Size2i res_size; - EditorAtlas::fit(sizes,res,res_size); - res_size.x=next_power_of_2(res_size.x); - res_size.y=next_power_of_2(res_size.y); - print_line("Atlas size: "+res_size); - - Image atlas(res_size.x,res_size.y,0,Image::FORMAT_RGBA8); - - for(int i=0;i<font_data_list.size();i++) { - - if (font_data_list[i]->bitmap.size()==0) - continue; - atlas.blit_rect(font_data_list[i]->blit,Rect2(0,0,font_data_list[i]->blit.get_width(),font_data_list[i]->blit.get_height()),res[i]+Size2(spacing,spacing)); - font_data_list[i]->ofs_x=res[i].x+spacing; - font_data_list[i]->ofs_y=res[i].y+spacing; - - - } - - if (from->has_option("advanced/premultiply_alpha") && bool(from->get_option("advanced/premultiply_alpha"))) { - - PoolVector<uint8_t> data = atlas.get_data(); - int dl = data.size(); - { - PoolVector<uint8_t>::Write w = data.write(); - - for(int i=0;i<dl;i+=4) { - - w[i+0]= uint8_t(int(w[i+0])*int(w[i+3])/255); - w[i+1]= uint8_t(int(w[i+1])*int(w[i+3])/255); - w[i+2]= uint8_t(int(w[i+2])*int(w[i+3])/255); - } - } - - atlas=Image(res_size.x,res_size.y,0,Image::FORMAT_RGBA8,data); - } - - if (from->has_option("color/monochrome") && bool(from->get_option("color/monochrome"))) { - - atlas.convert(Image::FORMAT_LA8); - } - - - if (0) { - //debug the texture - Ref<ImageTexture> atlast = memnew( ImageTexture ); - atlast->create_from_image(atlas); - //atlast->create_from_image(font_data_list[5]->blit); - TextureRect *tf = memnew( TextureRect ); - tf->set_texture(atlast); - dialog->add_child(tf); - } - - - /* CREATE FONT */ - - int char_space = from->get_option("extra_space/char"); - int space_space = from->get_option("extra_space/space"); - int top_space = from->get_option("extra_space/top"); - int bottom_space = from->get_option("extra_space/bottom"); - bool enable_filter = from->get_option("advanced/enable_filter"); - if (from->has_option("advanced/disable_filter")){ // this is a compatibility check for a deprecated option - enable_filter = !from->get_option("advanced/disable_filter"); - } - - Ref<BitmapFont> font; - - if (p_existing!=String() && ResourceCache::has(p_existing)) { - - font = Ref<BitmapFont>( Object::cast_to<BitmapFont>(ResourceCache::get(p_existing))); - } - - if (font.is_null()) { - font = Ref<BitmapFont>( memnew( BitmapFont ) ); - } - - font->clear(); - font->set_height(height+bottom_space+top_space); - font->set_ascent(ascent+top_space); - font->set_distance_field_hint(font_mode==_EditorFontImportOptions::FONT_DISTANCE_FIELD); - - //register texures - { - Ref<ImageTexture> t = memnew(ImageTexture); - int flags; - if (!enable_filter) - flags=0; - else - flags=Texture::FLAG_FILTER; - t->create_from_image(atlas,flags); - t->set_storage( ImageTexture::STORAGE_COMPRESS_LOSSLESS ); - font->add_texture(t); - - } - //register characters - - - for(int i=0;i<font_data_list.size();i++) { - _EditorFontData *fd=font_data_list[i]; - int tex_idx=0; - - font->add_char(fd->character,tex_idx,Rect2( fd->ofs_x, fd->ofs_y, fd->blit.get_width(), fd->blit.get_height()),Point2(fd->halign-fd->blit_ofs.x,fd->valign-fd->blit_ofs.y+top_space), fd->advance+char_space+(fd->character==' '?space_space:0)); - memdelete(fd); - } - - for(Map<_EditorKerningKey,int>::Element *E=kerning_map.front();E;E=E->next()) { - - font->add_kerning_pair(E->key().A,E->key().B,E->get()); - } - - FT_Done_FreeType( library ); - - return font; -#else - - return Ref<BitmapFont>(); -#endif -} - - -String EditorFontImportPlugin::get_name() const { - - return "font"; -} -String EditorFontImportPlugin::get_visible_name() const{ - - return TTR("Font"); -} -void EditorFontImportPlugin::import_dialog(const String& p_from){ - - dialog->popup_import(p_from); -} -Error EditorFontImportPlugin::import(const String& p_path, const Ref<ResourceImportMetadata>& p_from){ - - - Ref<BitmapFont> font = EditorFontImportPlugin::generate_font(p_from,p_path); - if (!font.is_valid()) - return ERR_CANT_CREATE; - - Ref<ResourceImportMetadata> from=p_from; - from->set_source_md5(0,FileAccess::get_md5(EditorImportPlugin::expand_source_path(from->get_source_path(0)))); - from->set_editor(get_name()); - font->set_import_metadata(from); - - return ResourceSaver::save(p_path,font); - -} - -void EditorFontImportPlugin::import_from_drop(const Vector<String>& p_drop, const String &p_dest_path) { - - for(int i=0;i<p_drop.size();i++) { - String ext = p_drop[i].get_extension().to_lower(); - String file = p_drop[i].get_file(); - if (ext=="ttf" || ext=="otf" || ext=="fnt") { - - import_dialog(); - dialog->set_source_and_dest(p_drop[i],p_dest_path.plus_file(file.get_basename()+".font")); - break; - } - } -} - - -EditorFontImportPlugin::EditorFontImportPlugin(EditorNode* p_editor) { - - dialog = memnew( EditorFontImportDialog(this) ); - p_editor->get_gui_base()->add_child(dialog); -} -#endif diff --git a/editor/io_plugins/editor_font_import_plugin.h b/editor/io_plugins/editor_font_import_plugin.h deleted file mode 100644 index d204b8ea97..0000000000 --- a/editor/io_plugins/editor_font_import_plugin.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************/ -/* editor_font_import_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_FONT_IMPORT_PLUGIN_H -#define EDITOR_FONT_IMPORT_PLUGIN_H - -#include "editor/editor_export.h" -#include "scene/resources/font.h" -#if 0 -class EditorNode; -class EditorFontImportDialog; - -class EditorFontImportPlugin : public EditorImportPlugin { - - GDCLASS(EditorFontImportPlugin,EditorImportPlugin); - - EditorFontImportDialog *dialog; -public: - - Ref<BitmapFont> generate_font(const Ref<ResourceImportMetadata>& p_from,const String& p_existing=String()); //used by editor - - 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); - - - EditorFontImportPlugin(EditorNode* p_editor); -}; - -#endif // EDITOR_FONT_IMPORT_PLUGIN_H -#endif diff --git a/editor/io_plugins/editor_mesh_import_plugin.cpp b/editor/io_plugins/editor_mesh_import_plugin.cpp deleted file mode 100644 index 0c9f3a3f37..0000000000 --- a/editor/io_plugins/editor_mesh_import_plugin.cpp +++ /dev/null @@ -1,594 +0,0 @@ -/*************************************************************************/ -/* editor_mesh_import_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_mesh_import_plugin.h" - -#if 0 - -#include "editor/editor_dir_dialog.h" -#include "editor/editor_file_dialog.h" -#include "editor/editor_node.h" -#include "editor/property_editor.h" -//#include "scene/resources/sample.h" -#include "io/marshalls.h" -#include "io/resource_saver.h" -#include "os/file_access.h" -#include "scene/resources/surface_tool.h" - -class _EditorMeshImportOptions : public Object { - - GDCLASS(_EditorMeshImportOptions,Object); -public: - - - bool generate_tangents; - bool generate_normals; - bool flip_faces; - bool smooth_shading; - bool weld_vertices; - bool import_material; - bool import_textures; - float weld_tolerance; - - - bool _set(const StringName& p_name, const Variant& p_value) { - - String n = p_name; - if (n=="generate/tangents") - generate_tangents=p_value; - else if (n=="generate/normals") - generate_normals=p_value; - else if (n=="import/materials") - import_material=p_value; - else if (n=="import/textures") - import_textures=p_value; - else if (n=="force/flip_faces") - flip_faces=p_value; - else if (n=="force/smooth_shading") - smooth_shading=p_value; - else if (n=="force/weld_vertices") - weld_vertices=p_value; - else if (n=="force/weld_tolerance") - weld_tolerance=p_value; - else - return false; - - return true; - - } - - bool _get(const StringName& p_name,Variant &r_ret) const{ - - String n = p_name; - if (n=="generate/tangents") - r_ret=generate_tangents; - else if (n=="generate/normals") - r_ret=generate_normals; - else if (n=="import/materials") - r_ret=import_material; - else if (n=="import/textures") - r_ret=import_textures; - else if (n=="force/flip_faces") - r_ret=flip_faces; - else if (n=="force/smooth_shading") - r_ret=smooth_shading; - else if (n=="force/weld_vertices") - r_ret=weld_vertices; - else if (n=="force/weld_tolerance") - r_ret=weld_tolerance; - else - return false; - - return true; - - } - void _get_property_list( List<PropertyInfo> *p_list) const{ - - p_list->push_back(PropertyInfo(Variant::BOOL,"generate/tangents")); - p_list->push_back(PropertyInfo(Variant::BOOL,"generate/normals")); - //not for nowp - //p_list->push_back(PropertyInfo(Variant::BOOL,"import/materials")); - //p_list->push_back(PropertyInfo(Variant::BOOL,"import/textures")); - p_list->push_back(PropertyInfo(Variant::BOOL,"force/flip_faces")); - p_list->push_back(PropertyInfo(Variant::BOOL,"force/smooth_shading")); - p_list->push_back(PropertyInfo(Variant::BOOL,"force/weld_vertices")); - p_list->push_back(PropertyInfo(Variant::REAL,"force/weld_tolerance",PROPERTY_HINT_RANGE,"0.00001,16,0.00001")); - //p_list->push_back(PropertyInfo(Variant::BOOL,"compress/enable")); - //p_list->push_back(PropertyInfo(Variant::INT,"compress/bitrate",PROPERTY_HINT_ENUM,"64,96,128,192")); - - - } - - - static void _bind_methods() { - - - ADD_SIGNAL( MethodInfo("changed")); - } - - - _EditorMeshImportOptions() { - - generate_tangents=true; - generate_normals=false; - flip_faces=false; - smooth_shading=false; - weld_vertices=true; - weld_tolerance=0.0001; - import_material=false; - import_textures=false; - - } - - -}; - -class EditorMeshImportDialog : public ConfirmationDialog { - - GDCLASS(EditorMeshImportDialog,ConfirmationDialog); - - EditorMeshImportPlugin *plugin; - - LineEdit *import_path; - LineEdit *save_path; - EditorFileDialog *file_select; - EditorDirDialog *save_select; - AcceptDialog *error_dialog; - PropertyEditor *option_editor; - - _EditorMeshImportOptions *options; - - -public: - - void _choose_files(const Vector<String>& p_path) { - - String files; - for(int i=0;i<p_path.size();i++) { - - if (i>0) - files+=","; - files+=p_path[i]; - } - /* - if (p_path.size()) { - String srctex=p_path[0]; - String ipath = EditorImportDB::get_singleton()->find_source_path(srctex); - - if (ipath!="") - save_path->set_text(ipath.get_base_dir()); - }*/ - import_path->set_text(files); - - } - void _choose_save_dir(const String& p_path) { - - save_path->set_text(p_path); - } - - void _browse() { - - file_select->popup_centered_ratio(); - } - - void _browse_target() { - - save_select->popup_centered_ratio(); - } - - void popup_import(const String& p_path) { - - popup_centered(Size2(400,400)*EDSCALE); - - if (p_path!="") { - - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path); - ERR_FAIL_COND(!rimd.is_valid()); - - save_path->set_text(p_path.get_base_dir()); - List<String> opts; - rimd->get_options(&opts); - for(List<String>::Element *E=opts.front();E;E=E->next()) { - - options->_set(E->get(),rimd->get_option(E->get())); - } - - String src = ""; - for(int i=0;i<rimd->get_source_count();i++) { - if (i>0) - src+=","; - src+=EditorImportPlugin::expand_source_path(rimd->get_source_path(i)); - } - import_path->set_text(src); - } - } - - void _import() { - - Vector<String> meshes = import_path->get_text().split(","); - if (meshes.size()==0) { - error_dialog->set_text(TTR("No meshes to import!")); - error_dialog->popup_centered_minsize(); - return; - } - - String dst = save_path->get_text(); - if (dst=="") { - error_dialog->set_text(TTR("Save path is empty!")); - error_dialog->popup_centered_minsize(); - return; - } - - for(int i=0;i<meshes.size();i++) { - - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - - List<PropertyInfo> pl; - options->_get_property_list(&pl); - for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { - - Variant v; - String opt=E->get().name; - options->_get(opt,v); - imd->set_option(opt,v); - - } - - imd->add_source(EditorImportPlugin::validate_source_path(meshes[i])); - - String file_path = dst.plus_file(meshes[i].get_file().get_basename()+".mesh"); - - plugin->import(file_path,imd); - } - - hide(); - } - - void _notification(int p_what) { - - - if (p_what==NOTIFICATION_ENTER_TREE) { - - option_editor->edit(options); - } - } - - static void _bind_methods() { - - ClassDB::bind_method("_choose_files",&EditorMeshImportDialog::_choose_files); - ClassDB::bind_method("_choose_save_dir",&EditorMeshImportDialog::_choose_save_dir); - ClassDB::bind_method("_import",&EditorMeshImportDialog::_import); - ClassDB::bind_method("_browse",&EditorMeshImportDialog::_browse); - ClassDB::bind_method("_browse_target",&EditorMeshImportDialog::_browse_target); - } - - EditorMeshImportDialog(EditorMeshImportPlugin *p_plugin) { - - plugin=p_plugin; - - set_title(TTR("Single Mesh Import")); - set_hide_on_ok(false); - - VBoxContainer *vbc = memnew( VBoxContainer ); - add_child(vbc); - //set_child_rect(vbc); - - HBoxContainer *hbc = memnew( HBoxContainer ); - vbc->add_margin_child(TTR("Source Mesh(es):"),hbc); - - import_path = memnew( LineEdit ); - import_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(import_path); - - Button * import_choose = memnew( Button ); - import_choose->set_text(" .. "); - hbc->add_child(import_choose); - - import_choose->connect("pressed", this,"_browse"); - - hbc = memnew( HBoxContainer ); - vbc->add_margin_child(TTR("Target Path:"),hbc); - - save_path = memnew( LineEdit ); - save_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(save_path); - - Button * save_choose = memnew( Button ); - save_choose->set_text(" .. "); - hbc->add_child(save_choose); - - save_choose->connect("pressed", this,"_browse_target"); - - file_select = memnew( EditorFileDialog ); - file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES); - file_select->add_filter("*.obj ; Wavefront OBJ"); - add_child(file_select); - file_select->connect("files_selected", this,"_choose_files"); - - save_select = memnew( EditorDirDialog ); - add_child(save_select); - save_select->connect("dir_selected", this,"_choose_save_dir"); - - get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text(TTR("Import")); - - error_dialog = memnew( AcceptDialog ); - add_child(error_dialog); - - options = memnew( _EditorMeshImportOptions ); - - option_editor = memnew( PropertyEditor ); - option_editor->hide_top_label(); - vbc->add_margin_child(TTR("Options:"),option_editor,true); - } - - ~EditorMeshImportDialog() { - memdelete(options); - } - -}; - - -String EditorMeshImportPlugin::get_name() const { - - return "mesh"; -} -String EditorMeshImportPlugin::get_visible_name() const{ - - return TTR("Mesh"); -} -void EditorMeshImportPlugin::import_dialog(const String& p_from){ - - dialog->popup_import(p_from); -} -Error EditorMeshImportPlugin::import(const String& p_path, const Ref<ResourceImportMetadata>& p_from){ - - - ERR_FAIL_COND_V(p_from->get_source_count()!=1,ERR_INVALID_PARAMETER); - - Ref<ResourceImportMetadata> from=p_from; - - String src_path=EditorImportPlugin::expand_source_path(from->get_source_path(0)); - FileAccessRef f = FileAccess::open(src_path,FileAccess::READ); - ERR_FAIL_COND_V(!f,ERR_CANT_OPEN); - - Ref<Mesh> mesh; - Map<String,Ref<Material> > name_map; - - if (FileAccess::exists(p_path)) { - mesh=ResourceLoader::load(p_path,"Mesh"); - if (mesh.is_valid()) { - for(int i=0;i<mesh->get_surface_count();i++) { - - if (!mesh->surface_get_material(i).is_valid()) - continue; - String name; - if (mesh->surface_get_name(i)!="") - name=mesh->surface_get_name(i); - else - name=vformat(TTR("Surface %d"),i+1); - - name_map[name]=mesh->surface_get_material(i); - } - - while(mesh->get_surface_count()) { - mesh->surface_remove(0); - } - } - } - - if (!mesh.is_valid()) - mesh = Ref<Mesh>( memnew( Mesh ) ); - - - bool generate_normals=from->get_option("generate/normals"); - bool generate_tangents=from->get_option("generate/tangents"); - bool flip_faces=from->get_option("force/flip_faces"); - bool force_smooth=from->get_option("force/smooth_shading"); - bool weld_vertices=from->get_option("force/weld_vertices"); - float weld_tolerance=from->get_option("force/weld_tolerance"); - Vector<Vector3> vertices; - Vector<Vector3> normals; - Vector<Vector2> uvs; - String name; - - Ref<SurfaceTool> surf_tool = memnew( SurfaceTool) ; - surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES); - if (force_smooth) - surf_tool->add_smooth_group(true); - int has_index_data=false; - - while(true) { - - - String l = f->get_line().strip_edges(); - - if (l.begins_with("v ")) { - //vertex - Vector<String> v = l.split(" ",false); - ERR_FAIL_COND_V(v.size()<4,ERR_INVALID_DATA); - Vector3 vtx; - vtx.x=v[1].to_float(); - vtx.y=v[2].to_float(); - vtx.z=v[3].to_float(); - vertices.push_back(vtx); - } else if (l.begins_with("vt ")) { - //uv - Vector<String> v = l.split(" ",false); - ERR_FAIL_COND_V(v.size()<3,ERR_INVALID_DATA); - Vector2 uv; - uv.x=v[1].to_float(); - uv.y=1.0-v[2].to_float(); - uvs.push_back(uv); - - } else if (l.begins_with("vn ")) { - //normal - Vector<String> v = l.split(" ",false); - ERR_FAIL_COND_V(v.size()<4,ERR_INVALID_DATA); - Vector3 nrm; - nrm.x=v[1].to_float(); - nrm.y=v[2].to_float(); - nrm.z=v[3].to_float(); - normals.push_back(nrm); - } if (l.begins_with("f ")) { - //vertex - - has_index_data=true; - Vector<String> v = l.split(" ",false); - ERR_FAIL_COND_V(v.size()<4,ERR_INVALID_DATA); - - //not very fast, could be sped up - - - Vector<String> face[3]; - face[0] = v[1].split("/"); - face[1] = v[2].split("/"); - ERR_FAIL_COND_V(face[0].size()==0,ERR_PARSE_ERROR); - ERR_FAIL_COND_V(face[0].size()!=face[1].size(),ERR_PARSE_ERROR); - for(int i=2;i<v.size()-1;i++) { - - face[2] = v[i+1].split("/"); - ERR_FAIL_COND_V(face[0].size()!=face[2].size(),ERR_PARSE_ERROR); - for(int j=0;j<3;j++) { - - int idx=j; - - if (!flip_faces && idx<2) { - idx=1^idx; - } - - - if (face[idx].size()==3) { - int norm = face[idx][2].to_int()-1; - ERR_FAIL_INDEX_V(norm,normals.size(),ERR_PARSE_ERROR); - surf_tool->add_normal(normals[norm]); - } - - if (face[idx].size()>=2 && face[idx][1]!=String()) { - - int uv = face[idx][1].to_int()-1; - ERR_FAIL_INDEX_V(uv,uvs.size(),ERR_PARSE_ERROR); - surf_tool->add_uv(uvs[uv]); - } - - int vtx = face[idx][0].to_int()-1; - ERR_FAIL_INDEX_V(vtx,vertices.size(),ERR_PARSE_ERROR); - - Vector3 vertex = vertices[vtx]; - if (weld_vertices) - vertex=vertex.snapped(weld_tolerance); - surf_tool->add_vertex(vertex); - } - - face[1]=face[2]; - } - } else if (l.begins_with("s ") && !force_smooth) { //smoothing - String what = l.substr(2,l.length()).strip_edges(); - if (what=="off") - surf_tool->add_smooth_group(false); - else - surf_tool->add_smooth_group(true); - - } else if (l.begins_with("o ") || f->eof_reached()) { //new surface or done - - if (has_index_data) { - //new object/surface - if (generate_normals || force_smooth) - surf_tool->generate_normals(); - if (uvs.size() && (normals.size() || generate_normals) && generate_tangents) - surf_tool->generate_tangents(); - - surf_tool->index(); - mesh = surf_tool->commit(mesh); - if (name=="") - name=vformat(TTR("Surface %d"),mesh->get_surface_count()-1); - mesh->surface_set_name(mesh->get_surface_count()-1,name); - name=""; - surf_tool->clear(); - surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES); - if (force_smooth) - surf_tool->add_smooth_group(true); - - has_index_data=false; - - if (f->eof_reached()) - break; - } - - if (l.begins_with("o ")) //name - name=l.substr(2,l.length()).strip_edges(); - } - } - - - from->set_source_md5(0,FileAccess::get_md5(src_path)); - from->set_editor(get_name()); - mesh->set_import_metadata(from); - - //re-apply materials if exist - for(int i=0;i<mesh->get_surface_count();i++) { - - String n = mesh->surface_get_name(i); - if (name_map.has(n)) - mesh->surface_set_material(i,name_map[n]); - } - - Error err = ResourceSaver::save(p_path,mesh); - - return err; -} - - -void EditorMeshImportPlugin::import_from_drop(const Vector<String>& p_drop, const String &p_dest_path) { - - - Vector<String> files; - for(int i=0;i<p_drop.size();i++) { - String ext = p_drop[i].get_extension().to_lower(); - String file = p_drop[i].get_file(); - if (ext=="obj") { - - files.push_back(p_drop[i]); - } - } - - if (files.size()) { - import_dialog(); - dialog->_choose_files(files); - dialog->_choose_save_dir(p_dest_path); - } -} - -EditorMeshImportPlugin::EditorMeshImportPlugin(EditorNode* p_editor) { - - dialog = memnew( EditorMeshImportDialog(this)); - p_editor->get_gui_base()->add_child(dialog); -} -#endif diff --git a/editor/io_plugins/editor_mesh_import_plugin.h b/editor/io_plugins/editor_mesh_import_plugin.h deleted file mode 100644 index 06fdc4195e..0000000000 --- a/editor/io_plugins/editor_mesh_import_plugin.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************/ -/* editor_mesh_import_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_MESH_IMPORT_PLUGIN_H -#define EDITOR_MESH_IMPORT_PLUGIN_H - -#if 0 -#include "editor/editor_import_export.h" -#include "scene/resources/font.h" - -class EditorNode; -class EditorMeshImportDialog; - -class EditorMeshImportPlugin : public EditorImportPlugin { - - GDCLASS(EditorMeshImportPlugin,EditorImportPlugin); - - EditorMeshImportDialog *dialog; - - -public: - - 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); - void import_from_drop(const Vector<String>& p_drop, const String &p_dest_path); - - - EditorMeshImportPlugin(EditorNode* p_editor); -}; - -#endif -#endif // EDITOR_MESH_IMPORT_PLUGIN_H diff --git a/editor/io_plugins/editor_sample_import_plugin.cpp b/editor/io_plugins/editor_sample_import_plugin.cpp deleted file mode 100644 index 69cfb560d5..0000000000 --- a/editor/io_plugins/editor_sample_import_plugin.cpp +++ /dev/null @@ -1,930 +0,0 @@ -/*************************************************************************/ -/* editor_sample_import_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_sample_import_plugin.h" - -#include "editor/editor_dir_dialog.h" -#include "editor/editor_file_dialog.h" -#include "editor/editor_node.h" -#include "editor/editor_settings.h" -#include "editor/property_editor.h" -#include "io/marshalls.h" -#include "io/resource_saver.h" -#include "os/file_access.h" - -#if 0 - -class _EditorSampleImportOptions : public Object { - - GDCLASS(_EditorSampleImportOptions,Object); -public: - - enum CompressMode { - COMPRESS_MODE_DISABLED, - COMPRESS_MODE_RAM, - COMPRESS_MODE_DISK - }; - - enum CompressBitrate { - COMPRESS_64, - COMPRESS_96, - COMPRESS_128, - COMPRESS_192 - }; - - bool force_8_bit; - bool force_mono; - bool force_rate; - float force_rate_hz; - - bool edit_trim; - bool edit_normalize; - bool edit_loop; - - CompressMode compress_mode; - CompressBitrate compress_bitrate; - - - bool _set(const StringName& p_name, const Variant& p_value) { - - String n = p_name; - if (n=="force/8_bit") - force_8_bit=p_value; - else if (n=="force/mono") - force_mono=p_value; - else if (n=="force/max_rate") - force_rate=p_value; - else if (n=="force/max_rate_hz") - force_rate_hz=p_value; - else if (n=="edit/trim") - edit_trim=p_value; - else if (n=="edit/normalize") - edit_normalize=p_value; - else if (n=="edit/loop") - edit_loop=p_value; - else if (n=="compress/mode") - compress_mode=CompressMode(int(p_value)); - else if (n=="compress/bitrate") - compress_bitrate=CompressBitrate(int(p_value)); - else - return false; - - return true; - - } - - bool _get(const StringName& p_name,Variant &r_ret) const{ - - String n = p_name; - if (n=="force/8_bit") - r_ret=force_8_bit; - else if (n=="force/mono") - r_ret=force_mono; - else if (n=="force/max_rate") - r_ret=force_rate; - else if (n=="force/max_rate_hz") - r_ret=force_rate_hz; - else if (n=="edit/trim") - r_ret=edit_trim; - else if (n=="edit/normalize") - r_ret=edit_normalize; - else if (n=="edit/loop") - r_ret=edit_loop; - else if (n=="compress/mode") - r_ret=compress_mode; - else if (n=="compress/bitrate") - r_ret=compress_bitrate; - else - return false; - - return true; - - } - void _get_property_list( List<PropertyInfo> *p_list) const{ - - p_list->push_back(PropertyInfo(Variant::BOOL,"force/8_bit")); - p_list->push_back(PropertyInfo(Variant::BOOL,"force/mono")); - p_list->push_back(PropertyInfo(Variant::BOOL,"force/max_rate")); - p_list->push_back(PropertyInfo(Variant::REAL,"force/max_rate_hz",PROPERTY_HINT_EXP_RANGE,"11025,192000,1")); - p_list->push_back(PropertyInfo(Variant::BOOL,"edit/trim")); - p_list->push_back(PropertyInfo(Variant::BOOL,"edit/normalize")); - p_list->push_back(PropertyInfo(Variant::BOOL,"edit/loop")); - p_list->push_back(PropertyInfo(Variant::INT,"compress/mode",PROPERTY_HINT_ENUM,"Disabled,RAM (Ima-ADPCM)")); - //p_list->push_back(PropertyInfo(Variant::INT,"compress/bitrate",PROPERTY_HINT_ENUM,"64,96,128,192")); - - - } - - - static void _bind_methods() { - - - ADD_SIGNAL( MethodInfo("changed")); - } - - - _EditorSampleImportOptions() { - - force_8_bit=false; - force_mono=false; - force_rate=true; - force_rate_hz=44100; - - edit_trim=true; - edit_normalize=true; - edit_loop=false; - - compress_mode=COMPRESS_MODE_RAM; - compress_bitrate=COMPRESS_128; - } - - -}; - -class EditorSampleImportDialog : public ConfirmationDialog { - - GDCLASS(EditorSampleImportDialog,ConfirmationDialog); - - EditorSampleImportPlugin *plugin; - - LineEdit *import_path; - LineEdit *save_path; - EditorFileDialog *file_select; - EditorDirDialog *save_select; - ConfirmationDialog *error_dialog; - PropertyEditor *option_editor; - - _EditorSampleImportOptions *options; - - -public: - - void _choose_files(const Vector<String>& p_path) { - - String files; - for(int i=0;i<p_path.size();i++) { - - if (i>0) - files+=","; - files+=p_path[i]; - } - /* - if (p_path.size()) { - String srctex=p_path[0]; - String ipath = EditorImportDB::get_singleton()->find_source_path(srctex); - - if (ipath!="") - save_path->set_text(ipath.get_base_dir()); - }*/ - import_path->set_text(files); - - } - void _choose_save_dir(const String& p_path) { - - save_path->set_text(p_path); - } - - void _browse() { - - file_select->popup_centered_ratio(); - } - - void _browse_target() { - - save_select->popup_centered_ratio(); - - } - - - void popup_import(const String& p_path) { - - popup_centered(Size2(400,400)*EDSCALE); - if (p_path!="") { - - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path); - ERR_FAIL_COND(!rimd.is_valid()); - - save_path->set_text(p_path.get_base_dir()); - List<String> opts; - rimd->get_options(&opts); - for(List<String>::Element *E=opts.front();E;E=E->next()) { - - options->_set(E->get(),rimd->get_option(E->get())); - } - - String src = ""; - for(int i=0;i<rimd->get_source_count();i++) { - if (i>0) - src+=","; - src+=EditorImportPlugin::expand_source_path(rimd->get_source_path(i)); - } - import_path->set_text(src); - } - } - - - void _import() { - - Vector<String> samples = import_path->get_text().split(","); - - if (samples.size()==0) { - error_dialog->set_text(TTR("No samples to import!")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - } - - if (save_path->get_text().strip_edges()=="") { - error_dialog->set_text(TTR("Target path is empty.")); - error_dialog->popup_centered_minsize(); - return; - } - - if (!save_path->get_text().begins_with("res://")) { - error_dialog->set_text(TTR("Target path must be a complete resource path.")); - error_dialog->popup_centered_minsize(); - return; - } - - if (!DirAccess::exists(save_path->get_text())) { - error_dialog->set_text(TTR("Target path must exist.")); - error_dialog->popup_centered_minsize(); - return; - } - - for(int i=0;i<samples.size();i++) { - - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - - List<PropertyInfo> pl; - options->_get_property_list(&pl); - for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { - - Variant v; - String opt=E->get().name; - options->_get(opt,v); - imd->set_option(opt,v); - - } - - imd->add_source(EditorImportPlugin::validate_source_path(samples[i])); - - String dst = save_path->get_text(); - if (dst=="") { - error_dialog->set_text(TTR("Save path is empty!")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - } - - dst = dst.plus_file(samples[i].get_file().get_basename()+".sample"); - - plugin->import(dst,imd); - } - - hide(); - - } - - - void _notification(int p_what) { - - - if (p_what==NOTIFICATION_ENTER_TREE) { - - option_editor->edit(options); - } - } - - static void _bind_methods() { - - - ClassDB::bind_method("_choose_files",&EditorSampleImportDialog::_choose_files); - ClassDB::bind_method("_choose_save_dir",&EditorSampleImportDialog::_choose_save_dir); - ClassDB::bind_method("_import",&EditorSampleImportDialog::_import); - ClassDB::bind_method("_browse",&EditorSampleImportDialog::_browse); - ClassDB::bind_method("_browse_target",&EditorSampleImportDialog::_browse_target); - //ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) ); - } - - EditorSampleImportDialog(EditorSampleImportPlugin *p_plugin) { - - plugin=p_plugin; - - - set_title(TTR("Import Audio Samples")); - - VBoxContainer *vbc = memnew( VBoxContainer ); - add_child(vbc); - //set_child_rect(vbc); - - - HBoxContainer *hbc = memnew( HBoxContainer ); - vbc->add_margin_child(TTR("Source Sample(s):"),hbc); - - import_path = memnew( LineEdit ); - import_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(import_path); - - Button * import_choose = memnew( Button ); - import_choose->set_text(" .. "); - hbc->add_child(import_choose); - - import_choose->connect("pressed", this,"_browse"); - - hbc = memnew( HBoxContainer ); - vbc->add_margin_child(TTR("Target Path:"),hbc); - - save_path = memnew( LineEdit ); - save_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(save_path); - - Button * save_choose = memnew( Button ); - save_choose->set_text(" .. "); - hbc->add_child(save_choose); - - save_choose->connect("pressed", this,"_browse_target"); - - file_select = memnew(EditorFileDialog); - file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - add_child(file_select); - file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES); - file_select->connect("files_selected", this,"_choose_files"); - file_select->add_filter("*.wav ; MS Waveform"); - save_select = memnew( EditorDirDialog ); - add_child(save_select); - - //save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR); - save_select->connect("dir_selected", this,"_choose_save_dir"); - - get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text(TTR("Import")); - - - error_dialog = memnew ( ConfirmationDialog ); - add_child(error_dialog); - error_dialog->get_ok()->set_text(TTR("Accept")); - //error_dialog->get_cancel()->hide(); - - set_hide_on_ok(false); - options = memnew( _EditorSampleImportOptions ); - - option_editor = memnew( PropertyEditor ); - option_editor->hide_top_label(); - vbc->add_margin_child(TTR("Options:"),option_editor,true); - } - - ~EditorSampleImportDialog() { - memdelete(options); - } - -}; - - -String EditorSampleImportPlugin::get_name() const { - - return "sample"; -} -String EditorSampleImportPlugin::get_visible_name() const{ - - return TTR("Audio Sample"); -} -void EditorSampleImportPlugin::import_dialog(const String& p_from){ - - dialog->popup_import(p_from); -} -Error EditorSampleImportPlugin::import(const String& p_path, const Ref<ResourceImportMetadata>& p_from){ - - ERR_FAIL_COND_V(p_from->get_source_count()!=1,ERR_INVALID_PARAMETER); - - Ref<ResourceImportMetadata> from=p_from; - - String src_path=EditorImportPlugin::expand_source_path(from->get_source_path(0)); - Ref<Sample> smp = ResourceLoader::load(src_path); - ERR_FAIL_COND_V(smp.is_null(),ERR_CANT_OPEN); - - - float rate = smp->get_mix_rate(); - bool is16 = smp->get_format()==Sample::FORMAT_PCM16; - int chans = smp->is_stereo()?2:1; - int len = smp->get_length(); - Sample::LoopFormat loop= smp->get_loop_format(); - int loop_beg = smp->get_loop_begin(); - int loop_end = smp->get_loop_end(); - - print_line("Input Sample: "); - print_line("\tlen: "+itos(len)); - print_line("\tchans: "+itos(chans)); - print_line("\t16bits: "+itos(is16)); - print_line("\trate: "+itos(rate)); - print_line("\tloop: "+itos(loop)); - print_line("\tloop begin: "+itos(loop_beg)); - print_line("\tloop end: "+itos(loop_end)); - Vector<float> data; - data.resize(len*chans); - - { - PoolVector<uint8_t> src_data = smp->get_data(); - PoolVector<uint8_t>::Read sr = src_data.read(); - - - for(int i=0;i<len*chans;i++) { - - float s=0; - if (is16) { - - int16_t i16 = decode_uint16(&sr[i*2]); - s=i16/32767.0; - } else { - - int8_t i8 = sr[i]; - s=i8/127.0; - } - data[i]=s; - } - } - - //apply frequency limit - - bool limit_rate = from->get_option("force/max_rate"); - int limit_rate_hz = from->get_option("force/max_rate_hz"); - if (limit_rate && rate > limit_rate_hz) { - //resampleeee!!! - int new_data_len = len * limit_rate_hz / rate; - Vector<float> new_data; - new_data.resize( new_data_len * chans ); - for(int c=0;c<chans;c++) { - - for(int i=0;i<new_data_len;i++) { - - //simple cubic interpolation should be enough. - float pos = float(i) * len / new_data_len; - float mu = pos-Math::floor(pos); - int ipos = int(Math::floor(pos)); - - float y0=data[MAX(0,ipos-1)*chans+c]; - float y1=data[ipos*chans+c]; - float y2=data[MIN(len-1,ipos+1)*chans+c]; - float y3=data[MIN(len-1,ipos+2)*chans+c]; - - float mu2 = mu*mu; - float a0 = y3 - y2 - y0 + y1; - float a1 = y0 - y1 - a0; - float a2 = y2 - y0; - float a3 = y1; - - float res=(a0*mu*mu2+a1*mu2+a2*mu+a3); - - new_data[i*chans+c]=res; - } - } - - if (loop) { - - loop_beg=loop_beg*new_data_len/len; - loop_end=loop_end*new_data_len/len; - } - data=new_data; - rate=limit_rate_hz; - len=new_data_len; - } - - - bool normalize = from->get_option("edit/normalize"); - - if (normalize) { - - float max=0; - for(int i=0;i<data.size();i++) { - - float amp = Math::abs(data[i]); - if (amp>max) - max=amp; - } - - if (max>0) { - - float mult=1.0/max; - for(int i=0;i<data.size();i++) { - - data[i]*=mult; - } - - } - } - - bool trim = from->get_option("edit/trim"); - - if (trim && !loop) { - - int first=0; - int last=(len*chans)-1; - bool found=false; - float limit = Math::db2linear((float)-30); - for(int i=0;i<data.size();i++) { - float amp = Math::abs(data[i]); - - if (!found && amp > limit) { - first=i; - found=true; - } - - if (found && amp > limit) { - last=i; - } - } - - first/=chans; - last/=chans; - - if (first<last) { - - Vector<float> new_data; - new_data.resize((last-first+1)*chans); - for(int i=first*chans;i<=last*chans;i++) { - new_data[i-first*chans]=data[i]; - } - - data=new_data; - len=data.size()/chans; - } - - } - - bool make_loop = from->get_option("edit/loop"); - - if (make_loop && !loop) { - - loop=Sample::LOOP_FORWARD; - loop_beg=0; - loop_end=len; - } - - int compression = from->get_option("compress/mode"); - bool force_mono = from->get_option("force/mono"); - - - if (force_mono && chans==2) { - - Vector<float> new_data; - new_data.resize(data.size()/2); - for(int i=0;i<len;i++) { - new_data[i]=(data[i*2+0]+data[i*2+1])/2.0; - } - - data=new_data; - chans=1; - } - - bool force_8_bit = from->get_option("force/8_bit"); - if (force_8_bit) { - - is16=false; - } - - - PoolVector<uint8_t> dst_data; - Sample::Format dst_format; - - if ( compression == _EditorSampleImportOptions::COMPRESS_MODE_RAM) { - - dst_format=Sample::FORMAT_IMA_ADPCM; - if (chans==1) { - _compress_ima_adpcm(data,dst_data); - } else { - - print_line("INTERLEAAVE!"); - - - - //byte interleave - Vector<float> left; - Vector<float> right; - - int tlen = data.size()/2; - left.resize(tlen); - right.resize(tlen); - - for(int i=0;i<tlen;i++) { - left[i]=data[i*2+0]; - right[i]=data[i*2+1]; - } - - PoolVector<uint8_t> bleft; - PoolVector<uint8_t> bright; - - _compress_ima_adpcm(left,bleft); - _compress_ima_adpcm(right,bright); - - int dl = bleft.size(); - dst_data.resize( dl *2 ); - - PoolVector<uint8_t>::Write w=dst_data.write(); - PoolVector<uint8_t>::Read rl=bleft.read(); - PoolVector<uint8_t>::Read rr=bright.read(); - - for(int i=0;i<dl;i++) { - w[i*2+0]=rl[i]; - w[i*2+1]=rr[i]; - } - } - - //print_line("compressing ima-adpcm, resulting buffersize is "+itos(dst_data.size())+" from "+itos(data.size())); - - } else { - - dst_format=is16?Sample::FORMAT_PCM16:Sample::FORMAT_PCM8; - dst_data.resize( data.size() * (is16?2:1)); - { - PoolVector<uint8_t>::Write w = dst_data.write(); - - int ds=data.size(); - for(int i=0;i<ds;i++) { - - if (is16) { - int16_t v = CLAMP(data[i]*32767,-32768,32767); - encode_uint16(v,&w[i*2]); - } else { - int8_t v = CLAMP(data[i]*127,-128,127); - w[i]=v; - } - } - } - } - - - Ref<Sample> target; - - if (ResourceCache::has(p_path)) { - - target = Ref<Sample>( Object::cast_to<Sample>(ResourceCache::get(p_path)) ); - } else { - - target = smp; - } - - target->create(dst_format,chans==2?true:false,len); - target->set_data(dst_data); - target->set_mix_rate(rate); - target->set_loop_format(loop); - target->set_loop_begin(loop_beg); - target->set_loop_end(loop_end); - - from->set_source_md5(0,FileAccess::get_md5(src_path)); - from->set_editor(get_name()); - target->set_import_metadata(from); - - - Error err = ResourceSaver::save(p_path,smp); - - return err; - -} - -void EditorSampleImportPlugin::_compress_ima_adpcm(const Vector<float>& p_data,PoolVector<uint8_t>& dst_data) { - - - /*p_sample_data->data = (void*)malloc(len); - xm_s8 *dataptr=(xm_s8*)p_sample_data->data;*/ - - static const int16_t _ima_adpcm_step_table[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 - }; - - static const int8_t _ima_adpcm_index_table[16] = { - -1, -1, -1, -1, 2, 4, 6, 8, - -1, -1, -1, -1, 2, 4, 6, 8 - }; - - - int datalen = p_data.size(); - int datamax=datalen; - if (datalen&1) - datalen++; - - dst_data.resize(datalen/2+4); - PoolVector<uint8_t>::Write w = dst_data.write(); - - - int i,step_idx=0,prev=0; - uint8_t *out = w.ptr(); - //int16_t xm_prev=0; - const float *in=p_data.ptr(); - - - /* initial value is zero */ - *(out++) =0; - *(out++) =0; - /* Table index initial value */ - *(out++) =0; - /* unused */ - *(out++) =0; - - for (i=0;i<datalen;i++) { - int step,diff,vpdiff,mask; - uint8_t nibble; - int16_t xm_sample; - - if (i>=datamax) - xm_sample=0; - else { - - - xm_sample=CLAMP(in[i]*32767.0,-32768,32767); - /* - if (xm_sample==32767 || xm_sample==-32768) - printf("clippy!\n",xm_sample); - */ - } - - //xm_sample=xm_sample+xm_prev; - //xm_prev=xm_sample; - - diff = (int)xm_sample - prev ; - - nibble=0 ; - step = _ima_adpcm_step_table[ step_idx ]; - vpdiff = step >> 3 ; - if (diff < 0) { - nibble=8; - diff=-diff ; - } - mask = 4 ; - while (mask) { - - if (diff >= step) { - - nibble |= mask; - diff -= step; - vpdiff += step; - } - - step >>= 1 ; - mask >>= 1 ; - }; - - if (nibble&8) - prev-=vpdiff ; - else - prev+=vpdiff ; - - if (prev > 32767) { - //printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip up %i\n",i,xm_sample,prev,diff,vpdiff,prev); - prev=32767; - } else if (prev < -32768) { - //printf("%i,xms %i, prev %i,diff %i, vpdiff %i, clip down %i\n",i,xm_sample,prev,diff,vpdiff,prev); - prev = -32768 ; - } - - step_idx += _ima_adpcm_index_table[nibble]; - if (step_idx< 0) - step_idx= 0 ; - else if (step_idx> 88) - step_idx= 88 ; - - - if (i&1) { - *out|=nibble<<4; - out++; - } else { - *out=nibble; - } - /*dataptr[i]=prev>>8;*/ - } - -} - - -EditorSampleImportPlugin* EditorSampleImportPlugin::singleton=NULL; - - -void EditorSampleImportPlugin::import_from_drop(const Vector<String>& p_drop, const String &p_dest_path) { - - - Vector<String> files; - for(int i=0;i<p_drop.size();i++) { - String ext = p_drop[i].get_extension().to_lower(); - - if (ext=="wav") { - - files.push_back(p_drop[i]); - } - } - - if (files.size()) { - import_dialog(); - dialog->_choose_files(files); - dialog->_choose_save_dir(p_dest_path); - } -} - -void EditorSampleImportPlugin::reimport_multiple_files(const Vector<String>& p_list) { - - if (p_list.size()==0) - return; - - Vector<String> sources; - for(int i=0;i<p_list.size();i++) { - int idx; - EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->find_file(p_list[i],&idx); - if (efsd) { - for(int j=0;j<efsd->get_source_count(idx);j++) { - String file = expand_source_path(efsd->get_source_file(idx,j)); - if (sources.find(file)==-1) { - sources.push_back(file); - } - - } - } - } - - if (sources.size()) { - - dialog->popup_import(p_list[0]); - dialog->_choose_files(sources); - dialog->_choose_save_dir(p_list[0].get_base_dir()); - } -} - -bool EditorSampleImportPlugin::can_reimport_multiple_files() const { - - return true; -} - -EditorSampleImportPlugin::EditorSampleImportPlugin(EditorNode* p_editor) { - - singleton=this; - dialog = memnew( EditorSampleImportDialog(this)); - p_editor->get_gui_base()->add_child(dialog); -} - -Vector<uint8_t> EditorSampleExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) { - - - - if (EditorImportExport::get_singleton()->sample_get_action()==EditorImportExport::SAMPLE_ACTION_NONE || p_path.get_extension().to_lower()!="wav") { - - return Vector<uint8_t>(); - } - - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - - imd->add_source(EditorImportPlugin::validate_source_path(p_path)); - - imd->set_option("force/8_bit",false); - imd->set_option("force/mono",false); - imd->set_option("force/max_rate",true); - imd->set_option("force/max_rate_hz",EditorImportExport::get_singleton()->sample_get_max_hz()); - imd->set_option("edit/trim",EditorImportExport::get_singleton()->sample_get_trim()); - imd->set_option("edit/normalize",false); - imd->set_option("edit/loop",false); - imd->set_option("compress/mode",1); - - String savepath = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/smpconv.sample"); - Error err = EditorSampleImportPlugin::singleton->import(savepath,imd); - - - ERR_FAIL_COND_V(err!=OK,Vector<uint8_t>()); - - p_path=p_path.get_basename()+".converted.sample"; - return FileAccess::get_file_as_array(savepath); - -} - - - -EditorSampleExportPlugin::EditorSampleExportPlugin() { - -} - -#endif diff --git a/editor/io_plugins/editor_sample_import_plugin.h b/editor/io_plugins/editor_sample_import_plugin.h deleted file mode 100644 index 134868f8c2..0000000000 --- a/editor/io_plugins/editor_sample_import_plugin.h +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************/ -/* editor_sample_import_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_SAMPLE_IMPORT_PLUGIN_H -#define EDITOR_SAMPLE_IMPORT_PLUGIN_H - -#if 0 -#include "editor/editor_import_export.h" -#include "scene/resources/font.h" - -class EditorNode; -class EditorSampleImportDialog; - -class EditorSampleImportPlugin : public EditorImportPlugin { - - GDCLASS(EditorSampleImportPlugin,EditorImportPlugin); - - EditorSampleImportDialog *dialog; - void _compress_ima_adpcm(const Vector<float>& p_data,PoolVector<uint8_t>& dst_data); -public: - - static EditorSampleImportPlugin *singleton; - - 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); - 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; - - - EditorSampleImportPlugin(EditorNode* p_editor); -}; - -class EditorSampleExportPlugin : public EditorExportPlugin { - - GDCLASS( EditorSampleExportPlugin, EditorExportPlugin); - - -public: - - virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform); - - EditorSampleExportPlugin(); -}; - -#endif // EDITOR_SAMPLE_IMPORT_PLUGIN_H -#endif diff --git a/editor/io_plugins/editor_scene_import_plugin.cpp b/editor/io_plugins/editor_scene_import_plugin.cpp deleted file mode 100644 index a0a52621a0..0000000000 --- a/editor/io_plugins/editor_scene_import_plugin.cpp +++ /dev/null @@ -1,2986 +0,0 @@ -/*************************************************************************/ -/* editor_scene_import_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_scene_import_plugin.h" -#if 0 -#include "editor/create_dialog.h" -#include "editor/editor_node.h" -#include "io/resource_saver.h" -#include "os/file_access.h" -#include "os/os.h" -#include "project_settings.h" -#include "scene/3d/body_shape.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/navigation.h" -#include "scene/3d/path.h" -#include "scene/3d/physics_body.h" -#include "scene/3d/portal.h" -#include "scene/3d/room_instance.h" -#include "scene/3d/vehicle_body.h" -#include "scene/animation/animation_player.h" -#include "scene/resources/box_shape.h" -#include "scene/resources/packed_scene.h" -#include "scene/resources/sphere_shape.h" -#include <scene/resources/box_shape.h> -#include <scene/resources/plane_shape.h> -#include <scene/resources/ray_shape.h> - - - - -EditorSceneImporter::EditorSceneImporter() { - - -} - -void EditorScenePostImport::_bind_methods() { - - BIND_VMETHOD( MethodInfo("post_import",PropertyInfo(Variant::OBJECT,"scene")) ); - -} - -Node *EditorScenePostImport::post_import(Node* p_scene) { - - if (get_script_instance()) - return get_script_instance()->call("post_import",p_scene); - - return p_scene; -} - -EditorScenePostImport::EditorScenePostImport() { - - -} - - -///////////////////////////// - - -class EditorImportAnimationOptions : public VBoxContainer { - - GDCLASS( EditorImportAnimationOptions, VBoxContainer ); - - - - TreeItem *fps; - TreeItem* optimize_linear_error; - TreeItem* optimize_angular_error; - TreeItem* optimize_max_angle; - - TreeItem *clips_base; - - TextEdit *filters; - Vector<TreeItem*> clips; - - Tree *flags; - Tree *clips_tree; - Tree *optimization_tree; - Vector<TreeItem*> items; - - - bool updating; - bool validating; - - - - void _changed(); - void _item_edited(); - void _button_action(Object *p_obj,int p_col,int p_id); - -protected: - static void _bind_methods(); - void _notification(int p_what); - -public: - - void set_flags(uint32_t p_flags); - uint32_t get_flags() const; - - void set_fps(int p_fps); - int get_fps() const; - - void set_optimize_linear_error(float p_error); - float get_optimize_linear_error() const; - - void set_optimize_angular_error(float p_error); - float get_optimize_angular_error() const; - - void set_optimize_max_angle(float p_error); - float get_optimize_max_angle() const; - - void setup_clips(const Array& p_clips); - Array get_clips() const; - - void set_filter(const String& p_filter); - String get_filter() const; - - EditorImportAnimationOptions(); - - -}; - -//////////////////////////// - -class EditorSceneImportDialog : public ConfirmationDialog { - - GDCLASS(EditorSceneImportDialog,ConfirmationDialog); - - - struct FlagInfo { - int value; - const char *category; - const char *text; - bool defval; - }; - - static const FlagInfo scene_flag_names[]; - - EditorImportTextureOptions *texture_options; - EditorImportAnimationOptions *animation_options; - - EditorSceneImportPlugin *plugin; - - EditorNode *editor; - - LineEdit *import_path; - LineEdit *save_path; - LineEdit *script_path; - Tree *import_options; - EditorFileDialog *file_select; - EditorFileDialog *script_select; - EditorDirDialog *save_select; - OptionButton *texture_action; - CreateDialog *root_type_choose; - LineEdit *root_node_name; - - ConfirmationDialog *confirm_open; - - ConfirmationDialog *confirm_import; - RichTextLabel *missing_files; - - Vector<TreeItem*> scene_flags; - - Map<Ref<Mesh>,Ref<Shape> > collision_map; - ConfirmationDialog *error_dialog; - - Button *root_type; - CheckBox *root_default; - - - void _root_default_pressed(); - void _root_type_pressed(); - void _set_root_type(); - - void _choose_file(const String& p_path); - void _choose_save_file(const String& p_path); - void _choose_script(const String& p_path); - void _browse(); - void _browse_target(); - void _browse_script(); - void _import(bool p_and_open=false); - void _import_confirm(); - - Ref<ResourceImportMetadata> wip_rimd; - Node *wip_import; - String wip_save_file; - bool wip_blocked; - bool wip_open; - - void _dialog_hid(); - void _open_and_import(); - - -protected: - - void _notification(int p_what); - static void _bind_methods(); -public: - - void setup_popup(const String& p_from,const String& p_to_path) { - _choose_file(p_from); - _choose_save_file(p_to_path); - } - - Error import(const String& p_from, const String& p_to, const String& p_preset); - void popup_import(const String& p_from); - EditorSceneImportDialog(EditorNode *p_editor,EditorSceneImportPlugin *p_plugin); -}; - -/////////////////////////////////// - - -static const char *anim_flag_names[]={ - "Detect Loop (-loop,-cycle)", - "Keep Value Tracks", - "Optimize", - "Force All Tracks in All Clips", - NULL -}; - -static const char *anim_flag_descript[]={ - "Set loop flag for animation names that\ncontain 'cycle' or 'loop' in the name.", - "When merging an existing aimation,\nkeep the user-created value-tracks.", - "Remove redundant keyframes in\n transform tacks.", - "Some exporters will rely on default pose for some bones.\nThis forces those bones to have at least one animation key.", - NULL -}; - - - -void EditorImportAnimationOptions::set_flags(uint32_t p_flags){ - - updating=true; - for(int i=0;i<items.size();i++) { - - items[i]->set_checked(0,p_flags&(1<<i)); - } - updating=false; - -} -uint32_t EditorImportAnimationOptions::get_flags() const{ - - uint32_t f=0; - for(int i=0;i<items.size();i++) { - - if (items[i]->is_checked(0)) - f|=(1<<i); - } - - return f; -} - - -void EditorImportAnimationOptions::_changed() { - - if (updating) - return; - emit_signal("changed"); -} - - -void EditorImportAnimationOptions::_button_action(Object *p_obj,int p_col,int p_id) { - - memdelete(p_obj); - -} - - -void EditorImportAnimationOptions::_item_edited() { - - if (validating) - return; - - if (clips.size()==0) - return; - validating=true; - print_line("edited"); - TreeItem *item = clips_tree->get_edited(); - if (item==clips[clips.size()-1]) { - //add new - print_line("islast"); - if (item->get_text(0).find("<")!=-1 || item->get_text(0).find(">")!=-1) { - validating=false; - return; //fuckit - } - - item->set_editable(1,true); - item->set_editable(2,true); - item->add_button(0,EditorNode::get_singleton()->get_gui_base()->get_icon("Del","EditorIcons")); - item->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); - item->set_range_config(1,0,3600,0.01); - item->set_range(1,0); - item->set_editable(1,true); - item->set_cell_mode(2,TreeItem::CELL_MODE_RANGE); - item->set_range_config(2,0,3600,0.01); - item->set_range(2,0); - item->set_cell_mode(3,TreeItem::CELL_MODE_CHECK); - item->set_editable(3,true); - - TreeItem *newclip = clips_tree->create_item(clips_base); - newclip->set_text(0,"<new clip>"); - newclip->set_editable(0,true); - newclip->set_editable(1,false); - newclip->set_editable(2,false); - clips.push_back(newclip); - - - - } - - - //make name unique JUST IN CASE - String name = item->get_text(0); - name=name.replace("/","_").replace(":","_").strip_edges(); - if (name=="") - name=TTR("New Clip"); - - if (clips.size()>2) { - int index=1; - while(true) { - bool valid = true; - String try_name=name; - if (index>1) - try_name+=" "+itos(index); - - for(int i=0;i<clips.size()-1;i++) { - - if (clips[i]==item) - continue; - if (clips[i]->get_text(0)==try_name) { - index++; - valid=false; - break; - } - } - - if (valid) { - name=try_name; - break; - } - - } - } - - if (item->get_text(0)!=name) - item->set_text(0,name); - - validating=false; - -} - -void EditorImportAnimationOptions::_bind_methods() { - - ClassDB::bind_method("_changed",&EditorImportAnimationOptions::_changed); - ClassDB::bind_method("_item_edited",&EditorImportAnimationOptions::_item_edited); - ClassDB::bind_method("_button_action",&EditorImportAnimationOptions::_button_action); - //ClassDB::bind_method("_changedp",&EditorImportAnimationOptions::_changedp); - - ADD_SIGNAL(MethodInfo("changed")); -} - - -void EditorImportAnimationOptions::_notification(int p_what) { - - if (p_what==NOTIFICATION_ENTER_TREE) { - - flags->connect("item_edited",this,"_changed"); - clips_tree->connect("item_edited",this,"_item_edited"); - clips_tree->connect("button_pressed",this,"_button_action",varray(),CONNECT_DEFERRED); - //format->connect("item_selected",this,"_changedp"); - } -} - - -Array EditorImportAnimationOptions::get_clips() const { - - Array arr; - for(int i=0;i<clips.size()-1;i++) { - - arr.push_back(clips[i]->get_text(0)); - arr.push_back(clips[i]->get_range(1)); - arr.push_back(clips[i]->get_range(2)); - arr.push_back(clips[i]->is_checked(3)); - } - - return arr; -} - - -void EditorImportAnimationOptions::setup_clips(const Array& p_clips) { - - ERR_FAIL_COND(p_clips.size()%4!=0); - for(int i=0;i<clips.size();i++) { - - memdelete(clips[i]); - } - - - clips.clear(); - - for(int i=0;i<p_clips.size();i+=4) { - - TreeItem *clip = clips_tree->create_item(clips_base); - clip->set_text(0,p_clips[i]); - clip->add_button(0,EditorNode::get_singleton()->get_gui_base()->get_icon("Del","EditorIcons")); - clip->set_editable(0,true); - clip->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); - clip->set_range_config(1,0,3600,0.01); - clip->set_range(1,p_clips[i+1]); - clip->set_editable(1,true); - clip->set_cell_mode(2,TreeItem::CELL_MODE_RANGE); - clip->set_range_config(2,0,3600,0.01); - clip->set_range(2,p_clips[i+2]); - clip->set_editable(2,true); - clip->set_cell_mode(3,TreeItem::CELL_MODE_CHECK); - clip->set_editable(3,true); - clip->set_checked(3,p_clips[i+3]); - clips.push_back(clip); - - } - - TreeItem *newclip = clips_tree->create_item(clips_base); - newclip->set_text(0,"<new clip>"); - newclip->set_editable(0,true); - newclip->set_editable(1,false); - newclip->set_editable(2,false); - newclip->set_editable(3,false); - clips.push_back(newclip); - -} - - -EditorImportAnimationOptions::EditorImportAnimationOptions() { - - - updating=false; - validating=false; - - TabContainer *tab= memnew(TabContainer); - add_margin_child(TTR("Animation Options"),tab,true); - - flags = memnew( Tree ); - flags->set_hide_root(true); - tab->add_child(flags); - flags->set_name(TTR("Flags")); - TreeItem *root = flags->create_item(); - - const char ** fname=anim_flag_names; - const char ** fdescr=anim_flag_descript; - - while( *fname ) { - - TreeItem*ti = flags->create_item(root); - ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); - ti->set_text(0,*fname); - ti->set_editable(0,true); - ti->set_tooltip(0,*fdescr); - items.push_back(ti); - fname++; - fdescr++; - } - - - TreeItem *fps_base = flags->create_item(root); - fps_base->set_text(0,TTR("Bake FPS:")); - fps_base->set_editable(0,false); - fps = flags->create_item(fps_base); - fps->set_cell_mode(0,TreeItem::CELL_MODE_RANGE); - fps->set_editable(0,true); - fps->set_range_config(0,1,120,1); - fps->set_range(0,15); - - optimization_tree = memnew( Tree ); - optimization_tree->set_columns(2); - tab->add_child(optimization_tree); - optimization_tree->set_name(TTR("Optimizer")); - optimization_tree->set_column_expand(0,true); - optimization_tree->set_column_expand(1,false); - optimization_tree->set_column_min_width(1,80); - optimization_tree->set_hide_root(true); - - - TreeItem *optimize_root = optimization_tree->create_item(); - - optimize_linear_error = optimization_tree->create_item(optimize_root); - optimize_linear_error->set_text(0,TTR("Max Linear Error")); - optimize_linear_error->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); - optimize_linear_error->set_editable(1,true); - optimize_linear_error->set_range_config(1,0,1,0.001); - optimize_linear_error->set_range(1,0.05); - - optimize_angular_error = optimization_tree->create_item(optimize_root); - optimize_angular_error->set_text(0,TTR("Max Angular Error")); - optimize_angular_error->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); - optimize_angular_error->set_editable(1,true); - optimize_angular_error->set_range_config(1,0,1,0.001); - optimize_angular_error->set_range(1,0.01); - - optimize_max_angle = optimization_tree->create_item(optimize_root); - optimize_max_angle->set_text(0,TTR("Max Angle")); - optimize_max_angle->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); - optimize_max_angle->set_editable(1,true); - optimize_max_angle->set_range_config(1,0,360,0.001); - optimize_max_angle->set_range(1,int(180*0.125)); - - clips_tree = memnew( Tree ); - clips_tree->set_hide_root(true); - tab->add_child(clips_tree); - clips_tree->set_name(TTR("Clips")); - - clips_tree->set_columns(4); - clips_tree->set_column_expand(0,1); - clips_tree->set_column_expand(1,0); - clips_tree->set_column_expand(2,0); - clips_tree->set_column_expand(3,0); - clips_tree->set_column_min_width(1,60); - clips_tree->set_column_min_width(2,60); - clips_tree->set_column_min_width(3,40); - clips_tree->set_column_titles_visible(true); - clips_tree->set_column_title(0,TTR("Name")); - clips_tree->set_column_title(1,TTR("Start(s)")); - clips_tree->set_column_title(2,TTR("End(s)")); - clips_tree->set_column_title(3,TTR("Loop")); - clips_base =clips_tree->create_item(0); - - - setup_clips(Array()); - - - filters = memnew( TextEdit ); - tab->add_child(filters); - filters->set_name(TTR("Filters")); -} - - - -void EditorImportAnimationOptions::set_fps(int p_fps) { - - fps->set_range(0,p_fps); -} - -int EditorImportAnimationOptions::get_fps() const { - - return fps->get_range(0); -} - - -void EditorImportAnimationOptions::set_optimize_linear_error(float p_optimize_linear_error) { - - optimize_linear_error->set_range(1,p_optimize_linear_error); -} - -float EditorImportAnimationOptions::get_optimize_linear_error() const { - - return optimize_linear_error->get_range(1); -} - -void EditorImportAnimationOptions::set_optimize_angular_error(float p_optimize_angular_error) { - - optimize_angular_error->set_range(1,p_optimize_angular_error); -} - -float EditorImportAnimationOptions::get_optimize_angular_error() const { - - return optimize_angular_error->get_range(1); -} - -void EditorImportAnimationOptions::set_optimize_max_angle(float p_optimize_max_angle) { - - optimize_max_angle->set_range(1,p_optimize_max_angle); -} - -float EditorImportAnimationOptions::get_optimize_max_angle() const { - - return optimize_max_angle->get_range(1); -} - - -void EditorImportAnimationOptions::set_filter(const String& p_filter) { - - filters->set_text(p_filter); -} - -String EditorImportAnimationOptions::get_filter() const { - - return filters->get_text(); -} - - - - - -//////////////////////////////////////////////////////// - - - -void EditorSceneImportDialog::_choose_file(const String& p_path) { -#if 0 - StringName sn = EditorImportDB::get_singleton()->find_source_path(p_path); - if (sn!=StringName()) { - - EditorImportDB::ImportScene isc; - if (EditorImportDB::get_singleton()->get_scene(sn,isc)==OK) { - - save_path->set_text(String(sn).get_base_dir()); - texture_options->set_flags( isc.image_flags ); - texture_options->set_quality( isc.image_quality ); - texture_options->set_format( isc.image_format ); - animation_options->set_flags( isc.anim_flags ); - script_path->set_text( isc.import_script ); - uint32_t f = isc.flags; - for(int i=0;i<scene_flags.size();i++) { - - scene_flags[i]->set_checked(0,f&(1<<i)); - } - } - } else { -#endif - save_path->set_text(""); - root_node_name->set_text(""); - //save_path->set_text(p_path.get_file().basename()+".scn"); -#if 0 - } -#endif - - if (p_path!=String()) { - - String from_path = EditorFileSystem::get_singleton()->find_resource_from_source(EditorImportPlugin::validate_source_path(p_path)); - print_line("from path.."+from_path); - if (from_path!=String()) { - popup_import(from_path); - - } - } - - - import_path->set_text(p_path); - if (root_node_name->get_text().size()==0){ - root_node_name->set_text(import_path->get_text().get_file().get_basename()); - } - -} -void EditorSceneImportDialog::_choose_save_file(const String& p_path) { - - save_path->set_text(p_path); -} - -void EditorSceneImportDialog::_choose_script(const String& p_path) { - - String p = ProjectSettings::get_singleton()->localize_path(p_path); - if (!p.is_resource_file()) - p=ProjectSettings::get_singleton()->get_resource_path().path_to(p_path.get_base_dir())+p_path.get_file(); - script_path->set_text(p); - -} - - -void EditorSceneImportDialog::_open_and_import() { - - bool unsaved=EditorNode::has_unsaved_changes(); - - if (unsaved) { - - confirm_open->popup_centered_minsize(Size2(300,80)*EDSCALE); - } else { - _import(true); - } -} - -void EditorSceneImportDialog::_import(bool p_and_open) { - - wip_open=p_and_open; -//' ImportMonitorBlock imb; - - - if (import_path->get_text().strip_edges()=="") { - error_dialog->set_text(TTR("Source path is empty.")); - error_dialog->popup_centered_minsize(); - return; - } - - if (save_path->get_text().strip_edges()=="") { - error_dialog->set_text(TTR("Target path is empty.")); - error_dialog->popup_centered_minsize(); - return; - } - - if (!save_path->get_text().begins_with("res://")) { - error_dialog->set_text(TTR("Target path must be a complete resource path.")); - error_dialog->popup_centered_minsize(); - return; - } - - if (!DirAccess::exists(save_path->get_text())) { - error_dialog->set_text(TTR("Target path must exist.")); - error_dialog->popup_centered_minsize(); - return; - } - - String dst_path; - - if (texture_action->get_selected()==0) - dst_path=save_path->get_text();//.get_base_dir(); - else - dst_path=ProjectSettings::get_singleton()->get("import/shared_textures"); - - uint32_t flags=0; - - for(int i=0;i<scene_flags.size();i++) { - - if (scene_flags[i]->is_checked(0)) { - int md = scene_flags[i]->get_metadata(0); - flags|=md; - } - } - - - - - - if (script_path->get_text()!="") { - Ref<Script> scr = ResourceLoader::load(script_path->get_text()); - if (!scr.is_valid()) { - error_dialog->set_text(TTR("Couldn't load post-import script.")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - } - - Ref<EditorScenePostImport> pi = Ref<EditorScenePostImport>( memnew( EditorScenePostImport ) ); - pi->set_script(scr.get_ref_ptr()); - if (!pi->get_script_instance()) { - - error_dialog->set_text(TTR("Invalid/broken script for post-import.")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - } - - } - - - // Scenes should always be imported as binary format since vertex data is large and would take - // up a lot of space and time to load if imported as text format (GH-5778) - String save_file = save_path->get_text().plus_file(import_path->get_text().get_file().get_basename()+".scn"); - print_line("Saving to: "+save_file); - - - - - - Node *scene=NULL; - - - Ref<ResourceImportMetadata> rim = memnew( ResourceImportMetadata ); - - rim->add_source(EditorImportPlugin::validate_source_path(import_path->get_text())); - rim->set_option("flags",flags); - print_line("GET FLAGS: "+itos(texture_options->get_flags())); - rim->set_option("texture_flags",texture_options->get_flags()); - rim->set_option("texture_format",texture_options->get_format()); - rim->set_option("texture_quality",texture_options->get_quality()); - rim->set_option("animation_flags",animation_options->get_flags()); - rim->set_option("animation_bake_fps",animation_options->get_fps()); - rim->set_option("animation_optimizer_linear_error",animation_options->get_optimize_linear_error()); - rim->set_option("animation_optimizer_angular_error",animation_options->get_optimize_angular_error()); - rim->set_option("animation_optimizer_max_angle",animation_options->get_optimize_max_angle()); - rim->set_option("animation_filters",animation_options->get_filter()); - rim->set_option("animation_clips",animation_options->get_clips()); - rim->set_option("post_import_script",script_path->get_text()); - rim->set_option("reimport",true); - if (!root_default->is_pressed()) { - rim->set_option("root_type",root_type->get_text()); - } - if (root_node_name->get_text().size()==0) { - root_node_name->set_text(import_path->get_text().get_file().get_basename()); - } - rim->set_option("root_name",root_node_name->get_text()); - - List<String> missing; - Error err = plugin->import1(rim,&scene,&missing); - - if (err || !scene) { - - error_dialog->set_text(TTR("Error importing scene.")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - } - - if (missing.size()) { - - missing_files->clear(); - for(List<String>::Element *E=missing.front();E;E=E->next()) { - - missing_files->add_text(E->get()); - missing_files->add_newline(); - } - wip_import=scene; - wip_rimd=rim; - wip_save_file=save_file; - confirm_import->popup_centered_ratio(); - return; - - } else { - - err = plugin->import2(scene,save_file,rim); - - if (err) { - - error_dialog->set_text(TTR("Error importing scene.")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - } - if (wip_open) - EditorNode::get_singleton()->load_scene(save_file,false,false,false); - - } - - hide(); - - /* - editor->clear_scene(); - - Error err = EditorImport::import_scene(import_path->get_text(),save_file,dst_path,flags,texture_options->get_format(),compression,texture_options->get_flags(),texture_options->get_quality(),animation_options->get_flags(), &scene,pi); - - if (err) { - - error_dialog->set_text("Error importing scene."); - error_dialog->popup_centered(Size2(200,100)); - return; - } - - editor->save_import_export(); - if (scene) - editor->set_edited_scene(scene); - - hide(); - */ -}; - - -void EditorSceneImportDialog::_import_confirm() { - - wip_blocked=true; - print_line("import confirm!"); - Error err = plugin->import2(wip_import,wip_save_file,wip_rimd); - wip_blocked=false; - wip_import=NULL; - wip_rimd=Ref<ResourceImportMetadata>(); - confirm_import->hide(); - if (err) { - - wip_save_file=""; - error_dialog->set_text(TTR("Error importing scene.")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - } - - if (wip_open) - EditorNode::get_singleton()->load_scene(wip_save_file,false,false,false); - wip_open=false; - wip_save_file=""; - - hide(); - -} - - -void EditorSceneImportDialog::_browse() { - - file_select->popup_centered_ratio(); -} - -void EditorSceneImportDialog::_browse_target() { - - save_select->popup_centered_ratio(); - if (save_path->get_text()!="") - save_select->set_current_path(save_path->get_text()); - -} - -void EditorSceneImportDialog::_browse_script() { - - script_select->popup_centered_ratio(); - -} - -void EditorSceneImportDialog::popup_import(const String &p_from) { - - popup_centered(Size2(750,550)*EDSCALE); - if (p_from!="") { - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_from); - if (rimd.is_null()) - return; - - int flags = rimd->get_option("flags"); - - for(int i=0;i<scene_flags.size();i++) { - - int md = scene_flags[i]->get_metadata(0); - scene_flags[i]->set_checked(0,flags&md); - } - - texture_options->set_flags(rimd->get_option("texture_flags")); - texture_options->set_format(EditorTextureImportPlugin::ImageFormat(int(rimd->get_option("texture_format")))); - texture_options->set_quality(rimd->get_option("texture_quality")); - animation_options->set_flags(rimd->get_option("animation_flags")); - if (rimd->has_option("animation_clips")) - animation_options->setup_clips(rimd->get_option("animation_clips")); - if (rimd->has_option("animation_filters")) - animation_options->set_filter(rimd->get_option("animation_filters")); - if (rimd->has_option("animation_bake_fps")) - animation_options->set_fps(rimd->get_option("animation_bake_fps")); - if (rimd->has_option("animation_optimizer_linear_error")) - animation_options->set_optimize_linear_error(rimd->get_option("animation_optimizer_linear_error")); - if (rimd->has_option("animation_optimizer_angular_error")) - animation_options->set_optimize_angular_error(rimd->get_option("animation_optimizer_angular_error")); - if (rimd->has_option("animation_optimizer_max_angle")) - animation_options->set_optimize_max_angle(rimd->get_option("animation_optimizer_max_angle")); - - if (rimd->has_option("root_type")) { - root_default->set_pressed(false); - String type = rimd->get_option("root_type"); - root_type->set_text(type); - root_type->set_disabled(false); - - if (has_icon(type,"EditorIcons")) { - root_type->set_icon(get_icon(type,"EditorIcons")); - } else { - root_type->set_icon(get_icon("Object","EditorIcons")); - } - - } else { - root_default->set_pressed(true); - root_type->set_disabled(true); - } - if (rimd->has_option("root_name")) { - root_node_name->set_text(rimd->get_option("root_name")); - } else { - root_node_name->set_text(root_type->get_text()); // backward compatibility for 2.1 or before - } - script_path->set_text(rimd->get_option("post_import_script")); - - save_path->set_text(p_from.get_base_dir()); - import_path->set_text(EditorImportPlugin::expand_source_path(rimd->get_source_path(0))); - - } -} - - -void EditorSceneImportDialog::_notification(int p_what) { - - - if (p_what==NOTIFICATION_ENTER_TREE) { - - - List<String> extensions; - file_select->clear_filters(); - root_type->set_icon(get_icon("Spatial","EditorIcons")); - root_type->set_text("Spatial"); - root_type->set_disabled(true); - - for(int i=0;i<plugin->get_importers().size();i++) { - plugin->get_importers()[i]->get_extensions(&extensions); - } - - - for(int i=0;i<extensions.size();i++) { - - file_select->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper()); - } - - extensions.clear(); - - //EditorImport::get_import_extensions(&extensions) - /* ResourceLoader::get_recognized_extensions_for_type("PackedScene",&extensions); - save_select->clear_filters(); - for(int i=0;i<extensions.size();i++) { - - save_select->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper()); - }*/ - - - } -} - -Error EditorSceneImportDialog::import(const String& p_from, const String& p_to, const String& p_preset) { - - import_path->set_text(p_from); - save_path->set_text(p_to); - script_path->set_text(p_preset); - - _import(); - - - - return OK; -} - -void EditorSceneImportDialog::_dialog_hid() { - - if (wip_blocked) - return; - print_line("DIALOGHID!"); - if (wip_import) { - memdelete(wip_import); - wip_import=NULL; - wip_save_file=""; - wip_rimd=Ref<ResourceImportMetadata>(); - } -} -void EditorSceneImportDialog::_root_default_pressed() { - - root_type->set_disabled(root_default->is_pressed()); -} - -void EditorSceneImportDialog::_root_type_pressed() { - - - root_type_choose->popup(false); -} - - -void EditorSceneImportDialog::_set_root_type() { - - String type = root_type_choose->get_selected_type(); - if (type==String()) - return; - root_type->set_text(type); - if (has_icon(type,"EditorIcons")) { - root_type->set_icon(get_icon(type,"EditorIcons")); - } else { - root_type->set_icon(get_icon("Object","EditorIcons")); - } -} - -void EditorSceneImportDialog::_bind_methods() { - - - ClassDB::bind_method("_choose_file",&EditorSceneImportDialog::_choose_file); - ClassDB::bind_method("_choose_save_file",&EditorSceneImportDialog::_choose_save_file); - ClassDB::bind_method("_choose_script",&EditorSceneImportDialog::_choose_script); - ClassDB::bind_method("_import",&EditorSceneImportDialog::_import,DEFVAL(false)); - ClassDB::bind_method("_browse",&EditorSceneImportDialog::_browse); - ClassDB::bind_method("_browse_target",&EditorSceneImportDialog::_browse_target); - ClassDB::bind_method("_browse_script",&EditorSceneImportDialog::_browse_script); - ClassDB::bind_method("_dialog_hid",&EditorSceneImportDialog::_dialog_hid); - ClassDB::bind_method("_import_confirm",&EditorSceneImportDialog::_import_confirm); - ClassDB::bind_method("_open_and_import",&EditorSceneImportDialog::_open_and_import); - ClassDB::bind_method("_root_default_pressed",&EditorSceneImportDialog::_root_default_pressed); - ClassDB::bind_method("_root_type_pressed",&EditorSceneImportDialog::_root_type_pressed); - ClassDB::bind_method("_set_root_type",&EditorSceneImportDialog::_set_root_type); - - - ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) ); -} - - - -const EditorSceneImportDialog::FlagInfo EditorSceneImportDialog::scene_flag_names[]={ - - {EditorSceneImportPlugin::SCENE_FLAG_REMOVE_NOIMP,("Actions"),"Remove Nodes (-noimp)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_IMPORT_ANIMATIONS,("Actions"),"Import Animations",true}, - {EditorSceneImportPlugin::SCENE_FLAG_COMPRESS_GEOMETRY,("Actions"),"Compress Geometry",false}, - {EditorSceneImportPlugin::SCENE_FLAG_GENERATE_TANGENT_ARRAYS,("Actions"),"Force Generation of Tangent Arrays",false}, - {EditorSceneImportPlugin::SCENE_FLAG_LINEARIZE_DIFFUSE_TEXTURES,("Actions"),"SRGB->Linear Of Diffuse Textures",false}, - {EditorSceneImportPlugin::SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY,("Actions"),"Convert Normal Maps to XY",true}, - {EditorSceneImportPlugin::SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS,("Actions"),"Set Material Lightmap to UV2 if Tex2Array Exists",true}, - {EditorSceneImportPlugin::SCENE_FLAG_MERGE_KEEP_MATERIALS,("Merge"),"Keep Materials after first import (delete them for re-import).",true}, - {EditorSceneImportPlugin::SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,("Merge"),"Keep user-added Animation tracks.",true}, - {EditorSceneImportPlugin::SCENE_FLAG_DETECT_ALPHA,("Materials"),"Set Alpha in Materials (-alpha)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_DETECT_VCOLOR,("Materials"),"Set Vert. Color in Materials (-vcol)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_COLLISIONS,("Create"),"Create Collisions and/or Rigid Bodies (-col,-colonly,-rigid,-rigidonly)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_PORTALS,("Create"),"Create Portals (-portal)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_ROOMS,("Create"),"Create Rooms (-room)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_SIMPLIFY_ROOMS,("Create"),"Simplify Rooms",false}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_BILLBOARDS,("Create"),"Create Billboards (-bb)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_IMPOSTORS,("Create"),"Create Impostors (-imp:dist)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_LODS,("Create"),"Create LODs (-lod:dist)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_CARS,("Create"),"Create Vehicles (-vehicle)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_WHEELS,("Create"),"Create Vehicle Wheels (-wheel)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_CREATE_NAVMESH,("Create"),"Create Navigation Meshes (-navmesh)",true}, - {EditorSceneImportPlugin::SCENE_FLAG_DETECT_LIGHTMAP_LAYER,("Create"),"Detect LightMap Layer (-lm:<int>).",true}, - {-1,NULL,NULL,false} -}; - - -EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSceneImportPlugin *p_plugin) { - - - editor=p_editor; - plugin=p_plugin; - - set_title(TTR("Import 3D Scene")); - HBoxContainer *import_hb = memnew( HBoxContainer ); - add_child(import_hb); - //set_child_rect(import_hb); - - VBoxContainer *vbc = memnew( VBoxContainer ); - import_hb->add_child(vbc); - vbc->set_h_size_flags(SIZE_EXPAND_FILL); - - HBoxContainer *hbc = memnew( HBoxContainer ); - vbc->add_margin_child(TTR("Source Scene:"),hbc); - - import_path = memnew( LineEdit ); - import_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(import_path); - - Button * import_choose = memnew( Button ); - import_choose->set_text(" .. "); - hbc->add_child(import_choose); - - import_choose->connect("pressed", this,"_browse"); - - hbc = memnew( HBoxContainer ); - vbc->add_margin_child(TTR("Target Path:"),hbc); - - save_path = memnew( LineEdit ); - save_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(save_path); - - Button * save_choose = memnew( Button ); - save_choose->set_text(" .. "); - hbc->add_child(save_choose); - - save_choose->connect("pressed", this,"_browse_target"); - - texture_action = memnew( OptionButton ); - texture_action->add_item(TTR("Same as Target Scene")); - texture_action->add_item(TTR("Shared")); - texture_action->select(0); - vbc->add_margin_child(TTR("Target Texture Folder:"),texture_action); - - import_options = memnew( Tree ); - vbc->set_v_size_flags(SIZE_EXPAND_FILL); - vbc->add_margin_child(TTR("Options:"),import_options,true); - - file_select = memnew(EditorFileDialog); - file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - add_child(file_select); - - - file_select->set_mode(EditorFileDialog::MODE_OPEN_FILE); - - file_select->connect("file_selected", this,"_choose_file"); - - save_select = memnew(EditorDirDialog); - add_child(save_select); - - //save_select->set_mode(EditorFileDialog::MODE_SAVE_FILE); - save_select->connect("dir_selected", this,"_choose_save_file"); - - get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text(TTR("Import")); - - TreeItem *root = import_options->create_item(NULL); - import_options->set_hide_root(true); - - const FlagInfo* fn=scene_flag_names; - - Map<String,TreeItem*> categories; - - while(fn->text) { - - String cat = fn->category; - TreeItem *parent; - if (!categories.has(cat)) { - parent = import_options->create_item(root); - parent->set_text(0,cat); - categories[cat]=parent; - } else { - parent=categories[cat]; - } - - TreeItem *opt = import_options->create_item(parent); - opt->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); - opt->set_checked(0,fn->defval); - opt->set_editable(0,true); - opt->set_text(0,fn->text); - opt->set_metadata(0,fn->value); - - scene_flags.push_back(opt); - fn++; - } - - hbc = memnew( HBoxContainer ); - vbc->add_margin_child(TTR("Post-Process Script:"),hbc); - - script_path = memnew( LineEdit ); - script_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(script_path); - - Button * script_choose = memnew( Button ); - script_choose->set_text(" .. "); - hbc->add_child(script_choose); - - script_choose->connect("pressed", this,"_browse_script"); - - script_select = memnew(EditorFileDialog); - add_child(script_select); - for(int i=0;i<ScriptServer::get_language_count();i++) { - - ScriptLanguage *sl=ScriptServer::get_language(i); - String ext = sl->get_extension(); - if (ext=="") - continue; - script_select->add_filter("*."+ext+" ; "+sl->get_name()); - } - - - script_select->set_mode(EditorFileDialog::MODE_OPEN_FILE); - - script_select->connect("file_selected", this,"_choose_script"); - - error_dialog = memnew ( ConfirmationDialog ); - add_child(error_dialog); - error_dialog->get_ok()->set_text(TTR("Accept")); - //error_dialog->get_cancel()->hide(); - - - HBoxContainer *custom_root_hb = memnew( HBoxContainer ); - vbc->add_margin_child(TTR("Custom Root Node Type:"),custom_root_hb); - root_type = memnew(Button); - root_type->set_h_size_flags(SIZE_EXPAND_FILL); - root_type->set_text_align(Button::ALIGN_LEFT); - root_type->connect("pressed",this,"_root_type_pressed"); - custom_root_hb->add_child(root_type); - - root_default = memnew(CheckBox); - root_default->set_text(TTR("Auto")); - root_default->set_pressed(true); - root_default->connect("pressed",this,"_root_default_pressed"); - custom_root_hb->add_child(root_default); - - root_node_name = memnew( LineEdit ); - root_node_name->set_h_size_flags(SIZE_EXPAND_FILL); - vbc->add_margin_child(TTR("Root Node Name:"),root_node_name); - /* - this_import = memnew( OptionButton ); - this_import->add_item("Overwrite Existing Scene"); - this_import->add_item("Overwrite Existing, Keep Materials"); - this_import->add_item("Keep Existing, Merge with New"); - this_import->add_item("Keep Existing, Ignore New"); - vbc->add_margin_child("This Time:",this_import); - - next_import = memnew( OptionButton ); - next_import->add_item("Overwrite Existing Scene"); - next_import->add_item("Overwrite Existing, Keep Materials"); - next_import->add_item("Keep Existing, Merge with New"); - next_import->add_item("Keep Existing, Ignore New"); - vbc->add_margin_child("Next Time:",next_import); -*/ - set_hide_on_ok(false); - - GLOBAL_DEF("import/shared_textures","res://"); - ProjectSettings::get_singleton()->set_custom_property_info("import/shared_textures",PropertyInfo(Variant::STRING,"import/shared_textures",PROPERTY_HINT_DIR)); - - import_hb->add_constant_override("separation",30); - - - VBoxContainer *ovb = memnew( VBoxContainer); - ovb->set_h_size_flags(SIZE_EXPAND_FILL); - import_hb->add_child(ovb); - - texture_options = memnew( EditorImportTextureOptions ); - ovb->add_child(texture_options); - texture_options->set_v_size_flags(SIZE_EXPAND_FILL); - //animation_options->set_flags(EditorImport:: - texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM); - texture_options->set_flags( EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA | EditorTextureImportPlugin::IMAGE_FLAG_REPEAT | EditorTextureImportPlugin::IMAGE_FLAG_FILTER ); - - - animation_options = memnew( EditorImportAnimationOptions ); - ovb->add_child(animation_options); - animation_options->set_v_size_flags(SIZE_EXPAND_FILL); - animation_options->set_flags(EditorSceneAnimationImportPlugin::ANIMATION_DETECT_LOOP|EditorSceneAnimationImportPlugin::ANIMATION_KEEP_VALUE_TRACKS|EditorSceneAnimationImportPlugin::ANIMATION_OPTIMIZE|EditorSceneAnimationImportPlugin::ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS); - - - confirm_import = memnew( ConfirmationDialog ); - add_child(confirm_import); - VBoxContainer *cvb = memnew( VBoxContainer ); - confirm_import->add_child(cvb); - //confirm_import->set_child_rect(cvb); - - PanelContainer *pc = memnew( PanelContainer ); - pc->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("normal","TextEdit")); - //ec->add_child(pc); - missing_files = memnew( RichTextLabel ); - cvb->add_margin_child(TTR("The Following Files are Missing:"),pc,true); - pc->add_child(missing_files); - confirm_import->get_ok()->set_text(TTR("Import Anyway")); - confirm_import->get_cancel()->set_text(TTR("Cancel")); - confirm_import->connect("popup_hide",this,"_dialog_hid"); - confirm_import->connect("confirmed",this,"_import_confirm"); - confirm_import->set_hide_on_ok(false); - - add_button(TTR("Import & Open"),!OS::get_singleton()->get_swap_ok_cancel())->connect("pressed",this,"_open_and_import"); - - confirm_open = memnew( ConfirmationDialog ); - add_child(confirm_open); - confirm_open->set_text(TTR("Edited scene has not been saved, open imported scene anyway?")); - confirm_open->connect("confirmed",this,"_import",varray(true)); - - - wip_import=NULL; - wip_blocked=false; - wip_open=false; - //texture_options->set_format(EditorImport::IMAGE_FORMAT_C); - - root_type_choose = memnew( CreateDialog ); - add_child(root_type_choose); - root_type_choose->set_base_type("Node"); - root_type_choose->connect("create",this,"_set_root_type"); -} - - - -//////////////////////////////// - - - -String EditorSceneImportPlugin::get_name() const { - - return "scene_3d"; -} - -String EditorSceneImportPlugin::get_visible_name() const{ - - return TTR("Scene"); -} - -void EditorSceneImportPlugin::import_dialog(const String& p_from){ - - dialog->popup_import(p_from); -} - - -////////////////////////// - - -static bool _teststr(const String& p_what,const String& p_str) { - - if (p_what.findn("$"+p_str)!=-1) //blender and other stuff - return true; - if (p_what.to_lower().ends_with("-"+p_str)) //collada only supports "_" and "-" besides letters - return true; - if (p_what.to_lower().ends_with("_"+p_str)) //collada only supports "_" and "-" besides letters - return true; - return false; -} - -static String _fixstr(const String& p_what,const String& p_str) { - - if (p_what.findn("$"+p_str)!=-1) //blender and other stuff - return p_what.replace("$"+p_str,""); - if (p_what.to_lower().ends_with("-"+p_str)) //collada only supports "_" and "-" besides letters - return p_what.substr(0,p_what.length()-(p_str.length()+1)); - if (p_what.to_lower().ends_with("_"+p_str)) //collada only supports "_" and "-" besides letters - return p_what.substr(0,p_what.length()-(p_str.length()+1)); - return p_what; -} - - - -void EditorSceneImportPlugin::_find_resources(const Variant& p_var, Map<Ref<ImageTexture>, TextureRole> &image_map,int p_flags) { - - - switch(p_var.get_type()) { - - case Variant::OBJECT: { - - Ref<Resource> res = p_var; - if (res.is_valid()) { - - if (res->is_class("Texture") && !image_map.has(res)) { - - image_map.insert(res,TEXTURE_ROLE_DEFAULT); - - - } else { - - - List<PropertyInfo> pl; - res->get_property_list(&pl); - for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { - - if (E->get().type==Variant::OBJECT || E->get().type==Variant::ARRAY || E->get().type==Variant::DICTIONARY) { - if (E->get().type==Variant::OBJECT && Object::cast_to<SpatialMaterial>(*res) && (E->get().name=="textures/diffuse" || E->get().name=="textures/detail" || E->get().name=="textures/emission")) { - - Ref<ImageTexture> tex =res->get(E->get().name); - if (tex.is_valid()) { - - image_map.insert(tex,TEXTURE_ROLE_DIFFUSE); - } - - } else if (E->get().type==Variant::OBJECT && Object::cast_to<SpatialMaterial>(*res) && (E->get().name=="textures/normal")) { - - Ref<ImageTexture> tex =res->get(E->get().name); - if (tex.is_valid()) { - - image_map.insert(tex,TEXTURE_ROLE_NORMALMAP); - /* - if (p_flags&SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY) - Object::cast_to<SpatialMaterial>(*res)->set_fixed_flag(SpatialMaterial::FLAG_USE_XY_NORMALMAP,true); - */ - } - - - } else { - _find_resources(res->get(E->get().name),image_map,p_flags); - } - } - } - - } - } - - } break; - case Variant::DICTIONARY: { - - Dictionary d= p_var; - - List<Variant> keys; - d.get_key_list(&keys); - - for(List<Variant>::Element *E=keys.front();E;E=E->next()) { - - - _find_resources(E->get(),image_map,p_flags); - _find_resources(d[E->get()],image_map,p_flags); - - } - - - } break; - case Variant::ARRAY: { - - Array a = p_var; - for(int i=0;i<a.size();i++) { - - _find_resources(a[i],image_map,p_flags); - } - - } break; - default: {} - - } - -} - - -Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,Ref<Shape> > &collision_map,uint32_t p_flags,Map<Ref<ImageTexture>,TextureRole >& image_map) { - - // children first.. - for(int i=0;i<p_node->get_child_count();i++) { - - - Node *r = _fix_node(p_node->get_child(i),p_root,collision_map,p_flags,image_map); - if (!r) { - print_line("was erased.."); - i--; //was erased - } - } - - String name = p_node->get_name(); - - bool isroot = p_node==p_root; - - - if (!isroot && p_flags&SCENE_FLAG_REMOVE_NOIMP && _teststr(name,"noimp")) { - - memdelete(p_node); - return NULL; - } - - { - - List<PropertyInfo> pl; - p_node->get_property_list(&pl); - for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { - - if (E->get().type==Variant::OBJECT || E->get().type==Variant::ARRAY || E->get().type==Variant::DICTIONARY) { - _find_resources(p_node->get(E->get().name),image_map,p_flags); - } - } - - } - - - - - if (p_flags&SCENE_FLAG_CREATE_BILLBOARDS && Object::cast_to<MeshInstance>(p_node)) { - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - bool bb=false; - - if ((_teststr(name,"bb"))) { - bb=true; - } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(),"bb"))) { - bb=true; - - } - - if (bb) { - mi->set_flag(GeometryInstance::FLAG_BILLBOARD,true); - if (mi->get_mesh().is_valid()) { - - Ref<Mesh> m = mi->get_mesh(); - for(int i=0;i<m->get_surface_count();i++) { - - Ref<SpatialMaterial> fm = m->surface_get_material(i); - if (fm.is_valid()) { - //fm->set_flag(Material::FLAG_UNSHADED,true); - //fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - //fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - //fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - } - } - } - } - } - - - if (p_flags&(SCENE_FLAG_DETECT_ALPHA|SCENE_FLAG_DETECT_VCOLOR|SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS) && Object::cast_to<MeshInstance>(p_node)) { - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - Ref<Mesh> m = mi->get_mesh(); - - if (m.is_valid()) { - - for(int i=0;i<m->get_surface_count();i++) { - - Ref<SpatialMaterial> mat = m->surface_get_material(i); - if (!mat.is_valid()) - continue; - - if (p_flags&SCENE_FLAG_DETECT_ALPHA && _teststr(mat->get_name(),"alpha")) { - - //mat->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - //mat->set_name(_fixstr(mat->get_name(),"alpha")); - } - if (p_flags&SCENE_FLAG_DETECT_VCOLOR && _teststr(mat->get_name(),"vcol")) { - - //mat->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY,true); - //mat->set_name(_fixstr(mat->get_name(),"vcol")); - } - - if (p_flags&SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS && m->surface_get_format(i)&Mesh::ARRAY_FORMAT_TEX_UV2) { - //mat->set_flag(Material::FLAG_LIGHTMAP_ON_UV2,true); - } - - } - } - } - - if (p_flags&SCENE_FLAG_REMOVE_NOIMP && Object::cast_to<AnimationPlayer>(p_node)) { - //remove animations referencing non-importable nodes - AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node); - - List<StringName> anims; - ap->get_animation_list(&anims); - for(List<StringName>::Element *E=anims.front();E;E=E->next()) { - - Ref<Animation> anim=ap->get_animation(E->get()); - ERR_CONTINUE(anim.is_null()); - for(int i=0;i<anim->get_track_count();i++) { - NodePath path = anim->track_get_path(i); - - for(int j=0;j<path.get_name_count();j++) { - String node = path.get_name(j); - if (_teststr(node,"noimp")) { - anim->remove_track(i); - i--; - break; - } - } - } - - } - } - - - if (p_flags&SCENE_FLAG_CREATE_IMPOSTORS && Object::cast_to<MeshInstance>(p_node)) { - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - String str; - - if ((_teststr(name,"imp"))) { - str=name; - } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(),"imp"))) { - str=mi->get_mesh()->get_name(); - - } - - - if (Object::cast_to<MeshInstance>(p_node->get_parent())) { - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent()); - String d=str.substr(str.find("imp")+3,str.length()); - if (d!="") { - if ((d[0]<'0' || d[0]>'9')) - d=d.substr(1,d.length()); - if (d.length() && d[0]>='0' && d[0]<='9') { - float dist = d.to_double(); - mi->set_flag(GeometryInstance::FLAG_BILLBOARD,true); - mi->set_flag(GeometryInstance::FLAG_BILLBOARD_FIX_Y,true); - //mi->set_draw_range_begin(dist); - //mi->set_draw_range_end(100000); - - //mip->set_draw_range_begin(0); - //mip->set_draw_range_end(dist); - - if (mi->get_mesh().is_valid()) { - - Ref<Mesh> m = mi->get_mesh(); - for(int i=0;i<m->get_surface_count();i++) { - - Ref<SpatialMaterial> fm = m->surface_get_material(i); - if (fm.is_valid()) { - //fm->set_flag(Material::FLAG_UNSHADED,true); - //fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - //fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER); - //fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - } - } - } - } - } - } - } - - if (p_flags&SCENE_FLAG_CREATE_LODS && Object::cast_to<MeshInstance>(p_node)) { - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - String str; - - if ((_teststr(name,"lod"))) { - str=name; - } else if (mi->get_mesh().is_valid() && (_teststr(mi->get_mesh()->get_name(),"lod"))) { - str=mi->get_mesh()->get_name(); - - } - - - if (Object::cast_to<MeshInstance>(p_node->get_parent())) { - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - MeshInstance *mip = Object::cast_to<MeshInstance>(p_node->get_parent()); - String d=str.substr(str.find("lod")+3,str.length()); - if (d!="") { - if ((d[0]<'0' || d[0]>'9')) - d=d.substr(1,d.length()); - if (d.length() && d[0]>='0' && d[0]<='9') { - float dist = d.to_double(); - /// mi->set_draw_range_begin(dist); - // mi->set_draw_range_end(100000); - - // mip->set_draw_range_begin(0); - // mip->set_draw_range_end(dist); - - /*if (mi->get_mesh().is_valid()) { - - Ref<Mesh> m = mi->get_mesh(); - for(int i=0;i<m->get_surface_count();i++) { - - Ref<SpatialMaterial> fm = m->surface_get_material(i); - if (fm.is_valid()) { - fm->set_flag(Material::FLAG_UNSHADED,true); - fm->set_flag(Material::FLAG_DOUBLE_SIDED,true); - fm->set_hint(Material::HINT_NO_DEPTH_DRAW,true); - fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - } - } - }*/ - } - } - } - } - - - if (p_flags&SCENE_FLAG_DETECT_LIGHTMAP_LAYER && _teststr(name,"lm") && Object::cast_to<MeshInstance>(p_node)) { - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - String str=name; - int layer = str.substr(str.find("lm")+3,str.length()).to_int(); - //mi->set_baked_light_texture_id(layer); - } - - bool is_rigid = _teststr(name, "rigidonly"); - - if (p_flags & SCENE_FLAG_CREATE_COLLISIONS && (_teststr(name, "colonly") || is_rigid)) { - - if (isroot) - return p_node; - - if (Object::cast_to<MeshInstance>(p_node) && !is_rigid) { - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - Node * col = mi->create_trimesh_collision_node(); - ERR_FAIL_COND_V(!col,NULL); - - col->set_name(_fixstr(name,"colonly")); - Object::cast_to<Spatial>(col)->set_transform(mi->get_transform()); - p_node->replace_by(col); - memdelete(p_node); - p_node=col; - - StaticBody *sb = Object::cast_to<StaticBody>(col); - CollisionShape *colshape = memnew( CollisionShape); - colshape->set_shape(sb->get_shape(0)); - colshape->set_name("shape"); - sb->add_child(colshape); - colshape->set_owner(p_node->get_owner()); - } else if (p_node->has_meta("empty_draw_type")) { - String empty_draw_type = String(p_node->get_meta("empty_draw_type")); - print_line(empty_draw_type); - PhysicsBody *pb; - if (is_rigid) { - pb = memnew(RigidBody); - pb->set_name(_fixstr(name, "rigidonly")); - } else { - pb = memnew(StaticBody); - pb->set_name(_fixstr(name, "colonly")); - } - Object::cast_to<Spatial>(pb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform()); - p_node->replace_by(pb); - memdelete(p_node); - CollisionShape *colshape = memnew( CollisionShape); - if (empty_draw_type == "CUBE") { - BoxShape *boxShape = memnew( BoxShape); - boxShape->set_extents(Vector3(1, 1, 1)); - colshape->set_shape(boxShape); - colshape->set_name("BoxShape"); - } else if (empty_draw_type == "SINGLE_ARROW") { - RayShape *rayShape = memnew( RayShape); - rayShape->set_length(1); - colshape->set_shape(rayShape); - colshape->set_name("RayShape"); - Object::cast_to<Spatial>(pb)->rotate_x(Math_PI / 2); - } else if (empty_draw_type == "IMAGE") { - PlaneShape *planeShape = memnew( PlaneShape); - colshape->set_shape(planeShape); - colshape->set_name("PlaneShape"); - } else { - SphereShape *sphereShape = memnew( SphereShape); - sphereShape->set_radius(1); - colshape->set_shape(sphereShape); - colshape->set_name("SphereShape"); - } - pb->add_child(colshape); - colshape->set_owner(pb->get_owner()); - } - - } else if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(name,"rigid") && Object::cast_to<MeshInstance>(p_node)) { - - if (isroot) - return p_node; - - // get mesh instance and bounding box - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - Rect3 aabb = mi->get_aabb(); - - // create a new rigid body collision node - RigidBody * rigid_body = memnew( RigidBody ); - Node * col = rigid_body; - ERR_FAIL_COND_V(!col,NULL); - - // remove node name postfix - col->set_name(_fixstr(name,"rigid")); - // get mesh instance xform matrix to the rigid body collision node - Object::cast_to<Spatial>(col)->set_transform(mi->get_transform()); - // save original node by duplicating it into a new instance and correcting the name - Node * mesh = p_node->duplicate(); - mesh->set_name(_fixstr(name,"rigid")); - // reset the xform matrix of the duplicated node so it can inherit parent node xform - Object::cast_to<Spatial>(mesh)->set_transform(Transform(Basis())); - // reparent the new mesh node to the rigid body collision node - p_node->add_child(mesh); - mesh->set_owner(p_node->get_owner()); - // replace the original node with the rigid body collision node - p_node->replace_by(col); - memdelete(p_node); - p_node=col; - - // create an alias for the rigid body collision node - RigidBody *rb = Object::cast_to<RigidBody>(col); - // create a new Box collision shape and set the right extents - Ref<BoxShape> shape = memnew( BoxShape ); - shape->set_extents(aabb.get_size() * 0.5); - CollisionShape *colshape = memnew( CollisionShape); - colshape->set_name("shape"); - colshape->set_shape(shape); - // reparent the new collision shape to the rigid body collision node - rb->add_child(colshape); - colshape->set_owner(p_node->get_owner()); - - } else if (p_flags&SCENE_FLAG_CREATE_COLLISIONS &&_teststr(name,"col") && Object::cast_to<MeshInstance>(p_node)) { - - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - mi->set_name(_fixstr(name,"col")); - Node *col= mi->create_trimesh_collision_node(); - ERR_FAIL_COND_V(!col,NULL); - - col->set_name("col"); - p_node->add_child(col); - - StaticBody *sb=Object::cast_to<StaticBody>(col); - CollisionShape *colshape = memnew( CollisionShape); - colshape->set_shape(sb->get_shape(0)); - colshape->set_name("shape"); - col->add_child(colshape); - colshape->set_owner(p_node->get_owner()); - sb->set_owner(p_node->get_owner()); - - } else if (p_flags&SCENE_FLAG_CREATE_NAVMESH &&_teststr(name,"navmesh") && Object::cast_to<MeshInstance>(p_node)) { - - if (isroot) - return p_node; - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - Ref<Mesh> mesh=mi->get_mesh(); - ERR_FAIL_COND_V(mesh.is_null(),NULL); - NavigationMeshInstance *nmi = memnew( NavigationMeshInstance ); - - - nmi->set_name(_fixstr(name,"navmesh")); - Ref<NavigationMesh> nmesh = memnew( NavigationMesh); - nmesh->create_from_mesh(mesh); - nmi->set_navigation_mesh(nmesh); - Object::cast_to<Spatial>(nmi)->set_transform(mi->get_transform()); - p_node->replace_by(nmi); - memdelete(p_node); - p_node=nmi; - } else if (p_flags&SCENE_FLAG_CREATE_CARS &&_teststr(name,"vehicle")) { - - if (isroot) - return p_node; - - Node *owner = p_node->get_owner(); - Spatial *s = Object::cast_to<Spatial>(p_node); - VehicleBody *bv = memnew( VehicleBody ); - String n = _fixstr(p_node->get_name(),"vehicle"); - bv->set_name(n); - p_node->replace_by(bv); - p_node->set_name(n); - bv->add_child(p_node); - bv->set_owner(owner); - p_node->set_owner(owner); - bv->set_transform(s->get_transform()); - s->set_transform(Transform()); - - p_node=bv; - - - } else if (p_flags&SCENE_FLAG_CREATE_CARS &&_teststr(name,"wheel")) { - - if (isroot) - return p_node; - - Node *owner = p_node->get_owner(); - Spatial *s = Object::cast_to<Spatial>(p_node); - VehicleWheel *bv = memnew( VehicleWheel ); - String n = _fixstr(p_node->get_name(),"wheel"); - bv->set_name(n); - p_node->replace_by(bv); - p_node->set_name(n); - bv->add_child(p_node); - bv->set_owner(owner); - p_node->set_owner(owner); - bv->set_transform(s->get_transform()); - s->set_transform(Transform()); - - p_node=bv; - - } else if (p_flags&SCENE_FLAG_CREATE_ROOMS && _teststr(name,"room") && Object::cast_to<MeshInstance>(p_node)) { - - - if (isroot) - return p_node; - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID); - - - BSP_Tree bsptree(faces); - - Ref<RoomBounds> area = memnew( RoomBounds ); - //area->set_bounds(faces); - //area->set_geometry_hint(faces); - - - Room * room = memnew( Room ); - room->set_name(_fixstr(name,"room")); - room->set_transform(mi->get_transform()); - room->set_room(area); - - p_node->replace_by(room); - memdelete(p_node); - p_node=room; - - } else if (p_flags&SCENE_FLAG_CREATE_ROOMS &&_teststr(name,"room")) { - - if (isroot) - return p_node; - - Spatial *dummy = Object::cast_to<Spatial>(p_node); - ERR_FAIL_COND_V(!dummy,NULL); - - Room * room = memnew( Room ); - room->set_name(_fixstr(name,"room")); - room->set_transform(dummy->get_transform()); - - p_node->replace_by(room); - memdelete(p_node); - p_node=room; - - //room->compute_room_from_subtree(); - - } else if (p_flags&SCENE_FLAG_CREATE_PORTALS &&_teststr(name,"portal") && Object::cast_to<MeshInstance>(p_node)) { - - if (isroot) - return p_node; - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - PoolVector<Face3> faces = mi->get_faces(VisualInstance::FACES_SOLID); - - ERR_FAIL_COND_V(faces.size()==0,NULL); - //step 1 compute the plane - Set<Vector3> points; - Plane plane; - - Vector3 center; - - for(int i=0;i<faces.size();i++) { - - Face3 f = faces.get(i); - Plane p = f.get_plane(); - plane.normal+=p.normal; - plane.d+=p.d; - - for(int i=0;i<3;i++) { - - Vector3 v = f.vertex[i].snapped(0.01); - if (!points.has(v)) { - points.insert(v); - center+=v; - } - } - } - - plane.normal.normalize(); - plane.d/=faces.size(); - center/=points.size(); - - //step 2, create points - - Transform t; - t.basis.from_z(plane.normal); - t.basis.transpose(); - t.origin=center; - - Vector<Point2> portal_points; - - for(Set<Vector3>::Element *E=points.front();E;E=E->next()) { - - Vector3 local = t.xform_inv(E->get()); - portal_points.push_back(Point2(local.x,local.y)); - } - // step 3 bubbly sort points - - int swaps=0; - - do { - swaps=0; - - for(int i=0;i<portal_points.size()-1;i++) { - - float a = portal_points[i].angle(); - float b = portal_points[i+1].angle(); - - if (a>b) { - SWAP( portal_points[i], portal_points[i+1] ); - swaps++; - } - - } - - } while(swaps); - - - Portal *portal = memnew( Portal ); - - portal->set_shape(portal_points); - portal->set_transform( mi->get_transform() * t); - - p_node->replace_by(portal); - memdelete(p_node); - p_node=portal; - - } else if (Object::cast_to<MeshInstance>(p_node)) { - - //last attempt, maybe collision insde the mesh data - - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - - Ref<Mesh> mesh = mi->get_mesh(); - if (!mesh.is_null()) { - - if (p_flags&SCENE_FLAG_CREATE_COLLISIONS && _teststr(mesh->get_name(),"col")) { - - mesh->set_name( _fixstr(mesh->get_name(),"col") ); - Ref<Shape> shape; - - if (collision_map.has(mesh)) { - shape = collision_map[mesh]; - - } else { - - shape = mesh->create_trimesh_shape(); - if (!shape.is_null()) - collision_map[mesh]=shape; - - - } - - if (!shape.is_null()) { -#if 0 - StaticBody* static_body = memnew( StaticBody ); - ERR_FAIL_COND_V(!static_body,NULL); - static_body->set_name( String(mesh->get_name()) + "_col" ); - shape->set_name(static_body->get_name()); - static_body->add_shape(shape); - - mi->add_child(static_body); - if (mi->get_owner()) - static_body->set_owner( mi->get_owner() ); -#endif - } - - } - - for(int i=0;i<mesh->get_surface_count();i++) { - - Ref<SpatialMaterial> fm = mesh->surface_get_material(i); - if (fm.is_valid()) { - String name = fm->get_name(); - /* if (_teststr(name,"alpha")) { - fm->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA,true); - name=_fixstr(name,"alpha"); - } - - if (_teststr(name,"vcol")) { - fm->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY,true); - name=_fixstr(name,"vcol"); - }*/ - fm->set_name(name); - } - } - - } - - } - - - return p_node; -} - -void EditorSceneImportPlugin::_tag_import_paths(Node *p_scene,Node *p_node) { - - if (p_scene!=p_node && p_node->get_owner()!=p_scene) - return; - - NodePath path = p_scene->get_path_to(p_node); - p_node->set_import_path( path ); - - Spatial *snode=Object::cast_to<Spatial>(p_node); - - if (snode) { - - snode->set_import_transform(snode->get_transform()); - } - - for(int i=0;i<p_node->get_child_count();i++) { - _tag_import_paths(p_scene,p_node->get_child(i)); - } - -} - -Error EditorSceneImportPlugin::import1(const Ref<ResourceImportMetadata>& p_from,Node**r_node,List<String> *r_missing) { - - Ref<ResourceImportMetadata> from=p_from; - - ERR_FAIL_COND_V(from->get_source_count()!=1,ERR_INVALID_PARAMETER); - - String src_path=EditorImportPlugin::expand_source_path(from->get_source_path(0)); - - Ref<EditorSceneImporter> importer; - String ext=src_path.get_extension().to_lower(); - - - EditorProgress progress("import",TTR("Import Scene"),104); - progress.step(TTR("Importing Scene.."),0); - - for(int i=0;i<importers.size();i++) { - - List<String> extensions; - importers[i]->get_extensions(&extensions); - - for(List<String>::Element *E=extensions.front();E;E=E->next()) { - - if (E->get().to_lower()==ext) { - - importer = importers[i]; - break; - } - } - - if (importer.is_valid()) - break; - } - - ERR_FAIL_COND_V(!importer.is_valid(),ERR_FILE_UNRECOGNIZED); - - int animation_flags=p_from->get_option("animation_flags"); - int scene_flags = from->get_option("flags"); - int fps = 24; - if (from->has_option("animation_bake_fps")) - fps=from->get_option("animation_bake_fps"); - - - Array clips; - if (from->has_option("animation_clips")) - clips=from->get_option("animation_clips"); - - uint32_t import_flags=0; - if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_DETECT_LOOP) - import_flags|=EditorSceneImporter::IMPORT_ANIMATION_DETECT_LOOP; - if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_KEEP_VALUE_TRACKS) - import_flags |= EditorSceneImporter::IMPORT_ANIMATION_KEEP_VALUE_TRACKS; - if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_OPTIMIZE) - import_flags|=EditorSceneImporter::IMPORT_ANIMATION_OPTIMIZE; - if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS) - import_flags|=EditorSceneImporter::IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS; - if (scene_flags&SCENE_FLAG_IMPORT_ANIMATIONS) - import_flags|=EditorSceneImporter::IMPORT_ANIMATION; - /* - if (scene_flags&SCENE_FLAG_FAIL_ON_MISSING_IMAGES) - import_flags|=EditorSceneImporter::IMPORT_FAIL_ON_MISSING_DEPENDENCIES; - */ - if (scene_flags&SCENE_FLAG_GENERATE_TANGENT_ARRAYS) - import_flags|=EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS; - - - - - - Error err=OK; - Node *scene = importer->import_scene(src_path,import_flags,fps,r_missing,&err); - if (!scene || err!=OK) { - return err; - } - - if (from->has_option("root_type")) { - String type = from->get_option("root_type"); - Node *base_node = Object::cast_to<Node>(ClassDB::instance(type)); - - if (base_node) { - - scene->replace_by(base_node); - memdelete(scene); - scene=base_node; - } - } - - scene->set_name(from->get_option("root_name")); - _tag_import_paths(scene,scene); - - *r_node=scene; - return OK; -} - - -void EditorSceneImportPlugin::_create_clips(Node *scene, const Array& p_clips,bool p_bake_all) { - - if (!scene->has_node(String("AnimationPlayer"))) - return; - - Node* n = scene->get_node(String("AnimationPlayer")); - ERR_FAIL_COND(!n); - AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n); - ERR_FAIL_COND(!anim); - - if (!anim->has_animation("default")) - return; - - - Ref<Animation> default_anim = anim->get_animation("default"); - - for(int i=0;i<p_clips.size();i+=4) { - - String name = p_clips[i]; - float from=p_clips[i+1]; - float to=p_clips[i+2]; - bool loop=p_clips[i+3]; - if (from>=to) - continue; - - Ref<Animation> new_anim = memnew( Animation ); - - for(int j=0;j<default_anim->get_track_count();j++) { - - - List<float> keys; - int kc = default_anim->track_get_key_count(j); - int dtrack=-1; - for(int k=0;k<kc;k++) { - - float kt = default_anim->track_get_key_time(j,k); - if (kt>=from && kt<to) { - - //found a key within range, so create track - if (dtrack==-1) { - new_anim->add_track(default_anim->track_get_type(j)); - dtrack = new_anim->get_track_count()-1; - new_anim->track_set_path(dtrack,default_anim->track_get_path(j)); - - if (kt>(from+0.01) && k>0) { - - if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) { - Quat q; - Vector3 p; - Vector3 s; - default_anim->transform_track_interpolate(j,from,&p,&q,&s); - new_anim->transform_track_insert_key(dtrack,0,p,q,s); - } - } - - } - - if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) { - Quat q; - Vector3 p; - Vector3 s; - default_anim->transform_track_get_key(j,k,&p,&q,&s); - new_anim->transform_track_insert_key(dtrack,kt-from,p,q,s); - } - - } - - if (dtrack!=-1 && kt>=to) { - - if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) { - Quat q; - Vector3 p; - Vector3 s; - default_anim->transform_track_interpolate(j,to,&p,&q,&s); - new_anim->transform_track_insert_key(dtrack,to-from,p,q,s); - } - } - - } - - if (dtrack==-1 && p_bake_all) { - new_anim->add_track(default_anim->track_get_type(j)); - dtrack = new_anim->get_track_count()-1; - new_anim->track_set_path(dtrack,default_anim->track_get_path(j)); - if (default_anim->track_get_type(j)==Animation::TYPE_TRANSFORM) { - - - Quat q; - Vector3 p; - Vector3 s; - default_anim->transform_track_interpolate(j,from,&p,&q,&s); - new_anim->transform_track_insert_key(dtrack,0,p,q,s); - default_anim->transform_track_interpolate(j,to,&p,&q,&s); - new_anim->transform_track_insert_key(dtrack,to-from,p,q,s); - } - - } - } - - - new_anim->set_loop(loop); - new_anim->set_length(to-from); - anim->add_animation(name,new_anim); - } - - anim->remove_animation("default"); //remove default (no longer needed) -} - -void EditorSceneImportPlugin::_filter_anim_tracks(Ref<Animation> anim,Set<String> &keep) { - - Ref<Animation> a = anim; - ERR_FAIL_COND(!a.is_valid()); - - print_line("From Anim "+anim->get_name()+":"); - - for(int j=0;j<a->get_track_count();j++) { - - String path = a->track_get_path(j); - - if (!keep.has(path)) { - - print_line("Remove: "+path); - a->remove_track(j); - j--; - } - - } -} - - -void EditorSceneImportPlugin::_filter_tracks(Node *scene, const String& p_text) { - - if (!scene->has_node(String("AnimationPlayer"))) - return; - Node* n = scene->get_node(String("AnimationPlayer")); - ERR_FAIL_COND(!n); - AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n); - ERR_FAIL_COND(!anim); - - Vector<String> strings = p_text.split("\n"); - for(int i=0;i<strings.size();i++) { - - strings[i]=strings[i].strip_edges(); - } - - List<StringName> anim_names; - anim->get_animation_list(&anim_names); - for(List<StringName>::Element *E=anim_names.front();E;E=E->next()) { - - String name = E->get(); - bool valid_for_this=false; - bool valid=false; - - Set<String> keep; - Set<String> keep_local; - - - for(int i=0;i<strings.size();i++) { - - - if (strings[i].begins_with("@")) { - - valid_for_this=false; - for(Set<String>::Element *F=keep_local.front();F;F=F->next()) { - keep.insert(F->get()); - } - keep_local.clear(); - - Vector<String> filters=strings[i].substr(1,strings[i].length()).split(","); - for(int j=0;j<filters.size();j++) { - - String fname = filters[j].strip_edges(); - if (fname=="") - continue; - int fc = fname[0]; - bool plus; - if (fc=='+') - plus=true; - else if (fc=='-') - plus=false; - else - continue; - - String filter=fname.substr(1,fname.length()).strip_edges(); - - if (!name.matchn(filter)) - continue; - valid_for_this=plus; - } - - if (valid_for_this) - valid=true; - - } else if (valid_for_this) { - - Ref<Animation> a = anim->get_animation(name); - if (!a.is_valid()) - continue; - - for(int j=0;j<a->get_track_count();j++) { - - String path = a->track_get_path(j); - - String tname = strings[i]; - if (tname=="") - continue; - int fc = tname[0]; - bool plus; - if (fc=='+') - plus=true; - else if (fc=='-') - plus=false; - else - continue; - - String filter=tname.substr(1,tname.length()).strip_edges(); - - if (!path.matchn(filter)) - continue; - - if (plus) - keep_local.insert(path); - else if (!keep.has(path)) { - keep_local.erase(path); - } - } - - } - - } - - if (valid) { - for(Set<String>::Element *F=keep_local.front();F;F=F->next()) { - keep.insert(F->get()); - } - print_line("FILTERING ANIM: "+String(E->get())); - _filter_anim_tracks(anim->get_animation(name),keep); - } else { - print_line("NOT FILTERING ANIM: "+String(E->get())); - - } - - } - - - -} - -void EditorSceneImportPlugin::_optimize_animations(Node *scene, float p_max_lin_error,float p_max_ang_error,float p_max_angle) { - - if (!scene->has_node(String("AnimationPlayer"))) - return; - Node* n = scene->get_node(String("AnimationPlayer")); - ERR_FAIL_COND(!n); - AnimationPlayer *anim = Object::cast_to<AnimationPlayer>(n); - ERR_FAIL_COND(!anim); - - - List<StringName> anim_names; - anim->get_animation_list(&anim_names); - for(List<StringName>::Element *E=anim_names.front();E;E=E->next()) { - - Ref<Animation> a = anim->get_animation(E->get()); - a->optimize(p_max_lin_error,p_max_ang_error,Math::deg2rad(p_max_angle)); - } -} - - -void EditorSceneImportPlugin::_find_resources_to_merge(Node *scene, Node *node, bool p_merge_material, Map<String, Ref<Material> > &materials, bool p_merge_anims, Map<String,Ref<Animation> >& merged_anims,Set<Ref<Mesh> > &tested_meshes) { - - if (node!=scene && node->get_owner()!=scene) - return; - - String path = scene->get_path_to(node); - - if (p_merge_anims && Object::cast_to<AnimationPlayer>(node)) { - - AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(node); - List<StringName> anims; - ap->get_animation_list(&anims); - for (List<StringName>::Element *E=anims.front();E;E=E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); - Ref<Animation> clone; - - bool has_user_tracks=false; - - for(int i=0;i<anim->get_track_count();i++) { - - if (!anim->track_is_imported(i)) { - has_user_tracks=true; - break; - } - } - - if (has_user_tracks) { - - clone = anim->duplicate(); - for(int i=0;i<clone->get_track_count();i++) { - if (clone->track_is_imported(i)) { - clone->remove_track(i); - i--; - } - } - - merged_anims[path+"::"+String(E->get())]=clone; - } - } - } - - - - if (p_merge_material && Object::cast_to<MeshInstance>(node)) { - MeshInstance *mi=Object::cast_to<MeshInstance>(node); - Ref<Mesh> mesh = mi->get_mesh(); - if (mesh.is_valid() && mesh->get_name()!=String() && !tested_meshes.has(mesh)) { - - for(int i=0;i<mesh->get_surface_count();i++) { - Ref<Material> material = mesh->surface_get_material(i); - - if (material.is_valid()) { - - String sname = mesh->surface_get_name(i); - if (sname=="") - sname="surf_"+itos(i); - - sname=mesh->get_name()+":surf:"+sname; - materials[sname]=material; - } - } - - tested_meshes.insert(mesh); - } - - if (mesh.is_valid()) { - - for(int i=0;i<mesh->get_surface_count();i++) { - Ref<Material> material = mi->get_surface_material(i); - if (material.is_valid()) { - String sname = mesh->surface_get_name(i); - if (sname=="") - sname="surf_"+itos(i); - - sname=path+":inst_surf:"+sname; - materials[sname]=material; - } - } - - } - - Ref<Material> override = mi->get_material_override(); - - if (override.is_valid()) { - - materials[path+":override"]=override; - } - } - - - - for(int i=0;i<node->get_child_count();i++) { - _find_resources_to_merge(scene,node->get_child(i),p_merge_material,materials,p_merge_anims,merged_anims,tested_meshes); - } - -} - - -void EditorSceneImportPlugin::_merge_found_resources(Node *scene, Node *node, bool p_merge_material, const Map<String, Ref<Material> > &materials, bool p_merge_anims, const Map<String,Ref<Animation> >& merged_anims, Set<Ref<Mesh> > &tested_meshes) { - - if (node!=scene && node->get_owner()!=scene) - return; - - String path = scene->get_path_to(node); - - print_line("at path: "+path); - - if (AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(node)) { - - List<StringName> anims; - ap->get_animation_list(&anims); - for (List<StringName>::Element *E=anims.front();E;E=E->next()) { - Ref<Animation> anim = ap->get_animation(E->get()); - - String anim_path = path+"::"+String(E->get()); - - if (merged_anims.has(anim_path)) { - - Ref<Animation> user_tracks = merged_anims[anim_path]; - for(int i=0;i<user_tracks->get_track_count();i++) { - - int idx = anim->get_track_count(); - anim->add_track(user_tracks->track_get_type(i)); - anim->track_set_path(idx,user_tracks->track_get_path(i)); - anim->track_set_interpolation_type(idx,user_tracks->track_get_interpolation_type(i)); - for(int j=0;j<user_tracks->track_get_key_count(i);j++) { - - float ofs = user_tracks->track_get_key_time(i,j); - float trans = user_tracks->track_get_key_transition(i,j); - Variant value = user_tracks->track_get_key_value(i,j); - - anim->track_insert_key(idx,ofs,value,trans); - } - } - } - } - } - - - - if (MeshInstance *mi=Object::cast_to<MeshInstance>(node)) { - - Ref<Mesh> mesh = mi->get_mesh(); - if (mesh.is_valid() && mesh->get_name()!=String() && !tested_meshes.has(mesh)) { - - for(int i=0;i<mesh->get_surface_count();i++) { - - String sname = mesh->surface_get_name(i); - if (sname=="") - sname="surf_"+itos(i); - - sname=mesh->get_name()+":surf:"+sname; - - - if (materials.has(sname)) { - - mesh->surface_set_material(i,materials[sname]); - } - } - - tested_meshes.insert(mesh); - } - - if (mesh.is_valid()) { - - for(int i=0;i<mesh->get_surface_count();i++) { - - String sname = mesh->surface_get_name(i); - if (sname=="") - sname="surf_"+itos(i); - - sname=path+":inst_surf:"+sname; - - - if (materials.has(sname)) { - - mi->set_surface_material(i,materials[sname]); - } - } - - } - - - String opath = path+":override"; - if (materials.has(opath)) { - mi->set_material_override(materials[opath]); - } - - } - - - - for(int i=0;i<node->get_child_count();i++) { - _merge_found_resources(scene,node->get_child(i),p_merge_material,materials,p_merge_anims,merged_anims,tested_meshes); - } - -} - -Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, const Ref<ResourceImportMetadata>& p_from) { - - Error err=OK; - Ref<ResourceImportMetadata> from=p_from; - String src_path=EditorImportPlugin::expand_source_path(from->get_source_path(0)); - int animation_flags=p_from->get_option("animation_flags"); - Array animation_clips = p_from->get_option("animation_clips"); - String animation_filter = p_from->get_option("animation_filters"); - int scene_flags = from->get_option("flags"); - float anim_optimizer_linerr=0.05; - float anim_optimizer_angerr=0.01; - float anim_optimizer_maxang=22; - - if (from->has_option("animation_optimizer_linear_error")) - anim_optimizer_linerr=from->get_option("animation_optimizer_linear_error"); - if (from->has_option("animation_optimizer_angular_error")) - anim_optimizer_angerr=from->get_option("animation_optimizer_angular_error"); - if (from->has_option("animation_optimizer_max_angle")) - anim_optimizer_maxang=from->get_option("animation_optimizer_max_angle"); - - EditorProgress progress("import",TTR("Import Scene"),104); - progress.step(TTR("Importing Scene.."),2); - - - from->set_source_md5(0,FileAccess::get_md5(src_path)); - from->set_editor(get_name()); - - from->set_option("reimport",false); - String target_res_path=p_dest_path.get_base_dir(); - - Map<Ref<Mesh>,Ref<Shape> > collision_map; - - Map< Ref<ImageTexture>,TextureRole > imagemap; - - scene=_fix_node(scene,scene,collision_map,scene_flags,imagemap); - if (animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_OPTIMIZE) - _optimize_animations(scene,anim_optimizer_linerr,anim_optimizer_angerr,anim_optimizer_maxang); - if (animation_clips.size()) - _create_clips(scene,animation_clips,animation_flags&EditorSceneAnimationImportPlugin::ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS); - - _filter_tracks(scene,animation_filter); - - - if (scene_flags&(SCENE_FLAG_MERGE_KEEP_MATERIALS|SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS) && FileAccess::exists(p_dest_path)) { - //must merge! - - print_line("MUST MERGE"); - Ref<PackedScene> pscene = ResourceLoader::load(p_dest_path,"PackedScene",true); - if (pscene.is_valid()) { - - Node *instance = pscene->instance(); - if (instance) { - Map<String,Ref<Animation> > merged_anims; - Map<String,Ref<Material> > merged_materials; - Set<Ref<Mesh> > tested_meshes; - - _find_resources_to_merge(instance,instance,scene_flags&SCENE_FLAG_MERGE_KEEP_MATERIALS,merged_materials,scene_flags&SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,merged_anims,tested_meshes); - - tested_meshes.clear(); - _merge_found_resources(scene,scene,scene_flags&SCENE_FLAG_MERGE_KEEP_MATERIALS,merged_materials,scene_flags&SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS,merged_anims,tested_meshes); - - memdelete(instance); - } - - } - - } - - /// BEFORE ANYTHING, RUN SCRIPT - - progress.step(TTR("Running Custom Script.."),2); - - String post_import_script_path = from->get_option("post_import_script"); - Ref<EditorScenePostImport> post_import_script; - - if (post_import_script_path!="") { - post_import_script_path = post_import_script_path; - Ref<Script> scr = ResourceLoader::load(post_import_script_path); - if (!scr.is_valid()) { - EditorNode::add_io_error(TTR("Couldn't load post-import script:")+" "+post_import_script_path); - } else { - - post_import_script = Ref<EditorScenePostImport>( memnew( EditorScenePostImport ) ); - post_import_script->set_script(scr.get_ref_ptr()); - if (!post_import_script->get_script_instance()) { - EditorNode::add_io_error(TTR("Invalid/broken script for post-import (check console):")+" "+post_import_script_path); - post_import_script.unref(); - return ERR_CANT_CREATE; - } - } - } - - - if (post_import_script.is_valid()) { - scene = post_import_script->post_import(scene); - if (!scene) { - EditorNode::add_io_error(TTR("Error running post-import script:")+" "+post_import_script_path); - return err; - } - - - } - - - /// IMPORT IMAGES - - - int idx=0; - - int image_format = from->get_option("texture_format"); - int image_flags = from->get_option("texture_flags"); - float image_quality = from->get_option("texture_quality"); - - for (Map< Ref<ImageTexture>,TextureRole >::Element *E=imagemap.front();E;E=E->next()) { - - //texture could be converted to something more useful for 3D, that could load individual mipmaps and stuff - //but not yet.. - - Ref<ImageTexture> texture = E->key(); - - ERR_CONTINUE(!texture.is_valid()); - - String path = texture->get_path(); - String fname= path.get_file(); - String target_path = ProjectSettings::get_singleton()->localize_path(target_res_path.plus_file(fname)); - progress.step(TTR("Import Image:")+" "+fname,3+(idx)*100/imagemap.size()); - - idx++; - - if (path==target_path) { - - EditorNode::add_io_error(TTR("Can't import a file over itself:")+" "+target_path); - continue; - } - - if (!target_path.begins_with("res://")) { - EditorNode::add_io_error(vformat(TTR("Couldn't localize path: %s (already local)"),target_path)); - continue; - } - - - { - - - target_path=target_path.get_basename()+".tex"; - - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - - uint32_t flags = image_flags; - if (E->get()==TEXTURE_ROLE_DIFFUSE && scene_flags&SCENE_FLAG_LINEARIZE_DIFFUSE_TEXTURES) - flags|=EditorTextureImportPlugin::IMAGE_FLAG_CONVERT_TO_LINEAR; - - if (E->get()==TEXTURE_ROLE_NORMALMAP && scene_flags&SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY) - flags|=EditorTextureImportPlugin::IMAGE_FLAG_CONVERT_NORMAL_TO_XY; - - imd->set_option("flags",flags); - imd->set_option("format",image_format); - imd->set_option("quality",image_quality); - imd->set_option("atlas",false); - imd->add_source(EditorImportPlugin::validate_source_path(path)); - - - if (FileAccess::exists(target_path)) { - - Ref<ResourceImportMetadata> rimdex = ResourceLoader::load_import_metadata(target_path); - if (rimdex.is_valid()) { - //make sure the options are the same, otherwise re-import - List<String> opts; - imd->get_options(&opts); - bool differ=false; - for (List<String>::Element *E=opts.front();E;E=E->next()) { - if (!(rimdex->get_option(E->get())==imd->get_option(E->get()))) { - differ=true; - break; - } - } - - if (!differ) { - texture->set_path(target_path); - continue; //already imported - } - } - } - - EditorTextureImportPlugin::get_singleton()->import(target_path,imd); - - } - } - - - - progress.step(TTR("Saving.."),104); - - Ref<PackedScene> packer = memnew( PackedScene ); - packer->pack(scene); - //packer->set_path(p_dest_path); do not take over, let the changed files reload themselves - packer->set_import_metadata(from); - - print_line("SAVING TO: "+p_dest_path); - err = ResourceSaver::save(p_dest_path,packer); //do not take over, let the changed files reload themselves - - //EditorFileSystem::get_singleton()->update_resource(packer); - - memdelete(scene); - - /* - scene->set_filename(p_dest_path); - if (r_scene) { - *r_scene=scene; - } else { - memdelete(scene); - } - - String sp; - if (p_post_import.is_valid() && !p_post_import->get_script().is_null()) { - Ref<Script> scr = p_post_import->get_script(); - if (scr.is_valid()) - sp=scr->get_path(); - } - - String op=_getrelpath(p_path,p_dest_path); - - */ - - EditorNode::get_singleton()->reload_scene(p_dest_path); - - return err; - -} - - -Error EditorSceneImportPlugin::import(const String& p_dest_path, const Ref<ResourceImportMetadata>& p_from){ - - - Node *n=NULL; - Error err = import1(p_from,&n); - if (err!=OK) { - if (n) { - memdelete(n); - } - return err; - } - return import2(n,p_dest_path,p_from); -} - -void EditorSceneImportPlugin::add_importer(const Ref<EditorSceneImporter>& p_importer) { - - importers.push_back(p_importer); -} - -void EditorSceneImportPlugin::import_from_drop(const Vector<String>& p_drop,const String& p_dest_path) { - - List<String> extensions; - for(int i=0;i<importers.size();i++) { - importers[i]->get_extensions(&extensions); - } - //bool warn_compatible=false; - for(int i=0;i<p_drop.size();i++) { - - String extension = p_drop[i].get_extension().to_lower(); - - for(List<String>::Element *E=extensions.front();E;E=E->next()) { - - if (E->get()==extension) { - - dialog->popup_import(String()); - dialog->setup_popup(p_drop[i],p_dest_path); - return; - } - } - } - -} - - -EditorSceneImportPlugin::EditorSceneImportPlugin(EditorNode* p_editor) { - - dialog = memnew( EditorSceneImportDialog(p_editor,this) ); - p_editor->get_gui_base()->add_child(dialog); -} - - -/////////////////////////////// - - -String EditorSceneAnimationImportPlugin::get_name() const { - - return "anim_3d"; -} -String EditorSceneAnimationImportPlugin::get_visible_name() const{ - - - return TTR("3D Scene Animation"); -} -void EditorSceneAnimationImportPlugin::import_dialog(const String& p_from){ - - -} -Error EditorSceneAnimationImportPlugin::import(const String& p_path, const Ref<ResourceImportMetadata>& p_from){ - - return OK; -} - -EditorSceneAnimationImportPlugin::EditorSceneAnimationImportPlugin(EditorNode* p_editor) { - - -} -#endif diff --git a/editor/io_plugins/editor_scene_import_plugin.h b/editor/io_plugins/editor_scene_import_plugin.h deleted file mode 100644 index 44526deb8b..0000000000 --- a/editor/io_plugins/editor_scene_import_plugin.h +++ /dev/null @@ -1,201 +0,0 @@ -/*************************************************************************/ -/* editor_scene_import_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_SCENE_IMPORT_PLUGIN_H -#define EDITOR_SCENE_IMPORT_PLUGIN_H -#if 0 -#include "editor/editor_dir_dialog.h" -#include "editor/editor_file_system.h" -#include "editor/editor_import_export.h" -#include "editor/io_plugins/editor_texture_import_plugin.h" -#include "scene/gui/dialogs.h" -#include "scene/gui/file_dialog.h" -#include "scene/gui/label.h" -#include "scene/gui/line_edit.h" -#include "scene/gui/option_button.h" -#include "scene/gui/progress_bar.h" -#include "scene/gui/slider.h" -#include "scene/gui/spin_box.h" -#include "scene/gui/tree.h" -#include "scene/resources/animation.h" -#include "scene/resources/mesh.h" - - -class EditorNode; -class EditorSceneImportDialog; - -class EditorSceneImporter : public Reference { - - GDCLASS(EditorSceneImporter,Reference ); -public: - - enum ImportFlags { - IMPORT_SCENE=1, - IMPORT_ANIMATION=2, - IMPORT_ANIMATION_DETECT_LOOP=4, - IMPORT_ANIMATION_OPTIMIZE=8, - IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS=16, - IMPORT_ANIMATION_KEEP_VALUE_TRACKS=32, - IMPORT_GENERATE_TANGENT_ARRAYS=256, - IMPORT_FAIL_ON_MISSING_DEPENDENCIES=512 - - }; - - virtual uint32_t get_import_flags() const=0; - virtual void get_extensions(List<String> *r_extensions) const=0; - virtual Node* import_scene(const String& p_path,uint32_t p_flags,int p_bake_fps,List<String> *r_missing_deps,Error* r_err=NULL)=0; - virtual Ref<Animation> import_animation(const String& p_path,uint32_t p_flags)=0; - - - - EditorSceneImporter(); -}; - -///////////////////////////////////////// - - -//Plugin for post processing scenes or images - -class EditorScenePostImport : public Reference { - - GDCLASS(EditorScenePostImport,Reference ); -protected: - - static void _bind_methods(); -public: - - virtual Node* post_import(Node* p_scene); - EditorScenePostImport(); -}; - - -class EditorSceneImportPlugin : public EditorImportPlugin { - - GDCLASS(EditorSceneImportPlugin,EditorImportPlugin); - - EditorSceneImportDialog *dialog; - - Vector<Ref<EditorSceneImporter> > importers; - - enum TextureRole { - TEXTURE_ROLE_DEFAULT, - TEXTURE_ROLE_DIFFUSE, - TEXTURE_ROLE_NORMALMAP - }; - - void _find_resources(const Variant& p_var,Map<Ref<ImageTexture>,TextureRole >& image_map,int p_flags); - Node* _fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>,Ref<Shape> > &collision_map,uint32_t p_flags,Map<Ref<ImageTexture>,TextureRole >& image_map); - void _create_clips(Node *scene, const Array& p_clips, bool p_bake_all); - void _filter_anim_tracks(Ref<Animation> anim,Set<String> &keep); - void _filter_tracks(Node *scene, const String& p_text); - void _optimize_animations(Node *scene, float p_max_lin_error,float p_max_ang_error,float p_max_angle); - - void _tag_import_paths(Node *p_scene,Node *p_node); - - void _find_resources_to_merge(Node *scene, Node *node, bool p_merge_material, Map<String,Ref<Material> >&materials, bool p_merge_anims, Map<String,Ref<Animation> >& merged_anims, Set<Ref<Mesh> > &tested_meshes); - void _merge_found_resources(Node *scene, Node *node, bool p_merge_material, const Map<String, Ref<Material> > &materials, bool p_merge_anims, const Map<String,Ref<Animation> >& merged_anims, Set<Ref<Mesh> > &tested_meshes); - - -public: - - enum SceneFlags { - - SCENE_FLAG_CREATE_COLLISIONS=1<<0, - SCENE_FLAG_CREATE_PORTALS=1<<1, - SCENE_FLAG_CREATE_ROOMS=1<<2, - SCENE_FLAG_SIMPLIFY_ROOMS=1<<3, - SCENE_FLAG_CREATE_BILLBOARDS=1<<4, - SCENE_FLAG_CREATE_IMPOSTORS=1<<5, - SCENE_FLAG_CREATE_LODS=1<<6, - SCENE_FLAG_CREATE_CARS=1<<8, - SCENE_FLAG_CREATE_WHEELS=1<<9, - SCENE_FLAG_DETECT_ALPHA=1<<15, - SCENE_FLAG_DETECT_VCOLOR=1<<16, - SCENE_FLAG_CREATE_NAVMESH=1<<17, - SCENE_FLAG_DETECT_LIGHTMAP_LAYER=1<<18, - - SCENE_FLAG_MERGE_KEEP_MATERIALS=1<<20, - SCENE_FLAG_MERGE_KEEP_EXTRA_ANIM_TRACKS=1<<21, - - SCENE_FLAG_REMOVE_NOIMP=1<<24, - SCENE_FLAG_IMPORT_ANIMATIONS=1<<25, - SCENE_FLAG_COMPRESS_GEOMETRY=1<<26, - SCENE_FLAG_GENERATE_TANGENT_ARRAYS=1<<27, - SCENE_FLAG_LINEARIZE_DIFFUSE_TEXTURES=1<<28, - SCENE_FLAG_SET_LIGHTMAP_TO_UV2_IF_EXISTS=1<<29, - SCENE_FLAG_CONVERT_NORMALMAPS_TO_XY=1<<30, - }; - - - - 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); - - Error import1(const Ref<ResourceImportMetadata>& p_from,Node**r_node,List<String> *r_missing=NULL); - Error import2(Node* p_scene,const String& p_path, const Ref<ResourceImportMetadata>& p_from); - - void add_importer(const Ref<EditorSceneImporter>& p_importer); - const Vector<Ref<EditorSceneImporter> >& get_importers() { return importers; } - - virtual void import_from_drop(const Vector<String>& p_drop,const String& p_dest_path); - - EditorSceneImportPlugin(EditorNode* p_editor=NULL); - - -}; - - -class EditorSceneAnimationImportPlugin : public EditorImportPlugin { - - GDCLASS(EditorSceneAnimationImportPlugin,EditorImportPlugin); -public: - - - enum AnimationFlags { - - ANIMATION_DETECT_LOOP=1, - ANIMATION_KEEP_VALUE_TRACKS=2, - ANIMATION_OPTIMIZE=4, - ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS=8 - }; - - 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); - - EditorSceneAnimationImportPlugin(EditorNode* p_editor=NULL); - - -}; - -#endif -#endif // EDITOR_SCENE_IMPORT_PLUGIN_H diff --git a/editor/io_plugins/editor_scene_importer_fbxconv.cpp b/editor/io_plugins/editor_scene_importer_fbxconv.cpp deleted file mode 100644 index 4e246d1ef9..0000000000 --- a/editor/io_plugins/editor_scene_importer_fbxconv.cpp +++ /dev/null @@ -1,1137 +0,0 @@ -/*************************************************************************/ -/* editor_scene_importer_fbxconv.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_scene_importer_fbxconv.h" - -#include "editor/editor_settings.h" -#include "os/file_access.h" -#include "os/os.h" -#include "scene/3d/mesh_instance.h" -#include "scene/animation/animation_player.h" - -#if 0 -String EditorSceneImporterFBXConv::_id(const String& p_id) const { - - return p_id.replace(":","_").replace("/","_"); -} - -uint32_t EditorSceneImporterFBXConv::get_import_flags() const { - - return IMPORT_SCENE|IMPORT_ANIMATION; -} -void EditorSceneImporterFBXConv::get_extensions(List<String> *r_extensions) const{ - - r_extensions->push_back("fbx"); - r_extensions->push_back("g3dj"); -} - - -Color EditorSceneImporterFBXConv::_get_color(const Array& a) { - - if (a.size()<3) - return Color(); - Color c; - c.r=a[0]; - c.g=a[1]; - c.b=a[2]; - if (a.size()>=4) - c.a=a[3]; - return c; - -} - -Transform EditorSceneImporterFBXConv::_get_transform_mixed(const Dictionary& d,const Dictionary& dbase) { - - - - - Array translation; - - if (d.has("translation")) - translation=d["translation"]; - else if (dbase.has("translation")) - translation=dbase["translation"]; - - Array rotation; - - if (d.has("rotation")) - rotation=d["rotation"]; - else if (dbase.has("rotation")) - rotation=dbase["rotation"]; - - Array scale; - - if (d.has("scale")) - scale=d["scale"]; - else if (dbase.has("scale")) - scale=dbase["scale"]; - - Transform t; - - - if (translation.size()) { - Array tr = translation; - if (tr.size()>=3) { - t.origin.x=tr[0]; - t.origin.y=tr[1]; - t.origin.z=tr[2]; - } - } - - if (rotation.size()) { - - Array r = rotation; - if (r.size()>=4) { - - Quat q; - q.x = r[0]; - q.y = r[1]; - q.z = r[2]; - q.w = r[3]; - t.basis=Matrix3(q); - } - } - - - if (scale.size()) { - - Array sc = scale; - if (sc.size()>=3) { - Vector3 s; - s.x=sc[0]; - s.y=sc[1]; - s.z=sc[2]; - t.basis.scale(s); - } - } - - return t; - - -} - -Transform EditorSceneImporterFBXConv::_get_transform(const Dictionary& d) { - - - Transform t; - - if (d.has("translation")) { - Array tr = d["translation"]; - if (tr.size()>=3) { - t.origin.x=tr[0]; - t.origin.y=tr[1]; - t.origin.z=tr[2]; - } - } - - if (d.has("rotation")) { - - Array r = d["rotation"]; - if (r.size()>=4) { - - Quat q; - q.x = r[0]; - q.y = r[1]; - q.z = r[2]; - q.w = r[3]; - t.basis=Matrix3(q); - } - } - - - if (d.has("scale")) { - - Array sc = d["scale"]; - if (sc.size()>=3) { - Vector3 s; - s.x=sc[0]; - s.y=sc[1]; - s.z=sc[2]; - t.basis.scale(s); - } - } - - return t; -} - - -void EditorSceneImporterFBXConv::_detect_bones_in_nodes(State& state,const Array& p_nodes) { - - - for(int i=0;i<p_nodes.size();i++) { - - Dictionary d = p_nodes[i]; - if (d.has("isBone") && bool(d["isBone"])) { - - String bone_name=_id(d["id"]); - print_line("IS BONE: "+bone_name); - if (!state.bones.has(bone_name)) { - state.bones.insert(bone_name,BoneInfo()); - } - - if (!state.bones[bone_name].has_rest) { - state.bones[bone_name].rest=_get_transform(d).affine_inverse(); - } - - state.bones[bone_name].node=d; - - //state.bones[name].rest=_get_transform(b); - } - - if (d.has("parts")) { - - Array parts=d["parts"]; - for(int j=0;j<parts.size();j++) { - - Dictionary p=parts[j]; - if (p.has("bones")) { - Array bones=p["bones"]; - //omfg - for(int k=0;k<bones.size();k++) { - - Dictionary b = bones[k]; - if (b.has("node")) { - - String name = _id(b["node"]); - if (!state.bones.has(name)) { - state.bones.insert(name,BoneInfo()); - } - - state.bones[name].rest=_get_transform(b); - state.bones[name].has_rest=true; - } - } - } - - } - } - - if (d.has("children")) { - - _detect_bones_in_nodes(state,d["children"]); - } - } - -} - -void EditorSceneImporterFBXConv::_parse_skeletons(const String& p_name,State& state, const Array &p_nodes, Skeleton *p_skeleton,int p_parent) { - - - - for(int i=0;i<p_nodes.size();i++) { - - - Dictionary d = p_nodes[i]; - int bone_idx=-1; - String id; - Skeleton* skeleton=p_skeleton; - if (d.has("id")) { - - id=_id(d["id"]); - if (state.bones.has(id)) { - //BONER - if (!skeleton) { - skeleton=memnew( Skeleton ); - state.skeletons[id]=skeleton; - } - bone_idx = skeleton->get_bone_count(); - skeleton->add_bone(id); - skeleton->set_bone_parent(bone_idx,p_parent); - skeleton->set_bone_rest(bone_idx,state.bones[id].rest); - state.bones[id].skeleton=skeleton; - } - } - - if (d.has("children")) { - - _parse_skeletons(id,state,d["children"],skeleton,bone_idx); - } - } - -} - -void EditorSceneImporterFBXConv::_detect_bones(State& state) { - //This format should mark when a node is a bone, - //which is the only thing that Collada does right. - //think about others implementing a parser. - //Just _one_ string and you avoid loads of lines of code to other people. - - for(int i=0;i<state.animations.size();i++) { - - Dictionary an = state.animations[i]; - if (an.has("bones")) { - - Array bo=an["bones"]; - for(int j=0;j<bo.size();j++) { - - Dictionary b=bo[j]; - if (b.has("boneId")) { - - String id = b["boneId"]; - if (!state.bones.has(id)) { - state.bones.insert(id,BoneInfo()); - } - state.bones[id].has_anim_chan=true; //used in anim - - - } - } - } - } - - _detect_bones_in_nodes(state,state.nodes); - _parse_skeletons("",state,state.nodes,NULL,-1); - - print_line("found bones: "+itos(state.bones.size())); - print_line("found skeletons: "+itos(state.skeletons.size())); -} - -Error EditorSceneImporterFBXConv::_parse_bones(State& state,const Array &p_bones,Skeleton* p_skeleton) { - - - - return OK; -} - - -void EditorSceneImporterFBXConv::_add_surface(State& state,Ref<Mesh>& m,const Dictionary &part) { - - if (part.has("meshpartid")) { - - String id = part["meshpartid"]; - ERR_FAIL_COND(!state.surface_cache.has(id)); - - - Ref<Material> mat; - if (part.has("materialid")) { - String matid=part["materialid"]; - if (state.material_cache.has(matid)) { - mat=state.material_cache[matid]; - } - } - int idx = m->get_surface_count(); - - Array array = state.surface_cache[id].array; - PoolVector<float> indices = array[Mesh::ARRAY_BONES]; - if (indices.size() && part.has("bones")) { - - - Map<int,int> index_map; - - Array bones=part["bones"]; - - for(int i=0;i<bones.size();i++) { - - Dictionary bone=bones[i]; - String name=_id(bone["node"]); - - if (state.bones.has(name)) { - int idx=state.bones[name].skeleton->find_bone(name); - if (idx==-1) - idx=0; - index_map[i]=idx; - } - } - - - - int ilen=indices.size(); - { - PoolVector<float>::Write iw=indices.write(); - for(int j=0;j<ilen;j++) { - int b = iw[j]; - ERR_CONTINUE(!index_map.has(b)); - b=index_map[b]; - iw[j]=b; - } - } - - array[Mesh::ARRAY_BONES]=indices; - - - } - - m->add_surface(state.surface_cache[id].primitive,array); - m->surface_set_material(idx,mat); - m->surface_set_name(idx,id); - } - -} - -Error EditorSceneImporterFBXConv::_parse_nodes(State& state,const Array &p_nodes,Node* p_base) { - - for(int i=0;i<p_nodes.size();i++) { - - Dictionary n = p_nodes[i]; - Spatial *node=NULL; - bool skip=false; - - String id; - if (n.has("id")) { - id=_id(n["id"]); - } - - print_line("ID: "+id); - - if (state.skeletons.has(id)) { - - Skeleton *skeleton = state.skeletons[id]; - node=skeleton; - skeleton->localize_rests(); - print_line("IS SKELETON! "); - } else if (state.bones.has(id)) { - if (p_base) - node=Object::cast_to<Spatial>(p_base); - if (!state.bones[id].has_anim_chan) { - print_line("no has anim "+id); - } - skip=true; - } else if (n.has("parts")) { - //is a mesh - MeshInstance *mesh = memnew( MeshInstance ); - node=mesh; - - Array parts=n["parts"]; - String long_identifier; - for(int j=0;j<parts.size();j++) { - - Dictionary part=parts[j]; - if (part.has("meshpartid")) { - String partid=part["meshpartid"]; - long_identifier+=partid; - } - } - - Ref<Mesh> m; - - if (state.mesh_cache.has(long_identifier)) { - m=state.mesh_cache[long_identifier]; - } else { - m = Ref<Mesh>( memnew( Mesh ) ); - - //and parts are surfaces - for(int j=0;j<parts.size();j++) { - - Dictionary part=parts[j]; - if (part.has("meshpartid")) { - _add_surface(state,m,part); - } - } - - - state.mesh_cache[long_identifier]=m; - } - - mesh->set_mesh(m); - } - - if (!skip) { - - if (!node) { - node = memnew( Spatial ); - } - - node->set_name(id); - node->set_transform(_get_transform(n)); - p_base->add_child(node); - node->set_owner(state.scene); - } - - - if (n.has("children")) { - Error err = _parse_nodes(state,n["children"],node); - if (err) - return err; - } - } - - return OK; -} - - -void EditorSceneImporterFBXConv::_parse_materials(State& state) { - - for(int i=0;i<state.materials.size();i++) { - - Dictionary material = state.materials[i]; - - ERR_CONTINUE(!material.has("id")); - String id = _id(material["id"]); - - Ref<SpatialMaterial> mat = memnew( SpatialMaterial ); - - if (material.has("diffuse")) { - mat->set_parameter(SpatialMaterial::PARAM_DIFFUSE,_get_color(material["diffuse"])); - } - - if (material.has("specular")) { - mat->set_parameter(SpatialMaterial::PARAM_SPECULAR,_get_color(material["specular"])); - } - - if (material.has("emissive")) { - mat->set_parameter(SpatialMaterial::PARAM_EMISSION,_get_color(material["emissive"])); - } - - if (material.has("shininess")) { - float exp = material["shininess"]; - mat->set_parameter(SpatialMaterial::PARAM_SPECULAR_EXP,exp); - } - - if (material.has("opacity")) { - Color c = mat->get_parameter(SpatialMaterial::PARAM_DIFFUSE); - c.a=material["opacity"]; - mat->set_parameter(SpatialMaterial::PARAM_DIFFUSE,c); - } - - - if (material.has("textures")) { - - Array textures = material["textures"]; - for(int j=0;j<textures.size();j++) { - - Dictionary texture=textures[j]; - Ref<Texture> tex; - if (texture.has("filename")) { - - - String filename=texture["filename"]; - String path=state.base_path+"/"+filename.replace("\\","/"); - if (state.texture_cache.has(path)) { - tex=state.texture_cache[path]; - } else { - tex = ResourceLoader::load(path,"ImageTexture"); - if (tex.is_null()) { - if (state.missing_deps) - state.missing_deps->push_back(path); - } - state.texture_cache[path]=tex; //add anyway - } - } - - if (tex.is_valid() && texture.has("type")) { - - String type=texture["type"]; - if (type=="DIFFUSE") - mat->set_texture(SpatialMaterial::PARAM_DIFFUSE,tex); - else if (type=="SPECULAR") - mat->set_texture(SpatialMaterial::PARAM_SPECULAR,tex); - else if (type=="SHININESS") - mat->set_texture(SpatialMaterial::PARAM_SPECULAR_EXP,tex); - else if (type=="NORMAL") - mat->set_texture(SpatialMaterial::PARAM_NORMAL,tex); - else if (type=="EMISSIVE") - mat->set_texture(SpatialMaterial::PARAM_EMISSION,tex); - } - - } - } - - state.material_cache[id]=mat; - - } - -} - -void EditorSceneImporterFBXConv::_parse_surfaces(State& state) { - - for(int i=0;i<state.meshes.size();i++) { - - Dictionary mesh = state.meshes[i]; - - ERR_CONTINUE(!mesh.has("attributes")); - ERR_CONTINUE(!mesh.has("vertices")); - ERR_CONTINUE(!mesh.has("parts")); - - print_line("MESH #"+itos(i)); - - Array attrlist=mesh["attributes"]; - Array vertices=mesh["vertices"]; - bool exists[Mesh::ARRAY_MAX]; - int ofs[Mesh::ARRAY_MAX]; - int weight_max=0; - int binormal_ofs=-1; - int weight_ofs[4]; - - for(int j=0;j<Mesh::ARRAY_MAX;j++) { - exists[j]=false; - ofs[j]=0; - } - exists[Mesh::ARRAY_INDEX]=true; - float stride=0; - - for(int j=0;j<attrlist.size();j++) { - - String attr=attrlist[j]; - if (attr=="POSITION") { - exists[Mesh::ARRAY_VERTEX]=true; - ofs[Mesh::ARRAY_VERTEX]=stride; - stride+=3; - } else if (attr=="NORMAL") { - exists[Mesh::ARRAY_NORMAL]=true; - ofs[Mesh::ARRAY_NORMAL]=stride; - stride+=3; - } else if (attr=="COLOR") { - exists[Mesh::ARRAY_COLOR]=true; - ofs[Mesh::ARRAY_COLOR]=stride; - stride+=4; - } else if (attr=="COLORPACKED") { - stride+=1; //ignore - } else if (attr=="TANGENT") { - exists[Mesh::ARRAY_TANGENT]=true; - ofs[Mesh::ARRAY_TANGENT]=stride; - stride+=3; - } else if (attr=="BINORMAL") { - binormal_ofs=stride; - stride+=3; - } else if (attr=="TEXCOORD0") { - exists[Mesh::ARRAY_TEX_UV]=true; - ofs[Mesh::ARRAY_TEX_UV]=stride; - stride+=2; - } else if (attr=="TEXCOORD1") { - exists[Mesh::ARRAY_TEX_UV2]=true; - ofs[Mesh::ARRAY_TEX_UV2]=stride; - stride+=2; - } else if (attr.begins_with("TEXCOORD")) { - stride+=2; - } else if (attr.begins_with("BLENDWEIGHT")) { - int idx=attr.replace("BLENDWEIGHT","").to_int(); - if (idx==0) { - exists[Mesh::ARRAY_BONES]=true; - ofs[Mesh::ARRAY_BONES]=stride; - exists[Mesh::ARRAY_WEIGHTS]=true; - ofs[Mesh::ARRAY_WEIGHTS]=stride+1; - } if (idx<4) { - weight_ofs[idx]=stride; - weight_max=MAX(weight_max,idx+1); - } - - stride+=2; - } - - print_line("ATTR "+attr+" OFS: "+itos(stride)); - - } - - Array parts=mesh["parts"]; - - for(int j=0;j<parts.size();j++) { - - - - Dictionary part=parts[j]; - ERR_CONTINUE(!part.has("indices")); - ERR_CONTINUE(!part.has("id")); - - print_line("PART: "+String(part["id"])); - Array indices=part["indices"]; - Map<int,int> iarray; - Map<int,int> array; - - for(int k=0;k<indices.size();k++) { - - int idx = indices[k]; - if (!iarray.has(idx)) { - int map_to=array.size(); - iarray[idx]=map_to; - array[map_to]=idx; - } - } - - print_line("indices total "+itos(indices.size())+" vertices used: "+itos(array.size())); - - Array arrays; - arrays.resize(Mesh::ARRAY_MAX); - - - - for(int k=0;k<Mesh::ARRAY_MAX;k++) { - - - if (!exists[k]) - continue; - print_line("exists: "+itos(k)); - int lofs = ofs[k]; - switch(k) { - - case Mesh::ARRAY_VERTEX: - case Mesh::ARRAY_NORMAL: { - - PoolVector<Vector3> vtx; - vtx.resize(array.size()); - { - int len=array.size(); - PoolVector<Vector3>::Write w = vtx.write(); - for(int l=0;l<len;l++) { - - int pos = array[l]; - w[l].x=vertices[pos*stride+lofs+0]; - w[l].y=vertices[pos*stride+lofs+1]; - w[l].z=vertices[pos*stride+lofs+2]; - } - } - arrays[k]=vtx; - - } break; - case Mesh::ARRAY_TANGENT: { - - if (binormal_ofs<0) - break; - - PoolVector<float> tangents; - tangents.resize(array.size()*4); - { - int len=array.size(); - - PoolVector<float>::Write w = tangents.write(); - for(int l=0;l<len;l++) { - - int pos = array[l]; - Vector3 n; - n.x=vertices[pos*stride+ofs[Mesh::ARRAY_NORMAL]+0]; - n.y=vertices[pos*stride+ofs[Mesh::ARRAY_NORMAL]+1]; - n.z=vertices[pos*stride+ofs[Mesh::ARRAY_NORMAL]+2]; - Vector3 t; - t.x=vertices[pos*stride+lofs+0]; - t.y=vertices[pos*stride+lofs+1]; - t.z=vertices[pos*stride+lofs+2]; - Vector3 bi; - bi.x=vertices[pos*stride+binormal_ofs+0]; - bi.y=vertices[pos*stride+binormal_ofs+1]; - bi.z=vertices[pos*stride+binormal_ofs+2]; - float d = bi.dot(n.cross(t)); - - w[l*4+0]=t.x; - w[l*4+1]=t.y; - w[l*4+2]=t.z; - w[l*4+3]=d; - - } - } - arrays[k]=tangents; - - } break; - case Mesh::ARRAY_COLOR: { - - PoolVector<Color> cols; - cols.resize(array.size()); - { - int len=array.size(); - PoolVector<Color>::Write w = cols.write(); - for(int l=0;l<len;l++) { - - int pos = array[l]; - w[l].r=vertices[pos*stride+lofs+0]; - w[l].g=vertices[pos*stride+lofs+1]; - w[l].b=vertices[pos*stride+lofs+2]; - w[l].a=vertices[pos*stride+lofs+3]; - } - } - arrays[k]=cols; - - } break; - case Mesh::ARRAY_TEX_UV: - case Mesh::ARRAY_TEX_UV2: { - - PoolVector<Vector2> uvs; - uvs.resize(array.size()); - { - int len=array.size(); - PoolVector<Vector2>::Write w = uvs.write(); - for(int l=0;l<len;l++) { - - int pos = array[l]; - w[l].x=vertices[pos*stride+lofs+0]; - w[l].y=vertices[pos*stride+lofs+1]; - w[l].y=1.0-w[l].y; - } - } - arrays[k]=uvs; - - } break; - case Mesh::ARRAY_BONES: - case Mesh::ARRAY_WEIGHTS: { - - PoolVector<float> arr; - arr.resize(array.size()*4); - int po=k==Mesh::ARRAY_WEIGHTS?1:0; - lofs=ofs[Mesh::ARRAY_BONES]; - { - int len=array.size(); - - PoolVector<float>::Write w = arr.write(); - for(int l=0;l<len;l++) { - - int pos = array[l]; - - for(int m=0;m<4;m++) { - - float val=0; - if (m<=weight_max) - val=vertices[pos*stride+lofs+m*2+po]; - w[l*4+m]=val; - } - } - } - - arrays[k]=arr; - } break; - case Mesh::ARRAY_INDEX: { - - PoolVector<int> arr; - arr.resize(indices.size()); - { - int len=indices.size(); - - PoolVector<int>::Write w = arr.write(); - for(int l=0;l<len;l++) { - - w[l]=iarray[ indices[l] ]; - } - } - - arrays[k]=arr; - - } break; - - - } - - - } - - Mesh::PrimitiveType pt=Mesh::PRIMITIVE_TRIANGLES; - - if (part.has("type")) { - String type=part["type"]; - if (type=="LINES") - pt=Mesh::PRIMITIVE_LINES; - else if (type=="POINTS") - pt=Mesh::PRIMITIVE_POINTS; - else if (type=="TRIANGLE_STRIP") - pt=Mesh::PRIMITIVE_TRIANGLE_STRIP; - else if (type=="LINE_STRIP") - pt=Mesh::PRIMITIVE_LINE_STRIP; - } - - if (pt==Mesh::PRIMITIVE_TRIANGLES) { - PoolVector<int> ia=arrays[Mesh::ARRAY_INDEX]; - int len=ia.size(); - { - PoolVector<int>::Write w=ia.write(); - for(int l=0;l<len;l+=3) { - SWAP(w[l+1],w[l+2]); - } - } - arrays[Mesh::ARRAY_INDEX]=ia; - - - } - SurfaceInfo si; - si.array=arrays; - si.primitive=pt; - state.surface_cache[_id(part["id"])]=si; - - } - } -} - - -Error EditorSceneImporterFBXConv::_parse_animations(State& state) { - - AnimationPlayer *ap = memnew( AnimationPlayer ); - - state.scene->add_child(ap); - ap->set_owner(state.scene); - - for(int i=0;i<state.animations.size();i++) { - - Dictionary anim = state.animations[i]; - ERR_CONTINUE(!anim.has("id")); - Ref<Animation> an = memnew( Animation ); - an->set_name(_id(anim["id"])); - - - if (anim.has("bones")) { - - Array bone_tracks = anim["bones"]; - for(int j=0;j<bone_tracks.size();j++) { - Dictionary bone_track=bone_tracks[j]; - String bone = bone_track["boneId"]; - if (!bone_track.has("keyframes")) - continue; - if (!state.bones.has(bone)) - continue; - - Skeleton *sk = state.bones[bone].skeleton; - - if (!sk) - continue; - int bone_idx=sk->find_bone(bone); - if (bone_idx==-1) - continue; - - - - String path = state.scene->get_path_to(sk); - path+=":"+bone; - an->add_track(Animation::TYPE_TRANSFORM); - int tidx = an->get_track_count()-1; - an->track_set_path(tidx,path); - - - Dictionary parent_xform_dict; - Dictionary xform_dict; - - if (state.bones.has(bone)) { - xform_dict=state.bones[bone].node; - } - - - Array parent_keyframes; - if (sk->get_bone_parent(bone_idx)!=-1) { - String parent_name = sk->get_bone_name(sk->get_bone_parent(bone_idx)); - if (state.bones.has(parent_name)) { - parent_xform_dict=state.bones[parent_name].node; - } - - print_line("parent for "+bone+"? "+parent_name+" XFD: "+String(Variant(parent_xform_dict))); - for(int k=0;k<bone_tracks.size();k++) { - Dictionary d = bone_tracks[k]; - if (d["boneId"]==parent_name) { - parent_keyframes=d["keyframes"]; - print_line("found keyframes"); - break; - } - } - - - } - - print_line("BONE XFD "+String(Variant(xform_dict))); - - Array keyframes=bone_track["keyframes"]; - - for(int k=0;k<keyframes.size();k++) { - - Dictionary key=keyframes[k]; - Transform xform=_get_transform_mixed(key,xform_dict); - float time = key["keytime"]; - time=time/1000.0; -#if 0 - if (parent_keyframes.size()) { - //localize - print_line(itos(k)+" localizate for: "+bone); - - float prev_kt=-1; - float kt; - int idx=0; - - for(int l=0;l<parent_keyframes.size();l++) { - - Dictionary d=parent_keyframes[l]; - kt=d["keytime"]; - kt=kt/1000.0; - if (kt>time) - break; - prev_kt=kt; - idx++; - - } - - Transform t; - if (idx==0) { - t=_get_transform_mixed(parent_keyframes[0],parent_xform_dict); - } else if (idx==parent_keyframes.size()){ - t=_get_transform_mixed(parent_keyframes[idx-1],parent_xform_dict); - } else { - t=_get_transform_mixed(parent_keyframes[idx-1],parent_xform_dict); - float d = (time-prev_kt)/(kt-prev_kt); - if (d>0) { - Transform t2=_get_transform_mixed(parent_keyframes[idx],parent_xform_dict); - t=t.interpolate_with(t2,d); - } else { - print_line("exact: "+rtos(kt)); - } - } - - xform = t.affine_inverse() * xform; //localize - } else if (!parent_xform_dict.empty()) { - Transform t = _get_transform(parent_xform_dict); - xform = t.affine_inverse() * xform; //localize - } -#endif - - xform = sk->get_bone_rest(bone_idx).affine_inverse() * xform; - - - Quat q = xform.basis; - q.normalize(); - Vector3 s = xform.basis.get_scale(); - Vector3 l = xform.origin; - - - - an->transform_track_insert_key(tidx,time,l,q,s); - - } - - } - - - } - - - ap->add_animation(_id(anim["id"]),an); - - } - - return OK; -} - -Error EditorSceneImporterFBXConv::_parse_json(State& state, const String &p_path) { - - //not the happiest.... - Vector<uint8_t> data = FileAccess::get_file_as_array(p_path); - ERR_FAIL_COND_V(!data.size(),ERR_FILE_CANT_OPEN); - String str; - bool utferr = str.parse_utf8((const char*)data.ptr(),data.size()); - ERR_FAIL_COND_V(utferr,ERR_PARSE_ERROR); - - Dictionary dict; - Error err = dict.parse_json(str); - str=String(); //free mem immediately - ERR_FAIL_COND_V(err,err); - - if (dict.has("meshes")) - state.meshes=dict["meshes"]; - if (dict.has("materials")) - state.materials=dict["materials"]; - if (dict.has("nodes")) - state.nodes=dict["nodes"]; - if (dict.has("animations")) - state.animations=dict["animations"]; - - - state.scene = memnew( Spatial ); - _detect_bones(state); - _parse_surfaces(state); - _parse_materials(state); - err = _parse_nodes(state,state.nodes,state.scene); - if (err) - return err; - - if (state.import_animations) { - err = _parse_animations(state); - if (err) - return err; - } - - print_line("JSON PARSED O-K!"); - - return OK; -} - -Error EditorSceneImporterFBXConv::_parse_fbx(State& state,const String& p_path) { - - state.base_path=p_path.get_base_dir(); - - if (p_path.to_lower().ends_with("g3dj")) { - return _parse_json(state,p_path.basename()+".g3dj"); - } - - String tool = EDITOR_DEF("fbxconv/path",""); - ERR_FAIL_COND_V( !FileAccess::exists(tool),ERR_UNCONFIGURED); - String wine = EDITOR_DEF("fbxconv/use_wine",""); - - List<String> args; - String path=p_path; - if (wine!="") { - List<String> wpargs; - wpargs.push_back("-w"); - wpargs.push_back(p_path); - String pipe; //winepath to convert to windows path - int wpres; - Error wperr = OS::get_singleton()->execute(wine+"path",wpargs,true,NULL,&pipe,&wpres); - ERR_FAIL_COND_V(wperr!=OK,ERR_CANT_CREATE); - ERR_FAIL_COND_V(wpres!=0,ERR_CANT_CREATE); - path=pipe.strip_edges(); - args.push_back(tool); - tool=wine; - } - - args.push_back("-o"); - args.push_back("G3DJ"); - args.push_back(path); - - int res; - Error err = OS::get_singleton()->execute(tool,args,true,NULL,NULL,&res); - ERR_FAIL_COND_V(err!=OK,ERR_CANT_CREATE); - ERR_FAIL_COND_V(res!=0,ERR_CANT_CREATE); - - return _parse_json(state,p_path.basename()+".g3dj"); - - -} - -Node* EditorSceneImporterFBXConv::import_scene(const String& p_path,uint32_t p_flags,List<String> *r_missing_deps,Error* r_err){ - - State state; - state.scene=NULL; - state.missing_deps=r_missing_deps; - state.import_animations=p_flags&IMPORT_ANIMATION; - Error err = _parse_fbx(state,p_path); - if (err!=OK) { - if (r_err) - *r_err=err; - return NULL; - } - - - return state.scene; -} -Ref<Animation> EditorSceneImporterFBXConv::import_animation(const String& p_path,uint32_t p_flags){ - - - return Ref<Animation>(); -} - - -EditorSceneImporterFBXConv::EditorSceneImporterFBXConv() { - - EDITOR_DEF("fbxconv/path",""); -#ifndef WINDOWS_ENABLED - EDITOR_DEF("fbxconv/use_wine",""); - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"fbxconv/use_wine",PROPERTY_HINT_GLOBAL_FILE)); - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"fbxconv/path",PROPERTY_HINT_GLOBAL_FILE)); -#else - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"fbxconv/path",PROPERTY_HINT_GLOBAL_FILE,"exe")); -#endif - -} -#endif diff --git a/editor/io_plugins/editor_scene_importer_fbxconv.h b/editor/io_plugins/editor_scene_importer_fbxconv.h deleted file mode 100644 index d191a17489..0000000000 --- a/editor/io_plugins/editor_scene_importer_fbxconv.h +++ /dev/null @@ -1,112 +0,0 @@ -/*************************************************************************/ -/* editor_scene_importer_fbxconv.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_SCENE_IMPORTER_FBXCONV_H -#define EDITOR_SCENE_IMPORTER_FBXCONV_H - -#include "editor/io_plugins/editor_scene_import_plugin.h" -#include "scene/3d/skeleton.h" - -#if 0 - -class EditorSceneImporterFBXConv : public EditorSceneImporter { - - GDCLASS(EditorSceneImporterFBXConv,EditorSceneImporter ); - - - struct BoneInfo { - - Skeleton *skeleton; - Transform rest; - int index; - bool has_anim_chan; - bool has_rest; - Dictionary node; - BoneInfo() { - has_rest=false; - skeleton=NULL; - index=-1; - has_anim_chan=false; - } - }; - - struct SurfaceInfo { - Array array; - Mesh::PrimitiveType primitive; - }; - - struct State { - - Node *scene; - Array meshes; - Array materials; - Array nodes; - Array animations; - Map<String,BoneInfo > bones; - Map<String,Skeleton*> skeletons; - Map<String,Ref<Mesh> > mesh_cache; - Map<String,SurfaceInfo> surface_cache; - Map<String,Ref<Material> > material_cache; - Map<String,Ref<Texture> > texture_cache; - List<String> *missing_deps; - String base_path; - bool import_animations; - }; - - String _id(const String& p_id) const; - - Transform _get_transform_mixed(const Dictionary& d, const Dictionary& dbase); - Transform _get_transform(const Dictionary& d); - Color _get_color(const Array& a); - void _detect_bones_in_nodes(State& state,const Array& p_nodes); - void _detect_bones(State& state); - - Error _parse_bones(State& state,const Array &p_bones,Skeleton* p_skeleton); - void _parse_skeletons(const String& p_name,State& state, const Array &p_nodes, Skeleton*p_skeleton=NULL, int p_parent=-1); - - void _add_surface(State& state,Ref<Mesh>& m,const Dictionary &part); - Error _parse_nodes(State& state,const Array &p_nodes,Node* p_base); - Error _parse_animations(State& state); - void _parse_materials(State& state); - void _parse_surfaces(State& state); - Error _parse_json(State& state,const String& p_path); - Error _parse_fbx(State &state, const String &p_path); - -public: - - virtual uint32_t get_import_flags() const; - virtual void get_extensions(List<String> *r_extensions) const; - virtual Node* import_scene(const String& p_path,uint32_t p_flags,List<String> *r_missing_deps=NULL,Error* r_err=NULL); - virtual Ref<Animation> import_animation(const String& p_path,uint32_t p_flags); - - EditorSceneImporterFBXConv(); -}; - -#endif // EDITOR_SCENE_IMPORTER_FBXCONV_H -#endif diff --git a/editor/io_plugins/editor_texture_import_plugin.cpp b/editor/io_plugins/editor_texture_import_plugin.cpp deleted file mode 100644 index 9432377648..0000000000 --- a/editor/io_plugins/editor_texture_import_plugin.cpp +++ /dev/null @@ -1,1896 +0,0 @@ -/*************************************************************************/ -/* editor_texture_import_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_texture_import_plugin.h" - -#if 0 -#include "editor/editor_node.h" -#include "editor/editor_settings.h" -#include "editor_atlas.h" -#include "io/image_loader.h" -#include "io/marshalls.h" -#include "io/resource_saver.h" -#include "project_settings.h" -#include "scene/gui/button_group.h" -#include "scene/gui/check_button.h" -#include "scene/gui/margin_container.h" -#include "scene/io/resource_format_image.h" - -#include "thirdparty/misc/md5.h" - -static const char *flag_names[]={ - ("Streaming Format"), - ("Fix Border Alpha"), - ("Alpha Bit Hint"), - ("Compress Extra (PVRTC2)"), - ("No MipMaps"), - ("Repeat"), - ("Filter (Magnifying)"), - ("Premultiply Alpha"), - ("Convert SRGB->Linear"), - ("Convert NormalMap to XY"), - ("Use Anisotropy"), - NULL -}; - -#if 0 // not used -static const char *flag_short_names[]={ - "Stream", - "FixBorder", - "AlphBit", - "ExtComp", - "NoMipMap", - "Repeat", - "Filter", - "PMAlpha", - "ToLinear", - "ToRG", - "Anisoropic", - NULL -}; -#endif - - -void EditorImportTextureOptions::set_format(EditorTextureImportPlugin::ImageFormat p_format) { - - updating=true; - format->select(p_format); - if (p_format==EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY) { - quality_vb->show(); - } else { - quality_vb->hide(); - } - - updating=false; - -} - -EditorTextureImportPlugin::ImageFormat EditorImportTextureOptions::get_format() const{ - - return (EditorTextureImportPlugin::ImageFormat)format->get_selected(); - -} - -void EditorImportTextureOptions::set_flags(uint32_t p_flags){ - - updating=true; - for(int i=0;i<items.size();i++) { - - items[i]->set_checked(0,p_flags&(1<<i)); - } - updating=false; - -} - -void EditorImportTextureOptions::set_quality(float p_quality) { - - quality->set_value(p_quality); -} - -float EditorImportTextureOptions::get_quality() const { - - return quality->get_value(); -} - - -uint32_t EditorImportTextureOptions::get_flags() const{ - - uint32_t f=0; - for(int i=0;i<items.size();i++) { - - if (items[i]->is_checked(0)) - f|=(1<<i); - } - - return f; -} - -void EditorImportTextureOptions::_changedp(int p_value) { - - _changed(); -} - -void EditorImportTextureOptions::_changed() { - - if (updating) - return; - if (format->get_selected()==EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY) { - quality_vb->show(); - } else { - quality_vb->hide(); - } - - emit_signal("changed"); -} - - -void EditorImportTextureOptions::_bind_methods() { - - ClassDB::bind_method("_changed",&EditorImportTextureOptions::_changed); - ClassDB::bind_method("_changedp",&EditorImportTextureOptions::_changedp); - - ADD_SIGNAL(MethodInfo("changed")); -} - - -void EditorImportTextureOptions::_notification(int p_what) { - - if (p_what==NOTIFICATION_ENTER_TREE) { - - flags->connect("item_edited",this,"_changed"); - format->connect("item_selected",this,"_changedp"); - } -} - -void EditorImportTextureOptions::show_2d_notice() { - - //notice_for_2d->show(); -} - -EditorImportTextureOptions::EditorImportTextureOptions() { - - - add_constant_override("separation",3); - updating=false; - format = memnew( OptionButton ); - - format->add_item(TTR("Uncompressed"),EditorTextureImportPlugin::IMAGE_FORMAT_UNCOMPRESSED); - format->add_item(TTR("Compress Lossless (PNG)"),EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS); - format->add_item(TTR("Compress Lossy (WebP)"),EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY); - format->add_item(TTR("Compress (VRAM)"),EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM); - - - add_margin_child(TTR("Texture Format"),format); - - quality_vb = memnew( VBoxContainer ); - - HBoxContainer *quality_hb = memnew(HBoxContainer); - HSlider *hs = memnew( HSlider ); - hs->set_h_size_flags(SIZE_EXPAND_FILL); - hs->set_stretch_ratio(0.8); - quality_hb->add_child(hs); - quality_hb->set_h_size_flags(SIZE_EXPAND_FILL); - SpinBox *sb = memnew( SpinBox ); - sb->set_h_size_flags(SIZE_EXPAND_FILL); - sb->set_stretch_ratio(0.2); - quality_hb->add_child(sb); - sb->share(hs); - hs->set_min(0); - hs->set_max(1.0); - hs->set_step(0.01); - hs->set_value(0.7); - quality=hs; - quality_vb->add_margin_child(TTR("Texture Compression Quality (WebP):"),quality_hb); - - add_child(quality_vb); - - flags = memnew( Tree ); - flags->set_hide_root(true); - TreeItem *root = flags->create_item(); - - - - const char ** fname=flag_names; - - while( *fname ) { - - TreeItem*ti = flags->create_item(root); - ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); - ti->set_text(0,*fname); - ti->set_editable(0,true); - items.push_back(ti); - fname++; - } - - add_margin_child(TTR("Texture Options"),flags,true); - - -} - -/////////////////////////////////////////////////////////// - - - - -class EditorTextureImportDialog : public ConfirmationDialog { - - GDCLASS(EditorTextureImportDialog,ConfirmationDialog); - - - - HBoxContainer *mode_hb; - CheckBox *mode_check[EditorTextureImportPlugin::MODE_MAX]; - - EditorImportTextureOptions *texture_options; - - EditorTextureImportPlugin::Mode mode; - //EditorNode *editor; - - LineEdit *import_path; - LineEdit *save_path; - EditorFileDialog *file_select; - EditorFileDialog *save_file_select; - EditorDirDialog *save_select; - OptionButton *texture_action; - ConfirmationDialog *error_dialog; - CheckButton *crop_source; - SpinBox *size; - - MarginContainer *size_mc; - Label* size_label; - - Label* source_label; - Label *notice_for_2d; - - EditorTextureImportPlugin *plugin; - - void _mode_changed(int p_mode); - void _choose_files(const Vector<String>& p_path); - void _choose_file(const String& p_path); - void _choose_save_dir(const String& p_path); - void _browse(); - void _browse_target(); - void _import(); - - -protected: - - void _notification(int p_what); - static void _bind_methods(); -public: - - - void setup_multiple_import_3d(const Vector<String>& p_path,const String& p_dest) { - - _mode_changed(EditorTextureImportPlugin::MODE_TEXTURE_3D); - _choose_files(p_path); - _choose_save_dir(p_dest); - } - - void add_sources_and_dest(const Vector<String>& p_path,const String& p_dest) { - - _choose_files(p_path); - _choose_save_dir(p_dest); - } - - Error import(const String& p_from, const String& p_to, const String& p_preset); - void popup_import(const String &p_from=String()); - EditorTextureImportDialog(EditorTextureImportPlugin *p_plugin=NULL); -}; - - -///////////////////////////////////////////////////////// - - - - -void EditorTextureImportDialog::_choose_files(const Vector<String>& p_path) { - - String files; - for(int i=0;i<p_path.size();i++) { - - if (i>0) - files+=","; - files+=p_path[i]; - } - /* - if (p_path.size()) { - String srctex=p_path[0]; - String ipath = EditorImportDB::get_singleton()->find_source_path(srctex); - - if (ipath!="") - save_path->set_text(ipath.get_base_dir()); - }*/ - import_path->set_text(files); - -} - - - -void EditorTextureImportDialog::_choose_file(const String& p_path) { - - - import_path->set_text(p_path); - -} -void EditorTextureImportDialog::_choose_save_dir(const String& p_path) { - - save_path->set_text(p_path); -} - - -void EditorTextureImportDialog::_import() { - - - //ImportMonitorBlock imb; - - Vector<String> files=import_path->get_text().split(","); - - if (!files.size()) { - - error_dialog->set_text(TTR("Please specify some files!")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - } - - String dst_path=save_path->get_text(); - - if (save_path->get_text().strip_edges()=="") { - error_dialog->set_text(TTR("Target path is empty.")); - error_dialog->popup_centered_minsize(); - return; - } - - if (!save_path->get_text().begins_with("res://")) { - error_dialog->set_text(TTR("Target path must be a complete resource path.")); - error_dialog->popup_centered_minsize(); - return; - } - - - if (mode!=EditorTextureImportPlugin::MODE_ATLAS && mode!=EditorTextureImportPlugin::MODE_LARGE && !DirAccess::exists(save_path->get_text())) { - error_dialog->set_text(TTR("Target path must exist.")); - error_dialog->popup_centered_minsize(); - return; - } - - if (mode==EditorTextureImportPlugin::MODE_ATLAS) { //atlas - - if (files.size()==0) { - - error_dialog->set_text(TTR("At least one file needed for Atlas.")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - - } - String dst_file = dst_path; - //dst_file=dst_file.basename()+".tex"; - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - //imd->set_editor(); - for(int i=0;i<files.size();i++) { - imd->add_source(EditorImportPlugin::validate_source_path(files[i])); - } - imd->set_option("format",texture_options->get_format()); - imd->set_option("flags",texture_options->get_flags()); - imd->set_option("quality",texture_options->get_quality()); - imd->set_option("atlas",true); - imd->set_option("atlas_size",int(size->get_value())); - imd->set_option("large",false); - imd->set_option("crop",crop_source->is_pressed()); - imd->set_option("mode",mode); - - Error err = plugin->import(dst_file,imd); - if (err) { - - error_dialog->set_text(TTR("Error importing:")+" "+dst_file.get_file()); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - - } - } else if (mode==EditorTextureImportPlugin::MODE_LARGE) { //large - - if (files.size()!=1) { - - error_dialog->set_text(TTR("Only one file is required for large texture.")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - - } - String dst_file = dst_path; - //dst_file=dst_file.basename()+".tex"; - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - //imd->set_editor(); - for(int i=0;i<files.size();i++) { - imd->add_source(EditorImportPlugin::validate_source_path(files[i])); - } - imd->set_option("format",texture_options->get_format()); - imd->set_option("flags",texture_options->get_flags()); - imd->set_option("quality",texture_options->get_quality()); - imd->set_option("atlas",false); - imd->set_option("large",true); - imd->set_option("large_cell_size",int(size->get_value())); - imd->set_option("crop",crop_source->is_pressed()); - imd->set_option("mode",mode); - - Error err = plugin->import(dst_file,imd); - if (err) { - - error_dialog->set_text(TTR("Error importing:")+" "+dst_file.get_file()); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - - } - } else { - - - for(int i=0;i<files.size();i++) { - - String dst_file = dst_path.plus_file(files[i].get_file()); - dst_file=dst_file.get_basename()+".tex"; - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - //imd->set_editor(); - imd->add_source(EditorImportPlugin::validate_source_path(files[i])); - imd->set_option("format",texture_options->get_format()); - imd->set_option("flags",texture_options->get_flags()); - imd->set_option("quality",texture_options->get_quality()); - imd->set_option("atlas",false); - imd->set_option("large",false); - imd->set_option("mode",mode); - - Error err = plugin->import(dst_file,imd); - if (err) { - - error_dialog->set_text(TTR("Error importing:")+" "+dst_file.get_file()); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - - } - } - } - - hide(); -} - -void EditorTextureImportDialog::_browse() { - - file_select->popup_centered_ratio(); -} - -void EditorTextureImportDialog::_browse_target() { - - if (mode==EditorTextureImportPlugin::MODE_ATLAS || mode==EditorTextureImportPlugin::MODE_LARGE) { - save_file_select->popup_centered_ratio(); - } else { - save_select->popup_centered_ratio(); - } - -} - - -void EditorTextureImportDialog::popup_import(const String& p_from) { - - popup_centered(Size2(600,500)*EDSCALE); - if (p_from!="") { - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_from); - ERR_FAIL_COND(!rimd.is_valid()); - - if (rimd->has_option("mode")) { - //new imported stuff uses this option - _mode_changed(rimd->get_option("mode")); - } else { - //this one is for compatibility, will have to guess it - if (rimd->has_option("atlas") && rimd->get_option("atlas")) { - _mode_changed(EditorTextureImportPlugin::MODE_ATLAS); - } else if (rimd->has_option("large") && rimd->get_option("large")) { - _mode_changed(EditorTextureImportPlugin::MODE_LARGE); - } else { - //guess by usage of mipmaps..? - _mode_changed(EditorTextureImportPlugin::MODE_TEXTURE_2D); - } - - } - - if (mode==EditorTextureImportPlugin::MODE_ATLAS || mode==EditorTextureImportPlugin::MODE_LARGE) - save_path->set_text(p_from); - else - save_path->set_text(p_from.get_base_dir()); - - texture_options->set_format(EditorTextureImportPlugin::ImageFormat(int(rimd->get_option("format")))); - texture_options->set_flags(rimd->get_option("flags")); - texture_options->set_quality(rimd->get_option("quality")); - String src = ""; - for(int i=0;i<rimd->get_source_count();i++) { - if (i>0) - src+=","; - src+=EditorImportPlugin::expand_source_path(rimd->get_source_path(i)); - } - import_path->set_text(src); - } -} - - -void EditorTextureImportDialog::_notification(int p_what) { - - - if (p_what==NOTIFICATION_ENTER_TREE) { - - - List<String> extensions; - ImageLoader::get_recognized_extensions(&extensions); - //ResourceLoader::get_recognized_extensions_for_type("PackedTexture",&extensions); - file_select->clear_filters(); - for(int i=0;i<extensions.size();i++) { - - file_select->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper()); - } - } -} - -Error EditorTextureImportDialog::import(const String& p_from, const String& p_to, const String& p_preset) { - - - import_path->set_text(p_from); - save_path->set_text(p_to); - _import(); - - return OK; -} - -void EditorTextureImportDialog::_mode_changed(int p_mode) { - - mode = EditorTextureImportPlugin::Mode(p_mode); - - for(int i=0;i<EditorTextureImportPlugin::MODE_MAX;i++) { - mode_check[i]->set_pressed(i==mode); - } - - if (p_mode==EditorTextureImportPlugin::MODE_ATLAS) { - - size_label->set_text(TTR("Max Texture Size:")); - size->set_value(2048); - crop_source->show(); - size_label->show(); - size->show(); - - texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA|EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS|EditorTextureImportPlugin::IMAGE_FLAG_FILTER); - texture_options->set_quality(0.7); - texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY); - set_title(TTR("Import Textures for Atlas (2D)")); - - } else { - crop_source->hide(); - } - - - if (p_mode==EditorTextureImportPlugin::MODE_LARGE) { - - size_label->set_text(TTR("Cell Size:")); - size->set_value(256); - size_label->show(); - size->show(); - - file_select->set_mode(EditorFileDialog::MODE_OPEN_FILE); - save_file_select->add_filter("*.largetex;"+TTR("Large Texture")); - - texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA|EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS|EditorTextureImportPlugin::IMAGE_FLAG_FILTER); - texture_options->set_quality(0.7); - texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS); - set_title(TTR("Import Large Textures (2D)")); - source_label->set_text(TTR("Source Texture")); - - } else { - file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES); - save_file_select->add_filter("*.tex;"+TTR("Base Atlas Texture")); - source_label->set_text(TTR("Source Texture(s)")); - } - - if (p_mode==EditorTextureImportPlugin::MODE_TEXTURE_2D) { - - size_label->hide(); - size->hide(); - - texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS|EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA|EditorTextureImportPlugin::IMAGE_FLAG_FILTER); - texture_options->set_quality(0.7); - texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY); - notice_for_2d->show(); - set_title(TTR("Import Textures for 2D")); - - } else { - notice_for_2d->hide(); - } - - if (p_mode==EditorTextureImportPlugin::MODE_TEXTURE_3D) { - - size_label->hide(); - size->hide(); - //texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_); - //texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS); - texture_options->set_flags(EditorTextureImportPlugin::IMAGE_FLAG_FIX_BORDER_ALPHA|EditorTextureImportPlugin::IMAGE_FLAG_FILTER|EditorTextureImportPlugin::IMAGE_FLAG_REPEAT); - texture_options->set_format(EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM); - set_title(TTR("Import Textures for 3D")); - } -} - -void EditorTextureImportDialog::_bind_methods() { - - - ClassDB::bind_method("_choose_files",&EditorTextureImportDialog::_choose_files); - ClassDB::bind_method("_choose_file",&EditorTextureImportDialog::_choose_file); - ClassDB::bind_method("_choose_save_dir",&EditorTextureImportDialog::_choose_save_dir); - ClassDB::bind_method("_import",&EditorTextureImportDialog::_import); - ClassDB::bind_method("_browse",&EditorTextureImportDialog::_browse); - ClassDB::bind_method("_browse_target",&EditorTextureImportDialog::_browse_target); - ClassDB::bind_method("_mode_changed",&EditorTextureImportDialog::_mode_changed); - //ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) ); -} - -EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* p_plugin) { - - - - - - plugin=p_plugin; - set_title(TTR("Import Textures")); - - mode_hb = memnew( HBoxContainer ); - add_child(mode_hb); - //set_child_rect(mode_hb); - - VBoxContainer *vbcg = memnew( VBoxContainer); - - - mode_hb->add_child(vbcg); - mode_hb->add_constant_override("separation",15); - VBoxContainer *bg = memnew( VBoxContainer ); - vbcg->add_margin_child("Import Mode",bg); - - for(int i=0;i<EditorTextureImportPlugin::MODE_MAX;i++) { - String mode_name[EditorTextureImportPlugin::MODE_MAX]={ - TTR("2D Texture"), - TTR("3D Texture"), - TTR("Atlas Texture"), - TTR("Large Texture") - }; - - - mode_check[i]=memnew(CheckBox); - bg->add_child(mode_check[i]); - mode_check[i]->set_text(mode_name[i]); - mode_check[i]->connect("pressed",this,"_mode_changed",varray(i)); - } - - VBoxContainer *vbc = memnew(VBoxContainer); - mode_hb->add_child(vbc); - vbc->set_h_size_flags(SIZE_EXPAND_FILL); - vbc->add_constant_override("separation",4); - - notice_for_2d = memnew( Label ); - notice_for_2d->set_text(TTR("NOTICE: Importing 2D textures is not mandatory. Just copy png/jpg files to the project.")); - //notice_for_2d->set_custom_minimum_size(Size2(0,50)); - notice_for_2d->set_autowrap(true); - notice_for_2d->hide(); - vbcg->add_child(notice_for_2d); - notice_for_2d->set_v_size_flags(SIZE_EXPAND_FILL); - notice_for_2d->set_valign(Label::VALIGN_BOTTOM); - - VBoxContainer *source_vb=memnew(VBoxContainer); - MarginContainer *source_mc = vbc->add_margin_child(TTR("Source Texture(s):"),source_vb); - - source_label = Object::cast_to<Label>(vbc->get_child(source_mc->get_index()-1)); - - HBoxContainer *hbc = memnew( HBoxContainer ); - source_vb->add_child(hbc); - - import_path = memnew( LineEdit ); - import_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(import_path); - crop_source = memnew( CheckButton ); - crop_source->set_pressed(true); - source_vb->add_child(crop_source); - crop_source->set_text(TTR("Crop empty space.")); - - - Button * import_choose = memnew( Button ); - import_choose->set_text(" .. "); - hbc->add_child(import_choose); - - import_choose->connect("pressed", this,"_browse"); - - hbc = memnew( HBoxContainer ); - vbc->add_margin_child(TTR("Target Path:"),hbc); - - size = memnew( SpinBox ); - size->set_min(128); - size->set_max(16384); - - - size->set_value(256); - size_mc=vbc->add_margin_child(TTR("Cell Size:"),size); - size_label=Object::cast_to<Label>(vbc->get_child(size_mc->get_index()-1)); - - - save_path = memnew( LineEdit ); - save_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(save_path); - - Button * save_choose = memnew( Button ); - save_choose->set_text(" .. "); - hbc->add_child(save_choose); - - save_choose->connect("pressed", this,"_browse_target"); - - file_select = memnew(EditorFileDialog); - file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - add_child(file_select); - - file_select->connect("files_selected", this,"_choose_files"); - file_select->connect("file_selected", this,"_choose_file"); - - save_file_select = memnew(EditorFileDialog); - save_file_select->set_access(EditorFileDialog::ACCESS_RESOURCES); - add_child(save_file_select); - save_file_select->set_mode(EditorFileDialog::MODE_SAVE_FILE); - save_file_select->clear_filters(); - - save_file_select->connect("file_selected", this,"_choose_save_dir"); - - save_select = memnew( EditorDirDialog ); - add_child(save_select); - - //save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR); - save_select->connect("dir_selected", this,"_choose_save_dir"); - - get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text(TTR("Import")); - - //move stuff up - /* - for(int i=0;i<4;i++) - vbc->move_child( vbc->get_child( vbc->get_child_count() -1), 0); - */ - - error_dialog = memnew ( ConfirmationDialog ); - add_child(error_dialog); - error_dialog->get_ok()->set_text(TTR("Accept")); - //error_dialog->get_cancel()->hide(); - - set_hide_on_ok(false); - - texture_options = memnew( EditorImportTextureOptions ); - vbc->add_child(texture_options); - texture_options->set_v_size_flags(SIZE_EXPAND_FILL); - - _mode_changed(EditorTextureImportPlugin::MODE_TEXTURE_3D); - - - //GLOBAL_DEF("import/shared_textures","res://"); - //Globals::get_singleton()->set_custom_property_info("import/shared_textures",PropertyInfo(Variant::STRING,"import/shared_textures",PROPERTY_HINT_DIR)); - - -} - - - -/////////////////////////////////////////////////////////// - - -String EditorTextureImportPlugin::get_name() const { - - return "texture"; -#if 0 //old names, kept for compatibility reference - switch(mode) { - case MODE_TEXTURE_2D: { - - return "texture_2d"; - } break; - case MODE_TEXTURE_3D: { - - return "texture_3d"; - - } break; - case MODE_ATLAS: { - - return "texture_atlas"; - } break; - case MODE_LARGE: { - - return "texture_large"; - } break; - - } - - - return ""; -#endif -} - -String EditorTextureImportPlugin::get_visible_name() const { - - return TTR("Texture"); - -} -void EditorTextureImportPlugin::import_dialog(const String& p_from) { - - dialog->popup_import(p_from); -} - -void EditorTextureImportPlugin::compress_image(EditorExportPlatform::ImageCompression p_mode,Image& image,bool p_smaller) { - - - switch(p_mode) { - case EditorExportPlatform::IMAGE_COMPRESSION_NONE: { - - //do absolutely nothing - - } break; - case EditorExportPlatform::IMAGE_COMPRESSION_BC: { - - - // for maximum compatibility, BC shall always use mipmaps and be PO2 - image.resize_to_po2(); - if (!image.has_mipmaps()) - image.generate_mipmaps(); - - image.compress(Image::COMPRESS_S3TC); - /* - if (has_alpha) { - - if (flags&IMAGE_FLAG_ALPHA_BIT) { - image.convert(Image::FORMAT_DXT5); - } else { - image.convert(Image::FORMAT_DXT3); - } - } else { - - image.convert(Image::FORMAT_DXT1); - }*/ - - - } break; - case EditorExportPlatform::IMAGE_COMPRESSION_PVRTC: - case EditorExportPlatform::IMAGE_COMPRESSION_PVRTC_SQUARE: { - - // for maximum compatibility (hi apple!), PVRT shall always - // use mipmaps, be PO2 and square - - if (!image.has_mipmaps()) - image.generate_mipmaps(); - image.resize_to_po2(true); - - if (p_smaller) { - - image.compress(Image::COMPRESS_PVRTC2); - //image.convert(has_alpha ? Image::FORMAT_PVRTC2A : Image::FORMAT_PVRTC2); - } else { - image.compress(Image::COMPRESS_PVRTC4); - //image.convert(has_alpha ? Image::FORMAT_PVRTC4A : Image::FORMAT_PVRTC4); - } - - } break; - case EditorExportPlatform::IMAGE_COMPRESSION_ETC1: { - - image.resize_to_po2(); //square or not? - if (!image.has_mipmaps()) - image.generate_mipmaps(); - if (!image.detect_alpha()) { - //ETC1 is only opaque - image.compress(Image::COMPRESS_ETC); - } - - } break; - case EditorExportPlatform::IMAGE_COMPRESSION_ETC2: { - - - } break; - } - - -} - -Error EditorTextureImportPlugin::import(const String& p_path, const Ref<ResourceImportMetadata>& p_from) { - - - return import2(p_path,p_from,EditorExportPlatform::IMAGE_COMPRESSION_BC,false); -} - - -Error EditorTextureImportPlugin::_process_texture_data(Ref<ImageTexture> &texture,int format, float quality,int flags,EditorExportPlatform::ImageCompression p_compr,int tex_flags,float shrink) { - - - if (format==IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS || format==IMAGE_FORMAT_COMPRESS_DISK_LOSSY) { - - Image image=texture->get_data(); - ERR_FAIL_COND_V(image.empty(),ERR_INVALID_DATA); - - bool has_alpha=image.detect_alpha(); - if (!has_alpha && image.get_format()==Image::FORMAT_RGBA8) { - - image.convert(Image::FORMAT_RGB8); - - } - - if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { - - image.fix_alpha_edges(); - } - - if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_PREMULT_ALPHA) { - - image.premultiply_alpha(); - } - - if (flags&IMAGE_FLAG_CONVERT_NORMAL_TO_XY) { - image.normalmap_to_xy(); - } - - /* - if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { - - image.srgb_to_linear(); - } - */ - - if (shrink>1) { - - int orig_w=image.get_width(); - int orig_h=image.get_height(); - image.resize(orig_w/shrink,orig_h/shrink,Image::INTERPOLATE_CUBIC); - texture->create_from_image(image,tex_flags); - texture->set_size_override(Size2(orig_w,orig_h)); - - - } else { - - texture->create_from_image(image,tex_flags); - } - - - if (format==IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS) { - texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSLESS); - } else { - texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY); - } - - - - texture->set_lossy_storage_quality(quality); - - - } else { - - - Image image=texture->get_data(); - ERR_FAIL_COND_V(image.empty(),ERR_INVALID_DATA); - - - bool has_alpha=image.detect_alpha(); - if (!has_alpha && image.get_format()==Image::FORMAT_RGBA8) { - - image.convert(Image::FORMAT_RGB8); - - } - - if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { - - image.fix_alpha_edges(); - } - - if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_PREMULT_ALPHA) { - - image.premultiply_alpha(); - } - - if (flags&IMAGE_FLAG_CONVERT_NORMAL_TO_XY) { - image.normalmap_to_xy(); - } - - /* - if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { - - print_line("CONVERT BECAUSE: "+itos(flags)); - image.srgb_to_linear(); - } - */ - - int orig_w=image.get_width(); - int orig_h=image.get_height(); - - if (shrink>1) { - image.resize(orig_w/shrink,orig_h/shrink,Image::INTERPOLATE_CUBIC); - texture->create_from_image(image,tex_flags); - texture->set_size_override(Size2(orig_w,orig_h)); - } - - if (!(flags&IMAGE_FLAG_NO_MIPMAPS)) { - image.generate_mipmaps(); - - } - - if (format!=IMAGE_FORMAT_UNCOMPRESSED) { - - compress_image(p_compr,image,flags&IMAGE_FLAG_COMPRESS_EXTRA); - } - - - texture->create_from_image(image,tex_flags); - - - if (shrink>1 || (format!=IMAGE_FORMAT_UNCOMPRESSED && (image.get_width()!=orig_w || image.get_height()!=orig_h))) { - texture->set_size_override(Size2(orig_w,orig_h)); - } - - //uint32_t save_flags=ResourceSaver::FLAG_COMPRESS; - } - - return OK; -} - - -Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<ResourceImportMetadata>& p_from,EditorExportPlatform::ImageCompression p_compr, bool p_external){ - - - - ERR_FAIL_COND_V(p_from->get_source_count()==0,ERR_INVALID_PARAMETER); - - Ref<ResourceImportMetadata> from=p_from; - - Ref<ImageTexture> texture; - Vector<Ref<AtlasTexture> > atlases; - bool atlas = from->get_option("atlas"); - bool large = from->get_option("large"); - - int flags=from->get_option("flags"); - int format=from->get_option("format"); - float quality=from->get_option("quality"); - - uint32_t tex_flags=0; - - if (flags&EditorTextureImportPlugin::IMAGE_FLAG_REPEAT) - tex_flags|=Texture::FLAG_REPEAT; - if (flags&EditorTextureImportPlugin::IMAGE_FLAG_FILTER) - tex_flags|=Texture::FLAG_FILTER; - if (!(flags&EditorTextureImportPlugin::IMAGE_FLAG_NO_MIPMAPS)) - tex_flags|=Texture::FLAG_MIPMAPS; - if (flags&EditorTextureImportPlugin::IMAGE_FLAG_CONVERT_TO_LINEAR) - tex_flags|=Texture::FLAG_CONVERT_TO_LINEAR; - if (flags&EditorTextureImportPlugin::IMAGE_FLAG_USE_ANISOTROPY) - tex_flags|=Texture::FLAG_ANISOTROPIC_FILTER; - - print_line("path: "+p_path+" flags: "+itos(tex_flags)); - float shrink=1; - if (from->has_option("shrink")) - shrink=from->get_option("shrink"); - - if (large) { - ERR_FAIL_COND_V(from->get_source_count()!=1,ERR_INVALID_PARAMETER); - - String src_path = EditorImportPlugin::expand_source_path(from->get_source_path(0)); - - - int cell_size=from->get_option("large_cell_size"); - ERR_FAIL_COND_V(cell_size<128 || cell_size>16384,ERR_CANT_OPEN); - - EditorProgress pg("largetex",TTR("Import Large Texture"),3); - - pg.step(TTR("Load Source Image"),0); - Image img; - Error err = ImageLoader::load_image(src_path,&img); - if (err) { - return err; - } - - pg.step(TTR("Slicing"),1); - - Map<Vector2,Image> pieces; - for(int i=0;i<img.get_width();i+=cell_size) { - int w = MIN(img.get_width()-i,cell_size); - for(int j=0;j<img.get_height();j+=cell_size) { - int h = MIN(img.get_height()-j,cell_size); - - Image piece(w,h,0,img.get_format()); - piece.blit_rect(img,Rect2(i,j,w,h),Point2(0,0)); - if (!piece.is_invisible()) { - pieces[Vector2(i,j)]=piece; - //print_line("ADDING PIECE AT "+Vector2(i,j)); - } - } - } - - Ref<LargeTexture> existing; - if (ResourceCache::has(p_path)) { - existing = ResourceCache::get(p_path); - } - - if (existing.is_valid()) { - existing->clear(); - } else { - existing = Ref<LargeTexture>(memnew( LargeTexture )); - } - - existing->set_size(Size2(img.get_width(),img.get_height())); - pg.step(TTR("Inserting"),2); - - for (Map<Vector2,Image>::Element *E=pieces.front();E;E=E->next()) { - - Ref<ImageTexture> imgtex = Ref<ImageTexture>( memnew( ImageTexture ) ); - imgtex->create_from_image(E->get(),tex_flags); - _process_texture_data(imgtex,format,quality,flags,p_compr,tex_flags,shrink); - existing->add_piece(E->key(),imgtex); - } - - if (!p_external) { - from->set_editor(get_name()); - from->set_source_md5(0,FileAccess::get_md5(src_path)); - existing->set_path(p_path); - existing->set_import_metadata(from); - } - pg.step(TTR("Saving"),3); - - err = ResourceSaver::save(p_path,existing); - if (err!=OK) { - EditorNode::add_io_error(TTR("Couldn't save large texture:")+" "+p_path); - return err; - } - - return OK; - - - } else if (atlas) { - - //prepare atlas! - Vector< Image > sources; - Vector< Image > tsources; - bool alpha=false; - bool crop = from->get_option("crop"); - - EditorProgress ep("make_atlas",TTR("Build Atlas For:")+" "+p_path.get_file(),from->get_source_count()+3); - - print_line("sources: "+itos(from->get_source_count())); - - for(int i=0;i<from->get_source_count();i++) { - - String path = EditorImportPlugin::expand_source_path(from->get_source_path(i)); - String md5 = FileAccess::get_md5(path); - from->set_source_md5(i,FileAccess::get_md5(path)); - ep.step(TTR("Loading Image:")+" "+path,i); - print_line("source path: "+path+" md5 "+md5); - Image src; - Error err = ImageLoader::load_image(path,&src); - if (err) { - EditorNode::add_io_error(TTR("Couldn't load image:")+" "+path); - return err; - } - - if (src.detect_alpha()) - alpha=true; - - tsources.push_back(src); - } - ep.step(TTR("Converting Images"),sources.size()); - - - Map<uint64_t,int> source_md5; - Map<int,List<int> > source_map; - - for(int i=0;i<tsources.size();i++) { - - Image src = tsources[i]; - - if (alpha) { - src.convert(Image::FORMAT_RGBA8); - } else { - src.convert(Image::FORMAT_RGB8); - } - - PoolVector<uint8_t> data = src.get_data(); - MD5_CTX md5; - PoolVector<uint8_t>::Read r=data.read(); - MD5Init(&md5); - int len=data.size(); - for(int j=0;j<len;j++) { - uint8_t b = r[j]; - b>>=2; //to aid in comparing - MD5Update(&md5,(unsigned char*)&b,1); - } - MD5Final(&md5); - uint64_t *cmp = (uint64_t*)md5.digest; //less bits, but still useful for this - - tsources[i]=Image(); //clear - - if (source_md5.has(*cmp)) { - int sidx=source_md5[*cmp]; - source_map[sidx].push_back(i); - print_line("REUSING "+from->get_source_path(i)); - - } else { - int sidx=sources.size(); - source_md5[*cmp]=sidx; - sources.push_back(src); - List<int> sm; - sm.push_back(i); - source_map[sidx]=sm; - - } - - - } - - //texturepacker is not really good for optimizing, so.. - //will at some point likely replace with my own - //first, will find the nearest to a square packing - int border=1; - - Vector<Size2i> src_sizes; - Vector<Rect2> crops; - - ep.step(TTR("Cropping Images"),sources.size()+1); - - for(int j=0;j<sources.size();j++) { - - Size2i s; - if (crop) { - Rect2 crop = sources[j].get_used_rect(); - print_line("CROP: "+crop); - s=crop.size; - crops.push_back(crop); - } else { - - s=Size2i(sources[j].get_width(),sources[j].get_height()); - } - s+=Size2i(border*2,border*2); - src_sizes.push_back(s); //add a line to constraint width - } - - Vector<Point2i> dst_positions; - Size2i dst_size; - EditorAtlas::fit(src_sizes,dst_positions,dst_size); - - print_line("size that worked: "+itos(dst_size.width)+","+itos(dst_size.height)); - - ep.step(TTR("Blitting Images"),sources.size()+2); - - bool blit_to_po2=tex_flags&Texture::FLAG_MIPMAPS; - int atlas_w=dst_size.width; - int atlas_h=dst_size.height; - if (blit_to_po2) { - atlas_w=next_power_of_2(dst_size.width); - atlas_h=next_power_of_2(dst_size.height); - } - Image atlas; - atlas.create(atlas_w,atlas_h,0,alpha?Image::FORMAT_RGBA8:Image::FORMAT_RGB8); - - - atlases.resize(from->get_source_count()); - - for(int i=0;i<sources.size();i++) { - - int x=dst_positions[i].x; - int y=dst_positions[i].y; - - Size2 sz = Size2(sources[i].get_width(),sources[i].get_height()); - - Rect2 region; - Rect2 margin; - - if (crop && sz!=crops[i].size) { - Rect2 rect = crops[i]; - rect.size=sz-rect.size; - region=Rect2(x+border,y+border,crops[i].size.width,crops[i].size.height); - margin=rect; - atlas.blit_rect(sources[i],crops[i],Point2(x+border,y+border)); - } else { - region=Rect2(x+border,y+border,sz.x,sz.y); - atlas.blit_rect(sources[i],Rect2(0,0,sources[i].get_width(),sources[i].get_height()),Point2(x+border,y+border)); - } - - ERR_CONTINUE( !source_map.has(i) ); - for (List<int>::Element *E=source_map[i].front();E;E=E->next()) { - - String apath; - String spath = from->get_source_path(E->get()).get_file(); - - if (p_external) { - apath = p_path.get_base_dir().plus_file(spath.get_basename()+"."+from->get_source_path(E->get()).md5_text()+".atlastex"); - } else { - apath = p_path.get_base_dir().plus_file(spath.get_basename()+".atlastex"); - } - - Ref<AtlasTexture> at; - - if (ResourceCache::has(apath)) { - - at = Ref<AtlasTexture>( Object::cast_to<AtlasTexture>(ResourceCache::get(apath)) ); - } else { - - at = Ref<AtlasTexture>( memnew( AtlasTexture ) ); - - } - at->set_region(region); - at->set_margin(margin); - at->set_path(apath); - atlases[E->get()]=at; - - } - } - if (ResourceCache::has(p_path)) { - texture = Ref<ImageTexture> ( Object::cast_to<ImageTexture>(ResourceCache::get(p_path)) ); - } else { - texture = Ref<ImageTexture>( memnew( ImageTexture ) ); - } - texture->create_from_image(atlas,tex_flags); - - } else { - ERR_FAIL_COND_V(from->get_source_count()!=1,ERR_INVALID_PARAMETER); - - String src_path = EditorImportPlugin::expand_source_path(from->get_source_path(0)); - - if (ResourceCache::has(p_path)) { - Resource *r = ResourceCache::get(p_path); - - texture = Ref<ImageTexture> ( Object::cast_to<ImageTexture>(r) ); - - Image img; - Error err = img.load(src_path); - ERR_FAIL_COND_V(err!=OK,ERR_CANT_OPEN); - texture->create_from_image(img); - } else { - texture=ResourceLoader::load(src_path,"ImageTexture"); - } - - ERR_FAIL_COND_V(texture.is_null(),ERR_CANT_OPEN); - if (!p_external) - from->set_source_md5(0,FileAccess::get_md5(src_path)); - - } - - - - if (!p_external) { - from->set_editor(get_name()); - texture->set_path(p_path); - texture->set_import_metadata(from); - } - - if (atlas) { - - if (p_external) { - //used by exporter - Array rects; - for(int i=0;i<atlases.size();i++) { - rects.push_back(atlases[i]->get_region()); - rects.push_back(atlases[i]->get_margin()); - } - from->set_option("rects",rects); - - } else { - //used by importer - for(int i=0;i<atlases.size();i++) { - String apath = atlases[i]->get_path(); - atlases[i]->set_atlas(texture); - Error err = ResourceSaver::save(apath,atlases[i]); - if (err) { - EditorNode::add_io_error(TTR("Couldn't save atlas image:")+" "+apath); - return err; - } - //from->set_source_md5(i,FileAccess::get_md5(apath)); - } - } - } - - bool compress=false; -#if 1 - - _process_texture_data(texture,format,quality,flags,p_compr,tex_flags,shrink); -#else - if (format==IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS || format==IMAGE_FORMAT_COMPRESS_DISK_LOSSY) { - - Image image=texture->get_data(); - ERR_FAIL_COND_V(image.empty(),ERR_INVALID_DATA); - - bool has_alpha=image.detect_alpha(); - if (!has_alpha && image.get_format()==Image::FORMAT_RGBA8) { - - image.convert(Image::FORMAT_RGB8); - - } - - if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { - - image.fix_alpha_edges(); - } - - if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_PREMULT_ALPHA) { - - image.premultiply_alpha(); - } - - if (flags&IMAGE_FLAG_CONVERT_NORMAL_TO_XY) { - image.normalmap_to_xy(); - } - - /* - if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { - - image.srgb_to_linear(); - } - */ - - if (shrink>1) { - - int orig_w=image.get_width(); - int orig_h=image.get_height(); - image.resize(orig_w/shrink,orig_h/shrink); - texture->create_from_image(image,tex_flags); - texture->set_size_override(Size2(orig_w,orig_h)); - - - } else { - - texture->create_from_image(image,tex_flags); - } - - - if (format==IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS) { - texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSLESS); - } else { - texture->set_storage(ImageTexture::STORAGE_COMPRESS_LOSSY); - } - - - - texture->set_lossy_storage_quality(quality); - - - } else { - - - Image image=texture->get_data(); - ERR_FAIL_COND_V(image.empty(),ERR_INVALID_DATA); - - - bool has_alpha=image.detect_alpha(); - if (!has_alpha && image.get_format()==Image::FORMAT_RGBA8) { - - image.convert(Image::FORMAT_RGB8); - - } - - if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_FIX_BORDER_ALPHA) { - - image.fix_alpha_edges(); - } - - if (image.get_format()==Image::FORMAT_RGBA8 && flags&IMAGE_FLAG_PREMULT_ALPHA) { - - image.premultiply_alpha(); - } - - if (flags&IMAGE_FLAG_CONVERT_NORMAL_TO_XY) { - image.normalmap_to_xy(); - } - - /* - if ((image.get_format()==Image::FORMAT_RGB8 || image.get_format()==Image::FORMAT_RGBA8) && flags&IMAGE_FLAG_CONVERT_TO_LINEAR) { - - print_line("CONVERT BECAUSE: "+itos(flags)); - image.srgb_to_linear(); - } - */ - - int orig_w=image.get_width(); - int orig_h=image.get_height(); - - if (shrink>1) { - image.resize(orig_w/shrink,orig_h/shrink); - texture->create_from_image(image,tex_flags); - texture->set_size_override(Size2(orig_w,orig_h)); - } - - if (!(flags&IMAGE_FLAG_NO_MIPMAPS)) { - image.generate_mipmaps(); - - } - - if (format!=IMAGE_FORMAT_UNCOMPRESSED) { - - compress_image(p_compr,image,flags&IMAGE_FLAG_COMPRESS_EXTRA); - } - - - texture->create_from_image(image,tex_flags); - - - if (shrink>1 || (format!=IMAGE_FORMAT_UNCOMPRESSED && (image.get_width()!=orig_w || image.get_height()!=orig_h))) { - texture->set_size_override(Size2(orig_w,orig_h)); - } - - compress=true; - - - } -#endif - uint32_t save_flags=0; - if (compress) - save_flags=ResourceSaver::FLAG_COMPRESS; - - Error err = ResourceSaver::save(p_path,texture,save_flags); - if (err!=OK) { - EditorNode::add_io_error(TTR("Couldn't save converted texture:")+" "+p_path); - return err; - } - - return OK; -} - -Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, const Ref<EditorExportPlatform> &p_platform) { - - - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path); - - if (rimd.is_null()) { - - StringName group = EditorImportExport::get_singleton()->image_get_export_group(p_path); - - if (group!=StringName()) { - //handled by export group - rimd = Ref<ResourceImportMetadata>( memnew( ResourceImportMetadata ) ); - - int group_format=0; - float group_lossy_quality=EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(group); - int group_shrink=EditorImportExport::get_singleton()->image_export_group_get_shrink(group); - group_shrink*=EditorImportExport::get_singleton()->get_export_image_shrink(); - - switch(EditorImportExport::get_singleton()->image_export_group_get_image_action(group)) { - case EditorImportExport::IMAGE_ACTION_NONE: { - - switch(EditorImportExport::get_singleton()->get_export_image_action()) { - case EditorImportExport::IMAGE_ACTION_NONE: { - - group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS; //? - - } break; //use default - case EditorImportExport::IMAGE_ACTION_COMPRESS_DISK: { - group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY; - } break; //use default - case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: { - group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM; - } break; //use default - } - - group_lossy_quality=EditorImportExport::get_singleton()->get_export_image_quality(); - - } break; //use default - case EditorImportExport::IMAGE_ACTION_COMPRESS_DISK: { - group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_DISK_LOSSY; - } break; //use default - case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: { - group_format=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM; - } break; //use default - case EditorImportExport::IMAGE_ACTION_KEEP: { - return Vector<uint8_t>(); - } break; //use default - } - - String validated_path=EditorImportPlugin::validate_source_path(p_path); - - int flags=texture_flags_to_export_flags(ResourceFormatLoaderImage::load_image_flags(validated_path)); - flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; - - print_line("group format"+itos(group_format)); - rimd->set_option("format",group_format); - rimd->set_option("flags",flags); - rimd->set_option("quality",group_lossy_quality); - rimd->set_option("atlas",false); - rimd->set_option("shrink",group_shrink); - rimd->add_source(validated_path,FileAccess::get_md5(p_path)); - - } else if (EditorImportExport::get_singleton()->get_image_formats().has(p_path.get_extension().to_lower()) && EditorImportExport::get_singleton()->get_export_image_action()!=EditorImportExport::IMAGE_ACTION_NONE) { - //handled by general image export settings - - rimd = Ref<ResourceImportMetadata>( memnew( ResourceImportMetadata ) ); - - switch(EditorImportExport::get_singleton()->get_export_image_action()) { - case EditorImportExport::IMAGE_ACTION_COMPRESS_DISK: rimd->set_option("format",IMAGE_FORMAT_COMPRESS_DISK_LOSSY); break; - case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: rimd->set_option("format",IMAGE_FORMAT_COMPRESS_RAM); break; - } - - String validated_path=EditorImportPlugin::validate_source_path(p_path); - - int flags=texture_flags_to_export_flags(ResourceFormatLoaderImage::load_image_flags(validated_path)); - flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; - - rimd->set_option("shrink",EditorImportExport::get_singleton()->get_export_image_shrink()); - rimd->set_option("flags",flags); - rimd->set_option("quality",EditorImportExport::get_singleton()->get_export_image_quality()); - rimd->set_option("atlas",false); - rimd->add_source(validated_path,FileAccess::get_md5(p_path)); - - } else { - return Vector<uint8_t>(); - } - } - - int fmt = rimd->get_option("format"); - - if (fmt!=IMAGE_FORMAT_COMPRESS_RAM && fmt!=IMAGE_FORMAT_COMPRESS_DISK_LOSSY) { - print_line("no compress ram or lossy"); - return Vector<uint8_t>(); //pointless to do anything, since no need to reconvert - } - - uint32_t flags = rimd->get_option("flags"); - uint8_t shrink = rimd->has_option("shrink") ? rimd->get_option("shrink"): Variant(1); - uint8_t format = rimd->get_option("format"); - uint8_t comp = (format==EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM)?uint8_t(p_platform->get_image_compression()):uint8_t(255); - - MD5_CTX ctx; - uint8_t f4[4]; - encode_uint32(flags,&f4[0]); - MD5Init(&ctx); - String gp = ProjectSettings::get_singleton()->globalize_path(p_path); - CharString cs = gp.utf8(); - MD5Update(&ctx,(unsigned char*)cs.get_data(),cs.length()); - MD5Update(&ctx,f4,4); - MD5Update(&ctx,&format,1); - MD5Update(&ctx,&comp,1); - MD5Update(&ctx,&shrink,1); - MD5Final(&ctx); - - - - uint64_t sd=0; - String smd5; - - String md5 = String::md5(ctx.digest); - print_line(p_path+" MD5: "+md5+" FLAGS: "+itos(flags)); - - String tmp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/"); - - bool valid=false; - { - //if existing, make sure it's valid - FileAccessRef f = FileAccess::open(tmp_path+"imgexp-"+md5+".txt",FileAccess::READ); - if (f) { - - uint64_t d = f->get_line().strip_edges().to_int64(); - sd = FileAccess::get_modified_time(p_path); - - if (d==sd) { - valid=true; - } else { - String cmd5 = f->get_line().strip_edges(); - smd5 = FileAccess::get_md5(p_path); - if (cmd5==smd5) { - valid=true; - } - } - - - } - } - - if (!valid) { - //cache failed, convert - Error err = import2(tmp_path+"imgexp-"+md5+".tex",rimd,p_platform->get_image_compression(),true); - ERR_FAIL_COND_V(err!=OK,Vector<uint8_t>()); - FileAccessRef f = FileAccess::open(tmp_path+"imgexp-"+md5+".txt",FileAccess::WRITE); - - if (sd==0) - sd = FileAccess::get_modified_time(p_path); - if (smd5==String()) - smd5 = FileAccess::get_md5(p_path); - - f->store_line(String::num(sd)); - f->store_line(smd5); - f->store_line(gp); //source path for reference - } - - - Vector<uint8_t> ret; - FileAccessRef f = FileAccess::open(tmp_path+"imgexp-"+md5+".tex",FileAccess::READ); - ERR_FAIL_COND_V(!f,ret); - - ret.resize(f->get_len()); - f->get_buffer(ret.ptr(),ret.size()); - - return ret; -} - -uint32_t EditorTextureImportPlugin::texture_flags_to_export_flags(uint32_t p_tex_flags) const { - - uint32_t flags=0; - - if (!(p_tex_flags&Texture::FLAG_MIPMAPS)) { - flags|=IMAGE_FLAG_NO_MIPMAPS; - } - if (p_tex_flags&Texture::FLAG_REPEAT) { - flags|=IMAGE_FLAG_REPEAT; - } - if (p_tex_flags&Texture::FLAG_FILTER) { - flags|=IMAGE_FLAG_FILTER; - } - if (p_tex_flags&Texture::FLAG_ANISOTROPIC_FILTER) { - flags|=IMAGE_FLAG_USE_ANISOTROPY; - } - if (p_tex_flags&Texture::FLAG_CONVERT_TO_LINEAR) { - flags|=IMAGE_FLAG_CONVERT_TO_LINEAR; - } - /* // no correspondence yet - if (p_tex_flags&Texture::TEXTURE_FLAG_MIRRORED_REPEAT) { - flags|=; - }*/ - - return flags; -} - -void EditorTextureImportPlugin::import_from_drop(const Vector<String>& p_drop,const String& p_dest_path) { - - Vector<String> valid; - - List<String> valid_extensions; - ImageLoader::get_recognized_extensions(&valid_extensions); - for(int i=0;i<p_drop.size();i++) { - - String extension=p_drop[i].get_extension().to_lower(); - - for (List<String>::Element *E=valid_extensions.front();E;E=E->next()) { - - if (E->get()==extension) { - valid.push_back(p_drop[i]); - break; - } - } - } - - if (valid.size()) { - dialog->popup_import(); - dialog->setup_multiple_import_3d(valid,p_dest_path); - } -} - -void EditorTextureImportPlugin::reimport_multiple_files(const Vector<String>& p_list) { - - Vector<String> valid; - - - for(int i=0;i<p_list.size();i++) { - - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_list[i]); - String type = rimd->get_editor(); - if (type=="texture" || type.begins_with("texture_")) { - - if ((rimd->has_option("atlas") && rimd->get_option("atlas")) || (rimd->has_option("large") && rimd->get_option("large"))) { - continue; - } - - valid.push_back(p_list[i]); - } - } - - if (valid.size()) { - - dialog->popup_import(valid[0]); - - Vector<String> sources; - for(int i=0;i<valid.size();i++) { - int idx; - EditorFileSystemDirectory *efsd = EditorFileSystem::get_singleton()->find_file(valid[i],&idx); - if (efsd) { - for(int j=0;j<efsd->get_source_count(idx);j++) { - String file = expand_source_path(efsd->get_source_file(idx,j)); - if (sources.find(file)==-1) { - sources.push_back(file); - } - - } - } - } - - if (sources.size()) { - - dialog->add_sources_and_dest(sources,valid[0].get_base_dir()); - } - } -} - -bool EditorTextureImportPlugin::can_reimport_multiple_files() const { - - return true; - -} - - - -EditorTextureImportPlugin *EditorTextureImportPlugin::singleton=NULL; - -EditorTextureImportPlugin::EditorTextureImportPlugin(EditorNode *p_editor) { - - singleton=this; - editor=p_editor; - dialog = memnew( EditorTextureImportDialog(this) ); - editor->get_gui_base()->add_child(dialog); - -} - -//////////////////////////// - - - Vector<uint8_t> EditorTextureExportPlugin::custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) { - - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path); - - if (rimd.is_valid()) { - - if (rimd->get_editor()!="") { - int compression = rimd->get_option("format"); - if (compression!=EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM) - return Vector<uint8_t>(); //only useful for RAM compression to reconvert - Ref<EditorImportPlugin> pl = EditorImportExport::get_singleton()->get_import_plugin_by_name(rimd->get_editor()); - if (pl.is_valid()) { - Vector<uint8_t> ce = pl->custom_export(p_path,p_platform); - if (ce.size()) - return ce; - } - } - } else if (EditorImportExport::get_singleton()->image_get_export_group(p_path)) { - - - Ref<EditorImportPlugin> pl = EditorImportExport::get_singleton()->get_import_plugin_by_name("texture"); - if (pl.is_valid()) { - Vector<uint8_t> ce = pl->custom_export(p_path,p_platform); - if (ce.size()) { - p_path=p_path.get_basename()+".converted.tex"; - return ce; - } - } - - } else if (EditorImportExport::get_singleton()->get_export_image_action()!=EditorImportExport::IMAGE_ACTION_NONE){ - - String xt = p_path.get_extension().to_lower(); - if (EditorImportExport::get_singleton()->get_image_formats().has(xt)) { //should check for more I guess? - - Ref<EditorImportPlugin> pl = EditorImportExport::get_singleton()->get_import_plugin_by_name("texture"); - if (pl.is_valid()) { - Vector<uint8_t> ce = pl->custom_export(p_path,p_platform); - if (ce.size()) { - p_path=p_path.get_basename()+".converted.tex"; - return ce; - } - } - } - } - - return Vector<uint8_t>(); -} - -EditorTextureExportPlugin::EditorTextureExportPlugin() { - - -} -#endif diff --git a/editor/io_plugins/editor_texture_import_plugin.h b/editor/io_plugins/editor_texture_import_plugin.h deleted file mode 100644 index ea09227713..0000000000 --- a/editor/io_plugins/editor_texture_import_plugin.h +++ /dev/null @@ -1,175 +0,0 @@ -/*************************************************************************/ -/* editor_texture_import_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_TEXTURE_IMPORT_PLUGIN_H -#define EDITOR_TEXTURE_IMPORT_PLUGIN_H - -#if 0 -#include "editor/editor_dir_dialog.h" -#include "editor/editor_file_system.h" -#include "editor/editor_import_export.h" -#include "scene/gui/dialogs.h" -#include "scene/gui/file_dialog.h" -#include "scene/gui/label.h" -#include "scene/gui/line_edit.h" -#include "scene/gui/option_button.h" -#include "scene/gui/progress_bar.h" -#include "scene/gui/slider.h" -#include "scene/gui/spin_box.h" -#include "scene/gui/tree.h" - - - -class EditorNode; -class EditorTextureImportDialog; - -class EditorTextureImportPlugin : public EditorImportPlugin { - - GDCLASS(EditorTextureImportPlugin,EditorImportPlugin); -public: - - - enum Mode { - MODE_TEXTURE_2D, - MODE_TEXTURE_3D, - MODE_ATLAS, - MODE_LARGE, - MODE_MAX - }; - - - -private: - - EditorNode *editor; - EditorTextureImportDialog *dialog; - static EditorTextureImportPlugin *singleton; - //used by other importers such as mesh - - Error _process_texture_data(Ref<ImageTexture> &texture, int format, float quality, int flags,EditorExportPlatform::ImageCompression p_compr,int tex_flags,float shrink); - void compress_image(EditorExportPlatform::ImageCompression p_mode,Image& image,bool p_smaller); - - uint32_t texture_flags_to_export_flags(uint32_t p_tex_flags) const; -public: - - - static EditorTextureImportPlugin *get_singleton() { return singleton; } - - enum ImageFormat { - - IMAGE_FORMAT_UNCOMPRESSED, - IMAGE_FORMAT_COMPRESS_DISK_LOSSLESS, - IMAGE_FORMAT_COMPRESS_DISK_LOSSY, - IMAGE_FORMAT_COMPRESS_RAM, - }; - - enum ImageFlags { - - IMAGE_FLAG_STREAM_FORMAT=1, - IMAGE_FLAG_FIX_BORDER_ALPHA=2, - IMAGE_FLAG_ALPHA_BIT=4, //hint for compressions that use a bit for alpha - IMAGE_FLAG_COMPRESS_EXTRA=8, // used for pvrtc2 - IMAGE_FLAG_NO_MIPMAPS=16, //normal for 2D games - IMAGE_FLAG_REPEAT=32, //usually disabled in 2D - IMAGE_FLAG_FILTER=64, //almost always enabled - IMAGE_FLAG_PREMULT_ALPHA=128,//almost always enabled - IMAGE_FLAG_CONVERT_TO_LINEAR=256, //convert image to linear - IMAGE_FLAG_CONVERT_NORMAL_TO_XY=512, //convert image to linear - IMAGE_FLAG_USE_ANISOTROPY=1024, //convert image to linear - }; - - 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 Error import2(const String& p_path, const Ref<ResourceImportMetadata>& p_from,EditorExportPlatform::ImageCompression p_compr, bool p_external=false); - virtual Vector<uint8_t> custom_export(const String& p_path,const Ref<EditorExportPlatform> &p_platform); - - 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; - - EditorTextureImportPlugin(EditorNode* p_editor=NULL); -}; - - -class EditorTextureExportPlugin : public EditorExportPlugin { - - GDCLASS( EditorTextureExportPlugin, EditorExportPlugin); - - -public: - - virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform); - EditorTextureExportPlugin(); -}; - -class EditorImportTextureOptions : public VBoxContainer { - - GDCLASS( EditorImportTextureOptions, VBoxContainer ); - - - OptionButton *format; - VBoxContainer *quality_vb; - HSlider *quality; - Tree *flags; - Vector<TreeItem*> items; - - - bool updating; - - void _changedp(int p_value); - void _changed(); - - -protected: - static void _bind_methods(); - void _notification(int p_what); - -public: - - - - void set_format(EditorTextureImportPlugin::ImageFormat p_format); - EditorTextureImportPlugin::ImageFormat get_format() const; - - void set_flags(uint32_t p_flags); - uint32_t get_flags() const; - - void set_quality(float p_quality); - float get_quality() const; - - void show_2d_notice(); - - EditorImportTextureOptions(); - - -}; -#endif // EDITOR_TEXTURE_IMPORT_PLUGIN_H -#endif diff --git a/editor/io_plugins/editor_translation_import_plugin.cpp b/editor/io_plugins/editor_translation_import_plugin.cpp deleted file mode 100644 index 5b15b94006..0000000000 --- a/editor/io_plugins/editor_translation_import_plugin.cpp +++ /dev/null @@ -1,480 +0,0 @@ -/*************************************************************************/ -/* editor_translation_import_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "editor_translation_import_plugin.h" - -#if 0 -#include "editor/editor_dir_dialog.h" -#include "editor/editor_node.h" -#include "editor/property_editor.h" -#include "scene/gui/file_dialog.h" -//#include "scene/resources/sample.h" -#include "compressed_translation.h" -#include "editor/project_settings.h" -#include "io/resource_saver.h" -#include "os/file_access.h" -#include "translation.h" - - -class EditorTranslationImportDialog : public ConfirmationDialog { - - GDCLASS(EditorTranslationImportDialog,ConfirmationDialog); - - EditorTranslationImportPlugin *plugin; - - LineEdit *import_path; - LineEdit *save_path; - EditorFileDialog *file_select; - CheckButton *ignore_first; - CheckButton *compress; - CheckButton *add_to_project; - EditorDirDialog *save_select; - ConfirmationDialog *error_dialog; - Vector<TreeItem*> items; - Tree *columns; - -public: - - void _choose_file(const String& p_path) { - - import_path->set_text(p_path); - FileAccess *f = FileAccess::open(p_path,FileAccess::READ); - if (!f) { - - error_dialog->set_text(TTR("Invalid source!")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - - } - - Vector<String> csvh = f->get_csv_line(); - memdelete(f); - - if (csvh.size()<2) { - - error_dialog->set_text(TTR("Invalid translation source!")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - return; - - } - - columns->clear(); - columns->set_columns(2); - TreeItem *root = columns->create_item(); - columns->set_hide_root(true); - columns->set_column_titles_visible(true); - columns->set_column_title(0,TTR("Column")); - columns->set_column_title(1,TTR("Language")); - Vector<String> langs = TranslationServer::get_all_locales(); - Vector<String> names = TranslationServer::get_all_locale_names(); - if (csvh[0]=="") - ignore_first->set_pressed(true); - - - items.clear(); - - for(int i=1;i<csvh.size();i++) { - - TreeItem *ti = columns->create_item(root); - - ti->set_editable(0,true); - ti->set_selectable(0,false); - ti->set_cell_mode(0,TreeItem::CELL_MODE_CHECK); - ti->set_checked(0,true); - ti->set_text(0,itos(i)); - items.push_back(ti); - - String lname = csvh[i].to_lower().strip_edges(); - int idx=-1; - String hint; - for(int j=0;j<langs.size();j++) { - - if (langs[j]==lname.substr(0,langs[j].length()).to_lower()) { - idx=j; - } - if (j>0) { - hint+=","; - } - hint+=names[j].replace(","," "); - } - - ti->set_cell_mode(1,TreeItem::CELL_MODE_RANGE); - ti->set_text(1,hint); - ti->set_editable(1,true); - - - if (idx!=-1) { - ignore_first->set_pressed(true); - ti->set_range(1,idx); - } else { - - //not found, maybe used stupid name - if (lname.begins_with("br")) //brazilian - ti->set_range(1,langs.find("pt")); - else if (lname.begins_with("ch")) //chinese - ti->set_range(1,langs.find("zh")); - else if (lname.begins_with("sp")) //spanish - ti->set_range(1,langs.find("es")); - else if (lname.begins_with("kr"))// kprean - ti->set_range(1,langs.find("ko")); - else if (i==0) - ti->set_range(1,langs.find("en")); - else - ti->set_range(1,langs.find("es")); - } - - ti->set_metadata(1,names[ti->get_range(1)]); - } - - - - } - void _choose_save_dir(const String& p_path) { - - save_path->set_text(p_path); - } - - void _browse() { - - file_select->popup_centered_ratio(); - } - - void _browse_target() { - - save_select->popup_centered_ratio(); - - } - - - void popup_import(const String& p_from) { - - popup_centered(Size2(400,400)*EDSCALE); - - if (p_from!="") { - - Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_from); - ERR_FAIL_COND(!rimd.is_valid()); - ERR_FAIL_COND(rimd->get_source_count()!=1); - _choose_file(EditorImportPlugin::expand_source_path(rimd->get_source_path(0))); - _choose_save_dir(p_from.get_base_dir()); - String locale = rimd->get_option("locale"); - bool skip_first=rimd->get_option("skip_first"); - bool compressed = rimd->get_option("compress"); - - int idx=-1; - - for(int i=0;i<items.size();i++) { - - String il = TranslationServer::get_all_locales()[items[i]->get_range(1)]; - if (il==locale) { - idx=i; - break; - } - } - - if (idx!=-1) { - idx=rimd->get_option("index"); - } - - for(int i=0;i<items.size();i++) { - - if (i==idx) { - - Vector<String> locs = TranslationServer::get_all_locales(); - for(int j=0;j<locs.size();j++) { - if (locs[j]==locale) { - items[i]->set_range(1,j); - } - - } - items[i]->set_checked(0,true); - } else { - items[i]->set_checked(0,false); - - } - } - - ignore_first->set_pressed(skip_first); - compress->set_pressed(compressed); - - - - } - - } - - - void _import() { - - - if (items.size()==0) { - error_dialog->set_text(TTR("No items to import!")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - } - - if (!save_path->get_text().begins_with("res://")) { - error_dialog->set_text(TTR("No target path!")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - } - - EditorProgress progress("import_xl",TTR("Import Translations"),items.size()); - for(int i=0;i<items.size();i++) { - - progress.step(items[i]->get_metadata(1),i); - if (!items[i]->is_checked(0)) - continue; - - String locale = TranslationServer::get_all_locales()[items[i]->get_range(1)]; - Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); - imd->add_source(EditorImportPlugin::validate_source_path(import_path->get_text())); - imd->set_option("locale",locale); - imd->set_option("index",i); - imd->set_option("skip_first",ignore_first->is_pressed()); - imd->set_option("compress",compress->is_pressed()); - - String savefile = save_path->get_text().plus_file(import_path->get_text().get_file().get_basename()+"."+locale+".translation"); - Error err = plugin->import(savefile,imd); - if (err!=OK) { - error_dialog->set_text(TTR("Couldn't import!")); - error_dialog->popup_centered(Size2(200,100)*EDSCALE); - } else if (add_to_project->is_pressed()) { - - ProjectSettings::get_singleton()->add_translation(savefile); - } - } - hide(); - - } - - - void _notification(int p_what) { - - - if (p_what==NOTIFICATION_ENTER_TREE) { - - - } - } - - static void _bind_methods() { - - - ClassDB::bind_method("_choose_file",&EditorTranslationImportDialog::_choose_file); - ClassDB::bind_method("_choose_save_dir",&EditorTranslationImportDialog::_choose_save_dir); - ClassDB::bind_method("_import",&EditorTranslationImportDialog::_import); - ClassDB::bind_method("_browse",&EditorTranslationImportDialog::_browse); - ClassDB::bind_method("_browse_target",&EditorTranslationImportDialog::_browse_target); - //ADD_SIGNAL( MethodInfo("imported",PropertyInfo(Variant::OBJECT,"scene")) ); - } - - EditorTranslationImportDialog(EditorTranslationImportPlugin *p_plugin) { - - plugin=p_plugin; - - - set_title(TTR("Import Translation")); - - VBoxContainer *vbc = memnew( VBoxContainer ); - add_child(vbc); - //set_child_rect(vbc); - - - - VBoxContainer *csvb = memnew( VBoxContainer ); - - HBoxContainer *hbc = memnew( HBoxContainer ); - csvb->add_child(hbc); - vbc->add_margin_child(TTR("Source CSV:"),csvb); - - import_path = memnew( LineEdit ); - import_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(import_path); - ignore_first = memnew( CheckButton ); - ignore_first->set_text(TTR("Ignore First Row")); - csvb->add_child(ignore_first); - - Button * import_choose = memnew( Button ); - import_choose->set_text(" .. "); - hbc->add_child(import_choose); - - import_choose->connect("pressed", this,"_browse"); - - VBoxContainer *tcomp = memnew( VBoxContainer); - hbc = memnew( HBoxContainer ); - tcomp->add_child(hbc); - vbc->add_margin_child(TTR("Target Path:"),tcomp); - - save_path = memnew( LineEdit ); - save_path->set_h_size_flags(SIZE_EXPAND_FILL); - hbc->add_child(save_path); - - Button * save_choose = memnew( Button ); - save_choose->set_text(" .. "); - hbc->add_child(save_choose); - - save_choose->connect("pressed", this,"_browse_target"); - - compress = memnew( CheckButton); - compress->set_pressed(true); - compress->set_text(TTR("Compress")); - tcomp->add_child(compress); - - add_to_project = memnew( CheckButton); - add_to_project->set_pressed(true); - add_to_project->set_text(TTR("Add to Project (project.godot)")); - tcomp->add_child(add_to_project); - - file_select = memnew(EditorFileDialog); - file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); - add_child(file_select); - file_select->set_mode(EditorFileDialog::MODE_OPEN_FILE); - file_select->connect("file_selected", this,"_choose_file"); - file_select->add_filter("*.csv ; Translation CSV"); - save_select = memnew( EditorDirDialog ); - add_child(save_select); - - //save_select->set_mode(EditorFileDialog::MODE_OPEN_DIR); - save_select->connect("dir_selected", this,"_choose_save_dir"); - - get_ok()->connect("pressed", this,"_import"); - get_ok()->set_text(TTR("Import")); - - - error_dialog = memnew ( ConfirmationDialog ); - add_child(error_dialog); - error_dialog->get_ok()->set_text(TTR("Accept")); - //error_dialog->get_cancel()->hide(); - - set_hide_on_ok(false); - - columns = memnew( Tree ); - vbc->add_margin_child(TTR("Import Languages:"),columns,true); - } - - ~EditorTranslationImportDialog() { - - } - -}; - - -String EditorTranslationImportPlugin::get_name() const { - - return "translation"; -} -String EditorTranslationImportPlugin::get_visible_name() const { - - return TTR("Translation"); -} -void EditorTranslationImportPlugin::import_dialog(const String& p_from) { - - dialog->popup_import(p_from); -} - - - -void EditorTranslationImportPlugin::import_from_drop(const Vector<String>& p_drop, const String &p_dest_path) { - - - for(int i=0;i<p_drop.size();i++) { - String ext = p_drop[i].get_extension().to_lower(); - - if (ext=="csv") { - - import_dialog(); - dialog->_choose_file(p_drop[i]); - dialog->_choose_save_dir(p_dest_path); - break; - } - } - - -} - -Error EditorTranslationImportPlugin::import(const String& p_path, const Ref<ResourceImportMetadata>& p_from) { - - Ref<ResourceImportMetadata> from = p_from; - ERR_FAIL_COND_V( from->get_source_count()!=1, ERR_INVALID_PARAMETER); - - String source = EditorImportPlugin::expand_source_path( from->get_source_path(0) ); - - FileAccessRef f = FileAccess::open(source,FileAccess::READ); - - ERR_FAIL_COND_V( !f, ERR_INVALID_PARAMETER ); - - bool skip_first = from->get_option("skip_first"); - int index = from->get_option("index"); - index+=1; - String locale = from->get_option("locale"); - - Ref<Translation> translation = memnew( Translation ); - - translation->set_locale( locale ); - - Vector<String> line = f->get_csv_line(); - - while(line.size()>1) { - - if (!skip_first) { - ERR_FAIL_INDEX_V(index,line.size(),ERR_INVALID_DATA ); - translation->add_message(line[0].strip_edges(),line[index]); - - } else { - - skip_first=false; - } - - line = f->get_csv_line(); - } - - from->set_source_md5(0,FileAccess::get_md5(source)); - from->set_editor(get_name()); - - String dst_path = p_path; - - if (from->get_option("compress")) { - - Ref<PHashTranslation> cxl = memnew( PHashTranslation ); - cxl->generate( translation ); - translation=cxl; - } - - translation->set_import_metadata(from); - return ResourceSaver::save(dst_path,translation); - -} - - -EditorTranslationImportPlugin::EditorTranslationImportPlugin(EditorNode* p_editor) { - - dialog = memnew(EditorTranslationImportDialog(this)); - p_editor->get_gui_base()->add_child(dialog); -} - -#endif diff --git a/editor/io_plugins/editor_translation_import_plugin.h b/editor/io_plugins/editor_translation_import_plugin.h deleted file mode 100644 index 78335b531d..0000000000 --- a/editor/io_plugins/editor_translation_import_plugin.h +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************/ -/* editor_translation_import_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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_TRANSLATION_IMPORT_PLUGIN_H -#define EDITOR_TRANSLATION_IMPORT_PLUGIN_H - -#include "editor/editor_export.h" -#include "scene/resources/font.h" -#if 0 -class EditorNode; -class EditorTranslationImportDialog; - -class EditorTranslationImportPlugin : public EditorImportPlugin { - - GDCLASS(EditorTranslationImportPlugin,EditorImportPlugin); - - EditorTranslationImportDialog *dialog; -public: - - 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); - void import_from_drop(const Vector<String>& p_drop, const String &p_dest_path); - - - EditorTranslationImportPlugin(EditorNode* p_editor); -}; - -#endif -#endif // EDITOR_TRANSLATION_IMPORT_PLUGIN_H diff --git a/editor/multi_node_edit.cpp b/editor/multi_node_edit.cpp index a0f7b1e9dd..df1d7ff3d1 100644 --- a/editor/multi_node_edit.cpp +++ b/editor/multi_node_edit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/multi_node_edit.h b/editor/multi_node_edit.h index 3ffb0e205e..5abe7f6438 100644 --- a/editor/multi_node_edit.h +++ b/editor/multi_node_edit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp index b1a538ed2e..bfbb2dc3d3 100644 --- a/editor/node_dock.cpp +++ b/editor/node_dock.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/node_dock.h b/editor/node_dock.h index 29e5dc5169..7c4f6bbecc 100644 --- a/editor/node_dock.h +++ b/editor/node_dock.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/output_strings.cpp b/editor/output_strings.cpp index 8c9f8386ef..213cd47d01 100644 --- a/editor/output_strings.cpp +++ b/editor/output_strings.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/output_strings.h b/editor/output_strings.h index aeaad35c0c..8482e55752 100644 --- a/editor/output_strings.h +++ b/editor/output_strings.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/pane_drag.cpp b/editor/pane_drag.cpp index 22b306f941..33db2307b5 100644 --- a/editor/pane_drag.cpp +++ b/editor/pane_drag.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/pane_drag.h b/editor/pane_drag.h index 0be017b8f7..55372198d1 100644 --- a/editor/pane_drag.h +++ b/editor/pane_drag.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 5b71f51b0f..cc7fc57cde 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -965,71 +965,6 @@ void AnimationPlayerEditor::_list_changed() { if (is_visible_in_tree()) _update_player(); } -#if 0 -void AnimationPlayerEditor::_editor_store() { - - if (animation->get_item_count()==0) - return; - String current = animation->get_item_text(animation->get_selected()); - Ref<Animation> anim = player->get_animation(current); - - if (key_editor->get_current_animation()==anim) - return; //already there - - - undo_redo->create_action("Store anim in editor"); - undo_redo->add_do_method(key_editor,"set_animation",anim); - undo_redo->add_undo_method(key_editor,"remove_animation",anim); - undo_redo->commit_action(); -} - -void AnimationPlayerEditor::_editor_load(){ - - Ref<Animation> anim = key_editor->get_current_animation(); - if (anim.is_null()) - return; - - String existing = player->find_animation(anim); - if (existing!="") { - _select_anim_by_name(existing); - return; //already has - } - - int count=1; - String base=anim->get_name(); - bool noname=false; - if (base=="") { - base="New Anim"; - noname=true; - } - - while(true) { - String attempt = base; - if (count>1) - attempt+=" ("+itos(count)+")"; - if (player->has_animation(attempt)) { - count++; - continue; - } - base=attempt; - break; - } - - if (noname) - anim->set_name(base); - - undo_redo->create_action("Add Animation From Editor"); - undo_redo->add_do_method(player,"add_animation",base,anim); - undo_redo->add_undo_method(player,"remove_animation",base); - undo_redo->add_do_method(this,"_animation_player_changed",player); - undo_redo->add_undo_method(this,"_animation_player_changed",player); - undo_redo->commit_action(); - - _select_anim_by_name(base); - - -} -#endif void AnimationPlayerEditor::_animation_key_editor_anim_len_changed(float p_len) { diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h index bcf40f52d3..cea6b05ed4 100644 --- a/editor/plugins/animation_player_editor_plugin.h +++ b/editor/plugins/animation_player_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp index f3ff915508..054124da8f 100644 --- a/editor/plugins/animation_tree_editor_plugin.cpp +++ b/editor/plugins/animation_tree_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -605,15 +605,6 @@ void AnimationTreeEditor::_draw_node(const StringName &p_node) { } } -#if 0 -void AnimationTreeEditor::_node_param_changed() { - - //anim_tree->node_set_param( click_node,property_editor->get_variant() ); - //update(); - //_write_anim_tree_graph(); -} -#endif - AnimationTreeEditor::ClickType AnimationTreeEditor::_locate_click(const Point2 &p_click, StringName *p_node_id, int *p_slot_index) const { Ref<StyleBox> style = get_stylebox("panel", "PopupMenu"); @@ -714,32 +705,6 @@ Point2 AnimationTreeEditor::_get_slot_pos(const StringName &p_node_id, bool p_in return pos; } -#if 0 -void AnimationTreeEditor::_node_edit_property(const StringName& p_node) { - - Ref<StyleBox> style = get_stylebox("panel","PopupMenu"); - Size2 size = get_node_size(p_node); - Point2 pos = Point2( anim_tree->node_get_pos_x(p_node), anim_tree->node_get_pos_y(p_node) )-offset; - - VisualServer::AnimationTreeNodeType type=anim_tree->node_get_type(p_node); - - PropertyInfo ph = VisualServer::get_singleton()->anim_tree_node_get_type_info(type); - if (ph.type==Variant::NIL) - return; - if (ph.type==Variant::_RID) - ph.type=Variant::RESOURCE; - - property_editor->edit(NULL,ph.name,ph.type,anim_tree->node_get_param(p_node),ph.hint,ph.hint_string); - - Point2 popup_pos=Point2( pos.x+(size.width-property_editor->get_size().width)/2.0,pos.y+(size.y-style->get_margin(MARGIN_BOTTOM))).floor(); - popup_pos+=get_global_position(); - property_editor->set_position(popup_pos); - - property_editor->popup(); - -} -#endif - void AnimationTreeEditor::_gui_input(Ref<InputEvent> p_event) { Ref<InputEventMouseButton> mb = p_event; diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h index 972c6c9b47..a5bef263f4 100644 --- a/editor/plugins/animation_tree_editor_plugin.h +++ b/editor/plugins/animation_tree_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index c01c2de6b7..626b4f5a7f 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index fa768ec96a..35977f3949 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/baked_light_baker.cpp b/editor/plugins/baked_light_baker.cpp deleted file mode 100644 index d76bdad858..0000000000 --- a/editor/plugins/baked_light_baker.cpp +++ /dev/null @@ -1,2727 +0,0 @@ -/*************************************************************************/ -/* baked_light_baker.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "baked_light_baker.h" - -#include "editor/editor_node.h" -#include "editor/editor_settings.h" -#include "io/marshalls.h" -#include <stdlib.h> -#include <cmath> - -#if 0 -void baked_light_baker_add_64f(double *dst,double value); -void baked_light_baker_add_64i(int64_t *dst,int64_t value); - -//-separar en 2 testuras? -//*mejorar performance y threads -//*modos lineales -//*saturacion - -_FORCE_INLINE_ static uint64_t get_uv_normal_bit(const Vector3& p_vector) { - - int lat = Math::fast_ftoi(Math::floor(Math::acos(p_vector.dot(Vector3(0,1,0)))*6.0/Math_PI+0.5)); - - if (lat==0) { - return 60; - } else if (lat==6) { - return 61; - } - - int lon = Math::fast_ftoi(Math::floor( (Math_PI+Math::atan2(p_vector.x,p_vector.z))*12.0/(Math_PI*2.0) + 0.5))%12; - - return lon+(lat-1)*12; -} - - - -_FORCE_INLINE_ static Vector3 get_bit_normal(int p_bit) { - - if (p_bit==61) { - return Vector3(0,1,0); - } else if (p_bit==62){ - return Vector3(0,-1,0); - } - - float latang = ((p_bit / 12)+1)*Math_PI/6.0; - - Vector2 latv(Math::sin(latang),Math::cos(latang)); - - float lonang = ((p_bit%12)*Math_PI*2.0/12.0)-Math_PI; - - Vector2 lonv(Math::sin(lonang),Math::cos(lonang)); - - return Vector3(lonv.x*latv.x,latv.y,lonv.y*latv.x).normalized(); - -} - - -BakedLightBaker::MeshTexture* BakedLightBaker::_get_mat_tex(const Ref<Texture>& p_tex) { - - if (!tex_map.has(p_tex)) { - - Ref<ImageTexture> imgtex=p_tex; - if (imgtex.is_null()) - return NULL; - Image image=imgtex->get_data(); - if (image.empty()) - return NULL; - - if (image.get_format()!=Image::FORMAT_RGBA8) { - if (image.get_format()>Image::FORMAT_INDEXED_ALPHA) { - Error err = image.decompress(); - if (err) - return NULL; - } - - if (image.get_format()!=Image::FORMAT_RGBA8) - image.convert(Image::FORMAT_RGBA8); - } - - if (imgtex->get_flags()&Texture::FLAG_CONVERT_TO_LINEAR) { - Image copy = image; - copy.srgb_to_linear(); - image=copy; - } - - PoolVector<uint8_t> dvt=image.get_data(); - PoolVector<uint8_t>::Read r=dvt.read(); - MeshTexture mt; - mt.tex_w=image.get_width(); - mt.tex_h=image.get_height(); - int len = image.get_width()*image.get_height()*4; - mt.tex.resize(len); - copymem(mt.tex.ptr(),r.ptr(),len); - - textures.push_back(mt); - tex_map[p_tex]=&textures.back()->get(); - } - - return tex_map[p_tex]; -} - - -void BakedLightBaker::_add_mesh(const Ref<Mesh>& p_mesh,const Ref<Material>& p_mat_override,const Transform& p_xform,int p_baked_texture) { - - - for(int i=0;i<p_mesh->get_surface_count();i++) { - - if (p_mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES) - continue; - Ref<Material> mat = p_mat_override.is_valid()?p_mat_override:p_mesh->surface_get_material(i); - - MeshMaterial *matptr=NULL; - int baked_tex=p_baked_texture; - - if (mat.is_valid()) { - - if (!mat_map.has(mat)) { - - MeshMaterial mm; - - Ref<SpatialMaterial> fm = mat; - if (fm.is_valid()) { - //fixed route - mm.diffuse.color=fm->get_parameter(SpatialMaterial::PARAM_DIFFUSE); - if (linear_color) - mm.diffuse.color=mm.diffuse.color.to_linear(); - mm.diffuse.tex=_get_mat_tex(fm->get_texture(SpatialMaterial::PARAM_DIFFUSE)); - mm.specular.color=fm->get_parameter(SpatialMaterial::PARAM_SPECULAR); - if (linear_color) - mm.specular.color=mm.specular.color.to_linear(); - - mm.specular.tex=_get_mat_tex(fm->get_texture(SpatialMaterial::PARAM_SPECULAR)); - } else { - - mm.diffuse.color=Color(1,1,1,1); - mm.diffuse.tex=NULL; - mm.specular.color=Color(0,0,0,1); - mm.specular.tex=NULL; - } - - materials.push_back(mm); - mat_map[mat]=&materials.back()->get(); - - } - - matptr=mat_map[mat]; - - } - - - int facecount=0; - - - if (p_mesh->surface_get_format(i)&Mesh::ARRAY_FORMAT_INDEX) { - - facecount=p_mesh->surface_get_array_index_len(i); - } else { - - facecount=p_mesh->surface_get_array_len(i); - } - - ERR_CONTINUE((facecount==0 || (facecount%3)!=0)); - - facecount/=3; - - int tbase=triangles.size(); - triangles.resize(facecount+tbase); - - - Array a = p_mesh->surface_get_arrays(i); - - PoolVector<Vector3> vertices = a[Mesh::ARRAY_VERTEX]; - PoolVector<Vector3>::Read vr=vertices.read(); - PoolVector<Vector2> uv; - PoolVector<Vector2>::Read uvr; - PoolVector<Vector2> uv2; - PoolVector<Vector2>::Read uv2r; - PoolVector<Vector3> normal; - PoolVector<Vector3>::Read normalr; - bool read_uv=false; - bool read_normal=false; - - if (p_mesh->surface_get_format(i)&Mesh::ARRAY_FORMAT_TEX_UV) { - - uv=a[Mesh::ARRAY_TEX_UV]; - uvr=uv.read(); - read_uv=true; - - if (mat.is_valid() && mat->get_flag(Material::FLAG_LIGHTMAP_ON_UV2) && p_mesh->surface_get_format(i)&Mesh::ARRAY_FORMAT_TEX_UV2) { - - uv2=a[Mesh::ARRAY_TEX_UV2]; - uv2r=uv2.read(); - - } else { - uv2r=uv.read(); - if (baked_light->get_transfer_lightmaps_only_to_uv2()) { - baked_tex=-1; - } - } - } - - if (p_mesh->surface_get_format(i)&Mesh::ARRAY_FORMAT_NORMAL) { - - normal=a[Mesh::ARRAY_NORMAL]; - normalr=normal.read(); - read_normal=true; - } - - Matrix3 normal_xform = p_xform.basis.inverse().transposed(); - - - if (p_mesh->surface_get_format(i)&Mesh::ARRAY_FORMAT_INDEX) { - - PoolVector<int> indices = a[Mesh::ARRAY_INDEX]; - PoolVector<int>::Read ir = indices.read(); - - for(int i=0;i<facecount;i++) { - Triangle &t=triangles[tbase+i]; - t.vertices[0]=p_xform.xform(vr[ ir[i*3+0] ]); - t.vertices[1]=p_xform.xform(vr[ ir[i*3+1] ]); - t.vertices[2]=p_xform.xform(vr[ ir[i*3+2] ]); - t.material=matptr; - t.baked_texture=baked_tex; - if (read_uv) { - - t.uvs[0]=uvr[ ir[i*3+0] ]; - t.uvs[1]=uvr[ ir[i*3+1] ]; - t.uvs[2]=uvr[ ir[i*3+2] ]; - - t.bake_uvs[0]=uv2r[ ir[i*3+0] ]; - t.bake_uvs[1]=uv2r[ ir[i*3+1] ]; - t.bake_uvs[2]=uv2r[ ir[i*3+2] ]; - } - if (read_normal) { - - t.normals[0]=normal_xform.xform(normalr[ ir[i*3+0] ]).normalized(); - t.normals[1]=normal_xform.xform(normalr[ ir[i*3+1] ]).normalized(); - t.normals[2]=normal_xform.xform(normalr[ ir[i*3+2] ]).normalized(); - } - } - - } else { - - for(int i=0;i<facecount;i++) { - Triangle &t=triangles[tbase+i]; - t.vertices[0]=p_xform.xform(vr[ i*3+0 ]); - t.vertices[1]=p_xform.xform(vr[ i*3+1 ]); - t.vertices[2]=p_xform.xform(vr[ i*3+2 ]); - t.material=matptr; - t.baked_texture=baked_tex; - if (read_uv) { - - t.uvs[0]=uvr[ i*3+0 ]; - t.uvs[1]=uvr[ i*3+1 ]; - t.uvs[2]=uvr[ i*3+2 ]; - - t.bake_uvs[0]=uv2r[ i*3+0 ]; - t.bake_uvs[1]=uv2r[ i*3+1 ]; - t.bake_uvs[2]=uv2r[ i*3+2 ]; - - } - if (read_normal) { - - t.normals[0]=normal_xform.xform(normalr[ i*3+0 ]).normalized(); - t.normals[1]=normal_xform.xform(normalr[ i*3+1 ]).normalized(); - t.normals[2]=normal_xform.xform(normalr[ i*3+2 ]).normalized(); - } - } - } - } - -} - - -void BakedLightBaker::_parse_geometry(Node* p_node) { - - if (MeshInstance *meshi=Object::cast_to<MeshInstance>(p_node)) { - - Ref<Mesh> mesh=meshi->get_mesh(); - if (mesh.is_valid()) { - _add_mesh(mesh,meshi->get_material_override(),base_inv * meshi->get_global_transform(),meshi->get_baked_light_texture_id()); - } - } else if (Light *dl=Object::cast_to<Light>(p_node)) { - - if (dl->get_bake_mode()!=Light::BAKE_MODE_DISABLED) { - - - LightData dirl; - dirl.type=VS::LightType(dl->get_light_type()); - dirl.diffuse=dl->get_color(DirectionalLight::COLOR_DIFFUSE); - dirl.specular=dl->get_color(DirectionalLight::COLOR_SPECULAR); - if (linear_color) - dirl.diffuse=dirl.diffuse.to_linear(); - if (linear_color) - dirl.specular=dirl.specular.to_linear(); - - dirl.energy=dl->get_parameter(DirectionalLight::PARAM_ENERGY); - dirl.pos=dl->get_global_transform().origin; - dirl.up=dl->get_global_transform().basis.get_axis(1).normalized(); - dirl.left=dl->get_global_transform().basis.get_axis(0).normalized(); - dirl.dir=-dl->get_global_transform().basis.get_axis(2).normalized(); - dirl.spot_angle=dl->get_parameter(DirectionalLight::PARAM_SPOT_ANGLE); - dirl.spot_attenuation=dl->get_parameter(DirectionalLight::PARAM_SPOT_ATTENUATION); - dirl.attenuation=dl->get_parameter(DirectionalLight::PARAM_ATTENUATION); - dirl.darkening=dl->get_parameter(DirectionalLight::PARAM_SHADOW_DARKENING); - dirl.radius=dl->get_parameter(DirectionalLight::PARAM_RADIUS); - dirl.bake_direct=dl->get_bake_mode()==Light::BAKE_MODE_FULL; - dirl.rays_thrown=0; - dirl.bake_shadow=dl->get_bake_mode()==Light::BAKE_MODE_INDIRECT_AND_SHADOWS; - lights.push_back(dirl); - } - - } else if (Spatial *sp = Object::cast_to<Spatial>(p_node)){ - - Array arr = p_node->call("_get_baked_light_meshes"); - for(int i=0;i<arr.size();i+=2) { - - Transform xform=arr[i]; - Ref<Mesh> mesh=arr[i+1]; - _add_mesh(mesh,Ref<Material>(),base_inv * (sp->get_global_transform() * xform)); - } - } - - for(int i=0;i<p_node->get_child_count();i++) { - - _parse_geometry(p_node->get_child(i)); - } -} - - -void BakedLightBaker::_fix_lights() { - - - total_light_area=0; - for(int i=0;i<lights.size();i++) { - - LightData &dl=lights[i]; - - switch(dl.type) { - case VS::LIGHT_DIRECTIONAL: { - - float up_max=-1e10; - float dir_max=-1e10; - float left_max=-1e10; - float up_min=1e10; - float dir_min=1e10; - float left_min=1e10; - - for(int j=0;j<triangles.size();j++) { - - for(int k=0;k<3;k++) { - - Vector3 v = triangles[j].vertices[k]; - - float up_d = dl.up.dot(v); - float dir_d = dl.dir.dot(v); - float left_d = dl.left.dot(v); - - if (up_d>up_max) - up_max=up_d; - if (up_d<up_min) - up_min=up_d; - - if (left_d>left_max) - left_max=left_d; - if (left_d<left_min) - left_min=left_d; - - if (dir_d>dir_max) - dir_max=dir_d; - if (dir_d<dir_min) - dir_min=dir_d; - - } - } - - //make a center point, then the upvector and leftvector - dl.pos = dl.left*( left_max+left_min )*0.5 + dl.up*( up_max+up_min )*0.5 + dl.dir*(dir_min-(dir_max-dir_min)); - dl.left*=(left_max-left_min)*0.5; - dl.up*=(up_max-up_min)*0.5; - dl.length = (dir_max - dir_min)*10; //arbitrary number to keep it in scale - dl.area=dl.left.length()*2*dl.up.length()*2; - dl.constant=1.0/dl.area; - } break; - case VS::LIGHT_OMNI: - case VS::LIGHT_SPOT: { - - dl.attenuation_table.resize(ATTENUATION_CURVE_LEN); - for(int j=0;j<ATTENUATION_CURVE_LEN;j++) { - dl.attenuation_table[j]=1.0-Math::pow(j/float(ATTENUATION_CURVE_LEN),dl.attenuation); - float falloff=j*dl.radius/float(ATTENUATION_CURVE_LEN); - if (falloff==0) - falloff=0.000001; - float intensity=4*Math_PI*(falloff*falloff); - //dl.attenuation_table[j]*=falloff*falloff; - dl.attenuation_table[j]*=1.0/(3.0/intensity); - - } - if (dl.type==VS::LIGHT_OMNI) { - - dl.area=4.0*Math_PI*pow(dl.radius,2.0f); - dl.constant=1.0/3.5; - } else { - - - float r = Math::tan(Math::deg2rad(dl.spot_angle))*dl.radius; - float c = 1.0-(Math::deg2rad(dl.spot_angle)*0.5+0.5); - dl.constant=1.0/3.5; - dl.constant*=1.0/c; - - dl.area=Math_PI*r*r*c; - } - - } break; - - - } - - total_light_area+=dl.area; - } -} - -BakedLightBaker::BVH* BakedLightBaker::_parse_bvh(BVH** p_children, int p_size, int p_depth, int &max_depth) { - - if (p_depth>max_depth) { - max_depth=p_depth; - } - - if (p_size==1) { - - return p_children[0]; - } else if (p_size==0) { - - return NULL; - } - - - AABB aabb; - aabb=p_children[0]->aabb; - for(int i=1;i<p_size;i++) { - - aabb.merge_with(p_children[i]->aabb); - } - - int li=aabb.get_longest_axis_index(); - - switch(li) { - - case Vector3::AXIS_X: { - SortArray<BVH*,BVHCmpX> sort_x; - sort_x.nth_element(0,p_size,p_size/2,p_children); - //sort_x.sort(&p_bb[p_from],p_size); - } break; - case Vector3::AXIS_Y: { - SortArray<BVH*,BVHCmpY> sort_y; - sort_y.nth_element(0,p_size,p_size/2,p_children); - //sort_y.sort(&p_bb[p_from],p_size); - } break; - case Vector3::AXIS_Z: { - SortArray<BVH*,BVHCmpZ> sort_z; - sort_z.nth_element(0,p_size,p_size/2,p_children); - //sort_z.sort(&p_bb[p_from],p_size); - - } break; - } - - - BVH* left = _parse_bvh(p_children,p_size/2,p_depth+1,max_depth); - BVH* right = _parse_bvh(&p_children[p_size/2],p_size-p_size/2,p_depth+1,max_depth); - - BVH *_new = memnew(BVH); - _new->aabb=aabb; - _new->center=aabb.pos+aabb.size*0.5; - _new->children[0]=left; - _new->children[1]=right; - _new->leaf=NULL; - - return _new; -} - -void BakedLightBaker::_make_bvh() { - - Vector<BVH*> bases; - bases.resize(triangles.size()); - int max_depth=0; - for(int i=0;i<triangles.size();i++) { - bases[i]=memnew( BVH ); - bases[i]->leaf=&triangles[i]; - bases[i]->aabb.pos=triangles[i].vertices[0]; - bases[i]->aabb.expand_to(triangles[i].vertices[1]); - bases[i]->aabb.expand_to(triangles[i].vertices[2]); - triangles[i].aabb=bases[i]->aabb; - bases[i]->center=bases[i]->aabb.pos+bases[i]->aabb.size*0.5; - } - - bvh=_parse_bvh(bases.ptr(),bases.size(),1,max_depth); - - ray_stack = memnew_arr(uint32_t,max_depth); - bvh_stack = memnew_arr(BVH*,max_depth); - - bvh_depth = max_depth; -} - -void BakedLightBaker::_octree_insert(int p_octant,Triangle* p_triangle, int p_depth) { - - - - - uint32_t *stack=octant_stack; - uint32_t *ptr_stack=octantptr_stack; - Octant *octants=octant_pool.ptr(); - - stack[0]=0; - ptr_stack[0]=0; - - int stack_pos=0; - - - while(true) { - - Octant *octant=&octants[ptr_stack[stack_pos]]; - if (stack[stack_pos]<8) { - - int i = stack[stack_pos]; - stack[stack_pos]++; - - - - //fit_aabb=fit_aabb.grow(bvh->aabb.size.x*0.0001); - - int child_idx =octant->children[i]; - bool encloses; - if (!child_idx) { - - AABB aabb=octant->aabb; - aabb.size*=0.5; - if (i&1) - aabb.pos.x+=aabb.size.x; - if (i&2) - aabb.pos.y+=aabb.size.y; - if (i&4) - aabb.pos.z+=aabb.size.z; - - aabb.grow_by(cell_size*octree_extra_margin); - if (!aabb.intersects(p_triangle->aabb)) - continue; - encloses=aabb.grow(cell_size*-octree_extra_margin*2.0).encloses(p_triangle->aabb); - if (!encloses && !Face3(p_triangle->vertices[0],p_triangle->vertices[1],p_triangle->vertices[2]).intersects_aabb2(aabb)) - continue; - } else { - - Octant *child=&octants[child_idx]; - AABB aabb=child->aabb; - aabb.grow_by(cell_size*octree_extra_margin); - if (!aabb.intersects(p_triangle->aabb)) - continue; - encloses=aabb.grow(cell_size*-octree_extra_margin*2.0).encloses(p_triangle->aabb); - if (!encloses && !Face3(p_triangle->vertices[0],p_triangle->vertices[1],p_triangle->vertices[2]).intersects_aabb2(aabb)) - continue; - - } - - if (encloses) - stack[stack_pos]=8; // quick and dirty opt - - if (!child_idx) { - - - if (octant_pool_size==octant_pool.size()) { - octant_pool.resize(octant_pool_size+OCTANT_POOL_CHUNK); - octants=octant_pool.ptr(); - octant=&octants[ptr_stack[stack_pos]]; - } - child_idx=octant_pool_size++; - octant->children[i]=child_idx; - Octant *child=&octants[child_idx]; - - child->aabb=octant->aabb; - child->texture_x=0; - child->texture_y=0; - - child->aabb.size*=0.5; - if (i&1) - child->aabb.pos.x+=child->aabb.size.x; - if (i&2) - child->aabb.pos.y+=child->aabb.size.y; - if (i&4) - child->aabb.pos.z+=child->aabb.size.z; - - - child->full_accum[0]=0; - child->full_accum[1]=0; - child->full_accum[2]=0; - child->sampler_ofs=0; - - - - if (stack_pos==octree_depth-1) { - child->leaf=true; - child->offset[0]=child->aabb.pos.x+child->aabb.size.x*0.5; - child->offset[1]=child->aabb.pos.y+child->aabb.size.y*0.5; - child->offset[2]=child->aabb.pos.z+child->aabb.size.z*0.5; - child->next_leaf=leaf_list; - - - for(int ci=0;ci<8;ci++) { - child->normal_accum[ci][0]=0; - child->normal_accum[ci][1]=0; - child->normal_accum[ci][2]=0; - - } - - child->bake_neighbour=0; - child->first_neighbour=true; - leaf_list=child_idx; - cell_count++; - - for(int ci=0;ci<8;ci++) { - child->light_accum[ci][0]=0; - child->light_accum[ci][1]=0; - child->light_accum[ci][2]=0; - } - - child->parent=ptr_stack[stack_pos]; - - } else { - - child->leaf=false; - for(int j=0;j<8;j++) { - child->children[j]=0; - } - } - } - - if (!octants[child_idx].leaf) { - stack_pos++; - stack[stack_pos]=0; - ptr_stack[stack_pos]=child_idx; - } else { - - Octant *child=&octants[child_idx]; - - Vector3 n = Plane(p_triangle->vertices[0],p_triangle->vertices[1],p_triangle->vertices[2]).normal; - - - for(int ci=0;ci<8;ci++) { - - Vector3 pos = child->aabb.pos; - - if (ci&1) - pos.x+=child->aabb.size.x; - if (ci&2) - pos.y+=child->aabb.size.y; - if (ci&4) - pos.z+=child->aabb.size.z; - - - pos.x=floor((pos.x+cell_size*0.5)/cell_size); - pos.y=floor((pos.y+cell_size*0.5)/cell_size); - pos.z=floor((pos.z+cell_size*0.5)/cell_size); - - { - Map<Vector3,Vector3>::Element *E=endpoint_normal.find(pos); - if (!E) { - endpoint_normal[pos]=n; - } else { - E->get()+=n; - } - } - - { - - uint64_t bit = get_uv_normal_bit(n); - - Map<Vector3,uint64_t>::Element *E=endpoint_normal_bits.find(pos); - if (!E) { - endpoint_normal_bits[pos]=(1<<bit); - } else { - E->get()|=(1<<bit); - } - - } - - } - - } - - - } else { - stack_pos--; - if (stack_pos<0) - break; - } - } - - -} - - -void BakedLightBaker::_make_octree() { - - - AABB base = bvh->aabb; - float lal=base.get_longest_axis_size(); - //must be square because we want square blocks - base.size.x=lal; - base.size.y=lal; - base.size.z=lal; - base.grow_by(lal*0.001); //for precision - octree_aabb=base; - - cell_size=base.size.x; - for(int i=0;i<octree_depth;i++) - cell_size/=2.0; - octant_stack = memnew_arr(uint32_t,octree_depth*2 ); - octantptr_stack = memnew_arr(uint32_t,octree_depth*2 ); - - octant_pool.resize(OCTANT_POOL_CHUNK); - octant_pool_size=1; - Octant *root=octant_pool.ptr(); - root->leaf=false; - root->aabb=octree_aabb; - root->parent=-1; - for(int i=0;i<8;i++) - root->children[i]=0; - - EditorProgress ep("bake_octree",vformat(TTR("Parsing %d Triangles:"), triangles.size()),triangles.size()); - - for(int i=0;i<triangles.size();i++) { - - _octree_insert(0,&triangles[i],octree_depth-1); - if ((i%1000)==0) { - - ep.step(TTR("Triangle #")+itos(i),i); - } - } - - { - uint32_t oct_idx=leaf_list; - Octant *octants=octant_pool.ptr(); - while(oct_idx) { - - BakedLightBaker::Octant *oct = &octants[oct_idx]; - for(int ci=0;ci<8;ci++) { - - - Vector3 pos = oct->aabb.pos; - - if (ci&1) - pos.x+=oct->aabb.size.x; - if (ci&2) - pos.y+=oct->aabb.size.y; - if (ci&4) - pos.z+=oct->aabb.size.z; - - - pos.x=floor((pos.x+cell_size*0.5)/cell_size); - pos.y=floor((pos.y+cell_size*0.5)/cell_size); - pos.z=floor((pos.z+cell_size*0.5)/cell_size); - - { - Map<Vector3,Vector3>::Element *E=endpoint_normal.find(pos); - if (!E) { - //? - print_line("lolwut?"); - } else { - Vector3 n = E->get().normalized(); - oct->normal_accum[ci][0]=n.x; - oct->normal_accum[ci][1]=n.y; - oct->normal_accum[ci][2]=n.z; - - } - - } - - { - - Map<Vector3,uint64_t>::Element *E=endpoint_normal_bits.find(pos); - if (!E) { - //? - print_line("lolwut?"); - } else { - - float max_aper=0; - for(uint64_t i=0;i<62;i++) { - - if (!(E->get()&(1<<i))) - continue; - Vector3 ang_i = get_bit_normal(i); - - for(uint64_t j=0;j<62;j++) { - - if (i==j) - continue; - if (!(E->get()&(1<<j))) - continue; - Vector3 ang_j = get_bit_normal(j); - float ang = Math::acos(ang_i.dot(ang_j)); - if (ang>max_aper) - max_aper=ang; - } - } - if (max_aper>0.75*Math_PI) { - //angle too wide prevent problems and forget - oct->normal_accum[ci][0]=0; - oct->normal_accum[ci][1]=0; - oct->normal_accum[ci][2]=0; - } - } - } - - - } - - oct_idx=oct->next_leaf; - } - } - - -} - - - - - -void BakedLightBaker::_plot_light(ThreadStack& thread_stack,const Vector3& p_plot_pos, const AABB& p_plot_aabb, const Color& p_light,const Color& p_tint_light,bool p_only_full, const Plane& p_plane) { - - //stackless version - - uint32_t *stack=thread_stack.octant_stack; - uint32_t *ptr_stack=thread_stack.octantptr_stack; - Octant *octants=octant_pool.ptr(); - - stack[0]=0; - ptr_stack[0]=0; - - int stack_pos=0; - - - while(true) { - - Octant &octant=octants[ptr_stack[stack_pos]]; - - if (stack[stack_pos]==0) { - - - Vector3 pos = octant.aabb.pos + octant.aabb.size*0.5; - float md = 1<<(octree_depth - stack_pos ); - float r=cell_size*plot_size*md; - float div = 1.0/(md*md*md); - //div=1.0; - - - float d = p_plot_pos.distance_to(pos); - - if ((p_plane.distance_to(pos)>-cell_size*1.75*md) && d<=r) { - - - float intensity = 1.0 - (d/r)*(d/r); //not gauss but.. - - baked_light_baker_add_64f(&octant.full_accum[0],p_tint_light.r*intensity*div); - baked_light_baker_add_64f(&octant.full_accum[1],p_tint_light.g*intensity*div); - baked_light_baker_add_64f(&octant.full_accum[2],p_tint_light.b*intensity*div); - } - } - - if (octant.leaf) { - - - - //if (p_plane.normal.dot(octant.aabb.get_support(p_plane.normal)) < p_plane.d-CMP_EPSILON) { //octants behind are no go - - - if (!p_only_full) { - float r=cell_size*plot_size; - for(int i=0;i<8;i++) { - Vector3 pos=octant.aabb.pos; - if (i&1) - pos.x+=octant.aabb.size.x; - if (i&2) - pos.y+=octant.aabb.size.y; - if (i&4) - pos.z+=octant.aabb.size.z; - - - - float d = p_plot_pos.distance_to(pos); - - if ((p_plane.distance_to(pos)>-cell_size*1.75) && d<=r) { - - - float intensity = 1.0 - (d/r)*(d/r); //not gauss but.. - if (edge_damp>0) { - Vector3 normal = Vector3(octant.normal_accum[i][0],octant.normal_accum[i][1],octant.normal_accum[i][2]); - if (normal.x>0 || normal.y>0 || normal.z>0) { - - float damp = Math::abs(p_plane.normal.dot(normal)); - intensity*=pow(damp,edge_damp); - - } - } - - //intensity*=1.0-Math::abs(p_plane.distance_to(pos))/(plot_size*cell_size); - //intensity = Math::cos(d*Math_PI*0.5/r); - - baked_light_baker_add_64f(&octant.light_accum[i][0],p_light.r*intensity); - baked_light_baker_add_64f(&octant.light_accum[i][1],p_light.g*intensity); - baked_light_baker_add_64f(&octant.light_accum[i][2],p_light.b*intensity); - - - } - } - } - - stack_pos--; - } else if (stack[stack_pos]<8) { - - int i = stack[stack_pos]; - stack[stack_pos]++; - - if (!octant.children[i]) { - continue; - } - - Octant &child=octants[octant.children[i]]; - - if (!child.aabb.intersects(p_plot_aabb)) - continue; - - if (child.aabb.encloses(p_plot_aabb)) { - stack[stack_pos]=8; //don't test the rest - } - - stack_pos++; - stack[stack_pos]=0; - ptr_stack[stack_pos]=octant.children[i]; - } else { - stack_pos--; - if (stack_pos<0) - break; - } - } - - -} - - -float BakedLightBaker::_throw_ray(ThreadStack& thread_stack,bool p_bake_direct,const Vector3& p_begin, const Vector3& p_end,float p_rest,const Color& p_light,float *p_att_curve,float p_att_pos,int p_att_curve_len,int p_bounces,bool p_first_bounce,bool p_only_dist) { - - - uint32_t* stack = thread_stack.ray_stack; - BVH **bstack = thread_stack.bvh_stack; - - enum { - TEST_AABB_BIT=0, - VISIT_LEFT_BIT=1, - VISIT_RIGHT_BIT=2, - VISIT_DONE_BIT=3, - - - }; - - Vector3 n = (p_end-p_begin); - float len=n.length(); - if (len==0) - return 0; - n/=len; - - - - real_t d=1e10; - bool inters=false; - Vector3 r_normal; - Vector3 r_point; - Vector3 end=p_end; - - Triangle *triangle=NULL; - - /* - for(int i=0;i<max_depth;i++) - stack[i]=0; - */ - - int level=0; - //AABB ray_aabb; - //ray_aabb.pos=p_begin; - //ray_aabb.expand_to(p_end); - - - bstack[0]=bvh; - stack[0]=TEST_AABB_BIT; - - - while(true) { - - uint32_t mode = stack[level]; - const BVH &b = *bstack[level]; - bool done=false; - - switch(mode) { - case TEST_AABB_BIT: { - - if (b.leaf) { - - - Face3 f3(b.leaf->vertices[0],b.leaf->vertices[1],b.leaf->vertices[2]); - - - Vector3 res; - - if (f3.intersects_segment(p_begin,end,&res)) { - - - float nd = n.dot(res); - if (nd<d) { - - d=nd; - r_point=res; - end=res; - len=(p_begin-end).length(); - r_normal=f3.get_plane().get_normal(); - triangle=b.leaf; - inters=true; - } - - } - - stack[level]=VISIT_DONE_BIT; - } else { - - - bool valid = b.aabb.smits_intersect_ray(p_begin,n,0,len); - //bool valid = b.aabb.intersects_segment(p_begin,p_end); - //bool valid = b.aabb.intersects(ray_aabb); - - if (!valid) { - - stack[level]=VISIT_DONE_BIT; - - } else { - - stack[level]=VISIT_LEFT_BIT; - } - } - - } continue; - case VISIT_LEFT_BIT: { - - stack[level]=VISIT_RIGHT_BIT; - bstack[level+1]=b.children[0]; - stack[level+1]=TEST_AABB_BIT; - level++; - - } continue; - case VISIT_RIGHT_BIT: { - - stack[level]=VISIT_DONE_BIT; - bstack[level+1]=b.children[1]; - stack[level+1]=TEST_AABB_BIT; - level++; - } continue; - case VISIT_DONE_BIT: { - - if (level==0) { - done=true; - break; - } else - level--; - - } continue; - } - - - if (done) - break; - } - - - - if (inters) { - - if (p_only_dist) { - - return p_begin.distance_to(r_point); - } - - - //should check if there is normals first - Vector2 uv; - if (true) { - - triangle->get_uv_and_normal(r_point,uv,r_normal); - - } else { - - } - - if (n.dot(r_normal)>0) - return -1; - - if (n.dot(r_normal)>0) - r_normal=-r_normal; - - - //ok... - Color diffuse_at_point(0.8,0.8,0.8); - Color specular_at_point(0.0,0.0,0.0); - - - float dist = p_begin.distance_to(r_point); - - AABB aabb; - aabb.pos=r_point; - aabb.pos-=Vector3(1,1,1)*cell_size*plot_size; - aabb.size=Vector3(2,2,2)*cell_size*plot_size; - - Color res_light=p_light; - float att=1.0; - float dp=(1.0-normal_damp)*n.dot(-r_normal)+normal_damp; - - if (p_att_curve) { - - p_att_pos+=dist; - int cpos = Math::fast_ftoi((p_att_pos/p_att_curve_len)*ATTENUATION_CURVE_LEN); - cpos=CLAMP(cpos,0,ATTENUATION_CURVE_LEN-1); - att=p_att_curve[cpos]; - } - - - res_light.r*=dp; - res_light.g*=dp; - res_light.b*=dp; - - //light is plotted before multiplication with diffuse, this way - //the multiplication can happen with more detail in the shader - - - - if (triangle->material) { - - //triangle->get_uv(r_point); - - diffuse_at_point=triangle->material->diffuse.get_color(uv); - specular_at_point=triangle->material->specular.get_color(uv); - } - - - diffuse_at_point.r=res_light.r*diffuse_at_point.r; - diffuse_at_point.g=res_light.g*diffuse_at_point.g; - diffuse_at_point.b=res_light.b*diffuse_at_point.b; - - if (p_bounces>0) { - - - p_rest-=dist; - if (p_rest<CMP_EPSILON) - return 0; - - if (r_normal==-n) - return 0; //todo change a little - - r_point+=r_normal*0.01; - - - - - specular_at_point.r=res_light.r*specular_at_point.r; - specular_at_point.g=res_light.g*specular_at_point.g; - specular_at_point.b=res_light.b*specular_at_point.b; - - - - if (use_diffuse && (diffuse_at_point.r>CMP_EPSILON || diffuse_at_point.g>CMP_EPSILON || diffuse_at_point.b>CMP_EPSILON)) { - //diffuse bounce - - Vector3 c1=r_normal.cross(n).normalized(); - Vector3 c2=r_normal.cross(c1).normalized(); - double r1 = double(rand())/RAND_MAX; - double r2 = double(rand())/RAND_MAX; - double r3 = double(rand())/RAND_MAX; -#if 0 - Vector3 next = - ((c1*(r1-0.5)) + (c2*(r2-0.5)) + (r_normal*(r3-0.5))).normalized()*0.5 + r_normal*0.5; - - if (next==Vector3()) - next=r_normal; - Vector3 rn=next.normalized(); - -#else - Vector3 rn = ((c1*(r1-0.5)) + (c2*(r2-0.5)) + (r_normal*r3*0.5)).normalized(); -#endif - - - _throw_ray(thread_stack,p_bake_direct,r_point,r_point+rn*p_rest,p_rest,diffuse_at_point,p_att_curve,p_att_pos,p_att_curve_len,p_bounces-1); - } - - if (use_specular && (specular_at_point.r>CMP_EPSILON || specular_at_point.g>CMP_EPSILON || specular_at_point.b>CMP_EPSILON)) { - //specular bounce - - //Vector3 c1=r_normal.cross(n).normalized(); - //Vector3 c2=r_normal.cross(c1).normalized(); - - Vector3 rn = n - r_normal *r_normal.dot(n) * 2.0; - - _throw_ray(thread_stack,p_bake_direct,r_point,r_point+rn*p_rest,p_rest,specular_at_point,p_att_curve,p_att_pos,p_att_curve_len,p_bounces-1); - } - } - - //specular later - //_plot_light_point(r_point,octree,octree_aabb,p_light); - - - Color plot_light=res_light.linear_interpolate(diffuse_at_point,tint); - plot_light.r*=att; - plot_light.g*=att; - plot_light.b*=att; - Color tint_light=diffuse_at_point; - tint_light.r*=att; - tint_light.g*=att; - tint_light.b*=att; - - bool skip=false; - - if (!p_first_bounce || p_bake_direct) { - - - float r = plot_size * cell_size*2; - if (dist<r) { - //avoid accumulaiton of light on corners - //plot_light=plot_light.linear_interpolate(Color(0,0,0,0),1.0-sd/plot_size*plot_size); - skip=true; - - } else { - - - Vector3 c1=r_normal.cross(n).normalized(); - Vector3 c2=r_normal.cross(c1).normalized(); - double r1 = double(rand())/RAND_MAX; - double r2 = double(rand())/RAND_MAX; - double r3 = double(rand())/RAND_MAX; - Vector3 rn = ((c1*(r1-0.5)) + (c2*(r2-0.5)) + (r_normal*r3*0.25)).normalized(); - float d =_throw_ray(thread_stack,p_bake_direct,r_point,r_point+rn*p_rest,p_rest,diffuse_at_point,p_att_curve,p_att_pos,p_att_curve_len,p_bounces-1,false,true); - r = plot_size*cell_size*ao_radius; - if (d>0 && d<r) { - //avoid accumulaiton of light on corners - //plot_light=plot_light.linear_interpolate(Color(0,0,0,0),1.0-sd/plot_size*plot_size); - skip=true; - - } else { - //plot_light=Color(0,0,0,0); - } - } - } - - - Plane plane(r_point,r_normal); - if (!skip) - _plot_light(thread_stack,r_point,aabb,plot_light,tint_light,!(!p_first_bounce || p_bake_direct),plane); - - - return dist; - } - - return -1; - -} - - - - -void BakedLightBaker::_make_octree_texture() { - - - BakedLightBaker::Octant *octants=octant_pool.ptr(); - - //find neighbours first, to have a better idea of what amount of space is needed - { - - Vector<OctantHash> octant_hashing; - octant_hashing.resize(octant_pool_size); - Vector<uint32_t> hash_table; - int hash_table_size=Math::larger_prime(16384); - hash_table.resize(hash_table_size); - uint32_t*hashptr = hash_table.ptr(); - OctantHash*octhashptr = octant_hashing.ptr(); - - for(int i=0;i<hash_table_size;i++) - hashptr[i]=0; - - - //step 1 add to hash table - - uint32_t oct_idx=leaf_list; - - - while(oct_idx) { - - BakedLightBaker::Octant *oct = &octants[oct_idx]; - uint64_t base=0; - Vector3 pos = oct->aabb.pos - octree_aabb.pos; //make sure is always positive - base=int((pos.x+cell_size*0.5)/cell_size); - base<<=16; - base|=int((pos.y+cell_size*0.5)/cell_size); - base<<=16; - base|=int((pos.z+cell_size*0.5)/cell_size); - - uint32_t hash = HashMapHasherDefault::hash(base); - uint32_t idx = hash % hash_table_size; - octhashptr[oct_idx].next=hashptr[idx]; - octhashptr[oct_idx].hash=hash; - octhashptr[oct_idx].value=base; - hashptr[idx]=oct_idx; - - oct_idx=oct->next_leaf; - - } - - //step 2 find neighbours - oct_idx=leaf_list; - int neighbours=0; - - - while(oct_idx) { - - BakedLightBaker::Octant *oct = &octants[oct_idx]; - Vector3 pos = oct->aabb.pos - octree_aabb.pos; //make sure is always positive - pos.x+=cell_size; - uint64_t base=0; - base=int((pos.x+cell_size*0.5)/cell_size); - base<<=16; - base|=int((pos.y+cell_size*0.5)/cell_size); - base<<=16; - base|=int((pos.z+cell_size*0.5)/cell_size); - - uint32_t hash = HashMapHasherDefault::hash(base); - uint32_t idx = hash % hash_table_size; - - uint32_t bucket = hashptr[idx]; - - while(bucket) { - - if (octhashptr[bucket].value==base) { - - oct->bake_neighbour=bucket; - octants[bucket].first_neighbour=false; - neighbours++; - break; - } - - bucket = octhashptr[bucket].next; - } - - oct_idx=oct->next_leaf; - - } - - print_line("octant with neighbour: "+itos(neighbours)); - - } - - - //ok let's try to just create a texture - - int otex_w=256; - - while (true) { - - - - uint32_t oct_idx=leaf_list; - - int row=0; - - - print_line("begin at row "+itos(row)); - int longest_line_reused=0; - int col=0; - int processed=0; - - //reset - while(oct_idx) { - - BakedLightBaker::Octant *oct = &octants[oct_idx]; - oct->texture_x=0; - oct->texture_y=0; - oct_idx=oct->next_leaf; - - } - - oct_idx=leaf_list; - //assign - while(oct_idx) { - - BakedLightBaker::Octant *oct = &octants[oct_idx]; - if (oct->first_neighbour && oct->texture_x==0 && oct->texture_y==0) { - //was not processed - uint32_t current_idx=oct_idx; - int reused=0; - - while(current_idx) { - BakedLightBaker::Octant *o = &octants[current_idx]; - if (col+1 >= otex_w) { - col=0; - row+=4; - } - o->texture_x=col; - o->texture_y=row; - processed++; - - if (o->bake_neighbour) { - reused++; - } - col+=o->bake_neighbour ? 1 : 2; //reuse neighbour - current_idx=o->bake_neighbour; - } - - if (reused>longest_line_reused) { - longest_line_reused=reused; - } - } - oct_idx=oct->next_leaf; - } - - row+=4; - - if (otex_w < row) { - - otex_w*=2; - } else { - - baked_light_texture_w=otex_w; - baked_light_texture_h=next_power_of_2(row); - print_line("w: "+itos(otex_w)); - print_line("h: "+itos(row)); - break; - } - - - } - - - { - - otex_w=(1<<lattice_size)*(1<<lattice_size)*2; //make sure lattice fits horizontally - Vector3 lattice_cell_size=octree_aabb.size; - for(int i=0;i<lattice_size;i++) { - - lattice_cell_size*=0.5; - } - - - - while(true) { - - //let's plot the leafs first, given the octree is not so obvious which size it will have - int row=4+4*(1<<lattice_size); - int col=0; - - col=0; - row+=4; - print_line("end at row "+itos(row)); - - //put octree, no need for recursion, just loop backwards. - int regular_octants=0; - for(int i=octant_pool_size-1;i>=0;i--) { - - BakedLightBaker::Octant *oct = &octants[i]; - if (oct->leaf) //ignore leaf - continue; - if (oct->aabb.size.x>lattice_cell_size.x*1.1) { //bigger than latice, skip - oct->texture_x=0; - oct->texture_y=0; - } else if (oct->aabb.size.x>lattice_cell_size.x*0.8) { - //this is the initial lattice - Vector3 pos = oct->aabb.pos - octree_aabb.pos; //make sure is always positive - int x = int((pos.x+lattice_cell_size.x*0.5)/lattice_cell_size.x); - int y = int((pos.y+lattice_cell_size.y*0.5)/lattice_cell_size.y); - int z = int((pos.z+lattice_cell_size.z*0.5)/lattice_cell_size.z); - //bug net - ERR_FAIL_INDEX(x,(1<<lattice_size)); - ERR_FAIL_INDEX(y,(1<<lattice_size)); - ERR_FAIL_INDEX(z,(1<<lattice_size)); - - /*int ofs = z*(1<<lattice_size)*(1<<lattice_size)+y*(1<<lattice_size)+x; - ofs*=4; - oct->texture_x=ofs%otex_w; - oct->texture_y=(ofs/otex_w)*4+4; - */ - - oct->texture_x=(x+(1<<lattice_size)*z)*2; - oct->texture_y=4+y*4; - //print_line("pos: "+itos(x)+","+itos(y)+","+itos(z)+" - ofs"+itos(oct->texture_x)+","+itos(oct->texture_y)); - - - } else { - //an everyday regular octant - - if (col+2 > otex_w) { - col=0; - row+=4; - } - - oct->texture_x=col; - oct->texture_y=row; - col+=2; - regular_octants++; - - - } - } - print_line("octants end at row "+itos(row)+" totalling"+itos(regular_octants)); - - //ok evaluation. - - if (otex_w<=2048 && row>2048) { //too big upwards, try bigger texture - otex_w*=2; - continue; - } else { - baked_octree_texture_w=otex_w; - baked_octree_texture_h=row+4; - break; - } - - } - - - } - - - baked_octree_texture_h=next_power_of_2(baked_octree_texture_h); - print_line("RESULT! "+itos(baked_octree_texture_w)+","+itos(baked_octree_texture_h)); - -} - - - - - - - - -double BakedLightBaker::get_normalization(int p_light_idx) const { - - double nrg=0; - - const LightData &dl=lights[p_light_idx]; - double cell_area = cell_size*cell_size; - //nrg+= /*dl.energy */ (dl.rays_thrown * cell_area / dl.area); - nrg=dl.rays_thrown * cell_area; - nrg*=(Math_PI*plot_size*plot_size)*0.5; // damping of radial linear gradient kernel - nrg*=dl.constant; - //nrg*=5; - - - return nrg; -} - - - -double BakedLightBaker::get_modifier(int p_light_idx) const { - - double nrg=0; - - const LightData &dl=lights[p_light_idx]; - double cell_area = cell_size*cell_size; - //nrg+= /*dl.energy */ (dl.rays_thrown * cell_area / dl.area); - nrg=cell_area; - nrg*=(Math_PI*plot_size*plot_size)*0.5; // damping of radial linear gradient kernel - nrg*=dl.constant; - //nrg*=5; - - - return nrg; -} - -void BakedLightBaker::throw_rays(ThreadStack& thread_stack,int p_amount) { - - - - for(int i=0;i<lights.size();i++) { - - LightData &dl=lights[i]; - - - int amount = p_amount * total_light_area / dl.area; - double mod = 1.0/double(get_modifier(i)); - mod*=p_amount/float(amount); - - switch(dl.type) { - - case VS::LIGHT_DIRECTIONAL: { - - - for(int j=0;j<amount;j++) { - Vector3 from = dl.pos; - double r1 = double(rand())/RAND_MAX; - double r2 = double(rand())/RAND_MAX; - from+=dl.up*(r1*2.0-1.0); - from+=dl.left*(r2*2.0-1.0); - Vector3 to = from+dl.dir*dl.length; - Color col=dl.diffuse; - float m = mod*dl.energy; - col.r*=m; - col.g*=m; - col.b*=m; - - dl.rays_thrown++; - baked_light_baker_add_64i(&total_rays,1); - - _throw_ray(thread_stack,dl.bake_direct,from,to,dl.length,col,NULL,0,0,max_bounces,true); - } - } break; - case VS::LIGHT_OMNI: { - - - for(int j=0;j<amount;j++) { - Vector3 from = dl.pos; - - double r1 = double(rand())/RAND_MAX; - double r2 = double(rand())/RAND_MAX; - double r3 = double(rand())/RAND_MAX; - -#if 0 - //crap is not uniform.. - Vector3 dir = Vector3(r1*2.0-1.0,r2*2.0-1.0,r3*2.0-1.0).normalized(); - -#else - - double phi = r1*Math_PI*2.0; - double costheta = r2*2.0-1.0; - double u = r3; - - double theta = acos( costheta ); - double r = 1.0 * pow( u,1/3.0 ); - - Vector3 dir( - r * sin( theta) * cos( phi ), - r * sin( theta) * sin( phi ), - r * cos( theta ) - ); - dir.normalize(); - -#endif - Vector3 to = dl.pos+dir*dl.radius; - Color col=dl.diffuse; - float m = mod*dl.energy; - col.r*=m; - col.g*=m; - col.b*=m; - - dl.rays_thrown++; - baked_light_baker_add_64i(&total_rays,1); - _throw_ray(thread_stack,dl.bake_direct,from,to,dl.radius,col,dl.attenuation_table.ptr(),0,dl.radius,max_bounces,true); - //_throw_ray(i,from,to,dl.radius,col,NULL,0,dl.radius,max_bounces,true); - } - - } break; - case VS::LIGHT_SPOT: { - - for(int j=0;j<amount;j++) { - Vector3 from = dl.pos; - - double r1 = double(rand())/RAND_MAX; - //double r2 = double(rand())/RAND_MAX; - double r3 = double(rand())/RAND_MAX; - - float d=Math::tan(Math::deg2rad(dl.spot_angle)); - - float x = sin(r1*Math_PI*2.0)*d; - float y = cos(r1*Math_PI*2.0)*d; - - Vector3 dir = r3*(dl.dir + dl.up*y + dl.left*x) + (1.0-r3)*dl.dir; - dir.normalize(); - - - Vector3 to = dl.pos+dir*dl.radius; - Color col=dl.diffuse; - float m = mod*dl.energy; - col.r*=m; - col.g*=m; - col.b*=m; - - dl.rays_thrown++; - baked_light_baker_add_64i(&total_rays,1); - _throw_ray(thread_stack,dl.bake_direct,from,to,dl.radius,col,dl.attenuation_table.ptr(),0,dl.radius,max_bounces,true); - //_throw_ray(i,from,to,dl.radius,col,NULL,0,dl.radius,max_bounces,true); - } - - } break; - - } - } -} - - - - - - - - - - - - - -void BakedLightBaker::bake(const Ref<BakedLight> &p_light, Node* p_node) { - - if (baking) - return; - cell_count=0; - - base_inv=Object::cast_to<Spatial>(p_node)->get_global_transform().affine_inverse(); - EditorProgress ep("bake",TTR("Light Baker Setup:"),5); - baked_light=p_light; - lattice_size=baked_light->get_initial_lattice_subdiv(); - octree_depth=baked_light->get_cell_subdivision(); - plot_size=baked_light->get_plot_size(); - max_bounces=baked_light->get_bounces(); - use_diffuse=baked_light->get_bake_flag(BakedLight::BAKE_DIFFUSE); - use_specular=baked_light->get_bake_flag(BakedLight::BAKE_SPECULAR); - use_translucency=baked_light->get_bake_flag(BakedLight::BAKE_TRANSLUCENT); - - edge_damp=baked_light->get_edge_damp(); - normal_damp=baked_light->get_normal_damp(); - octree_extra_margin=baked_light->get_cell_extra_margin(); - tint=baked_light->get_tint(); - ao_radius=baked_light->get_ao_radius(); - ao_strength=baked_light->get_ao_strength(); - linear_color=baked_light->get_bake_flag(BakedLight::BAKE_LINEAR_COLOR); - - baked_textures.clear(); - for(int i=0;i<baked_light->get_lightmaps_count();i++) { - BakeTexture bt; - bt.width=baked_light->get_lightmap_gen_size(i).x; - bt.height=baked_light->get_lightmap_gen_size(i).y; - baked_textures.push_back(bt); - } - - - ep.step(TTR("Parsing Geometry"),0); - _parse_geometry(p_node); - mat_map.clear(); - tex_map.clear(); - print_line("\ttotal triangles: "+itos(triangles.size())); - // no geometry - if (triangles.size() == 0) { - return; - } - ep.step(TTR("Fixing Lights"),1); - _fix_lights(); - ep.step(TTR("Making BVH"),2); - _make_bvh(); - ep.step(TTR("Creating Light Octree"),3); - _make_octree(); - ep.step(TTR("Creating Octree Texture"),4); - _make_octree_texture(); - baking=true; - _start_thread(); - -} - - -void BakedLightBaker::update_octree_sampler(PoolVector<int> &p_sampler) { - - BakedLightBaker::Octant *octants=octant_pool.ptr(); - double norm = 1.0/double(total_rays); - - - - if (p_sampler.size()==0 || first_bake_to_map) { - - Vector<int> tmp_smp; - tmp_smp.resize(32); //32 for header - - for(int i=0;i<32;i++) { - tmp_smp[i]=0; - } - - for(int i=octant_pool_size-1;i>=0;i--) { - - if (i==0) - tmp_smp[1]=tmp_smp.size(); - - Octant &octant=octants[i]; - octant.sampler_ofs = tmp_smp.size(); - int idxcol[2]={0,0}; - - int r = CLAMP((octant.full_accum[0]*norm)*2048,0,32767); - int g = CLAMP((octant.full_accum[1]*norm)*2048,0,32767); - int b = CLAMP((octant.full_accum[2]*norm)*2048,0,32767); - - idxcol[0]|=r; - idxcol[1]|=(g<<16)|b; - - if (octant.leaf) { - tmp_smp.push_back(idxcol[0]); - tmp_smp.push_back(idxcol[1]); - } else { - - for(int j=0;j<8;j++) { - if (octant.children[j]) { - idxcol[0]|=(1<<(j+16)); - } - } - tmp_smp.push_back(idxcol[0]); - tmp_smp.push_back(idxcol[1]); - for(int j=0;j<8;j++) { - if (octant.children[j]) { - tmp_smp.push_back(octants[octant.children[j]].sampler_ofs); - if (octants[octant.children[j]].sampler_ofs==0) { - print_line("FUUUUUUUUCK"); - } - } - } - } - - } - - p_sampler.resize(tmp_smp.size()); - PoolVector<int>::Write w = p_sampler.write(); - int ss = tmp_smp.size(); - for(int i=0;i<ss;i++) { - w[i]=tmp_smp[i]; - } - - first_bake_to_map=false; - - } - - double gamma = baked_light->get_gamma_adjust(); - double mult = baked_light->get_energy_multiplier(); - float saturation = baked_light->get_saturation(); - - PoolVector<int>::Write w = p_sampler.write(); - - encode_uint32(octree_depth,(uint8_t*)&w[2]); - encode_uint32(linear_color,(uint8_t*)&w[3]); - - encode_float(octree_aabb.pos.x,(uint8_t*)&w[4]); - encode_float(octree_aabb.pos.y,(uint8_t*)&w[5]); - encode_float(octree_aabb.pos.z,(uint8_t*)&w[6]); - encode_float(octree_aabb.size.x,(uint8_t*)&w[7]); - encode_float(octree_aabb.size.y,(uint8_t*)&w[8]); - encode_float(octree_aabb.size.z,(uint8_t*)&w[9]); - - //norm*=multiplier; - - for(int i=octant_pool_size-1;i>=0;i--) { - - Octant &octant=octants[i]; - int idxcol[2]={w[octant.sampler_ofs],w[octant.sampler_ofs+1]}; - - double rf=pow(octant.full_accum[0]*norm*mult,gamma); - double gf=pow(octant.full_accum[1]*norm*mult,gamma); - double bf=pow(octant.full_accum[2]*norm*mult,gamma); - - double gray = (rf+gf+bf)/3.0; - rf = gray + (rf-gray)*saturation; - gf = gray + (gf-gray)*saturation; - bf = gray + (bf-gray)*saturation; - - - int r = CLAMP((rf)*2048,0,32767); - int g = CLAMP((gf)*2048,0,32767); - int b = CLAMP((bf)*2048,0,32767); - - idxcol[0]=((idxcol[0]>>16)<<16)|r; - idxcol[1]=(g<<16)|b; - w[octant.sampler_ofs]=idxcol[0]; - w[octant.sampler_ofs+1]=idxcol[1]; - } - -} - -void BakedLightBaker::update_octree_images(PoolVector<uint8_t> &p_octree,PoolVector<uint8_t> &p_light) { - - - int len = baked_octree_texture_w*baked_octree_texture_h*4; - p_octree.resize(len); - - int ilen = baked_light_texture_w*baked_light_texture_h*4; - p_light.resize(ilen); - - - PoolVector<uint8_t>::Write w = p_octree.write(); - zeromem(w.ptr(),len); - - PoolVector<uint8_t>::Write iw = p_light.write(); - zeromem(iw.ptr(),ilen); - - float gamma = baked_light->get_gamma_adjust(); - float mult = baked_light->get_energy_multiplier(); - - for(int i=0;i<len;i+=4) { - w[i+0]=0xFF; - w[i+1]=0; - w[i+2]=0xFF; - w[i+3]=0xFF; - } - - for(int i=0;i<ilen;i+=4) { - iw[i+0]=0xFF; - iw[i+1]=0; - iw[i+2]=0xFF; - iw[i+3]=0xFF; - } - - float multiplier=1.0; - - if (baked_light->get_format()==BakedLight::FORMAT_HDR8) - multiplier=8; - encode_uint32(baked_octree_texture_w,&w[0]); - encode_uint32(baked_octree_texture_h,&w[4]); - encode_uint32(0,&w[8]); - encode_float(1<<lattice_size,&w[12]); - encode_uint32(octree_depth-lattice_size,&w[16]); - encode_uint32(multiplier,&w[20]); - encode_uint16(baked_light_texture_w,&w[24]); //if present, use the baked light texture - encode_uint16(baked_light_texture_h,&w[26]); - encode_uint32(0,&w[28]); //baked light texture format - - encode_float(octree_aabb.pos.x,&w[32]); - encode_float(octree_aabb.pos.y,&w[36]); - encode_float(octree_aabb.pos.z,&w[40]); - encode_float(octree_aabb.size.x,&w[44]); - encode_float(octree_aabb.size.y,&w[48]); - encode_float(octree_aabb.size.z,&w[52]); - - - BakedLightBaker::Octant *octants=octant_pool.ptr(); - int octant_count=octant_pool_size; - uint8_t *ptr = w.ptr(); - uint8_t *lptr = iw.ptr(); - - - int child_offsets[8]={ - 0, - 4, - baked_octree_texture_w*4, - baked_octree_texture_w*4+4, - baked_octree_texture_w*8+0, - baked_octree_texture_w*8+4, - baked_octree_texture_w*8+baked_octree_texture_w*4, - baked_octree_texture_w*8+baked_octree_texture_w*4+4, - }; - - int lchild_offsets[8]={ - 0, - 4, - baked_light_texture_w*4, - baked_light_texture_w*4+4, - baked_light_texture_w*8+0, - baked_light_texture_w*8+4, - baked_light_texture_w*8+baked_light_texture_w*4, - baked_light_texture_w*8+baked_light_texture_w*4+4, - }; - - /*Vector<double> norm_arr; - norm_arr.resize(lights.size()); - - for(int i=0;i<lights.size();i++) { - norm_arr[i] = 1.0/get_normalization(i); - } - - const double *normptr=norm_arr.ptr(); -*/ - double norm = 1.0/double(total_rays); - mult/=multiplier; - double saturation = baked_light->get_saturation(); - - for(int i=0;i<octant_count;i++) { - - Octant &oct=octants[i]; - if (oct.texture_x==0 && oct.texture_y==0) - continue; - - - if (oct.leaf) { - - int ofs = (oct.texture_y * baked_light_texture_w + oct.texture_x)<<2; - ERR_CONTINUE(ofs<0 || ofs >ilen); - //write colors - for(int j=0;j<8;j++) { - - /* - if (!oct.children[j]) - continue; - */ - uint8_t *iptr=&lptr[ofs+lchild_offsets[j]]; - - float r=oct.light_accum[j][0]*norm; - float g=oct.light_accum[j][1]*norm; - float b=oct.light_accum[j][2]*norm; - - r=pow(r*mult,gamma); - g=pow(g*mult,gamma); - b=pow(b*mult,gamma); - - double gray = (r+g+b)/3.0; - r = gray + (r-gray)*saturation; - g = gray + (g-gray)*saturation; - b = gray + (b-gray)*saturation; - - float ic[3]={ - r, - g, - b, - }; - iptr[0]=CLAMP(ic[0]*255.0,0,255); - iptr[1]=CLAMP(ic[1]*255.0,0,255); - iptr[2]=CLAMP(ic[2]*255.0,0,255); - iptr[3]=255; - } - - } else { - - int ofs = (oct.texture_y * baked_octree_texture_w + oct.texture_x)<<2; - ERR_CONTINUE(ofs<0 || ofs >len); - - //write indices - for(int j=0;j<8;j++) { - - if (!oct.children[j]) - continue; - Octant&choct=octants[oct.children[j]]; - uint8_t *iptr=&ptr[ofs+child_offsets[j]]; - - iptr[0]=choct.texture_x>>8; - iptr[1]=choct.texture_x&0xFF; - iptr[2]=choct.texture_y>>8; - iptr[3]=choct.texture_y&0xFF; - - } - } - - } - - -} - - -void BakedLightBaker::_free_bvh(BVH* p_bvh) { - - if (!p_bvh->leaf) { - if (p_bvh->children[0]) - _free_bvh(p_bvh->children[0]); - if (p_bvh->children[1]) - _free_bvh(p_bvh->children[1]); - } - - memdelete(p_bvh); - -} - - -bool BakedLightBaker::is_baking() { - - return baking; -} - -void BakedLightBaker::set_pause(bool p_pause){ - - if (paused==p_pause) - return; - - paused=p_pause; - - if (paused) { - _stop_thread(); - } else { - _start_thread(); - } -} -bool BakedLightBaker::is_paused() { - - return paused; - -} - -void BakedLightBaker::_bake_thread_func(void *arg) { - - BakedLightBaker *ble = (BakedLightBaker*)arg; - - - - ThreadStack thread_stack; - - thread_stack.ray_stack = memnew_arr(uint32_t,ble->bvh_depth); - thread_stack.bvh_stack = memnew_arr(BVH*,ble->bvh_depth); - thread_stack.octant_stack = memnew_arr(uint32_t,ble->octree_depth*2 ); - thread_stack.octantptr_stack = memnew_arr(uint32_t,ble->octree_depth*2 ); - - while(!ble->bake_thread_exit) { - - ble->throw_rays(thread_stack,1000); - } - - memdelete_arr(thread_stack.ray_stack ); - memdelete_arr(thread_stack.bvh_stack ); - memdelete_arr(thread_stack.octant_stack ); - memdelete_arr(thread_stack.octantptr_stack ); - -} - -void BakedLightBaker::_start_thread() { - - if (threads.size()!=0) - return; - bake_thread_exit=false; - - int thread_count = EDITOR_DEF("light_baker/custom_bake_threads",0); - if (thread_count<=0 || thread_count>64) - thread_count=OS::get_singleton()->get_processor_count(); - - //thread_count=1; - threads.resize(thread_count); - for(int i=0;i<threads.size();i++) { - threads[i]=Thread::create(_bake_thread_func,this); - } -} - -void BakedLightBaker::_stop_thread() { - - if (threads.size()==0) - return; - bake_thread_exit=true; - for(int i=0;i<threads.size();i++) { - Thread::wait_to_finish(threads[i]); - memdelete(threads[i]); - } - threads.clear(); -} - -void BakedLightBaker::_plot_pixel_to_lightmap(int x, int y, int width, int height, uint8_t *image, const Vector3& p_pos,const Vector3& p_normal,double *p_norm_ptr,float mult,float gamma) { - - - uint8_t *ptr = &image[(y*width+x)*4]; - //int lc = lights.size(); - double norm = 1.0/double(total_rays); - - - Color color; - - Octant *octants=octant_pool.ptr(); - - - int octant_idx=0; - - - while(true) { - - Octant &octant=octants[octant_idx]; - - if (octant.leaf) { - - Vector3 lpos = p_pos-octant.aabb.pos; - lpos/=octant.aabb.size; - - Vector3 cols[8]; - - for(int i=0;i<8;i++) { - - cols[i].x+=octant.light_accum[i][0]*norm; - cols[i].y+=octant.light_accum[i][1]*norm; - cols[i].z+=octant.light_accum[i][2]*norm; - } - - - /*Vector3 final = (cols[0] + (cols[1] - cols[0]) * lpos.y); - final = final + ((cols[2] + (cols[3] - cols[2]) * lpos.y) - final)*lpos.x; - - Vector3 final2 = (cols[4+0] + (cols[4+1] - cols[4+0]) * lpos.y); - final2 = final2 + ((cols[4+2] + (cols[4+3] - cols[4+2]) * lpos.y) - final2)*lpos.x;*/ - - Vector3 finala = cols[0].linear_interpolate(cols[1],lpos.x); - Vector3 finalb = cols[2].linear_interpolate(cols[3],lpos.x); - Vector3 final = finala.linear_interpolate(finalb,lpos.y); - - Vector3 final2a = cols[4+0].linear_interpolate(cols[4+1],lpos.x); - Vector3 final2b = cols[4+2].linear_interpolate(cols[4+3],lpos.x); - Vector3 final2 = final2a.linear_interpolate(final2b,lpos.y); - - final = final.linear_interpolate(final2,lpos.z); - if (baked_light->get_format()==BakedLight::FORMAT_HDR8) - final*=8.0; - - - color.r=pow(final.x*mult,gamma); - color.g=pow(final.y*mult,gamma); - color.b=pow(final.z*mult,gamma); - color.a=1.0; - - int lc = lights.size(); - LightData *lv = lights.ptr(); - for(int i=0;i<lc;i++) { - //shadow baking - if (!lv[i].bake_shadow) - continue; - Vector3 from = p_pos+p_normal*0.01; - Vector3 to; - float att=0; - switch(lv[i].type) { - case VS::LIGHT_DIRECTIONAL: { - to=from-lv[i].dir*lv[i].length; - } break; - case VS::LIGHT_OMNI: { - to=lv[i].pos; - float d = MIN(lv[i].radius,to.distance_to(from))/lv[i].radius; - att=d;//1.0-d; - } break; - default: continue; - } - - uint32_t* stack = ray_stack; - BVH **bstack = bvh_stack; - - enum { - TEST_RAY_BIT=0, - VISIT_LEFT_BIT=1, - VISIT_RIGHT_BIT=2, - VISIT_DONE_BIT=3, - - - }; - - bool intersected=false; - - int level=0; - - Vector3 n = (to-from); - float len=n.length(); - if (len==0) - continue; - n/=len; - - bstack[0]=bvh; - stack[0]=TEST_RAY_BIT; - - - while(!intersected) { - - uint32_t mode = stack[level]; - const BVH &b = *bstack[level]; - bool done=false; - - switch(mode) { - case TEST_RAY_BIT: { - - if (b.leaf) { - - - Face3 f3(b.leaf->vertices[0],b.leaf->vertices[1],b.leaf->vertices[2]); - - - Vector3 res; - - if (f3.intersects_segment(from,to)) { - intersected=true; - done=true; - } - - stack[level]=VISIT_DONE_BIT; - } else { - - - bool valid = b.aabb.smits_intersect_ray(from,n,0,len); - //bool valid = b.aabb.intersects_segment(p_begin,p_end); - //bool valid = b.aabb.intersects(ray_aabb); - - if (!valid) { - - stack[level]=VISIT_DONE_BIT; - - } else { - - stack[level]=VISIT_LEFT_BIT; - } - } - - } continue; - case VISIT_LEFT_BIT: { - - stack[level]=VISIT_RIGHT_BIT; - bstack[level+1]=b.children[0]; - stack[level+1]=TEST_RAY_BIT; - level++; - - } continue; - case VISIT_RIGHT_BIT: { - - stack[level]=VISIT_DONE_BIT; - bstack[level+1]=b.children[1]; - stack[level+1]=TEST_RAY_BIT; - level++; - } continue; - case VISIT_DONE_BIT: { - - if (level==0) { - done=true; - break; - } else - level--; - - } continue; - } - - - if (done) - break; - } - - - - if (intersected) { - - color.a=Math::lerp(MAX(0.01,lv[i].darkening),1.0,att); - } - - } - - break; - } else { - - Vector3 lpos = p_pos - octant.aabb.pos; - Vector3 half = octant.aabb.size * 0.5; - - int ofs=0; - - if (lpos.x >= half.x) - ofs|=1; - if (lpos.y >= half.y) - ofs|=2; - if (lpos.z >= half.z) - ofs|=4; - - octant_idx = octant.children[ofs]; - - if (octant_idx==0) - return; - - } - } - - ptr[0]=CLAMP(color.r*255.0,0,255); - ptr[1]=CLAMP(color.g*255.0,0,255); - ptr[2]=CLAMP(color.b*255.0,0,255); - ptr[3]=CLAMP(color.a*255.0,0,255); - -} - - -Error BakedLightBaker::transfer_to_lightmaps() { - - if (!triangles.size() || baked_textures.size()==0) - return ERR_UNCONFIGURED; - - EditorProgress ep("transfer_to_lightmaps",TTR("Transfer to Lightmaps:"),baked_textures.size()*2+triangles.size()); - - for(int i=0;i<baked_textures.size();i++) { - - ERR_FAIL_COND_V( baked_textures[i].width<=0 || baked_textures[i].height<=0,ERR_UNCONFIGURED ); - - baked_textures[i].data.resize( baked_textures[i].width*baked_textures[i].height*4 ); - zeromem(baked_textures[i].data.ptr(),baked_textures[i].data.size()); - ep.step(TTR("Allocating Texture #")+itos(i+1),i); - } - - Vector<double> norm_arr; - norm_arr.resize(lights.size()); - - for(int i=0;i<lights.size();i++) { - norm_arr[i] = 1.0/get_normalization(i); - } - float gamma = baked_light->get_gamma_adjust(); - float mult = baked_light->get_energy_multiplier(); - - for(int i=0;i<triangles.size();i++) { - - if (i%200==0) { - ep.step(TTR("Baking Triangle #")+itos(i),i+baked_textures.size()); - } - Triangle &t=triangles[i]; - if (t.baked_texture<0 || t.baked_texture>=baked_textures.size()) - continue; - - BakeTexture &bt=baked_textures[t.baked_texture]; - Vector3 normal = Plane(t.vertices[0],t.vertices[1],t.vertices[2]).normal; - - - int x[3]; - int y[3]; - - Vector3 vertices[3]={ - t.vertices[0], - t.vertices[1], - t.vertices[2] - }; - - for(int j=0;j<3;j++) { - - x[j]=t.bake_uvs[j].x*bt.width; - y[j]=t.bake_uvs[j].y*bt.height; - x[j]=CLAMP(x[j],0,bt.width-1); - y[j]=CLAMP(y[j],0,bt.height-1); - } - - - { - - // sort the points vertically - if (y[1] > y[2]) { - SWAP(x[1], x[2]); - SWAP(y[1], y[2]); - SWAP(vertices[1],vertices[2]); - } - if (y[0] > y[1]) { - SWAP(x[0], x[1]); - SWAP(y[0], y[1]); - SWAP(vertices[0],vertices[1]); - } - if (y[1] > y[2]) { - SWAP(x[1], x[2]); - SWAP(y[1], y[2]); - SWAP(vertices[1],vertices[2]); - } - - double dx_far = double(x[2] - x[0]) / (y[2] - y[0] + 1); - double dx_upper = double(x[1] - x[0]) / (y[1] - y[0] + 1); - double dx_low = double(x[2] - x[1]) / (y[2] - y[1] + 1); - double xf = x[0]; - double xt = x[0] + dx_upper; // if y[0] == y[1], special case - for (int yi = y[0]; yi <= (y[2] > bt.height-1 ? bt.height-1 : y[2]); yi++) - { - if (yi >= 0) { - for (int xi = (xf > 0 ? int(xf) : 0); xi <= (xt < bt.width ? xt : bt.width-1) ; xi++) { - //pixels[int(x + y * width)] = color; - - Vector2 v0 = Vector2(x[1]-x[0],y[1]-y[0]); - Vector2 v1 = Vector2(x[2]-x[0],y[2]-y[0]); - //vertices[2] - vertices[0]; - Vector2 v2 = Vector2(xi-x[0],yi-y[0]); - float d00 = v0.dot( v0); - float d01 = v0.dot( v1); - float d11 = v1.dot( v1); - float d20 = v2.dot( v0); - float d21 = v2.dot( v1); - float denom = (d00 * d11 - d01 * d01); - Vector3 pos; - if (denom==0) { - pos=t.vertices[0]; - } else { - float v = (d11 * d20 - d01 * d21) / denom; - float w = (d00 * d21 - d01 * d20) / denom; - float u = 1.0f - v - w; - pos = vertices[0]*u + vertices[1]*v + vertices[2]*w; - } - _plot_pixel_to_lightmap(xi,yi,bt.width,bt.height,bt.data.ptr(),pos,normal,norm_arr.ptr(),mult,gamma); - - } - - for (int xi = (xf < bt.width ? int(xf) : bt.width-1); xi >= (xt > 0 ? xt : 0); xi--) { - //pixels[int(x + y * width)] = color; - Vector2 v0 = Vector2(x[1]-x[0],y[1]-y[0]); - Vector2 v1 = Vector2(x[2]-x[0],y[2]-y[0]); - //vertices[2] - vertices[0]; - Vector2 v2 = Vector2(xi-x[0],yi-y[0]); - float d00 = v0.dot( v0); - float d01 = v0.dot( v1); - float d11 = v1.dot( v1); - float d20 = v2.dot( v0); - float d21 = v2.dot( v1); - float denom = (d00 * d11 - d01 * d01); - Vector3 pos; - if (denom==0) { - pos=t.vertices[0]; - } else { - float v = (d11 * d20 - d01 * d21) / denom; - float w = (d00 * d21 - d01 * d20) / denom; - float u = 1.0f - v - w; - pos = vertices[0]*u + vertices[1]*v + vertices[2]*w; - } - - _plot_pixel_to_lightmap(xi,yi,bt.width,bt.height,bt.data.ptr(),pos,normal,norm_arr.ptr(),mult,gamma); - - } - } - xf += dx_far; - if (yi < y[1]) - xt += dx_upper; - else - xt += dx_low; - } - } - - } - - - for(int i=0;i<baked_textures.size();i++) { - - - { - - ep.step(TTR("Post-Processing Texture #")+itos(i),i+baked_textures.size()+triangles.size()); - - BakeTexture &bt=baked_textures[i]; - - Vector<uint8_t> copy_data=bt.data; - uint8_t *data=bt.data.ptr(); - const int max_radius=8; - const int shadow_radius=2; - const int max_dist=0x7FFFFFFF; - - for(int x=0;x<bt.width;x++) { - - for(int y=0;y<bt.height;y++) { - - - uint8_t a = copy_data[(y*bt.width+x)*4+3]; - - if (a>0) { - //blur shadow - - int from_x = MAX(0,x-shadow_radius); - int to_x = MIN(bt.width-1,x+shadow_radius); - int from_y = MAX(0,y-shadow_radius); - int to_y = MIN(bt.height-1,y+shadow_radius); - - int sum=0; - int sumc=0; - - for(int k=from_y;k<=to_y;k++) { - for(int l=from_x;l<=to_x;l++) { - - const uint8_t * rp = ©_data[(k*bt.width+l)<<2]; - - sum+=rp[3]; - sumc++; - } - } - - sum/=sumc; - data[(y*bt.width+x)*4+3]=sum; - - } else { - - int closest_dist=max_dist; - uint8_t closest_color[4]; - - int from_x = MAX(0,x-max_radius); - int to_x = MIN(bt.width-1,x+max_radius); - int from_y = MAX(0,y-max_radius); - int to_y = MIN(bt.height-1,y+max_radius); - - for(int k=from_y;k<=to_y;k++) { - for(int l=from_x;l<=to_x;l++) { - - int dy = y-k; - int dx = x-l; - int dist = dy*dy+dx*dx; - if (dist>=closest_dist) - continue; - - const uint8_t * rp = ©_data[(k*bt.width+l)<<2]; - - if (rp[3]==0) - continue; - - closest_dist=dist; - closest_color[0]=rp[0]; - closest_color[1]=rp[1]; - closest_color[2]=rp[2]; - closest_color[3]=rp[3]; - } - } - - - if (closest_dist!=max_dist) { - - data[(y*bt.width+x)*4+0]=closest_color[0]; - data[(y*bt.width+x)*4+1]=closest_color[1]; - data[(y*bt.width+x)*4+2]=closest_color[2]; - data[(y*bt.width+x)*4+3]=closest_color[3]; - } - } - } - } - } - - PoolVector<uint8_t> dv; - dv.resize(baked_textures[i].data.size()); - { - PoolVector<uint8_t>::Write w = dv.write(); - copymem(w.ptr(),baked_textures[i].data.ptr(),baked_textures[i].data.size()); - } - - Image img(baked_textures[i].width,baked_textures[i].height,0,Image::FORMAT_RGBA8,dv); - Ref<ImageTexture> tex = memnew( ImageTexture ); - tex->create_from_image(img); - baked_light->set_lightmap_texture(i,tex); - } - - - return OK; -} - -void BakedLightBaker::clear() { - - - - _stop_thread(); - - if (bvh) - _free_bvh(bvh); - - if (ray_stack) - memdelete_arr(ray_stack); - if (octant_stack) - memdelete_arr(octant_stack); - if (octantptr_stack) - memdelete_arr(octantptr_stack); - if (bvh_stack) - memdelete_arr(bvh_stack); -/* - * ??? - for(int i=0;i<octant_pool.size();i++) { - /* - if (octant_pool[i].leaf) { - memdelete_arr( octant_pool[i].light ); - } - Vector<double> norm_arr; - norm_arr.resize(lights.size()); - */ - - for(int i=0;i<lights.size();i++) { - norm_arr[i] = 1.0/get_normalization(i); - } - - const double *normptr=norm_arr.ptr(); - } -*/ - octant_pool.clear(); - octant_pool_size=0; - bvh=NULL; - leaf_list=0; - cell_count=0; - ray_stack=NULL; - octant_stack=NULL; - octantptr_stack=NULL; - bvh_stack=NULL; - materials.clear(); - materials.clear(); - textures.clear(); - lights.clear(); - triangles.clear(); - endpoint_normal.clear(); - endpoint_normal_bits.clear(); - baked_octree_texture_w=0; - baked_octree_texture_h=0; - paused=false; - baking=false; - - bake_thread_exit=false; - first_bake_to_map=true; - baked_light=Ref<BakedLight>(); - total_rays=0; - -} - -BakedLightBaker::BakedLightBaker() { - octree_depth=9; - lattice_size=4; - octant_pool.clear(); - octant_pool_size=0; - bvh=NULL; - leaf_list=0; - cell_count=0; - ray_stack=NULL; - bvh_stack=NULL; - octant_stack=NULL; - octantptr_stack=NULL; - plot_size=2.5; - max_bounces=2; - materials.clear(); - baked_octree_texture_w=0; - baked_octree_texture_h=0; - paused=false; - baking=false; - - bake_thread_exit=false; - total_rays=0; - first_bake_to_map=true; - linear_color=false; - -} - -BakedLightBaker::~BakedLightBaker() { - - clear(); -} -#endif diff --git a/editor/plugins/baked_light_baker.h b/editor/plugins/baked_light_baker.h deleted file mode 100644 index 123812fc07..0000000000 --- a/editor/plugins/baked_light_baker.h +++ /dev/null @@ -1,382 +0,0 @@ -/*************************************************************************/ -/* baked_light_baker.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 BAKED_LIGHT_BAKER_H -#define BAKED_LIGHT_BAKER_H - -#include "os/thread.h" - -#include "scene/3d/light.h" -#include "scene/3d/mesh_instance.h" - -#if 0 - -class BakedLightBaker { -public: - - enum { - - ATTENUATION_CURVE_LEN=256, - OCTANT_POOL_CHUNK=1000000 - }; - - /* - struct OctantLight { - double accum[8][3]; - }; - */ - - struct Octant { - bool leaf; - AABB aabb; - uint16_t texture_x; - uint16_t texture_y; - int sampler_ofs; - float normal_accum[8][3]; - double full_accum[3]; - int parent; - union { - struct { - int next_leaf; - float offset[3]; - int bake_neighbour; - bool first_neighbour; - double light_accum[8][3]; - }; - int children[8]; - }; - }; - - struct OctantHash { - - int next; - uint32_t hash; - uint64_t value; - - }; - - struct MeshTexture { - - Vector<uint8_t> tex; - int tex_w,tex_h; - - _FORCE_INLINE_ void get_color(const Vector2& p_uv,Color& ret) { - - if (tex_w && tex_h) { - - int x = Math::fast_ftoi(Math::fposmod(p_uv.x,1.0)*tex_w); - int y = Math::fast_ftoi(Math::fposmod(p_uv.y,1.0)*tex_w); - x=CLAMP(x,0,tex_w-1); - y=CLAMP(y,0,tex_h-1); - const uint8_t*ptr = &tex[(y*tex_w+x)*4]; - ret.r*=ptr[0]/255.0; - ret.g*=ptr[1]/255.0; - ret.b*=ptr[2]/255.0; - ret.a*=ptr[3]/255.0; - } - } - - }; - - struct Param { - - Color color; - MeshTexture*tex; - _FORCE_INLINE_ Color get_color(const Vector2& p_uv) { - - Color ret=color; - if (tex) - tex->get_color(p_uv,ret); - return ret; - - } - - }; - - struct MeshMaterial { - - Param diffuse; - Param specular; - Param emission; - }; - - struct Triangle { - - AABB aabb; - Vector3 vertices[3]; - Vector2 uvs[3]; - Vector2 bake_uvs[3]; - Vector3 normals[3]; - MeshMaterial *material; - int baked_texture; - - _FORCE_INLINE_ Vector2 get_uv(const Vector3& p_pos) { - - Vector3 v0 = vertices[1] - vertices[0]; - Vector3 v1 = vertices[2] - vertices[0]; - Vector3 v2 = p_pos - vertices[0]; - - float d00 = v0.dot( v0); - float d01 = v0.dot( v1); - float d11 = v1.dot( v1); - float d20 = v2.dot( v0); - float d21 = v2.dot( v1); - float denom = (d00 * d11 - d01 * d01); - if (denom==0) - return uvs[0]; - float v = (d11 * d20 - d01 * d21) / denom; - float w = (d00 * d21 - d01 * d20) / denom; - float u = 1.0f - v - w; - - return uvs[0]*u + uvs[1]*v + uvs[2]*w; - } - - _FORCE_INLINE_ void get_uv_and_normal(const Vector3& p_pos,Vector2& r_uv,Vector3& r_normal) { - - Vector3 v0 = vertices[1] - vertices[0]; - Vector3 v1 = vertices[2] - vertices[0]; - Vector3 v2 = p_pos - vertices[0]; - - float d00 = v0.dot( v0); - float d01 = v0.dot( v1); - float d11 = v1.dot( v1); - float d20 = v2.dot( v0); - float d21 = v2.dot( v1); - float denom = (d00 * d11 - d01 * d01); - if (denom==0) { - r_normal=normals[0]; - r_uv=uvs[0]; - return; - } - float v = (d11 * d20 - d01 * d21) / denom; - float w = (d00 * d21 - d01 * d20) / denom; - float u = 1.0f - v - w; - - r_uv=uvs[0]*u + uvs[1]*v + uvs[2]*w; - r_normal=(normals[0]*u+normals[1]*v+normals[2]*w).normalized(); - } - }; - - - struct BVH { - - AABB aabb; - Vector3 center; - Triangle *leaf; - BVH*children[2]; - }; - - - struct BVHCmpX { - - bool operator()(const BVH* p_left, const BVH* p_right) const { - - return p_left->center.x < p_right->center.x; - } - }; - - struct BVHCmpY { - - bool operator()(const BVH* p_left, const BVH* p_right) const { - - return p_left->center.y < p_right->center.y; - } - }; - struct BVHCmpZ { - - bool operator()(const BVH* p_left, const BVH* p_right) const { - - return p_left->center.z < p_right->center.z; - } - }; - - struct BakeTexture { - - Vector<uint8_t> data; - int width,height; - }; - - - struct LightData { - - VS::LightType type; - - Vector3 pos; - Vector3 up; - Vector3 left; - Vector3 dir; - Color diffuse; - Color specular; - float energy; - float length; - int rays_thrown; - bool bake_shadow; - - float radius; - float attenuation; - float spot_angle; - float darkening; - float spot_attenuation; - float area; - - float constant; - - bool bake_direct; - - Vector<float> attenuation_table; - - }; - - - Vector<LightData> lights; - - List<MeshMaterial> materials; - List<MeshTexture> textures; - - AABB octree_aabb; - Vector<Octant> octant_pool; - int octant_pool_size; - BVH*bvh; - Vector<Triangle> triangles; - Vector<BakeTexture> baked_textures; - Transform base_inv; - int leaf_list; - int octree_depth; - int bvh_depth; - int cell_count; - uint32_t *ray_stack; - BVH **bvh_stack; - uint32_t *octant_stack; - uint32_t *octantptr_stack; - - struct ThreadStack { - uint32_t *octant_stack; - uint32_t *octantptr_stack; - uint32_t *ray_stack; - BVH **bvh_stack; - }; - - Map<Vector3,Vector3> endpoint_normal; - Map<Vector3,uint64_t> endpoint_normal_bits; - - float cell_size; - float plot_size; //multiplied by cell size - float octree_extra_margin; - - int max_bounces; - int64_t total_rays; - bool use_diffuse; - bool use_specular; - bool use_translucency; - bool linear_color; - - - int baked_octree_texture_w; - int baked_octree_texture_h; - int baked_light_texture_w; - int baked_light_texture_h; - int lattice_size; - float edge_damp; - float normal_damp; - float tint; - float ao_radius; - float ao_strength; - - bool paused; - bool baking; - bool first_bake_to_map; - - Map<Ref<Material>,MeshMaterial*> mat_map; - Map<Ref<Texture>,MeshTexture*> tex_map; - - - - MeshTexture* _get_mat_tex(const Ref<Texture>& p_tex); - void _add_mesh(const Ref<Mesh>& p_mesh,const Ref<Material>& p_mat_override,const Transform& p_xform,int p_baked_texture=-1); - void _parse_geometry(Node* p_node); - BVH* _parse_bvh(BVH** p_children,int p_size,int p_depth,int& max_depth); - void _make_bvh(); - void _make_octree(); - void _make_octree_texture(); - void _octree_insert(int p_octant, Triangle* p_triangle, int p_depth); - _FORCE_INLINE_ void _plot_pixel_to_lightmap(int x, int y, int width, int height, uint8_t *image, const Vector3& p_pos,const Vector3& p_normal,double *p_norm_ptr,float mult,float gamma); - - - void _free_bvh(BVH* p_bvh); - - void _fix_lights(); - - Ref<BakedLight> baked_light; - - - //void _plot_light(const Vector3& p_plot_pos,const AABB& p_plot_aabb,const Color& p_light,int p_octant=0); - void _plot_light(ThreadStack& thread_stack,const Vector3& p_plot_pos,const AABB& p_plot_aabb,const Color& p_light,const Color& p_tint_light,bool p_only_full,const Plane& p_plane); - //void _plot_light_point(const Vector3& p_plot_pos, Octant *p_octant, const AABB& p_aabb,const Color& p_light); - - float _throw_ray(ThreadStack& thread_stack,bool p_bake_direct,const Vector3& p_begin, const Vector3& p_end,float p_rest,const Color& p_light,float *p_att_curve,float p_att_pos,int p_att_curve_len,int p_bounces,bool p_first_bounce=false,bool p_only_dist=false); - - - float total_light_area; - - Vector<Thread*> threads; - - bool bake_thread_exit; - static void _bake_thread_func(void *arg); - - void _start_thread(); - void _stop_thread(); -public: - - - void throw_rays(ThreadStack &thread_stack, int p_amount); - double get_normalization(int p_light_idx) const; - double get_modifier(int p_light_idx) const; - - void bake(const Ref<BakedLight>& p_light,Node *p_base); - bool is_baking(); - void set_pause(bool p_pause); - bool is_paused(); - uint64_t get_rays_thrown() { return total_rays; } - - Error transfer_to_lightmaps(); - - void update_octree_sampler(PoolVector<int> &p_sampler); - void update_octree_images(PoolVector<uint8_t> &p_octree,PoolVector<uint8_t> &p_light); - - Ref<BakedLight> get_baked_light() { return baked_light; } - - void clear(); - - BakedLightBaker(); - ~BakedLightBaker(); - -}; - -#endif // BAKED_LIGHT_BAKER_H -#endif diff --git a/editor/plugins/baked_light_baker_cmpxchg.cpp b/editor/plugins/baked_light_baker_cmpxchg.cpp deleted file mode 100644 index f0a1aea416..0000000000 --- a/editor/plugins/baked_light_baker_cmpxchg.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/*************************************************************************/ -/* baked_light_baker_cmpxchg.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "typedefs.h" - -#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100 - -void baked_light_baker_add_64f(double *dst, double value) { - - union { - int64_t i; - double f; - } swapy; - - while (true) { - swapy.f = *dst; - int64_t from = swapy.i; - swapy.f += value; - int64_t to = swapy.i; - if (__sync_bool_compare_and_swap((int64_t *)dst, from, to)) - break; - } -} - -void baked_light_baker_add_64i(int64_t *dst, int64_t value) { - - while (!__sync_bool_compare_and_swap(dst, *dst, (*dst) + value)) { - } -} - -#elif defined(WINDOWS_ENABLED) - -#include "windows.h" - -void baked_light_baker_add_64f(double *dst, double value) { - - union { - int64_t i; - double f; - } swapy; - - while (true) { - swapy.f = *dst; - int64_t from = swapy.i; - swapy.f += value; - int64_t to = swapy.i; - int64_t result = InterlockedCompareExchange64((int64_t *)dst, to, from); - if (result == from) - break; - } -} - -void baked_light_baker_add_64i(int64_t *dst, int64_t value) { - - while (true) { - int64_t from = *dst; - int64_t to = from + value; - int64_t result = InterlockedCompareExchange64(dst, to, from); - if (result == from) - break; - } -} - -#else - -//in goder (the god of programmers) we trust -#warning seems this platform or compiler does not support safe cmpxchg, your baked lighting may be funny - -void baked_light_baker_add_64f(double *dst, double value) { - - *dst += value; -} - -void baked_light_baker_add_64i(int64_t *dst, int64_t value) { - - *dst += value; -} - -#endif diff --git a/editor/plugins/baked_light_editor_plugin.cpp b/editor/plugins/baked_light_editor_plugin.cpp deleted file mode 100644 index 85058ed108..0000000000 --- a/editor/plugins/baked_light_editor_plugin.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/*************************************************************************/ -/* baked_light_editor_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "baked_light_editor_plugin.h" - -#include "io/marshalls.h" -#include "io/resource_saver.h" -#include "scene/3d/mesh_instance.h" -#include "scene/gui/box_container.h" - -#if 0 - - -void BakedLightEditor::_end_baking() { - - baker->clear(); - set_process(false); - button_bake->set_pressed(false); - bake_info->set_text(""); -} - -void BakedLightEditor::_node_removed(Node *p_node) { - - if(p_node==node) { - _end_baking(); - node=NULL; - - hide(); - } - -} - - - - - -void BakedLightEditor::_notification(int p_option) { - - - if (p_option==NOTIFICATION_ENTER_TREE) { - - button_bake->set_icon(get_icon("Bake","EditorIcons")); - button_reset->set_icon(get_icon("Reload","EditorIcons")); - button_make_lightmaps->set_icon(get_icon("LightMap","EditorIcons")); - } - - if (p_option==NOTIFICATION_PROCESS) { - - if (baker->is_baking() && !baker->is_paused()) { - - update_timeout-=get_process_delta_time(); - if (update_timeout<0) { - - if (baker->get_baked_light()!=node->get_baked_light()) { - _end_baking(); - return; - } - - uint64_t t = OS::get_singleton()->get_ticks_msec(); - -#ifdef DEBUG_CUBES - double norm = baker->get_normalization(); - float max_lum=0; - - { - PoolVector<Color>::Write cw=colors.write(); - BakedLightBaker::Octant *octants=baker->octant_pool.ptr(); - BakedLightBaker::Octant *oct = &octants[baker->leaf_list]; - int vert_idx=0; - - while(oct) { - - - - Color colors[8]; - for(int i=0;i<8;i++) { - - colors[i].r=oct->light_accum[i][0]/norm; - colors[i].g=oct->light_accum[i][1]/norm; - colors[i].b=oct->light_accum[i][2]/norm; - - float lum = colors[i].get_v(); - /* - if (lum<0.05) - color.a=0; - */ - if (lum>max_lum) - max_lum=lum; - - } - static const int vert2cub[36]={7,3,1,1,5,7,7,6,2,2,3,7,7,5,4,4,6,7,2,6,4,4,0,2,4,5,1,1,0,4,1,3,2,2,0,1}; - for (int i=0;i<36;i++) { - - - cw[vert_idx++]=colors[vert2cub[i]]; - } - - if (oct->next_leaf) - oct=&octants[oct->next_leaf]; - else - oct=NULL; - - } - } - print_line("MSCOL: "+itos(OS::get_singleton()->get_ticks_msec()-t)); - t = OS::get_singleton()->get_ticks_msec(); - - Array a; - a.resize(Mesh::ARRAY_MAX); - a[Mesh::ARRAY_VERTEX]=vertices; - a[Mesh::ARRAY_COLOR]=colors; - while(mesh->get_surface_count()) - mesh->surface_remove(0); - mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,a); - mesh->surface_set_material(0,material); -#endif - ERR_FAIL_COND(node->get_baked_light().is_null()); - - baker->update_octree_images(octree_texture,light_texture); - baker->update_octree_sampler(octree_sampler); - //print_line("sampler size: "+itos(octree_sampler.size()*4)); - -#if 1 -//debug - Image img(baker->baked_octree_texture_w,baker->baked_octree_texture_h,0,Image::FORMAT_RGBA8,octree_texture); - Ref<ImageTexture> it = memnew( ImageTexture ); - it->create_from_image(img); - ResourceSaver::save("baked_octree.png",it); - -#endif - - - uint64_t rays_snap = baker->get_rays_thrown(); - int rays_sec = (rays_snap-last_rays_time)*1.0-(update_timeout); - last_rays_time=rays_snap; - - bake_info->set_text("rays/s: "+itos(rays_sec)); - update_timeout=1; - print_line("MSUPDATE: "+itos(OS::get_singleton()->get_ticks_msec()-t)); - t=OS::get_singleton()->get_ticks_msec(); - node->get_baked_light()->set_octree(octree_texture); - node->get_baked_light()->set_light(light_texture); - node->get_baked_light()->set_sampler_octree(octree_sampler); - node->get_baked_light()->set_edited(true); - - print_line("MSSET: "+itos(OS::get_singleton()->get_ticks_msec()-t)); - - - - } - } - } -} - - -void BakedLightEditor::_menu_option(int p_option) { - - - switch(p_option) { - - - case MENU_OPTION_BAKE: { - - ERR_FAIL_COND(!node); - ERR_FAIL_COND(node->get_baked_light().is_null()); - baker->bake(node->get_baked_light(),node); - node->get_baked_light()->set_mode(BakedLight::MODE_OCTREE); - update_timeout=0; - set_process(true); - - - } break; - case MENU_OPTION_CLEAR: { - - - - } break; - - } -} - -void BakedLightEditor::_bake_pressed() { - - ERR_FAIL_COND(!node); - const String conf_warning = node->get_configuration_warning(); - if (!conf_warning.empty()) { - err_dialog->set_text(conf_warning); - err_dialog->popup_centered_minsize(); - button_bake->set_pressed(false); - return; - } - - if (baker->is_baking()) { - - baker->set_pause(!button_bake->is_pressed()); - if (baker->is_paused()) { - - set_process(false); - bake_info->set_text(""); - button_reset->show(); - button_make_lightmaps->show(); - - } else { - - update_timeout=0; - set_process(true); - button_make_lightmaps->hide(); - button_reset->hide(); - } - } else { - baker->bake(node->get_baked_light(),node); - node->get_baked_light()->set_mode(BakedLight::MODE_OCTREE); - update_timeout=0; - - last_rays_time=0; - button_bake->set_pressed(false); - - set_process(true); - } - -} - -void BakedLightEditor::_clear_pressed(){ - - baker->clear(); - button_bake->set_pressed(false); - bake_info->set_text(""); - -} - -void BakedLightEditor::edit(BakedLightInstance *p_baked_light) { - - if (p_baked_light==NULL || node==p_baked_light) { - return; - } - if (node && node!=p_baked_light) - _end_baking(); - - - node=p_baked_light; - //_end_baking(); - -} - -void BakedLightEditor::_bake_lightmaps() { - - Error err = baker->transfer_to_lightmaps(); - if (err) { - - err_dialog->set_text("Error baking to lightmaps!\nMake sure that a bake has just\n happened and that lightmaps are\n configured. "); - err_dialog->popup_centered_minsize(); - return; - } - - node->get_baked_light()->set_mode(BakedLight::MODE_LIGHTMAPS); - - -} - -void BakedLightEditor::_bind_methods() { - - ClassDB::bind_method("_menu_option",&BakedLightEditor::_menu_option); - ClassDB::bind_method("_bake_pressed",&BakedLightEditor::_bake_pressed); - ClassDB::bind_method("_clear_pressed",&BakedLightEditor::_clear_pressed); - ClassDB::bind_method("_bake_lightmaps",&BakedLightEditor::_bake_lightmaps); -} - -BakedLightEditor::BakedLightEditor() { - - - bake_hbox = memnew( HBoxContainer ); - button_bake = memnew( ToolButton ); - button_bake->set_text(TTR("Bake!")); - button_bake->set_toggle_mode(true); - button_reset = memnew( Button ); - button_make_lightmaps = memnew( Button ); - button_bake->set_tooltip("Start/Unpause the baking process.\nThis bakes lighting into the lightmap octree."); - button_make_lightmaps ->set_tooltip("Convert the lightmap octree to lightmap textures\n(must have set up UV/Lightmaps properly before!)."); - - - bake_info = memnew( Label ); - bake_hbox->add_child( button_bake ); - bake_hbox->add_child( button_reset ); - bake_hbox->add_child( bake_info ); - - err_dialog = memnew( AcceptDialog ); - add_child(err_dialog); - node=NULL; - baker = memnew( BakedLightBaker ); - - bake_hbox->add_child(button_make_lightmaps); - button_make_lightmaps->hide(); - - button_bake->connect("pressed",this,"_bake_pressed"); - button_reset->connect("pressed",this,"_clear_pressed"); - button_make_lightmaps->connect("pressed",this,"_bake_lightmaps"); - button_reset->hide(); - button_reset->set_tooltip(TTR("Reset the lightmap octree baking process (start over).")); - - - update_timeout=0; - - - -} - -BakedLightEditor::~BakedLightEditor() { - - memdelete(baker); -} - -void BakedLightEditorPlugin::edit(Object *p_object) { - - baked_light_editor->edit(Object::cast_to<BakedLightInstance>(p_object)); -} - -bool BakedLightEditorPlugin::handles(Object *p_object) const { - - return p_object->is_type("BakedLightInstance"); -} - -void BakedLightEditorPlugin::make_visible(bool p_visible) { - - if (p_visible) { - baked_light_editor->show(); - baked_light_editor->bake_hbox->show(); - } else { - - baked_light_editor->hide(); - baked_light_editor->bake_hbox->hide(); - baked_light_editor->edit(NULL); - } - -} - -BakedLightEditorPlugin::BakedLightEditorPlugin(EditorNode *p_node) { - - editor=p_node; - baked_light_editor = memnew( BakedLightEditor ); - editor->get_viewport()->add_child(baked_light_editor); - add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU,baked_light_editor->bake_hbox); - baked_light_editor->hide(); - baked_light_editor->bake_hbox->hide(); -} - - -BakedLightEditorPlugin::~BakedLightEditorPlugin() -{ -} - -#endif diff --git a/editor/plugins/baked_light_editor_plugin.h b/editor/plugins/baked_light_editor_plugin.h deleted file mode 100644 index c4a7cd51cf..0000000000 --- a/editor/plugins/baked_light_editor_plugin.h +++ /dev/null @@ -1,118 +0,0 @@ -/*************************************************************************/ -/* baked_light_editor_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 BAKED_LIGHT_EDITOR_PLUGIN_H -#define BAKED_LIGHT_EDITOR_PLUGIN_H - -#include "editor/editor_node.h" -#include "editor/editor_plugin.h" -#include "editor/plugins/baked_light_baker.h" -#include "scene/gui/spin_box.h" - -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - -#if 0 - -class MeshInstance; - -class BakedLightEditor : public Control { - - GDCLASS(BakedLightEditor, Control ); - - - float update_timeout; - PoolVector<uint8_t> octree_texture; - PoolVector<uint8_t> light_texture; - PoolVector<int> octree_sampler; - - BakedLightBaker *baker; - AcceptDialog *err_dialog; - - HBoxContainer *bake_hbox; - Button *button_bake; - Button *button_reset; - Button *button_make_lightmaps; - Label *bake_info; - - uint64_t last_rays_time; - - - - BakedLightInstance *node; - - enum Menu { - - MENU_OPTION_BAKE, - MENU_OPTION_CLEAR - }; - - void _bake_lightmaps(); - - void _bake_pressed(); - void _clear_pressed(); - - void _end_baking(); - void _menu_option(int); - -friend class BakedLightEditorPlugin; -protected: - void _node_removed(Node *p_node); - static void _bind_methods(); - void _notification(int p_what); -public: - - void edit(BakedLightInstance *p_baked_light); - BakedLightEditor(); - ~BakedLightEditor(); -}; - -class BakedLightEditorPlugin : public EditorPlugin { - - GDCLASS( BakedLightEditorPlugin, EditorPlugin ); - - BakedLightEditor *baked_light_editor; - EditorNode *editor; - -public: - - virtual String get_name() const { return "BakedLight"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_node); - virtual bool handles(Object *p_node) const; - virtual void make_visible(bool p_visible); - - BakedLightEditorPlugin(EditorNode *p_node); - ~BakedLightEditorPlugin(); - -}; - -#endif // MULTIMESH_EDITOR_PLUGIN_H -#endif diff --git a/editor/plugins/camera_editor_plugin.cpp b/editor/plugins/camera_editor_plugin.cpp index 18ee8d8db3..c19540116e 100644 --- a/editor/plugins/camera_editor_plugin.cpp +++ b/editor/plugins/camera_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/camera_editor_plugin.h b/editor/plugins/camera_editor_plugin.h index a0f98687cb..12702db7a5 100644 --- a/editor/plugins/camera_editor_plugin.h +++ b/editor/plugins/camera_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 701952d249..329395d9c4 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -382,54 +382,15 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) { void CanvasItemEditor::_add_canvas_item(CanvasItem *p_canvas_item) { editor_selection->add_node(p_canvas_item); -#if 0 - if (canvas_items.has(p_canvas_item)) - return; - - canvas_items.insert(p_canvas_item,p_info); - p_canvas_item->connect("hide",this,"_visibility_changed",varray(p_canvas_item->get_instance_id()),CONNECT_ONESHOT); -#endif } void CanvasItemEditor::_remove_canvas_item(CanvasItem *p_canvas_item) { editor_selection->remove_node(p_canvas_item); -#if 0 - p_canvas_item->disconnect("hide",this,"_visibility_changed"); - canvas_items.erase(p_canvas_item); -#endif } void CanvasItemEditor::_clear_canvas_items() { editor_selection->clear(); -#if 0 - while(canvas_items.size()) - _remove_canvas_item(canvas_items.front()->key()); -#endif -} - -void CanvasItemEditor::_visibility_changed(ObjectID p_canvas_item) { -#if 0 - Object *c = ObjectDB::get_instance(p_canvas_item); - if (!c) - return; - CanvasItem *ct = Object::cast_to<CanvasItem>(c); - if (!ct) - return; - canvas_items.erase(ct); - //_remove_canvas_item(ct); - update(); -#endif -} - -void CanvasItemEditor::_node_removed(Node *p_node) { -#if 0 - CanvasItem *canvas_item = (CanvasItem*)p_node; //not a good cast, but safe - if (canvas_items.has(canvas_item)) - _remove_canvas_item(canvas_item); - - update(); -#endif } void CanvasItemEditor::_keying_changed() { @@ -993,11 +954,6 @@ void CanvasItemEditor::_selection_menu_hide() { selection_menu->set_size(Vector2(0, 0)); } -bool CanvasItemEditor::get_remove_list(List<Node *> *p_list) { - - return false; //!p_list->empty(); -} - void CanvasItemEditor::_list_select(const Ref<InputEventMouseButton> &b) { Point2 click = b->get_position(); @@ -2392,14 +2348,6 @@ void CanvasItemEditor::_notification(int p_what) { AnimationPlayerEditor::singleton->get_key_editor()->connect("visibility_changed", this, "_keying_changed"); _keying_changed(); } - - if (p_what == NOTIFICATION_READY) { - - get_tree()->connect("node_removed", this, "_node_removed"); - } - - if (p_what == NOTIFICATION_DRAW) { - } } void CanvasItemEditor::edit(CanvasItem *p_canvas_item) { @@ -2774,50 +2722,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { viewport->update(); } break; - - case ALIGN_VERTICAL: { -#if 0 - if ( ref_item && canvas_items.size() > 1 ) { - Vector2 ref_pos = ref_item->get_global_transform().elements[2]; - Rect2 ref_r = ref_item->get_item_rect(); - for ( CanvasItemMap::Element *E = canvas_items.front(); E; E = E->next() ) { - CanvasItem *it_curr = E->key(); - if ( it_curr == ref_item ) continue; - Vector2 v = it_curr->get_global_transform().elements[2]; - Rect2 r = it_curr->get_item_rect(); - r.pos.x = ( ref_pos.x + ref_r.size.x / 2 ) - ( v.x + r.size.x / 2 ); - it_curr->edit_set_rect( r ); - } - viewport->update(); - } -#endif - } break; - - case ALIGN_HORIZONTAL: { -#if 0 - if ( ref_item && canvas_items.size() > 1 ) { - Vector2 ref_pos = ref_item->get_global_transform().elements[2]; - Rect2 ref_r = ref_item->get_item_rect(); - for ( CanvasItemMap::Element *E = canvas_items.front(); E; E = E->next() ) { - CanvasItem *it_curr = E->key(); - if ( it_curr == ref_item ) continue; - Vector2 v = it_curr->get_global_transform().elements[2]; - Rect2 r = it_curr->get_item_rect(); - r.pos.y = ( ref_pos.y + ref_r.size.y / 2 ) - ( v.y + r.size.y / 2 ); - it_curr->edit_set_rect( r ); - } - viewport->update(); - } -#endif - } break; - - case SPACE_HORIZONTAL: { - //space_selected_items< proj_vector2_x, compare_items_x >(); - } break; - - case SPACE_VERTICAL: { - //space_selected_items< proj_vector2_y, compare_items_y >(); - } break; case ANCHOR_ALIGN_TOP_LEFT: { _set_anchors_preset(PRESET_TOP_LEFT); } break; @@ -3154,34 +3058,6 @@ void CanvasItemEditor::_popup_callback(int p_op) { } break; } } -#if 0 -template< class P, class C > void CanvasItemEditor::space_selected_items() { - P p; - if ( canvas_items.size() > 2 ) { - Vector< CanvasItem * > items; - for ( CanvasItemMap::Element *E = canvas_items.front(); E; E = E->next() ) { - CanvasItem *it_curr = E->key(); - items.push_back( it_curr ); - } - items.sort_custom< C >(); - - float width_s = p.get( items[0]->get_item_rect().size ); - float width_e = p.get( items[ items.size() - 1 ]->get_item_rect().size ); - float start_x = p.get( items[0]->get_global_transform().elements[2] ) + ( width_s / 2 ); - float end_x = p.get( items[ items.size() - 1 ]->get_global_transform().elements[2] ) + ( width_e / 2 ); - float sp = ( end_x - start_x ) / ( items.size() - 1 ); - - for ( int i = 0; i < items.size(); i++ ) { - CanvasItem *it_curr = items[i]; - Vector2 v = it_curr->get_global_transform().elements[2]; - Rect2 r = it_curr->get_item_rect(); - p.set( r.pos, ( start_x + sp * i ) - ( p.get( v ) + p.get( r.size ) / 2 ) ); - it_curr->edit_set_rect( r ); - } - viewport->update(); - } -} -#endif void CanvasItemEditor::_focus_selection(int p_op) { Vector2 center(0.f, 0.f); @@ -3238,10 +3114,8 @@ void CanvasItemEditor::_focus_selection(int p_op) { void CanvasItemEditor::_bind_methods() { - ClassDB::bind_method("_node_removed", &CanvasItemEditor::_node_removed); ClassDB::bind_method("_update_scroll", &CanvasItemEditor::_update_scroll); ClassDB::bind_method("_popup_callback", &CanvasItemEditor::_popup_callback); - ClassDB::bind_method("_visibility_changed", &CanvasItemEditor::_visibility_changed); ClassDB::bind_method("_dialog_value_changed", &CanvasItemEditor::_dialog_value_changed); ClassDB::bind_method("_get_editor_data", &CanvasItemEditor::_get_editor_data); ClassDB::bind_method("_tool_select", &CanvasItemEditor::_tool_select); @@ -3257,74 +3131,6 @@ void CanvasItemEditor::_bind_methods() { ADD_SIGNAL(MethodInfo("item_group_status_changed")); } -#if 0 -void CanvasItemEditor::end_drag() { - print_line( "end drag" ); - - if (undo_redo) { - - undo_redo->create_action("Edit CanvasItem"); - for(CanvasItemMap::Element *E=canvas_items.front();E;E=E->next()) { - CanvasItem *canvas_item = E->key(); - Variant state=canvas_item->edit_get_state(); - undo_redo->add_do_method(canvas_item,"edit_set_state",state); - undo_redo->add_undo_method(canvas_item,"edit_set_state",E->get().undo_state); - } - undo_redo->commit_action(); - } - - drag=DRAG_NONE; - viewport->update(); -} - -void CanvasItemEditor::box_selection_start( Point2 &click ) { - print_line( "box selection start" ); - - drag_from=transform.affine_inverse().xform(click); - - box_selecting=true; - box_selecting_to=drag_from; - viewport->update(); -} - -bool CanvasItemEditor::box_selection_end() { - print_line( "box selection end" ); - - Node* scene = Object::cast_to<EditorNode>(get_scene()->get_root_node())->get_edited_scene(); - if (scene) { - - List<CanvasItem*> selitems; - - Point2 bsfrom = transform.xform(drag_from); - Point2 bsto= transform.xform(box_selecting_to); - if (bsfrom.x>bsto.x) - SWAP(bsfrom.x,bsto.x); - if (bsfrom.y>bsto.y) - SWAP(bsfrom.y,bsto.y); - - if ( bsfrom.distance_to( bsto ) < 3 ) { - print_line( "box selection too small" ); - box_selecting=false; - viewport->update(); - return false; - } - - _find_canvas_items_at_rect(Rect2(bsfrom,bsto-bsfrom),scene,transform,&selitems); - - for(List<CanvasItem*>::Element *E=selitems.front();E;E=E->next()) { - - _append_canvas_item(E->get()); - } - - } - - box_selecting=false; - viewport->update(); - - return true; -} -#endif - void CanvasItemEditor::add_control_to_menu_panel(Control *p_control) { hb->add_child(p_control); @@ -3495,12 +3301,6 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { skeleton_menu->set_hide_on_checkable_item_selection(false); skeleton_menu->connect("id_pressed", this, "_popup_callback"); - /* - p->add_item("Align Horizontal",ALIGN_HORIZONTAL); - p->add_item("Align Vertical",ALIGN_VERTICAL); - p->add_item("Space Horizontal",SPACE_HORIZONTAL); - p->add_item("Space Vertical",SPACE_VERTICAL);*/ - view_menu = memnew(MenuButton); view_menu->set_text(TTR("View")); hb->add_child(view_menu); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 0291660d42..8f67d641f5 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -94,8 +94,6 @@ class CanvasItemEditor : public VBoxContainer { UNLOCK_SELECTED, GROUP_SELECTED, UNGROUP_SELECTED, - ALIGN_HORIZONTAL, - ALIGN_VERTICAL, ANCHOR_ALIGN_TOP_LEFT, ANCHOR_ALIGN_TOP_RIGHT, ANCHOR_ALIGN_BOTTOM_LEFT, @@ -113,9 +111,6 @@ class CanvasItemEditor : public VBoxContainer { ANCHOR_ALIGN_HCENTER_WIDE, ANCHOR_ALIGN_WIDE, ANCHOR_ALIGN_WIDE_FIT, - - SPACE_HORIZONTAL, - SPACE_VERTICAL, ANIM_INSERT_KEY, ANIM_INSERT_KEY_EXISTING, ANIM_INSERT_POS, @@ -289,20 +284,7 @@ class CanvasItemEditor : public VBoxContainer { bool updating_value_dialog; Point2 display_rotate_from; Point2 display_rotate_to; -#if 0 - struct EditInfo { - - Variant undo_state; - Matrix32 prev_xform; - float prev_rot; - Rect2 prev_rect; - EditInfo() { prev_rot=0; } - }; - - typedef Map<CanvasItem*,EditInfo> CanvasItemMap; - CanvasItemMap canvas_items; -#endif Ref<StyleBoxTexture> select_sb; Ref<Texture> select_handle; Ref<Texture> anchor_handle; @@ -327,7 +309,6 @@ class CanvasItemEditor : public VBoxContainer { void _add_canvas_item(CanvasItem *p_canvas_item); void _remove_canvas_item(CanvasItem *p_canvas_item); void _clear_canvas_items(); - void _visibility_changed(ObjectID p_canvas_item); void _key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE p_move_mode); void _list_select(const Ref<InputEventMouseButton> &b); @@ -384,7 +365,6 @@ class CanvasItemEditor : public VBoxContainer { protected: void _notification(int p_what); - void _node_removed(Node *p_node); static void _bind_methods(); void end_drag(); void box_selection_start(Point2 &click); @@ -436,7 +416,6 @@ public: Control *get_viewport_control() { return viewport; } - bool get_remove_list(List<Node *> *p_list); void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; } void edit(CanvasItem *p_canvas_item); @@ -458,7 +437,6 @@ public: virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); - virtual bool get_remove_list(List<Node *> *p_list) { return canvas_item_editor->get_remove_list(p_list); } virtual Dictionary get_state() const; virtual void set_state(const Dictionary &p_state); diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp index 09c75b9e87..c90462db1d 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -386,17 +386,6 @@ CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) { button_edit->set_toggle_mode(true); button_edit->set_tooltip(TTR("Edit existing polygon:\nLMB: Move Point.\nCtrl+LMB: Split Segment.\nRMB: Erase Point.")); -//add_constant_override("separation",0); - -#if 0 - options = memnew( MenuButton ); - add_child(options); - options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCode",PARSE_BBCODE); - options->get_popup()->connect("id_pressed", this,"_menu_option"); -#endif - mode = MODE_EDIT; wip_active = false; } diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.h b/editor/plugins/collision_polygon_2d_editor_plugin.h index b2f32d8491..bc3c5a1659 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.h +++ b/editor/plugins/collision_polygon_2d_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index c6fa796226..3ac055e650 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -510,17 +510,6 @@ CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) { button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT)); button_edit->set_toggle_mode(true); -//add_constant_override("separation",0); - -#if 0 - options = memnew( MenuButton ); - add_child(options); - options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCode",PARSE_BBCODE); - options->get_popup()->connect("id_pressed", this,"_menu_option"); -#endif - mode = MODE_EDIT; wip_active = false; imgeom = memnew(ImmediateGeometry); diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_editor_plugin.h index 9f8b52d7f2..0150d8a9d7 100644 --- a/editor/plugins/collision_polygon_editor_plugin.h +++ b/editor/plugins/collision_polygon_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 945801548c..3e6165e552 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h index 09aefc65c0..ffa91952e0 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.h +++ b/editor/plugins/collision_shape_2d_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/cube_grid_theme_editor_plugin.cpp b/editor/plugins/cube_grid_theme_editor_plugin.cpp index 84faa8a265..36c0b44e38 100644 --- a/editor/plugins/cube_grid_theme_editor_plugin.cpp +++ b/editor/plugins/cube_grid_theme_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -98,7 +98,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, p_library->set_item_mesh(id, mesh); - Ref<Shape> collision; + Vector<MeshLibrary::ShapeData> collisions; for (int j = 0; j < mi->get_child_count(); j++) { @@ -119,24 +119,19 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library, for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) { - collision = sb->shape_owner_get_shape(E->get(), k); + Ref<Shape> collision = sb->shape_owner_get_shape(E->get(), k); if (collision.is_valid()) - break; - /* TileSet::ShapeData shape_data; - shape_data.shape = shape; - shape_data.shape_transform = shape_transform; - shape_data.one_way_collision = one_way; - collisions.push_back(shape_data);*/ + continue; + MeshLibrary::ShapeData shape_data; + shape_data.shape = collision; + shape_data.local_transform = sb->shape_owner_get_transform(E->get()); + collisions.push_back(shape_data); } - if (collision.is_valid()) - break; } } - if (!collision.is_null()) { + p_library->set_item_shapes(id, collisions); - p_library->set_item_shape(id, collision); - } Ref<NavigationMesh> navmesh; for (int j = 0; j < mi->get_child_count(); j++) { Node *child2 = mi->get_child(j); diff --git a/editor/plugins/cube_grid_theme_editor_plugin.h b/editor/plugins/cube_grid_theme_editor_plugin.h index 6fe5fc4235..b5fa18a4ad 100644 --- a/editor/plugins/cube_grid_theme_editor_plugin.h +++ b/editor/plugins/cube_grid_theme_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index da14c77fa9..615cf85aa4 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/curve_editor_plugin.h b/editor/plugins/curve_editor_plugin.h index 040c298a92..2df9d05533 100644 --- a/editor/plugins/curve_editor_plugin.h +++ b/editor/plugins/curve_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 1842717cc0..c48a241e4d 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h index 2ce35390a5..c422d5c686 100644 --- a/editor/plugins/editor_preview_plugins.h +++ b/editor/plugins/editor_preview_plugins.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/gi_probe_editor_plugin.cpp b/editor/plugins/gi_probe_editor_plugin.cpp index bac35dbdb0..fcbf282758 100644 --- a/editor/plugins/gi_probe_editor_plugin.cpp +++ b/editor/plugins/gi_probe_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/gi_probe_editor_plugin.h b/editor/plugins/gi_probe_editor_plugin.h index e4151d4b8c..a1fecd2911 100644 --- a/editor/plugins/gi_probe_editor_plugin.h +++ b/editor/plugins/gi_probe_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index f6e50988de..abd2559d1f 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/gradient_editor_plugin.h b/editor/plugins/gradient_editor_plugin.h index 1acf5f7e57..c169fa0947 100644 --- a/editor/plugins/gradient_editor_plugin.h +++ b/editor/plugins/gradient_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/item_list_editor_plugin.cpp b/editor/plugins/item_list_editor_plugin.cpp index 99eb02c5df..aeb6e5c302 100644 --- a/editor/plugins/item_list_editor_plugin.cpp +++ b/editor/plugins/item_list_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/item_list_editor_plugin.h b/editor/plugins/item_list_editor_plugin.h index 3bfe2c88e0..808f308c0c 100644 --- a/editor/plugins/item_list_editor_plugin.h +++ b/editor/plugins/item_list_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/light_occluder_2d_editor_plugin.cpp b/editor/plugins/light_occluder_2d_editor_plugin.cpp index e83cd779c6..e6b921c539 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -424,17 +424,6 @@ LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) { add_child(create_poly); create_poly->get_ok()->set_text(TTR("Create")); -//add_constant_override("separation",0); - -#if 0 - options = memnew( MenuButton ); - add_child(options); - options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCode",PARSE_BBCODE); - options->get_popup()->connect("id_pressed", this,"_menu_option"); -#endif - mode = MODE_EDIT; wip_active = false; } diff --git a/editor/plugins/light_occluder_2d_editor_plugin.h b/editor/plugins/light_occluder_2d_editor_plugin.h index 435d650a69..7a4f18963d 100644 --- a/editor/plugins/light_occluder_2d_editor_plugin.h +++ b/editor/plugins/light_occluder_2d_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp index 36e2999fe2..a5f854e1b1 100644 --- a/editor/plugins/line_2d_editor_plugin.cpp +++ b/editor/plugins/line_2d_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/line_2d_editor_plugin.h b/editor/plugins/line_2d_editor_plugin.h index f2979e4330..dea77ec248 100644 --- a/editor/plugins/line_2d_editor_plugin.h +++ b/editor/plugins/line_2d_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 2afcf6a341..d2767bf1b2 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 218354a918..10d7997a52 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index c87f274345..a77f022347 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/mesh_editor_plugin.h b/editor/plugins/mesh_editor_plugin.h index 305d24ba07..8ae20a5434 100644 --- a/editor/plugins/mesh_editor_plugin.h +++ b/editor/plugins/mesh_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp index 06fca06bab..84fc0cecf2 100644 --- a/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/mesh_instance_editor_plugin.h b/editor/plugins/mesh_instance_editor_plugin.h index 614dcac0b9..fa851458ce 100644 --- a/editor/plugins/mesh_instance_editor_plugin.h +++ b/editor/plugins/mesh_instance_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index 6ecb49b16c..79345754b6 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -144,22 +144,7 @@ void MultiMeshEditor::_populate() { } w = PoolVector<Face3>::Write(); -#if 0 - node->get_multimesh()->set_instance_count(populate_amount->get_val()); - node->populate_parent(populate_rotate_random->get_val(),populate_tilt_random->get_val(),populate_scale_random->get_val(),populate_scale->get_val()); - - ERR_EXPLAIN("Parent is not of type VisualInstance."); - ERR_FAIL_COND(!get_parent() || !get_parent()->is_type("VisualInstance")); - - ERR_EXPLAIN("Multimesh not present."); - ERR_FAIL_COND(multimesh.is_null()); - - VisualInstance *vi = Object::cast_to<VisualInstance>(get_parent()); - ERR_EXPLAIN("Parent is not of type VisualInstance, can't be populated."); - ERR_FAIL_COND(!vi); - -#endif PoolVector<Face3> faces = geometry; ERR_EXPLAIN(TTR("Parent has no solid faces to populate.")); int facecount = faces.size(); diff --git a/editor/plugins/multimesh_editor_plugin.h b/editor/plugins/multimesh_editor_plugin.h index a93fa73a2e..6b44662091 100644 --- a/editor/plugins/multimesh_editor_plugin.h +++ b/editor/plugins/multimesh_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp index 663db26ac3..76e969a339 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -468,17 +468,6 @@ NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) { add_child(create_nav); create_nav->get_ok()->set_text(TTR("Create")); -//add_constant_override("separation",0); - -#if 0 - options = memnew( MenuButton ); - add_child(options); - options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCode",PARSE_BBCODE); - options->get_popup()->connect("id_pressed", this,"_menu_option"); -#endif - mode = MODE_EDIT; wip_active = false; edited_outline = -1; diff --git a/editor/plugins/navigation_polygon_editor_plugin.h b/editor/plugins/navigation_polygon_editor_plugin.h index 6ec9b14cc1..33f9d5c785 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.h +++ b/editor/plugins/navigation_polygon_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/particles_2d_editor_plugin.cpp b/editor/plugins/particles_2d_editor_plugin.cpp index 98972f8f9e..5eaa248224 100644 --- a/editor/plugins/particles_2d_editor_plugin.cpp +++ b/editor/plugins/particles_2d_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/particles_2d_editor_plugin.h b/editor/plugins/particles_2d_editor_plugin.h index ccfec1a25f..fd42abb6bd 100644 --- a/editor/plugins/particles_2d_editor_plugin.h +++ b/editor/plugins/particles_2d_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 4dfae51746..10834b74ff 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/particles_editor_plugin.h b/editor/plugins/particles_editor_plugin.h index a6e14266c7..2c8ce88eb2 100644 --- a/editor/plugins/particles_editor_plugin.h +++ b/editor/plugins/particles_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/path_2d_editor_plugin.cpp b/editor/plugins/path_2d_editor_plugin.cpp index 693614b552..adc8d4f091 100644 --- a/editor/plugins/path_2d_editor_plugin.cpp +++ b/editor/plugins/path_2d_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -33,6 +33,7 @@ #include "editor/editor_settings.h" #include "os/file_access.h" #include "os/keyboard.h" + void Path2DEditor::_notification(int p_what) { switch (p_what) { @@ -228,200 +229,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { return true; } - -#if 0 - switch(mode) { - - - case MODE_CREATE: { - - if (mb->get_button_index()==BUTTON_LEFT && mb->is_pressed()) { - - - if (!wip_active) { - - wip.clear(); - wip.push_back( canvas_item_editor->snap_point(cpoint) ); - wip_active=true; - edited_point_pos=canvas_item_editor->snap_point(cpoint); - canvas_item_editor->update(); - edited_point=1; - return true; - } else { - if (wip.size()>1 && xform.xform(wip[0]).distance_to(gpoint)<grab_threshold) { - //wip closed - _wip_close(); - - - return true; - } else { - - wip.push_back( canvas_item_editor->snap_point(cpoint) ); - edited_point=wip.size(); - canvas_item_editor->update(); - return true; - - //add wip point - } - } - } else if (mb->get_button_index()==BUTTON_RIGHT && mb->is_pressed() && wip_active) { - _wip_close(); - } - - } break; - - case MODE_EDIT: { - - if (mb->get_button_index()==BUTTON_LEFT) { - if (mb->is_pressed()) { - - if (mb->get_control()) { - - - if (poly.size() < 3) { - - undo_redo->create_action(TTR("Edit Poly")); - undo_redo->add_undo_method(node,"set_polygon",poly); - poly.push_back(cpoint); - undo_redo->add_do_method(node,"set_polygon",poly); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->commit_action(); - return true; - } - - //search edges - int closest_idx=-1; - Vector2 closest_pos; - real_t closest_dist=1e10; - for(int i=0;i<poly.size();i++) { - - if (d<closest_dist && d<grab_threshold) { - closest_dist=d; - closest_pos=cp; - closest_idx=i; - } - - Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points); - if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2) - continue; //not valid to reuse point - - real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_threshold) { - closest_dist=d; - closest_pos=cp; - closest_idx=i; - } - - - } - - if (closest_idx>=0) { - - pre_move_edit=poly; - poly.insert(closest_idx+1,canvas_item_editor->snap_point(xform.affine_inverse().xform(closest_pos))); - edited_point=closest_idx+1; - edited_point_pos=canvas_item_editor->snap_point(xform.affine_inverse().xform(closest_pos)); - node->set_polygon(poly); - canvas_item_editor->update(); - return true; - } - } else { - - real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_threshold) { - closest_dist=d; - closest_pos=cp; - closest_idx=i; - } - - int closest_idx=-1; - Vector2 closest_pos; - real_t closest_dist=1e10; - for(int i=0;i<poly.size();i++) { - - Vector2 cp =xform.xform(poly[i]); - - real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_threshold) { - closest_dist=d; - closest_pos=cp; - closest_idx=i; - } - - } - - if (closest_idx>=0) { - - pre_move_edit=poly; - edited_point=closest_idx; - edited_point_pos=xform.affine_inverse().xform(closest_pos); - canvas_item_editor->update(); - return true; - } - } - } else { - - if (edited_point!=-1) { - - //apply - - ERR_FAIL_INDEX_V(edited_point,poly.size(),false); - poly[edited_point]=edited_point_pos; - undo_redo->create_action(TTR("Edit Poly")); - undo_redo->add_do_method(node,"set_polygon",poly); - undo_redo->add_undo_method(node,"set_polygon",pre_move_edit); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->commit_action(); - - edited_point=-1; - return true; - } - } - } if (mb->get_button_index()==BUTTON_RIGHT && mb->is_pressed() && edited_point==-1) { - - real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_threshold) { - closest_dist=d; - closest_pos=cp; - closest_idx=i; - } - - int closest_idx=-1; - Vector2 closest_pos; - real_t closest_dist=1e10; - for(int i=0;i<poly.size();i++) { - - Vector2 cp =xform.xform(poly[i]); - - real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_threshold) { - closest_dist=d; - closest_pos=cp; - closest_idx=i; - } - - } - - if (closest_idx>=0) { - - - undo_redo->create_action(TTR("Edit Poly (Remove Point)")); - undo_redo->add_undo_method(node,"set_polygon",poly); - poly.remove(closest_idx); - undo_redo->add_do_method(node,"set_polygon",poly); - undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update"); - undo_redo->commit_action(); - return true; - } - - } - - } break; - } -#endif } Ref<InputEventMouseMotion> mm = p_event; @@ -463,19 +270,6 @@ bool Path2DEditor::forward_gui_input(const Ref<InputEvent> &p_event) { canvas_item_editor->get_viewport_control()->update(); return true; } - -#if 0 - if (edited_point!=-1 && (wip_active || mm->get_button_mask()&BUTTON_MASK_LEFT)) { - - - Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform(); - - Vector2 gpoint = Point2(mm.x,mm.y); - edited_point_pos = canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint)); - canvas_item_editor->update(); - - } -#endif } return false; @@ -619,16 +413,7 @@ Path2DEditor::Path2DEditor(EditorNode *p_editor) { undo_redo = editor->get_undo_redo(); mode = MODE_EDIT; - action = ACTION_NONE; -#if 0 - options = memnew( MenuButton ); - add_child(options); - options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCode",PARSE_BBCODE); - options->get_popup()->connect("id_pressed", this,"_menu_option"); -#endif base_hb = memnew(HBoxContainer); CanvasItemEditor::get_singleton()->add_control_to_menu_panel(base_hb); diff --git a/editor/plugins/path_2d_editor_plugin.h b/editor/plugins/path_2d_editor_plugin.h index 61ff700118..c195845244 100644 --- a/editor/plugins/path_2d_editor_plugin.h +++ b/editor/plugins/path_2d_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index 45343ec2dd..d0f2b19ed3 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/path_editor_plugin.h b/editor/plugins/path_editor_plugin.h index 43df9d460f..b672e828a9 100644 --- a/editor/plugins/path_editor_plugin.h +++ b/editor/plugins/path_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 74df553bde..88158d4b20 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -770,17 +770,6 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) { add_child(button_uv); button_uv->connect("pressed", this, "_menu_option", varray(MODE_EDIT_UV)); -//add_constant_override("separation",0); - -#if 0 - options = memnew( MenuButton ); - add_child(options); - options->set_area_as_parent_rect(); - options->set_text("Polygon"); - //options->get_popup()->add_item("Parse BBCode",PARSE_BBCODE); - options->get_popup()->connect("id_pressed", this,"_menu_option"); -#endif - mode = MODE_EDIT; wip_active = false; diff --git a/editor/plugins/polygon_2d_editor_plugin.h b/editor/plugins/polygon_2d_editor_plugin.h index 4fcb1d81c2..38148ca7e3 100644 --- a/editor/plugins/polygon_2d_editor_plugin.h +++ b/editor/plugins/polygon_2d_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 8a7e869228..e157ddbf90 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/resource_preloader_editor_plugin.h b/editor/plugins/resource_preloader_editor_plugin.h index 6e4726748d..46539f432c 100644 --- a/editor/plugins/resource_preloader_editor_plugin.h +++ b/editor/plugins/resource_preloader_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 9b83d4e483..6f35ca1b0c 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -965,7 +965,33 @@ void ScriptEditor::_menu_option(int p_option) { current->reload(p_option == FILE_TOOL_RELOAD_SOFT); } break; + case FILE_RUN: { + Ref<Script> scr = current->get_edited_script(); + if (scr.is_null()) { + EditorNode::get_singleton()->show_warning("Can't obtain the script for running"); + break; + } + if (!scr->is_tool()) { + + EditorNode::get_singleton()->show_warning("Script is not in tool mode, will not be able to run"); + return; + } + + if (!ClassDB::is_parent_class(scr->get_instance_base_type(), "EditorScript")) { + + EditorNode::get_singleton()->show_warning("To run this script, it must inherit EditorScript and be set to tool mode"); + return; + } + + Ref<EditorScript> es = memnew(EditorScript); + es->set_script(scr.get_ref_ptr()); + es->set_editor(EditorNode::get_singleton()); + + es->_run(); + + EditorNode::get_undo_redo()->clear_history(); + } break; case FILE_CLOSE: { if (current->is_unsaved()) { _ask_close_current_unsaved_tab(current); @@ -1192,117 +1218,6 @@ static const Node *_find_node_with_script(const Node *p_node, const RefPtr &p_sc return NULL; } -Dictionary ScriptEditor::get_state() const { - - //apply_scripts(); - - Dictionary state; -#if 0 - Array paths; - int open=-1; - - for(int i=0;i<tab_container->get_child_count();i++) { - - ScriptTextEditor *se = Object::cast_to<ScriptTextEditor>(tab_container->get_child(i)); - if (!se) - continue; - - - Ref<Script> script = se->get_edited_script(); - if (script->get_path()!="" && script->get_path().find("local://")==-1 && script->get_path().find("::")==-1) { - - paths.push_back(script->get_path()); - } else { - - - const Node *owner = _find_node_with_script(get_tree()->get_root(),script.get_ref_ptr()); - if (owner) - paths.push_back(owner->get_path()); - - } - - if (i==tab_container->get_current_tab()) - open=i; - } - - if (paths.size()) - state["sources"]=paths; - if (open!=-1) - state["current"]=open; - -#endif - return state; -} -void ScriptEditor::set_state(const Dictionary &p_state) { - -#if 0 - print_line("attempt set state: "+String(Variant(p_state))); - - if (!p_state.has("sources")) - return; //bleh - - Array sources = p_state["sources"]; - for(int i=0;i<sources.size();i++) { - - Variant source=sources[i]; - - Ref<Script> script; - - if (source.get_type()==Variant::NODE_PATH) { - - - Node *owner=get_tree()->get_root()->get_node(source); - if (!owner) - continue; - - script = owner->get_script(); - } else if (source.get_type()==Variant::STRING) { - - - script = ResourceLoader::load(source,"Script"); - } - - - if (script.is_null()) //ah well.. - continue; - - editor->call("_resource_selected",script); - } - - if (p_state.has("current")) { - tab_container->set_current_tab(p_state["current"]); - } -#endif -} -void ScriptEditor::clear() { -#if 0 - List<ScriptTextEditor*> stes; - for(int i=0;i<tab_container->get_child_count();i++) { - - ScriptTextEditor *se = Object::cast_to<ScriptTextEditor>(tab_container->get_child(i)); - if (!se) - continue; - stes.push_back(se); - - } - - while(stes.size()) { - - memdelete(stes.front()->get()); - stes.pop_front(); - } - - int idx = tab_container->get_current_tab(); - if (idx>=tab_container->get_child_count()) - idx=tab_container->get_child_count()-1; - if (idx>=0) { - tab_container->set_current_tab(idx); - script_list->select( script_list->find_metadata(idx) ); - } - -#endif -} - void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) { for (int i = 0; i < tab_container->get_child_count(); i++) { @@ -2331,6 +2246,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_all", TTR("Close All")), CLOSE_ALL); file_menu->get_popup()->add_separator(); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/run_file", TTR("Run"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_X), FILE_RUN); + file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/toggle_scripts_panel", TTR("Toggle Scripts Panel"), KEY_MASK_CMD | KEY_BACKSLASH), TOGGLE_SCRIPTS_PANEL); file_menu->get_popup()->connect("id_pressed", this, "_menu_option"); @@ -2361,19 +2278,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_BREAK), true); debug_menu->get_popup()->set_item_disabled(debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true); -#if 0 - window_menu = memnew( MenuButton ); - menu_hb->add_child(window_menu); - window_menu->set_text(TTR("Window")); - window_menu->get_popup()->add_item(TTR("Close"),WINDOW_CLOSE,KEY_MASK_CMD|KEY_W); - window_menu->get_popup()->add_separator(); - window_menu->get_popup()->add_item(TTR("Move Left"),WINDOW_MOVE_LEFT,KEY_MASK_CMD|KEY_LEFT); - window_menu->get_popup()->add_item(TTR("Move Right"),WINDOW_MOVE_RIGHT,KEY_MASK_CMD|KEY_RIGHT); - window_menu->get_popup()->add_separator(); - window_menu->get_popup()->connect("id_pressed", this,"_menu_option"); - -#endif - menu_hb->add_spacer(); script_icon = memnew(TextureRect); @@ -2542,20 +2446,6 @@ void ScriptEditorPlugin::selected_notify() { script_editor->ensure_select_current(); } -Dictionary ScriptEditorPlugin::get_state() const { - - return script_editor->get_state(); -} - -void ScriptEditorPlugin::set_state(const Dictionary &p_state) { - - script_editor->set_state(p_state); -} -void ScriptEditorPlugin::clear() { - - script_editor->clear(); -} - void ScriptEditorPlugin::save_external_data() { script_editor->save_all_scripts(); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index f87a20a1f0..d2677c6a4a 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -131,6 +131,7 @@ class ScriptEditor : public PanelContainer { FILE_RELOAD_THEME, FILE_SAVE_THEME, FILE_SAVE_THEME_AS, + FILE_RUN, FILE_CLOSE, CLOSE_DOCS, CLOSE_ALL, @@ -344,14 +345,8 @@ public: _FORCE_INLINE_ bool edit(const Ref<Script> &p_script, bool p_grab_focus = true) { return edit(p_script, -1, 0, p_grab_focus); } bool edit(const Ref<Script> &p_script, int p_line, int p_col, bool p_grab_focus = true); - Dictionary get_state() const; - void set_state(const Dictionary &p_state); - void clear(); - void get_breakpoints(List<String> *p_breakpoints); - //void swap_lines(TextEdit *tx, int line1, int line2); - void save_all_scripts(); void set_window_layout(Ref<ConfigFile> p_layout); @@ -398,10 +393,6 @@ public: virtual void make_visible(bool p_visible); virtual void selected_notify(); - Dictionary get_state() const; - virtual void set_state(const Dictionary &p_state); - virtual void clear(); - virtual void save_external_data(); virtual void apply_changes(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index d3bfbf17fc..89dc358d02 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 561fa26c76..f8b7470ec8 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 5a57efd941..069a0c4292 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -252,9 +252,6 @@ void ShaderEditor::_menu_option(int p_option) { current->get_find_replace_bar()->popup_replace(); } break; - //case SEARCH_LOCATE_SYMBOL: { - - //} break; case SEARCH_GOTO_LINE: { goto_line_dialog->popup_find_line(current->get_text_edit()); @@ -274,90 +271,6 @@ void ShaderEditor::_notification(int p_what) { } } -Dictionary ShaderEditor::get_state() const { -#if 0 - apply_shaders(); - - Dictionary state; - - Array paths; - int open=-1; - - for(int i=0;i<tab_container->get_child_count();i++) { - - ShaderTextEditor *ste = tab_container->Object::cast_to<ShaderTextEditor>(get_child(i)); - if (!ste) - continue; - - - Ref<Shader> shader = ste->get_edited_shader(); - if (shader->get_path()!="" && shader->get_path().find("local://")==-1 && shader->get_path().find("::")==-1) { - - paths.push_back(shader->get_path()); - } else { - - - const Node *owner = _find_node_with_shader(get_root_node(),shader.get_ref_ptr()); - if (owner) - paths.push_back(owner->get_path()); - - } - - if (i==tab_container->get_current_tab()) - open=i; - } - - if (paths.size()) - state["sources"]=paths; - if (open!=-1) - state["current"]=open; - - - return state; -#endif - return Dictionary(); -} -void ShaderEditor::set_state(const Dictionary &p_state) { -#if 0 - print_line("setting state.."); - if (!p_state.has("sources")) - return; //bleh - - Array sources = p_state["sources"]; - for(int i=0;i<sources.size();i++) { - - Variant source=sources[i]; - - Ref<Shader> shader; - - if (source.get_type()==Variant::NODE_PATH) { - - print_line("cain find owner at path "+String(source)); - Node *owner=get_root_node()->get_node(source); - if (!owner) - continue; - - shader = owner->get_shader(); - } else if (source.get_type()==Variant::STRING) { - - print_line("loading at path "+String(source)); - shader = ResourceLoader::load(source,"Shader"); - } - - print_line("found shader at "+String(source)+"? - "+itos(shader.is_null())); - if (shader.is_null()) //ah well.. - continue; - - get_scene()->get_root_node()->call("_resource_selected",shader); - } - - if (p_state.has("current")) - tab_container->set_current_tab(p_state["current"]); -#endif -} -void ShaderEditor::clear() { -} - void ShaderEditor::_params_changed() { shader_editor->_validate_script(); @@ -519,20 +432,6 @@ void ShaderEditorPlugin::selected_notify() { shader_editor->ensure_select_current(); } -Dictionary ShaderEditorPlugin::get_state() const { - - return shader_editor->get_state(); -} - -void ShaderEditorPlugin::set_state(const Dictionary &p_state) { - - shader_editor->set_state(p_state); -} -void ShaderEditorPlugin::clear() { - - shader_editor->clear(); -} - void ShaderEditorPlugin::save_external_data() { shader_editor->save_external_data(); diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index 8625267a63..ab18784d9f 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -77,7 +77,6 @@ class ShaderEditor : public VBoxContainer { SEARCH_FIND_NEXT, SEARCH_FIND_PREV, SEARCH_REPLACE, - //SEARCH_LOCATE_SYMBOL, SEARCH_GOTO_LINE, }; @@ -108,10 +107,6 @@ public: void ensure_select_current(); void edit(const Ref<Shader> &p_shader); - Dictionary get_state() const; - void set_state(const Dictionary &p_state); - void clear(); - virtual Size2 get_minimum_size() const { return Size2(0, 200); } void save_external_data(); @@ -135,10 +130,6 @@ public: virtual void make_visible(bool p_visible); virtual void selected_notify(); - Dictionary get_state() const; - virtual void set_state(const Dictionary &p_state); - virtual void clear(); - virtual void save_external_data(); virtual void apply_changes(); diff --git a/editor/plugins/shader_graph_editor_plugin.cpp b/editor/plugins/shader_graph_editor_plugin.cpp index 3f8f2488dc..732344cb78 100644 --- a/editor/plugins/shader_graph_editor_plugin.cpp +++ b/editor/plugins/shader_graph_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -541,22 +541,7 @@ void GraphCurveMapEdit::_plot_curve(const Vector2& p_a,const Vector2& p_b,const newy = CLAMP ((Math::round (y)), 0, ymax); /* if this point is different than the last one...then draw it */ - if ((lastx != newx) || (lasty != newy)) - { -#if 0 - if(fix255) - { - /* use fixed array size (for the curve graph) */ - cd->curve[cd->outline][newx] = newy; - } - else - { - /* use dynamic allocated curve_ptr (for the real curve) */ - cd->curve_ptr[cd->outline][newx] = newy; - - if(gb_debug) printf("outline: %d cX: %d cY: %d\n", (int)cd->outline, (int)newx, (int)newy); - } -#endif + if ((lastx != newx) || (lasty != newy)) { draw_line(Vector2(lastx,ymax-lasty),Vector2(newx,ymax-newy),Color(0.8,0.8,0.8,0.8),2.0); } diff --git a/editor/plugins/shader_graph_editor_plugin.h b/editor/plugins/shader_graph_editor_plugin.h index 159c752ee6..f53dd8200d 100644 --- a/editor/plugins/shader_graph_editor_plugin.h +++ b/editor/plugins/shader_graph_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 607052231a..d8f01c6b60 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1608,8 +1608,10 @@ Point2i SpatialEditorViewport::_get_warped_mouse_motion(const Ref<InputEventMous void SpatialEditorViewport::_update_freelook(real_t delta) { - if (!is_freelook_active()) + if (!is_freelook_active()) { + freelook_velocity = Vector3(); return; + } Vector3 forward = camera->get_transform().basis.xform(Vector3(0, 0, -1)); Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0)); @@ -1623,53 +1625,61 @@ void SpatialEditorViewport::_update_freelook(real_t delta) { int key_down = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_down")->get_shortcut().ptr())->get_scancode(); int key_speed_modifier = Object::cast_to<InputEventKey>(ED_GET_SHORTCUT("spatial_editor/freelook_speed_modifier")->get_shortcut().ptr())->get_scancode(); - Vector3 velocity; + Vector3 direction; bool pressed = false; bool speed_modifier = false; const Input &input = *Input::get_singleton(); if (input.is_key_pressed(key_left)) { - velocity -= right; + direction -= right; pressed = true; } if (input.is_key_pressed(key_right)) { - velocity += right; + direction += right; pressed = true; } if (input.is_key_pressed(key_forward)) { - velocity += forward; + direction += forward; pressed = true; } if (input.is_key_pressed(key_backwards)) { - velocity -= forward; + direction -= forward; pressed = true; } if (input.is_key_pressed(key_up)) { - velocity += up; + direction += up; pressed = true; } if (input.is_key_pressed(key_down)) { - velocity -= up; + direction -= up; pressed = true; } if (input.is_key_pressed(key_speed_modifier)) { speed_modifier = true; } - if (pressed) { - const EditorSettings &s = *EditorSettings::get_singleton(); - const real_t base_speed = s.get("editors/3d/freelook_base_speed"); - const real_t modifier_speed_factor = s.get("editors/3d/freelook_modifier_speed_factor"); + const EditorSettings &s = *EditorSettings::get_singleton(); + real_t inertia = s.get("editors/3d/freelook_inertia"); + if (inertia < 0) + inertia = 0; - real_t speed = base_speed * cursor.distance; - if (speed_modifier) - speed *= modifier_speed_factor; + const real_t base_speed = s.get("editors/3d/freelook_base_speed"); + const real_t modifier_speed_factor = s.get("editors/3d/freelook_modifier_speed_factor"); - velocity.normalize(); + real_t speed = base_speed * cursor.distance; + if (speed_modifier) + speed *= modifier_speed_factor; - cursor.pos += velocity * (speed * delta); - } + Vector3 instant_velocity = direction * speed; + + // Higher inertia should increase "lag" (lerp with factor between 0 and 1) + // Inertia of zero should produce instant movement (lerp with factor of 1) + // Takes reference of 60fps for units, so that inertia of 1 gives approximate lerp factor of 0.5 + real_t factor = 1.0 / (1.0 + inertia * delta * 60.f); + freelook_velocity = freelook_velocity.linear_interpolate(instant_velocity, CLAMP(factor, 0, 1)); + + cursor.pos += freelook_velocity * delta; } void SpatialEditorViewport::set_message(String p_message, float p_time) { @@ -3585,21 +3595,6 @@ void SpatialEditor::_unhandled_key_input(Ref<InputEvent> p_event) { if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack()) return; -#if 0 -//i don't remember this being used, why was it here? - { - - EditorNode *en = editor; - EditorPluginList *over_plugin_list = en->get_editor_plugins_over(); - - if (!over_plugin_list->empty() && over_plugin_list->forward_gui_input(p_event)) { - - return; //ate the over input event - } - - } -#endif - Ref<InputEventKey> k = p_event; if (k.is_valid()) { diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 7797a657c0..b024a8bd93 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -122,6 +122,7 @@ private: float gizmo_scale; bool freelook_active; + Vector3 freelook_velocity; PanelContainer *info; Label *info_label; diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index 203734a928..c2c26bfe6c 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -120,63 +120,6 @@ void SpriteFramesEditor::_load_pressed() { file->popup_centered_ratio(); } -void SpriteFramesEditor::_item_edited() { - -#if 0 - if (!tree->get_selected()) - return; - - TreeItem *s = tree->get_selected(); - - if (tree->get_selected_column()==0) { - // renamed - String old_name=s->get_metadata(0); - String new_name=s->get_text(0); - if (old_name==new_name) - return; - - if (new_name=="" || new_name.find("\\")!=-1 || new_name.find("/")!=-1 || frames->has_resource(new_name)) { - - s->set_text(0,old_name); - return; - } - - RES samp = frames->get_resource(old_name); - undo_redo->create_action("Rename Resource"); - undo_redo->add_do_method(frames,"remove_resource",old_name); - undo_redo->add_do_method(frames,"add_resource",new_name,samp); - undo_redo->add_undo_method(frames,"remove_resource",new_name); - undo_redo->add_undo_method(frames,"add_resource",old_name,samp); - undo_redo->add_do_method(this,"_update_library"); - undo_redo->add_undo_method(this,"_update_library"); - undo_redo->commit_action(); - - } -#endif -} - -void SpriteFramesEditor::_delete_confirm_pressed() { - - ERR_FAIL_COND(!frames->has_animation(edited_anim)); - - if (tree->get_current() < 0) - return; - - sel -= 1; - if (sel < 0 && frames->get_frame_count(edited_anim)) - sel = 0; - - int to_remove = tree->get_current(); - sel = to_remove; - Ref<Texture> r = frames->get_frame(edited_anim, to_remove); - undo_redo->create_action(TTR("Delete Resource")); - undo_redo->add_do_method(frames, "remove_frame", edited_anim, to_remove); - undo_redo->add_undo_method(frames, "add_frame", edited_anim, r, to_remove); - undo_redo->add_do_method(this, "_update_library"); - undo_redo->add_undo_method(this, "_update_library"); - undo_redo->commit_action(); -} - void SpriteFramesEditor::_paste_pressed() { ERR_FAIL_COND(!frames->has_animation(edited_anim)); @@ -303,15 +246,6 @@ void SpriteFramesEditor::_delete_pressed() { if (tree->get_current() < 0) return; - - _delete_confirm_pressed(); //it has undo.. why bother with a dialog.. - /* - dialog->set_title("Confirm..."); - dialog->set_text("Remove Resource '"+tree->get_selected()->get_text(0)+"' ?"); - //dialog->get_cancel()->set_text("Cancel"); - //dialog->get_ok()->show(); - dialog->get_ok()->set_text("Remove"); - dialog->popup_centered(Size2(300,60));*/ } void SpriteFramesEditor::_animation_select() { @@ -693,10 +627,8 @@ void SpriteFramesEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_load_pressed"), &SpriteFramesEditor::_load_pressed); ClassDB::bind_method(D_METHOD("_empty_pressed"), &SpriteFramesEditor::_empty_pressed); ClassDB::bind_method(D_METHOD("_empty2_pressed"), &SpriteFramesEditor::_empty2_pressed); - ClassDB::bind_method(D_METHOD("_item_edited"), &SpriteFramesEditor::_item_edited); ClassDB::bind_method(D_METHOD("_delete_pressed"), &SpriteFramesEditor::_delete_pressed); ClassDB::bind_method(D_METHOD("_paste_pressed"), &SpriteFramesEditor::_paste_pressed); - ClassDB::bind_method(D_METHOD("_delete_confirm_pressed"), &SpriteFramesEditor::_delete_confirm_pressed); ClassDB::bind_method(D_METHOD("_file_load_request", "files", "atpos"), &SpriteFramesEditor::_file_load_request, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("_update_library", "skipsel"), &SpriteFramesEditor::_update_library, DEFVAL(false)); ClassDB::bind_method(D_METHOD("_up_pressed"), &SpriteFramesEditor::_up_pressed); @@ -829,8 +761,6 @@ SpriteFramesEditor::SpriteFramesEditor() { move_up->connect("pressed", this, "_up_pressed"); move_down->connect("pressed", this, "_down_pressed"); file->connect("files_selected", this, "_file_load_request"); - //dialog->connect("confirmed", this,"_delete_confirm_pressed"); - //tree->connect("item_selected", this,"_item_edited"); loading_scene = false; sel = -1; diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index c0eb1ec3d0..0d1ab9fd8c 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -76,11 +76,9 @@ class SpriteFramesEditor : public PanelContainer { void _empty_pressed(); void _empty2_pressed(); void _delete_pressed(); - void _delete_confirm_pressed(); void _up_pressed(); void _down_pressed(); void _update_library(bool p_skip_selector = false); - void _item_edited(); void _animation_select(); void _animation_name_edited(); diff --git a/editor/plugins/stream_editor_plugin.cpp b/editor/plugins/stream_editor_plugin.cpp deleted file mode 100644 index 1ae2ea4998..0000000000 --- a/editor/plugins/stream_editor_plugin.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/*************************************************************************/ -/* stream_editor_plugin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "stream_editor_plugin.h" - -#if 0 - -void StreamEditor::_notification(int p_what) { - - if (p_what==NOTIFICATION_ENTER_TREE) { - play->set_icon( get_icon("Play","EditorIcons") ); - stop->set_icon( get_icon("Stop","EditorIcons") ); - } - -} -void StreamEditor::_node_removed(Node *p_node) { - - if(p_node==node) { - node=NULL; - hide(); - } - -} - -void StreamEditor::_play() { - - node->call("play"); -} - -void StreamEditor::_stop() { - - node->call("stop"); -} - -void StreamEditor::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_play"),&StreamEditor::_play); - ClassDB::bind_method(D_METHOD("_stop"),&StreamEditor::_stop); - -} - -void StreamEditor::edit(Node *p_stream) { - - node=p_stream; - -} -StreamEditor::StreamEditor() { - - play = memnew( Button ); - - - play->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,60); - play->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,40); - play->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0); - play->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0); - - add_child(play); - - stop = memnew( Button ); - - stop->set_position(Point2( 35, 5 )); - stop->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_END,30); - stop->set_anchor_and_margin(MARGIN_RIGHT,Control::ANCHOR_END,10); - stop->set_anchor_and_margin(MARGIN_TOP,Control::ANCHOR_BEGIN,0); - stop->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,0); - add_child(stop); - - - play->connect("pressed", this,"_play"); - stop->connect("pressed", this,"_stop"); - -} - - -void StreamEditorPlugin::edit(Object *p_object) { - - stream_editor->edit(Object::cast_to<Node>(p_object)); -} - -bool StreamEditorPlugin::handles(Object *p_object) const { - - return p_object->is_class("StreamPlayer") || p_object->is_class("SpatialStreamPlayer"); -} - -void StreamEditorPlugin::make_visible(bool p_visible) { - - if (p_visible) { - stream_editor->show(); - stream_editor->set_fixed_process(true); - } else { - - stream_editor->hide(); - stream_editor->set_fixed_process(false); - stream_editor->edit(NULL); - } - -} - -StreamEditorPlugin::StreamEditorPlugin(EditorNode *p_node) { - - editor=p_node; - stream_editor = memnew( StreamEditor ); - editor->get_viewport()->add_child(stream_editor); - - stream_editor->set_anchor(MARGIN_LEFT,Control::ANCHOR_END); - stream_editor->set_anchor(MARGIN_RIGHT,Control::ANCHOR_END); - stream_editor->set_margin(MARGIN_LEFT,60); - stream_editor->set_margin(MARGIN_RIGHT,0); - stream_editor->set_margin(MARGIN_TOP,0); - stream_editor->set_margin(MARGIN_BOTTOM,10); - - - stream_editor->hide(); - - - -} - - -StreamEditorPlugin::~StreamEditorPlugin() -{ -} - -#endif diff --git a/editor/plugins/stream_editor_plugin.h b/editor/plugins/stream_editor_plugin.h deleted file mode 100644 index cdd1c126ad..0000000000 --- a/editor/plugins/stream_editor_plugin.h +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************/ -/* stream_editor_plugin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 STREAM_EDITOR_PLUGIN_H -#define STREAM_EDITOR_PLUGIN_H - -#if 0 -#include "editor/editor_node.h" -#include "editor/editor_plugin.h" -#include "scene/audio/stream_player.h" - -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - -class StreamEditor : public Control { - - GDCLASS(StreamEditor, Control ); - - Button * play; - Button * stop; - - Panel *panel; - Node *node; - - void _play(); - void _stop(); -protected: - void _notification(int p_what); - void _node_removed(Node *p_node); - static void _bind_methods(); -public: - - void edit(Node *p_stream); - StreamEditor(); -}; - -class StreamEditorPlugin : public EditorPlugin { - - GDCLASS( StreamEditorPlugin, EditorPlugin ); - - StreamEditor *stream_editor; - EditorNode *editor; - -public: - - virtual String get_name() const { return "Stream"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_node); - virtual bool handles(Object *p_node) const; - virtual void make_visible(bool p_visible); - - StreamEditorPlugin(EditorNode *p_node); - ~StreamEditorPlugin(); - -}; - -#endif // STREAM_EDITOR_PLUGIN_H -#endif diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index 24af6233cb..478ca2e972 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h index effcdb7e5a..bf3c56197c 100644 --- a/editor/plugins/style_box_editor_plugin.h +++ b/editor/plugins/style_box_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index 5648ee510e..90dc4cf993 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h index 2b5e7ed629..c7734b5b3d 100644 --- a/editor/plugins/texture_editor_plugin.h +++ b/editor/plugins/texture_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 6406655231..82b507bd49 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/texture_region_editor_plugin.h b/editor/plugins/texture_region_editor_plugin.h index 265d46cb08..0789dde1c1 100644 --- a/editor/plugins/texture_region_editor_plugin.h +++ b/editor/plugins/texture_region_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index c55bc46b25..86ef1a489f 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index a75b83e76a..cb6f086de6 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 6749f24204..f943ee5f6d 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/tile_map_editor_plugin.h b/editor/plugins/tile_map_editor_plugin.h index d76884e663..e863c4bf3d 100644 --- a/editor/plugins/tile_map_editor_plugin.h +++ b/editor/plugins/tile_map_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 7637ce97fc..443c280428 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/plugins/tile_set_editor_plugin.h b/editor/plugins/tile_set_editor_plugin.h index d04ebc7197..677ee05b55 100644 --- a/editor/plugins/tile_set_editor_plugin.h +++ b/editor/plugins/tile_set_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/progress_dialog.cpp b/editor/progress_dialog.cpp index 980afee447..376d9d3158 100644 --- a/editor/progress_dialog.cpp +++ b/editor/progress_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/progress_dialog.h b/editor/progress_dialog.h index 75ad0f26dd..8ac0907145 100644 --- a/editor/progress_dialog.h +++ b/editor/progress_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/project_export.cpp b/editor/project_export.cpp index a600c8af2a..d649afc594 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -35,7 +35,6 @@ #include "io/image_loader.h" #include "io/resource_loader.h" #include "io/resource_saver.h" -#include "io_plugins/editor_texture_import_plugin.h" #include "os/dir_access.h" #include "os/file_access.h" #include "os/os.h" diff --git a/editor/project_export.h b/editor/project_export.h index 29c24005e0..61de0f739a 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 9cb110a2ca..e042e9cc96 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/project_manager.h b/editor/project_manager.h index 11fd3b2e01..ecc01955ba 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 3352ea22de..58ac5bc561 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index 6deb9e1d46..c8c5e3265b 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index a6a29bb66c..34a3ab71db 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/property_editor.h b/editor/property_editor.h index 2ba6058bdf..bfd5ee401e 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 4b7d54a737..6bbb35ceab 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/property_selector.h b/editor/property_selector.h index def791a3fd..3fa60771d7 100644 --- a/editor/property_selector.h +++ b/editor/property_selector.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp index ef875bbead..13d74a6593 100644 --- a/editor/pvrtc_compress.cpp +++ b/editor/pvrtc_compress.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/pvrtc_compress.h b/editor/pvrtc_compress.h index 2bb6d57050..cd11f260fe 100644 --- a/editor/pvrtc_compress.h +++ b/editor/pvrtc_compress.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp index 7fb9666afb..c71cc5af3f 100644 --- a/editor/quick_open.cpp +++ b/editor/quick_open.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/quick_open.h b/editor/quick_open.h index 44f8c025e6..3f64dd8cf0 100644 --- a/editor/quick_open.h +++ b/editor/quick_open.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/register_exporters.h b/editor/register_exporters.h index 72f8acb89c..fefa1477b8 100644 --- a/editor/register_exporters.h +++ b/editor/register_exporters.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/reparent_dialog.cpp b/editor/reparent_dialog.cpp index acc511e004..5e765fe70f 100644 --- a/editor/reparent_dialog.cpp +++ b/editor/reparent_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/reparent_dialog.h b/editor/reparent_dialog.h index b7a3164f4b..667c7fe705 100644 --- a/editor/reparent_dialog.h +++ b/editor/reparent_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/run_settings_dialog.cpp b/editor/run_settings_dialog.cpp index 5892e530be..a76e94a173 100644 --- a/editor/run_settings_dialog.cpp +++ b/editor/run_settings_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/run_settings_dialog.h b/editor/run_settings_dialog.h index b1b4240bf2..225d5ee085 100644 --- a/editor/run_settings_dialog.h +++ b/editor/run_settings_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 859c41f0d0..b87387ec6c 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 618159f5c9..f61c67bb13 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 3e56e74808..87b4d2a867 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h index c666b6a8d5..1114b92796 100644 --- a/editor/scene_tree_editor.h +++ b/editor/scene_tree_editor.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index b70c63c97c..d0e2e0c240 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/script_create_dialog.h b/editor/script_create_dialog.h index c8f199b53a..d16c523f0a 100644 --- a/editor/script_create_dialog.h +++ b/editor/script_create_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index d1d9f86b66..284b25801c 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index bee49bf15c..6cb5f0a70c 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 042b4e004e..623e458aca 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/settings_config_dialog.h b/editor/settings_config_dialog.h index cda191ac36..8a66d5098c 100644 --- a/editor/settings_config_dialog.h +++ b/editor/settings_config_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 2de63054b3..fb5143b486 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -238,7 +238,6 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi Instance ins; Ref<ArrayMesh> mesh = memnew(ArrayMesh); -#if 1 Array a; a.resize(VS::ARRAY_MAX); @@ -273,61 +272,6 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi } } -#else - for (int ih = 0; ih < p_handles.size(); ih++) { - - Vector<Vector3> vertices; - Vector<Vector3> normals; - - int vtx_idx = 0; - -#define ADD_VTX(m_idx) \ - vertices.push_back((face_points[m_idx] * HANDLE_HALF_SIZE + p_handles[ih])); \ - normals.push_back(normal_points[m_idx]); \ - vtx_idx++; - - for (int i = 0; i < 6; i++) { - - Vector3 face_points[4]; - Vector3 normal_points[4]; - float uv_points[8] = { 0, 0, 0, 1, 1, 1, 1, 0 }; - - for (int j = 0; j < 4; j++) { - - float v[3]; - v[0] = 1.0; - v[1] = 1 - 2 * ((j >> 1) & 1); - v[2] = v[1] * (1 - 2 * (j & 1)); - - for (int k = 0; k < 3; k++) { - - if (i < 3) - face_points[j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1); - else - face_points[3 - j][(i + k) % 3] = v[k] * (i >= 3 ? -1 : 1); - } - normal_points[j] = Vector3(); - normal_points[j][i % 3] = (i >= 3 ? -1 : 1); - } - //tri 1 - ADD_VTX(0); - ADD_VTX(1); - ADD_VTX(2); - //tri 2 - ADD_VTX(2); - ADD_VTX(3); - ADD_VTX(0); - } - - Array d; - d.resize(VS::ARRAY_MAX); - d[VisualServer::ARRAY_NORMAL] = normals; - d[VisualServer::ARRAY_VERTEX] = vertices; - - mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, d); - mesh->surface_set_material(ih, SpatialEditorGizmos::singleton->handle_material); - } -#endif ins.mesh = mesh; ins.billboard = p_billboard; ins.extra_margin = true; diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index fa5484c3d9..a7c7497763 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/SCsub b/main/SCsub index 1675a6e6ab..1f97cd1be0 100644 --- a/main/SCsub +++ b/main/SCsub @@ -1,6 +1,7 @@ #!/usr/bin/env python Import('env') +from compat import byte_to_str def make_splash(target, source, env): @@ -8,17 +9,17 @@ def make_splash(target, source, env): src = source[0].srcnode().abspath dst = target[0].srcnode().abspath f = open(src, "rb") - g = open(dst, "wb") + g = open(dst, "w") buf = f.read() g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef BOOT_SPLASH_H\n") g.write("#define BOOT_SPLASH_H\n") - g.write("static const Color boot_splash_bg_color = Color(1,1,1,1);\n"); + g.write("static const Color boot_splash_bg_color = Color(1,1,1,1);\n") g.write("static const unsigned char boot_splash_png[] = {\n") for i in range(len(buf)): - g.write(str(ord(buf[i])) + ",\n") + g.write(byte_to_str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") @@ -28,7 +29,7 @@ def make_app_icon(target, source, env): src = source[0].srcnode().abspath dst = target[0].srcnode().abspath f = open(src, "rb") - g = open(dst, "wb") + g = open(dst, "w") buf = f.read() @@ -37,7 +38,7 @@ def make_app_icon(target, source, env): g.write("#define APP_ICON_H\n") g.write("static const unsigned char app_icon_png[] = {\n") for i in range(len(buf)): - g.write(str(ord(buf[i])) + ",\n") + g.write(byte_to_str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") diff --git a/main/input_default.cpp b/main/input_default.cpp index d496717460..b4c9a6207f 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "input_default.h" + #include "input_map.h" #include "os/os.h" #include "scene/resources/texture.h" @@ -96,58 +97,6 @@ bool InputDefault::is_joy_button_pressed(int p_device, int p_button) const { bool InputDefault::is_action_pressed(const StringName &p_action) const { return action_state.has(p_action) && action_state[p_action].pressed; -#if 0 - if (custom_action_press.has(p_action)) - return true; //simpler - - const List<InputEvent> *alist = InputMap::get_singleton()->get_action_list(p_action); - if (!alist) - return false; - - - for (const List<InputEvent>::Element *E=alist->front();E;E=E->next()) { - - - int device=E->get().device; - - switch(E->get().type) { - - case InputEvent::KEY: { - - const InputEventKey &iek=E->get().key; - if ((keys_pressed.has(iek->get_scancode()))) - return true; - } break; - case InputEvent::MOUSE_BUTTON: { - - const InputEventMouseButton &iemb=E->get().mouse_button; - if(mouse_button_mask&(1<<iemb->get_button_index())) - return true; - } break; - case InputEvent::JOYPAD_BUTTON: { - - const InputEventJoypadButton &iejb=E->get().joy_button; - int c = _combine_device(iejb->get_button_index(),device); - if (joy_buttons_pressed.has(c)) - return true; - } break; - case InputEvent::JOYPAD_MOTION: { - - const InputEventJoypadMotion &iejm=E->get().joy_motion; - int c = _combine_device(iejm.axis,device); - if (_joy_axis.has(c)) { - if (iejm.axis_value < 0) { - if (_joy_axis[c] < -0.5f) return true; - } - else - if (_joy_axis[c] > 0.5f) return true; - } - } break; - } - } - - return false; -#endif } bool InputDefault::is_action_just_pressed(const StringName &p_action) const { diff --git a/main/input_default.h b/main/input_default.h index 92ef67c7b5..345c34c55e 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/main.cpp b/main/main.cpp index 14deec67ea..00cb43b0a8 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/main.h b/main/main.h index ca96e397ca..f8db0225bf 100644 --- a/main/main.h +++ b/main/main.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/performance.cpp b/main/performance.cpp index 3fb76c22fa..e85d2bf736 100644 --- a/main/performance.cpp +++ b/main/performance.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/performance.h b/main/performance.h index 75583c6c38..a9e3c07d7c 100644 --- a/main/performance.h +++ b/main/performance.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_containers.cpp b/main/tests/test_containers.cpp deleted file mode 100644 index 956be5d169..0000000000 --- a/main/tests/test_containers.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/*************************************************************************/ -/* test_containers.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "test_containers.h" - -#include "dvector.h" -#include "math_funcs.h" -#include "print_string.h" -#include "servers/visual/default_mouse_cursor.xpm" -#include "set.h" - -#include "image.h" -#include "list.h" -#include "variant.h" - -namespace TestContainers { - -MainLoop *test() { - - /* - HashMap<int,int> int_map; - - for (int i=0;i<68000;i++) { - - int num=(int)Math::random(0,1024); - int_map[i]=num; - } - */ - - { - - }; - -#if 0 - Set<int> set; - - print_line("Begin Insert"); - for (int i=0;i<1100;i++) { - - int num=i;//(int)Math::random(0,1024); - //print_line("inserting "+itos(num)); - set.insert( num ); - } - - /* - for (int i=0;i<400;i++) { - - int num=(int)Math::random(0,1024); - set.erase(num); - } - */ - //set.print_tree(); - - for(Set<int>::Element *I=set.front();I;I=I->next()) { - - print_line("inserted "+itos(I->get())+" prev is "+itos(I->prev()?I->prev()->get():-100)); - - } - - print_line("depth is "+itos(set.calculate_depth())); - print_line("Insert Success"); -#endif - - return NULL; -} -} diff --git a/main/tests/test_containers.h b/main/tests/test_containers.h deleted file mode 100644 index 7b589d4057..0000000000 --- a/main/tests/test_containers.h +++ /dev/null @@ -1,43 +0,0 @@ -/*************************************************************************/ -/* test_containers.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 TEST_CONTAINERS_H -#define TEST_CONTAINERS_H - -#include "os/main_loop.h" -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - -namespace TestContainers { - -MainLoop *test(); -} - -#endif diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index 0607360d88..bcf4278bde 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1053,16 +1053,6 @@ MainLoop *test(TestType p_type) { memdelete(fw); } -#if 0 - Parser parser; - Error err = parser.parse(code); - if (err) { - print_line("error:"+itos(parser.get_error_line())+":"+itos(parser.get_error_column())+":"+parser.get_error()); - } else { - print_line("Parse O-K!"); - } -#endif - memdelete(fa); return NULL; diff --git a/main/tests/test_gdscript.h b/main/tests/test_gdscript.h index b4e1665de5..f37b175913 100644 --- a/main/tests/test_gdscript.h +++ b/main/tests/test_gdscript.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp index 44d4464aac..d9b2873d6b 100644 --- a/main/tests/test_gui.cpp +++ b/main/tests/test_gui.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -70,32 +70,6 @@ public: SceneTree::init(); -#if 0 - - - Viewport *vp = memnew( Viewport ); - vp->set_world( Ref<World>( memnew( World ))); - get_root()->add_child(vp); - - vp->set_rect(Rect2(0,0,256,256)); - vp->set_as_render_target(true); - vp->set_render_target_update_mode(Viewport::RENDER_TARGET_UPDATE_ALWAYS); - - - Camera *camera = memnew( Camera ); - vp->add_child(camera); - camera->make_current(); - - Sprite *sp = memnew( Sprite ); - sp->set_texture( vp->get_render_target_texture() ); - //sp->set_texture( ResourceLoader::load("res://ball.png") ); - sp->set_position(Point2(300,300)); - get_root()->add_child(sp); - - - return; -#endif - Panel *frame = memnew(Panel); frame->set_anchor(MARGIN_RIGHT, Control::ANCHOR_END); frame->set_anchor(MARGIN_BOTTOM, Control::ANCHOR_END); @@ -111,7 +85,6 @@ public: label->set_position(Point2(80, 90)); label->set_size(Point2(170, 80)); label->set_align(Label::ALIGN_FILL); - //label->set_text("There"); label->set_text("There was once upon a time a beautiful unicorn that loved to play with little girls..."); frame->add_child(label); @@ -124,25 +97,6 @@ public: frame->add_child(button); -#if 0 - Sprite *tf = memnew( Sprite ); - frame->add_child(tf); - Image img; - ImageLoader::load_image("LarvoClub.png",&img); - - img.resize(512,512); - img.generate_mipmaps(); - img.compress(Image::COMPRESS_PVRTC4); - Ref<ImageTexture> tt = memnew( ImageTexture ); - tt->create_from_image(img); - tf->set_texture(tt); - tf->set_position(Point2(50,50)); - //tf->set_scale(Point2(0.3,0.3)); - - - return; -#endif - Tree *tree = memnew(Tree); tree->set_columns(2); @@ -182,9 +136,6 @@ public: frame->add_child(tree); - //control = memnew( Control ); - //root->add_child( control ); - LineEdit *line_edit = memnew(LineEdit); line_edit->set_position(Point2(30, 190)); @@ -244,36 +195,6 @@ public: frame->add_child(options); - /* - Tree * tree = memnew( Tree ); - tree->set_columns(2); - - tree->set_position( Point2( 230,210 ) ); - tree->set_size( Point2( 150,250 ) ); - - - TreeItem *item = tree->create_item(); - item->set_editable(0,true); - item->set_text(0,"root"); - item = tree->create_item( tree->get_root() ); - item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); - item->set_editable(0,true); - item->set_text(0,"check"); - item = tree->create_item( tree->get_root() ); - item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE); - item->set_editable(0,true); - item->set_range_config(0,0,20,0.1); - item->set_range(0,2); - item->add_button(0,Theme::get_default()->get_icon("folder","FileDialog")); - item = tree->create_item( tree->get_root() ); - item->set_cell_mode(0, TreeItem::CELL_MODE_RANGE); - item->set_editable(0,true); - item->set_text(0,"Have,Many,Several,Options!"); - item->set_range(0,2); - - frame->add_child(tree); -*/ - RichTextLabel *richtext = memnew(RichTextLabel); richtext->set_position(Point2(600, 210)); @@ -306,18 +227,10 @@ public: richtext->add_text("keep writing a lot of text"); richtext->pop(); richtext->add_text(" so the label control overflows and the scrollbar appears.\n"); - //richtext->push_indent(1); - //richtext->add_text("By the way, testing indent levels! Yohohoho! Everything should appear to the right sightly here!\n"); - //richtext->pop(); richtext->push_meta("http://www.scrollingcapabilities.xz"); richtext->add_text("This allows to test for the scrolling capabilities "); richtext->pop(); richtext->add_text("of the rich text label for huge text (not like this text will really be huge but, you know).\nAs long as it is so long that it will work nicely for a test/demo, then it's welcomed in my book...\nChanging subject, the day is cloudy today and I'm wondering if I'll get che chance to travel somewhere nice. Sometimes, watching the clouds from satellite images may give a nice insight about how pressure zones in our planet work, althogh it also makes it pretty obvious to see why most weather forecasts get it wrong so often.\nClouds are so difficult to predict!\nBut it's pretty cool how our civilization has adapted to having water falling from the sky each time it rains..."); - //richtext->add_text("Hello!\nGorgeous.."); - - //richtext->push_meta("http://www.scrollingcapabilities.xz"); - ///richtext->add_text("Hello!\n"); - //richtext->pop(); TabContainer *tabc = memnew(TabContainer); @@ -346,21 +259,6 @@ public: tabc->set_position(Point2(400, 210)); tabc->set_size(Point2(180, 250)); - - /*Ref<ImageTexture> text = memnew( ImageTexture ); - text->load("test_data/concave.png"); - - Sprite* sprite = memnew(Sprite); - sprite->set_texture(text); - sprite->set_position(Point2(300, 300)); - frame->add_child(sprite); - sprite->show(); - - Sprite* sprite2 = memnew(Sprite); - sprite->set_texture(text); - sprite->add_child(sprite2); - sprite2->set_position(Point2(50, 50)); - sprite2->show();*/ } }; diff --git a/main/tests/test_gui.h b/main/tests/test_gui.h index 881ff96956..a5c5695980 100644 --- a/main/tests/test_gui.h +++ b/main/tests/test_gui.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_image.cpp b/main/tests/test_image.cpp index 0b120f87d5..b94d93b2b1 100644 --- a/main/tests/test_image.cpp +++ b/main/tests/test_image.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_image.h b/main/tests/test_image.h index 3b1783ded7..254bccea85 100644 --- a/main/tests/test_image.h +++ b/main/tests/test_image.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_io.cpp b/main/tests/test_io.cpp index f7c49c9249..f96c5cfe3c 100644 --- a/main/tests/test_io.cpp +++ b/main/tests/test_io.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -112,66 +112,6 @@ MainLoop *test() { FileAccess::make_default<FileAccessMemory>(FileAccess::ACCESS_USERDATA); print_line("archive test"); -#if 0 - Archive arch; - - Archive::get_singleton()->add_package("a_package"); - FileAccessArchive f; - - print_line("opening for read"); - f._open("file.txt", FileAccess::READ); - int pos = f.get_pos(); - printf("file has %i bytes, initial pos %i\n", (int)f.get_len(), pos); - - do { - printf("%c", f.get_8()); - - } while (!f.eof_reached()); - - print_line("opening for stored seek"); - f.open("seek.bin", FileAccess::READ); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - f.seek(128); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - - print_line("opening for deflated seek"); - f.open("seek_deflated.bin", FileAccess::READ); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - f.seek(128); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - f.seek(256); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - f.seek(4); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - pos = f.get_pos(); - printf("byte at pos %i is %i\n", pos, (int)f.get_8()); - - f.close(); - - DirAccessArchive d; - String dir = "../blah1/blah2/blahask/../blah3/.//blah4/"; - printf("changing dir to %s\n", dir.utf8().get_data()); - d.change_dir(dir); - printf("current dir is %s\n", d.get_current_dir().utf8().get_data()); - - FileAccessMemory::cleanup(); -#endif }; print_line("test done"); diff --git a/main/tests/test_io.h b/main/tests/test_io.h index 765c083955..ffb834b894 100644 --- a/main/tests/test_io.h +++ b/main/tests/test_io.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_main.cpp b/main/tests/test_main.cpp index f3ed4604e1..794bdb757b 100644 --- a/main/tests/test_main.cpp +++ b/main/tests/test_main.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -32,19 +32,16 @@ #ifdef DEBUG_ENABLED -#include "test_containers.h" +#include "test_gdscript.h" #include "test_gui.h" +#include "test_image.h" +#include "test_io.h" #include "test_math.h" #include "test_physics.h" #include "test_physics_2d.h" #include "test_render.h" -#include "test_sound.h" -#include "test_string.h" - -#include "test_gdscript.h" -#include "test_image.h" -#include "test_io.h" #include "test_shader_lang.h" +#include "test_string.h" const char **tests_get_names() { @@ -71,11 +68,6 @@ MainLoop *test_main(String p_test, const List<String> &p_args) { return TestString::test(); } - if (p_test == "containers") { - - return TestContainers::test(); - } - if (p_test == "math") { return TestMath::test(); @@ -103,11 +95,6 @@ MainLoop *test_main(String p_test, const List<String> &p_args) { } #endif - //if (p_test=="sound") { - - // return TestSound::test(); - //} - if (p_test == "io") { return TestIO::test(); diff --git a/main/tests/test_main.h b/main/tests/test_main.h index da890a4b96..0a50e3c7be 100644 --- a/main/tests/test_main.h +++ b/main/tests/test_main.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp index d21be24dab..3ba8ef51b4 100644 --- a/main/tests/test_math.cpp +++ b/main/tests/test_math.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -205,54 +205,12 @@ class GetClassAndNamespace { case 'r': res = 13; break; - /* too much, not needed for now - case 'u': { - //hexnumbarh - oct is deprecated - - - for(int j=0;j<4;j++) { - CharType c = code[idx+j+1]; - if (c==0) { - r_err_str="Unterminated String"; - return ERR_PARSE_ERROR; - } - if (!((c>='0' && c<='9') || (c>='a' && c<='f') || (c>='A' && c<='F'))) { - - r_err_str="Malformed hex constant in string"; - return ERR_PARSE_ERROR; - } - CharType v; - if (c>='0' && c<='9') { - v=c-'0'; - } else if (c>='a' && c<='f') { - v=c-'a'; - v+=10; - } else if (c>='A' && c<='F') { - v=c-'A'; - v+=10; - } else { - ERR_PRINT("BUG"); - v=0; - } - - res<<=4; - res|=v; - - - } - idx+=4; //will add at the end anyway - - - } break;*/ case '\"': res = '\"'; break; case '\\': res = '\\'; break; - //case '/': res='/'; break; default: { res = next; - //r_err_str="Invalid escape sequence"; - //return ERR_PARSE_ERROR; } break; } @@ -413,23 +371,6 @@ void test_vec(Plane p_vec) { print_line("out: " + v0); v0.normal.z = (v0.d / 100.0 * 2.0 - 1.0) * v0.d; print_line("out_F: " + v0); - - /*v0: 0, 0, -0.1, 0.1 -v1: 0, 0, 0, 0.1 -fix: 0, 0, 0, 0.1 -v0: 0, 0, 1.302803, 1.5 -v1: 0, 0, 1.401401, 1.5 -fix: 0, 0, 1.401401, 1.5 -v0: 0, 0, 25.851850, 26 -v1: 0, 0, 25.925926, 26 -fix: 0, 0, 25.925924, 26 -v0: 0, 0, 49.899902, 50 -v1: 0, 0, 49.949947, 50 -fix: 0, 0, 49.949951, 50 -v0: 0, 0, 100, 100 -v1: 0, 0, 100, 100 -fix: 0, 0, 100, 100 -*/ } uint32_t ihash(uint32_t a) { @@ -469,10 +410,9 @@ MainLoop *test() { const float pow2to9 = 512.0f; const float B = 15.0f; - //const float Emax = 31.0f; const float N = 9.0f; - float sharedexp = 65408.000f; //(( pow2to9 - 1.0f)/ pow2to9)*powf( 2.0f, 31.0f - 15.0f); + float sharedexp = 65408.000f; float cRed = MAX(0.0f, MIN(sharedexp, r)); float cGreen = MAX(0.0f, MIN(sharedexp, g)); @@ -480,8 +420,6 @@ MainLoop *test() { float cMax = MAX(cRed, MAX(cGreen, cBlue)); - // expp = MAX(-B - 1, log2(maxc)) + 1 + B - float expp = MAX(-B - 1.0f, floor(Math::log(cMax) / Math_LN2)) + 1.0f + B; float sMax = (float)floor((cMax / Math::pow(2.0f, expp - B - N)) + 0.5f); @@ -591,8 +529,6 @@ MainLoop *test() { hashes.push_back(hashes.size()); } - //hashes.resize(50); - for (int i = nearest_shift(hashes.size()); i < 20; i++) { bool success = true; @@ -625,7 +561,6 @@ MainLoop *test() { } { - //print_line("NUM: "+itos(237641278346127)); print_line("NUM: " + itos(-128)); return NULL; } @@ -635,14 +570,12 @@ MainLoop *test() { v.normalize(); float a = 0.3; - //Quat q(v,a); Basis m(v, a); Vector3 v2(7, 3, 1); v2.normalize(); float a2 = 0.8; - //Quat q(v,a); Basis m2(v2, a2); Quat q = m; @@ -749,86 +682,6 @@ MainLoop *test() { print_line("scalar /=: " + v); } -#if 0 - print_line(String("C:\\momo\\.\\popo\\..\\gongo").simplify_path()); - print_line(String("res://../popo/..//gongo").simplify_path()); - print_line(String("res://..").simplify_path()); - - - PoolVector<uint8_t> a; - PoolVector<uint8_t> b; - - a.resize(20); - b=a; - b.resize(30); - a=b; -#endif - -#if 0 - String za = String::utf8("á"); - printf("unicode: %x\n",za[0]); - CharString cs=za.utf8(); - for(int i=0;i<cs.size();i++) { - uint32_t v = uint8_t(cs[i]); - printf("%i - %x\n",i,v); - } - return NULL; - - print_line(String("C:\\window\\system\\momo").path_to("C:\\window\\momonga")); - print_line(String("res://momo/sampler").path_to("res://pindonga")); - print_line(String("/margarito/terere").path_to("/margarito/pilates")); - print_line(String("/algo").path_to("/algo")); - print_line(String("c:").path_to("c:\\")); - print_line(String("/").path_to("/")); - - - print_line(itos(sizeof(Variant))); - return NULL; - - Vector<StringName> path; - path.push_back("three"); - path.push_back("two"); - path.push_back("one"); - path.push_back("comeon"); - path.revert(); - - NodePath np(path,true); - - print_line(np); - - - return NULL; - - bool a=2; - - print_line(Variant(a)); - - - Transform2D mat2_1; - mat2_1.rotate(0.5); - Transform2D mat2_2; - mat2_2.translate(Vector2(1,2)); - Transform2D mat2_3 = mat2_1 * mat2_2; - mat2_3.affine_invert(); - - print_line(mat2_3.elements[0]); - print_line(mat2_3.elements[1]); - print_line(mat2_3.elements[2]); - - - - Transform mat3_1; - mat3_1.basis.rotate(Vector3(0,0,1),0.5); - Transform mat3_2; - mat3_2.translate(Vector3(1,2,0)); - Transform mat3_3 = mat3_1 * mat3_2; - mat3_3.affine_invert(); - - print_line(mat3_3.basis.get_axis(0)); - print_line(mat3_3.basis.get_axis(1)); - print_line(mat3_3.origin); - -#endif return NULL; } } diff --git a/main/tests/test_math.h b/main/tests/test_math.h index 24fd442dd0..a0328a14d0 100644 --- a/main/tests/test_math.h +++ b/main/tests/test_math.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics.cpp index 5a233e818e..f149821928 100644 --- a/main/tests/test_physics.cpp +++ b/main/tests/test_physics.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -71,7 +71,6 @@ class TestPhysicsMainLoop : public MainLoop { PhysicsDirectBodyState *state = (PhysicsDirectBodyState *)p_state; VisualServer *vs = VisualServer::get_singleton(); Transform t = state->get_transform(); - //t.basis.scale( Vector3(1.0,0.5,0.2) ); vs->instance_set_transform(p_visual_instance, t); } @@ -208,7 +207,6 @@ protected: d[VS::ARRAY_VERTEX] = p_faces; d[VS::ARRAY_NORMAL] = normals; vs->mesh_add_surface_from_arrays(trimesh_mesh, VS::PRIMITIVE_TRIANGLES, d); - //vs->material_set_flag( trimesh_mat, VisualServer::MATERIAL_FLAG_UNSHADED,true); RID triins = vs->instance_create2(trimesh_mesh, scenario); @@ -219,9 +217,6 @@ protected: Transform tritrans = p_xform; ps->body_set_state(tribody, PhysicsServer::BODY_STATE_TRANSFORM, tritrans); vs->instance_set_transform(triins, tritrans); - //RID trimesh_material = vs->fixed_material_create(); - //vs->material_generate( trimesh_material, Color(0.2,0.4,0.6) ); - //vs->mesh_surface_set_material( trimesh_mesh, 0, trimesh_material ); } void make_grid(int p_width, int p_height, float p_cellsize, float p_cellheight, const Transform &p_xform = Transform()) { @@ -305,7 +300,6 @@ public: /* LIGHT */ RID lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL); - //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) ); scenario = vs->scenario_create(); vs->light_set_shadow(lightaux, true); light = vs->instance_create2(lightaux, scenario); @@ -327,100 +321,14 @@ public: vs->camera_set_perspective(camera, 60, 0.1, 40.0); vs->camera_set_transform(camera, Transform(Basis(), Vector3(0, 9, 12))); - //vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME); Transform gxf; gxf.basis.scale(Vector3(1.4, 0.4, 1.4)); gxf.origin = Vector3(-2, 1, -2); make_grid(5, 5, 2.5, 1, gxf); - //create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_STATIC,gxf); - //create_static_plane( Plane( Vector3(0,1,0), -2) ); - //test_joint(); test_fall(); - //test_joint(); - - /* - Vector<Vector3> faces; - faces.push_back( Vector3(10,0,-5) ); - faces.push_back( Vector3(0,0,10) ); - faces.push_back( Vector3(-10,-0.2,-5) ); - make_trimesh(faces); -*/ - /* Make Trimesh */ quit = false; return; - -#if 0 -#define GRID_SIZE 5 - - float grid[GRID_SIZE][GRID_SIZE]; - - for (int i=0;i<GRID_SIZE;i++) { - - for (int j=0;j<GRID_SIZE;j++) { - - grid[j][i]=Math::random(0.0, 1.0 ); - } - } - - Vector<Vector3> faces; - - for (int i=1;i<GRID_SIZE;i++) { - - for (int j=1;j<GRID_SIZE;j++) { - -#define MAKE_VERTEX(m_x, m_z) \ - faces.push_back(Vector3(m_x - GRID_SIZE / 2.0, grid[m_x][m_z], m_z - GRID_SIZE / 2.0) * 3.0) - - MAKE_VERTEX(i,j-1); - MAKE_VERTEX(i,j); - MAKE_VERTEX(i-1,j); - - MAKE_VERTEX(i-1,j-1); - MAKE_VERTEX(i,j-1); - MAKE_VERTEX(i-1,j); - - } - } - /* - faces.clear(); - faces.push_back( Vector3(0,0,-5) ); - faces.push_back( Vector3(1,0,-1) ); - faces.push_back( Vector3(-1,-0,-1) ); - */ - - RID trimesh_shape = ps->shape_create(); - ps->shape_set_data(trimesh_shape, PhysicsServer::SHAPE_CONCAVE_POLYGON,faces); - faces=ps->shape_get_shape(trimesh_shape, 0); - Vector<Vector3> normals; // for drawing - for (int i=0;i<faces.size()/3;i++) { - - Plane p( faces[i*3+0],faces[i*3+1], faces[i*3+2] ); - normals.push_back(p.normal); - normals.push_back(p.normal); - normals.push_back(p.normal); - } - - RID trimesh_mesh = vs->mesh_create(); - vs->mesh_add_surface(trimesh_mesh, VS::PRIMITIVE_TRIANGLES, VS::ARRAY_FORMAT_VERTEX|VS::ARRAY_FORMAT_NORMAL, faces.size() ); - vs->mesh_surface_set_array(trimesh_mesh,0,VS::ARRAY_VERTEX, faces ); - vs->mesh_surface_set_array(trimesh_mesh,0,VS::ARRAY_NORMAL, normals ); - RID trimesh_mat = vs->fixed_material_create(); - vs->material_generate( trimesh_mat, Color(1.0,0.5,0.3) ); - vs->mesh_surface_set_material( trimesh_mesh, 0, trimesh_mat ); - - RID triins = vs->instance_create2(trimesh_mesh); - - - - RID tribody = ps->body_create( PhysicsServer::BODY_MODE_STATIC, trimesh_shape); - Transform tritrans = Transform( Basis(), Vector3(0,0,-2) ); - ps->body_set_state( tribody, PhysicsServer::BODY_STATE_TRANSFORM, tritrans ); - vs->instance_set_transform( triins, tritrans ); - RID trimesh_material = vs->fixed_material_create(); - vs->material_generate( trimesh_material, Color(0.2,0.4,0.6) ); - vs->mesh_surface_set_material( trimesh_mesh, 0, trimesh_material ); -#endif } virtual bool iteration(float p_time) { @@ -445,58 +353,9 @@ public: } void test_joint() { -#if 0 - PhysicsServer * ps = PhysicsServer::get_singleton(); - - mover = create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_STATIC,Transform(Basis(),Vector3(0,0,-24))); - RID b = create_body(PhysicsServer::SHAPE_CAPSULE,PhysicsServer::BODY_MODE_RIGID,Transform()); - - ps->joint_create_double_pin(b,Vector3(0,0,1.0),mover,Vector3(0,0,0)); - ps->body_add_collision_exception(mover,b); - - - List<String> cmdline = OS::get_singleton()->get_cmdline_args(); - int link_count = LINK_COUNT; - if (cmdline.size() > 0 && cmdline[cmdline.size()-1].to_int()) { - link_count = cmdline[cmdline.size()-1].to_int(); - }; - - for(int i=0;i<link_count;i++) { - - RID c = create_body(PhysicsServer::SHAPE_CAPSULE,PhysicsServer::BODY_MODE_RIGID,Transform()); - ps->joint_create_double_pin(b,Vector3(0,0,-0.7),c,Vector3(0,0,0.7)); - ps->body_add_collision_exception(c,b); - b=c; - } - - - create_static_plane(Plane(Vector3(0,1,0),-8)); -#endif } void test_hinge() { -#if 0 - PhysicsServer * ps = PhysicsServer::get_singleton(); - - - mover = create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_STATIC,Transform(Basis(),Vector3(0,0,-24))); - RID b = create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_RIGID,Transform()); - - ps->joint_create_double_hinge(b,Transform(Basis(),Vector3(1,1,1.0)),mover,Transform(Basis(),Vector3(0,0,0))); - ps->body_add_collision_exception(mover,b); - -/* - for(int i=0;i<20;i++) { - - RID c = create_body(PhysicsServer::SHAPE_CAPSULE,PhysicsServer::BODY_MODE_RIGID,Transform()); - ps->joint_create_double_hinge(b,Transform(Basis(),Vector3(0,0,-0.7)),c,Transform(Basis(),Vector3(0,0,0.7))); - ps->body_add_collision_exception(c,b); - b=c; - } - -*/ - //create_static_plane(Plane(Vector3(0,1,0),-8)); -#endif } void test_character() { @@ -544,35 +403,21 @@ public: }; PhysicsServer::ShapeType type = shape_idx[i % 4]; - //type=PhysicsServer::SHAPE_CONVEX_POLYGON; Transform t; t.origin = Vector3(0.0 * i, 3.5 + 1.1 * i, 0.7 + 0.0 * i); - //t.origin=Vector3(-0.7+0.0*i,0.5+4.1*i,0); t.basis.rotate(Vector3(0.2, -1, 0), Math_PI / 2 * 0.6); - //t.basis.rotate(Vector3(0,-1,0),Math_PI/4*i); - //t.basis.rotate(Vector3(0,-1,0),Math_PI/4*i); - //t.basis.rotate(Vector3(-1,0,0),Math_PI/4*i); create_body(type, PhysicsServer::BODY_MODE_RIGID, t); - //RID b = create_body(type,i==0?PhysicsServer::BODY_MODE_STATIC:PhysicsServer::BODY_MODE_RIGID,t); } create_static_plane(Plane(Vector3(0, 1, 0), -1)); - - /* - create_static_plane( Plane( Vector3(1,0,0), -2) ); - create_static_plane( Plane( Vector3(-1,0,0), -2) ); - create_static_plane( Plane( Vector3(0,0,1), -2) ); - create_static_plane( Plane( Vector3(0,0,-1), -2) ); -*/ } void test_activate() { create_body(PhysicsServer::SHAPE_BOX, PhysicsServer::BODY_MODE_RIGID, Transform(Basis(), Vector3(0, 2, 0)), true); - //create_body(PhysicsServer::SHAPE_SPHERE,PhysicsServer::BODY_MODE_RIGID,Transform(Basis(),Vector3(0,6,0)),true); create_static_plane(Plane(Vector3(0, 1, 0), -1)); } diff --git a/main/tests/test_physics.h b/main/tests/test_physics.h index 9c9f2fa883..166bc87b4b 100644 --- a/main/tests/test_physics.h +++ b/main/tests/test_physics.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp index 2c9b51aadb..a746973799 100644 --- a/main/tests/test_physics_2d.cpp +++ b/main/tests/test_physics_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_physics_2d.h b/main/tests/test_physics_2d.h index e2022cb1f9..572429185f 100644 --- a/main/tests/test_physics_2d.h +++ b/main/tests/test_physics_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp index 74f7453d1b..1f6217928d 100644 --- a/main/tests/test_render.cpp +++ b/main/tests/test_render.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_render.h b/main/tests/test_render.h index d7849c45ca..84b882de06 100644 --- a/main/tests/test_render.h +++ b/main/tests/test_render.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_shader_lang.cpp b/main/tests/test_shader_lang.cpp index f9516dad99..a0539f4bdf 100644 --- a/main/tests/test_shader_lang.cpp +++ b/main/tests/test_shader_lang.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -37,7 +37,6 @@ #include "scene/gui/control.h" #include "scene/gui/text_edit.h" #include "servers/visual/shader_language.h" -//#include "drivers/gles2/shader_compiler_gles2.h" typedef ShaderLanguage SL; diff --git a/main/tests/test_shader_lang.h b/main/tests/test_shader_lang.h index 7d871b72e7..203f3ffa87 100644 --- a/main/tests/test_shader_lang.h +++ b/main/tests/test_shader_lang.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_sound.cpp b/main/tests/test_sound.cpp deleted file mode 100644 index d8737f6c8d..0000000000 --- a/main/tests/test_sound.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************/ -/* test_sound.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "test_sound.h" -#include "math_funcs.h" -#include "os/main_loop.h" -#include "servers/visual_server.h" - -#include "io/resource_loader.h" -#include "os/os.h" -#include "print_string.h" -#include "servers/audio_server.h" - -#if 0 -namespace TestSound { - - -class TestMainLoop : public MainLoop { - - bool quit; - Ref<Sample> sample; - -public: - virtual void input_event(const InputEvent& p_event) { - - - } - virtual void request_quit() { - - quit=true; - } - - virtual void init() { - - List<String> cmdline = OS::get_singleton()->get_cmdline_args(); - quit=false; - if (cmdline.size()) { - - sample=ResourceLoader::load(cmdline.back()->get()); - ERR_FAIL_COND(sample.is_null()); - print_line("Sample loaded OK"); - } - - RID voice = AudioServer::get_singleton()->voice_create(); - AudioServer::get_singleton()->voice_play( voice, sample->get_rid() ); - - - } - - virtual bool idle(float p_time) { - return false; - } - - - virtual bool iteration(float p_time) { - - return quit; - } - virtual void finish() { - - } - -}; - - -MainLoop* test() { - - return memnew( TestMainLoop ); - -} - -} -#endif diff --git a/main/tests/test_sound.h b/main/tests/test_sound.h deleted file mode 100644 index f55f25fa18..0000000000 --- a/main/tests/test_sound.h +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************/ -/* test_sound.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 TEST_SOUND_H -#define TEST_SOUND_H - -#include "os/main_loop.h" - -namespace TestSound { - -MainLoop *test(); -} - -#endif // TEST_SOUND_H diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp index 0ff84a8286..88d7702acc 100644 --- a/main/tests/test_string.cpp +++ b/main/tests/test_string.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/main/tests/test_string.h b/main/tests/test_string.h index 1060adbc8d..9c97b13626 100644 --- a/main/tests/test_string.h +++ b/main/tests/test_string.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/methods.py b/methods.py index 30a1f3caed..25093ac530 100644 --- a/methods.py +++ b/methods.py @@ -1,4 +1,5 @@ import os +from compat import iteritems def add_source_files(self, sources, filetype, lib_env=None, shared=False): @@ -21,7 +22,7 @@ def add_source_files(self, sources, filetype, lib_env=None, shared=False): def build_shader_header(target, source, env): for x in source: - print x + print(x) name = str(x) name = name[name.rfind("/") + 1:] @@ -704,11 +705,11 @@ def include_file_in_legacygl_header(filename, header_data, depth): if (not included_file in header_data.vertex_included_files and header_data.reading == "vertex"): header_data.vertex_included_files += [included_file] if(include_file_in_legacygl_header(included_file, header_data, depth + 1) == None): - print "Error in file '" + filename + "': #include " + includeline + "could not be found!" + print("Error in file '" + filename + "': #include " + includeline + "could not be found!") elif (not included_file in header_data.fragment_included_files and header_data.reading == "fragment"): header_data.fragment_included_files += [included_file] if(include_file_in_legacygl_header(included_file, header_data, depth + 1) == None): - print "Error in file '" + filename + "': #include " + includeline + "could not be found!" + print("Error in file '" + filename + "': #include " + includeline + "could not be found!") line = fs.readline() @@ -1145,12 +1146,6 @@ def build_legacygl_headers(target, source, env): return 0 -def build_gles2_headers(target, source, env): - - for x in source: - build_legacygl_header(str(x), include="drivers/gles2/shader_gles2.h", class_suffix="GLES2", output_attribs=True) - - def build_gles3_headers(target, source, env): for x in source: @@ -1166,7 +1161,7 @@ def update_version(): print("Using custom revision: " + rev) import version - f = open("core/version_generated.gen.h", "wb") + f = open("core/version_generated.gen.h", "w") f.write("#define VERSION_SHORT_NAME " + str(version.short_name) + "\n") f.write("#define VERSION_NAME " + str(version.name) + "\n") f.write("#define VERSION_MAJOR " + str(version.major) + "\n") @@ -1179,14 +1174,14 @@ def update_version(): f.write("#define VERSION_YEAR " + str(datetime.datetime.now().year) + "\n") f.close() - fhash = open("core/version_hash.gen.h", "wb") + fhash = open("core/version_hash.gen.h", "w") githash = "" if os.path.isfile(".git/HEAD"): - head = open(".git/HEAD", "rb").readline().strip() + head = open(".git/HEAD", "r").readline().strip() if head.startswith("ref: "): head = ".git/" + head[5:] if os.path.isfile(head): - githash = open(head, "rb").readline().strip() + githash = open(head, "r").readline().strip() else: githash = head fhash.write("#define VERSION_HASH \"" + githash + "\"") @@ -1314,7 +1309,7 @@ void unregister_module_types() { """ - f = open("modules/register_module_types.gen.cpp", "wb") + f = open("modules/register_module_types.gen.cpp", "w") f.write(modules_cpp) return module_list @@ -1334,9 +1329,9 @@ def win32_spawn(sh, escape, cmd, args, env): data, err = proc.communicate() rv = proc.wait() if rv: - print "=====" - print err - print "=====" + print("=====") + print(err) + print("=====") return rv """ @@ -1410,17 +1405,17 @@ def android_add_default_config(self, config): def android_add_to_manifest(self, file): base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + file - f = open(base_path, "rb") + f = open(base_path, "r") self.android_manifest_chunk += f.read() def android_add_to_permissions(self, file): base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + file - f = open(base_path, "rb") + f = open(base_path, "r") self.android_permission_chunk += f.read() def android_add_to_attributes(self, file): base_path = self.Dir(".").abspath + "/modules/" + self.current_module + "/" + file - f = open(base_path, "rb") + f = open(base_path, "r") self.android_appattributes_chunk += f.read() def disable_module(self): @@ -1455,9 +1450,9 @@ def use_windows_spawn_fix(self, platform=None): data, err = proc.communicate() rv = proc.wait() if rv: - print "=====" - print err - print "=====" + print("=====") + print(err) + print("=====") return rv def mySpawn(sh, escape, cmd, args, env): @@ -1466,7 +1461,7 @@ def use_windows_spawn_fix(self, platform=None): cmdline = cmd + " " + newargs rv = 0 - env = {str(key): str(value) for key, value in env.iteritems()} + env = {str(key): str(value) for key, value in iteritems(env)} if len(cmdline) > 32000 and cmd.endswith("ar"): cmdline = cmd + " " + args[1] + " " + args[2] + " " for i in range(3, len(args)): @@ -1546,7 +1541,7 @@ def save_active_platforms(apnames, ap): str += "};\n" wf = x + "/" + name + ".gen.h" - pngw = open(wf, "wb") + pngw = open(wf, "w") pngw.write(str) @@ -1614,7 +1609,7 @@ def detect_visual_c_compiler_version(tools_env): # Start with Pre VS 2017 checks which uses VCINSTALLDIR: if 'VCINSTALLDIR' in tools_env: - # print "Checking VCINSTALLDIR" + # print("Checking VCINSTALLDIR") # find() works with -1 so big ifs bellow are needed... the simplest solution, in fact # First test if amd64 and amd64_x86 compilers are present in the path @@ -1647,7 +1642,7 @@ def detect_visual_c_compiler_version(tools_env): # and for VS 2017 and newer we check VCTOOLSINSTALLDIR: if 'VCTOOLSINSTALLDIR' in tools_env: - # print "Checking VCTOOLSINSTALLDIR" + # print("Checking VCTOOLSINSTALLDIR") # Newer versions have a different path available vc_amd64_compiler_detection_index = tools_env["PATH"].upper().find(tools_env['VCTOOLSINSTALLDIR'].upper() + "BIN\\HOSTX64\\X64;") @@ -1677,11 +1672,11 @@ def detect_visual_c_compiler_version(tools_env): vc_chosen_compiler_str = "x86_amd64" # debug help - # print vc_amd64_compiler_detection_index - # print vc_amd64_x86_compiler_detection_index - # print vc_x86_compiler_detection_index - # print vc_x86_amd64_compiler_detection_index - # print "chosen "+str(vc_chosen_compiler_index)+ " | "+str(vc_chosen_compiler_str) + # print(vc_amd64_compiler_detection_index) + # print(vc_amd64_x86_compiler_detection_index) + # print(vc_x86_compiler_detection_index) + # print(vc_x86_amd64_compiler_detection_index) + # print("chosen "+str(vc_chosen_compiler_index)+ " | "+str(vc_chosen_compiler_str)) return vc_chosen_compiler_str diff --git a/misc/dist/ios_xcode/godot_ios/main.m b/misc/dist/ios_xcode/godot_ios/main.m index ad53cf7fea..bb63364d8f 100644 --- a/misc/dist/ios_xcode/godot_ios/main.m +++ b/misc/dist/ios_xcode/godot_ios/main.m @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/misc/scripts/addheader.py b/misc/scripts/addheader.py index acb517b5bd..3f8b75ebcd 100644 --- a/misc/scripts/addheader.py +++ b/misc/scripts/addheader.py @@ -4,7 +4,7 @@ header = """\ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/dds/register_types.cpp b/modules/dds/register_types.cpp index 4a758fe033..22fb391b9a 100644 --- a/modules/dds/register_types.cpp +++ b/modules/dds/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/dds/register_types.h b/modules/dds/register_types.h index 4807c7dd5b..e48d56c898 100644 --- a/modules/dds/register_types.h +++ b/modules/dds/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp index 71593ebfa9..95d93e6af6 100644 --- a/modules/dds/texture_loader_dds.cpp +++ b/modules/dds/texture_loader_dds.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/dds/texture_loader_dds.h b/modules/dds/texture_loader_dds.h index 3b36e7f1eb..c545d210b4 100644 --- a/modules/dds/texture_loader_dds.h +++ b/modules/dds/texture_loader_dds.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index c76e0c6675..c50886ad3c 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h index f2c3b838e4..81d517147d 100644 --- a/modules/enet/networked_multiplayer_enet.h +++ b/modules/enet/networked_multiplayer_enet.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/enet/register_types.cpp b/modules/enet/register_types.cpp index a6e6c87c14..316aca6d94 100644 --- a/modules/enet/register_types.cpp +++ b/modules/enet/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/enet/register_types.h b/modules/enet/register_types.h index 9bcb35a92b..0775044bc7 100644 --- a/modules/enet/register_types.h +++ b/modules/enet/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index ccc1733c43..9a15beb6eb 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/etc/image_etc.h b/modules/etc/image_etc.h index 3cbadef6fa..8cc0bdc08f 100644 --- a/modules/etc/image_etc.h +++ b/modules/etc/image_etc.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/etc/register_types.cpp b/modules/etc/register_types.cpp index e777859a8f..ef0a403e90 100644 --- a/modules/etc/register_types.cpp +++ b/modules/etc/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/etc/register_types.h b/modules/etc/register_types.h index 44399376f3..1d9a0e3b2c 100644 --- a/modules/etc/register_types.h +++ b/modules/etc/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp index c04528d2a0..e8a5aced3e 100644 --- a/modules/etc/texture_loader_pkm.cpp +++ b/modules/etc/texture_loader_pkm.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/etc/texture_loader_pkm.h b/modules/etc/texture_loader_pkm.h index 8a0f06a51a..667870d7cc 100644 --- a/modules/etc/texture_loader_pkm.h +++ b/modules/etc/texture_loader_pkm.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index 6a89e8e087..f22df4407c 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -1,6 +1,7 @@ #!/usr/bin/env python Import('env') +from compat import isbasestring # Not building in a separate env as scene needs it @@ -74,7 +75,7 @@ if (env['builtin_freetype'] != 'no'): # and then plain strings for system library. We insert between the two. inserted = False for idx, linklib in enumerate(env["LIBS"]): - if isinstance(linklib, basestring): # first system lib such as "X11", otherwise SCons lib object + if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object env["LIBS"].insert(idx, lib) inserted = True break diff --git a/modules/freetype/register_types.cpp b/modules/freetype/register_types.cpp index 3f290c2138..de6e73a55e 100644 --- a/modules/freetype/register_types.cpp +++ b/modules/freetype/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/freetype/register_types.h b/modules/freetype/register_types.h index c3ba324ed1..ed8b5656b6 100644 --- a/modules/freetype/register_types.h +++ b/modules/freetype/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/freetype/uwpdef.h b/modules/freetype/uwpdef.h index c29b14dd12..ecde9946c7 100644 --- a/modules/freetype/uwpdef.h +++ b/modules/freetype/uwpdef.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index ccc7e5f2da..7faf21c5a1 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index 003ec46a25..bec746a441 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/array.cpp b/modules/gdnative/godot/array.cpp index 97c73dc253..c15ba30ca2 100644 --- a/modules/gdnative/godot/array.cpp +++ b/modules/gdnative/godot/array.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/array.h b/modules/gdnative/godot/array.h index 158170ba0e..434ce958c9 100644 --- a/modules/gdnative/godot/array.h +++ b/modules/gdnative/godot/array.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/basis.cpp b/modules/gdnative/godot/basis.cpp index 5cf379b7d5..8433355c12 100644 --- a/modules/gdnative/godot/basis.cpp +++ b/modules/gdnative/godot/basis.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/basis.h b/modules/gdnative/godot/basis.h index e96b8b730d..d336bb9bc1 100644 --- a/modules/gdnative/godot/basis.h +++ b/modules/gdnative/godot/basis.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/color.cpp b/modules/gdnative/godot/color.cpp index a5ffee1e0b..3677fdc265 100644 --- a/modules/gdnative/godot/color.cpp +++ b/modules/gdnative/godot/color.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/color.h b/modules/gdnative/godot/color.h index 2cd6b48b48..5d550e40b3 100644 --- a/modules/gdnative/godot/color.h +++ b/modules/gdnative/godot/color.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/dictionary.cpp b/modules/gdnative/godot/dictionary.cpp index c538456432..2996cc78a3 100644 --- a/modules/gdnative/godot/dictionary.cpp +++ b/modules/gdnative/godot/dictionary.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/dictionary.h b/modules/gdnative/godot/dictionary.h index 594b02b4dd..bbe40f23c3 100644 --- a/modules/gdnative/godot/dictionary.h +++ b/modules/gdnative/godot/dictionary.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/gdnative.cpp b/modules/gdnative/godot/gdnative.cpp index 4cda1f4560..7cd52da34d 100644 --- a/modules/gdnative/godot/gdnative.cpp +++ b/modules/gdnative/godot/gdnative.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/gdnative.h b/modules/gdnative/godot/gdnative.h index d849999079..8b289da1f5 100644 --- a/modules/gdnative/godot/gdnative.h +++ b/modules/gdnative/godot/gdnative.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/node_path.cpp b/modules/gdnative/godot/node_path.cpp index f4179361be..2309588a81 100644 --- a/modules/gdnative/godot/node_path.cpp +++ b/modules/gdnative/godot/node_path.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/node_path.h b/modules/gdnative/godot/node_path.h index 4d3dc4e0ee..3e2a99e461 100644 --- a/modules/gdnative/godot/node_path.h +++ b/modules/gdnative/godot/node_path.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/plane.cpp b/modules/gdnative/godot/plane.cpp index 5c5b302345..f3d4b6971e 100644 --- a/modules/gdnative/godot/plane.cpp +++ b/modules/gdnative/godot/plane.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/plane.h b/modules/gdnative/godot/plane.h index 8519ac60c4..27548c8b0c 100644 --- a/modules/gdnative/godot/plane.h +++ b/modules/gdnative/godot/plane.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/pool_arrays.cpp b/modules/gdnative/godot/pool_arrays.cpp index fa460be8bc..2e533077f6 100644 --- a/modules/gdnative/godot/pool_arrays.cpp +++ b/modules/gdnative/godot/pool_arrays.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/pool_arrays.h b/modules/gdnative/godot/pool_arrays.h index 29517d21ac..ecd85ddfe8 100644 --- a/modules/gdnative/godot/pool_arrays.h +++ b/modules/gdnative/godot/pool_arrays.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/quat.cpp b/modules/gdnative/godot/quat.cpp index 37ee4d6b15..e6bea78b60 100644 --- a/modules/gdnative/godot/quat.cpp +++ b/modules/gdnative/godot/quat.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/quat.h b/modules/gdnative/godot/quat.h index 0979653d93..9a3238a337 100644 --- a/modules/gdnative/godot/quat.h +++ b/modules/gdnative/godot/quat.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/rect2.cpp b/modules/gdnative/godot/rect2.cpp index 023584c4f6..98e7855dc9 100644 --- a/modules/gdnative/godot/rect2.cpp +++ b/modules/gdnative/godot/rect2.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/rect2.h b/modules/gdnative/godot/rect2.h index cb1ddb58cf..8ceeddf1b4 100644 --- a/modules/gdnative/godot/rect2.h +++ b/modules/gdnative/godot/rect2.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/rect3.cpp b/modules/gdnative/godot/rect3.cpp index 708d2987f2..88952ab49c 100644 --- a/modules/gdnative/godot/rect3.cpp +++ b/modules/gdnative/godot/rect3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/rect3.h b/modules/gdnative/godot/rect3.h index 69279351c4..ca96aadd5c 100644 --- a/modules/gdnative/godot/rect3.h +++ b/modules/gdnative/godot/rect3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/rid.cpp b/modules/gdnative/godot/rid.cpp index 09ce3a5979..51c8aaa1b3 100644 --- a/modules/gdnative/godot/rid.cpp +++ b/modules/gdnative/godot/rid.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/rid.h b/modules/gdnative/godot/rid.h index ac5b5383d9..b685157cec 100644 --- a/modules/gdnative/godot/rid.h +++ b/modules/gdnative/godot/rid.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/string.cpp b/modules/gdnative/godot/string.cpp index 2235c12a2d..3790b6ea95 100644 --- a/modules/gdnative/godot/string.cpp +++ b/modules/gdnative/godot/string.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/string.h b/modules/gdnative/godot/string.h index 7695cd7931..f41626faa1 100644 --- a/modules/gdnative/godot/string.h +++ b/modules/gdnative/godot/string.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/transform.cpp b/modules/gdnative/godot/transform.cpp index 87fee918bd..a965067b77 100644 --- a/modules/gdnative/godot/transform.cpp +++ b/modules/gdnative/godot/transform.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/transform.h b/modules/gdnative/godot/transform.h index 30b9970f67..60788e3d57 100644 --- a/modules/gdnative/godot/transform.h +++ b/modules/gdnative/godot/transform.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/transform2d.cpp b/modules/gdnative/godot/transform2d.cpp index 65f9f8ee32..9fc44ecdfa 100644 --- a/modules/gdnative/godot/transform2d.cpp +++ b/modules/gdnative/godot/transform2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/transform2d.h b/modules/gdnative/godot/transform2d.h index 41c8ba982c..c0f5725eed 100644 --- a/modules/gdnative/godot/transform2d.h +++ b/modules/gdnative/godot/transform2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/variant.cpp b/modules/gdnative/godot/variant.cpp index d814ef913c..582544b3a0 100644 --- a/modules/gdnative/godot/variant.cpp +++ b/modules/gdnative/godot/variant.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/variant.h b/modules/gdnative/godot/variant.h index 1c19d2a25b..fda24db8d4 100644 --- a/modules/gdnative/godot/variant.h +++ b/modules/gdnative/godot/variant.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/vector2.cpp b/modules/gdnative/godot/vector2.cpp index 05d4b1acc8..78ed5f06a9 100644 --- a/modules/gdnative/godot/vector2.cpp +++ b/modules/gdnative/godot/vector2.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/vector2.h b/modules/gdnative/godot/vector2.h index 9db238b4fd..98e9700e32 100644 --- a/modules/gdnative/godot/vector2.h +++ b/modules/gdnative/godot/vector2.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/vector3.cpp b/modules/gdnative/godot/vector3.cpp index fe27e740e2..5faeac2864 100644 --- a/modules/gdnative/godot/vector3.cpp +++ b/modules/gdnative/godot/vector3.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/godot/vector3.h b/modules/gdnative/godot/vector3.h index 8aba1d9a85..b76ca11a9c 100644 --- a/modules/gdnative/godot/vector3.h +++ b/modules/gdnative/godot/vector3.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index da50104e26..9ad05b7194 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdnative/register_types.h b/modules/gdnative/register_types.h index 48e778cb2c..08da72016f 100644 --- a/modules/gdnative/register_types.h +++ b/modules/gdnative/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp index 2aa24e88a9..4803781c67 100644 --- a/modules/gdscript/gd_compiler.cpp +++ b/modules/gdscript/gd_compiler.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h index b7ff092eba..ac713ae75b 100644 --- a/modules/gdscript/gd_compiler.h +++ b/modules/gdscript/gd_compiler.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -91,7 +91,6 @@ class GDCompiler { } } - //int get_identifier_pos(const StringName& p_dentifier) const; HashMap<Variant, int, VariantHasher, VariantComparator> constant_map; Map<StringName, int> name_map; @@ -127,17 +126,6 @@ class GDCompiler { int call_max; }; -#if 0 - void _create_index(const GDParser::OperatorNode *on); - void _create_call(const GDParser::OperatorNode *on); - - - int _parse_expression(const GDParser::Node *p_expr,CodeGen& codegen); - void _parse_block(GDParser::BlockNode *p_block); - void _parse_function(GDParser::FunctionNode *p_func); - Ref<GDScript> _parse_class(GDParser::ClassNode *p_class); -#endif - bool _is_class_member_property(CodeGen &codegen, const StringName &p_name); bool _is_class_member_property(GDScript *owner, const StringName &p_name); @@ -146,7 +134,6 @@ class GDCompiler { bool _create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level); bool _create_binary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false); - //int _parse_subexpression(CodeGen& codegen,const GDParser::BlockNode *p_block,const GDParser::Node *p_expression); int _parse_assign_right_expression(CodeGen &codegen, const GDParser::OperatorNode *p_expression, int p_stack_level); int _parse_expression(CodeGen &codegen, const GDParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false); Error _parse_block(CodeGen &codegen, const GDParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1); diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 905c784ab9..02fab6d17f 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -27,12 +27,14 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "gd_script.h" + #include "editor/editor_settings.h" #include "gd_compiler.h" -#include "gd_script.h" #include "global_constants.h" #include "os/file_access.h" #include "project_settings.h" + #ifdef TOOLS_ENABLED #include "editor/editor_file_system.h" #include "editor/editor_settings.h" @@ -363,7 +365,7 @@ struct GDCompletionIdentifier { Variant value; //im case there is a value, also return it }; -static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) { +static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) { GDCompletionIdentifier t; t.type = p_variant.get_type(); @@ -371,14 +373,14 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) { if (p_variant.get_type() == Variant::OBJECT) { Object *obj = p_variant; if (obj) { - /* - if (Object::cast_to<GDNativeClass>(obj)) { - t.obj_type=Object::cast_to<GDNativeClass>(obj)->get_name(); - t.value=Variant(); + + if (p_allow_gdnative_class && Object::cast_to<GDNativeClass>(obj)) { + t.obj_type = Object::cast_to<GDNativeClass>(obj)->get_name(); + t.value = Variant(); } else { - */ - t.obj_type = obj->get_class(); - //} + + t.obj_type = obj->get_class(); + } } } return t; @@ -511,9 +513,9 @@ static GDCompletionIdentifier _get_native_class(GDCompletionContext &context) { return id; } -static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type); +static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing); -static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type) { +static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type, bool p_for_indexing = false) { if (p_node->type == GDParser::Node::TYPE_CONSTANT) { @@ -564,7 +566,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: return true; } else if (p_node->type == GDParser::Node::TYPE_IDENTIFIER) { - return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type); + return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type, p_for_indexing); } else if (p_node->type == GDParser::Node::TYPE_SELF) { //eeh... @@ -810,23 +812,38 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: if (p1.value.get_type() == Variant::OBJECT) { //?? + if (p1.obj_type != StringName() && p2.type == Variant::STRING) { + + StringName base_type = p1.obj_type; + + if (p1.obj_type == "GDNativeClass") { + //native enum + Ref<GDNativeClass> gdn = p1.value; + if (gdn.is_valid()) { + + base_type = gdn->get_name(); + } + } StringName index = p2.value; bool valid; - Variant::Type t = ClassDB::get_property_type(p1.obj_type, index, &valid); + Variant::Type t = ClassDB::get_property_type(base_type, index, &valid); if (t != Variant::NIL && valid) { r_type.type = t; - if (t == Variant::INT) { + if (t == Variant::INT || t == Variant::OBJECT) { //check for enum! #if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED) - StringName getter = ClassDB::get_property_getter(p1.obj_type, index); + StringName getter = ClassDB::get_property_getter(base_type, index); if (getter != StringName()) { - MethodBind *mb = ClassDB::get_method(p1.obj_type, getter); + MethodBind *mb = ClassDB::get_method(base_type, getter); if (mb) { PropertyInfo rt = mb->get_return_info(); - if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { + if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM && t == Variant::INT) { r_type.enumeration = rt.class_name; + } else if (t == Variant::OBJECT) { + + r_type.obj_type = rt.class_name; } } } @@ -1054,7 +1071,7 @@ static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &c return false; } -static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) { +static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing) { //go to block first @@ -1208,7 +1225,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con for (Map<StringName, int>::Element *E = GDScriptLanguage::get_singleton()->get_global_map().front(); E; E = E->next()) { if (E->key() == p_identifier) { - r_type = _get_type_from_variant(GDScriptLanguage::get_singleton()->get_global_array()[E->get()]); + r_type = _get_type_from_variant(GDScriptLanguage::get_singleton()->get_global_array()[E->get()], !p_for_indexing); return true; } } @@ -1672,21 +1689,6 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N return; //found } } -#if 0 - //use class directly, no code was found - if (!isfunction) { - for (const Map<StringName,Variant>::Element *E=scr->get_constants().front();E;E=E->next()) { - options.insert(E->key()); - } - } - for (const Map<StringName,GDFunction>::Element *E=scr->get_member_functions().front();E;E=E->next()) { - options.insert(String(E->key())+"("); - } - - for (const Set<StringName>::Element *E=scr->get_members().front();E;E=E->next()) { - options.insert(E->get()); - } -#endif } if (scr->get_base().is_valid()) @@ -2027,99 +2029,6 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N } } } -#if 0 - bool _static=context.function->_static; - - - - - for(int i=0;i<context._class->static_functions.size();i++) { - if (context._class->static_functions[i]->arguments.size()) - result.insert(context._class->static_functions[i]->name.operator String()+"("); - else - result.insert(context._class->static_functions[i]->name.operator String()+"()"); - } - - if (!p_static) { - - for(int i=0;i<context._class->functions.size();i++) { - if (context._class->functions[i]->arguments.size()) - result.insert(context._class->functions[i]->name.operator String()+"("); - else - result.insert(context._class->functions[i]->name.operator String()+"()"); - } - } - - Ref<Reference> base = _get_parent_class(context); - - while(true) { - - Ref<GDScript> script = base; - Ref<GDNativeClass> nc = base; - if (script.is_valid()) { - - if (!p_static && !p_only_functions) { - for (const Set<StringName>::Element *E=script->get_members().front();E;E=E->next()) { - result.insert(E->get().operator String()); - } - } - - if (!p_only_functions) { - for (const Map<StringName,Variant>::Element *E=script->get_constants().front();E;E=E->next()) { - result.insert(E->key().operator String()); - } - } - - for (const Map<StringName,GDFunction>::Element *E=script->get_member_functions().front();E;E=E->next()) { - if (!p_static || E->get().is_static()) { - if (E->get().get_argument_count()) - result.insert(E->key().operator String()+"("); - else - result.insert(E->key().operator String()+"()"); - } - } - - if (!p_only_functions) { - for (const Map<StringName,Ref<GDScript> >::Element *E=script->get_subclasses().front();E;E=E->next()) { - result.insert(E->key().operator String()); - } - } - - base=script->get_base(); - if (base.is_null()) - base=script->get_native(); - } else if (nc.is_valid()) { - - if (!p_only_functions) { - - StringName type = nc->get_name(); - List<String> constants; - ClassDB::get_integer_constant_list(type,&constants); - for(List<String>::Element *E=constants.front();E;E=E->next()) { - result.insert(E->get()); - } - - List<MethodInfo> methods; - ClassDB::get_method_list(type,&methods); - for(List<MethodInfo>::Element *E=methods.front();E;E=E->next()) { - if (E->get().arguments.size()) - result.insert(E->get().name+"("); - else - result.insert(E->get().name+"()"); - } - } - break; - } else - break; - - } - - for(int i=0;i<GDFunctions::FUNC_MAX;i++) { - - result.insert(GDFunctions::get_func_name(GDFunctions::Function(i))); - } - -#endif } Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint) { @@ -2188,7 +2097,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base break; GDCompletionIdentifier t; - if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) { + if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) { if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") { //native enum @@ -2852,18 +2761,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } } -#if 0 - GDCompletionIdentifier identifier; - if (_guess_identifier_type(context,p.get_completion_line(),p_symbol,identifier)) { - - print_line("var type: "+Variant::get_type_name(identifier.type)); - if (identifier.script.is_valid()) { - print_line("var script: "+identifier.script->get_path()); - } - print_line("obj type: "+String(identifier.obj_type)); - print_line("value: "+String(identifier.value)); - } -#endif } } break; diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index 3b78573f58..e6f65fe0c2 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1319,22 +1319,6 @@ void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, } } -#if 0 -void GDFunction::clear() { - - name=StringName(); - constants.clear(); - _stack_size=0; - code.clear(); - _constants_ptr=NULL; - _constant_count=0; - _global_names_ptr=NULL; - _global_names_count=0; - _code_ptr=NULL; - _code_size=0; - -} -#endif GDFunction::GDFunction() : function_list(this) { @@ -1434,7 +1418,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount // If the return value is a GDFunctionState reference, // then the function did yield again after resuming. if (ret.is_ref()) { - GDFunctionState *gdfs = Object::cast_to<GDFunctionState>((Object *)&ret); + GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret); if (gdfs && gdfs->function == function) completed = false; } @@ -1490,7 +1474,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) { // If the return value is a GDFunctionState reference, // then the function did yield again after resuming. if (ret.is_ref()) { - GDFunctionState *gdfs = Object::cast_to<GDFunctionState>((Object *)&ret); + GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret); if (gdfs && gdfs->function == function) completed = false; } diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gd_function.h index 661de0acce..bf5ff5f8da 100644 --- a/modules/gdscript/gd_function.h +++ b/modules/gdscript/gd_function.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 65f0cbbe7d..3bd0ce3fab 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h index 11dfbd473c..a568c8f1cf 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gd_functions.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 48da2135fa..072937a521 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h index 177552d279..7e88fd9746 100644 --- a/modules/gdscript/gd_parser.h +++ b/modules/gdscript/gd_parser.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 68c1fb3635..cf6529d5ae 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "gd_script.h" + #include "gd_compiler.h" #include "global_constants.h" #include "io/file_access_encrypted.h" @@ -42,11 +43,6 @@ GDNativeClass::GDNativeClass(const StringName &p_name) { name = p_name; } -/*void GDNativeClass::call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount){ - - -}*/ - bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const { bool ok; @@ -183,7 +179,6 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro bool GDScript::can_instance() const { - //return valid; //any script in GDscript can instance return valid || (!tool && !ScriptServer::is_scripting_enabled()); } @@ -218,49 +213,6 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { placeholders.erase(p_placeholder); } - -/* -void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) { - - - List<PropertyInfo> plist; - GDScript *scr=this; - - Map<StringName,Variant> default_values; - while(scr) { - - Vector<_GDScriptMemberSort> msort; - for(Map<StringName,PropertyInfo>::Element *E=scr->member_info.front();E;E=E->next()) { - - _GDScriptMemberSort ms; - ERR_CONTINUE(!scr->member_indices.has(E->key())); - ms.index=scr->member_indices[E->key()].index; - ms.name=E->key(); - - msort.push_back(ms); - - } - - msort.sort(); - msort.invert(); - for(int i=0;i<msort.size();i++) { - - plist.push_front(scr->member_info[msort[i].name]); - if (scr->member_default_values.has(msort[i].name)) - default_values[msort[i].name]=scr->member_default_values[msort[i].name]; - else { - Variant::CallError err; - default_values[msort[i].name]=Variant::construct(scr->member_info[msort[i].name].type,NULL,0,err); - } - } - - scr=scr->_base; - } - - - p_placeholder->update(plist,default_values); - -}*/ #endif void GDScript::get_script_method_list(List<MethodInfo> *p_list) const { @@ -428,7 +380,6 @@ void GDScript::set_source_code(const String &p_code) { source = p_code; #ifdef TOOLS_ENABLED source_changed_cache = true; -//print_line("SC CHANGED "+get_path()); #endif } @@ -655,12 +606,6 @@ Error GDScript::reload(bool p_keep_state) { _set_subclass_path(E->get(), path); } -#ifdef TOOLS_ENABLED -/*for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) { - - _update_placeholder(E->get()); - }*/ -#endif return OK; } @@ -1141,53 +1086,10 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const { props.push_front(sptr->member_info[msort[i].name]); } -#if 0 - if (sptr->member_functions.has("_get_property_list")) { - - Variant::CallError err; - GDFunction *f = const_cast<GDFunction*>(sptr->member_functions["_get_property_list"]); - Variant plv = f->call(const_cast<GDInstance*>(this),NULL,0,err); - - if (plv.get_type()!=Variant::ARRAY) { - - ERR_PRINT("_get_property_list: expected array returned"); - } else { - - Array pl=plv; - - for(int i=0;i<pl.size();i++) { - - Dictionary p = pl[i]; - PropertyInfo pinfo; - if (!p.has("name")) { - ERR_PRINT("_get_property_list: expected 'name' key of type string.") - continue; - } - if (!p.has("type")) { - ERR_PRINT("_get_property_list: expected 'type' key of type integer.") - continue; - } - pinfo.name=p["name"]; - pinfo.type=Variant::Type(int(p["type"])); - if (p.has("hint")) - pinfo.hint=PropertyHint(int(p["hint"])); - if (p.has("hint_string")) - pinfo.hint_string=p["hint_string"]; - if (p.has("usage")) - pinfo.usage=p["usage"]; - - - props.push_back(pinfo); - } - } - } -#endif sptr = sptr->_base; } - //props.invert(); - for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) { p_properties->push_back(E->get()); @@ -1390,10 +1292,6 @@ GDInstance::~GDInstance() { } /************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ -/************* SCRIPT LANGUAGE **************/ GDScriptLanguage *GDScriptLanguage::singleton = NULL; diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 441f87474e..6f05a4770b 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index f70982d7c0..5f85158232 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "gd_tokenizer.h" + #include "gd_functions.h" #include "io/marshalls.h" #include "map.h" @@ -504,7 +505,6 @@ void GDTokenizerText::_advance() { _make_newline(i); return; } -#if 1 //py style tokenizer case '#': { // line comment skip while (GETCHAR(0) != '\n') { @@ -526,57 +526,9 @@ void GDTokenizerText::_advance() { return; } break; -#endif case '/': { switch (GETCHAR(1)) { -#if 0 // c style tokenizer - case '*': { // block comment - int pos = code_pos+2; - int new_line=line; - int new_col=column+2; - - while(true) { - if (_code[pos]=='0') { - _make_error("Unterminated Comment"); - code_pos=pos; - return; - } - if (_code[pos]=='*' && _code[pos+1]=='/') { - new_col+=2; - pos+=2; //compensate - break; - } else if (_code[pos]=='\n') { - new_line++; - new_col=1; - } else { - new_col++; - } - pos++; - } - - column=new_col; - line=new_line; - code_pos=pos; - continue; - - } break; - case '/': { // line comment skip - - while(GETCHAR(0)!='\n') { - code_pos++; - if (GETCHAR(0)==0) { //end of file - _make_error("Unterminated Comment"); - return; - } - } - INCPOS(1); - column=1; - line++; - continue; - - } break; -#endif case '=': { // diveq _make_token(TK_OP_ASSIGN_DIV); diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gd_tokenizer.h index 4e868301a3..c935ce45a1 100644 --- a/modules/gdscript/gd_tokenizer.h +++ b/modules/gdscript/gd_tokenizer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index 41ea0c2a26..036274c8f2 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -37,103 +37,7 @@ GDScriptLanguage *script_language_gd = NULL; ResourceFormatLoaderGDScript *resource_loader_gd = NULL; ResourceFormatSaverGDScript *resource_saver_gd = NULL; -#if 0 -#ifdef TOOLS_ENABLED -#include "editor/editor_import_export.h" -#include "editor/editor_node.h" -#include "editor/editor_settings.h" -#include "gd_tokenizer.h" - -class EditorExportGDScript : public EditorExportPlugin { - - GDCLASS(EditorExportGDScript,EditorExportPlugin); - -public: - - virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) { - //compile gdscript to bytecode - - if (EditorImportExport::get_singleton()->script_get_action()!=EditorImportExport::SCRIPT_ACTION_NONE) { - - if (p_path.ends_with(".gd")) { - Vector<uint8_t> file = FileAccess::get_file_as_array(p_path); - if (file.empty()) - return file; - String txt; - txt.parse_utf8((const char*)file.ptr(),file.size()); - file = GDTokenizerBuffer::parse_code_string(txt); - - if (!file.empty()) { - - if (EditorImportExport::get_singleton()->script_get_action()==EditorImportExport::SCRIPT_ACTION_ENCRYPT) { - - String tmp_path=EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/script.gde"); - FileAccess *fa = FileAccess::open(tmp_path,FileAccess::WRITE); - String skey=EditorImportExport::get_singleton()->script_get_encryption_key().to_lower(); - Vector<uint8_t> key; - key.resize(32); - for(int i=0;i<32;i++) { - int v=0; - if (i*2<skey.length()) { - CharType ct = skey[i*2]; - if (ct>='0' && ct<='9') - ct=ct-'0'; - else if (ct>='a' && ct<='f') - ct=10+ct-'a'; - v|=ct<<4; - } - - if (i*2+1<skey.length()) { - CharType ct = skey[i*2+1]; - if (ct>='0' && ct<='9') - ct=ct-'0'; - else if (ct>='a' && ct<='f') - ct=10+ct-'a'; - v|=ct; - } - key[i]=v; - } - FileAccessEncrypted *fae=memnew(FileAccessEncrypted); - Error err = fae->open_and_parse(fa,key,FileAccessEncrypted::MODE_WRITE_AES256); - if (err==OK) { - - fae->store_buffer(file.ptr(),file.size()); - p_path=p_path.get_basename()+".gde"; - } - - memdelete(fae); - - file=FileAccess::get_file_as_array(tmp_path); - return file; - - - } else { - - p_path=p_path.get_basename()+".gdc"; - return file; - } - } - - } - } - - return Vector<uint8_t>(); - } - - - EditorExportGDScript(){} - -}; - -static void register_editor_plugin() { - - Ref<EditorExportGDScript> egd = memnew( EditorExportGDScript ); - EditorImportExport::get_singleton()->add_export_plugin(egd); -} - -#endif -#endif void register_gdscript_types() { ClassDB::register_class<GDScript>(); @@ -146,13 +50,8 @@ void register_gdscript_types() { ResourceLoader::add_resource_format_loader(resource_loader_gd); resource_saver_gd = memnew(ResourceFormatSaverGDScript); ResourceSaver::add_resource_format_saver(resource_saver_gd); -#if 0 -#ifdef TOOLS_ENABLED - - EditorNode::add_init_callback(register_editor_plugin); -#endif -#endif } + void unregister_gdscript_types() { ScriptServer::unregister_language(script_language_gd); diff --git a/modules/gdscript/register_types.h b/modules/gdscript/register_types.h index 4e969f5bd4..a674877f37 100644 --- a/modules/gdscript/register_types.h +++ b/modules/gdscript/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index b444664878..0de2cf80ea 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -46,7 +46,13 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) { set_theme(p_value); } else if (name == "cell_size") { - set_cell_size(p_value); + if (p_value.get_type() == Variant::INT || p_value.get_type() == Variant::REAL) { + //compatibility + float cs = p_value; + set_cell_size(Vector3(cs, cs, cs)); + } else { + set_cell_size(p_value); + } } else if (name == "cell_octant_size") { set_octant_size(p_value); } else if (name == "cell_center_x") { @@ -176,12 +182,12 @@ Ref<MeshLibrary> GridMap::get_theme() const { return theme; } -void GridMap::set_cell_size(float p_size) { +void GridMap::set_cell_size(const Vector3 &p_size) { cell_size = p_size; _recreate_octant_data(); } -float GridMap::get_cell_size() const { +Vector3 GridMap::get_cell_size() const { return cell_size; } @@ -242,56 +248,29 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) { ok.y = p_y / octant_size; ok.z = p_z / octant_size; - if (cell_map.has(key)) { - - int prev_item = cell_map[key].item; - - OctantKey octantkey = ok; - - ERR_FAIL_COND(!octant_map.has(octantkey)); - Octant &g = *octant_map[octantkey]; - ERR_FAIL_COND(!g.items.has(prev_item)); - ERR_FAIL_COND(!g.items[prev_item].cells.has(key)); - - g.items[prev_item].cells.erase(key); - if (g.items[prev_item].cells.size() == 0) { - VS::get_singleton()->free(g.items[prev_item].multimesh_instance); - g.items.erase(prev_item); - } - if (g.items.empty()) { - - PhysicsServer::get_singleton()->free(g.static_body); - if (g.collision_debug.is_valid()) { - PhysicsServer::get_singleton()->free(g.collision_debug); - PhysicsServer::get_singleton()->free(g.collision_debug_instance); - } - - memdelete(&g); - octant_map.erase(octantkey); - } else { + if (p_item < 0) { + //erase + if (cell_map.has(key)) { + OctantKey octantkey = ok; + ERR_FAIL_COND(!octant_map.has(octantkey)); + Octant &g = *octant_map[octantkey]; + g.cells.erase(key); g.dirty = true; + cell_map.erase(key); + _queue_octants_dirty(); } - cell_map.erase(key); - - _queue_dirty_map(); - } - - if (p_item < 0) return; + } OctantKey octantkey = ok; - //add later if (!octant_map.has(octantkey)) { - + //create octant because it does not exist Octant *g = memnew(Octant); g->dirty = true; g->static_body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC); PhysicsServer::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id()); - if (is_inside_world()) - PhysicsServer::get_singleton()->body_set_space(g->static_body, get_world()->get_space()); - SceneTree *st = SceneTree::get_singleton(); if (st && st->is_debugging_collisions_hint()) { @@ -299,45 +278,26 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) { g->collision_debug = VisualServer::get_singleton()->mesh_create(); g->collision_debug_instance = VisualServer::get_singleton()->instance_create(); VisualServer::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug); - if (is_inside_world()) { - VisualServer::get_singleton()->instance_set_scenario(g->collision_debug_instance, get_world()->get_scenario()); - VisualServer::get_singleton()->instance_set_transform(g->collision_debug_instance, get_global_transform()); - } } octant_map[octantkey] = g; - } - - Octant &g = *octant_map[octantkey]; - if (!g.items.has(p_item)) { - Octant::ItemInstances ii; - if (theme.is_valid() && theme->has_item(p_item)) { - ii.mesh = theme->get_item_mesh(p_item); - ii.shape = theme->get_item_shape(p_item); - ii.navmesh = theme->get_item_navmesh(p_item); + if (is_inside_world()) { + _octant_enter_world(octantkey); + _octant_transform(octantkey); } - 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_flag(ii.multimesh_instance, VS::INSTANCE_FLAG_USE_BAKED_LIGHT, true); - - g.items[p_item] = ii; } - Octant::ItemInstances &ii = g.items[p_item]; - ii.cells.insert(key); + Octant &g = *octant_map[octantkey]; + g.cells.insert(key); g.dirty = true; + _queue_octants_dirty(); - _queue_dirty_map(); - - cell_map[key] = Cell(); - Cell &c = cell_map[key]; + Cell c; c.item = p_item; c.rot = p_rot; + + cell_map[key] = c; } int GridMap::get_cell_item(int p_x, int p_y, int p_z) const { @@ -372,115 +332,57 @@ int GridMap::get_cell_item_orientation(int p_x, int p_y, int p_z) const { return cell_map[key].rot; } -void GridMap::_octant_enter_tree(const OctantKey &p_key) { - ERR_FAIL_COND(!octant_map.has(p_key)); - if (navigation) { - Octant &g = *octant_map[p_key]; - - Vector3 ofs(cell_size * 0.5 * int(center_x), cell_size * 0.5 * int(center_y), cell_size * 0.5 * int(center_z)); - _octant_clear_navmesh(p_key); - - for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) { - Octant::ItemInstances &ii = E->get(); - - 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; - - if (clip && ((clip_above && cellpos[clip_axis] > clip_floor) || (!clip_above && cellpos[clip_axis] < clip_floor))) { - - xform.basis.set_zero(); - - } else { - - xform.basis.set_orthogonal_index(C->get().rot); - } - - xform.set_origin(cellpos * cell_size + ofs); - xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale)); - // add the item's navmesh at given xform to GridMap's Navigation ancestor - if (ii.navmesh.is_valid()) { - int nm_id = navigation->navmesh_create(ii.navmesh, xform, this); - Octant::NavMesh nm; - nm.id = nm_id; - nm.xform = xform; - g.navmesh_ids[ik] = nm; - } - } - } - } -} - -void GridMap::_octant_enter_world(const OctantKey &p_key) { +void GridMap::_octant_transform(const OctantKey &p_key) { ERR_FAIL_COND(!octant_map.has(p_key)); Octant &g = *octant_map[p_key]; PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); - PhysicsServer::get_singleton()->body_set_space(g.static_body, get_world()->get_space()); - //print_line("BODYPOS: "+get_global_transform()); if (g.collision_debug_instance.is_valid()) { - VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario()); VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform()); } - 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()); + for (int i = 0; i < g.multimesh_instances.size(); i++) { + VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform()); } } -void GridMap::_octant_transform(const OctantKey &p_key) { - - ERR_FAIL_COND(!octant_map.has(p_key)); +bool GridMap::_octant_update(const OctantKey &p_key) { + ERR_FAIL_COND_V(!octant_map.has(p_key), false); Octant &g = *octant_map[p_key]; - PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); + if (!g.dirty) + return false; - if (g.collision_debug_instance.is_valid()) { - VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform()); - } + //erase body shapes + PhysicsServer::get_singleton()->body_clear_shapes(g.static_body); - for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) { + //erase body shapes debug + if (g.collision_debug.is_valid()) { - VS::get_singleton()->instance_set_transform(E->get().multimesh_instance, get_global_transform()); - //print_line("UPDATEPOS: "+get_global_transform()); + VS::get_singleton()->mesh_clear(g.collision_debug); } -} -void GridMap::_octant_clear_navmesh(const OctantKey &p_key) { - Octant &g = *octant_map[p_key]; + //erase navigation if (navigation) { for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) { - Octant::NavMesh *nvm = &E->get(); - if (nvm && nvm->id) { - navigation->navmesh_remove(E->get().id); - } + navigation->navmesh_remove(E->get().id); } g.navmesh_ids.clear(); } -} - -void GridMap::_octant_update(const OctantKey &p_key) { - ERR_FAIL_COND(!octant_map.has(p_key)); - Octant &g = *octant_map[p_key]; - if (!g.dirty) - return; - Ref<Mesh> mesh; + //erase multimeshes - _octant_clear_navmesh(p_key); - PhysicsServer::get_singleton()->body_clear_shapes(g.static_body); + for (int i = 0; i < g.multimesh_instances.size(); i++) { - if (g.collision_debug.is_valid()) { + VS::get_singleton()->free(g.multimesh_instances[i].instance); + VS::get_singleton()->free(g.multimesh_instances[i].multimesh); + } + g.multimesh_instances.clear(); - VS::get_singleton()->mesh_clear(g.collision_debug); + if (g.cells.size() == 0) { + //octant no longer needed + _octant_clean_up(p_key); + return true; } PoolVector<Vector3> col_debug; @@ -490,80 +392,111 @@ void GridMap::_octant_update(const OctantKey &p_key) { * set item's multimesh's instance count to number of cells which have this item * and set said multimesh bounding box to one containing all cells which have this item */ - for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) { - Octant::ItemInstances &ii = E->get(); + Map<int, List<Pair<Transform, IndexKey> > > multimesh_items; - ii.multimesh->set_instance_count(ii.cells.size()); + print_line("updating octant " + itos(p_key.x) + ", " + itos(p_key.y) + ", " + itos(p_key.z) + " cells: " + itos(g.cells.size())); - Rect3 aabb; - Rect3 mesh_aabb = ii.mesh.is_null() ? Rect3() : ii.mesh->get_aabb(); + for (Set<IndexKey>::Element *E = g.cells.front(); E; E = E->next()) { - Vector3 ofs(cell_size * 0.5 * int(center_x), cell_size * 0.5 * int(center_y), cell_size * 0.5 * int(center_z)); + ERR_CONTINUE(!cell_map.has(E->get())); + const Cell &c = cell_map[E->get()]; + + if (!theme.is_valid() || !theme->has_item(c.item)) + continue; //print_line("OCTANT, CELLS: "+itos(ii.cells.size())); - int idx = 0; - // foreach cell containing this item type - 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); + Vector3 cellpos = Vector3(E->get().x, E->get().y, E->get().z); + Vector3 ofs(cell_size.x * 0.5 * int(center_x), cell_size.y * 0.5 * int(center_y), cell_size.z * 0.5 * int(center_z)); - Transform xform; + Transform xform; - if (clip && ((clip_above && cellpos[clip_axis] > clip_floor) || (!clip_above && cellpos[clip_axis] < clip_floor))) { + if (clip && ((clip_above && cellpos[clip_axis] > clip_floor) || (!clip_above && cellpos[clip_axis] < clip_floor))) { - xform.basis.set_zero(); + } else { + } - } else { + xform.basis.set_orthogonal_index(c.rot); + xform.set_origin(cellpos * cell_size + ofs); + xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale)); - xform.basis.set_orthogonal_index(C->get().rot); + if (theme->get_item_mesh(c.item).is_valid()) { + if (!multimesh_items.has(c.item)) { + multimesh_items[c.item] = List<Pair<Transform, IndexKey> >(); } - xform.set_origin(cellpos * cell_size + ofs); - xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale)); + Pair<Transform, IndexKey> p; + p.first = xform; + p.second = E->get(); + multimesh_items[c.item].push_back(p); + } - 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)); - //print_line("MMINST: "+xform); + Vector<MeshLibrary::ShapeData> shapes = theme->get_item_shapes(c.item); + // add the item's shape at given xform to octant's static_body + for (int i = 0; i < shapes.size(); i++) { + // add the item's shape + if (!shapes[i].shape.is_valid()) + continue; + PhysicsServer::get_singleton()->body_add_shape(g.static_body, shapes[i].shape->get_rid(), xform * shapes[i].local_transform); + if (g.collision_debug.is_valid()) { + shapes[i].shape->add_vertices_to_array(col_debug, xform * shapes[i].local_transform); + } - if (idx == 0) { + //print_line("PHIS x: "+xform); + } - aabb = xform.xform(mesh_aabb); - } else { + // add the item's navmesh at given xform to GridMap's Navigation ancestor + Ref<NavigationMesh> navmesh = theme->get_item_navmesh(c.item); + if (navmesh.is_valid()) { + Octant::NavMesh nm; + nm.xform = xform; - aabb.merge_with(xform.xform(mesh_aabb)); + if (navigation) { + nm.id = navigation->navmesh_create(navmesh, xform, this); + } else { + nm.id = -1; } + g.navmesh_ids[E->get()] = nm; + } + } - // add the item's shape at given xform to octant's static_body - if (ii.shape.is_valid()) { - // add the item's shape - PhysicsServer::get_singleton()->body_add_shape(g.static_body, ii.shape->get_rid(), xform); - if (g.collision_debug.is_valid()) { - ii.shape->add_vertices_to_array(col_debug, xform); - } + //update multimeshes + for (Map<int, List<Pair<Transform, IndexKey> > >::Element *E = multimesh_items.front(); E; E = E->next()) { + print_line("multimesh item " + itos(E->key()) + " transforms " + itos(E->get().size())); + Octant::MultimeshInstance mmi; - //print_line("PHIS x: "+xform); - } + RID mm = VS::get_singleton()->multimesh_create(); + VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_NONE); + VS::get_singleton()->multimesh_set_mesh(mm, theme->get_item_mesh(E->key())->get_rid()); - // add the item's navmesh at given xform to GridMap's Navigation ancestor - if (navigation) { - if (ii.navmesh.is_valid()) { - int nm_id = navigation->navmesh_create(ii.navmesh, xform, this); - Octant::NavMesh nm; - nm.id = nm_id; - nm.xform = xform; - g.navmesh_ids[ik] = nm; - } - } + int idx = 0; + for (List<Pair<Transform, IndexKey> >::Element *F = E->get().front(); F; F = F->next()) { + VS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first); +#ifdef TOOLS_ENABLED + + Octant::MultimeshInstance::Item it; + it.index = idx; + it.transform = F->get().first; + it.key = F->get().second; + mmi.items.push_back(it); +#endif idx++; } - //ii.multimesh->set_aabb(aabb); + RID instance = VS::get_singleton()->instance_create(); + VS::get_singleton()->instance_set_base(instance, mm); + + if (is_inside_tree()) { + VS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario()); + VS::get_singleton()->instance_set_transform(instance, get_global_transform()); + } + + mmi.multimesh = mm; + mmi.instance = instance; + + g.multimesh_instances.push_back(mmi); } if (col_debug.size()) { @@ -580,6 +513,39 @@ void GridMap::_octant_update(const OctantKey &p_key) { } g.dirty = false; + + return false; +} + +void GridMap::_octant_enter_world(const OctantKey &p_key) { + + ERR_FAIL_COND(!octant_map.has(p_key)); + Octant &g = *octant_map[p_key]; + PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform()); + PhysicsServer::get_singleton()->body_set_space(g.static_body, get_world()->get_space()); + //print_line("BODYPOS: "+get_global_transform()); + + if (g.collision_debug_instance.is_valid()) { + VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario()); + VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform()); + } + + for (int i = 0; i < g.multimesh_instances.size(); i++) { + VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, get_world()->get_scenario()); + VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform()); + } + + if (navigation && theme.is_valid()) { + for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) { + + if (cell_map.has(F->key()) && F->get().id < 0) { + Ref<NavigationMesh> nm = theme->get_item_navmesh(cell_map[F->key()].item); + if (nm.is_valid()) { + F->get().id = navigation->navmesh_create(nm, F->get().xform, this); + } + } + } + } } void GridMap::_octant_exit_world(const OctantKey &p_key) { @@ -594,30 +560,73 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) { VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID()); } - for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) { + for (int i = 0; i < g.multimesh_instances.size(); i++) { + VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID()); + } + + if (navigation) { + for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) { - VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance, RID()); - //VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform()); + if (F->get().id >= 0) { + navigation->navmesh_remove(F->get().id); + F->get().id = -1; + } + } } } +void GridMap::_octant_clean_up(const OctantKey &p_key) { + + ERR_FAIL_COND(!octant_map.has(p_key)); + Octant &g = *octant_map[p_key]; + + if (g.collision_debug.is_valid()) + VS::get_singleton()->free(g.collision_debug); + if (g.collision_debug_instance.is_valid()) + VS::get_singleton()->free(g.collision_debug_instance); + + PhysicsServer::get_singleton()->free(g.static_body); + + //erase navigation + if (navigation) { + for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) { + navigation->navmesh_remove(E->get().id); + } + g.navmesh_ids.clear(); + } + + //erase multimeshes + + for (int i = 0; i < g.multimesh_instances.size(); i++) { + + VS::get_singleton()->free(g.multimesh_instances[i].instance); + VS::get_singleton()->free(g.multimesh_instances[i].multimesh); + } + g.multimesh_instances.clear(); +} + void GridMap::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_WORLD: { - for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - //IndexKey ik; - //ik.key = E->key().indexkey; - _octant_enter_world(E->key()); - _octant_update(E->key()); - } + Spatial *c = this; + while (c) { + navigation = Object::cast_to<Navigation>(c); + if (navigation) { + break; + } - awaiting_update = false; + c = Object::cast_to<Spatial>(c->get_parent()); + } last_transform = get_global_transform(); + for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { + _octant_enter_world(E->key()); + } + } break; case NOTIFICATION_TRANSFORM_CHANGED: { @@ -638,56 +647,23 @@ void GridMap::_notification(int p_what) { _octant_exit_world(E->key()); } - //_queue_dirty_map(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS); - //_update_dirty_map_callback(); - //_update_area_instances(); - - } break; - case NOTIFICATION_ENTER_TREE: { - - Spatial *c = this; - while (c) { - navigation = Object::cast_to<Navigation>(c); - if (navigation) { - break; - } - - c = Object::cast_to<Spatial>(c->get_parent()); - } - - if (navigation) { - for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - if (navigation) { - _octant_enter_tree(E->key()); - } - } - } - - _queue_dirty_map(); - } break; - case NOTIFICATION_EXIT_TREE: { - for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - if (navigation) { - _octant_clear_navmesh(E->key()); - } - } - navigation = NULL; + //_queue_octants_dirty(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS); + //_update_octants_callback(); + //_update_area_instances(); + } break; } } -void GridMap::_queue_dirty_map() { +void GridMap::_queue_octants_dirty() { if (awaiting_update) return; - if (is_inside_world()) { - - MessageQueue::get_singleton()->push_call(this, "_update_dirty_map_callback"); - awaiting_update = true; - } + MessageQueue::get_singleton()->push_call(this, "_update_octants_callback"); + awaiting_update = true; } void GridMap::_recreate_octant_data() { @@ -706,17 +682,7 @@ void GridMap::_clear_internal() { if (is_inside_world()) _octant_exit_world(E->key()); - for (Map<int, Octant::ItemInstances>::Element *F = E->get()->items.front(); F; F = F->next()) { - - VS::get_singleton()->free(F->get().multimesh_instance); - } - - if (E->get()->collision_debug.is_valid()) - VS::get_singleton()->free(E->get()->collision_debug); - if (E->get()->collision_debug_instance.is_valid()) - VS::get_singleton()->free(E->get()->collision_debug_instance); - - PhysicsServer::get_singleton()->free(E->get()->static_body); + _octant_clean_up(E->key()); memdelete(E->get()); } @@ -734,13 +700,23 @@ void GridMap::resource_changed(const RES &p_res) { _recreate_octant_data(); } -void GridMap::_update_dirty_map_callback() { +void GridMap::_update_octants_callback() { if (!awaiting_update) return; + List<OctantKey> to_delete; for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) { - _octant_update(E->key()); + + if (_octant_update(E->key())) { + to_delete.push_back(E->key()); + } + } + + while (to_delete.front()) { + memdelete(octant_map[to_delete.front()->get()]); + octant_map.erase(to_delete.front()->get()); + to_delete.pop_back(); } awaiting_update = false; @@ -762,7 +738,7 @@ void GridMap::_bind_methods() { ClassDB::bind_method(D_METHOD("get_cell_item_orientation", "x", "y", "z"), &GridMap::get_cell_item_orientation); //ClassDB::bind_method(D_METHOD("_recreate_octants"),&GridMap::_recreate_octants); - ClassDB::bind_method(D_METHOD("_update_dirty_map_callback"), &GridMap::_update_dirty_map_callback); + ClassDB::bind_method(D_METHOD("_update_octants_callback"), &GridMap::_update_octants_callback); ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &GridMap::resource_changed); ClassDB::bind_method(D_METHOD("set_center_x", "enable"), &GridMap::set_center_x); @@ -800,13 +776,13 @@ void GridMap::set_clip(bool p_enabled, bool p_clip_above, int p_floor, Vector3:: g->dirty = true; } awaiting_update = true; - _update_dirty_map_callback(); + _update_octants_callback(); } void GridMap::set_cell_scale(float p_scale) { cell_scale = p_scale; - _queue_dirty_map(); + _queue_octants_dirty(); } float GridMap::get_cell_scale() const { @@ -819,7 +795,7 @@ Array GridMap::get_meshes() { if (theme.is_null()) return Array(); - Vector3 ofs(cell_size * 0.5 * int(center_x), cell_size * 0.5 * int(center_y), cell_size * 0.5 * int(center_z)); + Vector3 ofs(cell_size.x * 0.5 * int(center_x), cell_size.y * 0.5 * int(center_y), cell_size.z * 0.5 * int(center_z)); Array meshes; for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) { @@ -851,7 +827,7 @@ Array GridMap::get_meshes() { GridMap::GridMap() { - cell_size = 2; + cell_size = Vector3(2, 2, 2); octant_size = 4; awaiting_update = false; _in_tree = false; diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 7af1e08eb2..9e1d250680 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -38,8 +38,6 @@ //heh heh, godotsphir!! this shares no code and the design is completely different with previous projects i've done.. //should scale better with hardware that supports instancing -class BakedLightInstance; - class GridMap : public Spatial { GDCLASS(GridMap, Spatial); @@ -96,21 +94,25 @@ class GridMap : public Spatial { Transform xform; }; - struct ItemInstances { - Set<IndexKey> cells; - Ref<Mesh> mesh; - Ref<Shape> shape; - Ref<MultiMesh> multimesh; - RID multimesh_instance; - Ref<NavigationMesh> navmesh; + struct MultimeshInstance { + RID instance; + RID multimesh; + struct Item { + int index; + Transform transform; + IndexKey key; + }; + + Vector<Item> items; //tools only, for changing visibility }; + Vector<MultimeshInstance> multimesh_instances; + Set<IndexKey> cells; RID collision_debug; RID collision_debug_instance; bool dirty; RID static_body; - Map<int, ItemInstances> items; Map<IndexKey, NavMesh> navmesh_ids; }; @@ -137,7 +139,7 @@ class GridMap : public Spatial { Transform last_transform; bool _in_tree; - float cell_size; + Vector3 cell_size; int octant_size; bool center_x, center_y, center_z; float cell_scale; @@ -169,15 +171,14 @@ class GridMap : public Spatial { } void _octant_enter_world(const OctantKey &p_key); - void _octant_enter_tree(const OctantKey &p_key); void _octant_exit_world(const OctantKey &p_key); - void _octant_update(const OctantKey &p_key); + bool _octant_update(const OctantKey &p_key); + void _octant_clean_up(const OctantKey &p_key); void _octant_transform(const OctantKey &p_key); - void _octant_clear_navmesh(const GridMap::OctantKey &); bool awaiting_update; - void _queue_dirty_map(); - void _update_dirty_map_callback(); + void _queue_octants_dirty(); + void _update_octants_callback(); void resource_changed(const RES &p_res); @@ -199,8 +200,8 @@ public: void set_theme(const Ref<MeshLibrary> &p_theme); Ref<MeshLibrary> get_theme() const; - void set_cell_size(float p_size); - float get_cell_size() const; + void set_cell_size(const Vector3 &p_size); + Vector3 get_cell_size() const; void set_octant_size(int p_size); int get_octant_size() const; @@ -229,4 +230,4 @@ public: ~GridMap(); }; -#endif // CUBE_GRID_MAP_H +#endif // GRID_MAP_H diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 3bab1bfbc1..6f0a13e07f 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -217,12 +217,15 @@ void GridMapEditor::_update_cursor_transform() { } void GridMapEditor::_update_selection_transform() { + Transform xf_zero; + xf_zero.basis.set_zero(); if (!selection.active) { - Transform xf; - xf.basis.set_zero(); - VisualServer::get_singleton()->instance_set_transform(selection_instance, xf); + VisualServer::get_singleton()->instance_set_transform(selection_instance, xf_zero); + for (int i = 0; i < 3; i++) { + VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero); + } return; } @@ -231,6 +234,27 @@ void GridMapEditor::_update_selection_transform() { xf.origin = selection.begin * node->get_cell_size(); VisualServer::get_singleton()->instance_set_transform(selection_instance, node->get_global_transform() * xf); + + for (int i = 0; i < 3; i++) { + if (i != edit_axis || (edit_floor[edit_axis] < selection.begin[edit_axis]) || (edit_floor[edit_axis] > selection.end[edit_axis] + 1)) { + VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero); + } else { + + Vector3 scale = (selection.end - selection.begin + Vector3(1, 1, 1)); + scale[edit_axis] = 1.0; + Vector3 pos = selection.begin; + pos[edit_axis] = edit_floor[edit_axis]; + + scale *= node->get_cell_size(); + pos *= node->get_cell_size(); + + Transform xf; + xf.basis.scale(scale); + xf.origin = pos; + + VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf); + } + } } void GridMapEditor::_validate_selection() { @@ -273,7 +297,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo Plane p; p.normal[edit_axis] = 1.0; - p.d = edit_floor[edit_axis] * node->get_cell_size(); + p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis]; Vector3 inters; if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_value(), &inters)) @@ -289,7 +313,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo } int cell[3]; - float cell_size[3] = { node->get_cell_size(), node->get_cell_size(), node->get_cell_size() }; + float cell_size[3] = { node->get_cell_size().x, node->get_cell_size().y, node->get_cell_size().z }; last_mouseover = Vector3(-1, -1, -1); @@ -299,7 +323,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo cell[i] = edit_floor[i]; else { - cell[i] = inters[i] / node->get_cell_size(); + cell[i] = inters[i] / node->get_cell_size()[i]; if (inters[i] < 0) cell[i] -= 1; //compensate negative grid_ofs[i] = cell[i] * cell_size[i]; @@ -717,6 +741,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) { //update grids indicator_mat.instance(); indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + indicator_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); indicator_mat->set_albedo(Color(0.8, 0.5, 0.1)); @@ -724,7 +749,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) { Vector<Vector3> grid_points[3]; Vector<Color> grid_colors[3]; - float cell_size[3] = { p_gridmap->get_cell_size(), p_gridmap->get_cell_size(), p_gridmap->get_cell_size() }; + float cell_size[3] = { p_gridmap->get_cell_size().x, p_gridmap->get_cell_size().y, p_gridmap->get_cell_size().z }; for (int i = 0; i < 3; i++) { @@ -788,7 +813,7 @@ void GridMapEditor::update_grid() { //VS *vs = VS::get_singleton(); - grid_ofs[edit_axis] = edit_floor[edit_axis] * node->get_cell_size(); + grid_ofs[edit_axis] = edit_floor[edit_axis] * node->get_cell_size()[edit_axis]; edit_grid_xform.origin = grid_ofs; edit_grid_xform.basis = Basis(); @@ -811,6 +836,7 @@ void GridMapEditor::_notification(int p_what) { grid[i] = VS::get_singleton()->mesh_create(); grid_instance[i] = VS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario()); + selection_level_instance[i] = VisualServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario()); } selection_instance = VisualServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario()); @@ -827,6 +853,7 @@ void GridMapEditor::_notification(int p_what) { VS::get_singleton()->free(grid[i]); grid_instance[i] = RID(); grid[i] = RID(); + VisualServer::get_singleton()->free(selection_level_instance[i]); } VisualServer::get_singleton()->free(selection_instance); @@ -858,7 +885,7 @@ void GridMapEditor::_notification(int p_what) { Plane p; p.normal[edit_axis] = 1.0; - p.d = edit_floor[edit_axis] * node->get_cell_size(); + p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis]; p = node->get_transform().xform(p); // plane to snap SpatialEditorPlugin *sep = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen()); @@ -906,6 +933,7 @@ void GridMapEditor::_floor_changed(float p_value) { node->set_meta("_editor_floor_", Vector3(edit_floor[0], edit_floor[1], edit_floor[2])); update_grid(); _update_clip(); + _update_selection_transform(); } void GridMapEditor::_bind_methods() { @@ -1047,6 +1075,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { PoolVector<Vector3> lines; PoolVector<Vector3> triangles; + PoolVector<Vector3> square[3]; for (int i = 0; i < 6; i++) { @@ -1086,12 +1115,41 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { lines.push_back(b); } + for (int i = 0; i < 3; i++) { + Vector3 points[4]; + for (int j = 0; j < 4; j++) { + + static const bool orderx[4] = { 0, 1, 1, 0 }; + static const bool ordery[4] = { 0, 0, 1, 1 }; + + Vector3 sp; + if (orderx[j]) { + sp[(i + 1) % 3] = 1.0; + } + if (ordery[j]) { + sp[(i + 2) % 3] = 1.0; + } + + points[j] = sp; + } + + for (int j = 0; j < 4; j++) { + + Vector3 ofs; + ofs[i] += 0.01; + square[i].push_back(points[j] - ofs); + square[i].push_back(points[(j + 1) % 4] - ofs); + square[i].push_back(points[j] + ofs); + square[i].push_back(points[(j + 1) % 4] + ofs); + } + } + Array d; d.resize(VS::ARRAY_MAX); inner_mat.instance(); - inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.3)); - inner_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true); + inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2)); + //inner_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true); inner_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); inner_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); @@ -1100,12 +1158,19 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid()); outer_mat.instance(); - outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.3)); + outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8)); outer_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true); outer_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); outer_mat->set_line_width(3.0); outer_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + selection_floor_mat.instance(); + selection_floor_mat->set_albedo(Color(0.80, 0.80, 1.0, 1)); + selection_floor_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true); + selection_floor_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + selection_floor_mat->set_line_width(3.0); + //selection_floor_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + d[VS::ARRAY_VERTEX] = lines; 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()); @@ -1117,6 +1182,13 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { d[VS::ARRAY_VERTEX] = lines; 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()); + + for (int i = 0; i < 3; i++) { + d[VS::ARRAY_VERTEX] = square[i]; + selection_level_mesh[i] = VS::get_singleton()->mesh_create(); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], VS::PRIMITIVE_LINES, d); + VisualServer::get_singleton()->mesh_surface_set_material(selection_level_mesh[i], 0, selection_floor_mat->get_rid()); + } } selection.active = false; @@ -1133,6 +1205,9 @@ GridMapEditor::~GridMapEditor() { VisualServer::get_singleton()->free(grid_instance[i]); if (cursor_instance.is_valid()) VisualServer::get_singleton()->free(cursor_instance); + if (selection_level_instance[i].is_valid()) { + VisualServer::get_singleton()->free(selection_level_instance[i]); + } } VisualServer::get_singleton()->free(selection_mesh); diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 6c7c0ab331..ecbfbf2d65 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -109,12 +109,15 @@ class GridMapEditor : public VBoxContainer { RID cursor_instance; RID selection_mesh; RID selection_instance; + RID selection_level_mesh[3]; + RID selection_level_instance[3]; RID duplicate_mesh; RID duplicate_instance; Ref<SpatialMaterial> indicator_mat; Ref<SpatialMaterial> inner_mat; Ref<SpatialMaterial> outer_mat; + Ref<SpatialMaterial> selection_floor_mat; bool updating; @@ -223,7 +226,7 @@ class GridMapEditorPlugin : public EditorPlugin { EditorNode *editor; public: - virtual bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return gridmap_editor->forward_spatial_input_event(p_camera, p_event); } + virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return gridmap_editor->forward_spatial_input_event(p_camera, p_event); } virtual String get_name() const { return "GridMap"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp index e4def9378f..e2f6b57c04 100644 --- a/modules/gridmap/register_types.cpp +++ b/modules/gridmap/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/gridmap/register_types.h b/modules/gridmap/register_types.h index 1978353fc3..c50f89155f 100644 --- a/modules/gridmap/register_types.h +++ b/modules/gridmap/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp index a3f0601043..d883b0f280 100644 --- a/modules/hdr/image_loader_hdr.cpp +++ b/modules/hdr/image_loader_hdr.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/hdr/image_loader_hdr.h b/modules/hdr/image_loader_hdr.h index 1e08e954e1..e6703dc142 100644 --- a/modules/hdr/image_loader_hdr.h +++ b/modules/hdr/image_loader_hdr.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/hdr/register_types.cpp b/modules/hdr/register_types.cpp index e4f7c14aa7..808b168432 100644 --- a/modules/hdr/register_types.cpp +++ b/modules/hdr/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/hdr/register_types.h b/modules/hdr/register_types.h index 3d901ea003..e453192d9c 100644 --- a/modules/hdr/register_types.h +++ b/modules/hdr/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp index 4f38e83274..57ec074bbb 100644 --- a/modules/jpg/image_loader_jpegd.cpp +++ b/modules/jpg/image_loader_jpegd.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/jpg/image_loader_jpegd.h b/modules/jpg/image_loader_jpegd.h index 917c0e1d95..6a2f042412 100644 --- a/modules/jpg/image_loader_jpegd.h +++ b/modules/jpg/image_loader_jpegd.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/jpg/register_types.cpp b/modules/jpg/register_types.cpp index 2379bee0df..85dee90eb0 100644 --- a/modules/jpg/register_types.cpp +++ b/modules/jpg/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/jpg/register_types.h b/modules/jpg/register_types.h index c14f860742..3d912a4398 100644 --- a/modules/jpg/register_types.h +++ b/modules/jpg/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/nativescript/api_generator.cpp b/modules/nativescript/api_generator.cpp index d9e78ba54a..4490197bdb 100644 --- a/modules/nativescript/api_generator.cpp +++ b/modules/nativescript/api_generator.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/nativescript/api_generator.h b/modules/nativescript/api_generator.h index a108d7a7b6..56c2d786e6 100644 --- a/modules/nativescript/api_generator.h +++ b/modules/nativescript/api_generator.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/nativescript/godot_nativescript.cpp b/modules/nativescript/godot_nativescript.cpp index 453cee3a18..926b3261b2 100644 --- a/modules/nativescript/godot_nativescript.cpp +++ b/modules/nativescript/godot_nativescript.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/nativescript/godot_nativescript.h b/modules/nativescript/godot_nativescript.h index cfd445086b..1eaf459570 100644 --- a/modules/nativescript/godot_nativescript.h +++ b/modules/nativescript/godot_nativescript.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp index b495c7bf4d..3799ce31f8 100644 --- a/modules/nativescript/nativescript.cpp +++ b/modules/nativescript/nativescript.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/nativescript/nativescript.h b/modules/nativescript/nativescript.h index b62fefec40..571a3c9cc7 100644 --- a/modules/nativescript/nativescript.h +++ b/modules/nativescript/nativescript.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/nativescript/register_types.cpp b/modules/nativescript/register_types.cpp index c28b982884..b846710ab8 100644 --- a/modules/nativescript/register_types.cpp +++ b/modules/nativescript/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/nativescript/register_types.h b/modules/nativescript/register_types.h index 319da9c42f..7ac558f68f 100644 --- a/modules/nativescript/register_types.h +++ b/modules/nativescript/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/ogg/register_types.cpp b/modules/ogg/register_types.cpp index 9837ae12d9..452e6e332a 100644 --- a/modules/ogg/register_types.cpp +++ b/modules/ogg/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/ogg/register_types.h b/modules/ogg/register_types.h index dc84227b80..a2a8b7cedc 100644 --- a/modules/ogg/register_types.h +++ b/modules/ogg/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/openssl/register_types.cpp b/modules/openssl/register_types.cpp index e1ae581caf..16563aabf7 100644 --- a/modules/openssl/register_types.cpp +++ b/modules/openssl/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/openssl/register_types.h b/modules/openssl/register_types.h index ff39ec8798..58f2d55c98 100644 --- a/modules/openssl/register_types.h +++ b/modules/openssl/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/openssl/stream_peer_openssl.cpp b/modules/openssl/stream_peer_openssl.cpp index 8c5e6f83c3..d40bf73883 100644 --- a/modules/openssl/stream_peer_openssl.cpp +++ b/modules/openssl/stream_peer_openssl.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,15 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "stream_peer_openssl.h" -//hostname matching code from curl -//#include <openssl/applink.c> // To prevent crashing (see the OpenSSL FAQ) +//hostname matching code from curl bool StreamPeerOpenSSL::_match_host_name(const char *name, const char *hostname) { return Tool_Curl_cert_hostcheck(name, hostname) == CURL_HOST_MATCH; - //print_line("MATCH: "+String(name)+" vs "+String(hostname)); - //return true; } Error StreamPeerOpenSSL::_match_common_name(const char *hostname, const X509 *server_cert) { @@ -298,20 +295,6 @@ Error StreamPeerOpenSSL::connect_to_stream(Ref<StreamPeer> p_base, bool p_valida X509_STORE_add_cert(store, certs[i]); } -#if 0 - const unsigned char *in=(const unsigned char *)certs.ptr(); - X509 *Cert = d2i_X509(NULL, &in, certs.size()-1); - if (!Cert) { - print_line(String(ERR_error_string(ERR_get_error(),NULL))); - } - ERR_FAIL_COND_V(!Cert,ERR_PARSE_ERROR); - - X509_STORE *store = SSL_CTX_get_cert_store(ctx); - X509_STORE_add_cert(store,Cert); - - //char *str = X509_NAME_oneline(X509_get_subject_name(Cert),0,0); - //printf ("subject: %s\n", str); /* [1] */ -#endif } //used for testing diff --git a/modules/openssl/stream_peer_openssl.h b/modules/openssl/stream_peer_openssl.h index b1da5e1d95..1e445ef681 100644 --- a/modules/openssl/stream_peer_openssl.h +++ b/modules/openssl/stream_peer_openssl.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/opus/audio_stream_opus.cpp b/modules/opus/audio_stream_opus.cpp index e361ebf019..1dac890eb8 100644 --- a/modules/opus/audio_stream_opus.cpp +++ b/modules/opus/audio_stream_opus.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/opus/audio_stream_opus.h b/modules/opus/audio_stream_opus.h index daf3958c2a..ccfe04e84e 100644 --- a/modules/opus/audio_stream_opus.h +++ b/modules/opus/audio_stream_opus.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/opus/register_types.cpp b/modules/opus/register_types.cpp index e8bff58cbb..a69c8bf9f3 100644 --- a/modules/opus/register_types.cpp +++ b/modules/opus/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/opus/register_types.h b/modules/opus/register_types.h index 4517dc5df7..1865b7966e 100644 --- a/modules/opus/register_types.h +++ b/modules/opus/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/pbm/bitmap_loader_pbm.cpp b/modules/pbm/bitmap_loader_pbm.cpp index 93dedbd05f..d222935970 100644 --- a/modules/pbm/bitmap_loader_pbm.cpp +++ b/modules/pbm/bitmap_loader_pbm.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/pbm/bitmap_loader_pbm.h b/modules/pbm/bitmap_loader_pbm.h index 7a72edaeee..85d3eadcb9 100644 --- a/modules/pbm/bitmap_loader_pbm.h +++ b/modules/pbm/bitmap_loader_pbm.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/pbm/register_types.cpp b/modules/pbm/register_types.cpp index c9531ba14f..60401b8cc9 100644 --- a/modules/pbm/register_types.cpp +++ b/modules/pbm/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/pbm/register_types.h b/modules/pbm/register_types.h index 3888fd6f77..b75eff55d3 100644 --- a/modules/pbm/register_types.h +++ b/modules/pbm/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/pvr/register_types.cpp b/modules/pvr/register_types.cpp index 04e20558ce..8fb78d7734 100644 --- a/modules/pvr/register_types.cpp +++ b/modules/pvr/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/pvr/register_types.h b/modules/pvr/register_types.h index 7ff5237c03..4db8219b21 100644 --- a/modules/pvr/register_types.h +++ b/modules/pvr/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index bdd4779e28..9989785c70 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/pvr/texture_loader_pvr.h b/modules/pvr/texture_loader_pvr.h index 7d60831175..a51160d902 100644 --- a/modules/pvr/texture_loader_pvr.h +++ b/modules/pvr/texture_loader_pvr.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index c728657d6b..de0a6b7e21 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/regex/regex.h b/modules/regex/regex.h index 106d2649a5..8c76035b82 100644 --- a/modules/regex/regex.h +++ b/modules/regex/regex.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/regex/register_types.cpp b/modules/regex/register_types.cpp index eaa8f41e33..7b042aaa52 100644 --- a/modules/regex/register_types.cpp +++ b/modules/regex/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/regex/register_types.h b/modules/regex/register_types.h index 3b977edd32..1624fe18c8 100644 --- a/modules/regex/register_types.h +++ b/modules/regex/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/register_module_types.h b/modules/register_module_types.h index e30dab2819..089055ffa0 100644 --- a/modules/register_module_types.h +++ b/modules/register_module_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp index efce76c805..29073a8499 100644 --- a/modules/squish/image_compress_squish.cpp +++ b/modules/squish/image_compress_squish.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/squish/image_compress_squish.h b/modules/squish/image_compress_squish.h index 68aaeefc30..0dff5a7ce3 100644 --- a/modules/squish/image_compress_squish.h +++ b/modules/squish/image_compress_squish.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/squish/register_types.cpp b/modules/squish/register_types.cpp index 2eeea59836..d5aa1d4b71 100644 --- a/modules/squish/register_types.cpp +++ b/modules/squish/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/squish/register_types.h b/modules/squish/register_types.h index 3bf1b19dec..0afeeeff3b 100644 --- a/modules/squish/register_types.h +++ b/modules/squish/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp index 5ad16c7337..49d959203c 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h index 56bfe398c0..a459e6f31d 100644 --- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h +++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/stb_vorbis/register_types.cpp b/modules/stb_vorbis/register_types.cpp index 726260b45c..abd01e9a14 100644 --- a/modules/stb_vorbis/register_types.cpp +++ b/modules/stb_vorbis/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/stb_vorbis/register_types.h b/modules/stb_vorbis/register_types.h index c17e1eafe9..8e2d5e78f8 100644 --- a/modules/stb_vorbis/register_types.h +++ b/modules/stb_vorbis/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp index 5a1157bf9c..4d28dc027b 100644 --- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp +++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.h b/modules/stb_vorbis/resource_importer_ogg_vorbis.h index c588b58fb2..8134009704 100644 --- a/modules/stb_vorbis/resource_importer_ogg_vorbis.h +++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/svg/SCsub b/modules/svg/SCsub index 0d3a347b7e..5be9367808 100644 --- a/modules/svg/SCsub +++ b/modules/svg/SCsub @@ -1,9 +1,10 @@ #!/usr/bin/env python Import('env') +from compat import isbasestring # Thirdparty source files -thirdparty_dir = "#thirdparty/nanosvg/src/" +thirdparty_dir = "#thirdparty/nanosvg/" thirdparty_sources = [ "nanosvg.cc" ] @@ -18,7 +19,7 @@ lib = env.Library("svg_builtin", thirdparty_sources) # and then plain strings for system library. We insert between the two. inserted = False for idx, linklib in enumerate(env["LIBS"]): - if isinstance(linklib, basestring): # first system lib such as "X11", otherwise SCons lib object + if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object env["LIBS"].insert(idx, lib) inserted = True break @@ -31,4 +32,4 @@ env.Append(CCFLAGS=["-DSVG_ENABLED"]) # Godot's own source files env.add_source_files(env.modules_sources, "*.cpp") -Export('env')
\ No newline at end of file +Export('env') diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index c74188d9ea..086cc202f9 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h index d93e1e3d62..1f2ec3c1c2 100644 --- a/modules/svg/image_loader_svg.h +++ b/modules/svg/image_loader_svg.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp index e0f967ca06..e37239f27a 100644 --- a/modules/svg/register_types.cpp +++ b/modules/svg/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/svg/register_types.h b/modules/svg/register_types.h index 920b724623..49d550e7c9 100644 --- a/modules/svg/register_types.h +++ b/modules/svg/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp index 2329d0bcc2..379c894550 100644 --- a/modules/tga/image_loader_tga.cpp +++ b/modules/tga/image_loader_tga.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/tga/image_loader_tga.h b/modules/tga/image_loader_tga.h index f42a3f7e75..8689a1773b 100644 --- a/modules/tga/image_loader_tga.h +++ b/modules/tga/image_loader_tga.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/tga/register_types.cpp b/modules/tga/register_types.cpp index 6e120fa3bf..814b21d368 100644 --- a/modules/tga/register_types.cpp +++ b/modules/tga/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/tga/register_types.h b/modules/tga/register_types.h index 079b7bf291..10812981f8 100644 --- a/modules/tga/register_types.h +++ b/modules/tga/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/theora/register_types.cpp b/modules/theora/register_types.cpp index 1bea5439a3..ae6961b3da 100644 --- a/modules/theora/register_types.cpp +++ b/modules/theora/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/theora/register_types.h b/modules/theora/register_types.h index cb9f9d1848..7011ee44d0 100644 --- a/modules/theora/register_types.h +++ b/modules/theora/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index a83d3ead0e..2a24f8d4d1 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -83,37 +83,6 @@ void VideoStreamPlaybackTheora::video_write(void) { th_ycbcr_buffer yuv; th_decode_ycbcr_out(td, yuv); - // FIXME: The way stuff is commented out with `//*/` closing comments - // sounds very fishy... - - /* - int y_offset, uv_offset; - y_offset=(ti.pic_x&~1)+yuv[0].stride*(ti.pic_y&~1); - - { - int pixels = size.x * size.y; - frame_data.resize(pixels * 4); - PoolVector<uint8_t>::Write w = frame_data.write(); - char* dst = (char*)w.ptr(); - int p = 0; - for (int i=0; i<size.y; i++) { - - char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i; - char *out = dst + (int)size.x * 4 * i; - for (int j=0;j<size.x;j++) { - - dst[p++] = in_y[j]; - dst[p++] = in_y[j]; - dst[p++] = in_y[j]; - dst[p++] = 255; - }; - } - format = Image::FORMAT_RGBA8; - } - //*/ - - //* - int pitch = 4; frame_data.resize(size.x * size.y * pitch); { @@ -142,99 +111,6 @@ void VideoStreamPlaybackTheora::video_write(void) { texture->set_data(img); //zero copy send to visual server - /* - - if (px_fmt == TH_PF_444) { - - int pitch = 3; - frame_data.resize(size.x * size.y * pitch); - PoolVector<uint8_t>::Write w = frame_data.write(); - char* dst = (char*)w.ptr(); - - for(int i=0;i<size.y;i++) { - - char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i; - char *out = dst + (int)size.x * pitch * i; - char *in_u = (char *)yuv[1].data+uv_offset+yuv[1].stride*i; - char *in_v = (char *)yuv[2].data+uv_offset+yuv[2].stride*i; - for (int j=0;j<size.x;j++) { - - out[j*3+0] = in_y[j]; - out[j*3+1] = in_u[j]; - out[j*3+2] = in_v[j]; - }; - } - - format = Image::FORMAT_YUV_444; - - } else { - - int div; - if (px_fmt!=TH_PF_422) { - div = 2; - } - - bool rgba = true; - if (rgba) { - - int pitch = 4; - frame_data.resize(size.x * size.y * pitch); - PoolVector<uint8_t>::Write w = frame_data.write(); - char* dst = (char*)w.ptr(); - - uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div); - for(int i=0;i<size.y;i++) { - char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i; - char *in_u = (char *)yuv[1].data+uv_offset+yuv[1].stride*(i/div); - char *in_v = (char *)yuv[2].data+uv_offset+yuv[2].stride*(i/div); - uint8_t *out = (uint8_t*)dst + (int)size.x * pitch * i; - int ofs = 0; - for (int j=0;j<size.x;j++) { - - uint8_t y, u, v; - y = in_y[j]; - u = in_u[j/2]; - v = in_v[j/2]; - - int32_t r = Math::fast_ftoi(1.164 * (y - 16) + 1.596 * (v - 128)); - int32_t g = Math::fast_ftoi(1.164 * (y - 16) - 0.813 * (v - 128) - 0.391 * (u - 128)); - int32_t b = Math::fast_ftoi(1.164 * (y - 16) + 2.018 * (u - 128)); - - out[ofs++] = CLAMP(r, 0, 255); - out[ofs++] = CLAMP(g, 0, 255); - out[ofs++] = CLAMP(b, 0, 255); - out[ofs++] = 255; - } - } - - format = Image::FORMAT_RGBA8; - - } else { - - int pitch = 2; - frame_data.resize(size.x * size.y * pitch); - PoolVector<uint8_t>::Write w = frame_data.write(); - char* dst = (char*)w.ptr(); - - uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div); - for(int i=0;i<size.y;i++) { - char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i; - char *out = dst + (int)size.x * pitch * i; - for (int j=0;j<size.x;j++) - out[j*2] = in_y[j]; - char *in_u = (char *)yuv[1].data+uv_offset+yuv[1].stride*(i/div); - char *in_v = (char *)yuv[2].data+uv_offset+yuv[2].stride*(i/div); - for (int j=0;j<(int)size.x>>1;j++) { - out[j*4+1] = in_u[j]; - out[j*4+3] = in_v[j]; - } - } - - format = Image::FORMAT_YUV_422; - }; - }; - //*/ - frames_pending = 1; } @@ -455,15 +331,6 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) { th_decode_ctl(td, TH_DECCTL_SET_PPLEVEL, &pp_level, sizeof(pp_level)); pp_inc = 0; - /*{ - int arg = 0xffff; - th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_MBMODE,&arg,sizeof(arg)); - th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_MV,&arg,sizeof(arg)); - th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_QI,&arg,sizeof(arg)); - arg=10; - th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_BITS,&arg,sizeof(arg)); - }*/ - int w; int h; w = (ti.pic_x + ti.frame_width + 1 & ~1) - (ti.pic_x & ~1); @@ -502,8 +369,6 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) { float VideoStreamPlaybackTheora::get_time() const { - //print_line("total: "+itos(get_total())+" todo: "+itos(get_todo())); - //return MAX(0,time-((get_total())/(float)vi.rate)); return time - AudioServer::get_singleton()->get_output_delay() - delay_compensation; //-((get_total())/(float)vi.rate); }; @@ -526,8 +391,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) { thread_sem->post(); #endif - //double ctime =AudioServer::get_singleton()->get_mix_time(); - //print_line("play "+rtos(p_delta)); time += p_delta; @@ -663,8 +526,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) { } } -//print_line("no theora: "+itos(no_theora)+" theora eos: "+itos(theora_eos)+" frame done "+itos(frame_done)); - #ifdef THEORA_USE_THREAD_STREAMING if (file && thread_eof && no_theora && theora_eos && ring_buffer.data_left() == 0) { #else @@ -674,16 +535,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) { stop(); return; }; -#if 0 - if (!videobuf_ready || audio_todo > 0){ - /* no data yet for somebody. Grab another page */ - - buffer_data(); - while(ogg_sync_pageout(&oy,&og)>0){ - queue_page(&og); - } - } -#else if (!frame_done || !audio_done) { //what's the point of waiting for audio to grab a page? @@ -693,7 +544,7 @@ void VideoStreamPlaybackTheora::update(float p_delta) { queue_page(&og); } } -#endif + /* If playback has begun, top audio buffer off immediately. */ //if(stateflag) audio_write_nonblocking(); diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h index 84b665382b..f04e49c662 100644 --- a/modules/theora/video_stream_theora.h +++ b/modules/theora/video_stream_theora.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp index 18d453a717..57826d69fb 100644 --- a/modules/tinyexr/image_loader_tinyexr.cpp +++ b/modules/tinyexr/image_loader_tinyexr.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/tinyexr/image_loader_tinyexr.h b/modules/tinyexr/image_loader_tinyexr.h index f9636a303e..adecba5d9d 100644 --- a/modules/tinyexr/image_loader_tinyexr.h +++ b/modules/tinyexr/image_loader_tinyexr.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/tinyexr/register_types.cpp b/modules/tinyexr/register_types.cpp index 73f3131276..4bbafbc90a 100644 --- a/modules/tinyexr/register_types.cpp +++ b/modules/tinyexr/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/tinyexr/register_types.h b/modules/tinyexr/register_types.h index f3c7372359..e866bb7624 100644 --- a/modules/tinyexr/register_types.h +++ b/modules/tinyexr/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp index a54d306aff..c50ba17c35 100644 --- a/modules/visual_script/register_types.cpp +++ b/modules/visual_script/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/register_types.h b/modules/visual_script/register_types.h index 2c0ee56268..4fb03bc227 100644 --- a/modules/visual_script/register_types.h +++ b/modules/visual_script/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 6b69ffdf8d..88012d2031 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index b61b67a890..b2e7a6aa27 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 9cbd70d4ca..2c8796820e 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h index 8e9c0eca76..97ab307039 100644 --- a/modules/visual_script/visual_script_builtin_funcs.h +++ b/modules/visual_script/visual_script_builtin_funcs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index e93d6ec4d1..7ab2a93b55 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index e68711a036..dd051ef8e4 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index 25c2ebd6d2..6bd052fe26 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h index 4a9f59ebc3..2636e79842 100644 --- a/modules/visual_script/visual_script_expression.h +++ b/modules/visual_script/visual_script_expression.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index 77f3111d94..59d9540239 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h index d27fd47f84..380eb76c45 100644 --- a/modules/visual_script/visual_script_flow_control.h +++ b/modules/visual_script/visual_script_flow_control.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index b51ef6beef..5fcc5b0ad9 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h index 3b38d0d08f..a9a0bd083f 100644 --- a/modules/visual_script/visual_script_func_nodes.h +++ b/modules/visual_script/visual_script_func_nodes.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index 5e74c970e3..af7b334e46 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h index b5df761e7d..694fb96cfa 100644 --- a/modules/visual_script/visual_script_nodes.h +++ b/modules/visual_script/visual_script_nodes.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp index 08adc13193..4b8e17421b 100644 --- a/modules/visual_script/visual_script_yield_nodes.cpp +++ b/modules/visual_script/visual_script_yield_nodes.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/visual_script/visual_script_yield_nodes.h b/modules/visual_script/visual_script_yield_nodes.h index 638b7b5b41..d074962471 100644 --- a/modules/visual_script/visual_script_yield_nodes.h +++ b/modules/visual_script/visual_script_yield_nodes.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp index 1b10637fdc..6389c286c2 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/vorbis/audio_stream_ogg_vorbis.h b/modules/vorbis/audio_stream_ogg_vorbis.h index 519ceaaea1..03b3726b52 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.h +++ b/modules/vorbis/audio_stream_ogg_vorbis.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/vorbis/register_types.cpp b/modules/vorbis/register_types.cpp index d9865072b9..270a58e7fe 100644 --- a/modules/vorbis/register_types.cpp +++ b/modules/vorbis/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/vorbis/register_types.h b/modules/vorbis/register_types.h index e7cde7a66c..db317e9f6a 100644 --- a/modules/vorbis/register_types.h +++ b/modules/vorbis/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/webm/register_types.cpp b/modules/webm/register_types.cpp index c234f81097..892d1b8420 100644 --- a/modules/webm/register_types.cpp +++ b/modules/webm/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/webm/register_types.h b/modules/webm/register_types.h index cf412e601e..94ff7de739 100644 --- a/modules/webm/register_types.h +++ b/modules/webm/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 72f10b4f45..26344877de 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h index b2e88347aa..a48a6c6b9a 100644 --- a/modules/webm/video_stream_webm.h +++ b/modules/webm/video_stream_webm.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp index 4ffcdefbe9..8fe2db9e27 100644 --- a/modules/webp/image_loader_webp.cpp +++ b/modules/webp/image_loader_webp.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/webp/image_loader_webp.h b/modules/webp/image_loader_webp.h index b8c5933512..f7ef210458 100644 --- a/modules/webp/image_loader_webp.h +++ b/modules/webp/image_loader_webp.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/webp/register_types.cpp b/modules/webp/register_types.cpp index 6e29986740..95e5cd105d 100644 --- a/modules/webp/register_types.cpp +++ b/modules/webp/register_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/modules/webp/register_types.h b/modules/webp/register_types.h index d0aa148079..7ec926c572 100644 --- a/modules/webp/register_types.h +++ b/modules/webp/register_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/SCsub b/platform/android/SCsub index b124a1a5a8..87e7ee4747 100644 --- a/platform/android/SCsub +++ b/platform/android/SCsub @@ -1,6 +1,7 @@ #!/usr/bin/env python import shutil +from compat import open_utf8 Import('env') @@ -40,8 +41,8 @@ prog = None abspath = env.Dir(".").abspath -gradle_basein = open(abspath + "/build.gradle.template", "rb") -gradle_baseout = open(abspath + "/java/build.gradle", "wb") +gradle_basein = open_utf8(abspath + "/build.gradle.template", "r") +gradle_baseout = open_utf8(abspath + "/java/build.gradle", "w") gradle_text = gradle_basein.read() @@ -124,8 +125,8 @@ gradle_baseout.write(gradle_text) gradle_baseout.close() -pp_basein = open(abspath + "/AndroidManifest.xml.template", "rb") -pp_baseout = open(abspath + "/java/AndroidManifest.xml", "wb") +pp_basein = open_utf8(abspath + "/AndroidManifest.xml.template", "r") +pp_baseout = open_utf8(abspath + "/java/AndroidManifest.xml", "w") manifest = pp_basein.read() manifest = manifest.replace("$$ADD_APPLICATION_CHUNKS$$", env.android_manifest_chunk) manifest = manifest.replace("$$ADD_PERMISSION_CHUNKS$$", env.android_permission_chunk) @@ -146,7 +147,7 @@ elif env['android_arch'] == 'arm64v8': elif env['android_arch'] == 'x86': lib_arch_dir = 'x86' else: - print 'WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin' + print('WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin') if lib_arch_dir != '': if env['target'] == 'release': diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp index ec09fda429..4a3bdd877d 100644 --- a/platform/android/audio_driver_jandroid.cpp +++ b/platform/android/audio_driver_jandroid.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/audio_driver_jandroid.h b/platform/android/audio_driver_jandroid.h index 3697ca6f21..8135641a62 100644 --- a/platform/android/audio_driver_jandroid.h +++ b/platform/android/audio_driver_jandroid.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/audio_driver_opensl.cpp b/platform/android/audio_driver_opensl.cpp index acd94d2bdd..e774f5bb7d 100644 --- a/platform/android/audio_driver_opensl.cpp +++ b/platform/android/audio_driver_opensl.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -75,29 +75,10 @@ void AudioDriverOpenSL::_buffer_callback( } (*queueItf)->Enqueue(queueItf, ptr, 4 * buffer_size); - -#if 0 - SLresult res; - CallbackCntxt *pCntxt = (CallbackCntxt*)pContext; - if(pCntxt->pData < (pCntxt->pDataBase + pCntxt->size)) - { - res = (*queueItf)->Enqueue(queueItf, (void*) pCntxt->pData, - 2 * AUDIO_DATA_BUFFER_SIZE, SL_BOOLEAN_FALSE); /* Size given - in bytes. */ - CheckErr(res); - /* Increase data pointer by buffer size */ - pCntxt->pData += AUDIO_DATA_BUFFER_SIZE; - } - } -#endif } void AudioDriverOpenSL::_buffer_callbacks( SLAndroidSimpleBufferQueueItf queueItf, - /*SLuint32 eventFlags, - const void * pBuffer, - SLuint32 bufferSize, - SLuint32 dataUsed,*/ void *pContext) { AudioDriverOpenSL *ad = (AudioDriverOpenSL *)pContext; @@ -113,65 +94,6 @@ const char *AudioDriverOpenSL::get_name() const { return "Android"; } -#if 0 -int AudioDriverOpenSL::thread_func(SceSize args, void *argp) { - - AudioDriverOpenSL* ad = s_ad; - sceAudioOutput2Reserve(AUDIO_OUTPUT_SAMPLE); - - int half=0; - while(!ad->exit_thread) { - - int16_t *ptr = &ad->outbuff[AUDIO_OUTPUT_SAMPLE*2*half]; - - - - if (!ad->active) { - - for(int i=0;i<AUDIO_OUTPUT_SAMPLE*2;i++) { - ptr[i]=0; - } - - } else { - - //printf("samples: %i\n",AUDIO_OUTPUT_SAMPLE); - ad->lock(); - - ad->audio_server_process(AUDIO_OUTPUT_SAMPLE,ad->outbuff_32); - - ad->unlock(); - - const int32_t* src_buff=ad->outbuff_32; - - for(int i=0;i<AUDIO_OUTPUT_SAMPLE*2;i++) { - - ptr[i]=src_buff[i]>>16; - } - } - - - /* Output 16-bit PCM STEREO data that is in pcmBuf without changing the volume */ - sceAudioOutput2OutputBlocking( - SCE_AUDIO_VOLUME_0dB*3, //0db at 0x8000, that's obvious - ptr - ); - - if (half) - half=0; - else - half=1; - - } - - sceAudioOutput2Release(); - - sceKernelExitThread(SCE_KERNEL_EXIT_SUCCESS); - ad->thread_exited=true; - return SCE_KERNEL_EXIT_SUCCESS; - -} - -#endif Error AudioDriverOpenSL::init() { SLresult @@ -228,29 +150,12 @@ void AudioDriverOpenSL::start() { SLboolean required[MAX_NUMBER_INTERFACES]; SLInterfaceID iidArray[MAX_NUMBER_INTERFACES]; -#if 0 - - for (int i=0; i<MAX_NUMBER_INTERFACES; i++) - { - required[i] = SL_BOOLEAN_FALSE; - iidArray[i] = SL_IID_NULL; - } - // Set arrays required[] and iidArray[] for VOLUME interface - required[0] = SL_BOOLEAN_TRUE; - iidArray[0] = SL_IID_VOLUME; - - // Create Output Mix object to be used by player - res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 1, - iidArray, required); -#else - { const SLInterfaceID ids[1] = { SL_IID_ENVIRONMENTALREVERB }; const SLboolean req[1] = { SL_BOOLEAN_FALSE }; res = (*EngineItf)->CreateOutputMix(EngineItf, &OutputMix, 0, ids, req); } -#endif ERR_FAIL_COND(res != SL_RESULT_SUCCESS); // Realizing the Output Mix object in synchronous mode. res = (*OutputMix)->Realize(OutputMix, SL_BOOLEAN_FALSE); @@ -308,44 +213,18 @@ void AudioDriverOpenSL::start() { /* Setup to receive buffer queue event callbacks */ res = (*bufferQueueItf)->RegisterCallback(bufferQueueItf, _buffer_callbacks, this); ERR_FAIL_COND(res != SL_RESULT_SUCCESS); -/* Before we start set volume to -3dB (-300mB) */ -#if 0 - res = (*OutputMix)->GetInterface(OutputMix, SL_IID_VOLUME, - (void*)&volumeItf); - ERR_FAIL_COND( res !=SL_RESULT_SUCCESS ); - /* Setup the data source structure for the buffer queue */ - - res = (*volumeItf)->SetVolumeLevel(volumeItf, -300); - ERR_FAIL_COND( res !=SL_RESULT_SUCCESS ); -#endif + last_free = 0; -#if 1 + //fill up buffers for (int i = 0; i < BUFFER_COUNT; i++) { /* Enqueue a few buffers to get the ball rolling */ res = (*bufferQueueItf)->Enqueue(bufferQueueItf, buffers[i], 4 * buffer_size); /* Size given in */ } -#endif res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_PLAYING); ERR_FAIL_COND(res != SL_RESULT_SUCCESS); -#if 0 - res = (*bufferQueueItf)->GetState(bufferQueueItf, &state); - ERR_FAIL_COND( res !=SL_RESULT_SUCCESS ); - while(state.count) - { - (*bufferQueueItf)->GetState(bufferQueueItf, &state); - } - /* Make sure player is stopped */ - res = (*playItf)->SetPlayState(playItf, SL_PLAYSTATE_STOPPED); - CheckErr(res); - /* Destroy the player */ - (*player)->Destroy(player); - /* Destroy Output Mix object */ - (*OutputMix)->Destroy(OutputMix); -#endif - active = true; } diff --git a/platform/android/audio_driver_opensl.h b/platform/android/audio_driver_opensl.h index f6270a3084..b505c5fe8a 100644 --- a/platform/android/audio_driver_opensl.h +++ b/platform/android/audio_driver_opensl.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/detect.py b/platform/android/detect.py index ad5bfb4949..65442bf6f8 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -14,7 +14,7 @@ def get_name(): def can_build(): - return (os.environ.has_key("ANDROID_NDK_ROOT")) + return ("ANDROID_NDK_ROOT" in os.environ) def get_opts(): @@ -55,7 +55,7 @@ def configure(env): import subprocess def mySubProcess(cmdline, env): - # print "SPAWNED : " + cmdline + # print("SPAWNED : " + cmdline) startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, @@ -63,9 +63,9 @@ def configure(env): data, err = proc.communicate() rv = proc.wait() if rv: - print "=====" - print err - print "=====" + print("=====") + print(err) + print("=====") return rv def mySpawn(sh, escape, cmd, args, env): @@ -183,8 +183,8 @@ def configure(env): ## Compile flags env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"]) - env.Append(CPPFLAGS=string.split('-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing')) - env.Append(CPPFLAGS=string.split('-DNO_STATVFS -DGLES2_ENABLED')) + env.Append(CPPFLAGS='-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing'.split()) + env.Append(CPPFLAGS='-DNO_STATVFS -DGLES2_ENABLED'.split()) env['neon_enabled'] = False if env['android_arch'] == 'x86': @@ -194,11 +194,11 @@ def configure(env): elif env["android_arch"] == "armv6": target_opts = ['-target', 'armv6-none-linux-androideabi'] - env.Append(CPPFLAGS=string.split('-D__ARM_ARCH_6__ -march=armv6 -mfpu=vfp -mfloat-abi=softfp')) + env.Append(CPPFLAGS='-D__ARM_ARCH_6__ -march=armv6 -mfpu=vfp -mfloat-abi=softfp'.split()) elif env["android_arch"] == "armv7": target_opts = ['-target', 'armv7-none-linux-androideabi'] - env.Append(CPPFLAGS=string.split('-D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -march=armv7-a -mfloat-abi=softfp')) + env.Append(CPPFLAGS='-D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -march=armv7-a -mfloat-abi=softfp'.split()) if env['android_neon'] == 'yes': env['neon_enabled'] = True env.Append(CPPFLAGS=['-mfpu=neon', '-D__ARM_NEON__']) @@ -225,9 +225,9 @@ def configure(env): env['LINKFLAGS'] = ['-shared', '--sysroot=' + sysroot, '-Wl,--warn-shared-textrel'] if env["android_arch"] == "armv7": - env.Append(LINKFLAGS=string.split('-Wl,--fix-cortex-a8')) - env.Append(LINKFLAGS=string.split('-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now')) - env.Append(LINKFLAGS=string.split('-Wl,-soname,libgodot_android.so -Wl,--gc-sections')) + env.Append(LINKFLAGS='-Wl,--fix-cortex-a8'.split()) + env.Append(LINKFLAGS='-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now'.split()) + env.Append(LINKFLAGS='-Wl,-soname,libgodot_android.so -Wl,--gc-sections'.split()) if mt_link: env.Append(LINKFLAGS=['-Wl,--threads']) env.Append(LINKFLAGS=target_opts) diff --git a/platform/android/dir_access_android.cpp b/platform/android/dir_access_android.cpp index 67aa7750cd..9653a585b1 100644 --- a/platform/android/dir_access_android.cpp +++ b/platform/android/dir_access_android.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/dir_access_android.h b/platform/android/dir_access_android.h index 32986f524b..2f63befc32 100644 --- a/platform/android/dir_access_android.h +++ b/platform/android/dir_access_android.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 34f4afa331..26e4684056 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h index 21d1f697b7..ad89be3581 100644 --- a/platform/android/dir_access_jandroid.h +++ b/platform/android/dir_access_jandroid.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index ada7df887c..eff3a7178d 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "export.h" + #include "editor/editor_export.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" @@ -39,1865 +40,8 @@ #include "platform/android/run_icon.gen.h" #include "project_settings.h" #include "version.h" -#include <string.h> -#if 0 - -static const char* android_perms[]={ -"ACCESS_CHECKIN_PROPERTIES", -"ACCESS_COARSE_LOCATION", -"ACCESS_FINE_LOCATION", -"ACCESS_LOCATION_EXTRA_COMMANDS", -"ACCESS_MOCK_LOCATION", -"ACCESS_NETWORK_STATE", -"ACCESS_SURFACE_FLINGER", -"ACCESS_WIFI_STATE", -"ACCOUNT_MANAGER", -"ADD_VOICEMAIL", -"AUTHENTICATE_ACCOUNTS", -"BATTERY_STATS", -"BIND_ACCESSIBILITY_SERVICE", -"BIND_APPWIDGET", -"BIND_DEVICE_ADMIN", -"BIND_INPUT_METHOD", -"BIND_NFC_SERVICE", -"BIND_NOTIFICATION_LISTENER_SERVICE", -"BIND_PRINT_SERVICE", -"BIND_REMOTEVIEWS", -"BIND_TEXT_SERVICE", -"BIND_VPN_SERVICE", -"BIND_WALLPAPER", -"BLUETOOTH", -"BLUETOOTH_ADMIN", -"BLUETOOTH_PRIVILEGED", -"BRICK", -"BROADCAST_PACKAGE_REMOVED", -"BROADCAST_SMS", -"BROADCAST_STICKY", -"BROADCAST_WAP_PUSH", -"CALL_PHONE", -"CALL_PRIVILEGED", -"CAMERA", -"CAPTURE_AUDIO_OUTPUT", -"CAPTURE_SECURE_VIDEO_OUTPUT", -"CAPTURE_VIDEO_OUTPUT", -"CHANGE_COMPONENT_ENABLED_STATE", -"CHANGE_CONFIGURATION", -"CHANGE_NETWORK_STATE", -"CHANGE_WIFI_MULTICAST_STATE", -"CHANGE_WIFI_STATE", -"CLEAR_APP_CACHE", -"CLEAR_APP_USER_DATA", -"CONTROL_LOCATION_UPDATES", -"DELETE_CACHE_FILES", -"DELETE_PACKAGES", -"DEVICE_POWER", -"DIAGNOSTIC", -"DISABLE_KEYGUARD", -"DUMP", -"EXPAND_STATUS_BAR", -"FACTORY_TEST", -"FLASHLIGHT", -"FORCE_BACK", -"GET_ACCOUNTS", -"GET_PACKAGE_SIZE", -"GET_TASKS", -"GET_TOP_ACTIVITY_INFO", -"GLOBAL_SEARCH", -"HARDWARE_TEST", -"INJECT_EVENTS", -"INSTALL_LOCATION_PROVIDER", -"INSTALL_PACKAGES", -"INSTALL_SHORTCUT", -"INTERNAL_SYSTEM_WINDOW", -"INTERNET", -"KILL_BACKGROUND_PROCESSES", -"LOCATION_HARDWARE", -"MANAGE_ACCOUNTS", -"MANAGE_APP_TOKENS", -"MANAGE_DOCUMENTS", -"MASTER_CLEAR", -"MEDIA_CONTENT_CONTROL", -"MODIFY_AUDIO_SETTINGS", -"MODIFY_PHONE_STATE", -"MOUNT_FORMAT_FILESYSTEMS", -"MOUNT_UNMOUNT_FILESYSTEMS", -"NFC", -"PERSISTENT_ACTIVITY", -"PROCESS_OUTGOING_CALLS", -"READ_CALENDAR", -"READ_CALL_LOG", -"READ_CONTACTS", -"READ_EXTERNAL_STORAGE", -"READ_FRAME_BUFFER", -"READ_HISTORY_BOOKMARKS", -"READ_INPUT_STATE", -"READ_LOGS", -"READ_PHONE_STATE", -"READ_PROFILE", -"READ_SMS", -"READ_SOCIAL_STREAM", -"READ_SYNC_SETTINGS", -"READ_SYNC_STATS", -"READ_USER_DICTIONARY", -"REBOOT", -"RECEIVE_BOOT_COMPLETED", -"RECEIVE_MMS", -"RECEIVE_SMS", -"RECEIVE_WAP_PUSH", -"RECORD_AUDIO", -"REORDER_TASKS", -"RESTART_PACKAGES", -"SEND_RESPOND_VIA_MESSAGE", -"SEND_SMS", -"SET_ACTIVITY_WATCHER", -"SET_ALARM", -"SET_ALWAYS_FINISH", -"SET_ANIMATION_SCALE", -"SET_DEBUG_APP", -"SET_ORIENTATION", -"SET_POINTER_SPEED", -"SET_PREFERRED_APPLICATIONS", -"SET_PROCESS_LIMIT", -"SET_TIME", -"SET_TIME_ZONE", -"SET_WALLPAPER", -"SET_WALLPAPER_HINTS", -"SIGNAL_PERSISTENT_PROCESSES", -"STATUS_BAR", -"SUBSCRIBED_FEEDS_READ", -"SUBSCRIBED_FEEDS_WRITE", -"SYSTEM_ALERT_WINDOW", -"TRANSMIT_IR", -"UNINSTALL_SHORTCUT", -"UPDATE_DEVICE_STATS", -"USE_CREDENTIALS", -"USE_SIP", -"VIBRATE", -"WAKE_LOCK", -"WRITE_APN_SETTINGS", -"WRITE_CALENDAR", -"WRITE_CALL_LOG", -"WRITE_CONTACTS", -"WRITE_EXTERNAL_STORAGE", -"WRITE_GSERVICES", -"WRITE_HISTORY_BOOKMARKS", -"WRITE_PROFILE", -"WRITE_SECURE_SETTINGS", -"WRITE_SETTINGS", -"WRITE_SMS", -"WRITE_SOCIAL_STREAM", -"WRITE_SYNC_SETTINGS", -"WRITE_USER_DICTIONARY", -NULL}; - -class EditorExportPlatformAndroid : public EditorExportPlatform { - - GDCLASS( EditorExportPlatformAndroid,EditorExportPlatform ); - - - enum { - MAX_USER_PERMISSIONS=20, - SCREEN_SMALL=0, - SCREEN_NORMAL=1, - SCREEN_LARGE=2, - SCREEN_XLARGE=3, - SCREEN_MAX=4 - }; - - String custom_release_package; - String custom_debug_package; - - int version_code; - String version_name; - String package; - String name; - String icon; - String cmdline; - bool _signed; - bool apk_expansion; - bool remove_prev; - bool use_32_fb; - bool immersive; - bool export_arm; - bool export_arm64; - bool export_x86; - String apk_expansion_salt; - String apk_expansion_pkey; - int orientation; - - String release_keystore; - String release_password; - String release_username; - - struct APKExportData { - - zipFile apk; - EditorProgress *ep; - }; - - struct Device { - - String id; - String name; - String description; - }; - - Vector<Device> devices; - bool devices_changed; - Mutex *device_lock; - Thread *device_thread; - Ref<ImageTexture> logo; - - Set<String> perms; - String user_perms[MAX_USER_PERMISSIONS]; - bool screen_support[SCREEN_MAX]; - - volatile bool quit_request; - - - static void _device_poll_thread(void *ud); - - String get_package_name(); - - String get_project_name() const; - void _fix_manifest(Vector<uint8_t>& p_manifest, bool p_give_internet); - void _fix_resources(Vector<uint8_t>& p_manifest); - static Error save_apk_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total); - static bool _should_compress_asset(const String& p_path, const Vector<uint8_t>& p_data); - -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 "Android"; } - virtual ImageCompression get_image_compression() const { return IMAGE_COMPRESSION_ETC1; } - virtual Ref<Texture> get_logo() const { return logo; } - - - virtual bool poll_devices(); - virtual int get_device_count() const; - virtual String get_device_name(int p_device) const; - virtual String get_device_info(int p_device) const; - virtual Error run(int p_device,int p_flags=0); - - virtual bool requires_password(bool p_debug) const { return !p_debug; } - virtual String get_binary_extension() const { return "apk"; } - virtual Error export_project(const String& p_path, bool p_debug, int p_flags=0); - - virtual bool can_export(String *r_error=NULL) const; - - EditorExportPlatformAndroid(); - ~EditorExportPlatformAndroid(); -}; - -bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant& p_value) { - - String n=p_name; - - if (n=="one_click_deploy/clear_previous_install") - remove_prev=p_value; - else if (n=="custom_package/debug") - custom_debug_package=p_value; - else if (n=="custom_package/release") - custom_release_package=p_value; - else if (n=="version/code") - version_code=p_value; - else if (n=="version/name") - version_name=p_value; - else if (n=="command_line/extra_args") - cmdline=p_value; - else if (n=="package/unique_name") - package=p_value; - else if (n=="package/name") - name=p_value; - else if (n=="package/icon") - icon=p_value; - else if (n=="package/signed") - _signed=p_value; - else if (n=="architecture/arm") - export_arm=p_value; - else if (n=="architecture/arm64") - export_arm64=p_value; - else if (n=="architecture/x86") - export_x86=p_value; - else if (n=="screen/use_32_bits_view") - use_32_fb=p_value; - else if (n=="screen/immersive_mode") - immersive=p_value; - else if (n=="screen/orientation") - orientation=p_value; - else if (n=="screen/support_small") - screen_support[SCREEN_SMALL]=p_value; - else if (n=="screen/support_normal") - screen_support[SCREEN_NORMAL]=p_value; - else if (n=="screen/support_large") - screen_support[SCREEN_LARGE]=p_value; - else if (n=="screen/support_xlarge") - screen_support[SCREEN_XLARGE]=p_value; - else if (n=="keystore/release") - release_keystore=p_value; - else if (n=="keystore/release_user") - release_username=p_value; - else if (n=="keystore/release_password") - release_password=p_value; - else if (n=="apk_expansion/enable") - apk_expansion=p_value; - else if (n=="apk_expansion/SALT") - apk_expansion_salt=p_value; - else if (n=="apk_expansion/public_key") - apk_expansion_pkey=p_value; - else if (n.begins_with("permissions/")) { - - String what = n.get_slicec('/',1).to_upper(); - bool state = p_value; - if (state) - perms.insert(what); - else - perms.erase(what); - } else if (n.begins_with("user_permissions/")) { - - int which = n.get_slicec('/',1).to_int(); - ERR_FAIL_INDEX_V(which,MAX_USER_PERMISSIONS,false); - user_perms[which]=p_value; - - } else - return false; - - return true; -} - -bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret) const{ - - String n=p_name; - if (n=="one_click_deploy/clear_previous_install") - r_ret=remove_prev; - else if (n=="custom_package/debug") - r_ret=custom_debug_package; - else if (n=="custom_package/release") - r_ret=custom_release_package; - else if (n=="version/code") - r_ret=version_code; - else if (n=="version/name") - r_ret=version_name; - else if (n=="command_line/extra_args") - r_ret=cmdline; - else if (n=="package/unique_name") - r_ret=package; - else if (n=="package/name") - r_ret=name; - else if (n=="package/icon") - r_ret=icon; - else if (n=="package/signed") - r_ret=_signed; - else if (n=="architecture/arm") - r_ret=export_arm; - else if (n=="architecture/arm64") - r_ret=export_arm64; - else if (n=="architecture/x86") - r_ret=export_x86; - else if (n=="screen/use_32_bits_view") - r_ret=use_32_fb; - else if (n=="screen/immersive_mode") - r_ret=immersive; - else if (n=="screen/orientation") - r_ret=orientation; - else if (n=="screen/support_small") - r_ret=screen_support[SCREEN_SMALL]; - else if (n=="screen/support_normal") - r_ret=screen_support[SCREEN_NORMAL]; - else if (n=="screen/support_large") - r_ret=screen_support[SCREEN_LARGE]; - else if (n=="screen/support_xlarge") - r_ret=screen_support[SCREEN_XLARGE]; - else if (n=="keystore/release") - r_ret=release_keystore; - else if (n=="keystore/release_user") - r_ret=release_username; - else if (n=="keystore/release_password") - r_ret=release_password; - else if (n=="apk_expansion/enable") - r_ret=apk_expansion; - else if (n=="apk_expansion/SALT") - r_ret=apk_expansion_salt; - else if (n=="apk_expansion/public_key") - r_ret=apk_expansion_pkey; - else if (n.begins_with("permissions/")) { - - String what = n.get_slicec('/',1).to_upper(); - r_ret = perms.has(what); - } else if (n.begins_with("user_permissions/")) { - - int which = n.get_slicec('/',1).to_int(); - ERR_FAIL_INDEX_V(which,MAX_USER_PERMISSIONS,false); - r_ret=user_perms[which]; - } else - return false; - - return true; -} - -void EditorExportPlatformAndroid::_get_property_list( List<PropertyInfo> *p_list) const{ - - p_list->push_back( PropertyInfo( Variant::BOOL, "one_click_deploy/clear_previous_install")); - p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE,"apk")); - p_list->push_back( PropertyInfo( Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE,"apk")); - p_list->push_back( PropertyInfo( Variant::STRING, "command_line/extra_args")); - p_list->push_back( PropertyInfo( Variant::INT, "version/code", PROPERTY_HINT_RANGE,"1,65535,1")); - p_list->push_back( PropertyInfo( Variant::STRING, "version/name") ); - p_list->push_back( PropertyInfo( Variant::STRING, "package/unique_name") ); - p_list->push_back( PropertyInfo( Variant::STRING, "package/name") ); - p_list->push_back( PropertyInfo( Variant::STRING, "package/icon",PROPERTY_HINT_FILE,"png") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "package/signed") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "architecture/arm") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "architecture/x86") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "screen/use_32_bits_view") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "screen/immersive_mode") ); - p_list->push_back( PropertyInfo( Variant::INT, "screen/orientation",PROPERTY_HINT_ENUM,"Landscape,Portrait") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "screen/support_small") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "screen/support_normal") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "screen/support_large") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "screen/support_xlarge") ); - p_list->push_back( PropertyInfo( Variant::STRING, "keystore/release",PROPERTY_HINT_GLOBAL_FILE,"keystore") ); - p_list->push_back( PropertyInfo( Variant::STRING, "keystore/release_user" ) ); - p_list->push_back( PropertyInfo( Variant::STRING, "keystore/release_password" ) ); - p_list->push_back( PropertyInfo( Variant::BOOL, "apk_expansion/enable" ) ); - p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/SALT" ) ); - p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/public_key",PROPERTY_HINT_MULTILINE_TEXT ) ); - - const char **perms = android_perms; - while(*perms) { - - p_list->push_back( PropertyInfo( Variant::BOOL, "permissions/"+String(*perms).to_lower())); - perms++; - } - - for(int i=0;i<MAX_USER_PERMISSIONS;i++) { - - p_list->push_back( PropertyInfo( Variant::STRING, "user_permissions/"+itos(i))); - } - - //p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Copy,Single Exec.,Pack (.pck),Bundles (Optical)")); - -} - - -static String _parse_string(const uint8_t *p_bytes,bool p_utf8) { - - uint32_t offset=0; - uint32_t len = decode_uint16(&p_bytes[offset]); - - if (p_utf8) { - //don't know how to read extended utf8, this will have to be for now - len>>=8; - - } - offset+=2; - //printf("len %i, unicode: %i\n",len,int(p_utf8)); - - if (p_utf8) { - - Vector<uint8_t> str8; - str8.resize(len+1); - for(uint32_t i=0;i<len;i++) { - str8[i]=p_bytes[offset+i]; - } - str8[len]=0; - String str; - str.parse_utf8((const char*)str8.ptr()); - return str; - } else { - - String str; - for(uint32_t i=0;i<len;i++) { - CharType c = decode_uint16(&p_bytes[offset+i*2]); - if (c==0) - break; - str += String::chr(c); - } - return str; - } - -} - -void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t>& p_manifest) { - - - const int UTF8_FLAG = 0x00000100; - print_line("*******************GORRRGLE***********************"); - - uint32_t header = decode_uint32(&p_manifest[0]); - uint32_t filesize = decode_uint32(&p_manifest[4]); - uint32_t string_block_len = decode_uint32(&p_manifest[16]); - uint32_t string_count = decode_uint32(&p_manifest[20]); - uint32_t string_flags = decode_uint32(&p_manifest[28]); - const uint32_t string_table_begins = 40; - - Vector<String> string_table; - - //printf("stirng block len: %i\n",string_block_len); - //printf("stirng count: %i\n",string_count); - //printf("flags: %x\n",string_flags); - - for(uint32_t i=0;i<string_count;i++) { - - uint32_t offset = decode_uint32(&p_manifest[string_table_begins+i*4]); - offset+=string_table_begins+string_count*4; - - String str = _parse_string(&p_manifest[offset],string_flags&UTF8_FLAG); - - if (str.begins_with("godot-project-name")) { - - - if (str=="godot-project-name") { - //project name - str = get_project_name(); - - } else { - - String lang = str.substr(str.find_last("-")+1,str.length()).replace("-","_"); - String prop = "application/config/name_"+lang; - if (ProjectSettings::get_singleton()->has(prop)) { - str = ProjectSettings::get_singleton()->get(prop); - } else { - str = get_project_name(); - } - } - } - - string_table.push_back(str); - - } - - //write a new string table, but use 16 bits - Vector<uint8_t> ret; - ret.resize(string_table_begins+string_table.size()*4); - - for(uint32_t i=0;i<string_table_begins;i++) { - - ret[i]=p_manifest[i]; - } - - int ofs=0; - for(int i=0;i<string_table.size();i++) { - - encode_uint32(ofs,&ret[string_table_begins+i*4]); - ofs+=string_table[i].length()*2+2+2; - } - - ret.resize(ret.size()+ofs); - uint8_t *chars=&ret[ret.size()-ofs]; - for(int i=0;i<string_table.size();i++) { - - String s = string_table[i]; - encode_uint16(s.length(),chars); - chars+=2; - for(int j=0;j<s.length();j++) { - encode_uint16(s[j],chars); - chars+=2; - } - encode_uint16(0,chars); - chars+=2; - } - - //pad - while(ret.size()%4) - ret.push_back(0); - - //change flags to not use utf8 - encode_uint32(string_flags&~0x100,&ret[28]); - //change length - encode_uint32(ret.size()-12,&ret[16]); - //append the rest... - int rest_from = 12+string_block_len; - int rest_to = ret.size(); - int rest_len = (p_manifest.size() - rest_from); - ret.resize(ret.size() + (p_manifest.size() - rest_from) ); - for(int i=0;i<rest_len;i++) { - ret[rest_to+i]=p_manifest[rest_from+i]; - } - //finally update the size - encode_uint32(ret.size(),&ret[4]); - - - p_manifest=ret; - //printf("end\n"); -} - -String EditorExportPlatformAndroid::get_project_name() const { - - String aname; - if (this->name!="") { - aname=this->name; - } else { - aname = ProjectSettings::get_singleton()->get("application/config/name"); - - } - - if (aname=="") { - aname=_MKSTR(VERSION_NAME); - } - - return aname; -} - - -void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t>& p_manifest,bool p_give_internet) { - - - const int CHUNK_AXML_FILE = 0x00080003; - const int CHUNK_RESOURCEIDS = 0x00080180; - const int CHUNK_STRINGS = 0x001C0001; - const int CHUNK_XML_END_NAMESPACE = 0x00100101; - const int CHUNK_XML_END_TAG = 0x00100103; - const int CHUNK_XML_START_NAMESPACE = 0x00100100; - const int CHUNK_XML_START_TAG = 0x00100102; - const int CHUNK_XML_TEXT = 0x00100104; - const int UTF8_FLAG = 0x00000100; - - Vector<String> string_table; - - uint32_t ofs=0; - - - uint32_t header = decode_uint32(&p_manifest[ofs]); - uint32_t filesize = decode_uint32(&p_manifest[ofs+4]); - ofs+=8; - - //print_line("FILESIZE: "+itos(filesize)+" ACTUAL: "+itos(p_manifest.size())); - - uint32_t string_count; - uint32_t styles_count; - uint32_t string_flags; - uint32_t string_data_offset; - - uint32_t styles_offset; - uint32_t string_table_begins; - uint32_t string_table_ends; - Vector<uint8_t> stable_extra; - - while(ofs < (uint32_t)p_manifest.size()) { - - uint32_t chunk = decode_uint32(&p_manifest[ofs]); - uint32_t size = decode_uint32(&p_manifest[ofs+4]); - - - switch(chunk) { - - case CHUNK_STRINGS: { - - - int iofs=ofs+8; - - string_count=decode_uint32(&p_manifest[iofs]); - styles_count=decode_uint32(&p_manifest[iofs+4]); - string_flags=decode_uint32(&p_manifest[iofs+8]); - string_data_offset=decode_uint32(&p_manifest[iofs+12]); - styles_offset=decode_uint32(&p_manifest[iofs+16]); -/* - printf("string count: %i\n",string_count); - printf("flags: %i\n",string_flags); - printf("sdata ofs: %i\n",string_data_offset); - printf("styles ofs: %i\n",styles_offset); -*/ - uint32_t st_offset=iofs+20; - string_table.resize(string_count); - uint32_t string_end=0; - - string_table_begins=st_offset; - - - for(uint32_t i=0;i<string_count;i++) { - - uint32_t string_at = decode_uint32(&p_manifest[st_offset+i*4]); - string_at+=st_offset+string_count*4; - - ERR_EXPLAIN("Unimplemented, can't read utf8 string table."); - ERR_FAIL_COND(string_flags&UTF8_FLAG); - - if (string_flags&UTF8_FLAG) { - - - - } else { - uint32_t len = decode_uint16(&p_manifest[string_at]); - Vector<CharType> ucstring; - ucstring.resize(len+1); - for(uint32_t j=0;j<len;j++) { - uint16_t c=decode_uint16(&p_manifest[string_at+2+2*j]); - ucstring[j]=c; - } - string_end=MAX(string_at+2+2*len,string_end); - ucstring[len]=0; - string_table[i]=ucstring.ptr(); - } - - - //print_line("String "+itos(i)+": "+string_table[i]); - } - - for(uint32_t i=string_end;i<(ofs+size);i++) { - stable_extra.push_back(p_manifest[i]); - } - - //printf("stable extra: %i\n",int(stable_extra.size())); - string_table_ends=ofs+size; - - //print_line("STABLE SIZE: "+itos(size)+" ACTUAL: "+itos(string_table_ends)); - - } break; - case CHUNK_XML_START_TAG: { - - int iofs=ofs+8; - uint32_t line=decode_uint32(&p_manifest[iofs]); - uint32_t nspace=decode_uint32(&p_manifest[iofs+8]); - uint32_t name=decode_uint32(&p_manifest[iofs+12]); - uint32_t check=decode_uint32(&p_manifest[iofs+16]); - - String tname=string_table[name]; - - //printf("NSPACE: %i\n",nspace); - //printf("NAME: %i (%s)\n",name,tname.utf8().get_data()); - //printf("CHECK: %x\n",check); - uint32_t attrcount=decode_uint32(&p_manifest[iofs+20]); - iofs+=28; - //printf("ATTRCOUNT: %x\n",attrcount); - for(uint32_t i=0;i<attrcount;i++) { - uint32_t attr_nspace=decode_uint32(&p_manifest[iofs]); - uint32_t attr_name=decode_uint32(&p_manifest[iofs+4]); - uint32_t attr_value=decode_uint32(&p_manifest[iofs+8]); - uint32_t attr_flags=decode_uint32(&p_manifest[iofs+12]); - uint32_t attr_resid=decode_uint32(&p_manifest[iofs+16]); - - - String value; - if (attr_value!=0xFFFFFFFF) - value=string_table[attr_value]; - else - value="Res #"+itos(attr_resid); - String attrname = string_table[attr_name]; - String nspace; - if (attr_nspace!=0xFFFFFFFF) - nspace=string_table[attr_nspace]; - else - nspace=""; - - //printf("ATTR %i NSPACE: %i\n",i,attr_nspace); - //printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data()); - //printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data()); - //printf("ATTR %i FLAGS: %x\n",i,attr_flags); - //printf("ATTR %i RESID: %x\n",i,attr_resid); - - //replace project information - if (tname=="manifest" && attrname=="package") { - - print_line("FOUND package"); - string_table[attr_value]=get_package_name(); - } - - //print_line("tname: "+tname); - //print_line("nspace: "+nspace); - //print_line("attrname: "+attrname); - if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionCode") { - - print_line("FOUND versionCode"); - encode_uint32(version_code,&p_manifest[iofs+16]); - } - - - if (tname=="manifest" && /*nspace=="android" &&*/ attrname=="versionName") { - - print_line("FOUND versionName"); - if (attr_value==0xFFFFFFFF) { - WARN_PRINT("Version name in a resource, should be plaintext") - } else - string_table[attr_value]=version_name; - } - - if (tname=="activity" && /*nspace=="android" &&*/ attrname=="screenOrientation") { - - encode_uint32(orientation==0?0:1,&p_manifest[iofs+16]); - /* - print_line("FOUND screen orientation"); - if (attr_value==0xFFFFFFFF) { - WARN_PRINT("Version name in a resource, should be plaintext") - } else { - string_table[attr_value]=(orientation==0?"landscape":"portrait"); - }*/ - } - - if (tname=="uses-permission" && /*nspace=="android" &&*/ attrname=="name") { - - if (value.begins_with("godot.custom")) { - - int which = value.get_slice(".",2).to_int(); - if (which>=0 && which<MAX_USER_PERMISSIONS && user_perms[which].strip_edges()!="") { - - string_table[attr_value]=user_perms[which].strip_edges(); - } - - } else if (value.begins_with("godot.")) { - String perm = value.get_slice(".",1); - - if (perms.has(perm) || (p_give_internet && perm=="INTERNET")) { - - print_line("PERM: "+perm); - string_table[attr_value]="android.permission."+perm; - } - - } - } - - if (tname=="supports-screens" ) { - - if (attrname=="smallScreens") { - - encode_uint32(screen_support[SCREEN_SMALL]?0xFFFFFFFF:0,&p_manifest[iofs+16]); - - } else if (attrname=="normalScreens") { - - encode_uint32(screen_support[SCREEN_NORMAL]?0xFFFFFFFF:0,&p_manifest[iofs+16]); - - } else if (attrname=="largeScreens") { - - encode_uint32(screen_support[SCREEN_LARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]); - - } else if (attrname=="xlargeScreens") { - - encode_uint32(screen_support[SCREEN_XLARGE]?0xFFFFFFFF:0,&p_manifest[iofs+16]); - - } - } - - - iofs+=20; - } - - } break; - } - //printf("chunk %x: size: %d\n",chunk,size); - - ofs+=size; - } - - //printf("end\n"); - - //create new andriodmanifest binary - - Vector<uint8_t> ret; - ret.resize(string_table_begins+string_table.size()*4); - - for(uint32_t i=0;i<string_table_begins;i++) { - - ret[i]=p_manifest[i]; - } - - ofs=0; - for(int i=0;i<string_table.size();i++) { - - encode_uint32(ofs,&ret[string_table_begins+i*4]); - ofs+=string_table[i].length()*2+2+2; - //print_line("ofs: "+itos(i)+": "+itos(ofs)); - } - ret.resize(ret.size()+ofs); - uint8_t *chars=&ret[ret.size()-ofs]; - for(int i=0;i<string_table.size();i++) { - - String s = string_table[i]; - //print_line("savint string :"+s); - encode_uint16(s.length(),chars); - chars+=2; - for(int j=0;j<s.length();j++) { //include zero? - encode_uint16(s[j],chars); - chars+=2; - } - encode_uint16(0,chars); - chars+=2; - - } - - - for(int i=0;i<stable_extra.size();i++) { - ret.push_back(stable_extra[i]); - } - - while(ret.size()%4) - ret.push_back(0); - - - uint32_t new_stable_end=ret.size(); - - uint32_t extra = (p_manifest.size()-string_table_ends); - ret.resize(new_stable_end + extra); - for(uint32_t i=0;i<extra;i++) - ret[new_stable_end+i]=p_manifest[string_table_ends+i]; - - while(ret.size()%4) - ret.push_back(0); - encode_uint32(ret.size(),&ret[4]); //update new file size - - encode_uint32(new_stable_end-8,&ret[12]); //update new string table size - - //print_line("file size: "+itos(ret.size())); - - p_manifest=ret; - -#if 0 - uint32_t header[9]; - for(int i=0;i<9;i++) { - header[i]=decode_uint32(&p_manifest[i*4]); - } - - //print_line("STO: "+itos(header[3])); - uint32_t st_offset=9*4; - //ERR_FAIL_COND(header[3]!=0x24) - uint32_t string_count=header[4]; - - - string_table.resize(string_count); - - for(int i=0;i<string_count;i++) { - - uint32_t string_at = decode_uint32(&p_manifest[st_offset+i*4]); - string_at+=st_offset+string_count*4; - uint32_t len = decode_uint16(&p_manifest[string_at]); - Vector<CharType> ucstring; - ucstring.resize(len+1); - for(int j=0;j<len;j++) { - uint16_t c=decode_uint16(&p_manifest[string_at+2+2*j]); - ucstring[j]=c; - } - ucstring[len]=0; - string_table[i]=ucstring.ptr(); - } - -#endif - -} - - - -Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata,const String& p_path, const Vector<uint8_t>& p_data,int p_file,int p_total) { - - APKExportData *ed=(APKExportData*)p_userdata; - String dst_path=p_path; - dst_path=dst_path.replace_first("res://","assets/"); - - zipOpenNewFileInZip(ed->apk, - dst_path.utf8().get_data(), - NULL, - NULL, - 0, - NULL, - 0, - NULL, - _should_compress_asset(p_path,p_data) ? Z_DEFLATED : 0, - Z_DEFAULT_COMPRESSION); - - - zipWriteInFileInZip(ed->apk,p_data.ptr(),p_data.size()); - zipCloseFileInZip(ed->apk); - ed->ep->step("File: "+p_path,3+p_file*100/p_total); - return OK; - -} - -bool EditorExportPlatformAndroid::_should_compress_asset(const String& p_path, const Vector<uint8_t>& p_data) { - - /* - * By not compressing files with little or not benefit in doing so, - * a performance gain is expected at runtime. Moreover, if the APK is - * zip-aligned, assets stored as they are can be efficiently read by - * Android by memory-mapping them. - */ - - // -- Unconditional uncompress to mimic AAPT plus some other - - static const char* unconditional_compress_ext[] = { - // From https://github.com/android/platform_frameworks_base/blob/master/tools/aapt/Package.cpp - // These formats are already compressed, or don't compress well: - ".jpg", ".jpeg", ".png", ".gif", - ".wav", ".mp2", ".mp3", ".ogg", ".aac", - ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet", - ".rtttl", ".imy", ".xmf", ".mp4", ".m4a", - ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2", - ".amr", ".awb", ".wma", ".wmv", - // Godot-specific: - ".webp", // Same reasoning as .png - ".cfb", // Don't let small config files slow-down startup - // Trailer for easier processing - NULL - }; - - for (const char** ext=unconditional_compress_ext; *ext; ++ext) { - if (p_path.to_lower().ends_with(String(*ext))) { - return false; - } - } - - // -- Compressed resource? - - if (p_data.size() >= 4 && p_data[0]=='R' && p_data[1]=='S' && p_data[2]=='C' && p_data[3]=='C') { - // Already compressed - return false; - } - - // --- TODO: Decide on texture resources according to their image compression setting - - return true; -} - - - -Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_debug, int p_flags) { - - String src_apk; - - EditorProgress ep("export","Exporting for Android",105); - - if (p_debug) - src_apk=custom_debug_package; - else - src_apk=custom_release_package; - - if (src_apk=="") { - String err; - if (p_debug) { - src_apk=find_export_template("android_debug.apk", &err); - } else { - src_apk=find_export_template("android_release.apk", &err); - } - if (src_apk=="") { - EditorNode::add_io_error(err); - return ERR_FILE_NOT_FOUND; - } - } - - FileAccess *src_f=NULL; - zlib_filefunc_def io = zipio_create_io_from_file(&src_f); - - - - ep.step("Creating APK",0); - - unzFile pkg = unzOpen2(src_apk.utf8().get_data(), &io); - if (!pkg) { - - EditorNode::add_io_error("Could not find template APK to export:\n"+src_apk); - return ERR_FILE_NOT_FOUND; - } - - ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN); - int ret = unzGoToFirstFile(pkg); - - zlib_filefunc_def io2=io; - FileAccess *dst_f=NULL; - io2.opaque=&dst_f; - String unaligned_path=EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmpexport-unaligned.apk"; - zipFile unaligned_apk=zipOpen2(unaligned_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io2); - - - while(ret==UNZ_OK) { - - //get filename - unz_file_info info; - char fname[16384]; - ret = unzGetCurrentFileInfo(pkg,&info,fname,16384,NULL,0,NULL,0); - - bool skip=false; - - String file=fname; - - Vector<uint8_t> data; - data.resize(info.uncompressed_size); - - //read - unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg,data.ptr(),data.size()); - unzCloseCurrentFile(pkg); - - //write - - if (file=="AndroidManifest.xml") { - - _fix_manifest(data,p_flags&(EXPORT_DUMB_CLIENT|EXPORT_REMOTE_DEBUG)); - } - - if (file=="resources.arsc") { - - _fix_resources(data); - } - - if (file=="res/drawable/icon.png") { - bool found=false; - - if (this->icon!="" && this->icon.ends_with(".png")) { - FileAccess *f = FileAccess::open(this->icon,FileAccess::READ); - if (f) { - - data.resize(f->get_len()); - f->get_buffer(data.ptr(),data.size()); - memdelete(f); - found=true; - } - - } - - if (!found) { - - String appicon = ProjectSettings::get_singleton()->get("application/config/icon"); - if (appicon!="" && appicon.ends_with(".png")) { - FileAccess*f = FileAccess::open(appicon,FileAccess::READ); - if (f) { - data.resize(f->get_len()); - f->get_buffer(data.ptr(),data.size()); - memdelete(f); - } - } - } - } - - if (file=="lib/x86/libgodot_android.so" && !export_x86) { - skip=true; - } - - if (file.match("lib/armeabi*/libgodot_android.so") && !export_arm) { - skip=true; - } - - if (file.match("lib/arm64*/libgodot_android.so") && !export_arm64) { - skip = true; - } - - if (file.begins_with("META-INF") && _signed) { - skip=true; - } - - print_line("ADDING: "+file); - - if (!skip) { - - // Respect decision on compression made by AAPT for the export template - const bool uncompressed = info.compression_method == 0; - - zipOpenNewFileInZip(unaligned_apk, - file.utf8().get_data(), - NULL, - NULL, - 0, - NULL, - 0, - NULL, - uncompressed ? 0 : Z_DEFLATED, - Z_DEFAULT_COMPRESSION); - - zipWriteInFileInZip(unaligned_apk,data.ptr(),data.size()); - zipCloseFileInZip(unaligned_apk); - } - - ret = unzGoToNextFile(pkg); - } - - - ep.step("Adding Files..",1); - Error err=OK; - Vector<String> cl = cmdline.strip_edges().split(" "); - for(int i=0;i<cl.size();i++) { - if (cl[i].strip_edges().length()==0) { - cl.remove(i); - i--; - } - } - - gen_export_flags(cl,p_flags); - - if (p_flags&EXPORT_DUMB_CLIENT) { - - /*String host = EditorSettings::get_singleton()->get("filesystem/file_server/host"); - int port = EditorSettings::get_singleton()->get("filesystem/file_server/post"); - String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password"); - cl.push_back("--remote-fs"); - cl.push_back(host+":"+itos(port)); - if (passwd!="") { - cl.push_back("--remote-fs-password"); - cl.push_back(passwd); - }*/ - - - } else { - //all files - - if (apk_expansion) { - - String apkfname="main."+itos(version_code)+"."+get_package_name()+".obb"; - String fullpath=p_path.get_base_dir().plus_file(apkfname); - FileAccess *pf = FileAccess::open(fullpath,FileAccess::WRITE); - if (!pf) { - EditorNode::add_io_error("Could not write expansion package file: "+apkfname); - return OK; - } - err = save_pack(pf); - memdelete(pf); - - cl.push_back("--use_apk_expansion"); - cl.push_back("--apk_expansion_md5"); - cl.push_back(FileAccess::get_md5(fullpath)); - cl.push_back("--apk_expansion_key"); - cl.push_back(apk_expansion_pkey.strip_edges()); - - } else { - - APKExportData ed; - ed.ep=&ep; - ed.apk=unaligned_apk; - - err = export_project_files(save_apk_file,&ed,false); - } - - - } - - if (use_32_fb) - cl.push_back("--use_depth_32"); - - if (immersive) - cl.push_back("--use_immersive"); - - if (cl.size()) { - //add comandline - Vector<uint8_t> clf; - clf.resize(4); - encode_uint32(cl.size(),&clf[0]); - for(int i=0;i<cl.size();i++) { - - CharString txt = cl[i].utf8(); - int base = clf.size(); - clf.resize(base+4+txt.length()); - encode_uint32(txt.length(),&clf[base]); - copymem(&clf[base+4],txt.ptr(),txt.length()); - print_line(itos(i)+" param: "+cl[i]); - } - - zipOpenNewFileInZip(unaligned_apk, - "assets/_cl_", - NULL, - NULL, - 0, - NULL, - 0, - NULL, - 0, // No compress (little size gain and potentially slower startup) - Z_DEFAULT_COMPRESSION); - - zipWriteInFileInZip(unaligned_apk,clf.ptr(),clf.size()); - zipCloseFileInZip(unaligned_apk); - - } - - zipClose(unaligned_apk,NULL); - unzClose(pkg); - - if (err) { - return err; - } - - - - if (_signed) { - - - String jarsigner=EditorSettings::get_singleton()->get("export/android/jarsigner"); - if (!FileAccess::exists(jarsigner)) { - EditorNode::add_io_error("'jarsigner' could not be found.\nPlease supply a path in the editor settings.\nResulting apk is unsigned."); - return OK; - } - - String keystore; - String password; - String user; - if (p_debug) { - keystore=EditorSettings::get_singleton()->get("export/android/debug_keystore"); - password=EditorSettings::get_singleton()->get("export/android/debug_keystore_pass"); - user=EditorSettings::get_singleton()->get("export/android/debug_keystore_user"); - - ep.step("Signing Debug APK..",103); - - } else { - keystore=release_keystore; - password=release_password; - user=release_username; - - ep.step("Signing Release APK..",103); - - } - - if (!FileAccess::exists(keystore)) { - EditorNode::add_io_error("Could not find keystore, unable to export."); - return ERR_FILE_CANT_OPEN; - } - - List<String> args; - args.push_back("-digestalg"); - args.push_back("SHA1"); - args.push_back("-sigalg"); - args.push_back("MD5withRSA"); - String tsa_url=EditorSettings::get_singleton()->get("export/android/timestamping_authority_url"); - if (tsa_url != "") { - args.push_back("-tsa"); - args.push_back(tsa_url); - } - args.push_back("-verbose"); - args.push_back("-keystore"); - args.push_back(keystore); - args.push_back("-storepass"); - args.push_back(password); - args.push_back(unaligned_path); - args.push_back(user); - int retval; - OS::get_singleton()->execute(jarsigner,args,true,NULL,NULL,&retval); - if (retval) { - EditorNode::add_io_error("'jarsigner' returned with error #"+itos(retval)); - return ERR_CANT_CREATE; - } - - ep.step("Verifying APK..",104); - - args.clear(); - args.push_back("-verify"); - args.push_back(unaligned_path); - args.push_back("-verbose"); - - OS::get_singleton()->execute(jarsigner,args,true,NULL,NULL,&retval); - if (retval) { - EditorNode::add_io_error("'jarsigner' verification of APK failed. Make sure to use jarsigner from Java 6."); - return ERR_CANT_CREATE; - } - - } - - - - // Let's zip-align (must be done after signing) - - static const int ZIP_ALIGNMENT = 4; - - ep.step("Aligning APK..",105); - - unzFile tmp_unaligned = unzOpen2(unaligned_path.utf8().get_data(), &io); - if (!tmp_unaligned) { - - EditorNode::add_io_error("Could not find temp unaligned APK."); - return ERR_FILE_NOT_FOUND; - } - - ERR_FAIL_COND_V(!tmp_unaligned, ERR_CANT_OPEN); - ret = unzGoToFirstFile(tmp_unaligned); - - io2=io; - dst_f=NULL; - io2.opaque=&dst_f; - zipFile final_apk=zipOpen2(p_path.utf8().get_data(),APPEND_STATUS_CREATE,NULL,&io2); - - // Take files from the unaligned APK and write them out to the aligned one - // in raw mode, i.e. not uncompressing and recompressing, aligning them as needed, - // following what is done in https://github.com/android/platform_build/blob/master/tools/zipalign/ZipAlign.cpp - int bias = 0; - while(ret==UNZ_OK) { - - unz_file_info info; - memset(&info, 0, sizeof(info)); - - char fname[16384]; - char extra[16384]; - ret = unzGetCurrentFileInfo(tmp_unaligned,&info,fname,16384,extra,16384-ZIP_ALIGNMENT,NULL,0); - - String file=fname; - - Vector<uint8_t> data; - data.resize(info.compressed_size); - - // read - int method, level; - unzOpenCurrentFile2(tmp_unaligned, &method, &level, 1); // raw read - long file_offset = unzGetCurrentFileZStreamPos64(tmp_unaligned); - unzReadCurrentFile(tmp_unaligned,data.ptr(),data.size()); - unzCloseCurrentFile(tmp_unaligned); - - // align - int padding = 0; - if (!info.compression_method) { - // Uncompressed file => Align - long new_offset = file_offset + bias; - padding = (ZIP_ALIGNMENT - (new_offset % ZIP_ALIGNMENT)) % ZIP_ALIGNMENT; - } - - memset(extra + info.size_file_extra, 0, padding); - - // write - zipOpenNewFileInZip2(final_apk, - file.utf8().get_data(), - NULL, - extra, - info.size_file_extra + padding, - NULL, - 0, - NULL, - method, - level, - 1); // raw write - zipWriteInFileInZip(final_apk,data.ptr(),data.size()); - zipCloseFileInZipRaw(final_apk,info.uncompressed_size,info.crc); - - bias += padding; - - ret = unzGoToNextFile(tmp_unaligned); - } - - zipClose(final_apk,NULL); - unzClose(tmp_unaligned); - - if (err) { - return err; - } - - return OK; - -} - - -bool EditorExportPlatformAndroid::poll_devices() { - - bool dc=devices_changed; - devices_changed=false; - return dc; -} - -int EditorExportPlatformAndroid::get_device_count() const { - - device_lock->lock(); - int dc=devices.size(); - device_lock->unlock(); - - return dc; - -} - -String EditorExportPlatformAndroid::get_device_name(int p_device) const { - - ERR_FAIL_INDEX_V(p_device,devices.size(),""); - device_lock->lock(); - String s=devices[p_device].name; - device_lock->unlock(); - return s; -} - -String EditorExportPlatformAndroid::get_device_info(int p_device) const { - - ERR_FAIL_INDEX_V(p_device,devices.size(),""); - device_lock->lock(); - String s=devices[p_device].description; - device_lock->unlock(); - return s; -} - -void EditorExportPlatformAndroid::_device_poll_thread(void *ud) { - - EditorExportPlatformAndroid *ea=(EditorExportPlatformAndroid *)ud; - - - while(!ea->quit_request) { - - String adb=EditorSettings::get_singleton()->get("export/android/adb"); - if (FileAccess::exists(adb)) { - - String devices; - List<String> args; - args.push_back("devices"); - int ec; - OS::get_singleton()->execute(adb,args,true,NULL,&devices,&ec); - Vector<String> ds = devices.split("\n"); - Vector<String> ldevices; - for(int i=1;i<ds.size();i++) { - - String d = ds[i]; - int dpos = d.find("device"); - if (dpos==-1) - continue; - d=d.substr(0,dpos).strip_edges(); - //print_line("found devuce: "+d); - ldevices.push_back(d); - } - - ea->device_lock->lock(); - - bool different=false; - - if (devices.size()!=ldevices.size()) { - - different=true; - } else { - - for(int i=0;i<ea->devices.size();i++) { - - if (ea->devices[i].id!=ldevices[i]) { - different=true; - break; - } - } - } - - if (different) { - - - Vector<Device> ndevices; - - for(int i=0;i<ldevices.size();i++) { - - Device d; - d.id=ldevices[i]; - for(int j=0;j<ea->devices.size();j++) { - if (ea->devices[j].id==ldevices[i]) { - d.description=ea->devices[j].description; - d.name=ea->devices[j].name; - } - } - - if (d.description=="") { - //in the oven, request! - args.clear(); - args.push_back("-s"); - args.push_back(d.id); - args.push_back("shell"); - args.push_back("cat"); - args.push_back("/system/build.prop"); - int ec; - String dp; - - OS::get_singleton()->execute(adb,args,true,NULL,&dp,&ec); - - Vector<String> props = dp.split("\n"); - String vendor; - String device; - d.description+"Device ID: "+d.id+"\n"; - for(int j=0;j<props.size();j++) { - - String p = props[j]; - if (p.begins_with("ro.product.model=")) { - device=p.get_slice("=",1).strip_edges(); - } else if (p.begins_with("ro.product.brand=")) { - vendor=p.get_slice("=",1).strip_edges().capitalize(); - } else if (p.begins_with("ro.build.display.id=")) { - d.description+="Build: "+p.get_slice("=",1).strip_edges()+"\n"; - } else if (p.begins_with("ro.build.version.release=")) { - d.description+="Release: "+p.get_slice("=",1).strip_edges()+"\n"; - } else if (p.begins_with("ro.product.cpu.abi=")) { - d.description+="CPU: "+p.get_slice("=",1).strip_edges()+"\n"; - } else if (p.begins_with("ro.product.manufacturer=")) { - d.description+="Manufacturer: "+p.get_slice("=",1).strip_edges()+"\n"; - } else if (p.begins_with("ro.board.platform=")) { - d.description+="Chipset: "+p.get_slice("=",1).strip_edges()+"\n"; - } else if (p.begins_with("ro.opengles.version=")) { - uint32_t opengl = p.get_slice("=",1).to_int(); - d.description+="OpenGL: "+itos(opengl>>16)+"."+itos((opengl>>8)&0xFF)+"."+itos((opengl)&0xFF)+"\n"; - } - } - - d.name=vendor+" "+device; - //print_line("name: "+d.name); - //print_line("description: "+d.description); - - } - - ndevices.push_back(d); - - } - - ea->devices=ndevices; - ea->devices_changed=true; - } - - ea->device_lock->unlock(); - } - - uint64_t wait = 3000000; - uint64_t time = OS::get_singleton()->get_ticks_usec(); - while(OS::get_singleton()->get_ticks_usec() - time < wait ) { - OS::get_singleton()->delay_usec(1000); - if (ea->quit_request) - break; - } - - } - - if (EditorSettings::get_singleton()->get("export/android/shutdown_adb_on_exit")) { - String adb=EditorSettings::get_singleton()->get("export/android/adb"); - if (!FileAccess::exists(adb)) { - return; //adb not configured - } - - List<String> args; - args.push_back("kill-server"); - OS::get_singleton()->execute(adb,args,true); - }; -} - -Error EditorExportPlatformAndroid::run(int p_device, int p_flags) { - - ERR_FAIL_INDEX_V(p_device,devices.size(),ERR_INVALID_PARAMETER); - device_lock->lock(); - - EditorProgress ep("run","Running on "+devices[p_device].name,3); - - String adb=EditorSettings::get_singleton()->get("export/android/adb"); - if (adb=="") { - - EditorNode::add_io_error("ADB executable not configured in settings, can't run."); - device_lock->unlock(); - return ERR_UNCONFIGURED; - } - - //export_temp - ep.step("Exporting APK",0); - - - bool use_adb_over_usb = bool(EDITOR_DEF("export/android/use_remote_debug_over_adb",true)); - - if (use_adb_over_usb) { - p_flags|=EXPORT_REMOTE_DEBUG_LOCALHOST; - } - - String export_to=EditorSettings::get_singleton()->get_settings_path()+"/tmp/tmpexport.apk"; - Error err = export_project(export_to,true,p_flags); - if (err) { - device_lock->unlock(); - return err; - } - - List<String> args; - int rv; - - if (remove_prev) { - ep.step("Uninstalling..",1); - - print_line("Uninstalling previous version: "+devices[p_device].name); - - args.push_back("-s"); - args.push_back(devices[p_device].id); - args.push_back("uninstall"); - args.push_back(get_package_name()); - - err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); -#if 0 - if (err || rv!=0) { - EditorNode::add_io_error("Could not install to device."); - device_lock->unlock(); - return ERR_CANT_CREATE; - } -#endif - } - - print_line("Installing into device (please wait..): "+devices[p_device].name); - ep.step("Installing to Device (please wait..)..",2); - - args.clear(); - args.push_back("-s"); - args.push_back(devices[p_device].id); - args.push_back("install"); - args.push_back("-r"); - args.push_back(export_to); - - err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); - if (err || rv!=0) { - EditorNode::add_io_error("Could not install to device."); - device_lock->unlock(); - return ERR_CANT_CREATE; - } - - if (use_adb_over_usb) { - - args.clear(); - args.push_back("reverse"); - args.push_back("--remove-all"); - err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); - - int port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); - args.clear(); - args.push_back("reverse"); - args.push_back("tcp:"+itos(port)); - args.push_back("tcp:"+itos(port)); - - err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); - print_line("Reverse result: "+itos(rv)); - - int fs_port = EditorSettings::get_singleton()->get("filesystem/file_server/port"); - - args.clear(); - args.push_back("reverse"); - args.push_back("tcp:"+itos(fs_port)); - args.push_back("tcp:"+itos(fs_port)); - - err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); - print_line("Reverse result2: "+itos(rv)); - - } - - - ep.step("Running on Device..",3); - args.clear(); - args.push_back("-s"); - args.push_back(devices[p_device].id); - args.push_back("shell"); - args.push_back("am"); - args.push_back("start"); - args.push_back("--user 0"); - args.push_back("-a"); - args.push_back("android.intent.action.MAIN"); - args.push_back("-n"); - args.push_back(get_package_name()+"/org.godotengine.godot.Godot"); - - err = OS::get_singleton()->execute(adb,args,true,NULL,NULL,&rv); - if (err || rv!=0) { - EditorNode::add_io_error("Could not execute ondevice."); - device_lock->unlock(); - return ERR_CANT_CREATE; - } - device_lock->unlock(); - return OK; -} - -String EditorExportPlatformAndroid::get_package_name() { - - String pname = package; - String basename = ProjectSettings::get_singleton()->get("application/config/name"); - basename=basename.to_lower(); - - String name; - bool first=true; - for(int i=0;i<basename.length();i++) { - CharType c = basename[i]; - if (c>='0' && c<='9' && first) { - continue; - } - if ((c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9')) { - name+=String::chr(c); - first=false; - } - } - if (name=="") - name="noname"; - - pname=pname.replace("$genname",name); - return pname; - -} - -EditorExportPlatformAndroid::EditorExportPlatformAndroid() { - - version_code=1; - version_name="1.0"; - package="org.godotengine.$genname"; - name=""; - _signed=true; - apk_expansion=false; - quit_request=false; - orientation=0; - remove_prev=true; - use_32_fb=true; - immersive=true; - - export_arm=true; - export_arm64=false; - export_x86=false; - - - device_thread=Thread::create(_device_poll_thread,this); - devices_changed=true; - - Image img( _android_logo ); - logo = Ref<ImageTexture>( memnew( ImageTexture )); - logo->create_from_image(img); - - for(int i=0;i<4;i++) - screen_support[i]=true; -} - -bool EditorExportPlatformAndroid::can_export(String *r_error) const { - - bool valid=true; - String adb=EditorSettings::get_singleton()->get("export/android/adb"); - String err; - - if (!FileAccess::exists(adb)) { - - valid=false; - err+="ADB executable not configured in editor settings.\n"; - } - - String js = EditorSettings::get_singleton()->get("export/android/jarsigner"); - - if (!FileAccess::exists(js)) { - - valid=false; - err+="OpenJDK 6 jarsigner not configured in editor settings.\n"; - } - - String dk = EditorSettings::get_singleton()->get("export/android/debug_keystore"); - - if (!FileAccess::exists(dk)) { - - valid=false; - err+="Debug Keystore not configured in editor settings.\n"; - } - - if (!exists_export_template("android_debug.apk") || !exists_export_template("android_release.apk")) { - valid=false; - err+="No export templates found.\nDownload and install export templates.\n"; - } - - if (custom_debug_package!="" && !FileAccess::exists(custom_debug_package)) { - valid=false; - err+="Custom debug package not found.\n"; - } - - if (custom_release_package!="" && !FileAccess::exists(custom_release_package)) { - valid=false; - err+="Custom release package not found.\n"; - } - - if (apk_expansion) { - - /* - if (apk_expansion_salt=="") { - valid=false; - err+="Invalid SALT for apk expansion.\n"; - } - */ - if (apk_expansion_pkey=="") { - valid=false; - err+="Invalid public key for apk expansion.\n"; - } - } - - if (r_error) - *r_error=err; - - return valid; -} - - -EditorExportPlatformAndroid::~EditorExportPlatformAndroid() { - - quit_request=true; - Thread::wait_to_finish(device_thread); - memdelete(device_lock); - memdelete(device_thread); -} - -#endif +#include <string.h> static const char *android_perms[] = { "ACCESS_CHECKIN_PROPERTIES", @@ -2665,37 +809,6 @@ class EditorExportAndroid : public EditorExportPlatform { //print_line("file size: "+itos(ret.size())); p_manifest = ret; - -#if 0 - uint32_t header[9]; - for(int i=0;i<9;i++) { - header[i]=decode_uint32(&p_manifest[i*4]); - } - - //print_line("STO: "+itos(header[3])); - uint32_t st_offset=9*4; - //ERR_FAIL_COND(header[3]!=0x24) - uint32_t string_count=header[4]; - - - string_table.resize(string_count); - - for(int i=0;i<string_count;i++) { - - uint32_t string_at = decode_uint32(&p_manifest[st_offset+i*4]); - string_at+=st_offset+string_count*4; - uint32_t len = decode_uint16(&p_manifest[string_at]); - Vector<CharType> ucstring; - ucstring.resize(len+1); - for(int j=0;j<len;j++) { - uint16_t c=decode_uint16(&p_manifest[string_at+2+2*j]); - ucstring[j]=c; - } - ucstring[len]=0; - string_table[i]=ucstring.ptr(); - } - -#endif } static String _parse_string(const uint8_t *p_bytes, bool p_utf8) { @@ -2991,13 +1104,6 @@ public: args.push_back(get_package_name(package_name)); err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); -#if 0 - if (err || rv!=0) { - EditorNode::add_io_error("Could not install to device."); - device_lock->unlock(); - return ERR_CANT_CREATE; - } -#endif } print_line("Installing into device (please wait..): " + devices[p_device].name); diff --git a/platform/android/export/export.h b/platform/android/export/export.h index e3b0b4aab6..40ce129dcd 100644 --- a/platform/android/export/export.h +++ b/platform/android/export/export.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index be19f056b0..f207b81b4b 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/file_access_android.h b/platform/android/file_access_android.h index 0ee8cd7efe..c2ce2b0bfe 100644 --- a/platform/android/file_access_android.h +++ b/platform/android/file_access_android.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/file_access_jandroid.cpp b/platform/android/file_access_jandroid.cpp index e20ffd4f8a..ad855c790d 100644 --- a/platform/android/file_access_jandroid.cpp +++ b/platform/android/file_access_jandroid.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/file_access_jandroid.h b/platform/android/file_access_jandroid.h index a04f28d0d7..8060312182 100644 --- a/platform/android/file_access_jandroid.h +++ b/platform/android/file_access_jandroid.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/globals/global_defaults.cpp b/platform/android/globals/global_defaults.cpp index 6bdc6b337c..c73b578154 100644 --- a/platform/android/globals/global_defaults.cpp +++ b/platform/android/globals/global_defaults.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/globals/global_defaults.h b/platform/android/globals/global_defaults.h index d524b56af6..8c918414d3 100644 --- a/platform/android/globals/global_defaults.h +++ b/platform/android/globals/global_defaults.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 2dd2c0532a..8235683496 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -565,20 +565,6 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) { case APP_CMD_CONFIG_CHANGED: case APP_CMD_WINDOW_RESIZED: { -#if 0 -// android blows - if (engine->display_active) { - - EGLint w,h; - eglQuerySurface(engine->display, engine->surface, EGL_WIDTH, &w); - eglQuerySurface(engine->display, engine->surface, EGL_HEIGHT, &h); - engine->os->init_video_mode(w,h); - //print_line("RESIZED VIDEO MODE: "+itos(w)+","+itos(h)); - engine_draw_frame(engine); - - } -#else - if (engine->display_active) { EGLint w, h; @@ -594,17 +580,6 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) { engine_draw_frame(engine); engine->animating = 1; -/* - EGLint w,h; - eglQuerySurface(engine->display, engine->surface, EGL_WIDTH, &w); - eglQuerySurface(engine->display, engine->surface, EGL_HEIGHT, &h); - engine->os->init_video_mode(w,h); - //print_line("RESIZED VIDEO MODE: "+itos(w)+","+itos(h)); - - }*/ - -#endif - } break; case APP_CMD_INIT_WINDOW: //The window is being shown, get it ready. @@ -617,9 +592,7 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) { engine->os = new OS_Android(_gfx_init, engine); __android_log_print(ANDROID_LOG_INFO, "godot", "pre asdasd setup..."); -#if 0 - Error err = Main::setup("apk",2,args); -#else + Error err = Main::setup("apk", 0, NULL); String modules = ProjectSettings::get_singleton()->get("android/modules"); @@ -669,8 +642,6 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) { } } -#endif - if (!Main::start()) return; //should exit instead and print the error diff --git a/platform/android/java/src/org/godotengine/godot/Dictionary.java b/platform/android/java/src/org/godotengine/godot/Dictionary.java index b9501e0858..ed91fedd85 100644 --- a/platform/android/java/src/org/godotengine/godot/Dictionary.java +++ b/platform/android/java/src/org/godotengine/godot/Dictionary.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index d444d37c2f..eab0387f32 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java index 6cdc6be793..2c668dd586 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java +++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderAlarmReceiver.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java index 38d30c108c..97ba7826fb 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java +++ b/platform/android/java/src/org/godotengine/godot/GodotDownloaderService.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java index ecb623452c..989fd2b609 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/GodotLib.java b/platform/android/java/src/org/godotengine/godot/GodotLib.java index 98ac29d3ca..b487c17f53 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/src/org/godotengine/godot/GodotLib.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java index 3cb8fd3da8..a16c67523e 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java +++ b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/GodotView.java b/platform/android/java/src/org/godotengine/godot/GodotView.java index 752d9d501c..19fcf8e687 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotView.java +++ b/platform/android/java/src/org/godotengine/godot/GodotView.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java b/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java index bf5239aa77..d8a3ac5591 100644 --- a/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java +++ b/platform/android/java/src/org/godotengine/godot/input/GodotEditText.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java index 1dbcb78ada..c2d03e4ecc 100644 --- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java +++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java index c37821ffd9..8622f4ccff 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/ConsumeTask.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java index 72126a8f64..0afe35510c 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/GenericConsumeTask.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java index e223bbb8c0..7318ae2fc6 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/HandlePurchaseTask.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java index fa5564a3f4..69ac02e902 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java +++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsCache.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java index 6f308af360..b327265abb 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java +++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java index 81352b0cf4..6ecea0106c 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/PurchaseTask.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java index 9d40371b9b..d831e45694 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/ReleaseAllConsumablesTask.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java index 09f80df403..6e058c140c 100644 --- a/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java +++ b/platform/android/java/src/org/godotengine/godot/payments/ValidateTask.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/utils/Crypt.java b/platform/android/java/src/org/godotengine/godot/utils/Crypt.java index 02a2fba854..2fd66553f6 100644 --- a/platform/android/java/src/org/godotengine/godot/utils/Crypt.java +++ b/platform/android/java/src/org/godotengine/godot/utils/Crypt.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java b/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java index 7881754fb2..c9532a5d01 100644 --- a/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java +++ b/platform/android/java/src/org/godotengine/godot/utils/CustomSSLSocketFactory.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java index b314fb721b..0711f30b8b 100644 --- a/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java +++ b/platform/android/java/src/org/godotengine/godot/utils/HttpRequester.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java b/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java index 41d26ba70f..ded11550bb 100644 --- a/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java +++ b/platform/android/java/src/org/godotengine/godot/utils/RequestParams.java @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java_class_wrapper.cpp b/platform/android/java_class_wrapper.cpp index ffd9150ba4..8606ea41a0 100644 --- a/platform/android/java_class_wrapper.cpp +++ b/platform/android/java_class_wrapper.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java_class_wrapper.h b/platform/android/java_class_wrapper.h index f990708bdf..1274b4bea9 100644 --- a/platform/android/java_class_wrapper.h +++ b/platform/android/java_class_wrapper.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index eb139fb471..9abaae0a75 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -866,13 +866,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en __android_log_print(ANDROID_LOG_INFO, "godot", "**SETUP"); -#if 0 - char *args[]={"--test","render",NULL}; - __android_log_print(ANDROID_LOG_INFO,"godot","pre asdasd setup..."); - Error err = Main::setup("apk",2,args,false); -#else Error err = Main::setup("apk", cmdlen, (char **)cmdline, false); -#endif if (err != OK) { __android_log_print(ANDROID_LOG_INFO, "godot", "*****UNABLE TO SETUP"); diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h index dd62cb2431..64970040f8 100644 --- a/platform/android/java_glue.h +++ b/platform/android/java_glue.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index a027e78de9..1de2608b9e 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -146,7 +146,6 @@ void OS_Android::initialize(const VideoMode &p_desired, int p_video_driver, int physics_server = memnew(PhysicsServerSW); physics_server->init(); - //physics_2d_server = memnew( Physics2DServerSW ); physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>(); physics_2d_server->init(); @@ -160,43 +159,6 @@ void OS_Android::set_main_loop(MainLoop *p_main_loop) { main_loop = p_main_loop; input->set_main_loop(p_main_loop); -#if 0 - - print_line("preGS"); - FileAccess *f=memnew( FileAccessAndroid ); - print("made f %p\n",f); - Error err = f->open("AndroidManifest.xml",FileAccess::READ); - if (err) { - - print("************NO FILE!!\n"); - } else { - print("************YES FILE!!\n"); - } - f->close(); - print_line("end"); - - - AAssetDir* aad = AAssetManager_openDir(FileAccessAndroid::asset_manager,"."); - - if (aad) { - - print_line("DIR OPEN OK"); - - const char *fn= AAssetDir_getNextFileName(aad); - - while(fn) { - - print_line("FNAME: "+String(fn)); - fn= AAssetDir_getNextFileName(aad); - } - - AAssetDir_close(aad); - } else { - - print_line("DIR NO OPEN"); - } - -#endif } void OS_Android::delete_main_loop() { diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 54d7e562e0..119c14bff3 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -110,11 +110,8 @@ private: mutable String data_dir_cache; -#if 0 - AudioDriverAndroid audio_driver_android; -#else + //AudioDriverAndroid audio_driver_android; AudioDriverOpenSL audio_driver_android; -#endif const char *gl_extensions; diff --git a/platform/android/platform_config.h b/platform/android/platform_config.h index 48bcadcc29..b1c3f027f3 100644 --- a/platform/android/platform_config.h +++ b/platform/android/platform_config.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/power_android.cpp b/platform/android/power_android.cpp index bb5a1db250..98d4d810b9 100644 --- a/platform/android/power_android.cpp +++ b/platform/android/power_android.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/power_android.h b/platform/android/power_android.h index 328a4506a1..fc618c660d 100644 --- a/platform/android/power_android.h +++ b/platform/android/power_android.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp index 924ae3fe43..9e2e5452ca 100644 --- a/platform/android/thread_jandroid.cpp +++ b/platform/android/thread_jandroid.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/android/thread_jandroid.h b/platform/android/thread_jandroid.h index 5267329744..bacc1ce435 100644 --- a/platform/android/thread_jandroid.h +++ b/platform/android/thread_jandroid.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp index 802f6b2d32..4d8d580660 100644 --- a/platform/haiku/audio_driver_media_kit.cpp +++ b/platform/haiku/audio_driver_media_kit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/audio_driver_media_kit.h b/platform/haiku/audio_driver_media_kit.h index 2cceb279e8..2f4752a973 100644 --- a/platform/haiku/audio_driver_media_kit.h +++ b/platform/haiku/audio_driver_media_kit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/context_gl_haiku.cpp b/platform/haiku/context_gl_haiku.cpp index eb5e60152f..2b943df5ba 100644 --- a/platform/haiku/context_gl_haiku.cpp +++ b/platform/haiku/context_gl_haiku.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/context_gl_haiku.h b/platform/haiku/context_gl_haiku.h index 074b4bf0d1..40daf43ab9 100644 --- a/platform/haiku/context_gl_haiku.h +++ b/platform/haiku/context_gl_haiku.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/godot_haiku.cpp b/platform/haiku/godot_haiku.cpp index 3a8206d9d5..ffc6e56cdd 100644 --- a/platform/haiku/godot_haiku.cpp +++ b/platform/haiku/godot_haiku.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/haiku_application.cpp b/platform/haiku/haiku_application.cpp index 1f0c9fdcbf..d23b9e27d8 100644 --- a/platform/haiku/haiku_application.cpp +++ b/platform/haiku/haiku_application.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/haiku_application.h b/platform/haiku/haiku_application.h index 6e690d4ab8..2162cae892 100644 --- a/platform/haiku/haiku_application.h +++ b/platform/haiku/haiku_application.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 4a9f8c780d..572df493ff 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index 3671c3c9cb..0f3e9de85b 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/haiku_gl_view.cpp b/platform/haiku/haiku_gl_view.cpp index dd568f281e..d898bd1a5d 100644 --- a/platform/haiku/haiku_gl_view.cpp +++ b/platform/haiku/haiku_gl_view.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/haiku_gl_view.h b/platform/haiku/haiku_gl_view.h index 14e2889d6c..10facfe0c3 100644 --- a/platform/haiku/haiku_gl_view.h +++ b/platform/haiku/haiku_gl_view.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/key_mapping_haiku.cpp b/platform/haiku/key_mapping_haiku.cpp index 3db31fa3e4..074f03f471 100644 --- a/platform/haiku/key_mapping_haiku.cpp +++ b/platform/haiku/key_mapping_haiku.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/key_mapping_haiku.h b/platform/haiku/key_mapping_haiku.h index 8d09203737..943ba21e7c 100644 --- a/platform/haiku/key_mapping_haiku.h +++ b/platform/haiku/key_mapping_haiku.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index e897d4c385..de2f79a0ac 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -27,16 +27,15 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include <Screen.h> +#include "os_haiku.h" -#include "drivers/gles2/rasterizer_gles2.h" +#include "drivers/gles3/rasterizer_gles3.h" +#include "main/main.h" #include "servers/physics/physics_server_sw.h" #include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" -//#include "servers/physics_2d/physics_2d_server_wrap_mt.h" -#include "main/main.h" -#include "os_haiku.h" +#include <Screen.h> OS_Haiku::OS_Haiku() { #ifdef MEDIA_KIT_ENABLED diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 4440f2843d..cb68f9303f 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/platform_config.h b/platform/haiku/platform_config.h index e59b9bac80..27731a7b74 100644 --- a/platform/haiku/platform_config.h +++ b/platform/haiku/platform_config.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/power_haiku.cpp b/platform/haiku/power_haiku.cpp index b0d01df982..449b43a621 100644 --- a/platform/haiku/power_haiku.cpp +++ b/platform/haiku/power_haiku.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/haiku/power_haiku.h b/platform/haiku/power_haiku.h index 711ad86a02..12513bdaef 100644 --- a/platform/haiku/power_haiku.h +++ b/platform/haiku/power_haiku.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/app_delegate.h b/platform/iphone/app_delegate.h index f357427144..4a1f52565a 100644 --- a/platform/iphone/app_delegate.h +++ b/platform/iphone/app_delegate.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 362cfd1478..c7b65b476b 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/audio_driver_iphone.cpp b/platform/iphone/audio_driver_iphone.cpp index d8374147c8..dbc5bdb654 100644 --- a/platform/iphone/audio_driver_iphone.cpp +++ b/platform/iphone/audio_driver_iphone.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/audio_driver_iphone.h b/platform/iphone/audio_driver_iphone.h index c620e9068c..930ed168f7 100644 --- a/platform/iphone/audio_driver_iphone.h +++ b/platform/iphone/audio_driver_iphone.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 1d802ff288..0b81422fa3 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -13,7 +13,7 @@ def get_name(): def can_build(): - if sys.platform == 'darwin' or os.environ.has_key("OSXCROSS_IOS"): + if sys.platform == 'darwin' or ("OSXCROSS_IOS" in os.environ): return True return False @@ -83,11 +83,11 @@ def configure(env): if (env["arch"] == "x86"): env['IPHONEPLATFORM'] = 'iPhoneSimulator' env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.6' - env.Append(CCFLAGS=string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"')) + env.Append(CCFLAGS='-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $IPHONESDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"'.split()) elif (env["arch"] == "arm"): - env.Append(CCFLAGS=string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=9.0 -MMD -MT dependencies')) + env.Append(CCFLAGS='-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=9.0 -MMD -MT dependencies'.split()) elif (env["arch"] == "arm64"): - env.Append(CCFLAGS=string.split('-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=9.0 -isysroot $IPHONESDK')) + env.Append(CCFLAGS='-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=9.0 -isysroot $IPHONESDK'.split()) env.Append(CPPFLAGS=['-DNEED_LONG_INT']) env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 6ae2a0692d..8bb7f23ead 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/export/export.h b/platform/iphone/export/export.h index 6e9324aed7..1b96b8338a 100644 --- a/platform/iphone/export/export.h +++ b/platform/iphone/export/export.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/game_center.h b/platform/iphone/game_center.h index cda6f78a1f..c0a7830fe9 100644 --- a/platform/iphone/game_center.h +++ b/platform/iphone/game_center.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/game_center.mm b/platform/iphone/game_center.mm index f9bc70b7c4..c05bdea005 100644 --- a/platform/iphone/game_center.mm +++ b/platform/iphone/game_center.mm @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/gl_view.h b/platform/iphone/gl_view.h index 14e9a66a4a..a9fd8d5711 100644 --- a/platform/iphone/gl_view.h +++ b/platform/iphone/gl_view.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index f2778e8165..3e206c3a2c 100644 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/globals/global_defaults.cpp b/platform/iphone/globals/global_defaults.cpp index aa4662302d..4bdc716d6e 100644 --- a/platform/iphone/globals/global_defaults.cpp +++ b/platform/iphone/globals/global_defaults.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/globals/global_defaults.h b/platform/iphone/globals/global_defaults.h index 6fe1027287..ee8ae833b9 100644 --- a/platform/iphone/globals/global_defaults.h +++ b/platform/iphone/globals/global_defaults.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/godot_iphone.cpp b/platform/iphone/godot_iphone.cpp index 4d34ebedf9..8c6d6d8da4 100644 --- a/platform/iphone/godot_iphone.cpp +++ b/platform/iphone/godot_iphone.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/icloud.h b/platform/iphone/icloud.h index 67d12a990a..7ab3e04bb8 100644 --- a/platform/iphone/icloud.h +++ b/platform/iphone/icloud.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/icloud.mm b/platform/iphone/icloud.mm index 94c3d2ef91..84458ed79f 100644 --- a/platform/iphone/icloud.mm +++ b/platform/iphone/icloud.mm @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/in_app_store.h b/platform/iphone/in_app_store.h index 153c46bd7b..4c12f825c1 100644 --- a/platform/iphone/in_app_store.h +++ b/platform/iphone/in_app_store.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index 710df0f757..9efd4b9891 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/ios.h b/platform/iphone/ios.h index 2572d626d2..0c2e6b4aa6 100644 --- a/platform/iphone/ios.h +++ b/platform/iphone/ios.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/ios.mm b/platform/iphone/ios.mm index 6c95903241..add0949f94 100644 --- a/platform/iphone/ios.mm +++ b/platform/iphone/ios.mm @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/main.m b/platform/iphone/main.m index 6757cc8146..0de5c3b41b 100644 --- a/platform/iphone/main.m +++ b/platform/iphone/main.m @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index df497349ae..0e3eeed114 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index cf2766bb33..475dceebf2 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -47,7 +47,6 @@ #include "servers/visual_server.h" class AudioDriverIphone; -// class RasterizerGLES2; class OSIPhone : public OS_Unix { @@ -67,9 +66,6 @@ private: uint8_t supported_orientations; - // Rasterizer *rasterizer; - // RasterizerGLES2* rasterizer_gles22; - VisualServer *visual_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; diff --git a/platform/iphone/platform_config.h b/platform/iphone/platform_config.h index 7e4b533254..54de66082e 100644 --- a/platform/iphone/platform_config.h +++ b/platform/iphone/platform_config.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/platform_refcount.h b/platform/iphone/platform_refcount.h index c02e709ea1..8d04340793 100644 --- a/platform/iphone/platform_refcount.h +++ b/platform/iphone/platform_refcount.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/power_iphone.cpp b/platform/iphone/power_iphone.cpp index 5192f8e593..2811e62108 100644 --- a/platform/iphone/power_iphone.cpp +++ b/platform/iphone/power_iphone.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/power_iphone.h b/platform/iphone/power_iphone.h index 174ee6c63b..b4fb8d62dc 100644 --- a/platform/iphone/power_iphone.h +++ b/platform/iphone/power_iphone.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/sem_iphone.cpp b/platform/iphone/sem_iphone.cpp index 4614b201a4..623749f891 100644 --- a/platform/iphone/sem_iphone.cpp +++ b/platform/iphone/sem_iphone.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/sem_iphone.h b/platform/iphone/sem_iphone.h index 90db0fb74d..9ae201557f 100644 --- a/platform/iphone/sem_iphone.h +++ b/platform/iphone/sem_iphone.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/view_controller.h b/platform/iphone/view_controller.h index 57ed576c25..ed33e5fdf3 100644 --- a/platform/iphone/view_controller.h +++ b/platform/iphone/view_controller.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/iphone/view_controller.mm b/platform/iphone/view_controller.mm index 921ef8f607..23d60cc5d5 100644 --- a/platform/iphone/view_controller.mm +++ b/platform/iphone/view_controller.mm @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/audio_driver_javascript.cpp b/platform/javascript/audio_driver_javascript.cpp index 3e37ec293e..4c0e5fd966 100644 --- a/platform/javascript/audio_driver_javascript.cpp +++ b/platform/javascript/audio_driver_javascript.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/audio_driver_javascript.h b/platform/javascript/audio_driver_javascript.h index 7ccaff0f43..c5cebe800f 100644 --- a/platform/javascript/audio_driver_javascript.h +++ b/platform/javascript/audio_driver_javascript.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/audio_server_javascript.cpp b/platform/javascript/audio_server_javascript.cpp index f9b7890e12..ab9f66ce5b 100644 --- a/platform/javascript/audio_server_javascript.cpp +++ b/platform/javascript/audio_server_javascript.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_server_javascript.h" + +// FIXME: Needs to be ported to the new AudioServer API in 3.0 #if 0 #include "emscripten.h" diff --git a/platform/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h index 58c240f793..0773459f56 100644 --- a/platform/javascript/audio_server_javascript.h +++ b/platform/javascript/audio_server_javascript.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -29,6 +29,8 @@ /*************************************************************************/ #ifndef AUDIO_SERVER_JAVASCRIPT_H #define AUDIO_SERVER_JAVASCRIPT_H + +// FIXME: Needs to be ported to the new AudioServer API in 3.0 #if 0 #include "servers/audio_server.h" diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 68c8d1eea5..5f066f1b15 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -13,7 +13,7 @@ def get_name(): def can_build(): - return (os.environ.has_key("EMSCRIPTEN_ROOT")) + return ("EMSCRIPTEN_ROOT" in os.environ) def get_opts(): diff --git a/platform/javascript/dom_keys.h b/platform/javascript/dom_keys.h index 4b8b764c45..d63f165382 100644 --- a/platform/javascript/dom_keys.h +++ b/platform/javascript/dom_keys.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index b436d52363..5a161dd0ab 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/export/export.h b/platform/javascript/export/export.h index 910c4119f7..0cea0a213b 100644 --- a/platform/javascript/export/export.h +++ b/platform/javascript/export/export.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp index c9312e8d30..74f8d80a76 100644 --- a/platform/javascript/javascript_eval.cpp +++ b/platform/javascript/javascript_eval.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/javascript_eval.h b/platform/javascript/javascript_eval.h index 4a732cec76..ed7cf383da 100644 --- a/platform/javascript/javascript_eval.h +++ b/platform/javascript/javascript_eval.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index 6b1d574496..4c948bf181 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index f49acb04de..a0e5610591 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index ff484204c7..f78a3f2768 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/platform_config.h b/platform/javascript/platform_config.h index 48bcadcc29..b1c3f027f3 100644 --- a/platform/javascript/platform_config.h +++ b/platform/javascript/platform_config.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/power_javascript.cpp b/platform/javascript/power_javascript.cpp index bd4502fc2a..3d54146595 100644 --- a/platform/javascript/power_javascript.cpp +++ b/platform/javascript/power_javascript.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/javascript/power_javascript.h b/platform/javascript/power_javascript.h index c7b853ce11..834d765557 100644 --- a/platform/javascript/power_javascript.h +++ b/platform/javascript/power_javascript.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp index da5cd8f65e..8c5a734f76 100644 --- a/platform/osx/audio_driver_osx.cpp +++ b/platform/osx/audio_driver_osx.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/audio_driver_osx.h b/platform/osx/audio_driver_osx.h index 4576100690..ac178b89f3 100644 --- a/platform/osx/audio_driver_osx.h +++ b/platform/osx/audio_driver_osx.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 661da6e7c1..d3ebdfe992 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -12,7 +12,7 @@ def get_name(): def can_build(): - if (sys.platform == "darwin" or os.environ.has_key("OSXCROSS_ROOT")): + if (sys.platform == "darwin" or ("OSXCROSS_ROOT" in os.environ)): return True return False diff --git a/platform/osx/dir_access_osx.h b/platform/osx/dir_access_osx.h index 6dcff3898c..c988dfe425 100644 --- a/platform/osx/dir_access_osx.h +++ b/platform/osx/dir_access_osx.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm index 37ba0e6b19..6e8ceb5e19 100644 --- a/platform/osx/dir_access_osx.mm +++ b/platform/osx/dir_access_osx.mm @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 03f424de8d..7f749030ec 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/export/export.h b/platform/osx/export/export.h index 50604f068f..bb87c8a6b7 100644 --- a/platform/osx/export/export.h +++ b/platform/osx/export/export.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/godot_main_osx.mm b/platform/osx/godot_main_osx.mm index 0bf678f9b7..83d782cc2f 100644 --- a/platform/osx/godot_main_osx.mm +++ b/platform/osx/godot_main_osx.mm @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp index 96c660ad1d..ab323ad410 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/joypad_osx.h b/platform/osx/joypad_osx.h index bfbc523cff..e271f4b947 100644 --- a/platform/osx/joypad_osx.h +++ b/platform/osx/joypad_osx.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 827114cd2b..5bfed1ee50 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index a0fc53d517..f1260bc088 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/platform_config.h b/platform/osx/platform_config.h index 487077e651..d2474fcfc7 100644 --- a/platform/osx/platform_config.h +++ b/platform/osx/platform_config.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/power_osx.cpp b/platform/osx/power_osx.cpp index 2ef1a65ff1..24591e48b1 100644 --- a/platform/osx/power_osx.cpp +++ b/platform/osx/power_osx.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/power_osx.h b/platform/osx/power_osx.h index 6d984ec466..692c850d7c 100644 --- a/platform/osx/power_osx.h +++ b/platform/osx/power_osx.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/sem_osx.cpp b/platform/osx/sem_osx.cpp index b1eeccfec5..f75ac181bf 100644 --- a/platform/osx/sem_osx.cpp +++ b/platform/osx/sem_osx.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/osx/sem_osx.h b/platform/osx/sem_osx.h index 3025318c4b..2b408b00de 100644 --- a/platform/osx/sem_osx.h +++ b/platform/osx/sem_osx.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/server/godot_server.cpp b/platform/server/godot_server.cpp index ed0100ac93..2fd8c315de 100644 --- a/platform/server/godot_server.cpp +++ b/platform/server/godot_server.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 89af785d29..44034e815d 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/server/os_server.h b/platform/server/os_server.h index 7c29b1e232..f3db053be3 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/server/platform_config.h b/platform/server/platform_config.h index 48bcadcc29..b1c3f027f3 100644 --- a/platform/server/platform_config.h +++ b/platform/server/platform_config.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp index 8824d1c1d0..c565999d82 100644 --- a/platform/uwp/app.cpp +++ b/platform/uwp/app.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/app.h b/platform/uwp/app.h index 9cbe7669c9..e079fa9c9d 100644 --- a/platform/uwp/app.h +++ b/platform/uwp/app.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py index 64dac93f1f..23929dd804 100644 --- a/platform/uwp/detect.py +++ b/platform/uwp/detect.py @@ -145,8 +145,8 @@ def configure(env): env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/store/references']) env.Append(CPPFLAGS=['/AI', vc_base_path + 'lib/x86/store/references']) - env.Append(CCFLAGS=string.split('/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP" /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo')) - env.Append(CXXFLAGS=string.split('/ZW /FS')) + env.Append(CCFLAGS='/FS /MP /GS /wd"4453" /wd"28204" /wd"4291" /Zc:wchar_t /Gm- /fp:precise /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP" /errorReport:prompt /WX- /Zc:forScope /Gd /EHsc /nologo'.split()) + env.Append(CXXFLAGS='/ZW /FS'.split()) env.Append(CCFLAGS=['/AI', vc_base_path + '\\vcpackages', '/AI', os.environ['WINDOWSSDKDIR'] + '\\References\\CommonConfiguration\\Neutral']) ## Link flags diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 547eb96468..c129743507 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/export/export.h b/platform/uwp/export/export.h index 81bd848241..558af38a70 100644 --- a/platform/uwp/export/export.h +++ b/platform/uwp/export/export.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/gl_context_egl.cpp b/platform/uwp/gl_context_egl.cpp index 57c4c5d572..dd186c97d6 100644 --- a/platform/uwp/gl_context_egl.cpp +++ b/platform/uwp/gl_context_egl.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/gl_context_egl.h b/platform/uwp/gl_context_egl.h index 908b8dceec..1b24780b29 100644 --- a/platform/uwp/gl_context_egl.h +++ b/platform/uwp/gl_context_egl.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp index f3d4eb99c8..0f84bd55a3 100644 --- a/platform/uwp/joypad_uwp.cpp +++ b/platform/uwp/joypad_uwp.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -54,7 +54,7 @@ void JoypadUWP::process_controllers() { case ControllerType::GAMEPAD_CONTROLLER: { - GamepadReading reading = ((Gamepad ^) joy.controller_reference)->GetCurrentReading(); + GamepadReading reading = ((Gamepad ^)joy.controller_reference)->GetCurrentReading(); int button_mask = (int)GamepadButtons::Menu; for (int j = 0; j < 14; j++) { @@ -161,7 +161,7 @@ void JoypadUWP::joypad_vibration_start(int p_device, float p_weak_magnitude, flo GamepadVibration vibration; vibration.LeftMotor = p_strong_magnitude; vibration.RightMotor = p_weak_magnitude; - ((Gamepad ^) joy.controller_reference)->Vibration = vibration; + ((Gamepad ^)joy.controller_reference)->Vibration = vibration; joy.ff_timestamp = p_timestamp; joy.ff_end_timestamp = p_duration == 0 ? 0 : p_timestamp + (uint64_t)(p_duration * 1000000.0); @@ -175,7 +175,7 @@ void JoypadUWP::joypad_vibration_stop(int p_device, uint64_t p_timestamp) { GamepadVibration vibration; vibration.LeftMotor = 0.0; vibration.RightMotor = 0.0; - ((Gamepad ^) joy.controller_reference)->Vibration = vibration; + ((Gamepad ^)joy.controller_reference)->Vibration = vibration; joy.ff_timestamp = p_timestamp; joy.vibrating = false; diff --git a/platform/uwp/joypad_uwp.h b/platform/uwp/joypad_uwp.h index c55e1e7ab7..4efec485fa 100644 --- a/platform/uwp/joypad_uwp.h +++ b/platform/uwp/joypad_uwp.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index fabb227bf5..3a8932aae2 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index dfa21a0934..5f36396017 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/platform_config.h b/platform/uwp/platform_config.h index 77d2c9cadb..abe14f7578 100644 --- a/platform/uwp/platform_config.h +++ b/platform/uwp/platform_config.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/power_uwp.cpp b/platform/uwp/power_uwp.cpp index ece07f84ad..07a726647d 100644 --- a/platform/uwp/power_uwp.cpp +++ b/platform/uwp/power_uwp.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/power_uwp.h b/platform/uwp/power_uwp.h index c23d712980..9a9811a4f5 100644 --- a/platform/uwp/power_uwp.h +++ b/platform/uwp/power_uwp.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/thread_uwp.cpp b/platform/uwp/thread_uwp.cpp index 0549a8ed47..7c8c2b204a 100644 --- a/platform/uwp/thread_uwp.cpp +++ b/platform/uwp/thread_uwp.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/uwp/thread_uwp.h b/platform/uwp/thread_uwp.h index b8cccfb7c3..0446bd36ca 100644 --- a/platform/uwp/thread_uwp.h +++ b/platform/uwp/thread_uwp.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index f8aed0ccab..328b987f1f 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/context_gl_win.h b/platform/windows/context_gl_win.h index b3cab7806d..912d4d0133 100644 --- a/platform/windows/context_gl_win.h +++ b/platform/windows/context_gl_win.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/ctxgl_procaddr.cpp b/platform/windows/ctxgl_procaddr.cpp index e01c3fc252..c0c900acca 100644 --- a/platform/windows/ctxgl_procaddr.cpp +++ b/platform/windows/ctxgl_procaddr.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/ctxgl_procaddr.h b/platform/windows/ctxgl_procaddr.h index ecef01aadf..61fa6d7fbd 100644 --- a/platform/windows/ctxgl_procaddr.h +++ b/platform/windows/ctxgl_procaddr.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index 6cb33e2ff0..5301aa9e95 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/export/export.h b/platform/windows/export/export.h index ea9113c674..cc85339312 100644 --- a/platform/windows/export/export.h +++ b/platform/windows/export/export.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/godot_win.cpp b/platform/windows/godot_win.cpp index 6f1fb04706..d2ac6ecb50 100644 --- a/platform/windows/godot_win.cpp +++ b/platform/windows/godot_win.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp index e8a5084daf..cde72c98c9 100644 --- a/platform/windows/joypad.cpp +++ b/platform/windows/joypad.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/joypad.h b/platform/windows/joypad.h index 7cd791e78f..059c577bb6 100644 --- a/platform/windows/joypad.h +++ b/platform/windows/joypad.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/key_mapping_win.cpp b/platform/windows/key_mapping_win.cpp index 83e2af72b2..57f8e965de 100644 --- a/platform/windows/key_mapping_win.cpp +++ b/platform/windows/key_mapping_win.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/key_mapping_win.h b/platform/windows/key_mapping_win.h index af91676dff..139f047d17 100644 --- a/platform/windows/key_mapping_win.h +++ b/platform/windows/key_mapping_win.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/lang_table.h b/platform/windows/lang_table.h index 7cf2bb391b..d54894afce 100644 --- a/platform/windows/lang_table.h +++ b/platform/windows/lang_table.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index db453a5f46..7b12482383 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index deb1ae0982..01d904a4cc 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp index 3991a90423..d414ec891e 100644 --- a/platform/windows/packet_peer_udp_winsock.cpp +++ b/platform/windows/packet_peer_udp_winsock.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/packet_peer_udp_winsock.h b/platform/windows/packet_peer_udp_winsock.h index 01f2e5113f..8a6951fd6e 100644 --- a/platform/windows/packet_peer_udp_winsock.h +++ b/platform/windows/packet_peer_udp_winsock.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/platform_config.h b/platform/windows/platform_config.h index a0fc65ca89..832504b9c5 100644 --- a/platform/windows/platform_config.h +++ b/platform/windows/platform_config.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/power_windows.cpp b/platform/windows/power_windows.cpp index 428bc5dcc2..b37e189a3a 100644 --- a/platform/windows/power_windows.cpp +++ b/platform/windows/power_windows.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/power_windows.h b/platform/windows/power_windows.h index 164f1d7d95..9da9841f48 100644 --- a/platform/windows/power_windows.h +++ b/platform/windows/power_windows.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/stream_peer_winsock.cpp b/platform/windows/stream_peer_winsock.cpp index 18c5a40b80..a9d9cb9373 100644 --- a/platform/windows/stream_peer_winsock.cpp +++ b/platform/windows/stream_peer_winsock.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/stream_peer_winsock.h b/platform/windows/stream_peer_winsock.h index aa60a6500b..26e2a3e4c9 100644 --- a/platform/windows/stream_peer_winsock.h +++ b/platform/windows/stream_peer_winsock.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/tcp_server_winsock.cpp b/platform/windows/tcp_server_winsock.cpp index cc17c8a631..de300befa7 100644 --- a/platform/windows/tcp_server_winsock.cpp +++ b/platform/windows/tcp_server_winsock.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/windows/tcp_server_winsock.h b/platform/windows/tcp_server_winsock.h index 077acb94d7..a3e01098ed 100644 --- a/platform/windows/tcp_server_winsock.h +++ b/platform/windows/tcp_server_winsock.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index 563f7db5c3..0cc9734119 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/context_gl_x11.h b/platform/x11/context_gl_x11.h index acb3f38894..ba01b51d59 100644 --- a/platform/x11/context_gl_x11.h +++ b/platform/x11/context_gl_x11.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/export/export.cpp b/platform/x11/export/export.cpp index c8d6220aed..59b1a44247 100644 --- a/platform/x11/export/export.cpp +++ b/platform/x11/export/export.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "export.h" + #include "editor/editor_export.h" #include "platform/x11/logo.gen.h" #include "scene/resources/texture.h" @@ -51,23 +52,4 @@ void register_x11_exporter() { platform->set_os_name("X11"); EditorExport::get_singleton()->add_export_platform(platform); - -#if 0 - Image img(_x11_logo); - Ref<ImageTexture> logo = memnew( ImageTexture ); - logo->create_from_image(img); - - { - Ref<EditorExportPlatformPC> exporter = Ref<EditorExportPlatformPC>( memnew(EditorExportPlatformPC) ); - exporter->set_binary_extension(""); - exporter->set_release_binary32("linux_x11_32_release"); - exporter->set_debug_binary32("linux_x11_32_debug"); - exporter->set_release_binary64("linux_x11_64_release"); - exporter->set_debug_binary64("linux_x11_64_debug"); - exporter->set_name("Linux X11"); - exporter->set_logo(logo); - EditorImportExport::get_singleton()->add_export_platform(exporter); - } - -#endif } diff --git a/platform/x11/export/export.h b/platform/x11/export/export.h index 755b73d2c9..b70633266f 100644 --- a/platform/x11/export/export.h +++ b/platform/x11/export/export.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/godot_x11.cpp b/platform/x11/godot_x11.cpp index f02f3cb881..2e43613e5d 100644 --- a/platform/x11/godot_x11.cpp +++ b/platform/x11/godot_x11.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp index 2502b2d51f..3453297716 100644 --- a/platform/x11/joypad_linux.cpp +++ b/platform/x11/joypad_linux.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/joypad_linux.h b/platform/x11/joypad_linux.h index 55383885a0..b34d98b77a 100644 --- a/platform/x11/joypad_linux.h +++ b/platform/x11/joypad_linux.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/key_mapping_x11.cpp b/platform/x11/key_mapping_x11.cpp index 32a9806b22..95ac2fe6b6 100644 --- a/platform/x11/key_mapping_x11.cpp +++ b/platform/x11/key_mapping_x11.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/key_mapping_x11.h b/platform/x11/key_mapping_x11.h index 41060c9303..7b11cb5ccc 100644 --- a/platform/x11/key_mapping_x11.h +++ b/platform/x11/key_mapping_x11.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 8332b2f51c..2d33d25773 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -1601,8 +1601,7 @@ void OS_X11::process_xevents() { Point2i pos(event.xmotion.x, event.xmotion.y); if (mouse_mode == MOUSE_MODE_CAPTURED) { -#if 1 - //Vector2 c = Point2i(current_videomode.width/2,current_videomode.height/2); + if (pos == Point2i(current_videomode.width / 2, current_videomode.height / 2)) { //this sucks, it's a hack, etc and is a little inaccurate, etc. //but nothing I can do, X11 sucks. @@ -1615,17 +1614,6 @@ void OS_X11::process_xevents() { pos = last_mouse_pos + (pos - center); center = new_center; do_mouse_warp = window_has_focus; // warp the cursor if we're focused in -#else - //Dear X11, thanks for making my life miserable - - center.x = current_videomode.width / 2; - center.y = current_videomode.height / 2; - pos = last_mouse_pos + (pos - center); - if (pos == last_mouse_pos) - break; - XWarpPointer(x11_display, None, x11_window, - 0, 0, 0, 0, (int)center.x, (int)center.y); -#endif } if (!last_mouse_pos_valid) { diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 497ce1dde2..51240fa023 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/platform_config.h b/platform/x11/platform_config.h index 1a1de42b47..85af12372f 100644 --- a/platform/x11/platform_config.h +++ b/platform/x11/platform_config.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/power_x11.cpp b/platform/x11/power_x11.cpp index 72fa5cf380..32100354a6 100644 --- a/platform/x11/power_x11.cpp +++ b/platform/x11/power_x11.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/platform/x11/power_x11.h b/platform/x11/power_x11.h index 64ed5fe26a..e34223036d 100644 --- a/platform/x11/power_x11.h +++ b/platform/x11/power_x11.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 366c3a8bd8..26241df660 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h index 80defac079..6c660d0381 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 8f405dd314..1124904963 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index 12d71f3911..c56cf651a1 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp index 44bee20d0a..2858ddaad5 100644 --- a/scene/2d/back_buffer_copy.cpp +++ b/scene/2d/back_buffer_copy.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/back_buffer_copy.h b/scene/2d/back_buffer_copy.h index 4080f50696..2424dd7b19 100644 --- a/scene/2d/back_buffer_copy.h +++ b/scene/2d/back_buffer_copy.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 6cbac4ed3b..e39e6fc6da 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index 8d9e76be85..dfcadf65a6 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index ea32953d68..4f00966e75 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index c6180e07b6..3a99e917eb 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/canvas_modulate.cpp b/scene/2d/canvas_modulate.cpp index a132c5e18c..05831609fc 100644 --- a/scene/2d/canvas_modulate.cpp +++ b/scene/2d/canvas_modulate.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/canvas_modulate.h b/scene/2d/canvas_modulate.h index 37d9d47ba5..4195c1386c 100644 --- a/scene/2d/canvas_modulate.h +++ b/scene/2d/canvas_modulate.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index d3bb5a8d4e..ce56b85a9e 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index 36bf39ff4e..a828d8d8ea 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index f136de5166..e2764a6e8d 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -79,11 +79,6 @@ void CollisionPolygon2D::_build_polygon() { Vector<Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() { Vector<Vector<Vector2> > decomp; -#if 0 - //fast but imprecise triangulator, gave us problems - decomp = Geometry::decompose_polygon(polygon); -#else - List<TriangulatorPoly> in_poly, out_poly; TriangulatorPoly inp; @@ -116,8 +111,6 @@ Vector<Vector<Vector2> > CollisionPolygon2D::_decompose_in_convex() { idx++; } -#endif - return decomp; } diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h index f0666ba9de..c9ec860e36 100644 --- a/scene/2d/collision_polygon_2d.h +++ b/scene/2d/collision_polygon_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index 3bb53a5e11..0758f4a9bf 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h index 1f2b96b91f..04203a75b4 100644 --- a/scene/2d/collision_shape_2d.h +++ b/scene/2d/collision_shape_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/joints_2d.cpp b/scene/2d/joints_2d.cpp index 726f57d42e..69bad1623f 100644 --- a/scene/2d/joints_2d.cpp +++ b/scene/2d/joints_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/joints_2d.h b/scene/2d/joints_2d.h index f854ce51ee..685299abc6 100644 --- a/scene/2d/joints_2d.h +++ b/scene/2d/joints_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 219574cbfd..4abb51ef7c 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index 90e55aeda4..66b0aa2299 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index 680adeea69..92e0d8a2f6 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h index 30c30b1a47..cca7bfecd6 100644 --- a/scene/2d/light_occluder_2d.h +++ b/scene/2d/light_occluder_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 6e7bfe63c8..c87a9a5b1e 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/line_2d.h b/scene/2d/line_2d.h index e8ca5e6e7c..017ccf13ff 100644 --- a/scene/2d/line_2d.h +++ b/scene/2d/line_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/line_builder.cpp b/scene/2d/line_builder.cpp index 3c1410edbb..9eea5191b9 100644 --- a/scene/2d/line_builder.cpp +++ b/scene/2d/line_builder.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/line_builder.h b/scene/2d/line_builder.h index 0e1a2aaf50..227e0abd08 100644 --- a/scene/2d/line_builder.h +++ b/scene/2d/line_builder.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp index 383236b4ca..fa488b6b23 100644 --- a/scene/2d/navigation2d.cpp +++ b/scene/2d/navigation2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -236,42 +236,6 @@ void Navigation2D::navpoly_remove(int p_id) { _navpoly_unlink(p_id); navpoly_map.erase(p_id); } -#if 0 -void Navigation2D::_clip_path(Vector<Vector2>& path, Polygon *from_poly, const Vector2& p_to_point, Polygon* p_to_poly) { - - Vector2 from = path[path.size()-1]; - - if (from.distance_to(p_to_point)<CMP_EPSILON) - return; - Plane cut_plane; - cut_plane.normal = (from-p_to_point).cross(up); - if (cut_plane.normal==Vector2()) - return; - cut_plane.normal.normalize(); - cut_plane.d = cut_plane.normal.dot(from); - - - while(from_poly!=p_to_poly) { - - int pe = from_poly->prev_edge; - Vector2 a = _get_vertex(from_poly->edges[pe].point); - Vector2 b = _get_vertex(from_poly->edges[(pe+1)%from_poly->edges.size()].point); - - from_poly=from_poly->edges[pe].C; - ERR_FAIL_COND(!from_poly); - - if (a.distance_to(b)>CMP_EPSILON) { - - Vector2 inters; - if (cut_plane.intersects_segment(a,b,&inters)) { - if (inters.distance_to(p_to_point)>CMP_EPSILON && inters.distance_to(path[path.size()-1])>CMP_EPSILON) { - path.push_back(inters); - } - } - } - } -} -#endif Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vector2 &p_end, bool p_optimize) { @@ -498,29 +462,7 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect open_list.erase(least_cost_poly); } -#if 0 -debug path - { - Polygon *p=end_poly; - int idx=0; - - while(true) { - int prev = p->prev_edge; - int prev_n = (p->prev_edge+1)%p->edges.size(); - Vector2 point = (_get_vertex(p->edges[prev].point) + _get_vertex(p->edges[prev_n].point))*0.5; - String points; - for(int i=0;i<p->edges.size();i++) { - if (i>0) - points+=", "; - points+=_get_vertex(p->edges[i].point); - } - //print_line("poly "+itos(idx++)+" - "+points); - p = p->edges[prev].C; - if (p==begin_poly) - break; - } - } -#endif + if (found_route) { Vector<Vector2> path; diff --git a/scene/2d/navigation2d.h b/scene/2d/navigation2d.h index 54e89de9e2..e87b01f7c5 100644 --- a/scene/2d/navigation2d.h +++ b/scene/2d/navigation2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -153,9 +153,7 @@ class Navigation2D : public Node2D { float cell_size; Map<int, NavMesh> navpoly_map; int last_id; -#if 0 - void _clip_path(Vector<Vector2>& path,Polygon *from_poly, const Vector2& p_to_point, Polygon* p_to_poly); -#endif + protected: static void _bind_methods(); diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index 0d5d06bef7..352ec3b300 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/navigation_polygon.h b/scene/2d/navigation_polygon.h index f6e6ed210a..5576a3abd2 100644 --- a/scene/2d/navigation_polygon.h +++ b/scene/2d/navigation_polygon.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index af5834c5b6..0c7685a858 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index a6009851c7..19aafc81ff 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp index bdb4bd2b16..0ddcb7b51b 100644 --- a/scene/2d/parallax_background.cpp +++ b/scene/2d/parallax_background.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h index fce1bbd928..0dad1daeab 100644 --- a/scene/2d/parallax_background.h +++ b/scene/2d/parallax_background.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index 40d688b708..8fe651cb5f 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h index f2d0053342..95ca27c41a 100644 --- a/scene/2d/parallax_layer.h +++ b/scene/2d/parallax_layer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index b0c00c4a64..c146ac08c2 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h index a6ac0c37d3..6946f2a799 100644 --- a/scene/2d/particles_2d.h +++ b/scene/2d/particles_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index d2474d9557..1d7bd8fc2a 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h index e80817cd3c..88a0abdea9 100644 --- a/scene/2d/path_2d.h +++ b/scene/2d/path_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/path_texture.cpp b/scene/2d/path_texture.cpp index e06c79dabd..13644f71cf 100644 --- a/scene/2d/path_texture.cpp +++ b/scene/2d/path_texture.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/path_texture.h b/scene/2d/path_texture.h index 163e914e4a..4639a6072b 100644 --- a/scene/2d/path_texture.h +++ b/scene/2d/path_texture.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 30ede699fa..6ac946ea37 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -182,29 +182,6 @@ real_t StaticBody2D::get_constant_angular_velocity() const { return constant_angular_velocity; } -#if 0 -void StaticBody2D::_update_xform() { - - if (!pre_xform || !pending) - return; - - setting=true; - - - Transform2D new_xform = get_global_transform(); //obtain the new one - - set_block_transform_notify(true); - Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_TRANSFORM,*pre_xform); //then simulate motion! - set_global_transform(*pre_xform); //but restore state to previous one in both visual and physics - set_block_transform_notify(false); - - Physics2DServer::get_singleton()->body_static_simulate_motion(get_rid(),new_xform); //then simulate motion! - - setting=false; - pending=false; - -} -#endif void StaticBody2D::set_friction(real_t p_friction) { diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 54bd263b15..1a4b0c0f5c 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index cde5724069..197c74352e 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index eb47f4d8d1..20c3324a50 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp index 7688faa23b..cde665d422 100644 --- a/scene/2d/position_2d.cpp +++ b/scene/2d/position_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h index 67ff2c610d..af54fb919a 100644 --- a/scene/2d/position_2d.h +++ b/scene/2d/position_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index 2d2a00847d..f90331c411 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h index 244f4302ad..338de814d2 100644 --- a/scene/2d/ray_cast_2d.h +++ b/scene/2d/ray_cast_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp index a2d53f0c7b..c139573853 100644 --- a/scene/2d/remote_transform_2d.cpp +++ b/scene/2d/remote_transform_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/remote_transform_2d.h b/scene/2d/remote_transform_2d.h index d58ec14a95..30d5fd1e7c 100644 --- a/scene/2d/remote_transform_2d.h +++ b/scene/2d/remote_transform_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp index c39b12fc9a..c9bf6675d2 100644 --- a/scene/2d/screen_button.cpp +++ b/scene/2d/screen_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h index 2a5935aaf1..7647070b26 100644 --- a/scene/2d/screen_button.h +++ b/scene/2d/screen_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index b7b68d8060..c53faab5f9 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h index d3f9a5f032..64d30325f2 100644 --- a/scene/2d/sprite.h +++ b/scene/2d/sprite.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 6af6231f2c..d41db1dce5 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 082e9d1018..f401d51eeb 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp index a641828df8..8fc8b65217 100644 --- a/scene/2d/visibility_notifier_2d.cpp +++ b/scene/2d/visibility_notifier_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h index 38da69faef..ef0e1affd3 100644 --- a/scene/2d/visibility_notifier_2d.h +++ b/scene/2d/visibility_notifier_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/y_sort.cpp b/scene/2d/y_sort.cpp index f258b7e2e0..e0fb3f0645 100644 --- a/scene/2d/y_sort.cpp +++ b/scene/2d/y_sort.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/2d/y_sort.h b/scene/2d/y_sort.h index 3564cfc151..de7aa3a317 100644 --- a/scene/2d/y_sort.h +++ b/scene/2d/y_sort.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index c19b361cdd..217cb71230 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/area.h b/scene/3d/area.h index 5df308fc47..7ea97d0a8c 100644 --- a/scene/3d/area.h +++ b/scene/3d/area.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp index 8a02c54907..545be8bc5f 100644 --- a/scene/3d/arvr_nodes.cpp +++ b/scene/3d/arvr_nodes.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h index 936519126b..4c14be71b5 100644 --- a/scene/3d/arvr_nodes.h +++ b/scene/3d/arvr_nodes.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/bone_attachment.cpp b/scene/3d/bone_attachment.cpp index 067e151c65..e1a5329fb0 100644 --- a/scene/3d/bone_attachment.cpp +++ b/scene/3d/bone_attachment.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/bone_attachment.h b/scene/3d/bone_attachment.h index 65908d98a8..159d16157a 100644 --- a/scene/3d/bone_attachment.h +++ b/scene/3d/bone_attachment.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 9db7253fd6..02a7845e0b 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -339,15 +339,8 @@ Vector3 Camera::project_local_ray_normal(const Point2 &p_pos) const { ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); } -#if 0 - Size2 viewport_size = get_viewport()->get_visible_rect().size; - Vector2 cpos = p_pos; -#else - Size2 viewport_size = get_viewport()->get_camera_rect_size(); Vector2 cpos = get_viewport()->get_camera_coords(p_pos); -#endif - Vector3 ray; if (mode == PROJECTION_ORTHOGONAL) { @@ -371,17 +364,9 @@ Vector3 Camera::project_ray_origin(const Point2 &p_pos) const { ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); } -#if 0 - Size2 viewport_size = get_viewport()->get_visible_rect().size; - Vector2 cpos = p_pos; -#else - Size2 viewport_size = get_viewport()->get_camera_rect_size(); Vector2 cpos = get_viewport()->get_camera_coords(p_pos); -#endif - ERR_FAIL_COND_V(viewport_size.y == 0, Vector3()); - //float aspect = viewport_size.x / viewport_size.y; if (mode == PROJECTION_PERSPECTIVE) { diff --git a/scene/3d/camera.h b/scene/3d/camera.h index 70849791e5..243a7b9b39 100644 --- a/scene/3d/camera.h +++ b/scene/3d/camera.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/character_camera.cpp b/scene/3d/character_camera.cpp deleted file mode 100644 index 9feda1b72f..0000000000 --- a/scene/3d/character_camera.cpp +++ /dev/null @@ -1,718 +0,0 @@ -/*************************************************************************/ -/* character_camera.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "character_camera.h" - -#include "physics_body.h" -#if 0 -void CharacterCamera::_set(const String& p_name, const Variant& p_value) { - - if (p_name=="type") - set_camera_type((CameraType)((int)(p_value))); - else if (p_name=="orbit") - set_orbit(p_value); - else if (p_name=="height") - set_height(p_value); - else if (p_name=="inclination") - set_inclination(p_value); - else if (p_name=="max_orbit_x") - set_max_orbit_x(p_value); - else if (p_name=="min_orbit_x") - set_min_orbit_x(p_value); - else if (p_name=="max_distance") - set_max_distance(p_value); - else if (p_name=="min_distance") - set_min_distance(p_value); - else if (p_name=="distance") - set_distance(p_value); - else if (p_name=="clip") - set_clip(p_value); - else if (p_name=="autoturn") - set_autoturn(p_value); - else if (p_name=="autoturn_tolerance") - set_autoturn_tolerance(p_value); - else if (p_name=="autoturn_speed") - set_autoturn_speed(p_value); - -} -Variant CharacterCamera::_get(const String& p_name) const { - - if (p_name=="type") - return get_camera_type(); - else if (p_name=="orbit") - return get_orbit(); - else if (p_name=="height") - return get_height(); - else if (p_name=="inclination") - return get_inclination(); - else if (p_name=="max_orbit_x") - return get_max_orbit_x(); - else if (p_name=="min_orbit_x") - return get_min_orbit_x(); - else if (p_name=="max_distance") - return get_max_distance(); - else if (p_name=="min_distance") - return get_min_distance(); - else if (p_name=="distance") - return get_distance(); - else if (p_name=="clip") - return has_clip(); - else if (p_name=="autoturn") - return has_autoturn(); - else if (p_name=="autoturn_tolerance") - return get_autoturn_tolerance(); - else if (p_name=="autoturn_speed") - return get_autoturn_speed(); - - return Variant(); -} - -void CharacterCamera::_get_property_list( List<PropertyInfo> *p_list) const { - - p_list->push_back( PropertyInfo( Variant::INT, "type", PROPERTY_HINT_ENUM, "Fixed,Follow") ); - p_list->push_back( PropertyInfo( Variant::VECTOR2, "orbit" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "inclination", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "max_orbit_x", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "min_orbit_x", PROPERTY_HINT_RANGE,"-90,90,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "min_distance", PROPERTY_HINT_RANGE,"0,100,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "max_distance", PROPERTY_HINT_RANGE,"0,100,0.01" ) ); - p_list->push_back( PropertyInfo( Variant::REAL, "distance", PROPERTY_HINT_RANGE,"0.01,1024,0,01") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "clip") ); - p_list->push_back( PropertyInfo( Variant::BOOL, "autoturn") ); - p_list->push_back( PropertyInfo( Variant::REAL, "autoturn_tolerance", PROPERTY_HINT_RANGE,"1,90,0.01") ); - p_list->push_back( PropertyInfo( Variant::REAL, "autoturn_speed", PROPERTY_HINT_RANGE,"1,90,0.01") ); - - -} - -void CharacterCamera::_compute_camera() { - - - // update the transform with the next proposed transform (camera is 1 logic frame delayed) - - /* - float time = get_root_node()->get_frame_time(); - Vector3 oldp = accepted.get_origin(); - Vector3 newp = proposed.get_origin(); - - float frame_dist = time * - if (oldp.distance_to(newp) > - */ - - float time = get_root_node()->get_frame_time(); - - if (true) { - - if (clip_ray[0].clipped && clip_ray[1].clipped && clip_ray[2].clipped) { - //all have been clipped - proposed.origin=clip_ray[1].clip_pos; - - - } else { - - Vector3 rel=proposed.origin-target_pos; - - if (clip_ray[0].clipped && !clip_ray[2].clipped) { - - float distance = target_pos.distance_to(clip_ray[0].clip_pos); - real_t amount = 1.0-(distance/clip_len); - amount = CLAMP(amount,0,1); - - - rel=Matrix3(Vector3(0,1,0)), - rotate_orbit(Vector2(0,autoturn_speed*time*amount)); - } - if (clip_ray[2].clipped && !clip_ray[0].clipped) { - - float distance = target_pos.distance_to(clip_ray[2].clip_pos); - real_t amount = 1.0-(distance/clip_len); - amount = CLAMP(amount,0,1); - - rotate_orbit(Vector2(0,-autoturn_speed*time*amount)); - } - - } - } - - - Transform final; - - static float pos_ratio = 0.9; - static float rot_ratio = 10; - - Vector3 vec1 = accepted.origin; - Vector3 vec2 = proposed.origin; - final.origin = vec2.linear_interpolate(vec1, pos_ratio * time); - - Quat q1 = accepted.basis; - Quat q2 = proposed.basis; - final.basis = q1.slerp(q2, rot_ratio * time); - - accepted=final; - - _update_camera(); - - // calculate the next proposed transform - - - Vector3 new_pos; - Vector3 character_pos = get_global_transform().origin; - character_pos.y+=height; // height compensate - - if(type==CAMERA_FOLLOW) { - - - - /* calculate some variables */ - - Vector3 rel = follow_pos - character_pos; - - float l = rel.length(); - Vector3 rel_n = (l > 0) ? (rel/l) : Vector3(); -#if 1 - float ang = Math::acos(rel_n.dot( Vector3(0,1,0) )); - - Vector3 tangent = rel_n; - tangent.y=0; // get rid of y - if (tangent.length_squared() < CMP_EPSILON2) - tangent=Vector3(0,0,1); // use Z as tangent if rel is parallel to y - else - tangent.normalize(); - - /* now start applying the rules */ - - //clip distance - if (l > max_distance) - l=max_distance; - if (l < min_distance) - l=min_distance; - - //fix angle - - float ang_min = Math_PI * 0.5 + Math::deg2rad(min_orbit_x); - float ang_max = Math_PI * 0.5 + Math::deg2rad(max_orbit_x); - - if (ang<ang_min) - ang=ang_min; - if (ang>ang_max) - ang=ang_max; - - /* finally, rebuild the validated camera position */ - - new_pos=Vector3(0,Math::cos(ang),0); - new_pos+=tangent*Math::sin(ang); - new_pos*=l; - new_pos+=character_pos; -#else - if (l > max_distance) - l=max_distance; - if (l < min_distance) - l=min_distance; - - new_pos = character_pos + rel_n * l; - -#endif - follow_pos=new_pos; - - } else if (type==CAMERA_FIXED) { - - - if (distance<min_distance) - distance=min_distance; - if (distance>max_distance) - distance=max_distance; - - if (orbit.x<min_orbit_x) - orbit.x=min_orbit_x; - if (orbit.x>max_orbit_x) - orbit.x=max_orbit_x; - - Matrix3 m; - m.rotate(Vector3(0,1,0),-Math::deg2rad(orbit.y)); - m.rotate(Vector3(1,0,0),-Math::deg2rad(orbit.x)); - - new_pos = (m.get_axis(2) * distance) + character_pos; - - if (use_lookat_target) { - - Transform t = get_global_transform(); - Vector3 y = t.basis.get_axis(1).normalized(); - Vector3 z = lookat_target - character_pos; - z= (z - y * y.dot(z)).normalized(); - orbit.y = -Math::rad2deg(Math::atan2(z.x,z.z)) + 180; - - /* - Transform t = get_global_transform(); - Vector3 y = t.basis.get_axis(1).normalized(); - Vector3 z = lookat_target - t.origin; - z= (z - y * y.dot(z)).normalized(); - Vector3 x = z.cross(y).normalized(); - Transform t2; - t2.basis.set_axis(0,x); - t2.basis.set_axis(1,y); - t2.basis.set_axis(2,z); - t2.origin=t.origin; - - Vector3 local = t2.xform_inv(camera_pos); - - float ang = Math::atan2(local.x,local.y); - */ - - /* - - Vector3 vec1 = lookat_target - new_pos; - vec1.normalize(); - Vector3 vec2 = character_pos - new_pos; - vec2.normalize(); - - float dot = vec1.dot(vec2); - printf("dot %f\n", dot); - if ( dot < 0.5) { - - rotate_orbit(Vector2(0, 90)); - }; - */ - - - }; - } - - Vector3 target; - if (use_lookat_target) { - - target = lookat_target; - } else { - target = character_pos; - }; - - proposed.set_look_at(new_pos,target,Vector3(0,1,0)); - proposed = proposed * Transform(Matrix3(Vector3(1,0,0),Math::deg2rad(inclination)),Vector3()); //inclination - - - Vector<RID> exclude; - exclude.push_back(target_body); - - - - Vector3 rel = new_pos-target; - - for(int i=0;i<3;i++) { - - PhysicsServer::get_singleton()->query_intersection(clip_ray[i].query,get_world().get_space(),exclude); - PhysicsServer::get_singleton()->query_intersection_segment(clip_ray[i].query,target,target+Matrix3(Vector3(0,1,0),Math::deg2rad(autoturn_tolerance*(i-1.0))).xform(rel)); - clip_ray[i].clipped=false; - clip_ray[i].clip_pos=Vector3(); - } - target_pos=target; - clip_len=rel.length(); - - - -} - -void CharacterCamera::set_use_lookat_target(bool p_use, const Vector3 &p_lookat) { - - use_lookat_target = p_use; - lookat_target = p_lookat; -}; - - -void CharacterCamera::_notification(int p_what) { - - switch(p_what) { - - case NOTIFICATION_PROCESS: { - - - _compute_camera(); - } break; - - case NOTIFICATION_ENTER_SCENE: { - - if (type==CAMERA_FOLLOW) { - - set_orbit(orbit); - set_distance(distance); - } - - accepted=get_global_transform(); - proposed=accepted; - - target_body = RID(); - - Node* parent = get_parent(); - while (parent) { - PhysicsBody* p = Object::cast_to<PhysicsBody>(parent); - if (p) { - target_body = p->get_body(); - break; - }; - parent = parent->get_parent(); - }; - - } break; - - case NOTIFICATION_TRANSFORM_CHANGED: { - - } break; - case NOTIFICATION_EXIT_SCENE: { - - if (type==CAMERA_FOLLOW) { - distance=get_distance(); - orbit=get_orbit(); - - } - } break; - - case NOTIFICATION_BECAME_CURRENT: { - - set_process(true); - } break; - case NOTIFICATION_LOST_CURRENT: { - - set_process(false); - } break; - } - -} - - -void CharacterCamera::set_camera_type(CameraType p_camera_type) { - - - if (p_camera_type==type) - return; - - type=p_camera_type; - - // do conversions -} - -CharacterCamera::CameraType CharacterCamera::get_camera_type() const { - - return type; - -} - -void CharacterCamera::set_orbit(const Vector2& p_orbit) { - - orbit=p_orbit; - - if(type == CAMERA_FOLLOW && is_inside_scene()) { - - Vector3 char_pos = get_global_transform().origin; - char_pos.y+=height; - float d = char_pos.distance_to(follow_pos); - - Matrix3 m; - m.rotate(Vector3(0,1,0),-orbit.y); - m.rotate(Vector3(1,0,0),-orbit.x); - - follow_pos=char_pos + m.get_axis(2) * d; - - } - -} -void CharacterCamera::set_orbit_x(float p_x) { - - orbit.x=p_x; - if(type == CAMERA_FOLLOW && is_inside_scene()) - set_orbit(Vector2( p_x, get_orbit().y )); -} -void CharacterCamera::set_orbit_y(float p_y) { - - - orbit.y=p_y; - if(type == CAMERA_FOLLOW && is_inside_scene()) - set_orbit(Vector2( get_orbit().x, p_y )); - -} -Vector2 CharacterCamera::get_orbit() const { - - - if (type == CAMERA_FOLLOW && is_inside_scene()) { - - Vector3 char_pos = get_global_transform().origin; - char_pos.y+=height; - Vector3 rel = (follow_pos - char_pos).normalized(); - Vector2 ret_orbit; - ret_orbit.x = Math::acos( Vector3(0,1,0).dot( rel ) ) - Math_PI * 0.5; - ret_orbit.y = Math::atan2(rel.x,rel.z); - return ret_orbit; - } - return orbit; -} - -void CharacterCamera::rotate_orbit(const Vector2& p_relative) { - - if (type == CAMERA_FOLLOW && is_inside_scene()) { - - Matrix3 m; - m.rotate(Vector3(0,1,0),-Math::deg2rad(p_relative.y)); - m.rotate(Vector3(1,0,0),-Math::deg2rad(p_relative.x)); - - Vector3 char_pos = get_global_transform().origin; - char_pos.y+=height; - Vector3 rel = (follow_pos - char_pos); - rel = m.xform(rel); - follow_pos=char_pos+rel; - - } - - orbit+=p_relative; -} - -void CharacterCamera::set_height(float p_height) { - - - height=p_height; -} - -float CharacterCamera::get_height() const { - - return height; - -} - -void CharacterCamera::set_max_orbit_x(float p_max) { - - max_orbit_x=p_max; -} - -float CharacterCamera::get_max_orbit_x() const { - - return max_orbit_x; -} - -void CharacterCamera::set_min_orbit_x(float p_min) { - - min_orbit_x=p_min; -} - -float CharacterCamera::get_min_orbit_x() const { - - return min_orbit_x; -} - -float CharacterCamera::get_min_distance() const { - - return min_distance; -} -float CharacterCamera::get_max_distance() const { - - return max_distance; -} - -void CharacterCamera::set_min_distance(float p_min) { - - min_distance=p_min; -} - -void CharacterCamera::set_max_distance(float p_max) { - - max_distance = p_max; -} - - -void CharacterCamera::set_distance(float p_distance) { - - if (type == CAMERA_FOLLOW && is_inside_scene()) { - - Vector3 char_pos = get_global_transform().origin; - char_pos.y+=height; - Vector3 rel = (follow_pos - char_pos).normalized(); - rel*=p_distance; - follow_pos=char_pos+rel; - - } - - distance=p_distance; -} - -float CharacterCamera::get_distance() const { - - if (type == CAMERA_FOLLOW && is_inside_scene()) { - - Vector3 char_pos = get_global_transform().origin; - char_pos.y+=height; - return (follow_pos - char_pos).length(); - - } - - return distance; -} - -void CharacterCamera::set_clip(bool p_enabled) { - - - clip=p_enabled; -} - -bool CharacterCamera::has_clip() const { - - return clip; - -} - - -void CharacterCamera::set_autoturn(bool p_enabled) { - - - autoturn=p_enabled; -} - -bool CharacterCamera::has_autoturn() const { - - return autoturn; - -} - -void CharacterCamera::set_autoturn_tolerance(float p_degrees) { - - - autoturn_tolerance=p_degrees; -} -float CharacterCamera::get_autoturn_tolerance() const { - - - return autoturn_tolerance; -} - -void CharacterCamera::set_inclination(float p_degrees) { - - - inclination=p_degrees; -} -float CharacterCamera::get_inclination() const { - - - return inclination; -} - - -void CharacterCamera::set_autoturn_speed(float p_speed) { - - - autoturn_speed=p_speed; -} -float CharacterCamera::get_autoturn_speed() const { - - return autoturn_speed; - -} - - - - - -void CharacterCamera::_bind_methods() { - - ClassDB::bind_method(D_METHOD("set_camera_type","type"),&CharacterCamera::set_camera_type); - ClassDB::bind_method(D_METHOD("get_camera_type"),&CharacterCamera::get_camera_type); - ClassDB::bind_method(D_METHOD("set_orbit","orbit"),&CharacterCamera::set_orbit); - ClassDB::bind_method(D_METHOD("get_orbit"),&CharacterCamera::get_orbit); - ClassDB::bind_method(D_METHOD("set_orbit_x","x"),&CharacterCamera::set_orbit_x); - ClassDB::bind_method(D_METHOD("set_orbit_y","y"),&CharacterCamera::set_orbit_y); - ClassDB::bind_method(D_METHOD("set_min_orbit_x","x"),&CharacterCamera::set_min_orbit_x); - ClassDB::bind_method(D_METHOD("get_min_orbit_x"),&CharacterCamera::get_min_orbit_x); - ClassDB::bind_method(D_METHOD("set_max_orbit_x","x"),&CharacterCamera::set_max_orbit_x); - ClassDB::bind_method(D_METHOD("get_max_orbit_x"),&CharacterCamera::get_max_orbit_x); - ClassDB::bind_method(D_METHOD("rotate_orbit"),&CharacterCamera::rotate_orbit); - ClassDB::bind_method(D_METHOD("set_distance","distance"),&CharacterCamera::set_distance); - ClassDB::bind_method(D_METHOD("get_distance"),&CharacterCamera::get_distance); - ClassDB::bind_method(D_METHOD("set_clip","enable"),&CharacterCamera::set_clip); - ClassDB::bind_method(D_METHOD("has_clip"),&CharacterCamera::has_clip); - ClassDB::bind_method(D_METHOD("set_autoturn","enable"),&CharacterCamera::set_autoturn); - ClassDB::bind_method(D_METHOD("has_autoturn"),&CharacterCamera::has_autoturn); - ClassDB::bind_method(D_METHOD("set_autoturn_tolerance","degrees"),&CharacterCamera::set_autoturn_tolerance); - ClassDB::bind_method(D_METHOD("get_autoturn_tolerance"),&CharacterCamera::get_autoturn_tolerance); - ClassDB::bind_method(D_METHOD("set_autoturn_speed","speed"),&CharacterCamera::set_autoturn_speed); - ClassDB::bind_method(D_METHOD("get_autoturn_speed"),&CharacterCamera::get_autoturn_speed); - ClassDB::bind_method(D_METHOD("set_use_lookat_target","use","lookat"),&CharacterCamera::set_use_lookat_target, DEFVAL(Vector3())); - - ClassDB::bind_method(D_METHOD("_ray_collision"),&CharacterCamera::_ray_collision); - - BIND_ENUM_CONSTANT( CAMERA_FIXED ); - BIND_ENUM_CONSTANT( CAMERA_FOLLOW ); -} - -void CharacterCamera::_ray_collision(Vector3 p_point, Vector3 p_normal, int p_subindex, ObjectID p_against,int p_idx) { - - - clip_ray[p_idx].clip_pos=p_point; - clip_ray[p_idx].clipped=true; -}; - -Transform CharacterCamera::get_camera_transform() const { - - return accepted; -} - - -CharacterCamera::CharacterCamera() { - - - type=CAMERA_FOLLOW; - height=1; - - orbit=Vector2(0,0); - - distance=3; - min_distance=2; - max_distance=5; - - autoturn=false; - autoturn_tolerance=15; - autoturn_speed=20; - - min_orbit_x=-50; - max_orbit_x=70; - inclination=0; - - clip=false; - use_lookat_target = false; - - for(int i=0;i<3;i++) { - clip_ray[i].query=PhysicsServer::get_singleton()->query_create(this, "_ray_collision", i, true); - clip_ray[i].clipped=false; - } - - -} - -CharacterCamera::~CharacterCamera() { - - for(int i=0;i<3;i++) { - PhysicsServer::get_singleton()->free(clip_ray[i].query); - } - - -} -#endif diff --git a/scene/3d/character_camera.h b/scene/3d/character_camera.h deleted file mode 100644 index c3a1c70d5e..0000000000 --- a/scene/3d/character_camera.h +++ /dev/null @@ -1,167 +0,0 @@ -/*************************************************************************/ -/* character_camera.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 CHARACTER_CAMERA_H -#define CHARACTER_CAMERA_H - -#include "scene/3d/camera.h" -#if 0 -class CharacterCamera : public Camera { - - GDCLASS( CharacterCamera, Camera ); -public: - - enum CameraType { - CAMERA_FIXED, - CAMERA_FOLLOW - }; - -private: - - - CameraType type; - - //used for follow - Vector3 follow_pos; - //used for fixed - Vector2 orbit; - float distance; - - float height; - - float min_distance; - float max_distance; - - float max_orbit_x; - float min_orbit_x; - - float inclination; - - bool clip; - bool autoturn; - float autoturn_tolerance; - float autoturn_speed; - - - - struct ClipRay { - RID query; - bool clipped; - Vector3 clip_pos; - }; - - ClipRay clip_ray[3]; - Vector3 target_pos; - float clip_len; - - - Transform accepted; - Vector3 proposed_pos; - - bool use_lookat_target; - Vector3 lookat_target; - - void _compute_camera(); - - RID ray_query; - RID left_turn_query; - RID right_turn_query; - RID target_body; - -protected: - - virtual void _request_camera_update() {} //ignore - - 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; - void _notification(int p_what); - - static void _bind_methods(); - - void _ray_collision(Vector3 p_point, Vector3 p_normal, int p_subindex, ObjectID p_against,int p_idx); - -public: - - - void set_camera_type(CameraType p_camera_type); - CameraType get_camera_type() const; - - void set_orbit(const Vector2& p_orbit); - void set_orbit_x(float p_x); - void set_orbit_y(float p_y); - Vector2 get_orbit() const; - - void set_height(float p_height); - float get_height() const; - - void set_inclination(float p_degrees); - float get_inclination() const; - - void set_max_orbit_x(float p_max); - float get_max_orbit_x() const; - - void set_min_orbit_x(float p_min); - float get_min_orbit_x() const; - - void rotate_orbit(const Vector2& p_relative); - - void set_distance(float p_distance); - float get_distance() const; - - float get_min_distance() const; - float get_max_distance() const; - void set_min_distance(float p_min); - void set_max_distance(float p_max); - - - void set_clip(bool p_enabled); - bool has_clip() const; - - void set_autoturn(bool p_enabled); - bool has_autoturn() const; - - void set_autoturn_tolerance(float p_degrees); - float get_autoturn_tolerance() const; - - void set_autoturn_speed(float p_speed); - float get_autoturn_speed() const; - - void set_use_lookat_target(bool p_use, const Vector3 &p_lookat = Vector3()); - - virtual Transform get_camera_transform() const; - - CharacterCamera(); - ~CharacterCamera(); -}; - -VARIANT_ENUM_CAST( CharacterCamera::CameraType ); - -#endif -#endif // CHARACTER_CAMERA_H diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index 1aba26673c..c121ef4566 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "collision_object.h" + #include "scene/scene_string_names.h" #include "servers/physics_server.h" diff --git a/scene/3d/collision_object.h b/scene/3d/collision_object.h index 6c13e5d505..ac35de697c 100644 --- a/scene/3d/collision_object.h +++ b/scene/3d/collision_object.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp index 2087938de8..382cbb8f38 100644 --- a/scene/3d/collision_polygon.cpp +++ b/scene/3d/collision_polygon.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h index beefae182c..dbed1d7154 100644 --- a/scene/3d/collision_polygon.h +++ b/scene/3d/collision_polygon.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/collision_shape.cpp b/scene/3d/collision_shape.cpp index 6a0ed08fee..4d4ed30d03 100644 --- a/scene/3d/collision_shape.cpp +++ b/scene/3d/collision_shape.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/collision_shape.h b/scene/3d/collision_shape.h index 277e0dfa77..6d849f42af 100644 --- a/scene/3d/collision_shape.h +++ b/scene/3d/collision_shape.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index b5b6dfe7e3..0232ce7653 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index 8346437ebd..5a06984a47 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp index 060e088750..64d3f4fcab 100644 --- a/scene/3d/immediate_geometry.cpp +++ b/scene/3d/immediate_geometry.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h index bc8452c7e0..b2bcb5af1a 100644 --- a/scene/3d/immediate_geometry.h +++ b/scene/3d/immediate_geometry.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/interpolated_camera.cpp b/scene/3d/interpolated_camera.cpp index 4f28ac6b3e..157ae42571 100644 --- a/scene/3d/interpolated_camera.cpp +++ b/scene/3d/interpolated_camera.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/interpolated_camera.h b/scene/3d/interpolated_camera.h index c302c32fc9..26e7278c99 100644 --- a/scene/3d/interpolated_camera.h +++ b/scene/3d/interpolated_camera.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index f4b5cc5731..5b48ee4af8 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/light.h b/scene/3d/light.h index 788e948536..93dd4828da 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -38,8 +38,6 @@ @author Juan Linietsky <reduzio@gmail.com> */ -class BakedLight; - class Light : public VisualInstance { GDCLASS(Light, VisualInstance); diff --git a/scene/3d/listener.cpp b/scene/3d/listener.cpp index c7d3bac2f8..51cf9fb89b 100644 --- a/scene/3d/listener.cpp +++ b/scene/3d/listener.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/listener.h b/scene/3d/listener.h index b66fc7fc38..2c800443b4 100644 --- a/scene/3d/listener.h +++ b/scene/3d/listener.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 578e3900fa..c8215971c4 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h index 1bb2c97d10..8e8c12a592 100644 --- a/scene/3d/mesh_instance.h +++ b/scene/3d/mesh_instance.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp index b51953f27c..f90489f1f0 100644 --- a/scene/3d/multimesh_instance.cpp +++ b/scene/3d/multimesh_instance.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance.h index 7e14d567ac..cd0e7b463c 100644 --- a/scene/3d/multimesh_instance.h +++ b/scene/3d/multimesh_instance.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp index 1d74c7bbcc..d8c7a78648 100644 --- a/scene/3d/navigation.cpp +++ b/scene/3d/navigation.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/navigation.h b/scene/3d/navigation.h index 80699fce72..010d16dedd 100644 --- a/scene/3d/navigation.h +++ b/scene/3d/navigation.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/navigation_mesh.cpp b/scene/3d/navigation_mesh.cpp index 46d177df71..7a55f956e0 100644 --- a/scene/3d/navigation_mesh.cpp +++ b/scene/3d/navigation_mesh.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/navigation_mesh.h b/scene/3d/navigation_mesh.h index e5a3dc7b43..36fe3ee34b 100644 --- a/scene/3d/navigation_mesh.h +++ b/scene/3d/navigation_mesh.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 70f46e3a0a..80c706898d 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/particles.h b/scene/3d/particles.h index 9c1436a47b..2c109d6ec8 100644 --- a/scene/3d/particles.h +++ b/scene/3d/particles.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/path.cpp b/scene/3d/path.cpp index 19c9761091..ed4d88417c 100644 --- a/scene/3d/path.cpp +++ b/scene/3d/path.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -33,24 +33,6 @@ #include "scene/scene_string_names.h" void Path::_notification(int p_what) { -#if 0 - if (p_what==NOTIFICATION_DRAW && curve.is_valid() && is_inside_scene() && Engine::get_singleton()->is_editor_hint()) { - //draw the curve!! - - for(int i=0;i<curve->get_point_count();i++) { - - Vector2 prev_p=curve->get_point_pos(i); - - for(int j=1;j<=8;j++) { - - real_t frac = j/8.0; - Vector2 p = curve->interpolate(i,frac); - draw_line(prev_p,p,Color(0.5,0.6,1.0,0.7),2); - prev_p=p; - } - } - } -#endif } void Path::_curve_changed() { diff --git a/scene/3d/path.h b/scene/3d/path.h index eeae0668a7..0f9a169f72 100644 --- a/scene/3d/path.h +++ b/scene/3d/path.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index a1bee9a0ed..b149dcd2dc 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index 83811a1d93..23d752ad76 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp index af6e7f48fa..aa127ab79f 100644 --- a/scene/3d/physics_joint.cpp +++ b/scene/3d/physics_joint.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -973,301 +973,3 @@ Generic6DOFJoint::Generic6DOFJoint() { set_flag_z(FLAG_ENABLE_LINEAR_LIMIT, true); set_flag_z(FLAG_ENABLE_MOTOR, false); } - -#if 0 - -void PhysicsJoint::_set(const String& p_name, const Variant& p_value) { - - if (p_name=="body_A") - set_body_a(p_value); - else if (p_name=="body_B") - set_body_b(p_value); - else if (p_name=="active") - set_active(p_value); - else if (p_name=="no_collision") - set_disable_collision(p_value); -} -Variant PhysicsJoint::_get(const String& p_name) const { - - if (p_name=="body_A") - return get_body_a(); - else if (p_name=="body_B") - return get_body_b(); - else if (p_name=="active") - return is_active(); - else if (p_name=="no_collision") - return has_disable_collision(); - - return Variant(); -} -void PhysicsJoint::_get_property_list( List<PropertyInfo> *p_list) const { - - - p_list->push_back( PropertyInfo( Variant::NODE_PATH, "body_A" ) ); - p_list->push_back( PropertyInfo( Variant::NODE_PATH, "body_B" ) ); - p_list->push_back( PropertyInfo( Variant::BOOL, "active" ) ); - p_list->push_back( PropertyInfo( Variant::BOOL, "no_collision" ) ); -} -void PhysicsJoint::_notification(int p_what) { - - - switch(p_what) { - - case NOTIFICATION_PARENT_CONFIGURED: { - - _connect(); - if (get_root_node()->get_editor() && !indicator.is_valid()) { - - indicator=VisualServer::get_singleton()->poly_create(); - RID mat=VisualServer::get_singleton()->fixed_material_create(); - VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_UNSHADED, true ); - VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_ONTOP, true ); - VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_WIREFRAME, true ); - VisualServer::get_singleton()->material_set_flag( mat, VisualServer::MATERIAL_FLAG_DOUBLE_SIDED, true ); - VisualServer::get_singleton()->material_set_line_width( mat, 3 ); - - VisualServer::get_singleton()->poly_set_material(indicator,mat,true); - _update_indicator(); - - } - - if (indicator.is_valid()) { - - indicator_instance=VisualServer::get_singleton()->instance_create(indicator,get_world()->get_scenario()); - VisualServer::get_singleton()->instance_attach_object_instance_id( indicator_instance,get_instance_id() ); - } - } break; - case NOTIFICATION_TRANSFORM_CHANGED: { - - if (indicator_instance.is_valid()) { - - VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform()); - } - } break; - case NOTIFICATION_EXIT_SCENE: { - - if (indicator_instance.is_valid()) { - - VisualServer::get_singleton()->free(indicator_instance); - } - _disconnect(); - - } break; - - } -} - - -RID PhysicsJoint::_get_visual_instance_rid() const { - - return indicator_instance; - -} - -void PhysicsJoint::_bind_methods() { - - ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"),&PhysicsJoint::_get_visual_instance_rid); - ClassDB::bind_method(D_METHOD("set_body_a","path"),&PhysicsJoint::set_body_a); - ClassDB::bind_method(D_METHOD("set_body_b"),&PhysicsJoint::set_body_b); - ClassDB::bind_method(D_METHOD("get_body_a","path"),&PhysicsJoint::get_body_a); - ClassDB::bind_method(D_METHOD("get_body_b"),&PhysicsJoint::get_body_b); - - ClassDB::bind_method(D_METHOD("set_active","active"),&PhysicsJoint::set_active); - ClassDB::bind_method(D_METHOD("is_active"),&PhysicsJoint::is_active); - - ClassDB::bind_method(D_METHOD("set_disable_collision","disable"),&PhysicsJoint::set_disable_collision); - ClassDB::bind_method(D_METHOD("has_disable_collision"),&PhysicsJoint::has_disable_collision); - - - ClassDB::bind_method("reconnect",&PhysicsJoint::reconnect); - - ClassDB::bind_method(D_METHOD("get_rid"),&PhysicsJoint::get_rid); - -} - -void PhysicsJoint::set_body_a(const NodePath& p_path) { - - _disconnect(); - body_A=p_path; - _connect(); - _change_notify("body_A"); -} -void PhysicsJoint::set_body_b(const NodePath& p_path) { - - _disconnect(); - body_B=p_path; - _connect(); - _change_notify("body_B"); - -} -NodePath PhysicsJoint::get_body_a() const { - - return body_A; -} -NodePath PhysicsJoint::get_body_b() const { - - return body_B; -} - -void PhysicsJoint::set_active(bool p_active) { - - active=p_active; - if (is_inside_scene()) { - PhysicsServer::get_singleton()->joint_set_active(joint,active); - } - _change_notify("active"); -} - -void PhysicsJoint::set_disable_collision(bool p_active) { - - if (no_collision==p_active) - return; - _disconnect(); - no_collision=p_active; - _connect(); - - _change_notify("no_collision"); -} -bool PhysicsJoint::has_disable_collision() const { - - return no_collision; -} - - - -bool PhysicsJoint::is_active() const { - - return active; -} - -void PhysicsJoint::_disconnect() { - - if (!is_inside_scene()) - return; - - if (joint.is_valid()) - PhysicsServer::get_singleton()->free(joint); - - joint=RID(); - - Node *nA = get_node(body_A); - Node *nB = get_node(body_B); - - PhysicsBody *A = Object::cast_to<PhysicsBody>(nA); - PhysicsBody *B = Object::cast_to<PhysicsBody>(nB); - - if (!A ||!B) - return; - - if (no_collision) - PhysicsServer::get_singleton()->body_remove_collision_exception(A->get_body(),B->get_body()); - -} -void PhysicsJoint::_connect() { - - if (!is_inside_scene()) - return; - - ERR_FAIL_COND(joint.is_valid()); - - Node *nA = get_node(body_A); - Node *nB = get_node(body_B); - - PhysicsBody *A = Object::cast_to<PhysicsBody>(nA); - PhysicsBody *B = Object::cast_to<PhysicsBody>(nB); - - if (!A && !B) - return; - - if (B && !A) - SWAP(B,A); - - joint = create(A,B); - - if (A<B) - SWAP(A,B); - - if (no_collision) - PhysicsServer::get_singleton()->body_add_collision_exception(A->get_body(),B->get_body()); - - - -} - -void PhysicsJoint::reconnect() { - - _disconnect(); - _connect(); - -} - - -RID PhysicsJoint::get_rid() { - - return joint; -} - - -PhysicsJoint::PhysicsJoint() { - - active=true; - no_collision=true; -} - - -PhysicsJoint::~PhysicsJoint() { - - if (indicator.is_valid()) { - - VisualServer::get_singleton()->free(indicator); - } - -} - -/* PIN */ - -void PhysicsJointPin::_update_indicator() { - - - VisualServer::get_singleton()->poly_clear(indicator); - - Vector<Color> colors; - colors.push_back( Color(0.3,0.9,0.2,0.7) ); - colors.push_back( Color(0.3,0.9,0.2,0.7) ); - - Vector<Vector3> points; - points.resize(2); - points[0]=Vector3(Vector3(-0.2,0,0)); - points[1]=Vector3(Vector3(0.2,0,0)); - VisualServer::get_singleton()->poly_add_primitive(indicator,points,Vector<Vector3>(),colors,Vector<Vector3>()); - - points[0]=Vector3(Vector3(0,-0.2,0)); - points[1]=Vector3(Vector3(0,0.2,0)); - VisualServer::get_singleton()->poly_add_primitive(indicator,points,Vector<Vector3>(),colors,Vector<Vector3>()); - - points[0]=Vector3(Vector3(0,0,-0.2)); - points[1]=Vector3(Vector3(0,0,0.2)); - VisualServer::get_singleton()->poly_add_primitive(indicator,points,Vector<Vector3>(),colors,Vector<Vector3>()); - -} - -RID PhysicsJointPin::create(PhysicsBody*A,PhysicsBody*B) { - - RID body_A = A->get_body(); - RID body_B = B?B->get_body():RID(); - - ERR_FAIL_COND_V( !body_A.is_valid(), RID() ); - - Vector3 pin_pos = get_global_transform().origin; - - if (body_B.is_valid()) - return PhysicsServer::get_singleton()->joint_create_double_pin_global(body_A,pin_pos,body_B,pin_pos); - else - return PhysicsServer::get_singleton()->joint_create_pin(body_A,A->get_global_transform().xform_inv(pin_pos),pin_pos); -} - -PhysicsJointPin::PhysicsJointPin() { - - -} -#endif diff --git a/scene/3d/physics_joint.h b/scene/3d/physics_joint.h index b834aaf6d2..b94297da30 100644 --- a/scene/3d/physics_joint.h +++ b/scene/3d/physics_joint.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -321,73 +321,4 @@ public: VARIANT_ENUM_CAST(Generic6DOFJoint::Param); VARIANT_ENUM_CAST(Generic6DOFJoint::Flag); -#if 0 -class PhysicsJoint : public Spatial { - - GDCLASS(PhysicsJoint,Spatial); - OBJ_CATEGORY("3D Physics Nodes"); - - NodePath body_A; - NodePath body_B; - bool active; - bool no_collision; - - - RID indicator_instance; - - RID _get_visual_instance_rid() const; -protected: - - RID joint; - RID indicator; - - 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; - void _notification(int p_what); - static void _bind_methods(); - - virtual RID create(PhysicsBody*A,PhysicsBody*B)=0; - virtual void _update_indicator()=0; - - void _disconnect(); - void _connect(); -public: - - void set_body_a(const NodePath& p_path); - void set_body_b(const NodePath& p_path); - NodePath get_body_a() const; - NodePath get_body_b() const; - - void set_active(bool p_active); - bool is_active() const; - - void set_disable_collision(bool p_active); - bool has_disable_collision() const; - - void reconnect(); - - RID get_rid(); - - PhysicsJoint(); - ~PhysicsJoint(); -}; - - - -class PhysicsJointPin : public PhysicsJoint { - - GDCLASS( PhysicsJointPin, PhysicsJoint ); - -protected: - - virtual void _update_indicator(); - virtual RID create(PhysicsBody*A,PhysicsBody*B); -public: - - - PhysicsJointPin(); -}; - #endif // PHYSICS_JOINT_H -#endif diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp index f79f7f6949..6c14f7dbc9 100644 --- a/scene/3d/portal.cpp +++ b/scene/3d/portal.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -32,6 +32,7 @@ #include "scene/resources/surface_tool.h" #include "servers/visual_server.h" +// FIXME: This will be removed, kept as reference for new implementation #if 0 bool Portal::_set(const StringName &p_name, const Variant &p_value) { diff --git a/scene/3d/portal.h b/scene/3d/portal.h index 9cc5d280a1..6de3df8553 100644 --- a/scene/3d/portal.h +++ b/scene/3d/portal.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/position_3d.cpp b/scene/3d/position_3d.cpp index 4e66ef13c0..d0df985ac4 100644 --- a/scene/3d/position_3d.cpp +++ b/scene/3d/position_3d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/position_3d.h b/scene/3d/position_3d.h index 0adde19342..8083c33196 100644 --- a/scene/3d/position_3d.h +++ b/scene/3d/position_3d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/proximity_group.cpp b/scene/3d/proximity_group.cpp index d0410f2c55..2288d8b08b 100644 --- a/scene/3d/proximity_group.cpp +++ b/scene/3d/proximity_group.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/proximity_group.h b/scene/3d/proximity_group.h index fec3add41f..d003d2f525 100644 --- a/scene/3d/proximity_group.h +++ b/scene/3d/proximity_group.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index 019bb219ee..72b7706b77 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h index e9b34c4f75..fd566cd343 100644 --- a/scene/3d/ray_cast.h +++ b/scene/3d/ray_cast.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index 194146b6b3..46b105cd21 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h index d2a5facb5f..7c328a8f16 100644 --- a/scene/3d/reflection_probe.h +++ b/scene/3d/reflection_probe.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/remote_transform.cpp b/scene/3d/remote_transform.cpp index a4dfeb8adf..3d402fa5af 100644 --- a/scene/3d/remote_transform.cpp +++ b/scene/3d/remote_transform.cpp @@ -4,7 +4,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/remote_transform.h b/scene/3d/remote_transform.h index c25b57966e..51a0bf35a3 100644 --- a/scene/3d/remote_transform.h +++ b/scene/3d/remote_transform.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp index 81ddf4a667..439b6bfdf8 100644 --- a/scene/3d/room_instance.cpp +++ b/scene/3d/room_instance.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -31,6 +31,7 @@ #include "servers/visual_server.h" +// FIXME: Will be removed, kept as reference for new implementation #if 0 #include "geometry.h" #include "project_settings.h" diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h index 5b9886671f..b9a64b6670 100644 --- a/scene/3d/room_instance.h +++ b/scene/3d/room_instance.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/scenario_fx.cpp b/scene/3d/scenario_fx.cpp index 0780ce22ff..8102b3f15c 100644 --- a/scene/3d/scenario_fx.cpp +++ b/scene/3d/scenario_fx.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/scenario_fx.h b/scene/3d/scenario_fx.h index d1e0a63130..acf6a18526 100644 --- a/scene/3d/scenario_fx.h +++ b/scene/3d/scenario_fx.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index 94db247d7a..d0e0937eca 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h index a6546af64e..fdc1100472 100644 --- a/scene/3d/skeleton.h +++ b/scene/3d/skeleton.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 2c1ef5c00b..7db3bb18bd 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -286,37 +286,6 @@ Transform Spatial::get_global_transform() const { return data.global_transform; } -#if 0 -void Spatial::add_child_notify(Node *p_child) { -/* - Spatial *s=Object::cast_to<Spatial>(p_child); - if (!s) - return; - - ERR_FAIL_COND(data.children_lock>0); - - s->data.dirty=DIRTY_GLOBAL; // don't allow global transform to be valid - s->data.parent=this; - data.children.push_back(s); - s->data.C=data.children.back(); -*/ -} - -void Spatial::remove_child_notify(Node *p_child) { -/* - Spatial *s=Object::cast_to<Spatial>(p_child); - if (!s) - return; - - ERR_FAIL_COND(data.children_lock>0); - - if (s->data.C) - data.children.erase(s->data.C); - s->data.parent=NULL; - s->data.C=NULL; -*/ -} -#endif Spatial *Spatial::get_parent_spatial() const { diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index 3e647927ae..3f205ea86b 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/spatial_indexer.cpp b/scene/3d/spatial_indexer.cpp deleted file mode 100644 index 7090c974a3..0000000000 --- a/scene/3d/spatial_indexer.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/*************************************************************************/ -/* spatial_indexer.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "spatial_indexer.h" - -#if 0 - -#include "camera.h" -#include "proximity_area.h" -#include "scene/scene_string_names.h" - -void SpatialIndexer::add_camera(Camera* p_camera) { - - cameras.insert(p_camera); -} - -void SpatialIndexer::remove_camera(Camera* p_camera){ - - for (Set<ProximityArea*>::Element *F=proximity_areas.front();F;F=F->next()) { - - ProximityArea *prox = F->get(); - TK<Camera> k; - k.against=p_camera; - k.area=prox; - if (camera_pairs.has(k)) { - camera_pairs.erase(k); - prox->area_exit(ProximityArea::TRACK_CAMERAS,p_camera); - } - } - cameras.erase(p_camera); - -} - -void SpatialIndexer::update_camera(Camera* p_camera) { - - - _request_update(); -} - -void SpatialIndexer::_update_pairs() { - - // brute force interseciton code, no broadphase - // will implement broadphase in the future - - for (Set<Camera*>::Element *E=cameras.front();E;E=E->next()) { - - Camera *cam = E->get(); - Vector<Plane> cplanes = cam->get_frustum(); - - for (Set<ProximityArea*>::Element *F=proximity_areas.front();F;F=F->next()) { - - ProximityArea *prox = F->get(); - - bool inters=false; - - if (prox->get_track_flag(ProximityArea::TRACK_CAMERAS)) { - - AABB aabb = prox->get_global_transform().xform(prox->get_aabb()); - if (aabb.intersects_convex_shape(cplanes.ptr(),cplanes.size())) - inters=true; - } - - TK<Camera> k; - k.against=cam; - k.area=prox; - - bool has = camera_pairs.has(k); - - if (inters==has) - continue; - - if (inters) { - camera_pairs.insert(k); - prox->area_enter(ProximityArea::TRACK_CAMERAS,cam); - } else { - - camera_pairs.erase(k); - prox->area_exit(ProximityArea::TRACK_CAMERAS,cam); - } - } - - } - - pending_update=false; -} - -void SpatialIndexer::_bind_methods() { - - - ClassDB::bind_method(D_METHOD("_update_pairs"),&SpatialIndexer::_update_pairs); -} - - -void SpatialIndexer::add_proximity_area(ProximityArea* p_area) { - - proximity_areas.insert(p_area); - -} - -void SpatialIndexer::remove_proximity_area(ProximityArea* p_area) { - - for (Set<Camera*>::Element *E=cameras.front();E;E=E->next()) { - - Camera *cam = E->get(); - TK<Camera> k; - k.against=cam; - k.area=p_area; - if (camera_pairs.has(k)) { - camera_pairs.erase(k); - p_area->area_exit(ProximityArea::TRACK_CAMERAS,cam); - } - } - proximity_areas.erase(p_area); - -} - -void SpatialIndexer::_request_update() { - - if (pending_update) - return; - pending_update=true; - call_deferred(SceneStringNames::get_singleton()->_update_pairs); - -} - -void SpatialIndexer::update_proximity_area_transform(ProximityArea* p_area) { - - _request_update(); -} - -void SpatialIndexer::update_proximity_area_flags(ProximityArea* p_area) { - - _request_update(); -} - -SpatialIndexer::SpatialIndexer() { - - pending_update=false; -} -#endif diff --git a/scene/3d/spatial_indexer.h b/scene/3d/spatial_indexer.h deleted file mode 100644 index c8bdf8950d..0000000000 --- a/scene/3d/spatial_indexer.h +++ /dev/null @@ -1,84 +0,0 @@ -/*************************************************************************/ -/* spatial_indexer.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 SPATIAL_INDEXER_H -#define SPATIAL_INDEXER_H - -#include "scene/3d/spatial.h" -#if 0 - -class Camera; -class ProximityArea; - -class SpatialIndexer : public Object { - - GDCLASS( SpatialIndexer, Object ); - - template<class T> - struct TK { - - T *against; - ProximityArea *area; - bool operator<(const TK<T>& p_k) const { return against==p_k.against ? area < p_k.area : against < p_k.against; } - }; - - - Set<Camera*> cameras; //cameras - Set<ProximityArea*> proximity_areas; - - Set<TK<Camera> > camera_pairs; - - bool pending_update; - void _update_pairs(); - void _request_update(); - -protected: - - static void _bind_methods(); - -friend class ProximityArea; -friend class Camera; - - void add_proximity_area(ProximityArea* p_area); - void remove_proximity_area(ProximityArea* p_area); - void update_proximity_area_transform(ProximityArea* p_area); - void update_proximity_area_flags(ProximityArea* p_area); - - void add_camera(Camera* p_camera); - void remove_camera(Camera* p_camera); - void update_camera(Camera* p_camera); - -public: - - - SpatialIndexer(); - -}; -#endif -#endif // SPATIAL_INDEXER_H diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index a49fd17746..49a3205f21 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -598,219 +598,6 @@ Sprite3D::Sprite3D() { //////////////////////////////////////// -#if 0 - -void AnimatedSprite3D::_draw() { - - RID immediate = get_immediate(); - VS::get_singleton()->immediate_clear(immediate); - - if (!frames.is_valid() || !frames->get_frame_count(animation) || frame<0 || frame>=frames->get_frame_count(animation)) { - return; - } - - Ref<Texture> texture = frames->get_frame(animation,frame); - if (!texture.is_valid()) - return; //no texuture no life - Vector2 tsize = texture->get_size(); - if (tsize.x==0 || tsize.y==0) - return; - - Size2i s=tsize; - Rect2i src_rect; - - src_rect.size=s; - - Point2i ofs=get_offset(); - if (is_centered()) - ofs-=s/2; - - Rect2i dst_rect(ofs,s); - - - Rect2 final_rect; - Rect2 final_src_rect; - if (!texture->get_rect_region(dst_rect,src_rect,final_rect,final_src_rect)) - return; - - - if (final_rect.size.x==0 || final_rect.size.y==0) - return; - - Color color=_get_color_accum(); - color.a*=get_opacity(); - - float pixel_size=get_pixel_size(); - - Vector2 vertices[4]={ - - (final_rect.pos+Vector2(0,final_rect.size.y)) * pixel_size, - (final_rect.pos+final_rect.size) * pixel_size, - (final_rect.pos+Vector2(final_rect.size.x,0)) * pixel_size, - final_rect.pos * pixel_size, - - - }; - Vector2 uvs[4]={ - final_src_rect.pos / tsize, - (final_src_rect.pos+Vector2(final_src_rect.size.x,0)) / tsize, - (final_src_rect.pos+final_src_rect.size) / tsize, - (final_src_rect.pos+Vector2(0,final_src_rect.size.y)) / tsize, - }; - - if (is_flipped_h()) { - SWAP(uvs[0],uvs[1]); - SWAP(uvs[2],uvs[3]); - } - if (is_flipped_v()) { - - SWAP(uvs[0],uvs[3]); - SWAP(uvs[1],uvs[2]); - } - - - Vector3 normal; - int axis = get_axis(); - normal[axis]=1.0; - - RID mat = VS::get_singleton()->material_2d_get(get_draw_flag(FLAG_SHADED),get_draw_flag(FLAG_TRANSPARENT),get_alpha_cut_mode()==ALPHA_CUT_DISCARD,get_alpha_cut_mode()==ALPHA_CUT_OPAQUE_PREPASS); - VS::get_singleton()->immediate_set_material(immediate,mat); - - VS::get_singleton()->immediate_begin(immediate,VS::PRIMITIVE_TRIANGLE_FAN,texture->get_rid()); - - int x_axis = ((axis + 1) % 3); - int y_axis = ((axis + 2) % 3); - - if (axis!=Vector3::AXIS_Z) { - SWAP(x_axis,y_axis); - - for(int i=0;i<4;i++) { - //uvs[i] = Vector2(1.0,1.0)-uvs[i]; - //SWAP(vertices[i].x,vertices[i].y); - if (axis==Vector3::AXIS_Y) { - vertices[i].y = - vertices[i].y; - } else if (axis==Vector3::AXIS_X) { - vertices[i].x = - vertices[i].x; - } - } - } - - AABB aabb; - - for(int i=0;i<4;i++) { - VS::get_singleton()->immediate_normal(immediate,normal); - VS::get_singleton()->immediate_color(immediate,color); - VS::get_singleton()->immediate_uv(immediate,uvs[i]); - - Vector3 vtx; - vtx[x_axis]=vertices[i][0]; - vtx[y_axis]=vertices[i][1]; - VS::get_singleton()->immediate_vertex(immediate,vtx); - if (i==0) { - aabb.pos=vtx; - aabb.size=Vector3(); - } else { - aabb.expand_to(vtx); - } - } - set_aabb(aabb); - VS::get_singleton()->immediate_end(immediate); - -} - -void AnimatedSprite3D::_bind_methods(){ - - ClassDB::bind_method(D_METHOD("set_sprite_frames","sprite_frames"),&AnimatedSprite3D::set_sprite_frames); - ClassDB::bind_method(D_METHOD("get_sprite_frames"),&AnimatedSprite3D::get_sprite_frames); - ClassDB::bind_method(D_METHOD("set_frame","frame"),&AnimatedSprite3D::set_frame); - ClassDB::bind_method(D_METHOD("get_frame"),&AnimatedSprite3D::get_frame); - - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE,"SpriteFrames"), "set_sprite_frames","get_sprite_frames"); - ADD_PROPERTY( PropertyInfo( Variant::INT, "frame",PROPERTY_HINT_SPRITE_FRAME), "set_frame","get_frame"); - - ADD_SIGNAL(MethodInfo("frame_changed")); - -} - - - - -void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames>& p_sprite_frames) { - - - if (frames==p_sprite_frames) - return; - - if (frames.is_valid()) - frames->disconnect("changed",this,"_queue_update"); - frames=p_sprite_frames; - if (frames.is_valid()) - frames->connect("changed",this,"_queue_update"); - - if (!frames.is_valid() || frame >=frames->get_frame_count(animation)) { - frame=0; - - } - _queue_update(); - -} - -Ref<SpriteFrames> AnimatedSprite3D::get_sprite_frames() const{ - - return frames; -} - -void AnimatedSprite3D::set_frame(int p_frame){ - - if (frames.is_null()) - return; - - ERR_FAIL_INDEX(p_frame,frames->get_frame_count(animation)); - - if (frame==p_frame) - return; - - frame=p_frame; - _queue_update(); - emit_signal(SceneStringNames::get_singleton()->frame_changed); - -} -int AnimatedSprite3D::get_frame() const{ - - return frame; -} - -Rect2 AnimatedSprite3D::get_item_rect() const { - - if (!frames.is_valid() || !frames->get_frame_count(animation) || frame<0 || frame>=frames->get_frame_count(animation)) { - return Rect2(0,0,1,1); - } - - Ref<Texture> t = frames->get_frame(animation,frame); - if (t.is_null()) - return Rect2(0,0,1,1); - Size2i s = t->get_size(); - - Point2i ofs=get_offset(); - if (is_centered()) - ofs-=s/2; - - if (s==Size2(0,0)) - s=Size2(1,1); - - return Rect2(ofs,s); -} - - - -AnimatedSprite3D::AnimatedSprite3D() { - - animation="current"; - frame=0; -} - -#endif - void AnimatedSprite3D::_draw() { RID immediate = get_immediate(); @@ -1022,63 +809,6 @@ void AnimatedSprite3D::_notification(int p_what) { timeout -= to_process; } } break; -#if 0 - case NOTIFICATION_DRAW: { - - if (frames.is_null()) { - print_line("no draw no faemos"); - return; - } - - if (frame<0) { - print_line("no draw frame <0"); - return; - } - - if (!frames->has_animation(animation)) { - print_line("no draw no anim: "+String(animation)); - return; - } - - - - Ref<Texture> texture = frames->get_frame(animation,frame); - if (texture.is_null()) { - print_line("no draw texture is null"); - return; - } - - //print_line("DECIDED TO DRAW"); - - RID ci = get_canvas_item(); - - /* - texture->draw(ci,Point2()); - break; - */ - - Size2i s; - s = texture->get_size(); - Point2 ofs=offset; - if (centered) - ofs-=s/2; - - if (OS::get_singleton()->get_use_pixel_snap()) { - ofs=ofs.floor(); - } - Rect2 dst_rect(ofs,s); - - if (hflip) - dst_rect.size.x=-dst_rect.size.x; - if (vflip) - dst_rect.size.y=-dst_rect.size.y; - - //texture->draw_rect(ci,dst_rect,false,modulate); - texture->draw_rect_region(ci,dst_rect,Rect2(Vector2(),texture->get_size()),modulate); - //VisualServer::get_singleton()->canvas_item_add_texture_rect_region(ci,dst_rect,texture->get_rid(),src_rect,modulate); - - } break; -#endif } } diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 7dc4cd4ffb..1165392cb2 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -181,37 +181,6 @@ public: //~Sprite3D(); }; -#if 0 -class AnimatedSprite3D : public SpriteBase3D { - - GDCLASS(AnimatedSprite3D,SpriteBase3D); - Ref<SpriteFrames> frames; - - - StringName animation; - int frame; - -protected: - virtual void _draw(); - static void _bind_methods(); -public: - - - - void set_sprite_frames(const Ref<SpriteFrames>& p_sprite_frames); - Ref<SpriteFrames> get_sprite_frames() const; - - void set_frame(int p_frame); - int get_frame() const; - - - virtual Rect2 get_item_rect() const; - - AnimatedSprite3D(); - //~AnimatedSprite3D(); -}; -#endif - class AnimatedSprite3D : public SpriteBase3D { GDCLASS(AnimatedSprite3D, SpriteBase3D); diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index 69b938b886..d6b3206fbf 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/vehicle_body.h b/scene/3d/vehicle_body.h index d778800814..d67209c58f 100644 --- a/scene/3d/vehicle_body.h +++ b/scene/3d/vehicle_body.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp index 76bca2b975..d3203bacec 100644 --- a/scene/3d/visibility_notifier.cpp +++ b/scene/3d/visibility_notifier.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/visibility_notifier.h b/scene/3d/visibility_notifier.h index 316b2c3575..0b83e0534e 100644 --- a/scene/3d/visibility_notifier.h +++ b/scene/3d/visibility_notifier.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp index 1ca6ec42d9..0464a82f65 100644 --- a/scene/3d/visual_instance.cpp +++ b/scene/3d/visual_instance.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h index 4751d109e6..c405236d2c 100644 --- a/scene/3d/visual_instance.h +++ b/scene/3d/visual_instance.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -76,8 +76,6 @@ public: ~VisualInstance(); }; -class BakedLight; - class GeometryInstance : public VisualInstance { GDCLASS(GeometryInstance, VisualInstance); diff --git a/scene/SCsub b/scene/SCsub index df52e9c6cb..513adeffda 100644 --- a/scene/SCsub +++ b/scene/SCsub @@ -27,7 +27,6 @@ SConscript('2d/SCsub') SConscript('animation/SCsub') SConscript('audio/SCsub') SConscript('resources/SCsub') -SConscript('io/SCsub') # Build it all as a library diff --git a/scene/animation/animation_cache.cpp b/scene/animation/animation_cache.cpp index 557858f24c..b35b2568d1 100644 --- a/scene/animation/animation_cache.cpp +++ b/scene/animation/animation_cache.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/animation/animation_cache.h b/scene/animation/animation_cache.h index 6687098d00..e593668df6 100644 --- a/scene/animation/animation_cache.h +++ b/scene/animation/animation_cache.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index b941157756..be0b652276 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -608,16 +608,6 @@ void AnimationPlayer::_animation_update_transforms() { ERR_CONTINUE(pa->accum_pass != accum_pass); -#if 1 - /* switch(pa->special) { - - - case SP_NONE: pa->object->set(pa->prop,pa->value_accum); break; //you are not speshul - case SP_NODE2D_POS: static_cast<Node2D*>(pa->object)->set_position(pa->value_accum); break; - case SP_NODE2D_ROT: static_cast<Node2D*>(pa->object)->set_rot(Math::deg2rad(pa->value_accum)); break; - case SP_NODE2D_SCALE: static_cast<Node2D*>(pa->object)->set_scale(pa->value_accum); break; - }*/ - switch (pa->special) { case SP_NONE: { @@ -657,10 +647,6 @@ void AnimationPlayer::_animation_update_transforms() { static_cast<Node2D *>(pa->object)->set_scale(pa->value_accum); } break; } -#else - - pa->object->set(pa->prop, pa->value_accum); -#endif } cache_update_prop_size = 0; @@ -668,8 +654,6 @@ void AnimationPlayer::_animation_update_transforms() { void AnimationPlayer::_animation_process(float p_delta) { - //bool any_active=false; - if (playback.current.from) { end_notify = false; diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index 01b709205a..c6e52145a8 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 1c4a66a607..e2330eb0d4 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h index 47f18795bd..71d7277118 100644 --- a/scene/animation/animation_tree_player.h +++ b/scene/animation/animation_tree_player.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 45994ba050..3cd953773f 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/animation/tween.h b/scene/animation/tween.h index 43234fab86..929d63a7fc 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp index 434f4df3e1..8f543a575a 100644 --- a/scene/animation/tween_interpolaters.cpp +++ b/scene/animation/tween_interpolaters.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index 5f3ff9efe7..5d71f702df 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/audio/audio_player.h b/scene/audio/audio_player.h index 8bd6844dec..4bfa84f766 100644 --- a/scene/audio/audio_player.h +++ b/scene/audio/audio_player.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 9054063a4b..8fd19e8655 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "base_button.h" + #include "os/keyboard.h" #include "print_string.h" #include "scene/main/viewport.h" diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h index dfcf3b0f8a..0c08dc53a3 100644 --- a/scene/gui/base_button.h +++ b/scene/gui/base_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index e0c73e4788..739fd84b38 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/box_container.h b/scene/gui/box_container.h index d544ff79d1..4d00a2011f 100644 --- a/scene/gui/box_container.h +++ b/scene/gui/box_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index c8838f3eca..1fa03f81f4 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/button.h b/scene/gui/button.h index 499e44c0e1..dd6e730b86 100644 --- a/scene/gui/button.h +++ b/scene/gui/button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/button_group.cpp b/scene/gui/button_group.cpp index fbc2cd8cce..336c88fe9d 100644 --- a/scene/gui/button_group.cpp +++ b/scene/gui/button_group.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/button_group.h b/scene/gui/button_group.h index 93c3aaaeb3..6ebc0575d2 100644 --- a/scene/gui/button_group.h +++ b/scene/gui/button_group.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp index 2bd07d3849..8c9c9d8720 100644 --- a/scene/gui/center_container.cpp +++ b/scene/gui/center_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/center_container.h b/scene/gui/center_container.h index 30b526e893..4397539046 100644 --- a/scene/gui/center_container.h +++ b/scene/gui/center_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index b61d516599..21e2269141 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h index ec8e097bae..4a1adb5f2f 100644 --- a/scene/gui/check_box.h +++ b/scene/gui/check_box.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index 1c3d4df308..e68159e27f 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h index 8634858cfe..af3b80fe04 100644 --- a/scene/gui/check_button.h +++ b/scene/gui/check_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index cdb4a19232..704c00b1d6 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index d35182e062..7de67a707c 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp index 0641302b1c..6b5247648e 100644 --- a/scene/gui/color_rect.cpp +++ b/scene/gui/color_rect.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/color_rect.h b/scene/gui/color_rect.h index 65da3d9a7c..382648fddf 100644 --- a/scene/gui/color_rect.h +++ b/scene/gui/color_rect.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index 31a03dc597..ba5d92620b 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/container.h b/scene/gui/container.h index bff24c6d55..60a7a9efcb 100644 --- a/scene/gui/container.h +++ b/scene/gui/container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 96cda69bb2..e2da5e4981 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/control.h b/scene/gui/control.h index d73ca3f7c9..da5c4d0908 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -33,7 +33,7 @@ #include "math_2d.h" #include "rid.h" #include "scene/2d/canvas_item.h" -#include "scene/gui/input_action.h" +#include "scene/gui/shortcut.h" #include "scene/main/node.h" #include "scene/main/timer.h" #include "scene/resources/theme.h" diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 88d3860fb0..140d002387 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h index 9d8f113caa..54cc290b05 100644 --- a/scene/gui/dialogs.h +++ b/scene/gui/dialogs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 0b898c4d2e..990c0f3d96 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 9873a677b2..34cecfe4d0 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 22de28ea7f..c9ce5e2143 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/gradient_edit.h b/scene/gui/gradient_edit.h index 6c4ae6fd15..026e4f783b 100644 --- a/scene/gui/gradient_edit.h +++ b/scene/gui/gradient_edit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 5703564ce2..5b00aab2ef 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "graph_edit.h" + #include "os/input.h" #include "os/keyboard.h" #include "scene/gui/box_container.h" @@ -593,8 +594,6 @@ void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors, void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, const Color &p_to_color) { -#if 1 - //cubic bezier code float diff = p_to.x - p_from.x; float cp_offset; @@ -621,84 +620,53 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const colors.push_back(p_to_color); p_where->draw_polyline_colors(points, colors, 2, true); - -#else - - static const int steps = 20; - - //old cosine code - Rect2 r; - r.pos = p_from; - r.expand_to(p_to); - Vector2 sign = Vector2((p_from.x < p_to.x) ? 1 : -1, (p_from.y < p_to.y) ? 1 : -1); - bool flip = sign.x * sign.y < 0; - - Vector2 prev; - for (int i = 0; i <= steps; i++) { - - float d = i / float(steps); - float c = -Math::cos(d * Math_PI) * 0.5 + 0.5; - if (flip) - c = 1.0 - c; - Vector2 p = r.pos + Vector2(d * r.size.width, c * r.size.height); - - if (i > 0) { - - p_where->draw_line(prev, p, p_color.linear_interpolate(p_to_color, d), 2); - } - - prev = p; - } -#endif } void GraphEdit::_connections_layer_draw() { - { - //draw connections - List<List<Connection>::Element *> to_erase; - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - - NodePath fromnp(E->get().from); + //draw connections + List<List<Connection>::Element *> to_erase; + for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - Node *from = get_node(fromnp); - if (!from) { - to_erase.push_back(E); - continue; - } + NodePath fromnp(E->get().from); - GraphNode *gfrom = Object::cast_to<GraphNode>(from); + Node *from = get_node(fromnp); + if (!from) { + to_erase.push_back(E); + continue; + } - if (!gfrom) { - to_erase.push_back(E); - continue; - } + GraphNode *gfrom = Object::cast_to<GraphNode>(from); - NodePath tonp(E->get().to); - Node *to = get_node(tonp); - if (!to) { - to_erase.push_back(E); - continue; - } + if (!gfrom) { + to_erase.push_back(E); + continue; + } - GraphNode *gto = Object::cast_to<GraphNode>(to); + NodePath tonp(E->get().to); + Node *to = get_node(tonp); + if (!to) { + to_erase.push_back(E); + continue; + } - if (!gto) { - to_erase.push_back(E); - continue; - } + GraphNode *gto = Object::cast_to<GraphNode>(to); - Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom; - Color color = gfrom->get_connection_output_color(E->get().from_port); - Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom; - Color tocolor = gto->get_connection_input_color(E->get().to_port); - _draw_cos_line(connections_layer, frompos, topos, color, tocolor); + if (!gto) { + to_erase.push_back(E); + continue; } - while (to_erase.size()) { - connections.erase(to_erase.front()->get()); - to_erase.pop_front(); - } + Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom; + Color color = gfrom->get_connection_output_color(E->get().from_port); + Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom; + Color tocolor = gto->get_connection_input_color(E->get().to_port); + _draw_cos_line(connections_layer, frompos, topos, color, tocolor); + } + + while (to_erase.size()) { + connections.erase(to_erase.front()->get()); + to_erase.pop_front(); } } diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index e908829d5f..4656b50133 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index f69b1bf147..8730be0c06 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index a7d9e8ddb0..416d711aab 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp index 1a224d1026..5dd5667f46 100644 --- a/scene/gui/grid_container.cpp +++ b/scene/gui/grid_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/grid_container.h b/scene/gui/grid_container.h index aaa6a295ff..45e26ed48e 100644 --- a/scene/gui/grid_container.h +++ b/scene/gui/grid_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index c7889a6cf2..9bad871ef9 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index a80727f568..8166975408 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index cf7303cbe7..5fe3dd0129 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/label.h b/scene/gui/label.h index dce68f4422..7c1905af7d 100644 --- a/scene/gui/label.h +++ b/scene/gui/label.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index c5360b0df0..66b4e6cec1 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 7d04e4618b..52a4a29a33 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index 632e9ec4fc..9fe94fc464 100644 --- a/scene/gui/link_button.cpp +++ b/scene/gui/link_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/link_button.h b/scene/gui/link_button.h index 98a3dc66f6..386eb452ae 100644 --- a/scene/gui/link_button.h +++ b/scene/gui/link_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp index a9f8d9c384..14991f5d44 100644 --- a/scene/gui/margin_container.cpp +++ b/scene/gui/margin_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/margin_container.h b/scene/gui/margin_container.h index 1cdb3a36cc..9703d9ebe0 100644 --- a/scene/gui/margin_container.h +++ b/scene/gui/margin_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index 99e78d8851..ac450616d6 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h index 6bb23452dd..c7f1d976ff 100644 --- a/scene/gui/menu_button.h +++ b/scene/gui/menu_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 00df266a09..b4d0799945 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h index db921b8b97..a06c540678 100644 --- a/scene/gui/option_button.h +++ b/scene/gui/option_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp index f3c6142f9e..536b655f75 100644 --- a/scene/gui/panel.cpp +++ b/scene/gui/panel.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/panel.h b/scene/gui/panel.h index eac8f2d4e8..cc7ca47319 100644 --- a/scene/gui/panel.h +++ b/scene/gui/panel.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp index 45bb81ac75..a0c75d1330 100644 --- a/scene/gui/panel_container.cpp +++ b/scene/gui/panel_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/panel_container.h b/scene/gui/panel_container.h index f8f1fb6494..5d8f1ee64b 100644 --- a/scene/gui/panel_container.h +++ b/scene/gui/panel_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/patch_9_rect.cpp b/scene/gui/patch_9_rect.cpp index 71cbef495c..6b2deeb209 100644 --- a/scene/gui/patch_9_rect.cpp +++ b/scene/gui/patch_9_rect.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/patch_9_rect.h b/scene/gui/patch_9_rect.h index 636b9127e7..4cf93e4c05 100644 --- a/scene/gui/patch_9_rect.h +++ b/scene/gui/patch_9_rect.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 348d0aa460..5a2a552943 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -59,17 +59,10 @@ void Popup::_notification(int p_what) { void Popup::_fix_size() { -#if 0 - Point2 pos = get_position(); - Size2 size = get_size(); - Point2 window_size = window==this ? get_parent_area_size() :window->get_size(); -#else - Point2 pos = get_global_position(); Size2 size = get_size(); Point2 window_size = get_viewport_rect().size; -#endif if (pos.x + size.width > window_size.width) pos.x = window_size.width - size.width; if (pos.x < 0) @@ -79,14 +72,8 @@ void Popup::_fix_size() { pos.y = window_size.height - size.height; if (pos.y < 0) pos.y = 0; -#if 0 - if (pos!=get_pos()) - set_position(pos); -#else if (pos != get_position()) set_global_position(pos); - -#endif } void Popup::set_as_minsize() { diff --git a/scene/gui/popup.h b/scene/gui/popup.h index 0543ae1937..6739c580f2 100644 --- a/scene/gui/popup.h +++ b/scene/gui/popup.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 79caf1c836..f3711b86b6 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index 37714ee989..c9e9c8e311 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp index 13d368d253..6953d03384 100644 --- a/scene/gui/progress_bar.cpp +++ b/scene/gui/progress_bar.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/progress_bar.h b/scene/gui/progress_bar.h index 1121a78aab..c5a9252123 100644 --- a/scene/gui/progress_bar.h +++ b/scene/gui/progress_bar.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 74e3b39e04..1dbec6e5a1 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/range.h b/scene/gui/range.h index fdcbbb09ee..daa8af824a 100644 --- a/scene/gui/range.h +++ b/scene/gui/range.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/reference_rect.cpp b/scene/gui/reference_rect.cpp index 441c3e721b..e2f4abe04a 100644 --- a/scene/gui/reference_rect.cpp +++ b/scene/gui/reference_rect.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/reference_rect.h b/scene/gui/reference_rect.h index b118425eb6..9b826a1145 100644 --- a/scene/gui/reference_rect.h +++ b/scene/gui/reference_rect.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index f0efbdc517..a3f116c883 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 71fa766958..74bf180b5d 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 737765aa1a..16d1b320b7 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,9 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "scroll_bar.h" + #include "os/keyboard.h" #include "os/os.h" #include "print_string.h" + bool ScrollBar::focus_by_default = false; void ScrollBar::set_can_focus_by_default(bool p_can_focus) { @@ -686,138 +688,6 @@ bool ScrollBar::is_smooth_scroll_enabled() const { return smooth_scroll_enabled; } -#if 0 - -void ScrollBar::mouse_button(const Point2& p_pos, int b->get_button_index(),bool b->is_pressed(),int p_modifier_mask) { - - // wheel! - - if (b->get_button_index()==BUTTON_WHEEL_UP && b->is_pressed()) { - - if (orientation==VERTICAL) - set_val( get_val() - get_page() / 4.0 ); - else - set_val( get_val() + get_page() / 4.0 ); - - } - if (b->get_button_index()==BUTTON_WHEEL_DOWN && b->is_pressed()) { - - if (orientation==HORIZONTAL) - set_val( get_val() - get_page() / 4.0 ); - else - set_val( get_val() + get_page() / 4.0 ); - } - - if (b->get_button_index()!=BUTTON_LEFT) - return; - - if (b->is_pressed()) { - - int ofs = orientation==VERTICAL ? p_pos.y : p_pos.x ; - int grabber_ofs = get_grabber_offset(); - int grabber_size = get_grabber_size(); - - if ( ofs < grabber_ofs ) { - - set_val( get_val() - get_page() ); - - } else if (ofs > grabber_ofs + grabber_size ) { - - set_val( get_val() + get_page() ); - - } else { - - - drag.active=true; - drag.pos_at_click=get_click_pos(p_pos); - drag.value_at_click=get_unit_value(); - } - - - } else { - - drag.active=false; - } - -} -void ScrollBar::mouse_motion(const Point2& p_pos, const Point2& p_rel, int b->get_button_index()_mask) { - - if (!drag.active) - return; - - double value_ofs=drag.value_at_click+(get_click_pos(p_pos)-drag.pos_at_click); - - - value_ofs=value_ofs*( get_max() - get_min() ); - if (value_ofs<get_min()) - value_ofs=get_min(); - if (value_ofs>(get_max()-get_page())) - value_ofs=get_max()-get_page(); - if (get_val()==value_ofs) - return; //don't bother if the value is the same - - set_val( value_ofs ); - -} - -bool ScrollBar::key(unsigned long p_unicode, unsigned long p_scan_code,bool b->is_pressed(),bool p_repeat,int p_modifier_mask) { - - if (!b->is_pressed()) - return false; - - switch (p_scan_code) { - - case KEY_LEFT: { - - if (orientation!=HORIZONTAL) - return false; - set_val( get_val() - get_step() ); - - } break; - case KEY_RIGHT: { - - if (orientation!=HORIZONTAL) - return false; - set_val( get_val() + get_step() ); - - } break; - case KEY_UP: { - - if (orientation!=VERTICAL) - return false; - - set_val( get_val() - get_step() ); - - - } break; - case KEY_DOWN: { - - if (orientation!=VERTICAL) - return false; - set_val( get_val() + get_step() ); - - } break; - case KEY_HOME: { - - set_val( get_min() ); - - } break; - case KEY_END: { - - set_val( get_max() ); - - } break; - - default: - return false; - - } - - return true; -} - -#endif - void ScrollBar::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollBar::_gui_input); diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h index e22d4da46d..373483a8a0 100644 --- a/scene/gui/scroll_bar.h +++ b/scene/gui/scroll_bar.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index db94146970..e182e491d3 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h index e5df3e5e1c..9076be0d72 100644 --- a/scene/gui/scroll_container.h +++ b/scene/gui/scroll_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/separator.cpp b/scene/gui/separator.cpp index 3b00ab4605..3db234f7cc 100644 --- a/scene/gui/separator.cpp +++ b/scene/gui/separator.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/separator.h b/scene/gui/separator.h index 9a5fe2ac66..be2f1e8e77 100644 --- a/scene/gui/separator.h +++ b/scene/gui/separator.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/input_action.cpp b/scene/gui/shortcut.cpp index c08059a049..f37410e77b 100644 --- a/scene/gui/input_action.cpp +++ b/scene/gui/shortcut.cpp @@ -1,9 +1,9 @@ /*************************************************************************/ -/* input_action.cpp */ +/* shortcut.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -27,7 +27,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "input_action.h" +#include "shortcut.h" + #include "os/keyboard.h" void ShortCut::set_shortcut(const Ref<InputEvent> &p_shortcut) { @@ -52,61 +53,6 @@ String ShortCut::get_as_text() const { return shortcut->as_text(); else return "None"; -#if 0 - switch (shortcut.type) { - - case Ref<InputEvent>::NONE: { - - return "None"; - } break; - case Ref<InputEvent>::KEY: { - - String str; - if (shortcut->get_shift()) - str += RTR("Shift+"); - if (shortcut->get_alt()) - str += RTR("Alt+"); - if (shortcut->get_control()) - str += RTR("Ctrl+"); - if (shortcut->get_metakey()) - str += RTR("Meta+"); - - str += keycode_get_string(shortcut->get_scancode()).capitalize(); - - return str; - } break; - case Ref<InputEvent>::JOYPAD_BUTTON: { - - String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Button") + " " + itos(shortcut.joy_button->get_button_index()); - str += "."; - - return str; - } break; - case Ref<InputEvent>::MOUSE_BUTTON: { - - String str = RTR("Device") + " " + itos(shortcut.device) + ", "; - switch (shortcut->get_button_index()) { - case BUTTON_LEFT: str += RTR("Left Button."); break; - case BUTTON_RIGHT: str += RTR("Right Button."); break; - case BUTTON_MIDDLE: str += RTR("Middle Button."); break; - case BUTTON_WHEEL_UP: str += RTR("Wheel Up."); break; - case BUTTON_WHEEL_DOWN: str += RTR("Wheel Down."); break; - default: str += RTR("Button") + " " + itos(shortcut->get_button_index()) + "."; - } - - return str; - } break; - case Ref<InputEvent>::JOYPAD_MOTION: { - - int ax = shortcut.joy_motion.axis; - String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Axis") + " " + itos(ax) + "."; - - return str; - } break; - } - - return ""; -#endif } bool ShortCut::is_valid() const { diff --git a/scene/gui/input_action.h b/scene/gui/shortcut.h index 5c91d2be28..8d85bb920f 100644 --- a/scene/gui/input_action.h +++ b/scene/gui/shortcut.h @@ -1,9 +1,9 @@ /*************************************************************************/ -/* input_action.h */ +/* shortcut.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -27,8 +27,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef INPUTACTION_H -#define INPUTACTION_H +#ifndef SHORTCUT_H +#define SHORTCUT_H #include "os/input_event.h" #include "resource.h" @@ -53,4 +53,4 @@ public: ShortCut(); }; -#endif // INPUTACTION_H +#endif // SHORTCUT_H diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 9ba17ce34f..4661f54526 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/slider.h b/scene/gui/slider.h index f3cf3c6f48..a2334a69fc 100644 --- a/scene/gui/slider.h +++ b/scene/gui/slider.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 751edc5a43..f462989f53 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 683ed0c344..0c562bd744 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 5515c0f0cd..4420a936d2 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h index 87a210f24c..8ec21b5eaa 100644 --- a/scene/gui/split_container.h +++ b/scene/gui/split_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 8afcc896a3..461ae3444b 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h index 3e1a2c1598..be59a16b3f 100644 --- a/scene/gui/tab_container.h +++ b/scene/gui/tab_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index b0dc88bbb4..085f6de6b8 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index 86ad128dcd..73fa40bbb8 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 58637ef72f..7a9daea73e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -27,13 +27,12 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "text_edit.h" + +#include "message_queue.h" #include "os/input.h" #include "os/keyboard.h" #include "os/os.h" - -#include "message_queue.h" #include "project_settings.h" #include "scene/main/viewport.h" @@ -4471,18 +4470,6 @@ void TextEdit::_update_completion_candidates() { // The top of the list is the best match completion_current = completion_options[0]; - -#if 0 // even there's only one option, user still get the chance to choose using it or not - if (completion_options.size()==1) { - //one option to complete, just complete it automagically - _confirm_completion(); - //insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length())); - _cancel_completion(); - return; - - } -#endif - completion_enabled = true; } @@ -4909,24 +4896,6 @@ TextEdit::TextEdit() { click_select_held->set_wait_time(0.05); click_select_held->connect("timeout", this, "_click_selection_held"); -#if 0 - syntax_coloring=true; - keywords["void"]=Color(0.3,0.0,0.1); - keywords["int"]=Color(0.3,0.0,0.1); - keywords["function"]=Color(0.3,0.0,0.1); - keywords["class"]=Color(0.3,0.0,0.1); - keywords["extends"]=Color(0.3,0.0,0.1); - keywords["constructor"]=Color(0.3,0.0,0.1); - symbol_color=Color(0.1,0.0,0.3,1.0); - - color_regions.push_back(ColorRegion("/*","*/",Color(0.4,0.6,0,4))); - color_regions.push_back(ColorRegion("//","",Color(0.6,0.6,0.4))); - color_regions.push_back(ColorRegion("\"","\"",Color(0.4,0.7,0.7))); - color_regions.push_back(ColorRegion("'","'",Color(0.4,0.8,0.8))); - color_regions.push_back(ColorRegion("#","",Color(0.2,1.0,0.2))); - -#endif - current_op.type = TextOperation::TYPE_NONE; undo_enabled = true; undo_stack_pos = NULL; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 7ab26322e7..68ef559f46 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index d307b463d9..77bc876201 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h index 8df30cd35a..94f372decf 100644 --- a/scene/gui/texture_button.h +++ b/scene/gui/texture_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp index 59cff84719..aad7c6b96b 100644 --- a/scene/gui/texture_progress.cpp +++ b/scene/gui/texture_progress.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h index 20546bd11f..04096d35e3 100644 --- a/scene/gui/texture_progress.h +++ b/scene/gui/texture_progress.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index db340fd4d7..38f90fe7b5 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_rect.h b/scene/gui/texture_rect.h index dcc6c3f9bd..8a2b715488 100644 --- a/scene/gui/texture_rect.h +++ b/scene/gui/texture_rect.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tool_button.cpp b/scene/gui/tool_button.cpp index 5fc4b6ecf8..4dfa3d8f37 100644 --- a/scene/gui/tool_button.cpp +++ b/scene/gui/tool_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tool_button.h b/scene/gui/tool_button.h index d243b5559f..4c5ea685de 100644 --- a/scene/gui/tool_button.h +++ b/scene/gui/tool_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index a40d1acb8f..5e15bceb7d 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "tree.h" + #include "os/input.h" #include "os/keyboard.h" #include "os/os.h" @@ -990,41 +991,10 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co rect.size.x -= bmsize.x + cache.hseparation; } - /* - if (p_tool) - rect.size.x-=Math::floor(rect.size.y/2); - */ - rect.position.y += Math::floor((rect.size.y - font->get_height()) / 2.0) + font->get_ascent(); font->draw(ci, rect.position, text, p_color, rect.size.x); } -#if 0 -void Tree::draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color) { - - RID ci = get_canvas_item(); - if (!p_icon.is_null()) { - Size2i bmsize = p_icon->get_size(); - if (p_icon_max_w>0 && bmsize.width > p_icon_max_w) { - bmsize.height = bmsize.height * p_icon_max_w / bmsize.width; - bmsize.width=p_icon_max_w; - } - - draw_texture_rect(p_icon,Rect2(p_rect.pos + Size2i(0,Math::floor((p_rect.size.y-bmsize.y)/2)),bmsize)); - p_rect.pos.x+=bmsize.x+cache.hseparation; - p_rect.size.x-=bmsize.x+cache.hseparation; - - } - - if (p_tool) - p_rect.size.x-=Math::floor(p_rect.size.y/2); - - Ref<Font> font = cache.font; - - p_rect.pos.y+=Math::floor((p_rect.size.y-font->get_height())/2.0) +font->get_ascent(); - font->draw(ci,p_rect.pos,p_text,p_color,p_rect.size.x); -} -#endif int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item) { if (p_pos.y - cache.offset.y > (p_draw_size.height)) diff --git a/scene/gui/tree.h b/scene/gui/tree.h index a87f6d89e2..1fb1eb2792 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 37d10fb63e..a92155cc4f 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,27 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "video_player.h" + #include "os/os.h" #include "servers/audio_server.h" -/* - -int VideoPlayer::InternalStream::get_channel_count() const { - - return player->sp_get_channel_count(); -} -void VideoPlayer::InternalStream::set_mix_rate(int p_rate){ - - return player->sp_set_mix_rate(p_rate); -} -bool VideoPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){ - - return player->sp_mix(p_buffer,p_frames); -} -void VideoPlayer::InternalStream::update(){ - - player->sp_update(); -} -*/ int VideoPlayer::sp_get_channel_count() const { @@ -69,31 +51,6 @@ bool VideoPlayer::sp_mix(int32_t *p_buffer, int p_frames) { return false; } -void VideoPlayer::sp_update() { -#if 0 - _THREAD_SAFE_METHOD_ - //update is unused - if (!paused && playback.is_valid()) { - - if (!playback->is_playing()) { - //stream depleted data, but there's still audio in the ringbuffer - //check that all this audio has been flushed before stopping the stream - int to_mix = resampler.get_total() - resampler.get_todo(); - if (to_mix==0) { - stop(); - return; - } - - return; - } - - int todo =resampler.get_todo(); - int wrote = playback->mix(resampler.get_write_buffer(),todo); - resampler.write(wrote); - } -#endif -} - int VideoPlayer::_audio_mix_callback(void *p_udata, const int16_t *p_data, int p_frames) { VideoPlayer *vp = (VideoPlayer *)p_udata; diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index 87c452509b..b78f3aabe7 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -38,23 +38,12 @@ class VideoPlayer : public Control { GDCLASS(VideoPlayer, Control); - /* struct InternalStream : public AudioServer::AudioStream { - VideoPlayer *player; - virtual int get_channel_count() const; - virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate - virtual bool mix(int32_t *p_buffer,int p_frames); - virtual void update(); - }; -*/ - - // InternalStream internal_stream; Ref<VideoStreamPlayback> playback; Ref<VideoStream> stream; int sp_get_channel_count() const; void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate bool sp_mix(int32_t *p_buffer, int p_frames); - void sp_update(); RID stream_rid; @@ -118,4 +107,4 @@ public: ~VideoPlayer(); }; -#endif +#endif // VIDEO_PLAYER_H diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp index 2eb8eaa7d1..c321b873fd 100644 --- a/scene/gui/viewport_container.cpp +++ b/scene/gui/viewport_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/viewport_container.h b/scene/gui/viewport_container.h index 27eb6ec81b..630523b5fb 100644 --- a/scene/gui/viewport_container.h +++ b/scene/gui/viewport_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/io/SCsub b/scene/io/SCsub deleted file mode 100644 index bf9125be7f..0000000000 --- a/scene/io/SCsub +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.scene_sources, "*.cpp") - -Export('env') diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp deleted file mode 100644 index 04b6177c3c..0000000000 --- a/scene/io/resource_format_image.cpp +++ /dev/null @@ -1,266 +0,0 @@ -/*************************************************************************/ -/* resource_format_image.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "resource_format_image.h" - -#if 0 -#include "io/image_loader.h" -#include "os/os.h" -#include "project_settings.h" -#include "scene/resources/texture.h" -RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_original_path, Error *r_error) { - - if (r_error) - *r_error=ERR_CANT_OPEN; - - if (p_path.get_extension()=="cube") { - // open as cubemap txture - - CubeMap* ptr = memnew(CubeMap); - Ref<CubeMap> cubemap( ptr ); - - Error err; - FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err); - if (err) { - - ERR_FAIL_COND_V( err, RES() ); - } - - String base_path=p_path.substr( 0, p_path.find_last("/")+1 ); - - for(int i=0;i<6;i++) { - - String file = f->get_line().strip_edges(); - Image image; - - Error err = ImageLoader::load_image(base_path+file,&image); - - - if (err) { - - memdelete(f); - ERR_FAIL_COND_V( err, RES() ); - } - - if (i==0) { - - //cubemap->create(image.get_width(),image.get_height(),image.get_format(),Texture::FLAGS_DEFAULT|Texture::FLAG_CUBEMAP); - } - - static const CubeMap::Side cube_side[6]= { - CubeMap::SIDE_LEFT, - CubeMap::SIDE_RIGHT, - CubeMap::SIDE_BOTTOM, - CubeMap::SIDE_TOP, - CubeMap::SIDE_FRONT, - CubeMap::SIDE_BACK - }; - - cubemap->set_side(cube_side[i],image); - } - - memdelete(f); - - cubemap->set_name(p_path.get_file()); - if (r_error) - *r_error=OK; - - return cubemap; - - } else { - // simple image - - ImageTexture* ptr = memnew(ImageTexture); - Ref<ImageTexture> texture( ptr ); - - uint64_t begtime; - double total; - - Image image; - - if (debug_load_times) - begtime=OS::get_singleton()->get_ticks_usec(); - - - Error err = ImageLoader::load_image(p_path,&image); - - if (!err && debug_load_times) { - double total=USEC_TO_SEC((OS::get_singleton()->get_ticks_usec()-begtime)); - print_line("IMAGE: "+itos(image.get_width())+"x"+itos(image.get_height())); - print_line(" -load: "+rtos(total)); - } - - - ERR_EXPLAIN("Failed loading image: "+p_path); - ERR_FAIL_COND_V(err, RES()); - if (r_error) - *r_error=ERR_FILE_CORRUPT; - -#ifdef DEBUG_ENABLED -#ifdef TOOLS_ENABLED - - if (max_texture_size && (image.get_width() > max_texture_size || image.get_height() > max_texture_size)) { - - - if (bool(ProjectSettings::get_singleton()->get("debug/image_loader/max_texture_size_alert"))) { - OS::get_singleton()->alert("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+".","BAD ARTIST, NO COOKIE!"); - } - - ERR_EXPLAIN("Texture is too large: '"+p_path+"', at "+itos(image.get_width())+"x"+itos(image.get_height())+". Max allowed size is: "+itos(max_texture_size)+"x"+itos(max_texture_size)+"."); - ERR_FAIL_V(RES()); - } -#endif -#endif - - - uint32_t flags=load_image_flags(p_path); - - if (debug_load_times) - begtime=OS::get_singleton()->get_ticks_usec(); - - //print_line("img: "+p_path+" flags: "+itos(flags)); - texture->create_from_image( image,flags ); - texture->set_name(p_path.get_file()); - - - if (debug_load_times) { - total=USEC_TO_SEC(OS::get_singleton()->get_ticks_usec()-begtime); - print_line(" -make texture: "+rtos(total)); - } - - if (r_error) - *r_error=OK; - - return RES( texture ); - } - - -} - -uint32_t ResourceFormatLoaderImage::load_image_flags(const String &p_path) { - - - FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ); - Map<String,bool> flags_found; - if (f2) { - - while(!f2->eof_reached()) { - String l2 = f2->get_line(); - int eqpos = l2.find("="); - if (eqpos!=-1) { - String flag=l2.substr(0,eqpos).strip_edges(); - String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower(); - flags_found[flag]=(val=="true" || val=="1")?true:false; - } - } - memdelete(f2); - } - - - uint32_t flags=0; - - if (flags_found.has("filter")) { - if (flags_found["filter"]) - flags|=Texture::FLAG_FILTER; - } else if (bool(GLOBAL_DEF("rendering/image_loader/filter",true))) { - flags|=Texture::FLAG_FILTER; - } - - - if (flags_found.has("gen_mipmaps")) { - if (flags_found["gen_mipmaps"]) - flags|=Texture::FLAG_MIPMAPS; - } else if (bool(GLOBAL_DEF("rendering/image_loader/gen_mipmaps",true))) { - flags|=Texture::FLAG_MIPMAPS; - } - - if (flags_found.has("repeat")) { - if (flags_found["repeat"]) - flags|=Texture::FLAG_REPEAT; - } else if (bool(GLOBAL_DEF("rendering/image_loader/repeat",true))) { - flags|=Texture::FLAG_REPEAT; - } - - if (flags_found.has("anisotropic")) { - if (flags_found["anisotropic"]) - flags|=Texture::FLAG_ANISOTROPIC_FILTER; - } - - if (flags_found.has("tolinear")) { - if (flags_found["tolinear"]) - flags|=Texture::FLAG_CONVERT_TO_LINEAR; - } - - if (flags_found.has("mirroredrepeat")) { - if (flags_found["mirroredrepeat"]) - flags|=Texture::FLAG_MIRRORED_REPEAT; - } - - return flags; -} - -bool ResourceFormatLoaderImage::handles_type(const String& p_type) const { - - return ClassDB::is_parent_class(p_type,"Texture") || ClassDB::is_parent_class(p_type,"CubeMap"); -} - -void ResourceFormatLoaderImage::get_recognized_extensions(List<String> *p_extensions) const { - - ImageLoader::get_recognized_extensions(p_extensions); - p_extensions->push_back("cube"); -} - -String ResourceFormatLoaderImage::get_resource_type(const String &p_path) const { - - String ext=p_path.get_extension().to_lower(); - if (ext=="cube") - return "CubeMap"; - - List<String> extensions; - ImageLoader::get_recognized_extensions(&extensions); - - for(List<String>::Element *E=extensions.front();E;E=E->next()) { - if (E->get()==ext) - return "ImageTexture"; - } - return ""; -} - - -ResourceFormatLoaderImage::ResourceFormatLoaderImage() { - - max_texture_size = GLOBAL_DEF("debug/image_loader/max_texture_size",0); - GLOBAL_DEF("debug/image_loader/max_texture_size_alert",false); - debug_load_times=GLOBAL_DEF("debug/image_loader/image_load_times",false); - GLOBAL_DEF("rendering/image_loader/filter",true); - GLOBAL_DEF("rendering/image_loader/gen_mipmaps",true); - GLOBAL_DEF("rendering/image_loader/repeat",false); - -} -#endif diff --git a/scene/io/resource_format_image.h b/scene/io/resource_format_image.h deleted file mode 100644 index 2cf6315f17..0000000000 --- a/scene/io/resource_format_image.h +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************/ -/* resource_format_image.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 RESOURCE_FORMAT_IMAGE_H -#define RESOURCE_FORMAT_IMAGE_H - -#if 0 - -#include "io/resource_loader.h" -#include "io/resource_saver.h" -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ -class ResourceFormatLoaderImage : public ResourceFormatLoader { - - bool debug_load_times; - int max_texture_size; -public: - virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); - static uint32_t load_image_flags(const String &p_path); - virtual void get_recognized_extensions(List<String> *p_extensions) const; - virtual bool handles_type(const String& p_type) const; - virtual String get_resource_type(const String &p_path) const; - - ResourceFormatLoaderImage(); -}; - -#endif -#endif diff --git a/scene/io/resource_format_wav.cpp b/scene/io/resource_format_wav.cpp deleted file mode 100644 index dabbb79de3..0000000000 --- a/scene/io/resource_format_wav.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/*************************************************************************/ -/* resource_format_wav.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#if 0 -#include "resource_format_wav.h" -#include "os/file_access.h" -#include "scene/resources/sample.h" - - -RES ResourceFormatLoaderWAV::load(const String &p_path, const String& p_original_path, Error *r_error) { - if (r_error) - *r_error=ERR_FILE_CANT_OPEN; - - Error err; - FileAccess *file=FileAccess::open(p_path, FileAccess::READ,&err); - - ERR_FAIL_COND_V( err!=OK, RES() ); - - if (r_error) - *r_error=ERR_FILE_CORRUPT; - - /* CHECK RIFF */ - char riff[5]; - riff[4]=0; - file->get_buffer((uint8_t*)&riff,4); //RIFF - - if (riff[0]!='R' || riff[1]!='I' || riff[2]!='F' || riff[3]!='F') { - - file->close(); - memdelete(file); - ERR_FAIL_V( RES() ); - } - - - /* GET FILESIZE */ - uint32_t filesize=file->get_32(); - - /* CHECK WAVE */ - - char wave[4]; - - file->get_buffer((uint8_t*)&wave,4); //RIFF - - if (wave[0]!='W' || wave[1]!='A' || wave[2]!='V' || wave[3]!='E') { - - - file->close(); - memdelete(file); - ERR_EXPLAIN("Not a WAV file (no WAVE RIFF Header)") - ERR_FAIL_V( RES() ); - } - - bool format_found=false; - bool data_found=false; - int format_bits=0; - int format_channels=0; - int format_freq=0; - Sample::LoopFormat loop=Sample::LOOP_NONE; - int loop_begin=0; - int loop_end=0; - - - Ref<Sample> sample( memnew( Sample ) ); - - - while (!file->eof_reached()) { - - - /* chunk */ - char chunkID[4]; - file->get_buffer((uint8_t*)&chunkID,4); //RIFF - - /* chunk size */ - uint32_t chunksize=file->get_32(); - uint32_t file_pos=file->get_position(); //save file pos, so we can skip to next chunk safely - - if (file->eof_reached()) { - - //ERR_PRINT("EOF REACH"); - break; - } - - if (chunkID[0]=='f' && chunkID[1]=='m' && chunkID[2]=='t' && chunkID[3]==' ' && !format_found) { - /* IS FORMAT CHUNK */ - - uint16_t compression_code=file->get_16(); - - - if (compression_code!=1) { - ERR_PRINT("Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead."); - break; - } - - format_channels=file->get_16(); - if (format_channels!=1 && format_channels !=2) { - - ERR_PRINT("Format not supported for WAVE file (not stereo or mono)"); - break; - - } - - format_freq=file->get_32(); //sampling rate - - file->get_32(); // average bits/second (unused) - file->get_16(); // block align (unused) - format_bits=file->get_16(); // bits per sample - - if (format_bits%8) { - - ERR_PRINT("Strange number of bits in sample (not 8,16,24,32)"); - break; - } - - /* Don't need anything else, continue */ - format_found=true; - } - - - if (chunkID[0]=='d' && chunkID[1]=='a' && chunkID[2]=='t' && chunkID[3]=='a' && !data_found) { - /* IS FORMAT CHUNK */ - data_found=true; - - if (!format_found) { - ERR_PRINT("'data' chunk before 'format' chunk found."); - break; - - } - - int frames=chunksize; - - frames/=format_channels; - frames/=(format_bits>>3); - - /*print_line("chunksize: "+itos(chunksize)); - print_line("channels: "+itos(format_channels)); - print_line("bits: "+itos(format_bits)); -*/ - sample->create( - (format_bits==8) ? Sample::FORMAT_PCM8 : Sample::FORMAT_PCM16, - (format_channels==2)?true:false, - frames ); - sample->set_mix_rate( format_freq ); - - int len=frames; - if (format_channels==2) - len*=2; - if (format_bits>8) - len*=2; - - PoolVector<uint8_t> data; - data.resize(len); - PoolVector<uint8_t>::Write dataw = data.write(); - void * data_ptr = dataw.ptr(); - - for (int i=0;i<frames;i++) { - - - for (int c=0;c<format_channels;c++) { - - - if (format_bits==8) { - // 8 bit samples are UNSIGNED - - uint8_t s = file->get_8(); - s-=128; - int8_t *sp=(int8_t*)&s; - - int8_t *data_ptr8=&((int8_t*)data_ptr)[i*format_channels+c]; - - *data_ptr8=*sp; - - } else { - //16+ bits samples are SIGNED - // if sample is > 16 bits, just read extra bytes - - uint32_t data=0; - for (int b=0;b<(format_bits>>3);b++) { - - data|=((uint32_t)file->get_8())<<(b*8); - } - data<<=(32-format_bits); - - - int32_t s=data; - - int16_t *data_ptr16=&((int16_t*)data_ptr)[i*format_channels+c]; - - *data_ptr16=s>>16; - } - } - - } - - dataw=PoolVector<uint8_t>::Write(); - - sample->set_data(data); - - - if (file->eof_reached()) { - file->close(); - memdelete(file); - ERR_EXPLAIN("Premature end of file."); - ERR_FAIL_V(RES()); - } - } - - if (chunkID[0]=='s' && chunkID[1]=='m' && chunkID[2]=='p' && chunkID[3]=='l') { - //loop point info! - - for(int i=0;i<10;i++) - file->get_32(); // i wish to know why should i do this... no doc! - - loop=file->get_32()?Sample::LOOP_PING_PONG:Sample::LOOP_FORWARD; - loop_begin=file->get_32(); - loop_end=file->get_32(); - - } - file->seek( file_pos+chunksize ); - } - - sample->set_loop_format(loop); - sample->set_loop_begin(loop_begin); - sample->set_loop_end(loop_end); - - file->close(); - memdelete(file); - - if (r_error) - *r_error=OK; - - - return sample; - -} -void ResourceFormatLoaderWAV::get_recognized_extensions(List<String> *p_extensions) const { - - p_extensions->push_back("wav"); -} -bool ResourceFormatLoaderWAV::handles_type(const String& p_type) const { - - return (p_type=="Sample"); -} - -String ResourceFormatLoaderWAV::get_resource_type(const String &p_path) const { - - if (p_path.get_extension().to_lower()=="wav") - return "Sample"; - return ""; -} - -#endif diff --git a/scene/io/resource_format_wav.h b/scene/io/resource_format_wav.h deleted file mode 100644 index 9105689670..0000000000 --- a/scene/io/resource_format_wav.h +++ /dev/null @@ -1,46 +0,0 @@ -/*************************************************************************/ -/* resource_format_wav.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 RESOURCE_FORMAT_WAV_H -#define RESOURCE_FORMAT_WAV_H - -#if 0 -#include "io/resource_loader.h" - -class ResourceFormatLoaderWAV : public ResourceFormatLoader { -public: - virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); - virtual void get_recognized_extensions(List<String> *p_extensions) const; - virtual bool handles_type(const String& p_type) const; - virtual String get_resource_type(const String &p_path) const; - -}; - -#endif -#endif // RESOURCE_FORMAT_WAV_H diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index b168dcfccc..ce8714e574 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h index b14a915fe8..fbee87f487 100644 --- a/scene/main/canvas_layer.h +++ b/scene/main/canvas_layer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index e57cd857f8..1e1e4f2d5f 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/http_request.h b/scene/main/http_request.h index 104f529eae..790ff5f7ef 100644 --- a/scene/main/http_request.h +++ b/scene/main/http_request.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/instance_placeholder.cpp b/scene/main/instance_placeholder.cpp index 5580ef486e..cbe30e05dd 100644 --- a/scene/main/instance_placeholder.cpp +++ b/scene/main/instance_placeholder.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/instance_placeholder.h b/scene/main/instance_placeholder.h index ec4520e1c8..375c87a035 100644 --- a/scene/main/instance_placeholder.h +++ b/scene/main/instance_placeholder.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/node.cpp b/scene/main/node.cpp index adc52c501a..c3d9d97c5a 100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "node.h" + #include "instance_placeholder.h" #include "io/resource_loader.h" #include "message_queue.h" @@ -360,18 +361,6 @@ void Node::add_child_notify(Node *p_child) { // to be used when not wanted } -/* -void Node::remove_and_delete_child(Node *p_child) { - - ERR_FAIL_NULL( p_child ); - ERR_FAIL_COND( p_child->get_parent()!=this ); - - remove_child(p_child); - memdelete(p_child); - -} -*/ - void Node::remove_child_notify(Node *p_child) { // to be used when not wanted @@ -675,31 +664,6 @@ Variant Node::_rpc_unreliable_id_bind(const Variant **p_args, int p_argcount, Va return Variant(); } -#if 0 -Variant Node::_rpc_bind(const Variant** p_args, int p_argcount, Variant::CallError& r_error) { - - if (p_argcount<1) { - r_error.error=Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; - r_error.argument=1; - return Variant(); - } - - if (p_args[0]->get_type()!=Variant::STRING) { - r_error.error=Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; - r_error.argument=0; - r_error.expected=Variant::STRING; - return Variant(); - } - - StringName method = *p_args[0]; - - rpcp(method,&p_args[1],p_argcount-1); - - r_error.error=Variant::CallError::CALL_OK; - return Variant(); -} - -#endif void Node::rpcp(int p_peer_id, bool p_unreliable, const StringName &p_method, const Variant **p_arg, int p_argcount) { ERR_FAIL_COND(!is_inside_tree()); @@ -2070,59 +2034,6 @@ HashMap<NodePath, int> Node::get_editable_instances() const { return data.editable_instances; } -#if 0 - -void Node::generate_instance_state() { - - List<PropertyInfo> properties; - get_property_list(&properties); - - data.instance_state.clear(); - - for( List<PropertyInfo>::Element *E=properties.front();E;E=E->next() ) { - - PropertyInfo &pi=E->get(); - if ((pi.usage&PROPERTY_USAGE_NO_INSTANCE_STATE) || !(pi.usage&PROPERTY_USAGE_EDITOR) || !(pi.usage&PROPERTY_USAGE_STORAGE)) - continue; - - data.instance_state[pi.name]=get(pi.name); - } - - List<GroupInfo> groups; - get_groups(&groups); - for(List<GroupInfo>::Element *E=groups.front();E;E=E->next()) { - - if (!E->get().persistent) - continue; - data.instance_groups.push_back(E->get().name); - } - - List<MethodInfo> signal_list; - - get_signal_list(&signal_list); - - for(List<MethodInfo>::Element *E=signal_list.front();E;E=E->next()) { - - StringName name = E->get().name; - List<Connection> connections; - get_signal_connection_list(name,&connections); - - for(List<Connection>::Element *F=connections.front();F;F=F->next()) { - - if (F->get().flags&CONNECT_PERSIST) - data.instance_connections.push_back(F->get()); - } - - } -} - -Dictionary Node::get_instance_state() const { - - return data.instance_state; -} - -#endif - void Node::set_scene_instance_state(const Ref<SceneState> &p_state) { data.instance_state = p_state; @@ -2752,7 +2663,6 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("get_name"), &Node::get_name); ClassDB::bind_method(D_METHOD("add_child", "node", "legible_unique_name"), &Node::add_child, DEFVAL(false)); ClassDB::bind_method(D_METHOD("remove_child", "node"), &Node::remove_child); - //ClassDB::bind_method(D_METHOD("remove_and_delete_child","node"),&Node::remove_and_delete_child); ClassDB::bind_method(D_METHOD("get_child_count"), &Node::get_child_count); ClassDB::bind_method(D_METHOD("get_children"), &Node::_get_children); ClassDB::bind_method(D_METHOD("get_child", "idx"), &Node::get_child); @@ -2864,7 +2774,6 @@ void Node::_bind_methods() { BIND_CONSTANT(NOTIFICATION_ENTER_TREE); BIND_CONSTANT(NOTIFICATION_EXIT_TREE); BIND_CONSTANT(NOTIFICATION_MOVED_IN_PARENT); - //BIND_CONSTANT( NOTIFICATION_PARENT_DECONFIGURED ); BIND_CONSTANT(NOTIFICATION_READY); BIND_CONSTANT(NOTIFICATION_FIXED_PROCESS); BIND_CONSTANT(NOTIFICATION_PROCESS); diff --git a/scene/main/node.h b/scene/main/node.h index b5ce6682d8..12d6310062 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -192,7 +192,6 @@ protected: virtual void add_child_notify(Node *p_child); virtual void remove_child_notify(Node *p_child); virtual void move_child_notify(Node *p_child); - //void remove_and_delete_child(Node *p_child); void _propagate_replace_owner(Node *p_owner, Node *p_by_owner); @@ -212,7 +211,6 @@ public: NOTIFICATION_EXIT_TREE = 11, NOTIFICATION_MOVED_IN_PARENT = 12, NOTIFICATION_READY = 13, - //NOTIFICATION_PARENT_DECONFIGURED =15, - it's confusing, it's going away NOTIFICATION_PAUSED = 14, NOTIFICATION_UNPAUSED = 15, NOTIFICATION_FIXED_PROCESS = 16, diff --git a/scene/main/resource_preloader.cpp b/scene/main/resource_preloader.cpp index ae323ba021..35bb6ef7e8 100644 --- a/scene/main/resource_preloader.cpp +++ b/scene/main/resource_preloader.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/resource_preloader.h b/scene/main/resource_preloader.h index a54781dc81..40e900a492 100644 --- a/scene/main/resource_preloader.h +++ b/scene/main/resource_preloader.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 99af8face0..65aeb23609 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -29,18 +29,15 @@ /*************************************************************************/ #include "scene_tree.h" +#include "editor/editor_node.h" +#include "io/marshalls.h" +#include "io/resource_loader.h" #include "message_queue.h" #include "node.h" #include "os/keyboard.h" #include "os/os.h" #include "print_string.h" #include "project_settings.h" -#include <stdio.h> -//#include "servers/spatial_sound_2d_server.h" - -#include "editor/editor_node.h" -#include "io/marshalls.h" -#include "io/resource_loader.h" #include "scene/resources/material.h" #include "scene/resources/mesh.h" #include "scene/resources/packed_scene.h" @@ -49,6 +46,8 @@ #include "servers/physics_server.h" #include "viewport.h" +#include <stdio.h> + void SceneTreeTimer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_time_left", "time"), &SceneTreeTimer::set_time_left); @@ -413,19 +412,7 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) { root_lock++; if (!input_handled) { - -#if 0 - _call_input_pause("unhandled_input","_unhandled_input",ev); - //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_input","_unhandled_input",ev); - if (!input_handled && ev.type==InputEvent::KEY) { - _call_input_pause("unhandled_key_input","_unhandled_key_input",ev); - //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"unhandled_key_input","_unhandled_key_input",ev); - } -#else - call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_vp_unhandled_input", ev); //special one for GUI, as controls use their own process check - -#endif input_handled = true; _flush_ugc(); root_lock--; diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index 1de9a2ce8c..594b806cef 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 42690ab93a..df7d609ac0 100755 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/timer.h b/scene/main/timer.h index dd4711ec37..0cd92f12de 100755 --- a/scene/main/timer.h +++ b/scene/main/timer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 017c4f3bae..02da926e50 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,28 +28,23 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "viewport.h" + #include "os/input.h" #include "os/os.h" -#include "scene/3d/spatial.h" -#include "servers/physics_2d_server.h" -//#include "scene/3d/camera.h" - +#include "project_settings.h" +#include "scene/2d/collision_object_2d.h" #include "scene/3d/camera.h" #include "scene/3d/collision_object.h" #include "scene/3d/listener.h" -#include "scene/3d/spatial_indexer.h" +#include "scene/3d/scenario_fx.h" +#include "scene/3d/spatial.h" #include "scene/gui/control.h" -#include "scene/resources/mesh.h" - -#include "scene/2d/collision_object_2d.h" - #include "scene/gui/label.h" #include "scene/gui/panel.h" #include "scene/main/timer.h" +#include "scene/resources/mesh.h" #include "scene/scene_string_names.h" - -#include "project_settings.h" -#include "scene/3d/scenario_fx.h" +#include "servers/physics_2d_server.h" void ViewportTexture::setup_local_to_scene() { @@ -1180,44 +1175,7 @@ bool Viewport::is_size_override_stretch_enabled() const { return size_override_stretch; } -#if 0 -void Viewport::set_as_render_target(bool p_enable){ - -/* if (render_target==p_enable) - return; - - render_target=p_enable; - VS::get_singleton()->viewport_set_as_render_target(viewport,p_enable); - if (is_inside_tree()) { - - if (p_enable) - _vp_exit_tree(); - else - _vp_enter_tree(); - } - - if (p_enable) { - - texture_rid = VS::get_singleton()->viewport_get_texture(viewport); - } else { - - texture_rid=RID(); - } - - texture->set_flags(texture->flags); - texture->emit_changed(); - - update_configuration_warning(); - */ -} - -bool Viewport::is_set_as_render_target() const{ - - return render_target; - -} -#endif void Viewport::set_update_mode(UpdateMode p_mode) { update_mode = p_mode; @@ -1227,7 +1185,6 @@ Viewport::UpdateMode Viewport::get_update_mode() const { return update_mode; } -//RID get_texture() const; Ref<ViewportTexture> Viewport::get_texture() const { diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 83c989db54..f527fa4f5b 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 283514dd53..e01f5e3cdf 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -108,8 +108,6 @@ #include "scene/gui/tree.h" #include "scene/gui/video_player.h" #include "scene/gui/viewport_container.h" -#include "scene/io/resource_format_image.h" -#include "scene/io/resource_format_wav.h" #include "scene/main/canvas_layer.h" #include "scene/main/http_request.h" #include "scene/main/instance_placeholder.h" diff --git a/scene/register_scene_types.h b/scene/register_scene_types.h index dee0af9063..956b12a7cd 100644 --- a/scene/register_scene_types.h +++ b/scene/register_scene_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 8878e59e71..1a2c8333ef 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "animation.h" + #include "geometry.h" bool Animation::_set(const StringName &p_name, const Variant &p_value) { @@ -83,44 +84,6 @@ bool Animation::_set(const StringName &p_name, const Variant &p_value) { TransformTrack *tt = static_cast<TransformTrack *>(tracks[track]); PoolVector<float> values = p_value; int vcount = values.size(); - -#if 0 // old compatibility hack - if ((vcount%11) == 0) { - - - PoolVector<float>::Read r = values.read(); - - tt->transforms.resize(vcount/11); - - - for(int i=0;i<(vcount/11);i++) { - - - TKey<TransformKey> &tk=tt->transforms[i]; - const float *ofs=&r[i*11]; - tk.time=ofs[0]; - - tk.value.loc.x=ofs[1]; - tk.value.loc.y=ofs[2]; - tk.value.loc.z=ofs[3]; - - tk.value.rot.x=ofs[4]; - tk.value.rot.y=ofs[5]; - tk.value.rot.z=ofs[6]; - tk.value.rot.w=ofs[7]; - - tk.value.scale.x=ofs[8]; - tk.value.scale.y=ofs[9]; - tk.value.scale.z=ofs[10]; - - - } - return true; - - - - } -#endif ERR_FAIL_COND_V(vcount % 12, false); // shuld be multiple of 11 PoolVector<float>::Read r = values.read(); diff --git a/scene/resources/animation.h b/scene/resources/animation.h index 27c58aba8c..e653f6b124 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/audio_stream_resampled.cpp b/scene/resources/audio_stream_resampled.cpp deleted file mode 100644 index 1b1d6f8587..0000000000 --- a/scene/resources/audio_stream_resampled.cpp +++ /dev/null @@ -1,388 +0,0 @@ -/*************************************************************************/ -/* audio_stream_resampled.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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. */ -/*************************************************************************/ -#include "audio_stream_resampled.h" -#include "project_settings.h" - -#if 0 -int AudioStreamResampled::get_channel_count() const { - - if (!rb) - return 0; - - return channels; -} - - -template<int C> -uint32_t AudioStreamResampled::_resample(int32_t *p_dest,int p_todo,int32_t p_increment) { - - uint32_t read=offset&MIX_FRAC_MASK; - - for (int i=0;i<p_todo;i++) { - - offset = (offset + p_increment)&(((1<<(rb_bits+MIX_FRAC_BITS))-1)); - read+=p_increment; - uint32_t pos = offset >> MIX_FRAC_BITS; - uint32_t frac = offset & MIX_FRAC_MASK; -#ifndef FAST_AUDIO - ERR_FAIL_COND_V(pos>=rb_len,0); -#endif - uint32_t pos_next = (pos+1)&rb_mask; - //printf("rb pos %i\n",pos); - - // since this is a template with a known compile time value (C), conditionals go away when compiling. - if (C==1) { - - int32_t v0 = rb[pos]; - int32_t v0n=rb[pos_next]; -#ifndef FAST_AUDIO - v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS; -#endif - v0<<=16; - p_dest[i]=v0; - - } - if (C==2) { - - int32_t v0 = rb[(pos<<1)+0]; - int32_t v1 = rb[(pos<<1)+1]; - int32_t v0n=rb[(pos_next<<1)+0]; - int32_t v1n=rb[(pos_next<<1)+1]; - -#ifndef FAST_AUDIO - v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS; - v1+=(v1n-v1)*(int32_t)frac >> MIX_FRAC_BITS; -#endif - v0<<=16; - v1<<=16; - p_dest[(i<<1)+0]=v0; - p_dest[(i<<1)+1]=v1; - - } - - if (C==4) { - - int32_t v0 = rb[(pos<<2)+0]; - int32_t v1 = rb[(pos<<2)+1]; - int32_t v2 = rb[(pos<<2)+2]; - int32_t v3 = rb[(pos<<2)+3]; - int32_t v0n = rb[(pos_next<<2)+0]; - int32_t v1n=rb[(pos_next<<2)+1]; - int32_t v2n=rb[(pos_next<<2)+2]; - int32_t v3n=rb[(pos_next<<2)+3]; - -#ifndef FAST_AUDIO - v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS; - v1+=(v1n-v1)*(int32_t)frac >> MIX_FRAC_BITS; - v2+=(v2n-v2)*(int32_t)frac >> MIX_FRAC_BITS; - v3+=(v3n-v3)*(int32_t)frac >> MIX_FRAC_BITS; -#endif - v0<<=16; - v1<<=16; - v2<<=16; - v3<<=16; - p_dest[(i<<2)+0]=v0; - p_dest[(i<<2)+1]=v1; - p_dest[(i<<2)+2]=v2; - p_dest[(i<<2)+3]=v3; - - } - - if (C==6) { - - int32_t v0 = rb[(pos*6)+0]; - int32_t v1 = rb[(pos*6)+1]; - int32_t v2 = rb[(pos*6)+2]; - int32_t v3 = rb[(pos*6)+3]; - int32_t v4 = rb[(pos*6)+4]; - int32_t v5 = rb[(pos*6)+5]; - int32_t v0n = rb[(pos_next*6)+0]; - int32_t v1n=rb[(pos_next*6)+1]; - int32_t v2n=rb[(pos_next*6)+2]; - int32_t v3n=rb[(pos_next*6)+3]; - int32_t v4n=rb[(pos_next*6)+4]; - int32_t v5n=rb[(pos_next*6)+5]; - -#ifndef FAST_AUDIO - v0+=(v0n-v0)*(int32_t)frac >> MIX_FRAC_BITS; - v1+=(v1n-v1)*(int32_t)frac >> MIX_FRAC_BITS; - v2+=(v2n-v2)*(int32_t)frac >> MIX_FRAC_BITS; - v3+=(v3n-v3)*(int32_t)frac >> MIX_FRAC_BITS; - v4+=(v4n-v4)*(int32_t)frac >> MIX_FRAC_BITS; - v5+=(v5n-v5)*(int32_t)frac >> MIX_FRAC_BITS; -#endif - v0<<=16; - v1<<=16; - v2<<=16; - v3<<=16; - v4<<=16; - v5<<=16; - p_dest[(i*6)+0]=v0; - p_dest[(i*6)+1]=v1; - p_dest[(i*6)+2]=v2; - p_dest[(i*6)+3]=v3; - p_dest[(i*6)+4]=v4; - p_dest[(i*6)+5]=v5; - - } - - - } - - - return read>>MIX_FRAC_BITS;//rb_read_pos=offset>>MIX_FRAC_BITS; - -} - - -bool AudioStreamResampled::mix(int32_t *p_dest, int p_frames) { - - - if (!rb || !_can_mix()) - return false; - - int write_pos_cache=rb_write_pos; - - int32_t increment=(mix_rate*MIX_FRAC_LEN)/get_mix_rate(); - - int rb_todo; - - if (write_pos_cache==rb_read_pos) { - return false; //out of buffer - - } else if (rb_read_pos<write_pos_cache) { - - rb_todo=write_pos_cache-rb_read_pos; //-1? - } else { - - rb_todo=(rb_len-rb_read_pos)+write_pos_cache; //-1? - } - - int todo = MIN( ((int64_t(rb_todo)<<MIX_FRAC_BITS)/increment)+1, p_frames ); -#if 0 - if (int(mix_rate)==get_mix_rate()) { - - - if (channels==6) { - - for(int i=0;i<p_frames;i++) { - - int from = ((rb_read_pos+i)&rb_mask)*6; - int to = i*6; - - p_dest[from+0]=int32_t(rb[to+0])<<16; - p_dest[from+1]=int32_t(rb[to+1])<<16; - p_dest[from+2]=int32_t(rb[to+2])<<16; - p_dest[from+3]=int32_t(rb[to+3])<<16; - p_dest[from+4]=int32_t(rb[to+4])<<16; - p_dest[from+5]=int32_t(rb[to+5])<<16; - } - - } else { - int len=p_frames*channels; - int from=rb_read_pos*channels; - int mask=0; - switch(channels) { - case 1: mask=rb_len-1; break; - case 2: mask=(rb_len*2)-1; break; - case 4: mask=(rb_len*4)-1; break; - } - - for(int i=0;i<len;i++) { - - p_dest[i]=int32_t(rb[(from+i)&mask])<<16; - } - } - - rb_read_pos = (rb_read_pos+p_frames)&rb_mask; - } else -#endif - { - - uint32_t read=0; - switch(channels) { - case 1: read=_resample<1>(p_dest,todo,increment); break; - case 2: read=_resample<2>(p_dest,todo,increment); break; - case 4: read=_resample<4>(p_dest,todo,increment); break; - case 6: read=_resample<6>(p_dest,todo,increment); break; - } -#if 1 - //end of stream, fadeout - int remaining = p_frames-todo; - if (remaining && todo>0) { - - //print_line("fadeout"); - for(int c=0;c<channels;c++) { - - for(int i=0;i<todo;i++) { - - int32_t samp = p_dest[i*channels+c]>>8; - uint32_t mul = (todo-i) * 256 /todo; - //print_line("mul: "+itos(i)+" "+itos(mul)); - p_dest[i*channels+c]=samp*mul; - } - - } - - } - -#else - int remaining = p_frames-todo; - if (remaining && todo>0) { - - - for(int c=0;c<channels;c++) { - - int32_t from = p_dest[(todo-1)*channels+c]>>8; - - for(int i=0;i<remaining;i++) { - - uint32_t mul = (remaining-i) * 256 /remaining; - p_dest[(todo+i)*channels+c]=from*mul; - } - - } - - } -#endif - - //zero out what remains there to avoid glitches - for(int i=todo*channels;i<int(p_frames)*channels;i++) { - - p_dest[i]=0; - } - - if (read>rb_todo) - read=rb_todo; - - rb_read_pos = (rb_read_pos+read)&rb_mask; - - - - - } - - return true; -} - - -Error AudioStreamResampled::_setup(int p_channels,int p_mix_rate,int p_minbuff_needed) { - - ERR_FAIL_COND_V(p_channels!=1 && p_channels!=2 && p_channels!=4 && p_channels!=6,ERR_INVALID_PARAMETER); - - - float buffering_sec = int(GLOBAL_DEF("audio/stream_buffering_ms",500))/1000.0; - int desired_rb_bits =nearest_shift(MAX(buffering_sec*p_mix_rate,p_minbuff_needed)); - - bool recreate=!rb; - - if (rb && (uint32_t(desired_rb_bits)!=rb_bits || channels!=uint32_t(p_channels))) { - //recreate - - memdelete_arr(rb); - memdelete_arr(read_buf); - recreate=true; - - } - - if (recreate) { - - channels=p_channels; - rb_bits=desired_rb_bits; - rb_len=(1<<rb_bits); - rb_mask=rb_len-1; - rb = memnew_arr( int16_t, rb_len * p_channels ); - read_buf = memnew_arr( int16_t, rb_len * p_channels ); - - } - - mix_rate=p_mix_rate; - offset=0; - rb_read_pos=0; - rb_write_pos=0; - - //avoid maybe strange noises upon load - for (int i=0;i<(rb_len*channels);i++) { - - rb[i]=0; - read_buf[i]=0; - } - - return OK; - -} - -void AudioStreamResampled::_clear() { - - if (!rb) - return; - - AudioServer::get_singleton()->lock(); - //should be stopped at this point but just in case - if (rb) { - memdelete_arr(rb); - memdelete_arr(read_buf); - } - rb=NULL; - offset=0; - rb_read_pos=0; - rb_write_pos=0; - read_buf=NULL; - AudioServer::get_singleton()->unlock(); - -} - -AudioStreamResampled::AudioStreamResampled() { - - rb=NULL; - offset=0; - read_buf=NULL; - rb_read_pos=0; - rb_write_pos=0; - - rb_bits=0; - rb_len=0; - rb_mask=0; - read_buff_len=0; - channels=0; - mix_rate=0; - -} - -AudioStreamResampled::~AudioStreamResampled() { - - if (rb) { - memdelete_arr(rb); - memdelete_arr(read_buf); - } - -} - -#endif diff --git a/scene/resources/audio_stream_resampled.h b/scene/resources/audio_stream_resampled.h deleted file mode 100644 index 53fa3bd0b9..0000000000 --- a/scene/resources/audio_stream_resampled.h +++ /dev/null @@ -1,166 +0,0 @@ -/*************************************************************************/ -/* audio_stream_resampled.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* 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 AUDIO_STREAM_RESAMPLED_H -#define AUDIO_STREAM_RESAMPLED_H - -//#include "scene/resources/audio_stream.h" - -#if 0 - -class AudioStreamResampled : public AudioStream { - GDCLASS(AudioStreamResampled,AudioStream); - - uint32_t rb_bits; - uint32_t rb_len; - uint32_t rb_mask; - uint32_t read_buff_len; - uint32_t channels; - uint32_t mix_rate; - - volatile int rb_read_pos; - volatile int rb_write_pos; - - int32_t offset; //contains the fractional remainder of the resampler - enum { - MIX_FRAC_BITS=13, - MIX_FRAC_LEN=(1<<MIX_FRAC_BITS), - MIX_FRAC_MASK=MIX_FRAC_LEN-1, - }; - - int16_t *read_buf; - int16_t *rb; - - - template<int C> - uint32_t _resample(int32_t *p_dest,int p_todo,int32_t p_increment); - - -protected: - - _FORCE_INLINE_ int get_total() const { - - return rb_len; - } - - _FORCE_INLINE_ int get_todo() const { //return amount of frames to mix - - int todo; - int read_pos_cache=rb_read_pos; - - if (read_pos_cache==rb_write_pos) { - todo=rb_len-1; - } else if (read_pos_cache>rb_write_pos) { - - todo=read_pos_cache-rb_write_pos-1; - } else { - - todo=(rb_len-rb_write_pos)+read_pos_cache-1; - } - - return todo; - } - - //Stream virtual funcs - virtual int get_channel_count() const; - virtual bool mix(int32_t *p_dest, int p_frames); - - _FORCE_INLINE_ void _flush() { - rb_read_pos=0; - rb_write_pos=0; - } - - _FORCE_INLINE_ int16_t *get_write_buffer() { return read_buf; } - _FORCE_INLINE_ void write(uint32_t p_frames) { - - ERR_FAIL_COND(p_frames >= rb_len); - - switch(channels) { - case 1: { - - for(uint32_t i=0;i<p_frames;i++) { - - rb[ rb_write_pos ] = read_buf[i]; - rb_write_pos=(rb_write_pos+1)&rb_mask; - } - } break; - case 2: { - - for(uint32_t i=0;i<p_frames;i++) { - - rb[ (rb_write_pos<<1)+0 ] = read_buf[(i<<1)+0]; - rb[ (rb_write_pos<<1)+1 ] = read_buf[(i<<1)+1]; - rb_write_pos=(rb_write_pos+1)&rb_mask; - } - } break; - case 4: { - - for(uint32_t i=0;i<p_frames;i++) { - - rb[ (rb_write_pos<<2)+0 ] = read_buf[(i<<2)+0]; - rb[ (rb_write_pos<<2)+1 ] = read_buf[(i<<2)+1]; - rb[ (rb_write_pos<<2)+2 ] = read_buf[(i<<2)+2]; - rb[ (rb_write_pos<<2)+3 ] = read_buf[(i<<2)+3]; - rb_write_pos=(rb_write_pos+1)&rb_mask; - } - } break; - case 6: { - - for(uint32_t i=0;i<p_frames;i++) { - - rb[ (rb_write_pos*6)+0 ] = read_buf[(i*6)+0]; - rb[ (rb_write_pos*6)+1 ] = read_buf[(i*6)+1]; - rb[ (rb_write_pos*6)+2 ] = read_buf[(i*6)+2]; - rb[ (rb_write_pos*6)+3 ] = read_buf[(i*6)+3]; - rb[ (rb_write_pos*6)+4 ] = read_buf[(i*6)+4]; - rb[ (rb_write_pos*6)+5 ] = read_buf[(i*6)+5]; - rb_write_pos=(rb_write_pos+1)&rb_mask; - } - } break; - - - } - - } - - virtual bool _can_mix() const =0; - - _FORCE_INLINE_ bool _is_ready() const{ - return rb!=NULL; - } - - Error _setup(int p_channels,int p_mix_rate,int p_minbuff_needed=-1); - void _clear(); - -public: - AudioStreamResampled(); - ~AudioStreamResampled(); -}; -#endif -#endif // AUDIO_STREAM_RESAMPLED_H diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index c8f6007e60..659322897a 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h index 680f037f15..6cb255fedf 100644 --- a/scene/resources/audio_stream_sample.h +++ b/scene/resources/audio_stream_sample.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp index a473067937..be994e3b33 100644 --- a/scene/resources/bit_mask.cpp +++ b/scene/resources/bit_mask.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/bit_mask.h b/scene/resources/bit_mask.h index 5ab7a3134d..72090f2ebe 100644 --- a/scene/resources/bit_mask.h +++ b/scene/resources/bit_mask.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/bounds.cpp b/scene/resources/bounds.cpp index b088426013..ee1e750c82 100644 --- a/scene/resources/bounds.cpp +++ b/scene/resources/bounds.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/bounds.h b/scene/resources/bounds.h index 8c0d1dcf6e..3378101836 100644 --- a/scene/resources/bounds.h +++ b/scene/resources/bounds.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/box_shape.cpp b/scene/resources/box_shape.cpp index d5c25b718e..bbc85ce0f6 100644 --- a/scene/resources/box_shape.cpp +++ b/scene/resources/box_shape.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/box_shape.h b/scene/resources/box_shape.h index fdf1e98020..8884c9b75a 100644 --- a/scene/resources/box_shape.h +++ b/scene/resources/box_shape.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/canvas.cpp b/scene/resources/canvas.cpp index b6a909f3fa..f5bf0ad78e 100644 --- a/scene/resources/canvas.cpp +++ b/scene/resources/canvas.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/canvas.h b/scene/resources/canvas.h index 331a997914..b9977e11b9 100644 --- a/scene/resources/canvas.h +++ b/scene/resources/canvas.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/capsule_shape.cpp b/scene/resources/capsule_shape.cpp index 1fcc9da5b6..e11b98f82e 100644 --- a/scene/resources/capsule_shape.cpp +++ b/scene/resources/capsule_shape.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/capsule_shape.h b/scene/resources/capsule_shape.h index 2864e7e23f..9b43823c83 100644 --- a/scene/resources/capsule_shape.h +++ b/scene/resources/capsule_shape.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp index 20177692a1..56a09bc3bf 100644 --- a/scene/resources/capsule_shape_2d.cpp +++ b/scene/resources/capsule_shape_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/capsule_shape_2d.h b/scene/resources/capsule_shape_2d.h index 93e7d846a4..610f9a4cf9 100644 --- a/scene/resources/capsule_shape_2d.h +++ b/scene/resources/capsule_shape_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp index 1b7e09ddfb..ecfc98ea60 100644 --- a/scene/resources/circle_shape_2d.cpp +++ b/scene/resources/circle_shape_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/circle_shape_2d.h b/scene/resources/circle_shape_2d.h index a4a4601e66..3ba5ec949c 100644 --- a/scene/resources/circle_shape_2d.h +++ b/scene/resources/circle_shape_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp index 68f707220f..9f6150ae63 100644 --- a/scene/resources/color_ramp.cpp +++ b/scene/resources/color_ramp.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/color_ramp.h b/scene/resources/color_ramp.h index d9f14205bb..816152d51f 100644 --- a/scene/resources/color_ramp.h +++ b/scene/resources/color_ramp.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/concave_polygon_shape.cpp b/scene/resources/concave_polygon_shape.cpp index 47cc49c631..6ae4fde85e 100644 --- a/scene/resources/concave_polygon_shape.cpp +++ b/scene/resources/concave_polygon_shape.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/concave_polygon_shape.h b/scene/resources/concave_polygon_shape.h index a8f9d50674..82e052fee7 100644 --- a/scene/resources/concave_polygon_shape.h +++ b/scene/resources/concave_polygon_shape.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp index b8c931421e..7f4abf7ae0 100644 --- a/scene/resources/concave_polygon_shape_2d.cpp +++ b/scene/resources/concave_polygon_shape_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/concave_polygon_shape_2d.h b/scene/resources/concave_polygon_shape_2d.h index d4c102e0d6..e766e88a4b 100644 --- a/scene/resources/concave_polygon_shape_2d.h +++ b/scene/resources/concave_polygon_shape_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp index 10e92b43ae..bba52bd5ff 100644 --- a/scene/resources/convex_polygon_shape.cpp +++ b/scene/resources/convex_polygon_shape.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/convex_polygon_shape.h b/scene/resources/convex_polygon_shape.h index 4340b0ef7c..e103f2d90c 100644 --- a/scene/resources/convex_polygon_shape.h +++ b/scene/resources/convex_polygon_shape.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp index e13f7faf70..7588909d90 100644 --- a/scene/resources/convex_polygon_shape_2d.cpp +++ b/scene/resources/convex_polygon_shape_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/convex_polygon_shape_2d.h b/scene/resources/convex_polygon_shape_2d.h index ba4a5ae8aa..3354199e05 100644 --- a/scene/resources/convex_polygon_shape_2d.h +++ b/scene/resources/convex_polygon_shape_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index fe0759fcba..7fbaa1f73c 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "curve.h" + #include "core_string_names.h" template <class T> @@ -42,344 +43,6 @@ static _FORCE_INLINE_ T _bezier_interp(real_t t, T start, T control_1, T control return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3; } -#if 0 - -int Curve2D::get_point_count() const { - - return points.size(); -} -void Curve2D::add_point(const Vector2& p_pos, const Vector2& p_in, const Vector2& p_out) { - - Point n; - n.pos=p_pos; - n.in=p_in; - n.out=p_out; - points.push_back(n); - emit_signal(CoreStringNames::get_singleton()->changed); -} -void Curve2D::set_point_pos(int p_index, const Vector2& p_pos) { - - ERR_FAIL_INDEX(p_index,points.size()); - - points[p_index].pos=p_pos; - emit_signal(CoreStringNames::get_singleton()->changed); - -} -Vector2 Curve2D::get_point_pos(int p_index) const { - - ERR_FAIL_INDEX_V(p_index,points.size(),Vector2()); - return points[p_index].pos; - -} - - -void Curve2D::set_point_in(int p_index, const Vector2& p_in) { - - ERR_FAIL_INDEX(p_index,points.size()); - - points[p_index].in=p_in; - emit_signal(CoreStringNames::get_singleton()->changed); - -} -Vector2 Curve2D::get_point_in(int p_index) const { - - ERR_FAIL_INDEX_V(p_index,points.size(),Vector2()); - return points[p_index].in; - -} - -void Curve2D::set_point_out(int p_index, const Vector2& p_out) { - - ERR_FAIL_INDEX(p_index,points.size()); - - points[p_index].out=p_out; - emit_signal(CoreStringNames::get_singleton()->changed); -} - -Vector2 Curve2D::get_point_out(int p_index) const { - - ERR_FAIL_INDEX_V(p_index,points.size(),Vector2()); - return points[p_index].out; - -} - - -void Curve2D::remove_point(int p_index) { - - ERR_FAIL_INDEX(p_index,points.size()); - points.remove(p_index); - emit_signal(CoreStringNames::get_singleton()->changed); -} - -Vector2 Curve2D::interpolate(int p_index, float p_offset) const { - - int pc = points.size(); - ERR_FAIL_COND_V(pc==0,Vector2()); - - if (p_index >= pc-1) - return points[pc-1].pos; - else if (p_index<0) - return points[0].pos; - - Vector2 p0 = points[p_index].pos; - Vector2 p1 = p0+points[p_index].out; - Vector2 p3 = points[p_index+1].pos; - Vector2 p2 = p3+points[p_index+1].in; - - return _bezier_interp(p_offset,p0,p1,p2,p3); -} - -Vector2 Curve2D::interpolatef(real_t p_findex) const { - - - if (p_findex<0) - p_findex=0; - else if (p_findex>=points.size()) - p_findex=points.size(); - - return interpolate((int)p_findex,Math::fmod(p_findex,1.0)); - -} - -PoolVector<Point2> Curve2D::bake(int p_subdivs) const { - - int pc = points.size(); - - PoolVector<Point2> ret; - if (pc<2) - return ret; - - ret.resize((pc-1)*p_subdivs+1); - - PoolVector<Point2>::Write w = ret.write(); - const Point *r = points.ptr(); - - for(int i=0;i<pc;i++) { - - int ofs = pc*p_subdivs; - - int limit=(i==pc-1)?p_subdivs+1:p_subdivs; - - for(int j=0;j<limit;j++) { - - Vector2 p0 = r[i].pos; - Vector2 p1 = p0+r[i].out; - Vector2 p3 = r[i].pos; - Vector2 p2 = p3+r[i].in; - real_t t = j/(real_t)p_subdivs; - - w[ofs+j]=_bezier_interp(t,p0,p1,p2,p3); - - } - } - - w = PoolVector<Point2>::Write(); - - return ret; -} - -void Curve2D::advance(real_t p_distance,int &r_index, real_t &r_pos) const { - - int pc = points.size(); - ERR_FAIL_COND(pc<2); - if (r_index<0 || r_index>=(pc-1)) - return; - - Vector2 pos = interpolate(r_index,r_pos); - - float sign=p_distance<0 ? -1 : 1; - p_distance=Math::abs(p_distance); - - real_t base = r_index+r_pos; - real_t top = 0.1; //a tenth is in theory representative - int iterations=32; - - - - for(int i=0;i<iterations;i++) { - - - real_t o=base+top*sign; - if (sign>0 && o >=pc) { - top=pc-base; - break; - } else if (sign<0 && o <0) { - top=-base; - break; - } - - Vector2 new_d = interpolatef(o); - - if (new_d.distance_to(pos) > p_distance) - break; - top*=2.0; - } - - - real_t bottom = 0.0; - iterations=8; - real_t final_offset; - - - for(int i=0;i<iterations;i++) { - - real_t middle = (bottom+top)*0.5; - real_t o=base+middle*sign; - Vector2 new_d = interpolatef(o); - - if (new_d.distance_to(pos) > p_distance) { - bottom=middle; - } else { - top=middle; - } - final_offset=o; - } - - r_index=(int)final_offset; - r_pos=Math::fmod(final_offset,1.0); - -} - -void Curve2D::get_approx_position_from_offset(real_t p_offset,int &r_index, real_t &r_pos,int p_subdivs) const { - - ERR_FAIL_COND(points.size()<2); - - real_t accum=0; - - - - for(int i=0;i<points.size();i++) { - - Vector2 prev_p=interpolate(i,0); - - - for(int j=1;j<=p_subdivs;j++) { - - real_t frac = j/(real_t)p_subdivs; - Vector2 p = interpolate(i,frac); - real_t d = p.distance_to(prev_p); - - accum+=d; - if (accum>p_offset) { - - - r_index=j-1; - if (d>0) { - real_t mf = (p_offset-(accum-d)) / d; - r_pos=frac-(1.0-mf); - } else { - r_pos=frac; - } - - return; - } - - prev_p=p; - } - } - - r_index=points.size()-1; - r_pos=1.0; - - -} - -void Curve2D::set_points_in(const Vector2Array& p_points) { - - points.resize(p_points.size()); - for (int i=0; i<p_points.size(); i++) { - - Point p = points[i]; - p.in = p_points[i]; - points[i] = p; - }; -}; - -void Curve2D::set_points_out(const Vector2Array& p_points) { - - points.resize(p_points.size()); - for (int i=0; i<p_points.size(); i++) { - - Point p = points[i]; - p.out = p_points[i]; - points[i] = p; - }; -}; - -void Curve2D::set_points_pos(const Vector2Array& p_points) { - - points.resize(p_points.size()); - for (int i=0; i<p_points.size(); i++) { - - Point p = points[i]; - p.pos = p_points[i]; - points[i] = p; - }; -}; - -Vector2Array Curve2D::get_points_in() const { - Vector2Array ret; - ret.resize(points.size()); - for (int i=0; i<points.size(); i++) { - ret.set(i, points[i].in); - }; - return ret; -}; - -Vector2Array Curve2D::get_points_out() const { - Vector2Array ret; - ret.resize(points.size()); - for (int i=0; i<points.size(); i++) { - ret.set(i, points[i].out); - }; - return ret; -}; - -Vector2Array Curve2D::get_points_pos() const { - Vector2Array ret; - ret.resize(points.size()); - for (int i=0; i<points.size(); i++) { - ret.set(i, points[i].pos); - }; - return ret; -}; - - -void Curve2D::_bind_methods() { - - ClassDB::bind_method(D_METHOD("get_point_count"),&Curve2D::get_point_count); - ClassDB::bind_method(D_METHOD("add_point","pos","in","out"),&Curve2D::add_point,DEFVAL(Vector2()),DEFVAL(Vector2())); - ClassDB::bind_method(D_METHOD("set_point_pos","idx","pos"),&Curve2D::set_point_pos); - ClassDB::bind_method(D_METHOD("get_point_pos","idx"),&Curve2D::get_point_pos); - ClassDB::bind_method(D_METHOD("set_point_in","idx","pos"),&Curve2D::set_point_in); - ClassDB::bind_method(D_METHOD("get_point_in","idx"),&Curve2D::get_point_in); - ClassDB::bind_method(D_METHOD("set_point_out","idx","pos"),&Curve2D::set_point_out); - ClassDB::bind_method(D_METHOD("get_point_out","idx"),&Curve2D::get_point_out); - ClassDB::bind_method(D_METHOD("remove_point","idx"),&Curve2D::remove_point); - ClassDB::bind_method(D_METHOD("interpolate","idx","t"),&Curve2D::interpolate); - ClassDB::bind_method(D_METHOD("bake","subdivs"),&Curve2D::bake,DEFVAL(10)); - - - ClassDB::bind_method(D_METHOD("set_points_in"),&Curve2D::set_points_in); - ClassDB::bind_method(D_METHOD("set_points_out"),&Curve2D::set_points_out); - ClassDB::bind_method(D_METHOD("set_points_pos"),&Curve2D::set_points_pos); - - ClassDB::bind_method(D_METHOD("get_points_in"),&Curve2D::get_points_in); - ClassDB::bind_method(D_METHOD("get_points_out"),&Curve2D::get_points_out); - ClassDB::bind_method(D_METHOD("get_points_pos"),&Curve2D::get_points_pos); - - ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_in"), "set_points_in","get_points_in"); - ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_out"), "set_points_out","get_points_out"); - ADD_PROPERTY( PropertyInfo( Variant::VECTOR2_ARRAY, "points_pos"), "set_points_pos","get_points_pos"); -} - - -Curve2D::Curve2D() -{ -} - -#endif - const char *Curve::SIGNAL_RANGE_CHANGED = "range_changed"; Curve::Curve() { diff --git a/scene/resources/curve.h b/scene/resources/curve.h index e302f1e0af..3071aee5de 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -31,56 +31,6 @@ #define CURVE_H #include "resource.h" -#if 0 -class Curve2D : public Resource { - - GDCLASS(Curve2D,Resource); - - struct Point { - - Vector2 in; - Vector2 out; - Vector2 pos; - }; - - - Vector<Point> points; - -protected: - - static void _bind_methods(); - - void set_points_in(const Vector2Array& p_points_in); - void set_points_out(const Vector2Array& p_points_out); - void set_points_pos(const Vector2Array& p_points_pos); - - Vector2Array get_points_in() const; - Vector2Array get_points_out() const; - Vector2Array get_points_pos() const; - -public: - - - int get_point_count() const; - void add_point(const Vector2& p_pos, const Vector2& p_in=Vector2(), const Vector2& p_out=Vector2()); - void set_point_pos(int p_index, const Vector2& p_pos); - Vector2 get_point_pos(int p_index) const; - void set_point_in(int p_index, const Vector2& p_in); - Vector2 get_point_in(int p_index) const; - void set_point_out(int p_index, const Vector2& p_out); - Vector2 get_point_out(int p_index) const; - void remove_point(int p_index); - - Vector2 interpolate(int p_index, float p_offset) const; - Vector2 interpolatef(real_t p_findex) const; - PoolVector<Point2> bake(int p_subdivs=10) const; - void advance(real_t p_distance,int &r_index, real_t &r_pos) const; - void get_approx_position_from_offset(real_t p_offset,int &r_index, real_t &r_pos,int p_subdivs=16) const; - - Curve2D(); -}; - -#endif // y(x) curve class Curve : public Resource { diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 03288e45bf..08de33175a 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/default_theme/default_theme.h b/scene/resources/default_theme/default_theme.h index 6fd57b6f22..9032b71775 100644 --- a/scene/resources/default_theme/default_theme.h +++ b/scene/resources/default_theme/default_theme.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 57b860583e..82739b58a0 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index b8ff2845e7..52c3f30590 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp index fa8cf4723b..91263fb125 100644 --- a/scene/resources/dynamic_font_stb.cpp +++ b/scene/resources/dynamic_font_stb.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/dynamic_font_stb.h b/scene/resources/dynamic_font_stb.h index a2c081a925..24d764e716 100644 --- a/scene/resources/dynamic_font_stb.h +++ b/scene/resources/dynamic_font_stb.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 60a700aad8..7de2c85633 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 3a6906aa27..6337981b95 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 035e514eac..d9ccd31f88 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/font.h b/scene/resources/font.h index a04ffbdd4b..3bb7aeac85 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index f01d9f841b..77563121df 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/material.h b/scene/resources/material.h index 140b2142c9..b82e8d8cbd 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 0f791e4665..aa7827a61a 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index bccb39e8cd..53c6eb2d89 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp index f1092a90cb..116ddc4ac6 100644 --- a/scene/resources/mesh_data_tool.cpp +++ b/scene/resources/mesh_data_tool.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/mesh_data_tool.h b/scene/resources/mesh_data_tool.h index ad771edbd1..119b49161b 100644 --- a/scene/resources/mesh_data_tool.h +++ b/scene/resources/mesh_data_tool.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp index 7d51a2617e..6abbcfb90b 100644 --- a/scene/resources/mesh_library.cpp +++ b/scene/resources/mesh_library.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -43,9 +43,15 @@ bool MeshLibrary::_set(const StringName &p_name, const Variant &p_value) { set_item_name(idx, p_value); else if (what == "mesh") set_item_mesh(idx, p_value); - else if (what == "shape") - set_item_shape(idx, p_value); - else if (what == "preview") + else if (what == "shape") { + Vector<ShapeData> shapes; + ShapeData sd; + sd.shape = p_value; + shapes.push_back(sd); + set_item_shapes(idx, shapes); + } else if (what == "shapes") { + _set_item_shapes(idx, p_value); + } else if (what == "preview") set_item_preview(idx, p_value); else if (what == "navmesh") set_item_navmesh(idx, p_value); @@ -69,8 +75,8 @@ bool MeshLibrary::_get(const StringName &p_name, Variant &r_ret) const { r_ret = get_item_name(idx); else if (what == "mesh") r_ret = get_item_mesh(idx); - else if (what == "shape") - r_ret = get_item_shape(idx); + else if (what == "shapes") + r_ret = _get_item_shapes(idx); else if (what == "navmesh") r_ret = get_item_navmesh(idx); else if (what == "preview") @@ -88,7 +94,7 @@ void MeshLibrary::_get_property_list(List<PropertyInfo> *p_list) const { String name = "item/" + itos(E->key()) + "/"; p_list->push_back(PropertyInfo(Variant::STRING, name + "name")); p_list->push_back(PropertyInfo(Variant::OBJECT, name + "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh")); - p_list->push_back(PropertyInfo(Variant::OBJECT, name + "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape")); + p_list->push_back(PropertyInfo(Variant::ARRAY, name + "shapes")); p_list->push_back(PropertyInfo(Variant::OBJECT, name + "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh")); p_list->push_back(PropertyInfo(Variant::OBJECT, name + "preview", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_HELPER)); } @@ -118,10 +124,10 @@ void MeshLibrary::set_item_mesh(int p_item, const Ref<Mesh> &p_mesh) { _change_notify(); } -void MeshLibrary::set_item_shape(int p_item, const Ref<Shape> &p_shape) { +void MeshLibrary::set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes) { ERR_FAIL_COND(!item_map.has(p_item)); - item_map[p_item].shape = p_shape; + item_map[p_item].shapes = p_shapes; _change_notify(); notify_change_to_owners(); emit_changed(); @@ -156,10 +162,10 @@ Ref<Mesh> MeshLibrary::get_item_mesh(int p_item) const { return item_map[p_item].mesh; } -Ref<Shape> MeshLibrary::get_item_shape(int p_item) const { +Vector<MeshLibrary::ShapeData> MeshLibrary::get_item_shapes(int p_item) const { - ERR_FAIL_COND_V(!item_map.has(p_item), Ref<Shape>()); - return item_map[p_item].shape; + ERR_FAIL_COND_V(!item_map.has(p_item), Vector<ShapeData>()); + return item_map[p_item].shapes; } Ref<NavigationMesh> MeshLibrary::get_item_navmesh(int p_item) const { @@ -226,17 +232,46 @@ int MeshLibrary::get_last_unused_item_id() const { return item_map.back()->key() + 1; } +void MeshLibrary::_set_item_shapes(int p_item, const Array &p_shapes) { + + ERR_FAIL_COND(p_shapes.size() & 1); + Vector<ShapeData> shapes; + for (int i = 0; i < p_shapes.size(); i += 2) { + ShapeData sd; + sd.shape = p_shapes[i + 0]; + sd.local_transform = p_shapes[i + 1]; + + if (sd.shape.is_valid()) { + shapes.push_back(sd); + } + } + + set_item_shapes(p_item, shapes); +} + +Array MeshLibrary::_get_item_shapes(int p_item) const { + + Vector<ShapeData> shapes = get_item_shapes(p_item); + Array ret; + for (int i = 0; i < shapes.size(); i++) { + ret.push_back(shapes[i].shape); + ret.push_back(shapes[i].local_transform); + } + + return ret; +} + void MeshLibrary::_bind_methods() { ClassDB::bind_method(D_METHOD("create_item", "id"), &MeshLibrary::create_item); ClassDB::bind_method(D_METHOD("set_item_name", "id", "name"), &MeshLibrary::set_item_name); ClassDB::bind_method(D_METHOD("set_item_mesh", "id", "mesh"), &MeshLibrary::set_item_mesh); ClassDB::bind_method(D_METHOD("set_item_navmesh", "id", "navmesh"), &MeshLibrary::set_item_navmesh); - ClassDB::bind_method(D_METHOD("set_item_shape", "id", "shape"), &MeshLibrary::set_item_shape); + ClassDB::bind_method(D_METHOD("set_item_shapes", "id", "shapes"), &MeshLibrary::_set_item_shapes); ClassDB::bind_method(D_METHOD("get_item_name", "id"), &MeshLibrary::get_item_name); ClassDB::bind_method(D_METHOD("get_item_mesh", "id"), &MeshLibrary::get_item_mesh); ClassDB::bind_method(D_METHOD("get_item_navmesh", "id"), &MeshLibrary::get_item_navmesh); - ClassDB::bind_method(D_METHOD("get_item_shape", "id"), &MeshLibrary::get_item_shape); + ClassDB::bind_method(D_METHOD("get_item_shapes", "id"), &MeshLibrary::_get_item_shapes); ClassDB::bind_method(D_METHOD("remove_item", "id"), &MeshLibrary::remove_item); ClassDB::bind_method(D_METHOD("clear"), &MeshLibrary::clear); ClassDB::bind_method(D_METHOD("get_item_list"), &MeshLibrary::get_item_list); diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h index cc39110a99..99b6b48d61 100644 --- a/scene/resources/mesh_library.h +++ b/scene/resources/mesh_library.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -41,16 +41,24 @@ class MeshLibrary : public Resource { GDCLASS(MeshLibrary, Resource); RES_BASE_EXTENSION("meshlib"); +public: + struct ShapeData { + Ref<Shape> shape; + Transform local_transform; + }; struct Item { String name; Ref<Mesh> mesh; - Ref<Shape> shape; + Vector<ShapeData> shapes; Ref<Texture> preview; Ref<NavigationMesh> navmesh; }; Map<int, Item> item_map; + void _set_item_shapes(int p_item, const Array &p_shapes); + Array _get_item_shapes(int p_item) const; + protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; @@ -63,12 +71,12 @@ public: void set_item_name(int p_item, const String &p_name); void set_item_mesh(int p_item, const Ref<Mesh> &p_mesh); void set_item_navmesh(int p_item, const Ref<NavigationMesh> &p_navmesh); - void set_item_shape(int p_item, const Ref<Shape> &p_shape); + void set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes); void set_item_preview(int p_item, const Ref<Texture> &p_preview); String get_item_name(int p_item) const; Ref<Mesh> get_item_mesh(int p_item) const; Ref<NavigationMesh> get_item_navmesh(int p_item) const; - Ref<Shape> get_item_shape(int p_item) const; + Vector<ShapeData> get_item_shapes(int p_item) const; Ref<Texture> get_item_preview(int p_item) const; void remove_item(int p_item); diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp index b65800ebbd..15f1e15542 100644 --- a/scene/resources/multimesh.cpp +++ b/scene/resources/multimesh.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h index 7d6a0ce44f..7ca66b0b46 100644 --- a/scene/resources/multimesh.h +++ b/scene/resources/multimesh.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 3ce44e2c31..19fab5d587 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "packed_scene.h" + #include "core/core_string_names.h" #include "io/resource_loader.h" #include "project_settings.h" @@ -35,6 +36,7 @@ #include "scene/3d/spatial.h" #include "scene/gui/control.h" #include "scene/main/instance_placeholder.h" + #define PACK_VERSION 2 bool SceneState::can_instance() const { @@ -451,60 +453,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } } -#if 0 - - Ref<SceneState> base_scene = p_node->get_scene_inherited_state(); //for inheritance - Ref<SceneState> instance_state; - int instance_state_node=-1; - - if (base_scene.is_valid() && (p_node==p_owner || p_node->get_owner()==p_owner)) { - //scene inheritance in use, see if this node is actually inherited - NodePath path = p_owner->get_path_to(p_node); - instance_state_node = base_scene->find_node_by_path(path); - if (instance_state_node>=0) { - instance_state=base_scene; - } - } - - // check that this is a directly instanced scene from the scene being packed, if so - // this information must be saved. Of course, if using scene instancing and this node - // does belong to base scene, ignore. - - if (instance_state.is_null() && p_node!=p_owner && p_node->get_owner()==p_owner && p_node->get_filename()!="") { - - //instanced, only direct sub-scnes are supported of course - Ref<PackedScene> instance = ResourceLoader::load(p_node->get_filename()); - if (!instance.is_valid()) { - return ERR_CANT_OPEN; - } - - nd.instance=_vm_get_variant(instance,variant_map); - - } else { - - nd.instance=-1; - } - - // finally, if this does not belong to scene inheritance, check - // if it belongs to scene instancing - - if (instance_state.is_null() && p_node!=p_owner) { - //if not affected by scene inheritance, this may be - if (p_node->get_owner()==p_owner && p_node->get_filename()!=String()) { - instance_state=p_node->get_scene_instance_state(); - if (instance_state.is_valid()) { - instance_state_node=instance_state->find_node_by_path(p_node->get_path_to(p_node)); - } - - } else if (p_node->get_owner()!=p_owner && p_owner->is_editable_instance(p_node->get_owner())) { - instance_state=p_node->get_owner()->get_scene_instance_state(); - if (instance_state.is_valid()) { - instance_state_node=instance_state->find_node_by_path(p_node->get_owner()->get_path_to(p_node)); - } - } - } -#endif - // all setup, we then proceed to check all properties for the node // and save the ones that are worth saving @@ -641,27 +589,6 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map } else { nd.owner = -1; -#if 0 - // this is pointless, if this was instanced by something else, - // the owner will already be set. - - if (node_map.has(p_node->get_owner())) { - //maybe an existing saved node - nd.owner=node_map[p_node->get_owner()]; - } else { - //not saved, use nodepath map - int sidx; - if (nodepath_map.has(p_node->get_owner())) { - sidx=nodepath_map[p_node->get_owner()]; - } else { - sidx=nodepath_map.size(); - nodepath_map[p_node->get_owner()]=sidx; - } - - nd.owner=FLAG_ID_IS_PATH|sidx; - - } -#endif } // Save the right type. If this node was created by an instance diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h index 2f18f5c263..20bfb19b1f 100644 --- a/scene/resources/packed_scene.h +++ b/scene/resources/packed_scene.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/plane_shape.cpp b/scene/resources/plane_shape.cpp index d3ad454afc..2b1e890a5d 100644 --- a/scene/resources/plane_shape.cpp +++ b/scene/resources/plane_shape.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/plane_shape.h b/scene/resources/plane_shape.h index 2ed297a97e..1384b7521b 100644 --- a/scene/resources/plane_shape.h +++ b/scene/resources/plane_shape.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp index 80b413630a..053369e8d8 100644 --- a/scene/resources/polygon_path_finder.cpp +++ b/scene/resources/polygon_path_finder.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/polygon_path_finder.h b/scene/resources/polygon_path_finder.h index 2d2fb1678e..9b760caa2e 100644 --- a/scene/resources/polygon_path_finder.h +++ b/scene/resources/polygon_path_finder.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 2b8c0ddedd..cfc1468533 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h index bcd5d30dd3..34fb75a196 100644 --- a/scene/resources/primitive_meshes.h +++ b/scene/resources/primitive_meshes.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/ray_shape.cpp b/scene/resources/ray_shape.cpp index 3abb2a4fa1..ccce7660c6 100644 --- a/scene/resources/ray_shape.cpp +++ b/scene/resources/ray_shape.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/ray_shape.h b/scene/resources/ray_shape.h index 5a17e9414e..06b68adbae 100644 --- a/scene/resources/ray_shape.h +++ b/scene/resources/ray_shape.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp index bd9ec8cbc4..507dbce861 100644 --- a/scene/resources/rectangle_shape_2d.cpp +++ b/scene/resources/rectangle_shape_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/rectangle_shape_2d.h b/scene/resources/rectangle_shape_2d.h index 23db58ba07..81d9cb1f4a 100644 --- a/scene/resources/rectangle_shape_2d.h +++ b/scene/resources/rectangle_shape_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp index de238ebcc0..487975dd4e 100644 --- a/scene/resources/room.cpp +++ b/scene/resources/room.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -30,6 +30,8 @@ #include "room.h" #include "servers/visual_server.h" + +// FIXME: Left for reference for reimplementation using Area #if 0 RID RoomBounds::get_rid() const { diff --git a/scene/resources/room.h b/scene/resources/room.h index 4b8c837458..aadee858c2 100644 --- a/scene/resources/room.h +++ b/scene/resources/room.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index 0cccdc4fbf..fea5c11dec 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h index 1ea6465c21..193bcf7112 100644 --- a/scene/resources/scene_format_text.h +++ b/scene/resources/scene_format_text.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp index 99062d693b..1171db5c02 100644 --- a/scene/resources/segment_shape_2d.cpp +++ b/scene/resources/segment_shape_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/segment_shape_2d.h b/scene/resources/segment_shape_2d.h index 22fc1ab6e3..eb9c228c83 100644 --- a/scene/resources/segment_shape_2d.h +++ b/scene/resources/segment_shape_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index acd04a9321..ec41630258 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/shader.h b/scene/resources/shader.h index 0e8e48d82e..5cc70629c7 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index ed63e84d4c..2ca9a14562 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,8 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "shader_graph.h" + #include "scene/scene_string_names.h" +// FIXME: Needs to be ported to the new 3.0 shader API #if 0 Array ShaderGraph::_get_node_list(ShaderType p_type) const { @@ -397,79 +399,6 @@ void ShaderGraph::_bind_methods() { BIND_ENUM_CONSTANT( VEC_MAX_FUNC ); ADD_SIGNAL(MethodInfo("updated")); - -#if 0 - ClassDB::bind_method(D_METHOD("node_add"),&ShaderGraph::node_add ); - ClassDB::bind_method(D_METHOD("node_remove"),&ShaderGraph::node_remove ); - ClassDB::bind_method(D_METHOD("node_set_param"),&ShaderGraph::node_set_param ); - ClassDB::bind_method(D_METHOD("node_set_pos"),&ShaderGraph::node_set_pos ); - - ClassDB::bind_method(D_METHOD("node_get_pos"),&ShaderGraph::node_get_pos ); - ClassDB::bind_method(D_METHOD("node_get_param"),&ShaderGraph::node_get_param); - ClassDB::bind_method(D_METHOD("node_get_type"),&ShaderGraph::node_get_type); - - ClassDB::bind_method(D_METHOD("connect"),&ShaderGraph::connect ); - ClassDB::bind_method(D_METHOD("disconnect"),&ShaderGraph::disconnect ); - - ClassDB::bind_method(D_METHOD("get_connections"),&ShaderGraph::_get_connections_helper ); - - ClassDB::bind_method(D_METHOD("clear"),&ShaderGraph::clear ); - - BIND_ENUM_CONSTANT( NODE_IN ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_OUT ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_CONSTANT ); ///< param 0: value - BIND_ENUM_CONSTANT( NODE_PARAMETER ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_ADD ); - BIND_ENUM_CONSTANT( NODE_SUB ); - BIND_ENUM_CONSTANT( NODE_MUL ); - BIND_ENUM_CONSTANT( NODE_DIV ); - BIND_ENUM_CONSTANT( NODE_MOD ); - BIND_ENUM_CONSTANT( NODE_SIN ); - BIND_ENUM_CONSTANT( NODE_COS ); - BIND_ENUM_CONSTANT( NODE_TAN ); - BIND_ENUM_CONSTANT( NODE_ARCSIN ); - BIND_ENUM_CONSTANT( NODE_ARCCOS ); - BIND_ENUM_CONSTANT( NODE_ARCTAN ); - BIND_ENUM_CONSTANT( NODE_POW ); - BIND_ENUM_CONSTANT( NODE_LOG ); - BIND_ENUM_CONSTANT( NODE_MAX ); - BIND_ENUM_CONSTANT( NODE_MIN ); - BIND_ENUM_CONSTANT( NODE_COMPARE ); - BIND_ENUM_CONSTANT( NODE_TEXTURE ); ///< param 0: texture - BIND_ENUM_CONSTANT( NODE_TIME ); ///< param 0: interval length - BIND_ENUM_CONSTANT( NODE_NOISE ); - BIND_ENUM_CONSTANT( NODE_PASS ); - BIND_ENUM_CONSTANT( NODE_VEC_IN ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_VEC_OUT ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_VEC_CONSTANT ); ///< param 0: value - BIND_ENUM_CONSTANT( NODE_VEC_PARAMETER ); ///< param 0: name - BIND_ENUM_CONSTANT( NODE_VEC_ADD ); - BIND_ENUM_CONSTANT( NODE_VEC_SUB ); - BIND_ENUM_CONSTANT( NODE_VEC_MUL ); - BIND_ENUM_CONSTANT( NODE_VEC_DIV ); - BIND_ENUM_CONSTANT( NODE_VEC_MOD ); - BIND_ENUM_CONSTANT( NODE_VEC_CROSS ); - BIND_ENUM_CONSTANT( NODE_VEC_DOT ); - BIND_ENUM_CONSTANT( NODE_VEC_POW ); - BIND_ENUM_CONSTANT( NODE_VEC_NORMALIZE ); - BIND_ENUM_CONSTANT( NODE_VEC_TRANSFORM3 ); - BIND_ENUM_CONSTANT( NODE_VEC_TRANSFORM4 ); - BIND_ENUM_CONSTANT( NODE_VEC_COMPARE ); - BIND_ENUM_CONSTANT( NODE_VEC_TEXTURE_2D ); - BIND_ENUM_CONSTANT( NODE_VEC_TEXTURE_CUBE ); - BIND_ENUM_CONSTANT( NODE_VEC_NOISE ); - BIND_ENUM_CONSTANT( NODE_VEC_0 ); - BIND_ENUM_CONSTANT( NODE_VEC_1 ); - BIND_ENUM_CONSTANT( NODE_VEC_2 ); - BIND_ENUM_CONSTANT( NODE_VEC_BUILD ); - BIND_ENUM_CONSTANT( NODE_VEC_PASS ); - BIND_ENUM_CONSTANT( NODE_COLOR_CONSTANT ); - BIND_ENUM_CONSTANT( NODE_COLOR_PARAMETER ); - BIND_ENUM_CONSTANT( NODE_TEXTURE_PARAMETER ); - BIND_ENUM_CONSTANT( NODE_TEXTURE_2D_PARAMETER ); - BIND_ENUM_CONSTANT( NODE_TEXTURE_CUBE_PARAMETER ); - BIND_ENUM_CONSTANT( NODE_TYPE_MAX ); -#endif } diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h index 36578ce1f7..9a74b6c53a 100644 --- a/scene/resources/shader_graph.h +++ b/scene/resources/shader_graph.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -30,6 +30,7 @@ #ifndef SHADER_GRAPH_H #define SHADER_GRAPH_H +// FIXME: Needs to be ported to the new 3.0 shader API #if 0 #include "map.h" #include "scene/resources/shader.h" diff --git a/scene/resources/shape.cpp b/scene/resources/shape.cpp index d719aa5403..0046ff58a8 100644 --- a/scene/resources/shape.cpp +++ b/scene/resources/shape.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/shape.h b/scene/resources/shape.h index c15638aeed..bc75e723e9 100644 --- a/scene/resources/shape.h +++ b/scene/resources/shape.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp index 818c749e8c..4423c78bbe 100644 --- a/scene/resources/shape_2d.cpp +++ b/scene/resources/shape_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/shape_2d.h b/scene/resources/shape_2d.h index c020fb9141..fffc7011f1 100644 --- a/scene/resources/shape_2d.h +++ b/scene/resources/shape_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/shape_line_2d.cpp b/scene/resources/shape_line_2d.cpp index c38ae04eff..4dcc5ac981 100644 --- a/scene/resources/shape_line_2d.cpp +++ b/scene/resources/shape_line_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/shape_line_2d.h b/scene/resources/shape_line_2d.h index 3e59bbc687..68298b63be 100644 --- a/scene/resources/shape_line_2d.h +++ b/scene/resources/shape_line_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp index b7f2feb58d..9af8c42110 100644 --- a/scene/resources/sky_box.cpp +++ b/scene/resources/sky_box.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/sky_box.h b/scene/resources/sky_box.h index 9bd60cddaf..8934463b6f 100644 --- a/scene/resources/sky_box.h +++ b/scene/resources/sky_box.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/space_2d.cpp b/scene/resources/space_2d.cpp index 2a618bb868..4177364de7 100644 --- a/scene/resources/space_2d.cpp +++ b/scene/resources/space_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/space_2d.h b/scene/resources/space_2d.h index 3e08612d99..8ba392f85d 100644 --- a/scene/resources/space_2d.h +++ b/scene/resources/space_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/sphere_shape.cpp b/scene/resources/sphere_shape.cpp index 960554562f..00203c2b4b 100644 --- a/scene/resources/sphere_shape.cpp +++ b/scene/resources/sphere_shape.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/sphere_shape.h b/scene/resources/sphere_shape.h index a3b5d2424b..43d7956246 100644 --- a/scene/resources/sphere_shape.h +++ b/scene/resources/sphere_shape.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 7b2a9ffbc2..f646e3667d 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 30eb9543e8..db41333b7e 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 9320676016..7342164841 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h index fcc94753ca..2a90c2743d 100644 --- a/scene/resources/surface_tool.h +++ b/scene/resources/surface_tool.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index f542d2a8de..9751d6e711 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 6c20c71af0..207436e4a7 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index c2c7c37762..e2e29b037b 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/theme.h b/scene/resources/theme.h index 5744c142d4..5b375d5585 100644 --- a/scene/resources/theme.h +++ b/scene/resources/theme.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 44fe676ddc..50e8c28c22 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index 7d7855811f..fe782ff987 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/video_stream.cpp b/scene/resources/video_stream.cpp index 1b0e34b8db..2298e2ca9f 100644 --- a/scene/resources/video_stream.cpp +++ b/scene/resources/video_stream.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h index 544973f581..e08be02a07 100644 --- a/scene/resources/video_stream.h +++ b/scene/resources/video_stream.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -30,7 +30,6 @@ #ifndef VIDEO_STREAM_H #define VIDEO_STREAM_H -#include "audio_stream_resampled.h" #include "scene/resources/texture.h" class VideoStreamPlayback : public Resource { diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp index b0d14125a0..af159975ca 100644 --- a/scene/resources/world.cpp +++ b/scene/resources/world.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,10 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "world.h" + #include "camera_matrix.h" #include "octree.h" #include "scene/3d/camera.h" -#include "scene/3d/spatial_indexer.h" #include "scene/3d/visibility_notifier.h" #include "scene/scene_string_names.h" diff --git a/scene/resources/world.h b/scene/resources/world.h index 158086974c..767d1b5b6e 100644 --- a/scene/resources/world.h +++ b/scene/resources/world.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index 2f43f903ba..a644793bd8 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h index f968b08a15..63d32473e0 100644 --- a/scene/resources/world_2d.h +++ b/scene/resources/world_2d.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index f247e7cde8..6b7168a529 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index 0b70cd36ff..8676b8436e 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/arvr/arvr_interface.cpp b/servers/arvr/arvr_interface.cpp index 1f2e6028b0..0705df17b1 100644 --- a/servers/arvr/arvr_interface.cpp +++ b/servers/arvr/arvr_interface.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/arvr/arvr_interface.h b/servers/arvr/arvr_interface.h index e405499fbb..d4fb383bbc 100644 --- a/servers/arvr/arvr_interface.h +++ b/servers/arvr/arvr_interface.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/arvr/arvr_positional_tracker.cpp b/servers/arvr/arvr_positional_tracker.cpp index 9f3d01267b..539bac6703 100644 --- a/servers/arvr/arvr_positional_tracker.cpp +++ b/servers/arvr/arvr_positional_tracker.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/arvr/arvr_positional_tracker.h b/servers/arvr/arvr_positional_tracker.h index dba203b73c..f91f862ba3 100644 --- a/servers/arvr/arvr_positional_tracker.h +++ b/servers/arvr/arvr_positional_tracker.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index 8a064f9cce..bac24f6438 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/arvr_server.h b/servers/arvr_server.h index 06e0a4561c..2645637ad5 100644 --- a/servers/arvr_server.h +++ b/servers/arvr_server.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index dfb6406b38..992fece85f 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/audio_driver_dummy.h b/servers/audio/audio_driver_dummy.h index eadac44c5a..b3fea59389 100644 --- a/servers/audio/audio_driver_dummy.h +++ b/servers/audio/audio_driver_dummy.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/audio_effect.cpp b/servers/audio/audio_effect.cpp index edb79adb60..2a9f991d3f 100644 --- a/servers/audio/audio_effect.cpp +++ b/servers/audio/audio_effect.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/audio_effect.h b/servers/audio/audio_effect.h index 570b2025b1..3dbeb402eb 100644 --- a/servers/audio/audio_effect.h +++ b/servers/audio/audio_effect.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/audio_filter_sw.cpp b/servers/audio/audio_filter_sw.cpp index 4bf1cebf12..477bc59b73 100644 --- a/servers/audio/audio_filter_sw.cpp +++ b/servers/audio/audio_filter_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/audio_filter_sw.h b/servers/audio/audio_filter_sw.h index caf735436a..1c01e5f8da 100644 --- a/servers/audio/audio_filter_sw.h +++ b/servers/audio/audio_filter_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/audio_rb_resampler.cpp b/servers/audio/audio_rb_resampler.cpp index a5d0a53be6..2f160fd7cd 100644 --- a/servers/audio/audio_rb_resampler.cpp +++ b/servers/audio/audio_rb_resampler.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -173,44 +173,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) { } int todo = MIN(((int64_t(rb_todo) << MIX_FRAC_BITS) / increment) + 1, p_frames); -#if 0 - if (int(src_mix_rate)==target_mix_rate) { - - if (channels==6) { - - for(int i=0;i<p_frames;i++) { - - int from = ((rb_read_pos+i)&rb_mask)*6; - int to = i*6; - - p_dest[from+0]=int32_t(rb[to+0])<<16; - p_dest[from+1]=int32_t(rb[to+1])<<16; - p_dest[from+2]=int32_t(rb[to+2])<<16; - p_dest[from+3]=int32_t(rb[to+3])<<16; - p_dest[from+4]=int32_t(rb[to+4])<<16; - p_dest[from+5]=int32_t(rb[to+5])<<16; - } - - } else { - int len=p_frames*channels; - int from=rb_read_pos*channels; - int mask=0; - switch(channels) { - case 1: mask=rb_len-1; break; - case 2: mask=(rb_len*2)-1; break; - case 4: mask=(rb_len*4)-1; break; - } - - for(int i=0;i<len;i++) { - - p_dest[i]=int32_t(rb[(from+i)&mask])<<16; - } - } - - rb_read_pos = (rb_read_pos+p_frames)&rb_mask; - } else -#endif { uint32_t read = 0; @@ -220,7 +183,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) { case 4: read = _resample<4>(p_dest, todo, increment); break; case 6: read = _resample<6>(p_dest, todo, increment); break; } -#if 1 + //end of stream, fadeout int remaining = p_frames - todo; if (remaining && todo > 0) { @@ -238,23 +201,6 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) { } } -#else - int remaining = p_frames - todo; - if (remaining && todo > 0) { - - for (int c = 0; c < channels; c++) { - - int32_t from = p_dest[(todo - 1) * channels + c] >> 8; - - for (int i = 0; i < remaining; i++) { - - uint32_t mul = (remaining - i) * 256 / remaining; - p_dest[(todo + i) * channels + c] = from * mul; - } - } - } -#endif - //zero out what remains there to avoid glitches for (int i = todo * channels; i < int(p_frames) * channels; i++) { diff --git a/servers/audio/audio_rb_resampler.h b/servers/audio/audio_rb_resampler.h index a906f1bb20..bc1f924ab5 100644 --- a/servers/audio/audio_rb_resampler.h +++ b/servers/audio/audio_rb_resampler.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index aa498cccad..dd4240f028 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index 0d63e7af82..c7cb63ef2c 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_amplify.cpp b/servers/audio/effects/audio_effect_amplify.cpp index 91d1e84182..58da99ab85 100644 --- a/servers/audio/effects/audio_effect_amplify.cpp +++ b/servers/audio/effects/audio_effect_amplify.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_amplify.h b/servers/audio/effects/audio_effect_amplify.h index bba9e352b2..a4c2cbc2fd 100644 --- a/servers/audio/effects/audio_effect_amplify.h +++ b/servers/audio/effects/audio_effect_amplify.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_chorus.cpp b/servers/audio/effects/audio_effect_chorus.cpp index 8fb7ef2cd0..4075bc3e63 100644 --- a/servers/audio/effects/audio_effect_chorus.cpp +++ b/servers/audio/effects/audio_effect_chorus.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_chorus.h b/servers/audio/effects/audio_effect_chorus.h index 5db335e288..47065c4dd5 100644 --- a/servers/audio/effects/audio_effect_chorus.h +++ b/servers/audio/effects/audio_effect_chorus.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_compressor.cpp b/servers/audio/effects/audio_effect_compressor.cpp index 491e6ecc81..420f279da0 100644 --- a/servers/audio/effects/audio_effect_compressor.cpp +++ b/servers/audio/effects/audio_effect_compressor.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_compressor.h b/servers/audio/effects/audio_effect_compressor.h index 550302056c..5c76fb902a 100644 --- a/servers/audio/effects/audio_effect_compressor.h +++ b/servers/audio/effects/audio_effect_compressor.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_delay.cpp b/servers/audio/effects/audio_effect_delay.cpp index de301fba6f..b8a8603546 100644 --- a/servers/audio/effects/audio_effect_delay.cpp +++ b/servers/audio/effects/audio_effect_delay.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_delay.h b/servers/audio/effects/audio_effect_delay.h index 9d80c752d3..50a32c94f6 100644 --- a/servers/audio/effects/audio_effect_delay.h +++ b/servers/audio/effects/audio_effect_delay.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_distortion.cpp b/servers/audio/effects/audio_effect_distortion.cpp index 87cf520e19..f2bcabc3cb 100644 --- a/servers/audio/effects/audio_effect_distortion.cpp +++ b/servers/audio/effects/audio_effect_distortion.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_distortion.h b/servers/audio/effects/audio_effect_distortion.h index afeb6ac7ec..7c04b4f98e 100644 --- a/servers/audio/effects/audio_effect_distortion.h +++ b/servers/audio/effects/audio_effect_distortion.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_eq.cpp b/servers/audio/effects/audio_effect_eq.cpp index 87f793f95e..15905e3e0e 100644 --- a/servers/audio/effects/audio_effect_eq.cpp +++ b/servers/audio/effects/audio_effect_eq.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_eq.h b/servers/audio/effects/audio_effect_eq.h index 62041fe4f7..440f46c0c2 100644 --- a/servers/audio/effects/audio_effect_eq.h +++ b/servers/audio/effects/audio_effect_eq.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_filter.cpp b/servers/audio/effects/audio_effect_filter.cpp index bcf1cc5756..64a9db51a5 100644 --- a/servers/audio/effects/audio_effect_filter.cpp +++ b/servers/audio/effects/audio_effect_filter.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_filter.h b/servers/audio/effects/audio_effect_filter.h index 51932cdbf5..903977cb97 100644 --- a/servers/audio/effects/audio_effect_filter.h +++ b/servers/audio/effects/audio_effect_filter.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_limiter.cpp b/servers/audio/effects/audio_effect_limiter.cpp index 9f39db0440..391e5db639 100644 --- a/servers/audio/effects/audio_effect_limiter.cpp +++ b/servers/audio/effects/audio_effect_limiter.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_limiter.h b/servers/audio/effects/audio_effect_limiter.h index e15ffe5b34..5fc54a2dd3 100644 --- a/servers/audio/effects/audio_effect_limiter.h +++ b/servers/audio/effects/audio_effect_limiter.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_panner.cpp b/servers/audio/effects/audio_effect_panner.cpp index a6103f580a..8b268ef9f7 100644 --- a/servers/audio/effects/audio_effect_panner.cpp +++ b/servers/audio/effects/audio_effect_panner.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_panner.h b/servers/audio/effects/audio_effect_panner.h index 8c3edfbde0..4739373485 100644 --- a/servers/audio/effects/audio_effect_panner.h +++ b/servers/audio/effects/audio_effect_panner.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_phaser.cpp b/servers/audio/effects/audio_effect_phaser.cpp index 9af344d876..fe362ef831 100644 --- a/servers/audio/effects/audio_effect_phaser.cpp +++ b/servers/audio/effects/audio_effect_phaser.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_phaser.h b/servers/audio/effects/audio_effect_phaser.h index c587ca8239..d77b44e738 100644 --- a/servers/audio/effects/audio_effect_phaser.h +++ b/servers/audio/effects/audio_effect_phaser.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_pitch_shift.cpp b/servers/audio/effects/audio_effect_pitch_shift.cpp index 1889934f29..ec70e7b902 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.cpp +++ b/servers/audio/effects/audio_effect_pitch_shift.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_pitch_shift.h b/servers/audio/effects/audio_effect_pitch_shift.h index 08c8c59cc7..10a72465dc 100644 --- a/servers/audio/effects/audio_effect_pitch_shift.h +++ b/servers/audio/effects/audio_effect_pitch_shift.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_reverb.cpp b/servers/audio/effects/audio_effect_reverb.cpp index 7049204645..f5225bec96 100644 --- a/servers/audio/effects/audio_effect_reverb.cpp +++ b/servers/audio/effects/audio_effect_reverb.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_reverb.h b/servers/audio/effects/audio_effect_reverb.h index d8f13da8b7..795d38d3d5 100644 --- a/servers/audio/effects/audio_effect_reverb.h +++ b/servers/audio/effects/audio_effect_reverb.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_stereo_enhance.cpp b/servers/audio/effects/audio_effect_stereo_enhance.cpp index ebd48c0546..1ee393f533 100644 --- a/servers/audio/effects/audio_effect_stereo_enhance.cpp +++ b/servers/audio/effects/audio_effect_stereo_enhance.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/audio_effect_stereo_enhance.h b/servers/audio/effects/audio_effect_stereo_enhance.h index bad55614c6..f187fe50b3 100644 --- a/servers/audio/effects/audio_effect_stereo_enhance.h +++ b/servers/audio/effects/audio_effect_stereo_enhance.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/eq.cpp b/servers/audio/effects/eq.cpp index 4dd5eb0ebe..05630e61ae 100644 --- a/servers/audio/effects/eq.cpp +++ b/servers/audio/effects/eq.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/eq.h b/servers/audio/effects/eq.h index 90d19e6e91..97dd4615d1 100644 --- a/servers/audio/effects/eq.h +++ b/servers/audio/effects/eq.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/reverb.cpp b/servers/audio/effects/reverb.cpp index 7bc8c5cac3..8e745f979a 100644 --- a/servers/audio/effects/reverb.cpp +++ b/servers/audio/effects/reverb.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/effects/reverb.h b/servers/audio/effects/reverb.h index d4ddb3902a..2fa21d68d5 100644 --- a/servers/audio/effects/reverb.h +++ b/servers/audio/effects/reverb.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/reverb_sw.cpp b/servers/audio/reverb_sw.cpp index 45fd7fd7de..96d2ad848b 100644 --- a/servers/audio/reverb_sw.cpp +++ b/servers/audio/reverb_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/reverb_sw.h b/servers/audio/reverb_sw.h index f912734e65..b91beea039 100644 --- a/servers/audio/reverb_sw.h +++ b/servers/audio/reverb_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio/voice_rb_sw.h b/servers/audio/voice_rb_sw.h index a4a5ec3ddd..6d9eb73860 100644 --- a/servers/audio/voice_rb_sw.h +++ b/servers/audio/voice_rb_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 903e831399..c0343399c3 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/audio_server.h b/servers/audio_server.h index c92ff6d3a0..05e92ceaf0 100644 --- a/servers/audio_server.h +++ b/servers/audio_server.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/area_pair_sw.cpp b/servers/physics/area_pair_sw.cpp index 5c418c473f..3e8d148f08 100644 --- a/servers/physics/area_pair_sw.cpp +++ b/servers/physics/area_pair_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/area_pair_sw.h b/servers/physics/area_pair_sw.h index 75df6043ea..483f63284b 100644 --- a/servers/physics/area_pair_sw.h +++ b/servers/physics/area_pair_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp index a310ed3411..387230a478 100644 --- a/servers/physics/area_sw.cpp +++ b/servers/physics/area_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/area_sw.h b/servers/physics/area_sw.h index 3dae1db13f..455c0b5c8b 100644 --- a/servers/physics/area_sw.h +++ b/servers/physics/area_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics/body_pair_sw.cpp index 9ada1fbc50..a289b4b0ca 100644 --- a/servers/physics/body_pair_sw.cpp +++ b/servers/physics/body_pair_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "body_pair_sw.h" + #include "collision_solver_sw.h" #include "os/os.h" #include "space_sw.h" @@ -296,17 +297,7 @@ bool BodyPairSW::setup(real_t p_step) { c.rA = global_A - A->get_center_of_mass(); c.rB = global_B - B->get_center_of_mass() - offset_B; -// contact query reporting... -#if 0 - if (A->get_body_type() == PhysicsServer::BODY_CHARACTER) - static_cast<CharacterBodySW*>(A)->report_character_contact( global_A, global_B, B ); - if (B->get_body_type() == PhysicsServer::BODY_CHARACTER) - static_cast<CharacterBodySW*>(B)->report_character_contact( global_B, global_A, A ); - if (A->has_contact_query()) - A->report_contact( global_A, global_B, B ); - if (B->has_contact_query()) - B->report_contact( global_B, global_A, A ); -#endif + // contact query reporting... if (A->can_report_contacts()) { Vector3 crA = A->get_angular_velocity().cross(c.rA) + A->get_linear_velocity(); @@ -327,18 +318,7 @@ bool BodyPairSW::setup(real_t p_step) { kNormal += c.normal.dot(inertia_A.cross(c.rA)) + c.normal.dot(inertia_B.cross(c.rB)); c.mass_normal = 1.0f / kNormal; -#if 1 c.bias = -bias * inv_dt * MIN(0.0f, -depth + max_penetration); - -#else - if (depth > max_penetration) { - c.bias = (depth - max_penetration) * (1.0 / (p_step * (1.0 / RELAXATION_TIMESTEPS))); - } else { - real_t approach = -0.1 * (depth - max_penetration) / (CMP_EPSILON + max_penetration); - approach = CLAMP(approach, CMP_EPSILON, 1.0); - c.bias = approach * (depth - max_penetration) * (1.0 / p_step); - } -#endif c.depth = depth; Vector3 j_vec = c.normal * c.acc_normal_impulse + c.acc_tangent_impulse; diff --git a/servers/physics/body_pair_sw.h b/servers/physics/body_pair_sw.h index cb16849399..f09c977950 100644 --- a/servers/physics/body_pair_sw.h +++ b/servers/physics/body_pair_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index e065fae2be..46a5192e52 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h index 512b868570..7e8d31f8eb 100644 --- a/servers/physics/body_sw.h +++ b/servers/physics/body_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics/broad_phase_basic.cpp index 5a54e1f0d9..959718a252 100644 --- a/servers/physics/broad_phase_basic.cpp +++ b/servers/physics/broad_phase_basic.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/broad_phase_basic.h b/servers/physics/broad_phase_basic.h index 8dabf72f11..51a24f4678 100644 --- a/servers/physics/broad_phase_basic.h +++ b/servers/physics/broad_phase_basic.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics/broad_phase_octree.cpp index fb2144bd03..e7111d9580 100644 --- a/servers/physics/broad_phase_octree.cpp +++ b/servers/physics/broad_phase_octree.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/broad_phase_octree.h b/servers/physics/broad_phase_octree.h index bd3ba6677a..d28f2da13f 100644 --- a/servers/physics/broad_phase_octree.h +++ b/servers/physics/broad_phase_octree.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/broad_phase_sw.cpp b/servers/physics/broad_phase_sw.cpp index c3d42d4c2f..3e5b7e72c6 100644 --- a/servers/physics/broad_phase_sw.cpp +++ b/servers/physics/broad_phase_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h index 5564cf5077..2b5ed629fe 100644 --- a/servers/physics/broad_phase_sw.h +++ b/servers/physics/broad_phase_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp index d673088304..ab716a8f6e 100644 --- a/servers/physics/collision_object_sw.cpp +++ b/servers/physics/collision_object_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h index 44786829af..dc988aae86 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics/collision_object_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp index 128f78e46e..a044df7f31 100644 --- a/servers/physics/collision_solver_sat.cpp +++ b/servers/physics/collision_solver_sat.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/collision_solver_sat.h b/servers/physics/collision_solver_sat.h index d5fae7798a..efe9bc87ac 100644 --- a/servers/physics/collision_solver_sat.h +++ b/servers/physics/collision_solver_sat.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp index 32a42bcaf4..c7f66cb7fc 100644 --- a/servers/physics/collision_solver_sw.cpp +++ b/servers/physics/collision_solver_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/collision_solver_sw.h b/servers/physics/collision_solver_sw.h index 5a4e864eb5..1e38b1b54e 100644 --- a/servers/physics/collision_solver_sw.h +++ b/servers/physics/collision_solver_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/constraint_sw.h b/servers/physics/constraint_sw.h index d9f153a6a6..047513f635 100644 --- a/servers/physics/constraint_sw.h +++ b/servers/physics/constraint_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/gjk_epa.cpp b/servers/physics/gjk_epa.cpp index ab2a9b507a..6cea5b003d 100644 --- a/servers/physics/gjk_epa.cpp +++ b/servers/physics/gjk_epa.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/gjk_epa.h b/servers/physics/gjk_epa.h index 316b991477..6d8539d365 100644 --- a/servers/physics/gjk_epa.h +++ b/servers/physics/gjk_epa.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/cone_twist_joint_sw.cpp b/servers/physics/joints/cone_twist_joint_sw.cpp index d00eab53d3..3c900d4fbe 100644 --- a/servers/physics/joints/cone_twist_joint_sw.cpp +++ b/servers/physics/joints/cone_twist_joint_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/cone_twist_joint_sw.h b/servers/physics/joints/cone_twist_joint_sw.h index f0e029712c..0c722463be 100644 --- a/servers/physics/joints/cone_twist_joint_sw.h +++ b/servers/physics/joints/cone_twist_joint_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp index e1cd6ee7e5..70cc549e2d 100644 --- a/servers/physics/joints/generic_6dof_joint_sw.cpp +++ b/servers/physics/joints/generic_6dof_joint_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/generic_6dof_joint_sw.h b/servers/physics/joints/generic_6dof_joint_sw.h index 587a5850df..f6af0b1d6f 100644 --- a/servers/physics/joints/generic_6dof_joint_sw.h +++ b/servers/physics/joints/generic_6dof_joint_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics/joints/hinge_joint_sw.cpp index 3938427cea..fe20a55b60 100644 --- a/servers/physics/joints/hinge_joint_sw.cpp +++ b/servers/physics/joints/hinge_joint_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/hinge_joint_sw.h b/servers/physics/joints/hinge_joint_sw.h index 5ebf0cb165..8e0f9a4da0 100644 --- a/servers/physics/joints/hinge_joint_sw.h +++ b/servers/physics/joints/hinge_joint_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/jacobian_entry_sw.h b/servers/physics/joints/jacobian_entry_sw.h index 537a9a8f3d..79ce0e6157 100644 --- a/servers/physics/joints/jacobian_entry_sw.h +++ b/servers/physics/joints/jacobian_entry_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/pin_joint_sw.cpp b/servers/physics/joints/pin_joint_sw.cpp index 0792ffeecd..779e086858 100644 --- a/servers/physics/joints/pin_joint_sw.cpp +++ b/servers/physics/joints/pin_joint_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/pin_joint_sw.h b/servers/physics/joints/pin_joint_sw.h index 1d580b6c21..670c1ab61f 100644 --- a/servers/physics/joints/pin_joint_sw.h +++ b/servers/physics/joints/pin_joint_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/slider_joint_sw.cpp b/servers/physics/joints/slider_joint_sw.cpp index 947f46e960..66585f2605 100644 --- a/servers/physics/joints/slider_joint_sw.cpp +++ b/servers/physics/joints/slider_joint_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints/slider_joint_sw.h b/servers/physics/joints/slider_joint_sw.h index 7818ee2a5c..5079c65707 100644 --- a/servers/physics/joints/slider_joint_sw.h +++ b/servers/physics/joints/slider_joint_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/joints_sw.h b/servers/physics/joints_sw.h index b25939d523..b15ae08049 100644 --- a/servers/physics/joints_sw.h +++ b/servers/physics/joints_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp index 151fc44476..8d6f7b3fd8 100644 --- a/servers/physics/physics_server_sw.cpp +++ b/servers/physics/physics_server_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "physics_server_sw.h" + #include "broad_phase_basic.h" #include "broad_phase_octree.h" #include "joints/cone_twist_joint_sw.h" @@ -1206,117 +1207,6 @@ bool PhysicsServerSW::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_a return generic_6dof_joint->get_flag(p_axis, p_flag); } -#if 0 -void PhysicsServerSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) { - - JointSW *joint = joint_owner.get(p_joint); - ERR_FAIL_COND(!joint); - - switch(p_param) { - case JOINT_PARAM_BIAS: joint->set_bias(p_value); break; - case JOINT_PARAM_MAX_BIAS: joint->set_max_bias(p_value); break; - case JOINT_PARAM_MAX_FORCE: joint->set_max_force(p_value); break; - } - - -} - -real_t PhysicsServerSW::joint_get_param(RID p_joint,JointParam p_param) const { - - const JointSW *joint = joint_owner.get(p_joint); - ERR_FAIL_COND_V(!joint,-1); - - switch(p_param) { - case JOINT_PARAM_BIAS: return joint->get_bias(); break; - case JOINT_PARAM_MAX_BIAS: return joint->get_max_bias(); break; - case JOINT_PARAM_MAX_FORCE: return joint->get_max_force(); break; - } - - return 0; -} - - -RID PhysicsServerSW::pin_joint_create(const Vector3& p_pos,RID p_body_a,RID p_body_b) { - - BodySW *A=body_owner.get(p_body_a); - ERR_FAIL_COND_V(!A,RID()); - BodySW *B=NULL; - if (body_owner.owns(p_body_b)) { - B=body_owner.get(p_body_b); - ERR_FAIL_COND_V(!B,RID()); - } - - JointSW *joint = memnew( PinJointSW(p_pos,A,B) ); - RID self = joint_owner.make_rid(joint); - joint->set_self(self); - - return self; -} - -RID PhysicsServerSW::groove_joint_create(const Vector3& p_a_groove1,const Vector3& p_a_groove2, const Vector3& p_b_anchor, RID p_body_a,RID p_body_b) { - - - BodySW *A=body_owner.get(p_body_a); - ERR_FAIL_COND_V(!A,RID()); - - BodySW *B=body_owner.get(p_body_b); - ERR_FAIL_COND_V(!B,RID()); - - JointSW *joint = memnew( GrooveJointSW(p_a_groove1,p_a_groove2,p_b_anchor,A,B) ); - RID self = joint_owner.make_rid(joint); - joint->set_self(self); - return self; - - -} - -RID PhysicsServerSW::damped_spring_joint_create(const Vector3& p_anchor_a,const Vector3& p_anchor_b,RID p_body_a,RID p_body_b) { - - BodySW *A=body_owner.get(p_body_a); - ERR_FAIL_COND_V(!A,RID()); - - BodySW *B=body_owner.get(p_body_b); - ERR_FAIL_COND_V(!B,RID()); - - JointSW *joint = memnew( DampedSpringJointSW(p_anchor_a,p_anchor_b,A,B) ); - RID self = joint_owner.make_rid(joint); - joint->set_self(self); - return self; - -} - -void PhysicsServerSW::damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value) { - - - JointSW *j = joint_owner.get(p_joint); - ERR_FAIL_COND(!j); - ERR_FAIL_COND(j->get_type()!=JOINT_DAMPED_SPRING); - - DampedSpringJointSW *dsj = static_cast<DampedSpringJointSW*>(j); - dsj->set_param(p_param,p_value); -} - -real_t PhysicsServerSW::damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const { - - JointSW *j = joint_owner.get(p_joint); - ERR_FAIL_COND_V(!j,0); - ERR_FAIL_COND_V(j->get_type()!=JOINT_DAMPED_SPRING,0); - - DampedSpringJointSW *dsj = static_cast<DampedSpringJointSW*>(j); - return dsj->get_param(p_param); -} - -PhysicsServer::JointType PhysicsServerSW::joint_get_type(RID p_joint) const { - - - JointSW *joint = joint_owner.get(p_joint); - ERR_FAIL_COND_V(!joint,JOINT_PIN); - - return joint->get_type(); -} - -#endif - void PhysicsServerSW::free(RID p_rid) { if (shape_owner.owns(p_rid)) { diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h index 818922a989..2e1fa7065a 100644 --- a/servers/physics/physics_server_sw.h +++ b/servers/physics/physics_server_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -264,18 +264,6 @@ public: virtual void joint_set_solver_priority(RID p_joint, int p_priority); virtual int joint_get_solver_priority(RID p_joint) const; -#if 0 - virtual void joint_set_param(RID p_joint, JointParam p_param, real_t p_value); - virtual real_t joint_get_param(RID p_joint,JointParam p_param) const; - - virtual RID pin_joint_create(const Vector3& p_pos,RID p_body_a,RID p_body_b=RID()); - virtual RID groove_joint_create(const Vector3& p_a_groove1,const Vector3& p_a_groove2, const Vector3& p_b_anchor, RID p_body_a,RID p_body_b); - virtual RID damped_spring_joint_create(const Vector3& p_anchor_a,const Vector3& p_anchor_b,RID p_body_a,RID p_body_b=RID()); - virtual void damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value); - virtual real_t damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const; - - virtual JointType joint_get_type(RID p_joint) const; -#endif /* MISC */ virtual void free(RID p_rid); diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index b4004c8c94..f02ff03fcf 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,9 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "shape_sw.h" + #include "geometry.h" #include "quick_hull.h" #include "sort.h" + #define _POINT_SNAP 0.001953125 #define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002 #define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.9998 @@ -1473,119 +1475,6 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) { PoolVector<Vector3>::Read r = p_faces.read(); const Vector3 *facesr = r.ptr(); -#if 0 - Map<Vector3,int> point_map; - List<Face> face_list; - - - for(int i=0;i<src_face_count;i++) { - - Face3 faceaux; - - for(int j=0;j<3;j++) { - - faceaux.vertex[j]=facesr[i*3+j].snapped(_POINT_SNAP); - //faceaux.vertex[j]=facesr[i*3+j];//facesr[i*3+j].snapped(_POINT_SNAP); - } - - ERR_CONTINUE( faceaux.is_degenerate() ); - - Face face; - - for(int j=0;j<3;j++) { - - - Map<Vector3,int>::Element *E=point_map.find(faceaux.vertex[j]); - if (E) { - - face.indices[j]=E->value(); - } else { - - face.indices[j]=point_map.size(); - point_map.insert(faceaux.vertex[j],point_map.size()); - - } - } - - face_list.push_back(face); - } - - vertices.resize( point_map.size() ); - - PoolVector<Vector3>::Write vw = vertices.write(); - Vector3 *verticesw=vw.ptr(); - - AABB _aabb; - - for( Map<Vector3,int>::Element *E=point_map.front();E;E=E->next()) { - - if (E==point_map.front()) { - _aabb.pos=E->key(); - } else { - - _aabb.expand_to(E->key()); - } - verticesw[E->value()]=E->key(); - } - - point_map.clear(); // not needed anymore - - faces.resize(face_list.size()); - PoolVector<Face>::Write w = faces.write(); - Face *facesw=w.ptr(); - - int fc=0; - - for( List<Face>::Element *E=face_list.front();E;E=E->next()) { - - facesw[fc++]=E->get(); - } - - face_list.clear(); - - - PoolVector<_VolumeSW_BVH_Element> bvh_array; - bvh_array.resize( fc ); - - PoolVector<_VolumeSW_BVH_Element>::Write bvhw = bvh_array.write(); - _VolumeSW_BVH_Element *bvh_arrayw=bvhw.ptr(); - - - for(int i=0;i<fc;i++) { - - AABB face_aabb; - face_aabb.pos=verticesw[facesw[i].indices[0]]; - face_aabb.expand_to( verticesw[facesw[i].indices[1]] ); - face_aabb.expand_to( verticesw[facesw[i].indices[2]] ); - - bvh_arrayw[i].face_index=i; - bvh_arrayw[i].aabb=face_aabb; - bvh_arrayw[i].center=face_aabb.pos+face_aabb.size*0.5; - - } - - w=PoolVector<Face>::Write(); - vw=PoolVector<Vector3>::Write(); - - - int count=0; - _VolumeSW_BVH *bvh_tree=_volume_sw_build_bvh(bvh_arrayw,fc,count); - - ERR_FAIL_COND(count==0); - - bvhw=PoolVector<_VolumeSW_BVH_Element>::Write(); - - bvh.resize( count+1 ); - - PoolVector<BVH>::Write bvhw2 = bvh.write(); - BVH*bvh_arrayw2=bvhw2.ptr(); - - int idx=0; - _fill_bvh(bvh_tree,bvh_arrayw2,idx); - - set_aabb(_aabb); - -#else PoolVector<_VolumeSW_BVH_Element> bvh_array; bvh_array.resize(src_face_count); @@ -1638,8 +1527,6 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) { _fill_bvh(bvh_tree, bvh_arrayw2, idx); configure(_aabb); // this type of shape has no margin - -#endif } void ConcavePolygonShapeSW::set_data(const Variant &p_data) { diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h index 52623c019d..151b84c054 100644 --- a/servers/physics/shape_sw.h +++ b/servers/physics/shape_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index fc52aa45aa..17e2df6c9e 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "space_sw.h" + #include "collision_solver_sw.h" #include "physics_server_sw.h" #include "project_settings.h" @@ -267,20 +268,13 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform continue; } -//test initial overlap -#if 0 - if (CollisionSolverSW::solve_static(shape,p_xform,col_obj->get_shape(shape_idx),col_obj_xform,NULL,NULL,&sep_axis)) { - print_line("failed initial cast (collision at beginning)"); - return false; - } -#else + //test initial overlap sep_axis = p_motion.normalized(); if (!CollisionSolverSW::solve_distance(shape, p_xform, col_obj->get_shape(shape_idx), col_obj_xform, point_A, point_B, aabb, &sep_axis)) { //print_line("failed motion cast (no collision)"); return false; } -#endif //just do kinematic solving real_t low = 0; @@ -631,21 +625,6 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve Vector3 a = sr[i * 2 + 0]; Vector3 b = sr[i * 2 + 1]; - -#if 0 - Vector3 rel = b-a; - real_t d = rel.length(); - if (d==0) - continue; - - Vector3 n = rel/d; - real_t traveled = n.dot(recover_motion); - a+=n*traveled; - - real_t d = a.distance_to(b); - if (d<margin) - continue; -#endif recover_motion += (b - a) * 0.4; } diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h index dc7799d992..56f4d2f10d 100644 --- a/servers/physics/space_sw.h +++ b/servers/physics/space_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/step_sw.cpp b/servers/physics/step_sw.cpp index 5b5f5201db..79a55e0af1 100644 --- a/servers/physics/step_sw.cpp +++ b/servers/physics/step_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics/step_sw.h b/servers/physics/step_sw.h index 893bcfa6ad..56acd8ac37 100644 --- a/servers/physics/step_sw.h +++ b/servers/physics/step_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp index fc5167c720..6c0bc2c186 100644 --- a/servers/physics_2d/area_2d_sw.cpp +++ b/servers/physics_2d/area_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/area_2d_sw.h b/servers/physics_2d/area_2d_sw.h index 6d74a4b0f6..622729bfe8 100644 --- a/servers/physics_2d/area_2d_sw.h +++ b/servers/physics_2d/area_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/area_pair_2d_sw.cpp b/servers/physics_2d/area_pair_2d_sw.cpp index 184db944da..9b43305a61 100644 --- a/servers/physics_2d/area_pair_2d_sw.cpp +++ b/servers/physics_2d/area_pair_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/area_pair_2d_sw.h b/servers/physics_2d/area_pair_2d_sw.h index 05954424f8..4a046c5f55 100644 --- a/servers/physics_2d/area_pair_2d_sw.h +++ b/servers/physics_2d/area_pair_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 91b5646ef5..eb5fb5a729 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h index 412f2f51cd..0ffad62f45 100644 --- a/servers/physics_2d/body_2d_sw.h +++ b/servers/physics_2d/body_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index 484d4503d0..828b90e5d0 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/body_pair_2d_sw.h b/servers/physics_2d/body_pair_2d_sw.h index 4d2b3b31f9..4817ea72f6 100644 --- a/servers/physics_2d/body_pair_2d_sw.h +++ b/servers/physics_2d/body_pair_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/broad_phase_2d_basic.cpp b/servers/physics_2d/broad_phase_2d_basic.cpp index 76094ad98c..e15f47a946 100644 --- a/servers/physics_2d/broad_phase_2d_basic.cpp +++ b/servers/physics_2d/broad_phase_2d_basic.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/broad_phase_2d_basic.h b/servers/physics_2d/broad_phase_2d_basic.h index edd788266a..1e9a4280db 100644 --- a/servers/physics_2d/broad_phase_2d_basic.h +++ b/servers/physics_2d/broad_phase_2d_basic.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.cpp b/servers/physics_2d/broad_phase_2d_hash_grid.cpp index 0330bfa9f3..6c800a4b49 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.cpp +++ b/servers/physics_2d/broad_phase_2d_hash_grid.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/broad_phase_2d_hash_grid.h b/servers/physics_2d/broad_phase_2d_hash_grid.h index 0cb3edb94f..8da72c5fe0 100644 --- a/servers/physics_2d/broad_phase_2d_hash_grid.h +++ b/servers/physics_2d/broad_phase_2d_hash_grid.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/broad_phase_2d_sw.cpp b/servers/physics_2d/broad_phase_2d_sw.cpp index a412f76567..d3840d570e 100644 --- a/servers/physics_2d/broad_phase_2d_sw.cpp +++ b/servers/physics_2d/broad_phase_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/broad_phase_2d_sw.h b/servers/physics_2d/broad_phase_2d_sw.h index 0309cbe730..7e7fc7d1da 100644 --- a/servers/physics_2d/broad_phase_2d_sw.h +++ b/servers/physics_2d/broad_phase_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp index 8f13f1130a..b68fa14f4b 100644 --- a/servers/physics_2d/collision_object_2d_sw.cpp +++ b/servers/physics_2d/collision_object_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h index ad8edb0b3d..db1270633f 100644 --- a/servers/physics_2d/collision_object_2d_sw.h +++ b/servers/physics_2d/collision_object_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp index a5a6cd7eac..bf8478d0b1 100644 --- a/servers/physics_2d/collision_solver_2d_sat.cpp +++ b/servers/physics_2d/collision_solver_2d_sat.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "collision_solver_2d_sat.h" + #include "geometry.h" struct _CollectorCallback2D { @@ -89,124 +90,6 @@ _FORCE_INLINE_ static void _generate_contacts_edge_edge(const Vector2 *p_points_ ERR_FAIL_COND(p_point_count_B != 2); // circle is actually a 4x3 matrix #endif -#if 0 - Vector2 rel_A=p_points_A[1]-p_points_A[0]; - Vector2 rel_B=p_points_B[1]-p_points_B[0]; - - Vector2 t = p_collector->normal.tangent(); - - print_line("tangent: "+t); - - real_t dA[2]={t.dot(p_points_A[0]),t.dot(p_points_A[1])}; - Vector2 pA[2]={p_points_A[0],p_points_A[1]}; - - if (dA[0]>dA[1]) { - SWAP(dA[0],dA[1]); - SWAP(pA[0],pA[1]); - } - - real_t dB[2]={t.dot(p_points_B[0]),t.dot(p_points_B[1])}; - Vector2 pB[2]={p_points_B[0],p_points_B[1]}; - if (dB[0]>dB[1]) { - SWAP(dB[0],dB[1]); - SWAP(pB[0],pB[1]); - } - - - if (dA[0]<dB[0]) { - - Vector2 n = (p_points_A[1]-p_points_A[0]).normalized().tangent(); - real_t d = n.dot(p_points_A[1]); - - if (dA[1]>dB[1]) { - //A contains B - for(int i=0;i<2;i++) { - - Vector2 b = p_points_B[i]; - Vector2 a = n.plane_project(d,b); - if (p_collector->normal.dot(a) > p_collector->normal.dot(b)-CMP_EPSILON) - continue; - p_collector->call(a,b); - - } - } else { - - // B0,A1 containment - - Vector2 n_B = (p_points_B[1]-p_points_B[0]).normalized().tangent(); - real_t d_B = n_B.dot(p_points_B[1]); - - // first, B on A - - { - Vector2 b = p_points_B[0]; - Vector2 a = n.plane_project(d,b); - if (p_collector->normal.dot(a) < p_collector->normal.dot(b)-CMP_EPSILON) - p_collector->call(a,b); - } - - // second, A on B - - { - Vector2 a = p_points_A[1]; - Vector2 b = n_B.plane_project(d_B,a); - if (p_collector->normal.dot(a) < p_collector->normal.dot(b)-CMP_EPSILON) - p_collector->call(a,b); - } - - - - } - - - } else { - - Vector2 n = (p_points_B[1]-p_points_B[0]).normalized().tangent(); - real_t d = n.dot(p_points_B[1]); - - if (dB[1]>dA[1]) { - //B contains A - for(int i=0;i<2;i++) { - - Vector2 a = p_points_A[i]; - Vector2 b = n.plane_project(d,a); - if (p_collector->normal.dot(a) > p_collector->normal.dot(b)-CMP_EPSILON) - continue; - p_collector->call(a,b); - } - } else { - - // A0,B1 containment - Vector2 n_A = (p_points_A[1]-p_points_A[0]).normalized().tangent(); - real_t d_A = n_A.dot(p_points_A[1]); - - // first A on B - - { - Vector2 a = p_points_A[0]; - Vector2 b = n.plane_project(d,a); - if (p_collector->normal.dot(a) < p_collector->normal.dot(b)-CMP_EPSILON) - p_collector->call(a,b); - - } - - //second, B on A - - { - - Vector2 b = p_points_B[1]; - Vector2 a = n_A.plane_project(d_A,b); - if (p_collector->normal.dot(a) < p_collector->normal.dot(b)-CMP_EPSILON) - p_collector->call(a,b); - } - - } - } - -#endif - -#if 1 - Vector2 n = p_collector->normal; Vector2 t = n.tangent(); real_t dA = n.dot(p_points_A[0]); @@ -246,38 +129,6 @@ _FORCE_INLINE_ static void _generate_contacts_edge_edge(const Vector2 *p_points_ p_collector->call(a, b); } } - -#elif 0 - Vector2 axis = rel_A.normalized(); //make an axis - Vector2 axis_B = rel_B.normalized(); - if (axis.dot(axis_B) < 0) - axis_B = -axis_B; - axis = (axis + axis_B) * 0.5; - Vector2 base_A = p_points_A[0] - axis * axis.dot(p_points_A[0]); - Vector2 base_B = p_points_B[0] - axis * axis.dot(p_points_B[0]); - - //sort all 4 points in axis - real_t dvec[4] = { axis.dot(p_points_A[0]), axis.dot(p_points_A[1]), axis.dot(p_points_B[0]), axis.dot(p_points_B[1]) }; - - //todo , find max/min and then use 2 central points - SortArray<real_t> sa; - sa.sort(dvec, 4); - - //use the middle ones as contacts - for (int i = 1; i <= 2; i++) { - - Vector2 a = base_A + axis * dvec[i]; - Vector2 b = base_B + axis * dvec[i]; - if (p_collector->normal.dot(a) > p_collector->normal.dot(b) - 0.01) { - print_line("fail a: " + a); - print_line("fail b: " + b); - continue; - } - print_line("res a: " + a); - print_line("res b: " + b); - p_collector->call(a, b); - } -#endif } static void _generate_contacts_from_supports(const Vector2 *p_points_A, int p_point_count_A, const Vector2 *p_points_B, int p_point_count_B, _CollectorCallback2D *p_collector) { @@ -504,37 +355,11 @@ public: } } - /* - - - print_line("**************************"); - printf("CBK: %p\n",callback->userdata); - print_line("type A: "+itos(shape_A->get_type())); - print_line("type B: "+itos(shape_B->get_type())); - print_line("xform A: "+*transform_A); - print_line("xform B: "+*transform_B); - print_line("normal: "+best_axis); - print_line("depth: "+rtos(best_depth)); - print_line("index: "+itos(best_axis_index)); - - for(int i=0;i<support_count_A;i++) { - - print_line("A-"+itos(i)+": "+supports_A[i]); - } - - for(int i=0;i<support_count_B;i++) { - - print_line("B-"+itos(i)+": "+supports_B[i]); - } -//*/ - callback->normal = best_axis; _generate_contacts_from_supports(supports_A, support_count_A, supports_B, support_count_B, callback); if (callback && callback->sep_axis && *callback->sep_axis != Vector2()) *callback->sep_axis = Vector2(); //invalidate previous axis (no test) - //CollisionSolver2DSW::CallbackResult cbk=NULL; - //cbk(Vector2(),Vector2(),NULL); } _FORCE_INLINE_ SeparatorAxisTest2D(const ShapeA *p_shape_A, const Transform2D &p_transform_a, const ShapeB *p_shape_B, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_A = Vector2(), const Vector2 &p_motion_B = Vector2(), real_t p_margin_A = 0, real_t p_margin_B = 0) { @@ -558,9 +383,6 @@ public: }; /****** SAT TESTS *******/ -/****** SAT TESTS *******/ -/****** SAT TESTS *******/ -/****** SAT TESTS *******/ #define TEST_POINT(m_a, m_b) \ ((!separator.test_axis(((m_a) - (m_b)).normalized())) || \ @@ -582,11 +404,6 @@ static void _collision_segment_segment(const Shape2DSW *p_a, const Transform2D & return; //this collision is kind of pointless - /* - if (!separator.test_previous_axis()) - return; - */ - if (!separator.test_cast()) return; diff --git a/servers/physics_2d/collision_solver_2d_sat.h b/servers/physics_2d/collision_solver_2d_sat.h index 2a075e2a30..520083c5fa 100644 --- a/servers/physics_2d/collision_solver_2d_sat.h +++ b/servers/physics_2d/collision_solver_2d_sat.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp index b482f826c2..d66b917bcd 100644 --- a/servers/physics_2d/collision_solver_2d_sw.cpp +++ b/servers/physics_2d/collision_solver_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/collision_solver_2d_sw.h b/servers/physics_2d/collision_solver_2d_sw.h index aefd4d315d..9f3d348e91 100644 --- a/servers/physics_2d/collision_solver_2d_sw.h +++ b/servers/physics_2d/collision_solver_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/constraint_2d_sw.h b/servers/physics_2d/constraint_2d_sw.h index 7ff28b0cf4..252d0ee9b4 100644 --- a/servers/physics_2d/constraint_2d_sw.h +++ b/servers/physics_2d/constraint_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp index 93091f55cf..897e145a3e 100644 --- a/servers/physics_2d/joints_2d_sw.cpp +++ b/servers/physics_2d/joints_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "joints_2d_sw.h" + #include "space_2d_sw.h" //based on chipmunk joint constraints @@ -87,127 +88,12 @@ normal_relative_velocity(Body2DSW *a, Body2DSW *b, Vector2 rA, Vector2 rB, Vecto return relative_velocity(a, b, rA, rB).dot(n); } -#if 0 - -bool PinJoint2DSW::setup(real_t p_step) { - - Space2DSW *space = A->get_space(); - ERR_FAIL_COND_V(!space,false;) - rA = A->get_transform().basis_xform(anchor_A); - rB = B?B->get_transform().basis_xform(anchor_B):anchor_B; - - Vector2 gA = A->get_transform().get_origin(); - Vector2 gB = B?B->get_transform().get_origin():Vector2(); - - Vector2 delta = gB - gA; - delta = (delta+rB) -rA; - - real_t jdist = delta.length(); - correct=false; - if (jdist==0) - return false; // do not correct - - correct=true; - - n = delta / jdist; - - // calculate mass normal - mass_normal = 1.0f/k_scalar(A, B, rA, rB, n); - - // calculate bias velocity - //real_t maxBias = joint->constraint.maxBias; - bias = -(get_bias()==0?space->get_constraint_bias():get_bias())*(1.0/p_step)*(jdist-dist); - bias = CLAMP(bias, -get_max_bias(), +get_max_bias()); - - // compute max impulse - jn_max = get_max_force() * p_step; - - // apply accumulated impulse - Vector2 j = n * jn_acc; - A->apply_impulse(rA,-j); - if (B) - B->apply_impulse(rB,j); - - print_line("setup"); - return true; -} - - - -void PinJoint2DSW::solve(real_t p_step){ - - if (!correct) - return; - - Vector2 ln = n; - - // compute relative velocity - real_t vrn = normal_relative_velocity(A,B, rA, rB, ln); - - // compute normal impulse - real_t jn = (bias - vrn)*mass_normal; - real_t jnOld = jn_acc; - jn_acc = CLAMP(jnOld + jn,-jn_max,jn_max); //cpfclamp(jnOld + jn, -joint->jnMax, joint->jnMax); - jn = jn_acc - jnOld; - print_line("jn_acc: "+rtos(jn_acc)); - Vector2 j = jn*ln; - - A->apply_impulse(rA,-j); - if (B) - B->apply_impulse(rB,j); - -} - - -PinJoint2DSW::PinJoint2DSW(const Vector2& p_pos,Body2DSW* p_body_a,Body2DSW* p_body_b) : Joint2DSW(_arr,p_body_b?2:1) { - - A=p_body_a; - B=p_body_b; - anchor_A = p_body_a->get_inv_transform().xform(p_pos); - anchor_B = p_body_b?p_body_b->get_inv_transform().xform(p_pos):p_pos; - - jn_acc=0; - dist=0; - - p_body_a->add_constraint(this,0); - if (p_body_b) - p_body_b->add_constraint(this,1); - -} - -PinJoint2DSW::~PinJoint2DSW() { - - if (A) - A->remove_constraint(this); - if (B) - B->remove_constraint(this); - -} - -#else - bool PinJoint2DSW::setup(real_t p_step) { Space2DSW *space = A->get_space(); ERR_FAIL_COND_V(!space, false;) rA = A->get_transform().basis_xform(anchor_A); rB = B ? B->get_transform().basis_xform(anchor_B) : anchor_B; -#if 0 - Vector2 gA = rA+A->get_transform().get_origin(); - Vector2 gB = B?rB+B->get_transform().get_origin():rB; - - VectorB delta = gB - gA; - - real_t jdist = delta.length(); - correct=false; - if (jdist==0) - return false; // do not correct -#endif - - // deltaV = deltaV0 + K * impulse - // invM = [(1/m1 + 1/m2) * eye(2) - skew(rA) * invI1 * skew(rA) - skew(rB) * invI2 * skew(rB)] - // = [1/m1+1/m2 0 ] + invI1 * [rA.y*rA.y -rA.x*rA.y] + invI2 * [rA.y*rA.y -rA.x*rA.y] - // [ 0 1/m1+1/m2] [-rA.x*rA.y rA.x*rA.x] [-rA.x*rA.y rA.x*rA.x] real_t B_inv_mass = B ? B->get_inv_mass() : 0.0; @@ -315,8 +201,6 @@ PinJoint2DSW::~PinJoint2DSW() { B->remove_constraint(this); } -#endif - ////////////////////////////////////////////// ////////////////////////////////////////////// ////////////////////////////////////////////// diff --git a/servers/physics_2d/joints_2d_sw.h b/servers/physics_2d/joints_2d_sw.h index 548a8b778f..11cb41d9d1 100644 --- a/servers/physics_2d/joints_2d_sw.h +++ b/servers/physics_2d/joints_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -56,46 +56,6 @@ public: max_force = max_bias = 3.40282e+38; }; }; -#if 0 - -class PinJoint2DSW : public Joint2DSW { - - union { - struct { - Body2DSW *A; - Body2DSW *B; - }; - - Body2DSW *_arr[2]; - }; - - Vector2 anchor_A; - Vector2 anchor_B; - real_t dist; - real_t jn_acc; - real_t jn_max; - real_t max_distance; - real_t mass_normal; - real_t bias; - - Vector2 rA,rB; - Vector2 n; //normal - bool correct; - - -public: - - virtual Physics2DServer::JointType get_type() const { return Physics2DServer::JOINT_PIN; } - - virtual bool setup(real_t p_step); - virtual void solve(real_t p_step); - - - PinJoint2DSW(const Vector2& p_pos,Body2DSW* p_body_a,Body2DSW* p_body_b=NULL); - ~PinJoint2DSW(); -}; - -#else class PinJoint2DSW : public Joint2DSW { @@ -129,7 +89,6 @@ public: ~PinJoint2DSW(); }; -#endif class GrooveJoint2DSW : public Joint2DSW { union { diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 3805075ac3..006c5fd7b5 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h index e767aad1da..7d3c589fa9 100644 --- a/servers/physics_2d/physics_2d_server_sw.h +++ b/servers/physics_2d/physics_2d_server_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp index 8d19153268..a4e6abfd45 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp +++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index 8058709c06..189419e8e4 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index e153ee985c..20d0d38b17 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "shape_2d_sw.h" + #include "geometry.h" #include "sort.h" diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h index a75a4338e7..0128f7ee70 100644 --- a/servers/physics_2d/shape_2d_sw.h +++ b/servers/physics_2d/shape_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 718669988c..9b2e586993 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "space_2d_sw.h" + #include "collision_solver_2d_sw.h" #include "physics_2d_server_sw.h" @@ -575,21 +576,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co Vector2 a = sr[i * 2 + 0]; Vector2 b = sr[i * 2 + 1]; - -#if 0 - Vector2 rel = b-a; - real_t d = rel.length(); - if (d==0) - continue; - - Vector2 n = rel/d; - real_t traveled = n.dot(recover_motion); - a+=n*traveled; - - real_t d = a.distance_to(b); - if (d<margin) - continue; -#endif recover_motion += (b - a) * 0.4; } diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h index 4bd81c054f..ed6136e372 100644 --- a/servers/physics_2d/space_2d_sw.h +++ b/servers/physics_2d/space_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/step_2d_sw.cpp b/servers/physics_2d/step_2d_sw.cpp index f43fef4eef..8d6adf004d 100644 --- a/servers/physics_2d/step_2d_sw.cpp +++ b/servers/physics_2d/step_2d_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d/step_2d_sw.h b/servers/physics_2d/step_2d_sw.h index bdcb34f3ae..41227d8e9a 100644 --- a/servers/physics_2d/step_2d_sw.h +++ b/servers/physics_2d/step_2d_sw.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index 898c49a1eb..06966e2452 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index 905f96a5a9..cd6a20e6b8 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp index c51a59973c..5097e0a5d2 100644 --- a/servers/physics_server.cpp +++ b/servers/physics_server.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/physics_server.h b/servers/physics_server.h index a8c2a7761d..c6d312e0fe 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -96,6 +96,7 @@ class PhysicsShapeQueryParameters : public Reference { GDCLASS(PhysicsShapeQueryParameters, Reference); friend class PhysicsDirectSpaceState; + RID shape; Transform transform; float margin; @@ -133,8 +134,6 @@ class PhysicsDirectSpaceState : public Object { GDCLASS(PhysicsDirectSpaceState, Object); - //Variant _intersect_ray(const Vector3& p_from, const Vector3& p_to,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_collision_mask=0); - //Variant _intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max=64,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_collision_mask=0); public: enum ObjectTypeMask { TYPE_MASK_STATIC_BODY = 1 << 0, @@ -625,37 +624,6 @@ public: virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag, bool p_enable) = 0; virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis, G6DOFJointAxisFlag p_flag) = 0; -#if 0 - enum JointType { - - JOINT_PIN, - JOINT_GROOVE, - JOINT_DAMPED_SPRING - }; - - enum JointParam { - JOINT_PARAM_BIAS, - JOINT_PARAM_MAX_BIAS, - JOINT_PARAM_MAX_FORCE, - }; - - virtual void joint_set_param(RID p_joint, JointParam p_param, real_t p_value)=0; - virtual real_t joint_get_param(RID p_joint,JointParam p_param) const=0; - - virtual RID pin_joint_create(const Vector3& p_anchor,RID p_body_a,RID p_body_b=RID())=0; - virtual RID groove_joint_create(const Vector3& p_a_groove1,const Vector3& p_a_groove2, const Vector3& p_b_anchor, RID p_body_a,RID p_body_b)=0; - virtual RID damped_spring_joint_create(const Vector3& p_anchor_a,const Vector3& p_anchor_b,RID p_body_a,RID p_body_b=RID())=0; - - enum DampedStringParam { - DAMPED_STRING_REST_LENGTH, - DAMPED_STRING_STIFFNESS, - DAMPED_STRING_DAMPING - }; - virtual void damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value)=0; - virtual real_t damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const=0; - - virtual JointType joint_get_type(RID p_joint) const=0; -#endif /* QUERY API */ enum AreaBodyStatus { @@ -703,7 +671,6 @@ VARIANT_ENUM_CAST(PhysicsServer::SliderJointParam); VARIANT_ENUM_CAST(PhysicsServer::ConeTwistJointParam); VARIANT_ENUM_CAST(PhysicsServer::G6DOFJointAxisParam); VARIANT_ENUM_CAST(PhysicsServer::G6DOFJointAxisFlag); -//VARIANT_ENUM_CAST( PhysicsServer::ObjectType ); VARIANT_ENUM_CAST(PhysicsServer::AreaBodyStatus); VARIANT_ENUM_CAST(PhysicsServer::ProcessInfo); diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 092f445c13..845a3443b7 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/register_server_types.h b/servers/register_server_types.h index c183ccc8a4..2b3ac816ac 100644 --- a/servers/register_server_types.h +++ b/servers/register_server_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/server_wrap_mt_common.h b/servers/server_wrap_mt_common.h index 1ffa5ad14c..267e5c63b9 100644 --- a/servers/server_wrap_mt_common.h +++ b/servers/server_wrap_mt_common.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/rasterizer.cpp b/servers/visual/rasterizer.cpp index f7ea158646..fd594fa3ee 100644 --- a/servers/visual/rasterizer.cpp +++ b/servers/visual/rasterizer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "rasterizer.h" + #include "os/os.h" #include "print_string.h" @@ -44,614 +45,3 @@ RasterizerStorage::RasterizerStorage() { base_singleton = this; } - -#if 0 - -RID Rasterizer::create_default_material() { - - return material_create(); -} - - -/* Fixed MAterial SHADER API */ - -RID Rasterizer::_create_shader(const SpatialMaterialShaderKey& p_key) { - - ERR_FAIL_COND_V(!p_key.valid,RID()); - Map<SpatialMaterialShaderKey,SpatialMaterialShader>::Element *E=fixed_material_shaders.find(p_key); - - if (E) { - E->get().refcount++; - return E->get().shader; - } - - uint64_t t = OS::get_singleton()->get_ticks_usec(); - - SpatialMaterialShader fms; - fms.refcount=1; - fms.shader=shader_create(); - - //create shader code - - - int texcoords_used=0; - String code; - - static const char* _uv_str[4]={"UV","uv_xform","UV2","uv_sphere"}; -#define _TEXUVSTR(m_idx) String(_uv_str[(p_key.texcoord_mask >> (m_idx * 2)) & 0x3]) - - - if (p_key.use_pointsize) { - - code+="UV=POINT_COORD;\n"; - } - - - for(int i=0;i<VS::FIXED_MATERIAL_PARAM_MAX;i++) { - - if (p_key.texture_mask&(1<<i)) - texcoords_used|=(1<<((p_key.texcoord_mask>>(i*2))&0x3)); - } - - if (texcoords_used&(1<<VS::FIXED_MATERIAL_TEXCOORD_UV_TRANSFORM)) { - - code+="uniform mat4 fmp_uv_xform;\n"; - code+="vec2 uv_xform = (fmp_uv_xform * vec4(UV,0,1)).xy;\n"; - } - - /* HANDLE NORMAL MAPPING */ - - - if (p_key.texture_mask&(1<<VS::FIXED_MATERIAL_PARAM_NORMAL)) { - - String scode; - scode+="uniform float fmp_normal;\n"; - scode+="uniform texture fmp_normal_tex;\n"; - String uv_str; - if (((p_key.texcoord_mask>>(VS::FIXED_MATERIAL_PARAM_NORMAL*2))&0x3)==VS::FIXED_MATERIAL_TEXCOORD_SPHERE) { - uv_str="uv"; //sorry not supported - } else { - uv_str=_TEXUVSTR(VS::FIXED_MATERIAL_PARAM_NORMAL); - } - if (p_key.use_xy_normalmap) { - scode+="vec2 ywnormal=tex( fmp_normal_tex,"+uv_str+").wy * vec2(2.0,2.0) - vec2(1.0,1.0);\n"; - scode+="NORMALMAP=vec3(ywnormal,sqrt(1 - (ywnormal.x * ywnormal.x) - (ywnormal.y * ywnormal.y) ));\n"; - } else { - scode+="NORMALMAP=tex( fmp_normal_tex,"+uv_str+").xyz * vec3(2.0,2.0,1.0) - vec3(1.0,1.0,0.0);\n"; - } - scode+="NORMALMAP_DEPTH=fmp_normal;\n"; - - code+=scode; - } - - //handle sphere uv if used, do it here because it needs the normal, which may be transformed by a normal map - - if (texcoords_used&(1<<VS::FIXED_MATERIAL_TEXCOORD_SPHERE)) { - - String tcode; - tcode="vec3 eye_normal = normalize(VERTEX);\n"; - tcode+="vec3 ref = (eye_normal - 2.0*dot(NORMAL, eye_normal)*NORMAL);\n"; - tcode+="ref.z+=1.0;\n"; - tcode+="vec2 uv_sphere = ref.xy*vec2(0.5,0.0-0.5)+vec2(0.5,0.0-0.5);\n"; - code+=tcode; - } - - /* HANDLE DIFFUSE LIGHTING */ - - code+="uniform color fmp_diffuse;\n"; - code+="color diffuse=fmp_diffuse;\n"; - - if (p_key.use_color_array) - code+="diffuse*=COLOR;\n"; - - if (p_key.texture_mask&(1<<VS::FIXED_MATERIAL_PARAM_DIFFUSE)) { - - - code+="uniform texture fmp_diffuse_tex;\n"; - code+="diffuse*=tex( fmp_diffuse_tex,"+_TEXUVSTR(VS::FIXED_MATERIAL_PARAM_DIFFUSE)+");\n"; - } - - if (p_key.texture_mask&(1<<VS::FIXED_MATERIAL_PARAM_DETAIL)) { - - String dcode; - dcode+="uniform texture fmp_detail_tex;\n"; - dcode+="uniform float fmp_detail;\n"; - dcode+="color detail=tex( fmp_detail_tex,"+_TEXUVSTR(VS::FIXED_MATERIAL_PARAM_DETAIL)+");\n"; - //aways mix - dcode+="diffuse=vec4(mix(diffuse.rgb,detail.rgb,detail.a*fmp_detail),diffuse.a);\n"; - - code+=dcode; - } - - if (p_key.use_alpha) { - code+="DIFFUSE_ALPHA=diffuse;\n"; - if (p_key.discard_alpha) { - code+="DISCARD=diffuse.a<0.5;\n"; - } - } else { - code+="DIFFUSE=diffuse.rgb;\n"; - } - - /* HANDLE SPECULAR LIGHTING */ - - code+="uniform color fmp_specular;\n"; - code+="color specular=fmp_specular;\n"; - - if (p_key.texture_mask&(1<<VS::FIXED_MATERIAL_PARAM_SPECULAR)) { - - String scode; - scode+="uniform texture fmp_specular_tex;\n"; - scode+="specular*=tex( fmp_specular_tex,"+_TEXUVSTR(VS::FIXED_MATERIAL_PARAM_SPECULAR)+");\n"; - code+=scode; - } - - code+="SPECULAR=specular.rgb;\n"; - - code+="uniform float fmp_specular_exp;\n"; - code+="float specular_exp=fmp_specular_exp;\n"; - - if (p_key.texture_mask&(1<<VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP)) { - - String scode; - scode+="uniform texture fmp_specular_exp_tex;\n"; - scode+="specular_exp*=tex( fmp_specular_exp_tex,"+_TEXUVSTR(VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP)+").r;\n"; - code+=scode; - } - - code+="SPEC_EXP=specular_exp;\n"; - - /* HANDLE EMISSION LIGHTING */ - - code+="uniform color fmp_emission;\n"; - code+="color emission=fmp_emission;\n"; - - if (p_key.texture_mask&(1<<VS::FIXED_MATERIAL_PARAM_EMISSION)) { - - String scode; - scode+="uniform texture fmp_emission_tex;\n"; - scode+="emission*=tex( fmp_emission_tex,"+_TEXUVSTR(VS::FIXED_MATERIAL_PARAM_EMISSION)+");\n"; - code+=scode; - } - - code+="EMISSION=emission.rgb;\n"; - - - /* HANDLE GLOW */ - - code+="uniform float fmp_glow;\n"; - code+="float glow=fmp_glow;\n"; - - if (p_key.texture_mask&(1<<VS::FIXED_MATERIAL_PARAM_GLOW)) { - - String scode; - scode+="uniform texture fmp_glow_tex;\n"; - scode+="glow*=tex( fmp_glow_tex,"+_TEXUVSTR(VS::FIXED_MATERIAL_PARAM_GLOW)+").r;\n"; - code+=scode; - } - - code+="GLOW=glow;\n"; - - if (p_key.texture_mask&(1<<VS::FIXED_MATERIAL_PARAM_SHADE_PARAM)) { - - String scode; - scode+="uniform texture fmp_shade_param_tex;\n"; - scode+="SHADE_PARAM=tex( fmp_shade_param_tex,"+_TEXUVSTR(VS::FIXED_MATERIAL_PARAM_SHADE_PARAM)+").r;\n"; - code+=scode; - } else { - - String scode; - scode+="uniform float fmp_shade_param;\n"; - scode+="SHADE_PARAM=fmp_shade_param;\n"; - code+=scode; - - } - - - //print_line("**FRAGMENT SHADER GENERATED code: \n"+code); - - String vcode; - vcode="uniform float "+_fixed_material_param_names[VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP]+";\n"; - vcode+="SPEC_EXP="+_fixed_material_param_names[VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP]+";\n"; - if (p_key.use_pointsize) { - - vcode+="uniform float "+_fixed_material_point_size_name+";\n"; - vcode+="POINT_SIZE="+_fixed_material_point_size_name+";\n"; - //vcode+="POINT_SIZE=10.0;\n"; - } - - String lcode; - - switch(p_key.light_shader) { - - case VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT: { - //do nothing - - } break; - case VS::FIXED_MATERIAL_LIGHT_SHADER_WRAP: { - - lcode+="float NdotL = max(0.0,((dot( NORMAL, LIGHT_DIR )+SHADE_PARAM)/(1.0+SHADE_PARAM)));"; - lcode+="vec3 half_vec = normalize(LIGHT_DIR + EYE_VEC);"; - lcode+="float eye_light = max(dot(NORMAL, half_vec),0.0);"; - lcode+="LIGHT = LIGHT_DIFFUSE * DIFFUSE * NdotL;"; - lcode+="if (NdotL > 0.0) {"; - lcode+="\tLIGHT+=LIGHT_SPECULAR * SPECULAR * pow( eye_light, SPECULAR_EXP );"; - lcode+="};"; - - } break; - case VS::FIXED_MATERIAL_LIGHT_SHADER_VELVET: { - lcode+="float NdotL = max(0.0,dot( NORMAL, LIGHT_DIR ));"; - lcode+="vec3 half_vec = normalize(LIGHT_DIR + EYE_VEC);"; - lcode+="float eye_light = max(dot(NORMAL, half_vec),0.0);"; - lcode+="LIGHT = LIGHT_DIFFUSE * DIFFUSE * NdotL;"; - lcode+="float rim = (1.0-abs(dot(NORMAL,vec3(0,0,1))))*SHADE_PARAM;"; - lcode+="LIGHT += LIGHT_DIFFUSE * DIFFUSE * rim;"; - lcode+="if (NdotL > 0.0) {"; - lcode+="\tLIGHT+=LIGHT_SPECULAR * SPECULAR * pow( eye_light, SPECULAR_EXP );"; - lcode+="};"; - - - } break; - case VS::FIXED_MATERIAL_LIGHT_SHADER_TOON: { - - lcode+="float NdotL = dot( NORMAL, LIGHT_DIR );"; - lcode+="vec3 light_ref = reflect( LIGHT_DIR, NORMAL );"; - lcode+="float eye_light = clamp( dot( light_ref, vec3(0,0,0)-EYE_VEC), 0.0, 1.0 );"; - lcode+="float NdotL_diffuse = smoothstep( max( SHADE_PARAM-0.05, 0.0-1.0), min( SHADE_PARAM+0.05, 1.0), NdotL );"; - lcode+="float spec_radius=clamp((1.0-(SPECULAR_EXP/64.0)),0.0,1.0);"; - lcode+="float NdotL_specular = smoothstep( max( spec_radius-0.05, 0.0), min( spec_radius+0.05, 1.0), eye_light )*max(NdotL,0);"; - lcode+="LIGHT = NdotL_diffuse * LIGHT_DIFFUSE*DIFFUSE + NdotL_specular * LIGHT_SPECULAR*SPECULAR;"; - - } break; - - } - - //print_line("**VERTEX SHADER GENERATED code: \n"+vcode); - - shader_set_code(fms.shader,vcode,code,lcode,0,0); - - fixed_material_shaders[p_key]=fms; - return fms.shader; -} - -void Rasterizer::_free_shader(const SpatialMaterialShaderKey& p_key) { - - if (p_key.valid==0) - return; //not a valid key - - Map<SpatialMaterialShaderKey,SpatialMaterialShader>::Element *E=fixed_material_shaders.find(p_key); - - ERR_FAIL_COND(!E); - E->get().refcount--; - if (E->get().refcount==0) { - free(E->get().shader); - fixed_material_shaders.erase(E); - } - -} - - -void Rasterizer::fixed_material_set_flag(RID p_material, VS::SpatialMaterialFlags p_flag, bool p_enabled) { - - - Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND(!E); - SpatialMaterial &fm=*E->get(); - - switch(p_flag) { - - case VS::FIXED_MATERIAL_FLAG_USE_ALPHA: fm.use_alpha=p_enabled; break; - case VS::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY: fm.use_color_array=p_enabled; break; - case VS::FIXED_MATERIAL_FLAG_USE_POINT_SIZE: fm.use_pointsize=p_enabled; break; - case VS::FIXED_MATERIAL_FLAG_DISCARD_ALPHA: fm.discard_alpha=p_enabled; break; - case VS::FIXED_MATERIAL_FLAG_USE_XY_NORMALMAP: fm.use_xy_normalmap=p_enabled; break; - } - - if (!fm.dirty_list.in_list()) - fixed_material_dirty_list.add( &fm.dirty_list ); - -} - -bool Rasterizer::fixed_material_get_flag(RID p_material, VS::SpatialMaterialFlags p_flag) const{ - - const Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND_V(!E,false); - const SpatialMaterial &fm=*E->get(); - switch(p_flag) { - - case VS::FIXED_MATERIAL_FLAG_USE_ALPHA: return fm.use_alpha;; break; - case VS::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY: return fm.use_color_array;; break; - case VS::FIXED_MATERIAL_FLAG_USE_POINT_SIZE: return fm.use_pointsize;; break; - case VS::FIXED_MATERIAL_FLAG_DISCARD_ALPHA: return fm.discard_alpha;; break; - case VS::FIXED_MATERIAL_FLAG_USE_XY_NORMALMAP: return fm.use_xy_normalmap;; break; - - } - - - return false; -} - - -RID Rasterizer::fixed_material_create() { - - RID mat = material_create(); - fixed_materials[mat]=memnew( SpatialMaterial() ); - SpatialMaterial &fm=*fixed_materials[mat]; - fm.self=mat; - fm.get_key(); - material_set_flag(mat,VS::MATERIAL_FLAG_COLOR_ARRAY_SRGB,true); - for(int i=0;i<VS::FIXED_MATERIAL_PARAM_MAX;i++) { - - material_set_param(mat,_fixed_material_param_names[i],fm.param[i]); //must be there - } - fixed_material_dirty_list.add(&fm.dirty_list); - //print_line("FMC: "+itos(mat.get_id())); - return mat; -} - - - - -void Rasterizer::fixed_material_set_parameter(RID p_material, VS::SpatialMaterialParam p_parameter, const Variant& p_value){ - - Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND(!E); - SpatialMaterial &fm=*E->get(); - RID material=E->key(); - ERR_FAIL_INDEX(p_parameter,VS::FIXED_MATERIAL_PARAM_MAX); - - if ((p_parameter==VS::FIXED_MATERIAL_PARAM_DIFFUSE || p_parameter==VS::FIXED_MATERIAL_PARAM_SPECULAR || p_parameter==VS::FIXED_MATERIAL_PARAM_EMISSION)) { - - if (p_value.get_type()!=Variant::COLOR) { - ERR_EXPLAIN(String(_fixed_material_param_names[p_parameter])+" expects Color"); - ERR_FAIL(); - } - } else { - - if (!p_value.is_num()) { - ERR_EXPLAIN(String(_fixed_material_param_names[p_parameter])+" expects scalar"); - ERR_FAIL(); - } - } - - fm.param[p_parameter]=p_value; - VS::get_singleton()->material_set_param(material,_fixed_material_param_names[p_parameter],p_value); - - -} -Variant Rasterizer::fixed_material_get_parameter(RID p_material,VS::SpatialMaterialParam p_parameter) const{ - - const Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND_V(!E,Variant()); - const SpatialMaterial &fm=*E->get(); - ERR_FAIL_INDEX_V(p_parameter,VS::FIXED_MATERIAL_PARAM_MAX,Variant()); - return fm.param[p_parameter]; -} - -void Rasterizer::fixed_material_set_texture(RID p_material,VS::SpatialMaterialParam p_parameter, RID p_texture){ - - Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - if (!E) { - - print_line("Not found: "+itos(p_material.get_id())); - } - ERR_FAIL_COND(!E); - SpatialMaterial &fm=*E->get(); - - - ERR_FAIL_INDEX(p_parameter,VS::FIXED_MATERIAL_PARAM_MAX); - RID material=E->key(); - fm.texture[p_parameter]=p_texture; - VS::get_singleton()->material_set_param(material,_fixed_material_tex_names[p_parameter],p_texture); - - if (!fm.dirty_list.in_list()) - fixed_material_dirty_list.add( &fm.dirty_list ); - - - - -} -RID Rasterizer::fixed_material_get_texture(RID p_material,VS::SpatialMaterialParam p_parameter) const{ - - const Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND_V(!E,RID()); - const SpatialMaterial &fm=*E->get(); - ERR_FAIL_INDEX_V(p_parameter,VS::FIXED_MATERIAL_PARAM_MAX,RID()); - - return fm.texture[p_parameter]; -} - - -void Rasterizer::fixed_material_set_texcoord_mode(RID p_material,VS::SpatialMaterialParam p_parameter, VS::SpatialMaterialTexCoordMode p_mode) { - - Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND(!E); - SpatialMaterial &fm=*E->get(); - ERR_FAIL_INDEX(p_parameter,VS::FIXED_MATERIAL_PARAM_MAX); - - fm.get_key(); - - fm.texture_tc[p_parameter]=p_mode; - - if (!fm.dirty_list.in_list()) - fixed_material_dirty_list.add( &fm.dirty_list ); - -} - -VS::SpatialMaterialTexCoordMode Rasterizer::fixed_material_get_texcoord_mode(RID p_material,VS::SpatialMaterialParam p_parameter) const { - - const Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND_V(!E,VS::FIXED_MATERIAL_TEXCOORD_UV); - const SpatialMaterial &fm=*E->get(); - ERR_FAIL_INDEX_V(p_parameter,VS::FIXED_MATERIAL_PARAM_MAX,VS::FIXED_MATERIAL_TEXCOORD_UV); - - return fm.texture_tc[p_parameter]; -} - -void Rasterizer::fixed_material_set_uv_transform(RID p_material,const Transform& p_transform) { - - Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND(!E); - SpatialMaterial &fm=*E->get(); - RID material=E->key(); - - VS::get_singleton()->material_set_param(material,_fixed_material_uv_xform_name,p_transform); - - fm.uv_xform=p_transform; - -} - - - -Transform Rasterizer::fixed_material_get_uv_transform(RID p_material) const { - - const Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND_V(!E,Transform()); - const SpatialMaterial &fm=*E->get(); - - return fm.uv_xform; -} - -void Rasterizer::fixed_material_set_light_shader(RID p_material,VS::SpatialMaterialLightShader p_shader) { - - Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND(!E); - SpatialMaterial &fm=*E->get(); - - fm.light_shader=p_shader; - - if (!fm.dirty_list.in_list()) - fixed_material_dirty_list.add( &fm.dirty_list ); - -} - -VS::SpatialMaterialLightShader Rasterizer::fixed_material_get_light_shader(RID p_material) const { - - const Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND_V(!E,VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT); - const SpatialMaterial &fm=*E->get(); - - return fm.light_shader; -} - -void Rasterizer::fixed_material_set_point_size(RID p_material,float p_size) { - - Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND(!E); - SpatialMaterial &fm=*E->get(); - RID material=E->key(); - - VS::get_singleton()->material_set_param(material,_fixed_material_point_size_name,p_size); - - fm.point_size=p_size; - - -} - -float Rasterizer::fixed_material_get_point_size(RID p_material) const{ - - const Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - ERR_FAIL_COND_V(!E,1.0); - const SpatialMaterial &fm=*E->get(); - - return fm.point_size; - -} - -void Rasterizer::_update_fixed_materials() { - - - while(fixed_material_dirty_list.first()) { - - SpatialMaterial &fm=*fixed_material_dirty_list.first()->self(); - - SpatialMaterialShaderKey new_key = fm.get_key(); - if (new_key.key!=fm.current_key.key) { - - _free_shader(fm.current_key); - RID new_rid = _create_shader(new_key); - fm.current_key=new_key; - material_set_shader(fm.self,new_rid); - - if (fm.texture[VS::FIXED_MATERIAL_PARAM_DETAIL].is_valid()) { - //send these again just in case. - material_set_param(fm.self,_fixed_material_param_names[VS::FIXED_MATERIAL_PARAM_DETAIL],fm.param[VS::FIXED_MATERIAL_PARAM_DETAIL]); - } - if (fm.texture[VS::FIXED_MATERIAL_PARAM_NORMAL].is_valid()) { - //send these again just in case. - material_set_param(fm.self,_fixed_material_param_names[VS::FIXED_MATERIAL_PARAM_NORMAL],fm.param[VS::FIXED_MATERIAL_PARAM_NORMAL]); - } - - material_set_param(fm.self,_fixed_material_uv_xform_name,fm.uv_xform); - if (fm.use_pointsize) { - material_set_param(fm.self,_fixed_material_point_size_name,fm.point_size); - } - } - - fixed_material_dirty_list.remove(fixed_material_dirty_list.first()); - } -} - - -void Rasterizer::_free_fixed_material(const RID& p_material) { - - Map<RID,SpatialMaterial*>::Element *E = fixed_materials.find(p_material); - - if (E) { - - _free_shader(E->get()->current_key); //free shader - if (E->get()->dirty_list.in_list()) - fixed_material_dirty_list.remove( &E->get()->dirty_list); - memdelete(E->get()); - fixed_materials.erase(E); //free material - } - - -} - - -void Rasterizer::flush_frame() { - - //not really necessary to implement -} - -Rasterizer::Rasterizer() { - - static const char* fm_names[VS::FIXED_MATERIAL_PARAM_MAX]={ - "diffuse", - "detail", - "specular", - "emission", - "specular_exp", - "glow", - "normal", - "shade_param"}; - - for(int i=0;i<VS::FIXED_MATERIAL_PARAM_MAX;i++) { - - _fixed_material_param_names[i]=String("fmp_")+fm_names[i]; - _fixed_material_tex_names[i]=String("fmp_")+fm_names[i]+"_tex"; - } - - _fixed_material_uv_xform_name="fmp_uv_xform"; - _fixed_material_point_size_name="fmp_point_size"; - - draw_viewport_func=NULL; - - ERR_FAIL_COND( sizeof(SpatialMaterialShaderKey)!=4); - -} - -RID Rasterizer::create_overdraw_debug_material() { - RID mat = fixed_material_create(); - fixed_material_set_parameter( mat,VisualServer::FIXED_MATERIAL_PARAM_SPECULAR,Color(0,0,0) ); - fixed_material_set_parameter( mat,VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE,Color(0.1,0.1,0.2) ); - fixed_material_set_parameter( mat,VisualServer::FIXED_MATERIAL_PARAM_EMISSION,Color(0,0,0) ); - fixed_material_set_flag( mat, VS::FIXED_MATERIAL_FLAG_USE_ALPHA, true); - material_set_flag( mat, VisualServer::MATERIAL_FLAG_UNSHADED, true ); - material_set_blend_mode( mat,VisualServer::MATERIAL_BLEND_MODE_ADD ); - - - return mat; -} - -#endif diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index a75ce1cf35..9e4acac25d 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -101,10 +101,7 @@ public: Vector<float> blend_values; - //BakedLightData *baked_light; VS::ShadowCastingSetting cast_shadows; - //Transform *baked_light_octree_xform; - //int baked_lightmap_id; bool mirror : 8; bool receive_shadows : 8; @@ -114,8 +111,6 @@ public: float depth; //used for sorting SelfList<InstanceBase> dependency_item; - //InstanceBase *baked_light; //baked light to use - //SelfList<InstanceBase> baked_light_item; virtual void base_removed() = 0; virtual void base_changed() = 0; @@ -1029,1026 +1024,4 @@ public: virtual ~Rasterizer() {} }; -#if 0 -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ -#include "camera_matrix.h" -#include "map.h" -#include "self_list.h" -#include "servers/visual_server.h" - -class Rasterizer { -protected: - - - typedef void (*ItemDrawViewportFunc)(VisualServer*owner,void*ud,const Rect2& p_rect); - - RID create_default_material(); - RID create_overdraw_debug_material(); - - - /* Fixed Material Shader API */ - - union SpatialMaterialShaderKey { - - struct { - uint16_t texcoord_mask; - uint8_t texture_mask; - uint8_t light_shader:2; - bool use_alpha:1; - bool use_color_array:1; - bool use_pointsize:1; - bool discard_alpha:1; - bool use_xy_normalmap:1; - bool valid:1; - }; - - uint32_t key; - - _FORCE_INLINE_ bool operator<(const SpatialMaterialShaderKey& p_key) const { return key<p_key.key; } - }; - - struct SpatialMaterialShader { - - int refcount; - RID shader; - }; - - Map<SpatialMaterialShaderKey,SpatialMaterialShader> fixed_material_shaders; - - RID _create_shader(const SpatialMaterialShaderKey& p_key); - void _free_shader(const SpatialMaterialShaderKey& p_key); - - struct SpatialMaterial { - - - RID self; - bool use_alpha; - bool use_color_array; - bool discard_alpha; - bool use_pointsize; - bool use_xy_normalmap; - float point_size; - Transform uv_xform; - VS::SpatialMaterialLightShader light_shader; - RID texture[VS::FIXED_MATERIAL_PARAM_MAX]; - Variant param[VS::FIXED_MATERIAL_PARAM_MAX]; - VS::SpatialMaterialTexCoordMode texture_tc[VS::FIXED_MATERIAL_PARAM_MAX]; - - SelfList<SpatialMaterial> dirty_list; - - SpatialMaterialShaderKey current_key; - - _FORCE_INLINE_ SpatialMaterialShaderKey get_key() const { - - - SpatialMaterialShaderKey k; - k.key=0; - k.use_alpha=use_alpha; - k.use_color_array=use_color_array; - k.use_pointsize=use_pointsize; - k.use_xy_normalmap=use_xy_normalmap; - k.discard_alpha=discard_alpha; - k.light_shader=light_shader; - k.valid=true; - for(int i=0;i<VS::FIXED_MATERIAL_PARAM_MAX;i++) { - if (texture[i].is_valid()) { - //print_line("valid: "+itos(i)); - k.texture_mask|=(1<<i); - k.texcoord_mask|=(texture_tc[i])<<(i*2); - } - } - - return k; - } - - - SpatialMaterial() : dirty_list(this) { - - use_alpha=false; - use_color_array=false; - use_pointsize=false; - discard_alpha=false; - use_xy_normalmap=false; - point_size=1.0; - light_shader=VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT; - for(int i=0;i<VS::FIXED_MATERIAL_PARAM_MAX;i++) { - texture_tc[i]=VS::FIXED_MATERIAL_TEXCOORD_UV; - } - param[VS::FIXED_MATERIAL_PARAM_DIFFUSE]=Color(1,1,1); - param[VS::FIXED_MATERIAL_PARAM_DETAIL]=1.0; - param[VS::FIXED_MATERIAL_PARAM_EMISSION]=Color(0,0,0); - param[VS::FIXED_MATERIAL_PARAM_GLOW]=0; - param[VS::FIXED_MATERIAL_PARAM_SHADE_PARAM]=0; - param[VS::FIXED_MATERIAL_PARAM_SPECULAR]=Color(0.0,0.0,0.0); - param[VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP]=40; - param[VS::FIXED_MATERIAL_PARAM_NORMAL]=1; - - current_key.key=0; - - - } - }; - - StringName _fixed_material_param_names[VS::FIXED_MATERIAL_PARAM_MAX]; - StringName _fixed_material_tex_names[VS::FIXED_MATERIAL_PARAM_MAX]; - StringName _fixed_material_uv_xform_name; - StringName _fixed_material_point_size_name; - - Map<RID,SpatialMaterial*> fixed_materials; - - SelfList<SpatialMaterial>::List fixed_material_dirty_list; - -protected: - void _update_fixed_materials(); - void _free_fixed_material(const RID& p_material); - -public: - - enum ShadowFilterTechnique { - SHADOW_FILTER_NONE, - SHADOW_FILTER_PCF5, - SHADOW_FILTER_PCF13, - SHADOW_FILTER_ESM, - SHADOW_FILTER_VSM, - }; - - - - /* TEXTURE API */ - - virtual RID texture_create()=0; - RID texture_create_from_image(const Image& p_image,uint32_t p_flags=VS::TEXTURE_FLAGS_DEFAULT); // helper - virtual void texture_allocate(RID p_texture,int p_width, int p_height,Image::Format p_format,uint32_t p_flags=VS::TEXTURE_FLAGS_DEFAULT)=0; - virtual void texture_set_data(RID p_texture,const Image& p_image,VS::CubeMapSide p_cube_side=VS::CUBEMAP_LEFT)=0; - virtual Image texture_get_data(RID p_texture,VS::CubeMapSide p_cube_side=VS::CUBEMAP_LEFT) const=0; - virtual void texture_set_flags(RID p_texture,uint32_t p_flags)=0; - virtual uint32_t texture_get_flags(RID p_texture) const=0; - virtual Image::Format texture_get_format(RID p_texture) const=0; - virtual uint32_t texture_get_width(RID p_texture) const=0; - virtual uint32_t texture_get_height(RID p_texture) const=0; - virtual bool texture_has_alpha(RID p_texture) const=0; - virtual void texture_set_size_override(RID p_texture,int p_width, int p_height)=0; - - virtual void texture_set_reload_hook(RID p_texture,ObjectID p_owner,const StringName& p_function) const=0; - - virtual void texture_set_path(RID p_texture,const String& p_path)=0; - virtual String texture_get_path(RID p_texture) const=0; - virtual void texture_debug_usage(List<VS::TextureInfo> *r_info)=0; - - virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable)=0; - - /* SHADER API */ - - virtual RID shader_create(VS::ShaderMode p_mode=VS::SHADER_MATERIAL)=0; - - virtual void shader_set_mode(RID p_shader,VS::ShaderMode p_mode)=0; - virtual VS::ShaderMode shader_get_mode(RID p_shader) const=0; - - virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs=0,int p_fragment_ofs=0,int p_light_ofs=0)=0; - virtual String shader_get_fragment_code(RID p_shader) const=0; - virtual String shader_get_vertex_code(RID p_shader) const=0; - virtual String shader_get_light_code(RID p_shader) const=0; - - virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const=0; - - virtual void shader_set_default_texture_param(RID p_shader, const StringName& p_name, RID p_texture)=0; - virtual RID shader_get_default_texture_param(RID p_shader, const StringName& p_name) const=0; - - virtual Variant shader_get_default_param(RID p_shader, const StringName& p_name)=0; - - /* COMMON MATERIAL API */ - - virtual RID material_create()=0; - - virtual void material_set_shader(RID p_shader_material, RID p_shader)=0; - virtual RID material_get_shader(RID p_shader_material) const=0; - - virtual void material_set_param(RID p_material, const StringName& p_param, const Variant& p_value)=0; - virtual Variant material_get_param(RID p_material, const StringName& p_param) const=0; - - virtual void material_set_flag(RID p_material, VS::MaterialFlag p_flag,bool p_enabled)=0; - virtual bool material_get_flag(RID p_material,VS::MaterialFlag p_flag) const=0; - - virtual void material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode)=0; - virtual VS::MaterialDepthDrawMode material_get_depth_draw_mode(RID p_material) const=0; - - virtual void material_set_blend_mode(RID p_material,VS::MaterialBlendMode p_mode)=0; - virtual VS::MaterialBlendMode material_get_blend_mode(RID p_material) const=0; - - virtual void material_set_line_width(RID p_material,float p_line_width)=0; - virtual float material_get_line_width(RID p_material) const=0; - - - /* FIXED MATERIAL */ - - virtual RID fixed_material_create(); - - virtual void fixed_material_set_flag(RID p_material, VS::SpatialMaterialFlags p_flag, bool p_enabled); - virtual bool fixed_material_get_flag(RID p_material, VS::SpatialMaterialFlags p_flag) const; - - virtual void fixed_material_set_parameter(RID p_material, VS::SpatialMaterialParam p_parameter, const Variant& p_value); - virtual Variant fixed_material_get_parameter(RID p_material,VS::SpatialMaterialParam p_parameter) const; - - virtual void fixed_material_set_texture(RID p_material,VS::SpatialMaterialParam p_parameter, RID p_texture); - virtual RID fixed_material_get_texture(RID p_material,VS::SpatialMaterialParam p_parameter) const; - - virtual void fixed_material_set_texcoord_mode(RID p_material,VS::SpatialMaterialParam p_parameter, VS::SpatialMaterialTexCoordMode p_mode); - virtual VS::SpatialMaterialTexCoordMode fixed_material_get_texcoord_mode(RID p_material,VS::SpatialMaterialParam p_parameter) const; - - virtual void fixed_material_set_uv_transform(RID p_material,const Transform& p_transform); - virtual Transform fixed_material_get_uv_transform(RID p_material) const; - - virtual void fixed_material_set_light_shader(RID p_material,VS::SpatialMaterialLightShader p_shader); - virtual VS::SpatialMaterialLightShader fixed_material_get_light_shader(RID p_material) const; - - virtual void fixed_material_set_point_size(RID p_material,float p_size); - virtual float fixed_material_get_point_size(RID p_material) const; - - /* MESH API */ - - virtual RID mesh_create()=0; - - - virtual void mesh_add_surface(RID p_mesh,VS::PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes=Array(),bool p_alpha_sort=false)=0; - virtual Array mesh_get_surface_arrays(RID p_mesh,int p_surface) const=0; - virtual Array mesh_get_surface_morph_arrays(RID p_mesh,int p_surface) const=0; - - virtual void mesh_add_custom_surface(RID p_mesh,const Variant& p_dat)=0; - - virtual void mesh_set_morph_target_count(RID p_mesh,int p_amount)=0; - virtual int mesh_get_morph_target_count(RID p_mesh) const=0; - - virtual void mesh_set_morph_target_mode(RID p_mesh,VS::MorphTargetMode p_mode)=0; - virtual VS::MorphTargetMode mesh_get_morph_target_mode(RID p_mesh) const=0; - - virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material,bool p_owned=false)=0; - virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const=0; - - virtual int mesh_surface_get_array_len(RID p_mesh, int p_surface) const=0; - virtual int mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const=0; - virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const=0; - virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const=0; - - virtual void mesh_remove_surface(RID p_mesh,int p_index)=0; - virtual int mesh_get_surface_count(RID p_mesh) const=0; - - virtual AABB mesh_get_aabb(RID p_mesh,RID p_skeleton=RID()) const=0; - - virtual void mesh_set_custom_aabb(RID p_mesh,const AABB& p_aabb)=0; - virtual AABB mesh_get_custom_aabb(RID p_mesh) const=0; - - /* MULTIMESH API */ - - virtual RID multimesh_create()=0; - - virtual void multimesh_set_instance_count(RID p_multimesh,int p_count)=0; - virtual int multimesh_get_instance_count(RID p_multimesh) const=0; - - virtual void multimesh_set_mesh(RID p_multimesh,RID p_mesh)=0; - virtual void multimesh_set_aabb(RID p_multimesh,const AABB& p_aabb)=0; - virtual void multimesh_instance_set_transform(RID p_multimesh,int p_index,const Transform& p_transform)=0; - virtual void multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color)=0; - - virtual RID multimesh_get_mesh(RID p_multimesh) const=0; - virtual AABB multimesh_get_aabb(RID p_multimesh) const=0; - - virtual Transform multimesh_instance_get_transform(RID p_multimesh,int p_index) const=0; - virtual Color multimesh_instance_get_color(RID p_multimesh,int p_index) const=0; - - virtual void multimesh_set_visible_instances(RID p_multimesh,int p_visible)=0; - virtual int multimesh_get_visible_instances(RID p_multimesh) const=0; - - /* BAKED LIGHT */ - - - - - /* IMMEDIATE API */ - - virtual RID immediate_create()=0; - virtual void immediate_begin(RID p_immediate,VS::PrimitiveType p_rimitive,RID p_texture=RID())=0; - virtual void immediate_vertex(RID p_immediate,const Vector3& p_vertex)=0; - virtual void immediate_normal(RID p_immediate,const Vector3& p_normal)=0; - virtual void immediate_tangent(RID p_immediate,const Plane& p_tangent)=0; - virtual void immediate_color(RID p_immediate,const Color& p_color)=0; - virtual void immediate_uv(RID p_immediate,const Vector2& tex_uv)=0; - virtual void immediate_uv2(RID p_immediate,const Vector2& tex_uv)=0; - virtual void immediate_end(RID p_immediate)=0; - virtual void immediate_clear(RID p_immediate)=0; - virtual AABB immediate_get_aabb(RID p_immediate) const=0; - virtual void immediate_set_material(RID p_immediate,RID p_material)=0; - virtual RID immediate_get_material(RID p_immediate) const=0; - - - /* PARTICLES API */ - - virtual RID particles_create()=0; - - virtual void particles_set_amount(RID p_particles, int p_amount)=0; - virtual int particles_get_amount(RID p_particles) const=0; - - virtual void particles_set_emitting(RID p_particles, bool p_emitting)=0; - virtual bool particles_is_emitting(RID p_particles) const=0; - - virtual void particles_set_visibility_aabb(RID p_particles, const AABB& p_visibility)=0; - virtual AABB particles_get_visibility_aabb(RID p_particles) const=0; - - virtual void particles_set_emission_half_extents(RID p_particles, const Vector3& p_half_extents)=0; - virtual Vector3 particles_get_emission_half_extents(RID p_particles) const=0; - - virtual void particles_set_emission_base_velocity(RID p_particles, const Vector3& p_base_velocity)=0; - virtual Vector3 particles_get_emission_base_velocity(RID p_particles) const=0; - - virtual void particles_set_emission_points(RID p_particles, const PoolVector<Vector3>& p_points)=0; - virtual PoolVector<Vector3> particles_get_emission_points(RID p_particles) const=0; - - virtual void particles_set_gravity_normal(RID p_particles, const Vector3& p_normal)=0; - virtual Vector3 particles_get_gravity_normal(RID p_particles) const=0; - - virtual void particles_set_variable(RID p_particles, VS::ParticleVariable p_variable,float p_value)=0; - virtual float particles_get_variable(RID p_particles, VS::ParticleVariable p_variable) const=0; - - virtual void particles_set_randomness(RID p_particles, VS::ParticleVariable p_variable,float p_randomness)=0; - virtual float particles_get_randomness(RID p_particles, VS::ParticleVariable p_variable) const=0; - - virtual void particles_set_color_phase_pos(RID p_particles, int p_phase, float p_pos)=0; - virtual float particles_get_color_phase_pos(RID p_particles, int p_phase) const=0; - - virtual void particles_set_color_phases(RID p_particles, int p_phases)=0; - virtual int particles_get_color_phases(RID p_particles) const=0; - - virtual void particles_set_color_phase_color(RID p_particles, int p_phase, const Color& p_color)=0; - virtual Color particles_get_color_phase_color(RID p_particles, int p_phase) const=0; - - virtual void particles_set_attractors(RID p_particles, int p_attractors)=0; - virtual int particles_get_attractors(RID p_particles) const=0; - - virtual void particles_set_attractor_pos(RID p_particles, int p_attractor, const Vector3& p_pos)=0; - virtual Vector3 particles_get_attractor_pos(RID p_particles,int p_attractor) const=0; - - virtual void particles_set_attractor_strength(RID p_particles, int p_attractor, float p_force)=0; - virtual float particles_get_attractor_strength(RID p_particles,int p_attractor) const=0; - - virtual void particles_set_material(RID p_particles, RID p_material,bool p_owned=false)=0; - virtual RID particles_get_material(RID p_particles) const=0; - - virtual AABB particles_get_aabb(RID p_particles) const=0; - - virtual void particles_set_height_from_velocity(RID p_particles, bool p_enable)=0; - virtual bool particles_has_height_from_velocity(RID p_particles) const=0; - - virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable)=0; - virtual bool particles_is_using_local_coordinates(RID p_particles) const=0; - - /* SKELETON API */ - - virtual RID skeleton_create()=0; - virtual void skeleton_resize(RID p_skeleton,int p_bones)=0; - virtual int skeleton_get_bone_count(RID p_skeleton) const=0; - virtual void skeleton_bone_set_transform(RID p_skeleton,int p_bone, const Transform& p_transform)=0; - virtual Transform skeleton_bone_get_transform(RID p_skeleton,int p_bone)=0; - - - /* LIGHT API */ - - virtual RID light_create(VS::LightType p_type)=0; - virtual VS::LightType light_get_type(RID p_light) const=0; - - virtual void light_set_color(RID p_light,VS::LightColor p_type, const Color& p_color)=0; - virtual Color light_get_color(RID p_light,VS::LightColor p_type) const=0; - - virtual void light_set_shadow(RID p_light,bool p_enabled)=0; - virtual bool light_has_shadow(RID p_light) const=0; - - virtual void light_set_volumetric(RID p_light,bool p_enabled)=0; - virtual bool light_is_volumetric(RID p_light) const=0; - - virtual void light_set_projector(RID p_light,RID p_texture)=0; - virtual RID light_get_projector(RID p_light) const=0; - - virtual void light_set_var(RID p_light, VS::LightParam p_var, float p_value)=0; - virtual float light_get_var(RID p_light, VS::LightParam p_var) const=0; - - virtual void light_set_operator(RID p_light,VS::LightOp p_op)=0; - virtual VS::LightOp light_get_operator(RID p_light) const=0; - - virtual void light_omni_set_shadow_mode(RID p_light,VS::LightOmniShadowMode p_mode)=0; - virtual VS::LightOmniShadowMode light_omni_get_shadow_mode(RID p_light) const=0; - - virtual void light_directional_set_shadow_mode(RID p_light,VS::LightDirectionalShadowMode p_mode)=0; - virtual VS::LightDirectionalShadowMode light_directional_get_shadow_mode(RID p_light) const=0; - virtual void light_directional_set_shadow_param(RID p_light,VS::LightDirectionalShadowParam p_param, float p_value)=0; - virtual float light_directional_get_shadow_param(RID p_light,VS::LightDirectionalShadowParam p_param) const=0; - - virtual AABB light_get_aabb(RID p_poly) const=0; - - virtual RID light_instance_create(RID p_light)=0; - virtual void light_instance_set_transform(RID p_light_instance,const Transform& p_transform)=0; - - - enum ShadowType { - SHADOW_NONE, - SHADOW_SIMPLE, - SHADOW_ORTHOGONAL, - SHADOW_DUAL_PARABOLOID, - SHADOW_CUBE, - SHADOW_PSSM, //parallel split shadow map - SHADOW_PSM //perspective shadow map - }; - - enum ShadowPass { - PASS_DUAL_PARABOLOID_FRONT=0, - PASS_DUAL_PARABOLOID_BACK=1, - PASS_CUBE_FRONT=0, - PASS_CUBE_BACK=1, - PASS_CUBE_TOP=2, - PASS_CUBE_BOTTOM=3, - PASS_CUBE_LEFT=4, - PASS_CUBE_RIGHT=5, - }; - - virtual ShadowType light_instance_get_shadow_type(RID p_light_instance,bool p_far=false) const=0; - virtual int light_instance_get_shadow_passes(RID p_light_instance) const=0; - virtual void light_instance_set_shadow_transform(RID p_light_instance, int p_index, const CameraMatrix& p_camera, const Transform& p_transform, float p_split_near=0,float p_split_far=0)=0; - virtual int light_instance_get_shadow_size(RID p_light_instance, int p_index=0) const=0; - virtual bool light_instance_get_pssm_shadow_overlap(RID p_light_instance) const=0; - - /* SHADOWS */ - - virtual void shadow_clear_near()=0; - virtual bool shadow_allocate_near(RID p_light)=0; //true on successful alloc - virtual bool shadow_allocate_far(RID p_light)=0; //true on successful alloc - - /* PARTICLES INSTANCE */ - - virtual RID particles_instance_create(RID p_particles)=0; - virtual void particles_instance_set_transform(RID p_particles_instance,const Transform& p_transform)=0; - - /* RENDER API */ - /* all calls (inside begin/end shadow) are always warranted to be in the following order: */ - - /* VIEWPORT API */ - - virtual RID viewport_data_create()=0; - - virtual RID render_target_create()=0; - virtual void render_target_set_size(RID p_render_target, int p_width, int p_height)=0; - virtual RID render_target_get_texture(RID p_render_target) const=0; - virtual bool render_target_renedered_in_frame(RID p_render_target)=0; - - virtual void begin_frame()=0; - - virtual void set_viewport(const VS::ViewportRect& p_viewport)=0; - virtual void set_render_target(RID p_render_target,bool p_transparent_bg=false,bool p_vflip=false)=0; - virtual void clear_viewport(const Color& p_color)=0; - virtual void capture_viewport(Image* r_capture)=0; - - virtual void begin_scene(RID p_viewport_data,RID p_env,VS::ScenarioDebugMode p_debug)=0; - virtual void begin_shadow_map( RID p_light_instance, int p_shadow_pass )=0; - - virtual void set_camera(const Transform& p_world,const CameraMatrix& p_projection,bool p_ortho_hint)=0; - - virtual void add_light( RID p_light_instance )=0; ///< all "add_light" calls happen before add_geometry calls - - typedef Map<StringName,Variant> ParamOverrideMap; - - struct BakedLightData { - - VS::BakedLightMode mode; - RID octree_texture; - RID light_texture; - float color_multiplier; //used for both lightmaps and octree - Transform octree_transform; - Map<int,RID> lightmaps; - //cache - - float octree_lattice_size; - float octree_lattice_divide; - float texture_multiplier; - float lightmap_multiplier; - int octree_steps; - Vector2 octree_tex_pixel_size; - Vector2 light_tex_pixel_size; - - bool realtime_color_enabled; - Color realtime_color; - float realtime_energy; - }; - - struct InstanceData { - - Transform transform; - RID skeleton; - RID material_override; - RID sampled_light; - Vector<RID> materials; - Vector<RID> light_instances; - Vector<float> morph_values; - BakedLightData *baked_light; - VS::ShadowCastingSetting cast_shadows; - Transform *baked_light_octree_xform; - int baked_lightmap_id; - bool mirror :8; - bool depth_scale :8; - bool billboard :8; - bool billboard_y :8; - bool receive_shadows : 8; - - }; - - virtual void add_mesh( const RID& p_mesh, const InstanceData *p_data)=0; - virtual void add_multimesh( const RID& p_multimesh, const InstanceData *p_data)=0; - virtual void add_immediate( const RID& p_immediate, const InstanceData *p_data)=0; - virtual void add_particles( const RID& p_particle_instance, const InstanceData *p_data)=0; - - - virtual void end_scene()=0; - virtual void end_shadow_map()=0; - - virtual void end_frame()=0; - virtual void flush_frame(); //not necessary in most cases - - /* CANVAS API */ - - enum CanvasRectFlags { - - CANVAS_RECT_REGION=1, - CANVAS_RECT_TILE=2, - CANVAS_RECT_FLIP_H=4, - CANVAS_RECT_FLIP_V=8, - CANVAS_RECT_TRANSPOSE=16 - }; - - - struct Light { - - - - bool enabled; - Color color; - Matrix32 xform; - float height; - float energy; - float scale; - int z_min; - int z_max; - int layer_min; - int layer_max; - int item_mask; - int item_shadow_mask; - VS::LightMode mode; - RID texture; - Vector2 texture_offset; - RID canvas; - RID shadow_buffer; - int shadow_buffer_size; - float shadow_esm_mult; - Color shadow_color; - - - void *texture_cache; // implementation dependent - Rect2 rect_cache; - Matrix32 xform_cache; - float radius_cache; //used for shadow far plane - CameraMatrix shadow_matrix_cache; - - Matrix32 light_shader_xform; - Vector2 light_shader_pos; - - Light *shadows_next_ptr; - Light *filter_next_ptr; - Light *next_ptr; - Light *mask_next_ptr; - - Light() { - enabled=true; - color=Color(1,1,1); - shadow_color=Color(0,0,0,0); - height=0; - z_min=-1024; - z_max=1024; - layer_min=0; - layer_max=0; - item_mask=1; - scale=1.0; - energy=1.0; - item_shadow_mask=-1; - mode=VS::CANVAS_LIGHT_MODE_ADD; - texture_cache=NULL; - next_ptr=NULL; - mask_next_ptr=NULL; - filter_next_ptr=NULL; - shadow_buffer_size=2048; - shadow_esm_mult=80; - - } - }; - - struct Item; - - struct ItemMaterial { - - RID shader; - Map<StringName,Variant> shader_param; - uint32_t shader_version; - Set<Item*> owners; - VS::ItemShadingMode shading_mode; - - ItemMaterial() {shading_mode=VS::CANVAS_ITEM_SHADING_NORMAL; shader_version=0; } - }; - - struct Item { - - struct Command { - - enum Type { - - TYPE_LINE, - TYPE_RECT, - TYPE_STYLE, - TYPE_PRIMITIVE, - TYPE_POLYGON, - TYPE_POLYGON_PTR, - TYPE_CIRCLE, - TYPE_TRANSFORM, - TYPE_BLEND_MODE, - TYPE_CLIP_IGNORE, - }; - - Type type; - virtual ~Command(){} - }; - - struct CommandLine : public Command { - - Point2 from,to; - Color color; - float width; - bool antialiased; - CommandLine() { type = TYPE_LINE; } - }; - - struct CommandRect : public Command { - - Rect2 rect; - RID texture; - Color modulate; - Rect2 source; - uint8_t flags; - - CommandRect() { flags=0; type = TYPE_RECT; } - }; - - struct CommandStyle : public Command { - - Rect2 rect; - Rect2 source; - RID texture; - float margin[4]; - bool draw_center; - Color color; - CommandStyle() { draw_center=true; type = TYPE_STYLE; } - }; - - struct CommandPrimitive : public Command { - - Vector<Point2> points; - Vector<Point2> uvs; - Vector<Color> colors; - RID texture; - float width; - - CommandPrimitive() { type = TYPE_PRIMITIVE; width=1;} - }; - - struct CommandPolygon : public Command { - - Vector<int> indices; - Vector<Point2> points; - Vector<Point2> uvs; - Vector<Color> colors; - RID texture; - int count; - - CommandPolygon() { type = TYPE_POLYGON; count = 0; } - }; - - struct CommandPolygonPtr : public Command { - - const int* indices; - const Point2* points; - const Point2* uvs; - const Color* colors; - RID texture; - int count; - - CommandPolygonPtr() { type = TYPE_POLYGON_PTR; count = 0; } - }; - - struct CommandCircle : public Command { - - Point2 pos; - float radius; - Color color; - CommandCircle() { type = TYPE_CIRCLE; } - }; - - struct CommandTransform : public Command { - - Matrix32 xform; - CommandTransform() { type = TYPE_TRANSFORM; } - }; - - struct CommandBlendMode : public Command { - - VS::MaterialBlendMode blend_mode; - CommandBlendMode() { type = TYPE_BLEND_MODE; blend_mode = VS::MATERIAL_BLEND_MODE_MIX; } - }; - struct CommandClipIgnore : public Command { - - bool ignore; - CommandClipIgnore() { type = TYPE_CLIP_IGNORE; ignore=false; } - }; - - - struct ViewportRender { - VisualServer*owner; - void* udata; - Rect2 rect; - }; - - Matrix32 xform; - bool clip; - bool visible; - bool ontop; - VS::MaterialBlendMode blend_mode; - int light_mask; - Vector<Command*> commands; - mutable bool custom_rect; - mutable bool rect_dirty; - mutable Rect2 rect; - Item*next; - ItemMaterial* material; - struct CopyBackBuffer { - Rect2 rect; - Rect2 screen_rect; - bool full; - }; - CopyBackBuffer *copy_back_buffer; - - - float final_opacity; - Matrix32 final_transform; - Rect2 final_clip_rect; - Item* final_clip_owner; - Item* material_owner; - ViewportRender *vp_render; - bool distance_field; - bool light_masked; - - Rect2 global_rect_cache; - - const Rect2& get_rect() const { - if (custom_rect || !rect_dirty) - return rect; - - //must update rect - int s=commands.size(); - if (s==0) { - - rect=Rect2(); - rect_dirty=false; - return rect; - } - - Matrix32 xf; - bool found_xform=false; - bool first=true; - - const Item::Command * const *cmd = &commands[0]; - - - for (int i=0;i<s;i++) { - - const Item::Command *c=cmd[i]; - Rect2 r; - - switch(c->type) { - case Item::Command::TYPE_LINE: { - - const Item::CommandLine* line = static_cast< const Item::CommandLine*>(c); - r.pos=line->from; - r.expand_to(line->to); - } break; - case Item::Command::TYPE_RECT: { - - const Item::CommandRect* crect = static_cast< const Item::CommandRect*>(c); - r=crect->rect; - - } break; - case Item::Command::TYPE_STYLE: { - - const Item::CommandStyle* style = static_cast< const Item::CommandStyle*>(c); - r=style->rect; - } break; - case Item::Command::TYPE_PRIMITIVE: { - - const Item::CommandPrimitive* primitive = static_cast< const Item::CommandPrimitive*>(c); - r.pos=primitive->points[0]; - for(int i=1;i<primitive->points.size();i++) { - - r.expand_to(primitive->points[i]); - - } - } break; - case Item::Command::TYPE_POLYGON: { - - const Item::CommandPolygon* polygon = static_cast< const Item::CommandPolygon*>(c); - int l = polygon->points.size(); - const Point2*pp=&polygon->points[0]; - r.pos=pp[0]; - for(int i=1;i<l;i++) { - - r.expand_to(pp[i]); - - } - } break; - - case Item::Command::TYPE_POLYGON_PTR: { - - const Item::CommandPolygonPtr* polygon = static_cast< const Item::CommandPolygonPtr*>(c); - int l = polygon->count; - if (polygon->indices != NULL) { - - r.pos=polygon->points[polygon->indices[0]]; - for (int i=1; i<l; i++) { - - r.expand_to(polygon->points[polygon->indices[i]]); - } - } else { - r.pos=polygon->points[0]; - for (int i=1; i<l; i++) { - - r.expand_to(polygon->points[i]); - } - } - } break; - case Item::Command::TYPE_CIRCLE: { - - const Item::CommandCircle* circle = static_cast< const Item::CommandCircle*>(c); - r.pos=Point2(-circle->radius,-circle->radius)+circle->pos; - r.size=Point2(circle->radius*2.0,circle->radius*2.0); - } break; - case Item::Command::TYPE_TRANSFORM: { - - const Item::CommandTransform* transform = static_cast<const Item::CommandTransform*>(c); - xf=transform->xform; - found_xform=true; - continue; - } break; - case Item::Command::TYPE_BLEND_MODE: { - - } break; - case Item::Command::TYPE_CLIP_IGNORE: { - - } break; - } - - if (found_xform) { - r = xf.xform(r); - found_xform=false; - } - - - if (first) { - rect=r; - first=false; - } else - rect=rect.merge(r); - } - - rect_dirty=false; - return rect; - } - - void clear() { for (int i=0;i<commands.size();i++) memdelete( commands[i] ); commands.clear(); clip=false; rect_dirty=true; final_clip_owner=NULL; material_owner=NULL; light_masked=false; } - Item() { light_mask=1; vp_render=NULL; next=NULL; final_clip_owner=NULL; clip=false; final_opacity=1; blend_mode=VS::MATERIAL_BLEND_MODE_MIX; visible=true; rect_dirty=true; custom_rect=false; ontop=true; material_owner=NULL; material=NULL; copy_back_buffer=NULL; distance_field=false; light_masked=false; } - virtual ~Item() { clear(); if (copy_back_buffer) memdelete(copy_back_buffer); } - }; - - - ItemDrawViewportFunc draw_viewport_func; - - - virtual void begin_canvas_bg()=0; - virtual void canvas_begin()=0; - virtual void canvas_disable_blending()=0; - virtual void canvas_set_opacity(float p_opacity)=0; - virtual void canvas_set_blend_mode(VS::MaterialBlendMode p_mode)=0; - virtual void canvas_begin_rect(const Matrix32& p_transform)=0; - virtual void canvas_set_clip(bool p_clip, const Rect2& p_rect)=0; - virtual void canvas_end_rect()=0; - virtual void canvas_draw_line(const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width,bool p_antialiased)=0; - virtual void canvas_draw_rect(const Rect2& p_rect, int p_flags, const Rect2& p_source,RID p_texture,const Color& p_modulate)=0; - virtual void canvas_draw_style_box(const Rect2& p_rect, const Rect2& p_src_region, RID p_texture,const float *p_margins, bool p_draw_center=true,const Color& p_modulate=Color(1,1,1))=0; - virtual void canvas_draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width)=0; - virtual void canvas_draw_polygon(int p_vertex_count, const int* p_indices, const Vector2* p_vertices, const Vector2* p_uvs, const Color* p_colors,const RID& p_texture,bool p_singlecolor)=0; - virtual void canvas_set_transform(const Matrix32& p_transform)=0; - - virtual void canvas_render_items(Item *p_item_list,int p_z,const Color& p_modulate,Light *p_light)=0; - virtual void canvas_debug_viewport_shadows(Light* p_lights_with_shadow)=0; - /* LIGHT SHADOW MAPPING */ - - virtual RID canvas_light_occluder_create()=0; - virtual void canvas_light_occluder_set_polylines(RID p_occluder, const PoolVector<Vector2>& p_lines)=0; - - - virtual RID canvas_light_shadow_buffer_create(int p_width)=0; - - struct LightOccluderInstance { - - - bool enabled; - RID canvas; - RID polygon; - RID polygon_buffer; - Rect2 aabb_cache; - Matrix32 xform; - Matrix32 xform_cache; - int light_mask; - VS::CanvasOccluderPolygonCullMode cull_cache; - - LightOccluderInstance *next; - - LightOccluderInstance() { enabled=true; next=NULL; light_mask=1; cull_cache=VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED; } - }; - - - - virtual void canvas_light_shadow_buffer_update(RID p_buffer, const Matrix32& p_light_xform, int p_light_mask,float p_near, float p_far, LightOccluderInstance* p_occluders, CameraMatrix *p_xform_cache)=0; - - /* ENVIRONMENT */ - - - virtual RID environment_create()=0; - - virtual void environment_set_background(RID p_env,VS::EnvironmentBG p_bg)=0; - virtual VS::EnvironmentBG environment_get_background(RID p_env) const=0; - - virtual void environment_set_background_param(RID p_env,VS::EnvironmentBGParam p_param, const Variant& p_value)=0; - virtual Variant environment_get_background_param(RID p_env,VS::EnvironmentBGParam p_param) const=0; - - virtual void environment_set_enable_fx(RID p_env,VS::EnvironmentFx p_effect,bool p_enabled)=0; - virtual bool environment_is_fx_enabled(RID p_env,VS::EnvironmentFx p_effect) const=0; - - virtual void environment_fx_set_param(RID p_env,VS::EnvironmentFxParam p_param,const Variant& p_value)=0; - virtual Variant environment_fx_get_param(RID p_env,VS::EnvironmentFxParam p_param) const=0; - - /* SAMPLED LIGHT */ - virtual RID sampled_light_dp_create(int p_width,int p_height)=0; - virtual void sampled_light_dp_update(RID p_sampled_light,const Color *p_data,float p_multiplier)=0; - - - /*MISC*/ - - virtual bool is_texture(const RID& p_rid) const=0; - virtual bool is_material(const RID& p_rid) const=0; - virtual bool is_mesh(const RID& p_rid) const=0; - virtual bool is_multimesh(const RID& p_rid) const=0; - virtual bool is_immediate(const RID& p_rid) const=0; - virtual bool is_particles(const RID &p_beam) const=0; - - virtual bool is_light(const RID& p_rid) const=0; - virtual bool is_light_instance(const RID& p_rid) const=0; - virtual bool is_particles_instance(const RID& p_rid) const=0; - virtual bool is_skeleton(const RID& p_rid) const=0; - virtual bool is_environment(const RID& p_rid) const=0; - virtual bool is_shader(const RID& p_rid) const=0; - - virtual bool is_canvas_light_occluder(const RID& p_rid) const=0; - - virtual void free(const RID& p_rid)=0; - - virtual void init()=0; - virtual void finish()=0; - - virtual bool needs_to_draw_next_frame() const=0; - - virtual void reload_vram() {} - - virtual bool has_feature(VS::Features p_feature) const=0; - - virtual void restore_framebuffer()=0; - - virtual int get_render_info(VS::RenderInfo p_info)=0; - - virtual void set_force_16_bits_fbo(bool p_force) {} - - Rasterizer(); - virtual ~Rasterizer() {} -}; - -#endif -#endif +#endif // RASTERIZER_H diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 7146814cbe..6e42143246 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h index c92cbf2abb..f4be6fff39 100644 --- a/servers/visual/shader_language.h +++ b/servers/visual/shader_language.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index 3f1403d532..340cbf5e7b 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/shader_types.h b/servers/visual/shader_types.h index b8cbabeec1..4f4c7c5352 100644 --- a/servers/visual/shader_types.h +++ b/servers/visual/shader_types.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index 931e084246..ad6d0f6b2b 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index b9ad88286d..09ac9959f9 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/visual_server_global.cpp b/servers/visual/visual_server_global.cpp index a0f118dd67..1c86fb0264 100644 --- a/servers/visual/visual_server_global.cpp +++ b/servers/visual/visual_server_global.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/visual_server_global.h b/servers/visual/visual_server_global.h index 079f03f1b1..c65abc75f8 100644 --- a/servers/visual/visual_server_global.h +++ b/servers/visual/visual_server_global.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/visual_server_light_baker.cpp b/servers/visual/visual_server_light_baker.cpp index 67048eb54e..88a0c8166f 100644 --- a/servers/visual/visual_server_light_baker.cpp +++ b/servers/visual/visual_server_light_baker.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/visual_server_light_baker.h b/servers/visual/visual_server_light_baker.h index 218c42bb1b..173dbd9e19 100644 --- a/servers/visual/visual_server_light_baker.h +++ b/servers/visual/visual_server_light_baker.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index e66c8a1e21..68ca586caf 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "visual_server_raster.h" + #include "default_mouse_cursor.xpm" #include "io/marshalls.h" #include "os/os.h" @@ -208,7743 +209,3 @@ VisualServerRaster::~VisualServerRaster() { memdelete(VSG::viewport); memdelete(VSG::rasterizer); } - -#if 0 - -BalloonAllocator<> *VisualServerRaster::OctreeAllocator::allocator=NULL; - -#define VS_CHANGED \ - changes++;\ - - //print_line(__FUNCTION__); - - - - -RID VisualServerRaster::texture_create() { - - return rasterizer->texture_create(); -} - - -void VisualServerRaster::texture_allocate(RID p_texture, int p_width, int p_height,Image::Format p_format,uint32_t p_flags) { - - rasterizer->texture_allocate(p_texture,p_width,p_height,p_format,p_flags); -} - -void VisualServerRaster::texture_set_flags(RID p_texture,uint32_t p_flags) { - - VS_CHANGED; - rasterizer->texture_set_flags(p_texture,p_flags); -} - - -void VisualServerRaster::texture_set_data(RID p_texture,const Image& p_image,CubeMapSide p_cube_side) { - - VS_CHANGED; - rasterizer->texture_set_data(p_texture,p_image,p_cube_side); - - -} - -Image VisualServerRaster::texture_get_data(RID p_texture,CubeMapSide p_cube_side) const { - - - return rasterizer->texture_get_data(p_texture,p_cube_side); -} - - -uint32_t VisualServerRaster::texture_get_flags(RID p_texture) const { - - return rasterizer->texture_get_flags(p_texture); - -} -Image::Format VisualServerRaster::texture_get_format(RID p_texture) const { - - return rasterizer->texture_get_format(p_texture); - -} -uint32_t VisualServerRaster::texture_get_width(RID p_texture) const { - - return rasterizer->texture_get_width(p_texture); -} - -uint32_t VisualServerRaster::texture_get_height(RID p_texture) const { - - return rasterizer->texture_get_height(p_texture); -} - -void VisualServerRaster::texture_set_size_override(RID p_texture,int p_width, int p_height) { - - rasterizer->texture_set_size_override(p_texture,p_width,p_height); -} - -bool VisualServerRaster::texture_can_stream(RID p_texture) const { - - return false; -} - -void VisualServerRaster::texture_set_reload_hook(RID p_texture,ObjectID p_owner,const StringName& p_function) const { - - rasterizer->texture_set_reload_hook(p_texture,p_owner,p_function); -} - -void VisualServerRaster::texture_set_path(RID p_texture,const String& p_path) { - - rasterizer->texture_set_path(p_texture,p_path); -} - -String VisualServerRaster::texture_get_path(RID p_texture) const{ - - return rasterizer->texture_get_path(p_texture); -} - -void VisualServerRaster::texture_debug_usage(List<TextureInfo> *r_info){ - - rasterizer->texture_debug_usage(r_info); -} - -void VisualServerRaster::texture_set_shrink_all_x2_on_set_data(bool p_enable) { - - rasterizer->texture_set_shrink_all_x2_on_set_data(p_enable); -} - -/* SHADER API */ - -RID VisualServerRaster::shader_create(ShaderMode p_mode) { - - return rasterizer->shader_create(p_mode); -} - -void VisualServerRaster::shader_set_mode(RID p_shader,ShaderMode p_mode){ - - VS_CHANGED; - rasterizer->shader_set_mode(p_shader,p_mode); -} -VisualServer::ShaderMode VisualServerRaster::shader_get_mode(RID p_shader) const{ - - return rasterizer->shader_get_mode(p_shader); -} - - -void VisualServerRaster::shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs,int p_fragment_ofs,int p_light_ofs) { - - VS_CHANGED; - rasterizer->shader_set_code(p_shader,p_vertex,p_fragment,p_light,p_vertex_ofs,p_fragment_ofs,p_light_ofs); -} - -String VisualServerRaster::shader_get_vertex_code(RID p_shader) const{ - - return rasterizer->shader_get_vertex_code(p_shader); -} - -String VisualServerRaster::shader_get_fragment_code(RID p_shader) const{ - - return rasterizer->shader_get_fragment_code(p_shader); -} - -String VisualServerRaster::shader_get_light_code(RID p_shader) const{ - - return rasterizer->shader_get_light_code(p_shader); -} - -void VisualServerRaster::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const { - - return rasterizer->shader_get_param_list(p_shader,p_param_list); -} - - -void VisualServerRaster::shader_set_default_texture_param(RID p_shader, const StringName& p_name, RID p_texture) { - - rasterizer->shader_set_default_texture_param(p_shader,p_name,p_texture); -} - -RID VisualServerRaster::shader_get_default_texture_param(RID p_shader, const StringName& p_name) const{ - - return rasterizer->shader_get_default_texture_param(p_shader,p_name); -} - - -/* Material */ - -RID VisualServerRaster::material_create() { - - return rasterizer->material_create(); -} - -void VisualServerRaster::material_set_shader(RID p_material, RID p_shader) { - - VS_CHANGED; - rasterizer->material_set_shader(p_material, p_shader ); -} - -RID VisualServerRaster::material_get_shader(RID p_material) const { - - return rasterizer->material_get_shader(p_material); -} - -void VisualServerRaster::material_set_param(RID p_material, const StringName& p_param, const Variant& p_value) { - - VS_CHANGED; - rasterizer->material_set_param(p_material, p_param,p_value ); -} - -Variant VisualServerRaster::material_get_param(RID p_material, const StringName& p_param) const { - - return rasterizer->material_get_param(p_material,p_param); -} - -void VisualServerRaster::material_set_flag(RID p_material, MaterialFlag p_flag,bool p_enabled) { - VS_CHANGED; - rasterizer->material_set_flag(p_material,p_flag,p_enabled); -} - -void VisualServerRaster::material_set_depth_draw_mode(RID p_material, MaterialDepthDrawMode p_mode) { - - VS_CHANGED; - rasterizer->material_set_depth_draw_mode(p_material,p_mode); - -} - -VS::MaterialDepthDrawMode VisualServerRaster::material_get_depth_draw_mode(RID p_material) const { - - return rasterizer->material_get_depth_draw_mode(p_material); -} - - -bool VisualServerRaster::material_get_flag(RID p_material,MaterialFlag p_flag) const { - - return rasterizer->material_get_flag(p_material,p_flag); -} - -void VisualServerRaster::material_set_blend_mode(RID p_material,MaterialBlendMode p_mode) { - VS_CHANGED; - rasterizer->material_set_blend_mode(p_material,p_mode); -} -VS::MaterialBlendMode VisualServerRaster::material_get_blend_mode(RID p_material) const { - - return rasterizer->material_get_blend_mode(p_material); -} - -void VisualServerRaster::material_set_line_width(RID p_material,float p_line_width) { - VS_CHANGED; - rasterizer->material_set_line_width(p_material,p_line_width); -} -float VisualServerRaster::material_get_line_width(RID p_material) const { - - return rasterizer->material_get_line_width(p_material); -} - -/* FIXED MATERIAL */ - -RID VisualServerRaster::fixed_material_create() { - - return rasterizer->fixed_material_create(); -} - -void VisualServerRaster::fixed_material_set_flag(RID p_material, SpatialMaterialFlags p_flag, bool p_enabled) { - - rasterizer->fixed_material_set_flag(p_material,p_flag,p_enabled); -} - -bool VisualServerRaster::fixed_material_get_flag(RID p_material, SpatialMaterialFlags p_flag) const { - - return rasterizer->fixed_material_get_flag(p_material,p_flag); -} - -void VisualServerRaster::fixed_material_set_param(RID p_material, SpatialMaterialParam p_parameter, const Variant& p_value) { - VS_CHANGED; - rasterizer->fixed_material_set_parameter(p_material,p_parameter,p_value); -} - -Variant VisualServerRaster::fixed_material_get_param(RID p_material,SpatialMaterialParam p_parameter) const { - - return rasterizer->fixed_material_get_parameter(p_material,p_parameter); -} - - -void VisualServerRaster::fixed_material_set_texture(RID p_material,SpatialMaterialParam p_parameter, RID p_texture) { - VS_CHANGED; - rasterizer->fixed_material_set_texture(p_material,p_parameter,p_texture); -} - -RID VisualServerRaster::fixed_material_get_texture(RID p_material,SpatialMaterialParam p_parameter) const { - - return rasterizer->fixed_material_get_texture(p_material,p_parameter); -} - - - - -void VisualServerRaster::fixed_material_set_texcoord_mode(RID p_material,SpatialMaterialParam p_parameter, SpatialMaterialTexCoordMode p_mode) { - VS_CHANGED; - rasterizer->fixed_material_set_texcoord_mode(p_material,p_parameter,p_mode); -} - -VS::SpatialMaterialTexCoordMode VisualServerRaster::fixed_material_get_texcoord_mode(RID p_material,SpatialMaterialParam p_parameter) const { - - return rasterizer->fixed_material_get_texcoord_mode(p_material,p_parameter); -} - -void VisualServerRaster::fixed_material_set_point_size(RID p_material,float p_size) { - VS_CHANGED - - rasterizer->fixed_material_set_point_size(p_material,p_size); -} - -float VisualServerRaster::fixed_material_get_point_size(RID p_material) const{ - - return rasterizer->fixed_material_get_point_size(p_material); -} - - -void VisualServerRaster::fixed_material_set_uv_transform(RID p_material,const Transform& p_transform) { - VS_CHANGED; - rasterizer->fixed_material_set_uv_transform(p_material,p_transform); -} - -Transform VisualServerRaster::fixed_material_get_uv_transform(RID p_material) const { - - return rasterizer->fixed_material_get_uv_transform(p_material); -} - -void VisualServerRaster::fixed_material_set_light_shader(RID p_material,SpatialMaterialLightShader p_shader) { - - VS_CHANGED; - rasterizer->fixed_material_set_light_shader(p_material,p_shader); - -} - -VisualServerRaster::SpatialMaterialLightShader VisualServerRaster::fixed_material_get_light_shader(RID p_material) const{ - - return rasterizer->fixed_material_get_light_shader(p_material); -} - - - -/* MESH API */ - -RID VisualServerRaster::mesh_create() { - - return rasterizer->mesh_create(); -} - -void VisualServerRaster::mesh_set_morph_target_count(RID p_mesh,int p_amount) { - - rasterizer->mesh_set_morph_target_count(p_mesh,p_amount); - int amount = rasterizer->mesh_get_morph_target_count(p_mesh); - - - Map< RID, Set<RID> >::Element * E = instance_dependency_map.find( p_mesh ); - - if (!E) - return; - - - Set<RID>::Element *I = E->get().front(); - - while(I) { - - Instance *ins = instance_owner.get( I->get() ); - ins->data.morph_values.resize(amount); - I = I->next(); - } -} - -int VisualServerRaster::mesh_get_morph_target_count(RID p_mesh) const { - - return rasterizer->mesh_get_morph_target_count(p_mesh); -} - -void VisualServerRaster::mesh_set_morph_target_mode(RID p_mesh,MorphTargetMode p_mode) { - - rasterizer->mesh_set_morph_target_mode(p_mesh,p_mode); -} - -VisualServer::MorphTargetMode VisualServerRaster::mesh_get_morph_target_mode(RID p_mesh) const{ - - return rasterizer->mesh_get_morph_target_mode(p_mesh); -} - -void VisualServerRaster::mesh_add_custom_surface(RID p_mesh,const Variant& p_dat) { - - -} - - -void VisualServerRaster::mesh_add_surface(RID p_mesh,PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes,bool p_alpha_sort) { - - VS_CHANGED; - _dependency_queue_update(p_mesh,true,true); - rasterizer->mesh_add_surface(p_mesh,p_primitive,p_arrays,p_blend_shapes,p_alpha_sort); - -} - -Array VisualServerRaster::mesh_get_surface_arrays(RID p_mesh,int p_surface) const { - - return rasterizer->mesh_get_surface_arrays(p_mesh,p_surface); -} -Array VisualServerRaster::mesh_get_surface_morph_arrays(RID p_mesh,int p_surface) const { - - return rasterizer->mesh_get_surface_morph_arrays(p_mesh,p_surface); -} - - - - -void VisualServerRaster::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material,bool p_owned){ - VS_CHANGED; - rasterizer->mesh_surface_set_material(p_mesh,p_surface,p_material,p_owned); -} - -RID VisualServerRaster::mesh_surface_get_material(RID p_mesh,int p_surface) const { - - return rasterizer->mesh_surface_get_material(p_mesh,p_surface); - -} - - -int VisualServerRaster::mesh_surface_get_array_len(RID p_mesh, int p_surface) const{ - - return rasterizer->mesh_surface_get_array_len(p_mesh,p_surface); -} - -int VisualServerRaster::mesh_surface_get_array_index_len(RID p_mesh, int p_surface) const{ - - - return rasterizer->mesh_surface_get_array_index_len(p_mesh,p_surface); -} - -uint32_t VisualServerRaster::mesh_surface_get_format(RID p_mesh, int p_surface) const{ - - return rasterizer->mesh_surface_get_format(p_mesh,p_surface); -} - -VisualServer::PrimitiveType VisualServerRaster::mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const{ - - return rasterizer->mesh_surface_get_primitive_type(p_mesh,p_surface); -} - - -void VisualServerRaster::mesh_remove_surface(RID p_mesh,int p_surface){ - - rasterizer->mesh_remove_surface(p_mesh,p_surface); - _dependency_queue_update(p_mesh,true,true); -} - -int VisualServerRaster::mesh_get_surface_count(RID p_mesh) const{ - - return rasterizer->mesh_get_surface_count(p_mesh); - -} - - -void VisualServerRaster::mesh_set_custom_aabb(RID p_mesh,const AABB& p_aabb) { - - VS_CHANGED; - _dependency_queue_update(p_mesh,true); - rasterizer->mesh_set_custom_aabb(p_mesh,p_aabb); - -} - -AABB VisualServerRaster::mesh_get_custom_aabb(RID p_mesh) const { - - return rasterizer->mesh_get_custom_aabb(p_mesh); -} - -void VisualServerRaster::mesh_clear(RID p_mesh) { - - ERR_FAIL_COND(!rasterizer->is_mesh(p_mesh)); - while(rasterizer->mesh_get_surface_count(p_mesh)) { - rasterizer->mesh_remove_surface(p_mesh,0); - } - - _dependency_queue_update(p_mesh,true,true); -} - - -/* MULTIMESH */ - -RID VisualServerRaster::multimesh_create() { - - return rasterizer->multimesh_create(); -} - -void VisualServerRaster::multimesh_set_instance_count(RID p_multimesh,int p_count) { - VS_CHANGED; - rasterizer->multimesh_set_instance_count(p_multimesh,p_count); -} - -int VisualServerRaster::multimesh_get_instance_count(RID p_multimesh) const { - - return rasterizer->multimesh_get_instance_count(p_multimesh); -} - -void VisualServerRaster::multimesh_set_mesh(RID p_multimesh,RID p_mesh) { - VS_CHANGED; - rasterizer->multimesh_set_mesh(p_multimesh,p_mesh); - -} -void VisualServerRaster::multimesh_set_aabb(RID p_multimesh,const AABB& p_aabb) { - VS_CHANGED; - rasterizer->multimesh_set_aabb(p_multimesh,p_aabb); - _dependency_queue_update(p_multimesh,true); - -} - -void VisualServerRaster::multimesh_instance_set_transform(RID p_multimesh,int p_index,const Transform& p_transform) { - VS_CHANGED; - rasterizer->multimesh_instance_set_transform(p_multimesh,p_index,p_transform); - -} -void VisualServerRaster::multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color) { - VS_CHANGED; - rasterizer->multimesh_instance_set_color(p_multimesh,p_index,p_color); - -} -RID VisualServerRaster::multimesh_get_mesh(RID p_multimesh) const { - - return rasterizer->multimesh_get_mesh(p_multimesh); -} -AABB VisualServerRaster::multimesh_get_aabb(RID p_multimesh,const AABB& p_aabb) const { - - - return rasterizer->multimesh_get_aabb(p_multimesh); -} - -Transform VisualServerRaster::multimesh_instance_get_transform(RID p_multimesh,int p_index) const { - - return rasterizer->multimesh_instance_get_transform(p_multimesh,p_index); -} -Color VisualServerRaster::multimesh_instance_get_color(RID p_multimesh,int p_index) const { - - return rasterizer->multimesh_instance_get_color(p_multimesh,p_index); -} - -void VisualServerRaster::multimesh_set_visible_instances(RID p_multimesh,int p_visible) { - - rasterizer->multimesh_set_visible_instances(p_multimesh,p_visible); - -} - -int VisualServerRaster::multimesh_get_visible_instances(RID p_multimesh) const { - - return rasterizer->multimesh_get_visible_instances(p_multimesh); -} - - -/* IMMEDIATE API */ - - -RID VisualServerRaster::immediate_create() { - - return rasterizer->immediate_create(); -} - -void VisualServerRaster::immediate_begin(RID p_immediate,PrimitiveType p_primitive,RID p_texture){ - - rasterizer->immediate_begin(p_immediate,p_primitive,p_texture); -} -void VisualServerRaster::immediate_vertex(RID p_immediate,const Vector3& p_vertex){ - - rasterizer->immediate_vertex(p_immediate,p_vertex); - -} -void VisualServerRaster::immediate_normal(RID p_immediate,const Vector3& p_normal){ - - rasterizer->immediate_normal(p_immediate,p_normal); - -} -void VisualServerRaster::immediate_tangent(RID p_immediate,const Plane& p_tangent){ - - rasterizer->immediate_tangent(p_immediate,p_tangent); - -} -void VisualServerRaster::immediate_color(RID p_immediate,const Color& p_color){ - - rasterizer->immediate_color(p_immediate,p_color); - -} -void VisualServerRaster::immediate_uv(RID p_immediate,const Vector2& p_uv){ - - rasterizer->immediate_uv(p_immediate,p_uv); - -} -void VisualServerRaster::immediate_uv2(RID p_immediate,const Vector2& p_uv2){ - - rasterizer->immediate_uv2(p_immediate,p_uv2); - -} -void VisualServerRaster::immediate_end(RID p_immediate){ - - VS_CHANGED; - _dependency_queue_update(p_immediate,true); - rasterizer->immediate_end(p_immediate); - -} -void VisualServerRaster::immediate_clear(RID p_immediate){ - - VS_CHANGED; - _dependency_queue_update(p_immediate,true); - rasterizer->immediate_clear(p_immediate); - -} - -void VisualServerRaster::immediate_set_material(RID p_immediate,RID p_material) { - - rasterizer->immediate_set_material(p_immediate,p_material); -} - -RID VisualServerRaster::immediate_get_material(RID p_immediate) const { - - return rasterizer->immediate_get_material(p_immediate); -} - - -/* PARTICLES API */ - -RID VisualServerRaster::particles_create() { - - return rasterizer->particles_create(); -} - -void VisualServerRaster::particles_set_amount(RID p_particles, int p_amount) { - VS_CHANGED; - rasterizer->particles_set_amount(p_particles,p_amount); -} - -int VisualServerRaster::particles_get_amount(RID p_particles) const { - - return rasterizer->particles_get_amount(p_particles); -} - -void VisualServerRaster::particles_set_emitting(RID p_particles, bool p_emitting) { - VS_CHANGED; - rasterizer->particles_set_emitting(p_particles,p_emitting); -} -bool VisualServerRaster::particles_is_emitting(RID p_particles) const { - - return rasterizer->particles_is_emitting(p_particles); -} - -void VisualServerRaster::particles_set_visibility_aabb(RID p_particles, const AABB& p_visibility) { - VS_CHANGED; - rasterizer->particles_set_visibility_aabb(p_particles, p_visibility); -} -AABB VisualServerRaster::particles_get_visibility_aabb(RID p_particles) const { - - return rasterizer->particles_get_visibility_aabb(p_particles); -} - -void VisualServerRaster::particles_set_emission_half_extents(RID p_particles, const Vector3& p_half_extents) { - VS_CHANGED; - rasterizer->particles_set_emission_half_extents(p_particles,p_half_extents); -} -Vector3 VisualServerRaster::particles_get_emission_half_extents(RID p_particles) const { - - return rasterizer->particles_get_emission_half_extents(p_particles); -} - -void VisualServerRaster::particles_set_emission_base_velocity(RID p_particles, const Vector3& p_base_velocity) { - VS_CHANGED; - rasterizer->particles_set_emission_base_velocity(p_particles,p_base_velocity); -} -Vector3 VisualServerRaster::particles_get_emission_base_velocity(RID p_particles) const { - - return rasterizer->particles_get_emission_base_velocity(p_particles); -} - -void VisualServerRaster::particles_set_emission_points(RID p_particles, const PoolVector<Vector3>& p_points) { - - VS_CHANGED; - rasterizer->particles_set_emission_points(p_particles,p_points); -} - -PoolVector<Vector3> VisualServerRaster::particles_get_emission_points(RID p_particles) const { - - return rasterizer->particles_get_emission_points(p_particles); -} - -void VisualServerRaster::particles_set_gravity_normal(RID p_particles, const Vector3& p_normal) { - VS_CHANGED; - rasterizer->particles_set_gravity_normal(p_particles,p_normal); -} -Vector3 VisualServerRaster::particles_get_gravity_normal(RID p_particles) const { - - return rasterizer->particles_get_gravity_normal(p_particles); -} - -void VisualServerRaster::particles_set_variable(RID p_particles, ParticleVariable p_variable,float p_value) { - VS_CHANGED; - rasterizer->particles_set_variable(p_particles,p_variable,p_value); -} -float VisualServerRaster::particles_get_variable(RID p_particles, ParticleVariable p_variable) const { - - return rasterizer->particles_get_variable(p_particles,p_variable); -} - -void VisualServerRaster::particles_set_randomness(RID p_particles, ParticleVariable p_variable,float p_randomness) { - VS_CHANGED; - rasterizer->particles_set_randomness(p_particles,p_variable,p_randomness); -} -float VisualServerRaster::particles_get_randomness(RID p_particles, ParticleVariable p_variable) const { - - return rasterizer->particles_get_randomness(p_particles,p_variable); -} - -void VisualServerRaster::particles_set_color_phases(RID p_particles, int p_phases) { - VS_CHANGED; - rasterizer->particles_set_color_phases(p_particles,p_phases); -} -int VisualServerRaster::particles_get_color_phases(RID p_particles) const { - - return rasterizer->particles_get_color_phases(p_particles); -} - -void VisualServerRaster::particles_set_color_phase_pos(RID p_particles, int p_phase, float p_pos) { - VS_CHANGED; - rasterizer->particles_set_color_phase_pos(p_particles,p_phase,p_pos); -} -float VisualServerRaster::particles_get_color_phase_pos(RID p_particles, int p_phase) const { - - return rasterizer->particles_get_color_phase_pos(p_particles,p_phase); -} - -void VisualServerRaster::particles_set_attractors(RID p_particles, int p_attractors) { - VS_CHANGED; - rasterizer->particles_set_attractors(p_particles,p_attractors); -} -int VisualServerRaster::particles_get_attractors(RID p_particles) const { - - return rasterizer->particles_get_attractors(p_particles); -} - -void VisualServerRaster::particles_set_attractor_pos(RID p_particles, int p_attractor, const Vector3& p_pos) { - VS_CHANGED; - rasterizer->particles_set_attractor_pos(p_particles,p_attractor,p_pos); -} -Vector3 VisualServerRaster::particles_get_attractor_pos(RID p_particles,int p_attractor) const { - - return rasterizer->particles_get_attractor_pos(p_particles,p_attractor); -} - -void VisualServerRaster::particles_set_attractor_strength(RID p_particles, int p_attractor, float p_force) { - VS_CHANGED; - rasterizer->particles_set_attractor_strength(p_particles,p_attractor,p_force); -} - -float VisualServerRaster::particles_get_attractor_strength(RID p_particles,int p_attractor) const { - - return rasterizer->particles_get_attractor_strength(p_particles,p_attractor); -} - -void VisualServerRaster::particles_set_color_phase_color(RID p_particles, int p_phase, const Color& p_color) { - VS_CHANGED; - rasterizer->particles_set_color_phase_color(p_particles,p_phase,p_color); -} -Color VisualServerRaster::particles_get_color_phase_color(RID p_particles, int p_phase) const { - - return rasterizer->particles_get_color_phase_color(p_particles,p_phase); -} - -void VisualServerRaster::particles_set_material(RID p_particles, RID p_material,bool p_owned) { - VS_CHANGED; - rasterizer->particles_set_material(p_particles,p_material,p_owned); -} -RID VisualServerRaster::particles_get_material(RID p_particles) const { - - return rasterizer->particles_get_material(p_particles); -} - - -void VisualServerRaster::particles_set_height_from_velocity(RID p_particles, bool p_enable) { - - VS_CHANGED; - rasterizer->particles_set_height_from_velocity(p_particles,p_enable); - -} - -bool VisualServerRaster::particles_has_height_from_velocity(RID p_particles) const { - - return rasterizer->particles_has_height_from_velocity(p_particles); -} - -void VisualServerRaster::particles_set_use_local_coordinates(RID p_particles, bool p_enable) { - - rasterizer->particles_set_use_local_coordinates(p_particles,p_enable); -} - -bool VisualServerRaster::particles_is_using_local_coordinates(RID p_particles) const { - - return rasterizer->particles_is_using_local_coordinates(p_particles); -} - - -/* Light API */ - -RID VisualServerRaster::light_create(LightType p_type) { - - return rasterizer->light_create(p_type); -} -VisualServer::LightType VisualServerRaster::light_get_type(RID p_light) const { - - return rasterizer->light_get_type(p_light); -} - -void VisualServerRaster::light_set_color(RID p_light,LightColor p_type, const Color& p_color) { - VS_CHANGED; - rasterizer->light_set_color(p_light,p_type,p_color); - -} -Color VisualServerRaster::light_get_color(RID p_light,LightColor p_type) const { - - return rasterizer->light_get_color(p_light,p_type); - -} - - -void VisualServerRaster::light_set_shadow(RID p_light,bool p_enabled) { - VS_CHANGED; - rasterizer->light_set_shadow(p_light,p_enabled); -} - -bool VisualServerRaster::light_has_shadow(RID p_light) const { - - return rasterizer->light_has_shadow(p_light); -} - - - -void VisualServerRaster::light_set_volumetric(RID p_light,bool p_enabled) { - VS_CHANGED; - rasterizer->light_set_volumetric(p_light,p_enabled); -} - -bool VisualServerRaster::light_is_volumetric(RID p_light) const { - - return rasterizer->light_is_volumetric(p_light); -} - -void VisualServerRaster::light_set_projector(RID p_light,RID p_texture) { - VS_CHANGED; - rasterizer->light_set_projector(p_light,p_texture); -} - -RID VisualServerRaster::light_get_projector(RID p_light) const { - - return rasterizer->light_get_projector(p_light); -} - -void VisualServerRaster::light_set_param(RID p_light, LightParam p_var, float p_value) { - VS_CHANGED; - rasterizer->light_set_var(p_light,p_var,p_value); - _dependency_queue_update(p_light,true); - -} - -float VisualServerRaster::light_get_param(RID p_light, LightParam p_var) const { - - - return rasterizer->light_get_var(p_light,p_var); -} - -void VisualServerRaster::light_set_operator(RID p_light,LightOp p_op) { - VS_CHANGED; - rasterizer->light_set_operator(p_light,p_op); -} - -VisualServerRaster::LightOp VisualServerRaster::light_get_operator(RID p_light) const { - - return rasterizer->light_get_operator(p_light); -} - -void VisualServerRaster::light_omni_set_shadow_mode(RID p_light,LightOmniShadowMode p_mode) { - VS_CHANGED; - rasterizer->light_omni_set_shadow_mode(p_light,p_mode); -} - -VisualServerRaster::LightOmniShadowMode VisualServerRaster::light_omni_get_shadow_mode(RID p_light) const { - - return rasterizer->light_omni_get_shadow_mode(p_light); -} - -void VisualServerRaster::light_directional_set_shadow_mode(RID p_light,LightDirectionalShadowMode p_mode){ - VS_CHANGED; - rasterizer->light_directional_set_shadow_mode(p_light,p_mode); -} - -VS::LightDirectionalShadowMode VisualServerRaster::light_directional_get_shadow_mode(RID p_light) const{ - - return rasterizer->light_directional_get_shadow_mode(p_light); -} - -void VisualServerRaster::light_directional_set_shadow_param(RID p_light,LightDirectionalShadowParam p_param, float p_value) { - VS_CHANGED; - rasterizer->light_directional_set_shadow_param(p_light,p_param,p_value); -} - -float VisualServerRaster::light_directional_get_shadow_param(RID p_light,LightDirectionalShadowParam p_param) const { - - return rasterizer->light_directional_get_shadow_param(p_light,p_param); -} - - -RID VisualServerRaster::skeleton_create() { - - return rasterizer->skeleton_create(); -} - -void VisualServerRaster::skeleton_resize(RID p_skeleton,int p_bones) { - VS_CHANGED; - rasterizer->skeleton_resize(p_skeleton,p_bones); -} - -int VisualServerRaster::skeleton_get_bone_count(RID p_skeleton) const { - - return rasterizer->skeleton_get_bone_count(p_skeleton); -} - -void VisualServerRaster::skeleton_bone_set_transform(RID p_skeleton,int p_bone, const Transform& p_transform) { - VS_CHANGED; - rasterizer->skeleton_bone_set_transform(p_skeleton,p_bone,p_transform); - - Map< RID, Set<Instance*> >::Element *E=skeleton_dependency_map.find(p_skeleton); - - if (E) { - //detach skeletons - for (Set<Instance*>::Element *F=E->get().front();F;F=F->next()) { - - _instance_queue_update( F->get() , true); - } - } -} - -Transform VisualServerRaster::skeleton_bone_get_transform(RID p_skeleton,int p_bone) { - - - return rasterizer->skeleton_bone_get_transform(p_skeleton,p_bone); - -} - - -/* VISIBILITY API */ - -/* ROOM API */ - -RID VisualServerRaster::room_create() { - - Room *room = memnew( Room ); - ERR_FAIL_COND_V(!room,RID()); - return room_owner.make_rid( room ); - -} - -void VisualServerRaster::room_set_bounds(RID p_room, const BSP_Tree& p_bounds) { - VS_CHANGED; - Room *room = room_owner.get(p_room); - ERR_FAIL_COND(!room); - room->bounds=p_bounds; - _dependency_queue_update(p_room,true); - -} - -BSP_Tree VisualServerRaster::room_get_bounds(RID p_room) const { - - Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room, BSP_Tree()); - return room->bounds; - -} - -/* PORTAL API */ - -RID VisualServerRaster::portal_create() { - VS_CHANGED; - Portal *portal = memnew( Portal ); - ERR_FAIL_COND_V(!portal,RID()); - return portal_owner.make_rid( portal ); - - -} - - -void VisualServerRaster::portal_set_shape(RID p_portal, const Vector<Point2>& p_shape) { - VS_CHANGED; - Portal *portal = portal_owner.get(p_portal); - ERR_FAIL_COND(!portal); - portal->shape=p_shape; - - portal->bounds=Rect2(); - - for(int i=0;i<p_shape.size();i++) { - - if (i==0) - portal->bounds.pos=p_shape[i]; - else - portal->bounds.expand_to(p_shape[i]); - } - - _dependency_queue_update(p_portal,true); -} - - -Vector<Point2> VisualServerRaster::portal_get_shape(RID p_portal) const { - - Portal *portal = portal_owner.get(p_portal); - ERR_FAIL_COND_V(!portal, Vector<Point2>()); - return portal->shape; - - -} - -void VisualServerRaster::portal_set_enabled(RID p_portal, bool p_enabled) { - VS_CHANGED; - Portal *portal = portal_owner.get(p_portal); - ERR_FAIL_COND(!portal); - portal->enabled=p_enabled; - -} - -bool VisualServerRaster::portal_is_enabled(RID p_portal) const { - - Portal *portal = portal_owner.get(p_portal); - ERR_FAIL_COND_V(!portal, false); - return portal->enabled; - -} -void VisualServerRaster::portal_set_disable_distance(RID p_portal, float p_distance) { - VS_CHANGED; - Portal *portal = portal_owner.get(p_portal); - ERR_FAIL_COND(!portal); - portal->disable_distance=p_distance; - -} -float VisualServerRaster::portal_get_disable_distance(RID p_portal) const { - - Portal *portal = portal_owner.get(p_portal); - ERR_FAIL_COND_V(!portal, -1); - return portal->disable_distance; - -} -void VisualServerRaster::portal_set_disabled_color(RID p_portal, const Color& p_color) { - VS_CHANGED; - Portal *portal = portal_owner.get(p_portal); - ERR_FAIL_COND(!portal); - portal->disable_color=p_color; - -} -Color VisualServerRaster::portal_get_disabled_color(RID p_portal) const { - - Portal *portal = portal_owner.get(p_portal); - ERR_FAIL_COND_V(!portal, Color()); - return portal->disable_color; -} - -void VisualServerRaster::portal_set_connect_range(RID p_portal, float p_range) { - VS_CHANGED; - Portal *portal = portal_owner.get(p_portal); - ERR_FAIL_COND(!portal); - portal->connect_range=p_range; - _dependency_queue_update(p_portal,true); -} - -float VisualServerRaster::portal_get_connect_range(RID p_portal) const { - - Portal *portal = portal_owner.get(p_portal); - ERR_FAIL_COND_V(!portal,0); - return portal->connect_range; -} - - -RID VisualServerRaster::baked_light_create() { - - BakedLight *baked_light = memnew( BakedLight ); - ERR_FAIL_COND_V(!baked_light,RID()); - baked_light->data.mode=BAKED_LIGHT_OCTREE; - - baked_light->data.octree_lattice_size=0; - baked_light->data.octree_lattice_divide=0; - baked_light->data.octree_steps=1; - baked_light->data.lightmap_multiplier=1.0; - baked_light->data.realtime_color_enabled=false; - baked_light->data.realtime_color=Color(1.0, 1.0, 1.0); - baked_light->data.realtime_energy = 1.0; - - return baked_light_owner.make_rid( baked_light ); - -} - -void VisualServerRaster::baked_light_set_mode(RID p_baked_light,BakedLightMode p_mode){ - - VS_CHANGED; - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND(!baked_light); - baked_light->data.mode=p_mode; - baked_light->data.color_multiplier=1.0; - _dependency_queue_update(p_baked_light,true); - - -} - -VisualServer::BakedLightMode VisualServerRaster::baked_light_get_mode(RID p_baked_light) const{ - - const BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light,BAKED_LIGHT_OCTREE); - return baked_light->data.mode; - -} - -void VisualServerRaster::baked_light_set_lightmap_multiplier(RID p_baked_light,float p_multiplier) { - - VS_CHANGED; - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND(!baked_light); - - baked_light->data.lightmap_multiplier=p_multiplier; - -} - -float VisualServerRaster::baked_light_get_lightmap_multiplier(RID p_baked_light) const{ - - const BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light,0); - - return baked_light->data.lightmap_multiplier; - -} - - -void VisualServerRaster::baked_light_set_octree(RID p_baked_light,const PoolVector<uint8_t> p_octree){ - - VS_CHANGED; - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND(!baked_light); - - if (p_octree.size()==0) { - if (baked_light->data.octree_texture.is_valid()) - rasterizer->free(baked_light->data.octree_texture); - baked_light->data.octree_texture; - baked_light->octree_aabb=AABB(); - baked_light->octree_tex_size=Size2(); - } else { - - int tex_w; - int tex_h; - int light_tex_w; - int light_tex_h; - bool is16; - bool has_light_tex=false; - { - - PoolVector<uint8_t>::Read r=p_octree.read(); - tex_w = decode_uint32(&r[0]); - tex_h = decode_uint32(&r[4]); - print_line("TEX W: "+itos(tex_w)+" TEX H:"+itos(tex_h)+" LEN: "+itos(p_octree.size())); - is16=decode_uint32(&r[8]); - baked_light->data.octree_lattice_size=decode_float(&r[12]); - baked_light->data.octree_lattice_divide=tex_w/4.0; - print_line("LATTICE SIZE: "+rtos(baked_light->data.octree_lattice_size)); - print_line("LATTICE DIVIDE: "+rtos(baked_light->data.octree_lattice_divide)); - baked_light->data.octree_steps=decode_uint32(&r[16]); - baked_light->data.octree_tex_pixel_size.x=1.0/tex_w; - baked_light->data.octree_tex_pixel_size.y=1.0/tex_h; - - baked_light->data.texture_multiplier=decode_uint32(&r[20]); - light_tex_w=decode_uint16(&r[24]); - light_tex_h=decode_uint16(&r[26]); - print_line("ltexw "+itos(light_tex_w)); - print_line("ltexh "+itos(light_tex_h)); - - if (light_tex_w>0 && light_tex_h>0) { - baked_light->data.light_tex_pixel_size.x=1.0/light_tex_w; - baked_light->data.light_tex_pixel_size.y=1.0/light_tex_h; - has_light_tex=true; - } else { - baked_light->data.light_tex_pixel_size=baked_light->data.octree_tex_pixel_size; - - } - - - - baked_light->octree_aabb.pos.x=decode_float(&r[32]); - baked_light->octree_aabb.pos.y=decode_float(&r[36]); - baked_light->octree_aabb.pos.z=decode_float(&r[40]); - baked_light->octree_aabb.size.x=decode_float(&r[44]); - baked_light->octree_aabb.size.y=decode_float(&r[48]); - baked_light->octree_aabb.size.z=decode_float(&r[52]); - - - } - - if (baked_light->data.octree_texture.is_valid()) { - if (tex_w!=baked_light->octree_tex_size.x || tex_h!=baked_light->octree_tex_size.y) { - - rasterizer->free(baked_light->data.octree_texture); - baked_light->data.octree_texture; - baked_light->octree_tex_size.x=0; - baked_light->octree_tex_size.y=0; - } - } - - if (baked_light->data.light_texture.is_valid()) { - if (!has_light_tex || light_tex_w!=baked_light->light_tex_size.x || light_tex_h!=baked_light->light_tex_size.y) { - rasterizer->free(baked_light->data.light_texture); - baked_light->data.light_texture; - baked_light->light_tex_size.x=0; - baked_light->light_tex_size.y=0; - } - } - - if (!baked_light->data.octree_texture.is_valid()) { - baked_light->data.octree_texture=rasterizer->texture_create(); - rasterizer->texture_allocate(baked_light->data.octree_texture,tex_w,tex_h,Image::FORMAT_RGBA8,TEXTURE_FLAG_FILTER); - baked_light->octree_tex_size.x=tex_w; - baked_light->octree_tex_size.y=tex_h; - } - - if (!baked_light->data.light_texture.is_valid() && has_light_tex) { - baked_light->data.light_texture=rasterizer->texture_create(); - rasterizer->texture_allocate(baked_light->data.light_texture,light_tex_w,light_tex_h,Image::FORMAT_RGBA8,TEXTURE_FLAG_FILTER); - baked_light->light_tex_size.x=light_tex_w; - baked_light->light_tex_size.y=light_tex_h; - - } - - Image img(tex_w,tex_h,0,Image::FORMAT_RGBA8,p_octree); - rasterizer->texture_set_data(baked_light->data.octree_texture,img); - - } - - - _dependency_queue_update(p_baked_light,true); - -} - - -PoolVector<uint8_t> VisualServerRaster::baked_light_get_octree(RID p_baked_light) const{ - - - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light,PoolVector<uint8_t>()); - - if (rasterizer->is_texture(baked_light->data.octree_texture)) { - - Image img = rasterizer->texture_get_data(baked_light->data.octree_texture); - return img.get_data(); - } else { - return PoolVector<uint8_t>(); - } -} - -void VisualServerRaster::baked_light_set_light(RID p_baked_light,const PoolVector<uint8_t> p_light) { - - VS_CHANGED; - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND(!baked_light); - ERR_FAIL_COND(p_light.size()==0); - - int tex_w=baked_light->light_tex_size.x; - int tex_h=baked_light->light_tex_size.y; - - ERR_FAIL_COND(tex_w==0 && tex_h==0); - ERR_FAIL_COND(!baked_light->data.light_texture.is_valid()); - - - - print_line("w: "+itos(tex_w)+" h: "+itos(tex_h)+" lightsize: "+itos(p_light.size())); - - Image img(tex_w,tex_h,0,Image::FORMAT_RGBA8,p_light); - rasterizer->texture_set_data(baked_light->data.light_texture,img); - - - -} - -PoolVector<uint8_t> VisualServerRaster::baked_light_get_light(RID p_baked_light) const{ - - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light,PoolVector<uint8_t>()); - - if (rasterizer->is_texture(baked_light->data.light_texture)) { - - Image img = rasterizer->texture_get_data(baked_light->data.light_texture); - return img.get_data(); - } else { - return PoolVector<uint8_t>(); - } -} - - - -void VisualServerRaster::baked_light_set_sampler_octree(RID p_baked_light, const PoolVector<int> &p_sampler) { - - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND(!baked_light); - - baked_light->sampler=p_sampler; - - - -} - -PoolVector<int> VisualServerRaster::baked_light_get_sampler_octree(RID p_baked_light) const { - - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light,PoolVector<int>()); - - return baked_light->sampler; - -} - - -void VisualServerRaster::baked_light_add_lightmap(RID p_baked_light,const RID p_texture,int p_id){ - - VS_CHANGED; - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND(!baked_light); - baked_light->data.lightmaps.insert(p_id,p_texture); - -} -void VisualServerRaster::baked_light_clear_lightmaps(RID p_baked_light){ - - VS_CHANGED; - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND(!baked_light); - baked_light->data.lightmaps.clear(); - -} - -void VisualServerRaster::baked_light_set_realtime_color_enabled(RID p_baked_light, const bool p_enabled) { - - VS_CHANGED; - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND(!baked_light); - - baked_light->data.realtime_color_enabled = p_enabled; - -} - -bool VisualServerRaster::baked_light_get_realtime_color_enabled(RID p_baked_light) const{ - - const BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light, false); - - return baked_light->data.realtime_color_enabled; - -} - -void VisualServerRaster::baked_light_set_realtime_color(RID p_baked_light, const Color& p_color) { - - VS_CHANGED; - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND(!baked_light); - - baked_light->data.realtime_color = p_color; - -} - -Color VisualServerRaster::baked_light_get_realtime_color(RID p_baked_light) const{ - - const BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light, Color(1.0, 1.0, 1.0)); - - return baked_light->data.realtime_color; - -} - -void VisualServerRaster::baked_light_set_realtime_energy(RID p_baked_light, const float p_energy) { - - VS_CHANGED; - BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND(!baked_light); - - baked_light->data.realtime_energy = p_energy; - -} - -float VisualServerRaster::baked_light_get_realtime_energy(RID p_baked_light) const{ - - const BakedLight *baked_light = baked_light_owner.get(p_baked_light); - ERR_FAIL_COND_V(!baked_light, 1.0f); - - return baked_light->data.realtime_energy; - -} - - -/* BAKED LIGHT SAMPLER */ - -RID VisualServerRaster::baked_light_sampler_create() { - - BakedLightSampler * blsamp = memnew( BakedLightSampler ); - RID rid = baked_light_sampler_owner.make_rid(blsamp); - _update_baked_light_sampler_dp_cache(blsamp); - return rid; -} - -void VisualServerRaster::baked_light_sampler_set_param(RID p_baked_light_sampler,BakedLightSamplerParam p_param,float p_value){ - - VS_CHANGED; - BakedLightSampler * blsamp = baked_light_sampler_owner.get(p_baked_light_sampler); - ERR_FAIL_COND(!blsamp); - ERR_FAIL_INDEX(p_param,BAKED_LIGHT_SAMPLER_MAX); - blsamp->params[p_param]=p_value; - _dependency_queue_update(p_baked_light_sampler,true); -} - -float VisualServerRaster::baked_light_sampler_get_param(RID p_baked_light_sampler,BakedLightSamplerParam p_param) const{ - - - BakedLightSampler * blsamp = baked_light_sampler_owner.get(p_baked_light_sampler); - ERR_FAIL_COND_V(!blsamp,0); - ERR_FAIL_INDEX_V(p_param,BAKED_LIGHT_SAMPLER_MAX,0); - return blsamp->params[p_param]; -} - -void VisualServerRaster::_update_baked_light_sampler_dp_cache(BakedLightSampler * blsamp) { - - int res = blsamp->resolution; - blsamp->dp_cache.resize(res*res*2); - Vector3 *dp_normals=blsamp->dp_cache.ptr(); - - for(int p=0;p<2;p++) { - float sign = p==0?1:-1; - int ofs = res*res*p; - for(int i=0;i<res;i++) { - for(int j=0;j<res;j++) { - - Vector2 v( - (i/float(res))*2.0-1.0, - (j/float(res))*2.0-1.0 - ); - - float l=v.length(); - if (l>1.0) { - v/=l; - l=1.0; //clamp to avoid imaginary - } - v*=(2*l)/(l*l+1); //inverse of the dual paraboloid function - Vector3 n = Vector3(v.x,v.y,sign*sqrtf(MAX(1 - v.dot(v),0))); //reconstruction of z - n.y*=sign; - dp_normals[j*res+i+ofs]=n; - } - } - } - -} - -void VisualServerRaster::baked_light_sampler_set_resolution(RID p_baked_light_sampler,int p_resolution){ - - ERR_FAIL_COND(p_resolution<4 || p_resolution>64); - VS_CHANGED; - BakedLightSampler * blsamp = baked_light_sampler_owner.get(p_baked_light_sampler); - ERR_FAIL_COND(!blsamp); - blsamp->resolution=p_resolution; - _update_baked_light_sampler_dp_cache(blsamp); - -} -int VisualServerRaster::baked_light_sampler_get_resolution(RID p_baked_light_sampler) const{ - - BakedLightSampler * blsamp = baked_light_sampler_owner.get(p_baked_light_sampler); - ERR_FAIL_COND_V(!blsamp,0); - return blsamp->resolution; -} - -/* CAMERA API */ - -RID VisualServerRaster::camera_create() { - - Camera * camera = memnew( Camera ); - return camera_owner.make_rid( camera ); - -} - -void VisualServerRaster::camera_set_perspective(RID p_camera,float p_fovy_degrees, float p_z_near, float p_z_far) { - VS_CHANGED - Camera *camera = camera_owner.get( p_camera ); - ERR_FAIL_COND(!camera); - camera->type=Camera::PERSPECTIVE; - camera->fov=p_fovy_degrees; - camera->znear=p_z_near; - camera->zfar=p_z_far; - -} - -void VisualServerRaster::camera_set_orthogonal(RID p_camera,float p_size, float p_z_near, float p_z_far) { - VS_CHANGED; - Camera *camera = camera_owner.get( p_camera ); - ERR_FAIL_COND(!camera); - camera->type=Camera::ORTHOGONAL; - camera->size=p_size; - camera->znear=p_z_near; - camera->zfar=p_z_far; -} - -void VisualServerRaster::camera_set_transform(RID p_camera,const Transform& p_transform) { - VS_CHANGED; - Camera *camera = camera_owner.get( p_camera ); - ERR_FAIL_COND(!camera); - camera->transform=p_transform.orthonormalized(); - - -} - -void VisualServerRaster::camera_set_visible_layers(RID p_camera,uint32_t p_layers) { - - VS_CHANGED; - Camera *camera = camera_owner.get( p_camera ); - ERR_FAIL_COND(!camera); - - camera->visible_layers=p_layers; - -} - -uint32_t VisualServerRaster::camera_get_visible_layers(RID p_camera) const{ - - const Camera *camera = camera_owner.get( p_camera ); - ERR_FAIL_COND_V(!camera,0); - - return camera->visible_layers; -} - -void VisualServerRaster::camera_set_environment(RID p_camera,RID p_env) { - - Camera *camera = camera_owner.get( p_camera ); - ERR_FAIL_COND(!camera); - camera->env=p_env; - -} - -RID VisualServerRaster::camera_get_environment(RID p_camera) const { - - const Camera *camera = camera_owner.get( p_camera ); - ERR_FAIL_COND_V(!camera,RID()); - return camera->env; - -} - -void VisualServerRaster::camera_set_use_vertical_aspect(RID p_camera,bool p_enable) { - - Camera *camera = camera_owner.get( p_camera ); - ERR_FAIL_COND(!camera); - camera->vaspect=p_enable; - -} -bool VisualServerRaster::camera_is_using_vertical_aspect(RID p_camera,bool p_enable) const{ - - const Camera *camera = camera_owner.get( p_camera ); - ERR_FAIL_COND_V(!camera,false); - return camera->vaspect; - -} - - -/* VIEWPORT API */ - - -RID VisualServerRaster::viewport_create() { - - Viewport *viewport = memnew( Viewport ); - RID rid = viewport_owner.make_rid( viewport ); - ERR_FAIL_COND_V( !rid.is_valid(), rid ); - - viewport->self=rid; - viewport->hide_scenario=false; - viewport->hide_canvas=false; - viewport->viewport_data=rasterizer->viewport_data_create(); - - return rid; -} - -void VisualServerRaster::viewport_attach_to_screen(RID p_viewport,int p_screen) { - - VS_CHANGED; - Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - - screen_viewports[p_viewport]=p_screen; -} - -void VisualServerRaster::viewport_detach(RID p_viewport) { - - VS_CHANGED; - Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - ERR_FAIL_COND(!screen_viewports.has(p_viewport)); - screen_viewports.erase(p_viewport); - -} - -void VisualServerRaster::viewport_set_as_render_target(RID p_viewport,bool p_enable) { - - VS_CHANGED; - Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - if (viewport->render_target.is_valid()==p_enable) - return; - if (!p_enable) { - - rasterizer->free(viewport->render_target); - viewport->render_target; - viewport->render_target_texture; - if (viewport->update_list.in_list()) - viewport_update_list.remove(&viewport->update_list); - - } else { - - viewport->render_target=rasterizer->render_target_create(); - rasterizer->render_target_set_size(viewport->render_target,viewport->rect.width,viewport->rect.height); - viewport->render_target_texture=rasterizer->render_target_get_texture(viewport->render_target); - if (viewport->render_target_update_mode!=RENDER_TARGET_UPDATE_DISABLED) - viewport_update_list.add(&viewport->update_list); - } - -} - -void VisualServerRaster::viewport_set_render_target_update_mode(RID p_viewport,RenderTargetUpdateMode p_mode){ - - VS_CHANGED; - Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - if (viewport->render_target.is_valid() && viewport->update_list.in_list()) - viewport_update_list.remove(&viewport->update_list); - - viewport->render_target_update_mode=p_mode; - - if (viewport->render_target.is_valid() &&viewport->render_target_update_mode!=RENDER_TARGET_UPDATE_DISABLED) - viewport_update_list.add(&viewport->update_list); - -} -VisualServer::RenderTargetUpdateMode VisualServerRaster::viewport_get_render_target_update_mode(RID p_viewport) const{ - - const Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport,RENDER_TARGET_UPDATE_DISABLED); - - return viewport->render_target_update_mode; -} -RID VisualServerRaster::viewport_get_render_target_texture(RID p_viewport) const{ - - Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport,RID()); - - return viewport->render_target_texture; - -} - -void VisualServerRaster::viewport_set_render_target_vflip(RID p_viewport,bool p_enable) { - - Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - viewport->render_target_vflip=p_enable; - -} - -void VisualServerRaster::viewport_set_render_target_clear_on_new_frame(RID p_viewport,bool p_enable) { - - Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - viewport->render_target_clear_on_new_frame=p_enable; - -} - -void VisualServerRaster::viewport_set_render_target_to_screen_rect(RID p_viewport,const Rect2& p_rect) { - - Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - viewport->rt_to_screen_rect=p_rect; - -} - -bool VisualServerRaster::viewport_get_render_target_vflip(RID p_viewport) const{ - - const Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport,false); - - return viewport->render_target_vflip; - -} - -bool VisualServerRaster::viewport_get_render_target_clear_on_new_frame(RID p_viewport) const{ - - const Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport,false); - - return viewport->render_target_clear_on_new_frame; - -} - -void VisualServerRaster::viewport_render_target_clear(RID p_viewport) { - - Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - viewport->render_target_clear=true; - -} - -void VisualServerRaster::viewport_queue_screen_capture(RID p_viewport) { - - VS_CHANGED; - Viewport *viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - viewport->queue_capture=true; - -} - -Image VisualServerRaster::viewport_get_screen_capture(RID p_viewport) const { - - Viewport *viewport = (Viewport*)viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport,Image()); - - Image ret = viewport->capture; - viewport->capture=Image(); - return ret; -} - -void VisualServerRaster::viewport_set_rect(RID p_viewport,const ViewportRect& p_rect) { - VS_CHANGED; - Viewport *viewport=NULL; - - viewport = viewport_owner.get( p_viewport ); - - ERR_FAIL_COND(!viewport); - - viewport->rect=p_rect; - if (viewport->render_target.is_valid()) { - rasterizer->render_target_set_size(viewport->render_target,viewport->rect.width,viewport->rect.height); - } -} - - -VisualServer::ViewportRect VisualServerRaster::viewport_get_rect(RID p_viewport) const { - - const Viewport *viewport=NULL; - - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport, ViewportRect()); - - return viewport->rect; -} - -void VisualServerRaster::viewport_set_hide_scenario(RID p_viewport,bool p_hide) { - - VS_CHANGED; - - Viewport *viewport=NULL; - - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - viewport->hide_scenario=p_hide; - - -} - -void VisualServerRaster::viewport_set_hide_canvas(RID p_viewport,bool p_hide) { - - VS_CHANGED; - - Viewport *viewport=NULL; - - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - viewport->hide_canvas=p_hide; - - -} - -void VisualServerRaster::viewport_set_disable_environment(RID p_viewport,bool p_disable) { - - VS_CHANGED; - - Viewport *viewport=NULL; - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - viewport->disable_environment=p_disable; - -} - -void VisualServerRaster::viewport_attach_camera(RID p_viewport,RID p_camera) { - VS_CHANGED; - - Viewport *viewport=NULL; - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - - - - if (p_camera.is_valid()) { - - ERR_FAIL_COND(!camera_owner.owns(p_camera)); - // a camera - viewport->camera=p_camera; - } else { - viewport->camera; - } - -} - -void VisualServerRaster::viewport_set_scenario(RID p_viewport,RID p_scenario) { - - VS_CHANGED; - - Viewport *viewport=NULL; - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - if (p_scenario.is_valid()) { - - ERR_FAIL_COND(!scenario_owner.owns(p_scenario)); - // a camera - viewport->scenario=p_scenario; - } else { - viewport->scenario; - } - -} - -RID VisualServerRaster::viewport_get_attached_camera(RID p_viewport) const { - - const Viewport *viewport=NULL; - - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport, RID()); - - return viewport->camera; -} - -void VisualServerRaster::viewport_attach_canvas(RID p_viewport,RID p_canvas) { - VS_CHANGED; - Viewport *viewport=NULL; - - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - Canvas *canvas = canvas_owner.get( p_canvas ); - ERR_FAIL_COND(!canvas); - - ERR_EXPLAIN("Canvas already attached."); - ERR_FAIL_COND(viewport->canvas_map.has(p_canvas)); - - - Viewport::CanvasData cd; - cd.canvas=canvas; - cd.layer=0; - - viewport->canvas_map[p_canvas]=cd; - canvas->viewports.insert(p_viewport); - -} - - -void VisualServerRaster::viewport_set_canvas_transform(RID p_viewport,RID p_canvas,const Matrix32& p_transform) { - - VS_CHANGED; - Viewport *viewport=NULL; - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - Map<RID,Viewport::CanvasData>::Element *E=viewport->canvas_map.find(p_canvas); - if (!E) { - ERR_EXPLAIN("Viewport does not contain the canvas"); - ERR_FAIL_COND(!E); - } - - E->get().transform=p_transform; - -} - -Matrix32 VisualServerRaster::viewport_get_canvas_transform(RID p_viewport,RID p_canvas) const { - - Viewport *viewport=NULL; - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport,Matrix32()); - - Map<RID,Viewport::CanvasData>::Element *E=viewport->canvas_map.find(p_canvas); - if (!E) { - ERR_EXPLAIN("Viewport does not contain the canvas"); - ERR_FAIL_COND_V(!E,Matrix32()); - } - - - return E->get().transform; -} - - -void VisualServerRaster::viewport_set_global_canvas_transform(RID p_viewport,const Matrix32& p_transform) { - - VS_CHANGED - Viewport *viewport=NULL; - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - viewport->global_transform=p_transform; - -} - -Matrix32 VisualServerRaster::viewport_get_global_canvas_transform(RID p_viewport) const{ - - Viewport *viewport=NULL; - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport,Matrix32()); - return viewport->global_transform; -} - -void VisualServerRaster::viewport_remove_canvas(RID p_viewport,RID p_canvas) { - - VS_CHANGED; - Viewport *viewport=NULL; - - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - Canvas *canvas = canvas_owner.get( p_canvas ); - ERR_FAIL_COND(!canvas); - - - Map<RID,Viewport::CanvasData>::Element *E=viewport->canvas_map.find(p_canvas); - if (!E) { - ERR_EXPLAIN("Viewport does not contain the canvas"); - ERR_FAIL_COND(!E); - } - - - canvas->viewports.erase(p_viewport); - viewport->canvas_map.erase(E); - -} - - -void VisualServerRaster::viewport_set_canvas_layer(RID p_viewport,RID p_canvas,int p_layer) { - - VS_CHANGED; - Viewport *viewport=NULL; - - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - Map<RID,Viewport::CanvasData>::Element *E=viewport->canvas_map.find(p_canvas); - if (!E) { - ERR_EXPLAIN("Viewport does not contain the canvas"); - ERR_FAIL_COND(!E); - } - - E->get().layer=p_layer; - -} - -void VisualServerRaster::viewport_set_transparent_background(RID p_viewport,bool p_enabled) { - - VS_CHANGED; - Viewport *viewport=viewport_owner.get( p_viewport ); - ERR_FAIL_COND(!viewport); - - viewport->transparent_bg=p_enabled; -} - -bool VisualServerRaster::viewport_has_transparent_background(RID p_viewport) const { - - Viewport *viewport=viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport, false); - - return viewport->transparent_bg; -} - - -RID VisualServerRaster::viewport_get_scenario(RID p_viewport) const { - - const Viewport *viewport=NULL; - - viewport = viewport_owner.get( p_viewport ); - ERR_FAIL_COND_V(!viewport, RID()); - - return viewport->scenario; -} - - -RID VisualServerRaster::environment_create() { - - return rasterizer->environment_create(); -} - -void VisualServerRaster::environment_set_background(RID p_env,EnvironmentBG p_bg){ - - rasterizer->environment_set_background(p_env,p_bg); -} -VisualServer::EnvironmentBG VisualServerRaster::environment_get_background(RID p_env) const{ - - return rasterizer->environment_get_background(p_env); -} - -void VisualServerRaster::environment_set_background_param(RID p_env,EnvironmentBGParam p_param, const Variant& p_value){ - - - rasterizer->environment_set_background_param(p_env,p_param,p_value); -} -Variant VisualServerRaster::environment_get_background_param(RID p_env,EnvironmentBGParam p_param) const{ - - return rasterizer->environment_get_background_param(p_env,p_param); -} - -void VisualServerRaster::environment_set_enable_fx(RID p_env,EnvironmentFx p_effect,bool p_enabled){ - - rasterizer->environment_set_enable_fx(p_env,p_effect,p_enabled); -} -bool VisualServerRaster::environment_is_fx_enabled(RID p_env,EnvironmentFx p_effect) const{ - - return rasterizer->environment_is_fx_enabled(p_env,p_effect); -} - - -void VisualServerRaster::environment_fx_set_param(RID p_env,EnvironmentFxParam p_param,const Variant& p_value){ - - rasterizer->environment_fx_set_param(p_env,p_param,p_value); -} -Variant VisualServerRaster::environment_fx_get_param(RID p_env,EnvironmentFxParam p_param) const { - - return environment_fx_get_param(p_env,p_param); -} - - - -/* SCENARIO API */ - -void VisualServerRaster::_dependency_queue_update(RID p_rid,bool p_update_aabb,bool p_update_materials) { - - Map< RID, Set<RID> >::Element * E = instance_dependency_map.find( p_rid ); - - if (!E) - return; - - - Set<RID>::Element *I = E->get().front(); - - while(I) { - - Instance *ins = instance_owner.get( I->get() ); - _instance_queue_update( ins , p_update_aabb, p_update_materials ); - - I = I->next(); - } - -} - -void VisualServerRaster::_instance_queue_update(Instance *p_instance,bool p_update_aabb,bool p_update_materials) { - - if (p_update_aabb) - p_instance->update_aabb=true; - if (p_update_materials) - p_instance->update_materials=true; - - if (p_instance->update) - return; - p_instance->update_next=instance_update_list; - instance_update_list=p_instance; - p_instance->update=true; - -} - -RID VisualServerRaster::scenario_create() { - - Scenario *scenario = memnew( Scenario ); - ERR_FAIL_COND_V(!scenario,RID()); - RID scenario_rid = scenario_owner.make_rid( scenario ); - scenario->self=scenario_rid; - scenario->octree.set_pair_callback(instance_pair,this); - scenario->octree.set_unpair_callback(instance_unpair,this); - - return scenario_rid; -} - -void VisualServerRaster::scenario_set_debug(RID p_scenario,ScenarioDebugMode p_debug_mode) { - VS_CHANGED; - - Scenario *scenario = scenario_owner.get(p_scenario); - ERR_FAIL_COND(!scenario); - scenario->debug=p_debug_mode; -} - -void VisualServerRaster::scenario_set_environment(RID p_scenario, RID p_environment) { - - VS_CHANGED; - - Scenario *scenario = scenario_owner.get(p_scenario); - ERR_FAIL_COND(!scenario); - scenario->environment=p_environment; - -} - -void VisualServerRaster::scenario_set_fallback_environment(RID p_scenario, RID p_environment) { - - VS_CHANGED; - - Scenario *scenario = scenario_owner.get(p_scenario); - ERR_FAIL_COND(!scenario); - scenario->fallback_environment=p_environment; - - -} - -RID VisualServerRaster::scenario_get_environment(RID p_scenario, RID p_environment) const{ - - const Scenario *scenario = scenario_owner.get(p_scenario); - ERR_FAIL_COND_V(!scenario,RID()); - return scenario->environment; - -} - - -/* INSTANCING API */ - - -RID VisualServerRaster::instance_create() { - - Instance *instance = memnew( Instance ); - ERR_FAIL_COND_V(!instance,RID()); - - RID instance_rid = instance_owner.make_rid(instance); - instance->self=instance_rid; - instance->base_type=INSTANCE_NONE; - instance->scenario=NULL; - - return instance_rid; -} - -void VisualServerRaster::instance_set_base(RID p_instance, RID p_base) { - - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - if (instance->base_type!=INSTANCE_NONE) { - //free anything related to that base - - Map< RID, Set<RID> >::Element * E = instance_dependency_map.find( instance->base_rid ); - - if (E) { - // wtf, no E? - E->get().erase( instance->self ); - - } else { - - ERR_PRINT("no base E? Bug?"); - } - - if ( instance->room ) { - - instance_set_room(p_instance,RID()); - /* - if((1<<instance->base_type)&INSTANCE_GEOMETRY_MASK) - instance->room->room_info->owned_geometry_instances.erase(instance->RE); - else if (instance->base_type==INSTANCE_PORTAL) { - print_line("freeing portal, is it there? "+itos(instance->room->room_info->owned_portal_instances.(instance->RE))); - instance->room->room_info->owned_portal_instances.erase(instance->RE); - } else if (instance->base_type==INSTANCE_ROOM) - instance->room->room_info->owned_room_instances.erase(instance->RE); - else if (instance->base_type==INSTANCE_LIGHT) - instance->room->room_info->owned_light_instances.erase(instance->RE); - - instance->RE=NULL;*/ - } - - - - - - if (instance->light_info) { - - if (instance->scenario && instance->light_info->D) - instance->scenario->directional_lights.erase( instance->light_info->D ); - rasterizer->free(instance->light_info->instance); - memdelete(instance->light_info); - instance->light_info=NULL; - } - - - if (instance->portal_info) { - - _portal_disconnect(instance,true); - memdelete(instance->portal_info); - instance->portal_info=NULL; - - } - - if (instance->baked_light_info) { - - while(instance->baked_light_info->owned_instances.size()) { - - Instance *owned=instance->baked_light_info->owned_instances.front()->get(); - owned->baked_light=NULL; - owned->data.baked_light=NULL; - owned->data.baked_light_octree_xform=NULL; - owned->BLE=NULL; - instance->baked_light_info->owned_instances.pop_front(); - } - - memdelete(instance->baked_light_info); - instance->baked_light_info=NULL; - - } - - if (instance->scenario && instance->octree_id) { - instance->scenario->octree.erase( instance->octree_id ); - instance->octree_id=0; - } - - - if (instance->room_info) { - - for(List<Instance*>::Element *E=instance->room_info->owned_geometry_instances.front();E;E=E->next()) { - - Instance *owned = E->get(); - owned->room=NULL; - owned->RE=NULL; - } - for(List<Instance*>::Element *E=instance->room_info->owned_portal_instances.front();E;E=E->next()) { - - _portal_disconnect(E->get(),true); - Instance *owned = E->get(); - owned->room=NULL; - owned->RE=NULL; - } - - for(List<Instance*>::Element *E=instance->room_info->owned_room_instances.front();E;E=E->next()) { - - Instance *owned = E->get(); - owned->room=NULL; - owned->RE=NULL; - } - - if (instance->room_info->disconnected_child_portals.size()) { - ERR_PRINT("BUG: Disconnected portals remain!"); - } - memdelete(instance->room_info); - instance->room_info=NULL; - - } - - if (instance->particles_info) { - - rasterizer->free( instance->particles_info->instance ); - memdelete(instance->particles_info); - instance->particles_info=NULL; - - } - - if (instance->baked_light_sampler_info) { - - while (instance->baked_light_sampler_info->owned_instances.size()) { - - instance_geometry_set_baked_light_sampler(instance->baked_light_sampler_info->owned_instances.front()->get()->self,RID()); - } - - if (instance->baked_light_sampler_info->sampled_light.is_valid()) { - rasterizer->free(instance->baked_light_sampler_info->sampled_light); - } - memdelete( instance->baked_light_sampler_info ); - instance->baked_light_sampler_info=NULL; - } - - instance->data.morph_values.clear(); - instance->data.materials.clear(); - - } - - - instance->base_type=INSTANCE_NONE; - instance->base_rid; - - - if (p_base.is_valid()) { - - if (rasterizer->is_mesh(p_base)) { - instance->base_type=INSTANCE_MESH; - instance->data.morph_values.resize( rasterizer->mesh_get_morph_target_count(p_base)); - instance->data.materials.resize( rasterizer->mesh_get_surface_count(p_base)); - } else if (rasterizer->is_multimesh(p_base)) { - instance->base_type=INSTANCE_MULTIMESH; - } else if (rasterizer->is_immediate(p_base)) { - instance->base_type=INSTANCE_IMMEDIATE; - } else if (rasterizer->is_particles(p_base)) { - instance->base_type=INSTANCE_PARTICLES; - instance->particles_info=memnew( Instance::ParticlesInfo ); - instance->particles_info->instance = rasterizer->particles_instance_create( p_base ); - } else if (rasterizer->is_light(p_base)) { - - instance->base_type=INSTANCE_LIGHT; - instance->light_info = memnew( Instance::LightInfo ); - instance->light_info->instance = rasterizer->light_instance_create(p_base); - if (instance->scenario && rasterizer->light_get_type(p_base)==LIGHT_DIRECTIONAL) { - - instance->light_info->D = instance->scenario->directional_lights.push_back(instance->self); - } - - } else if (room_owner.owns(p_base)) { - instance->base_type=INSTANCE_ROOM; - instance->room_info = memnew( Instance::RoomInfo ); - instance->room_info->room=room_owner.get(p_base); - } else if (portal_owner.owns(p_base)) { - - instance->base_type=INSTANCE_PORTAL; - instance->portal_info = memnew(Instance::PortalInfo); - instance->portal_info->portal=portal_owner.get(p_base); - } else if (baked_light_owner.owns(p_base)) { - - instance->base_type=INSTANCE_BAKED_LIGHT; - instance->baked_light_info=memnew(Instance::BakedLightInfo); - instance->baked_light_info->baked_light=baked_light_owner.get(p_base); - - //instance->portal_info = memnew(Instance::PortalInfo); - //instance->portal_info->portal=portal_owner.get(p_base); - } else if (baked_light_sampler_owner.owns(p_base)) { - - - instance->base_type=INSTANCE_BAKED_LIGHT_SAMPLER; - instance->baked_light_sampler_info=memnew( Instance::BakedLightSamplerInfo); - instance->baked_light_sampler_info->sampler=baked_light_sampler_owner.get(p_base); - - //instance->portal_info = memnew(Instance::PortalInfo); - //instance->portal_info->portal=portal_owner.get(p_base); - - } else { - ERR_EXPLAIN("Invalid base RID for instance!") - ERR_FAIL(); - } - - instance_dependency_map[ p_base ].insert( instance->self ); - - instance->base_rid=p_base; - - if (instance->scenario) - _instance_queue_update(instance,true); - } - -} - -RID VisualServerRaster::instance_get_base(RID p_instance) const { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, RID() ); - return instance->base_rid; - -} - -void VisualServerRaster::instance_set_scenario(RID p_instance, RID p_scenario) { - - VS_CHANGED; - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - if (instance->scenario) { - - Map< RID, Set<RID> >::Element *E = instance_dependency_map.find( instance->scenario->self ); - - if (E) { - // wtf, no E? - E->get().erase( instance->self ); - - } else { - - ERR_PRINT("no scenario E? Bug?"); - } - - if (instance->light_info) { - - if (instance->light_info->D) - instance->scenario->directional_lights.erase( instance->light_info->D ); - } - - if (instance->portal_info) { - - _portal_disconnect(instance,true); - } - - if (instance->octree_id) { - instance->scenario->octree.erase( instance->octree_id ); - instance->octree_id=0; - } - - instance->scenario=NULL; - } - - - if (p_scenario.is_valid()) { - Scenario *scenario = scenario_owner.get( p_scenario ); - ERR_FAIL_COND(!scenario); - - instance->scenario=scenario; - - instance_dependency_map[ p_scenario ].insert( instance->self ); - instance->scenario=scenario; - - if (instance->base_type==INSTANCE_LIGHT && rasterizer->light_get_type(instance->base_rid)==LIGHT_DIRECTIONAL) { - - instance->light_info->D = instance->scenario->directional_lights.push_back(instance->self); - } - - _instance_queue_update(instance,true); - } - -} -RID VisualServerRaster::instance_get_scenario(RID p_instance) const { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, RID() ); - if (instance->scenario) - return instance->scenario->self; - else - return RID(); - - -} - - -void VisualServerRaster::instance_set_layer_mask(RID p_instance, uint32_t p_mask) { - - VS_CHANGED; - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - instance->layer_mask=p_mask; - -} - -uint32_t VisualServerRaster::instance_get_layer_mask(RID p_instance) const{ - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, 0 ); - - return instance->layer_mask; -} - - -AABB VisualServerRaster::instance_get_base_aabb(RID p_instance) const { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, AABB() ); - return instance->aabb; - -} - -void VisualServerRaster::instance_attach_object_instance_id(RID p_instance,uint32_t p_ID) { - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - instance->object_ID=p_ID; -} -uint32_t VisualServerRaster::instance_get_object_instance_id(RID p_instance) const { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, 0 ); - return instance->object_ID; - -} - -void VisualServerRaster::instance_attach_skeleton(RID p_instance,RID p_skeleton) { - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - if (instance->data.skeleton.is_valid()) { - skeleton_dependency_map[instance->data.skeleton].erase(instance); - } - - instance->data.skeleton=p_skeleton; - - if (instance->data.skeleton.is_valid()) { - skeleton_dependency_map[instance->data.skeleton].insert(instance); - } - -} - -RID VisualServerRaster::instance_get_skeleton(RID p_instance) const { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, RID() ); - return instance->data.skeleton; - -} - -void VisualServerRaster::instance_set_morph_target_weight(RID p_instance,int p_shape, float p_weight) { - - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - ERR_FAIL_INDEX( p_shape, instance->data.morph_values.size() ); - instance->data.morph_values[p_shape]=p_weight; -} - -float VisualServerRaster::instance_get_morph_target_weight(RID p_instance,int p_shape) const { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, 0 ); - ERR_FAIL_INDEX_V( p_shape, instance->data.morph_values.size(), 0 ); - return instance->data.morph_values[p_shape]; -} - -void VisualServerRaster::instance_set_surface_material(RID p_instance,int p_surface, RID p_material) { - - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance); - ERR_FAIL_INDEX( p_surface, instance->data.materials.size() ); - instance->data.materials[p_surface]=p_material; -} - - -void VisualServerRaster::instance_set_transform(RID p_instance, const Transform& p_transform) { - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - if (p_transform==instance->data.transform) // must improve somehow - return; - - instance->data.transform=p_transform; - if (instance->base_type==INSTANCE_LIGHT) - instance->data.transform.orthonormalize(); - _instance_queue_update(instance); - -} - -Transform VisualServerRaster::instance_get_transform(RID p_instance) const { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, Transform() ); - - return instance->data.transform; - -} - -void VisualServerRaster::instance_set_exterior( RID p_instance, bool p_enabled ) { - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - ERR_EXPLAIN("Portals can't be assigned to be exterior"); - - ERR_FAIL_COND( instance->base_type == INSTANCE_PORTAL ); - if (instance->exterior==p_enabled) - return; - instance->exterior=p_enabled; - _instance_queue_update( instance ); - - -} - -bool VisualServerRaster::instance_is_exterior( RID p_instance) const { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, false ); - - return instance->exterior; -} - - -void VisualServerRaster::instance_set_room( RID p_instance, RID p_room ) { - VS_CHANGED; - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - if (instance->room && instance->RE) { - - //instance already havs a room, remove it from there - - if ( (1<<instance->base_type) & INSTANCE_GEOMETRY_MASK ) { - - instance->room->room_info->owned_geometry_instances.erase(instance->RE); - - if (!p_room.is_valid() && instance->octree_id) { - //remove from the octree, so it's re-added with different flags - instance->scenario->octree.erase( instance->octree_id ); - instance->octree_id=0; - _instance_queue_update( instance,true ); - } - - - } else if ( instance->base_type==INSTANCE_ROOM ) { - - instance->room->room_info->owned_room_instances.erase(instance->RE); - - for(List<Instance*>::Element *E=instance->room_info->owned_portal_instances.front();E;E=E->next()) { - _portal_disconnect(E->get()); - _instance_queue_update( E->get(),false ); - } - - } else if ( instance->base_type==INSTANCE_PORTAL ) { - - _portal_disconnect(instance,true); - bool ss = instance->room->room_info->owned_portal_instances.erase(instance->RE); - - } else if ( instance->base_type==INSTANCE_LIGHT ) { - - instance->room->room_info->owned_light_instances.erase(instance->RE); - } else { - - ERR_FAIL(); - - } - - instance->RE=NULL; - instance->room=NULL; - - - } else { - - if (p_room.is_valid() && instance->octree_id) { - //remove from the octree, so it's re-added with different flags - instance->scenario->octree.erase( instance->octree_id ); - instance->octree_id=0; - _instance_queue_update( instance,true ); - } - - } - - if (!p_room.is_valid()) - return; // just clearning the room - - Instance *room = instance_owner.get( p_room ); - - ERR_FAIL_COND( !room ); - ERR_FAIL_COND( room->base_type!=INSTANCE_ROOM ); - - - if (instance->base_type==INSTANCE_ROOM) { - - //perform cycle test - - Instance *parent = instance; - - while(parent) { - - ERR_EXPLAIN("Cycle in room assignment"); - ERR_FAIL_COND( parent == room ); - parent=parent->room; - } - } - - if ( (1<<instance->base_type) & INSTANCE_GEOMETRY_MASK ) { - - instance->RE = room->room_info->owned_geometry_instances.push_back(instance); - } else if ( instance->base_type==INSTANCE_ROOM ) { - - instance->RE = room->room_info->owned_room_instances.push_back(instance); - for(List<Instance*>::Element *E=instance->room_info->owned_portal_instances.front();E;E=E->next()) - _instance_queue_update( E->get(),false ); - - - } else if ( instance->base_type==INSTANCE_PORTAL ) { - - instance->RE = room->room_info->owned_portal_instances.push_back(instance); - } else if ( instance->base_type==INSTANCE_LIGHT ) { - - instance->RE = room->room_info->owned_light_instances.push_back(instance); - } else { - - ERR_FAIL(); - - } - - instance->room=room; -} - -RID VisualServerRaster::instance_get_room( RID p_instance ) const { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, RID() ); - - if (instance->room) - return instance->room->self; - else - return RID(); -} - -void VisualServerRaster::instance_set_extra_visibility_margin( RID p_instance, real_t p_margin ) { - - VS_CHANGED; - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - instance->extra_margin=p_margin; -} -real_t VisualServerRaster::instance_get_extra_visibility_margin( RID p_instance ) const{ - - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, 0 ); - - return instance->extra_margin; -} - - -Vector<RID> VisualServerRaster::instances_cull_aabb(const AABB& p_aabb, RID p_scenario) const { - - - Vector<RID> instances; - Scenario *scenario=scenario_owner.get(p_scenario); - ERR_FAIL_COND_V(!scenario,instances); - - const_cast<VisualServerRaster*>(this)->_update_instances(); // check dirty instances before culling - - int culled=0; - Instance *cull[1024]; - culled=scenario->octree.cull_aabb(p_aabb,cull,1024); - - for (int i=0;i<culled;i++) { - - Instance *instance=cull[i]; - ERR_CONTINUE(!instance); - instances.push_back(instance->self); - } - - return instances; -} -Vector<RID> VisualServerRaster::instances_cull_ray(const Vector3& p_from, const Vector3& p_to, RID p_scenario) const{ - - Vector<RID> instances; - Scenario *scenario=scenario_owner.get(p_scenario); - ERR_FAIL_COND_V(!scenario,instances); - const_cast<VisualServerRaster*>(this)->_update_instances(); // check dirty instances before culling - - int culled=0; - Instance *cull[1024]; - culled=scenario->octree.cull_segment(p_from,p_to*10000,cull,1024); - - - for (int i=0;i<culled;i++) { - - Instance *instance=cull[i]; - ERR_CONTINUE(!instance); - instances.push_back(instance->self); - } - - return instances; - -} -Vector<RID> VisualServerRaster::instances_cull_convex(const Vector<Plane>& p_convex, RID p_scenario) const{ - - Vector<RID> instances; - Scenario *scenario=scenario_owner.get(p_scenario); - ERR_FAIL_COND_V(!scenario,instances); - const_cast<VisualServerRaster*>(this)->_update_instances(); // check dirty instances before culling - - int culled=0; - Instance *cull[1024]; - - - culled=scenario->octree.cull_convex(p_convex,cull,1024); - - for (int i=0;i<culled;i++) { - - Instance *instance=cull[i]; - ERR_CONTINUE(!instance); - instances.push_back(instance->self); - } - - return instances; - -} - -void VisualServerRaster::instance_geometry_set_flag(RID p_instance,InstanceFlags p_flags,bool p_enabled) { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - //ERR_FAIL_COND( ! ( (1<<instance->base_type) & INSTANCE_GEOMETRY_MASK) ); - - switch(p_flags) { - - case INSTANCE_FLAG_VISIBLE: { - - instance->visible=p_enabled; - - } break; - case INSTANCE_FLAG_BILLBOARD: { - - instance->data.billboard=p_enabled; - - } break; - case INSTANCE_FLAG_BILLBOARD_FIX_Y: { - - instance->data.billboard_y=p_enabled; - - } break; - case INSTANCE_FLAG_CAST_SHADOW: { - if (p_enabled == true) { - instance->data.cast_shadows = SHADOW_CASTING_SETTING_ON; - } - else { - instance->data.cast_shadows = SHADOW_CASTING_SETTING_OFF; - } - - } break; - case INSTANCE_FLAG_RECEIVE_SHADOWS: { - - instance->data.receive_shadows=p_enabled; - - } break; - case INSTANCE_FLAG_DEPH_SCALE: { - - instance->data.depth_scale=p_enabled; - - } break; - case INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS: { - - instance->visible_in_all_rooms=p_enabled; - - } break; - - } - -} - -bool VisualServerRaster::instance_geometry_get_flag(RID p_instance,InstanceFlags p_flags) const{ - - const Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, false ); - //ERR_FAIL_COND_V( ! ( (1<<instance->base_type) & INSTANCE_GEOMETRY_MASK), false ); - - switch(p_flags) { - - case INSTANCE_FLAG_VISIBLE: { - - return instance->visible; - - } break; - case INSTANCE_FLAG_BILLBOARD: { - - return instance->data.billboard; - - } break; - case INSTANCE_FLAG_BILLBOARD_FIX_Y: { - - return instance->data.billboard_y; - - } break; - case INSTANCE_FLAG_CAST_SHADOW: { - if(instance->data.cast_shadows == SHADOW_CASTING_SETTING_OFF) { - return false; - } - else { - return true; - } - - } break; - case INSTANCE_FLAG_RECEIVE_SHADOWS: { - - return instance->data.receive_shadows; - - } break; - case INSTANCE_FLAG_DEPH_SCALE: { - - return instance->data.depth_scale; - - } break; - case INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS: { - - return instance->visible_in_all_rooms; - - } break; - - } - - return false; -} - -void VisualServerRaster::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - instance->data.cast_shadows = p_shadow_casting_setting; -} - -VS::ShadowCastingSetting VisualServerRaster::instance_geometry_get_cast_shadows_setting(RID p_instance) const{ - - const Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, SHADOW_CASTING_SETTING_OFF ); - - return instance->data.cast_shadows; -} - - -void VisualServerRaster::instance_geometry_set_material_override(RID p_instance, RID p_material) { - - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - instance->data.material_override=p_material; - -} - -RID VisualServerRaster::instance_geometry_get_material_override(RID p_instance) const{ - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance, RID() ); - return instance->data.material_override; - -} - -void VisualServerRaster::instance_geometry_set_draw_range(RID p_instance,float p_min,float p_max){ - - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - instance->draw_range_begin=p_min; - instance->draw_range_end=p_max; - -} - -float VisualServerRaster::instance_geometry_get_draw_range_min(RID p_instance) const{ - - const Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance,0 ); - - return instance->draw_range_begin; - - -} - -float VisualServerRaster::instance_geometry_get_draw_range_max(RID p_instance) const{ - - const Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance,0 ); - - return instance->draw_range_end; - - -} - - -void VisualServerRaster::instance_geometry_set_baked_light(RID p_instance,RID p_baked_light) { - - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - - if (instance->baked_light) { - - - instance->baked_light->baked_light_info->owned_instances.erase(instance->BLE); - instance->BLE=NULL; - instance->baked_light=NULL; - instance->data.baked_light=NULL; - instance->data.baked_light_octree_xform=NULL; - - } - - if (!p_baked_light.is_valid()) - return; - Instance *bl_instance = instance_owner.get( p_baked_light ); - ERR_FAIL_COND( !bl_instance ); - ERR_FAIL_COND( bl_instance->base_type!=INSTANCE_BAKED_LIGHT ); - - instance->baked_light=bl_instance; - instance->BLE=bl_instance->baked_light_info->owned_instances.push_back(instance); - instance->data.baked_light=&bl_instance->baked_light_info->baked_light->data; - instance->data.baked_light_octree_xform=&bl_instance->baked_light_info->affine_inverse; - -} - -RID VisualServerRaster::instance_geometry_get_baked_light(RID p_instance) const{ - - const Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance,RID() ); - if (instance->baked_light) - return instance->baked_light->self; - return RID(); - -} - - -void VisualServerRaster::instance_geometry_set_baked_light_sampler(RID p_instance,RID p_baked_light_sampler) { - - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - if (instance->sampled_light) { - instance->sampled_light->baked_light_sampler_info->owned_instances.erase(instance); - instance->data.sampled_light; - } - - if(p_baked_light_sampler.is_valid()) { - Instance *sampler_instance = instance_owner.get( p_baked_light_sampler ); - ERR_FAIL_COND( !sampler_instance ); - ERR_FAIL_COND( sampler_instance->base_type!=INSTANCE_BAKED_LIGHT_SAMPLER ); - instance->sampled_light=sampler_instance; - instance->sampled_light->baked_light_sampler_info->owned_instances.insert(instance); - } else { - instance->sampled_light=NULL; - } - - instance->data.sampled_light; - -} - -RID VisualServerRaster::instance_geometry_get_baked_light_sampler(RID p_instance) const { - - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance,RID() ); - - if (instance->sampled_light) - return instance->sampled_light->self; - else - return RID(); - -} - - -void VisualServerRaster::instance_geometry_set_baked_light_texture_index(RID p_instance,int p_tex_id){ - - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - - instance->data.baked_lightmap_id=p_tex_id; - - -} -int VisualServerRaster::instance_geometry_get_baked_light_texture_index(RID p_instance) const{ - - const Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance,0 ); - - return instance->data.baked_lightmap_id; - -} - - -void VisualServerRaster::_update_instance(Instance *p_instance) { - - p_instance->version++; - - if (p_instance->base_type == INSTANCE_LIGHT) { - - rasterizer->light_instance_set_transform( p_instance->light_info->instance, p_instance->data.transform ); - - } - - - if (p_instance->aabb.has_no_surface()) - return; - - - if (p_instance->base_type == INSTANCE_PARTICLES) { - - rasterizer->particles_instance_set_transform( p_instance->particles_info->instance, p_instance->data.transform ); - } - - - if ((1<<p_instance->base_type)&INSTANCE_GEOMETRY_MASK) { - - //make sure lights are updated - InstanceSet::Element *E=p_instance->lights.front(); - while(E) { - - E->get()->version++; - E=E->next(); - } - - } else if (p_instance->base_type == INSTANCE_ROOM) { - - p_instance->room_info->affine_inverse=p_instance->data.transform.affine_inverse(); - } else if (p_instance->base_type == INSTANCE_BAKED_LIGHT) { - - Transform scale; - scale.basis.scale(p_instance->baked_light_info->baked_light->octree_aabb.size); - scale.origin=p_instance->baked_light_info->baked_light->octree_aabb.pos; - //print_line("scale: "+scale); - p_instance->baked_light_info->affine_inverse=(p_instance->data.transform*scale).affine_inverse(); - } - - - - p_instance->data.mirror = p_instance->data.transform.basis.determinant() < 0.0; - - AABB new_aabb; - - if (p_instance->base_type==INSTANCE_PORTAL) { - - //portals need to be transformed in a special way, so they don't become too wide if they have scale.. - Transform portal_xform = p_instance->data.transform; - portal_xform.basis.set_axis(2,portal_xform.basis.get_axis(2).normalized()); - - p_instance->portal_info->plane_cache=Plane( p_instance->data.transform.origin, portal_xform.basis.get_axis(2)); - int point_count=p_instance->portal_info->portal->shape.size(); - p_instance->portal_info->transformed_point_cache.resize(point_count); - - AABB portal_aabb; - - for(int i=0;i<point_count;i++) { - - Point2 src = p_instance->portal_info->portal->shape[i]; - Vector3 point = portal_xform.xform(Vector3(src.x,src.y,0)); - p_instance->portal_info->transformed_point_cache[i]=point; - if (i==0) - portal_aabb.pos=point; - else - portal_aabb.expand_to(point); - } - - portal_aabb.grow_by(p_instance->portal_info->portal->connect_range); - - new_aabb = portal_aabb; - - } else { - - new_aabb = p_instance->data.transform.xform(p_instance->aabb); - } - - - for(InstanceSet::Element *E=p_instance->lights.front();E;E=E->next()) { - Instance *light = E->get(); - light->version++; - } - - - p_instance->transformed_aabb=new_aabb; - - if (!p_instance->scenario) { - - - return; - } - - - - if (p_instance->octree_id==0) { - - uint32_t base_type = 1<<p_instance->base_type; - uint32_t pairable_mask=0; - bool pairable=false; - - if (p_instance->base_type == INSTANCE_LIGHT) { - - pairable_mask=p_instance->light_info->enabled?INSTANCE_GEOMETRY_MASK:0; - pairable=true; - } - - if (p_instance->base_type == INSTANCE_PORTAL) { - - pairable_mask=(1<<INSTANCE_PORTAL); - pairable=true; - } - - if (p_instance->base_type == INSTANCE_BAKED_LIGHT_SAMPLER) { - - pairable_mask=(1<<INSTANCE_BAKED_LIGHT); - pairable=true; - } - - - if (!p_instance->room && (1<<p_instance->base_type)&INSTANCE_GEOMETRY_MASK) { - - base_type|=INSTANCE_ROOMLESS_MASK; - } - - if (p_instance->base_type == INSTANCE_ROOM) { - - pairable_mask=INSTANCE_ROOMLESS_MASK; - pairable=true; - } - - - // not inside octree - p_instance->octree_id = p_instance->scenario->octree.create(p_instance,new_aabb,0,pairable,base_type,pairable_mask); - - } else { - - /* - if (new_aabb==p_instance->data.transformed_aabb) - return; - */ - - p_instance->scenario->octree.move(p_instance->octree_id,new_aabb); - } - - if (p_instance->base_type==INSTANCE_PORTAL) { - - _portal_attempt_connect(p_instance); - } - - if (!p_instance->room && (1<<p_instance->base_type)&INSTANCE_GEOMETRY_MASK) { - - _instance_validate_autorooms(p_instance); - } - - if (p_instance->base_type == INSTANCE_ROOM) { - - for(Set<Instance*>::Element *E=p_instance->room_info->owned_autoroom_geometry.front();E;E=E->next()) - _instance_validate_autorooms(E->get()); - } - - -} - -void VisualServerRaster::_update_instance_aabb(Instance *p_instance) { - - AABB new_aabb; - - ERR_FAIL_COND(p_instance->base_type!=INSTANCE_NONE && !p_instance->base_rid.is_valid()); - - switch(p_instance->base_type) { - case VisualServer::INSTANCE_NONE: { - - // do nothing - } break; - case VisualServer::INSTANCE_MESH: { - - new_aabb = rasterizer->mesh_get_aabb(p_instance->base_rid,p_instance->data.skeleton); - - } break; - case VisualServer::INSTANCE_MULTIMESH: { - - new_aabb = rasterizer->multimesh_get_aabb(p_instance->base_rid); - - } break; - case VisualServer::INSTANCE_IMMEDIATE: { - - new_aabb = rasterizer->immediate_get_aabb(p_instance->base_rid); - - - } break; - case VisualServer::INSTANCE_PARTICLES: { - - new_aabb = rasterizer->particles_get_aabb(p_instance->base_rid); - - - } break; - case VisualServer::INSTANCE_LIGHT: { - - new_aabb = rasterizer->light_get_aabb(p_instance->base_rid); - - } break; - case VisualServer::INSTANCE_ROOM: { - - Room *room = room_owner.get( p_instance->base_rid ); - ERR_FAIL_COND(!room); - new_aabb=room->bounds.get_aabb(); - - } break; - case VisualServer::INSTANCE_PORTAL: { - - Portal *portal = portal_owner.get( p_instance->base_rid ); - ERR_FAIL_COND(!portal); - for (int i=0;i<portal->shape.size();i++) { - - Vector3 point( portal->shape[i].x, portal->shape[i].y, 0 ); - if (i==0) { - - new_aabb.pos=point; - new_aabb.size.z=0.01; // make it not flat for octree - } else { - - new_aabb.expand_to(point); - } - } - - } break; - case VisualServer::INSTANCE_BAKED_LIGHT: { - - BakedLight *baked_light = baked_light_owner.get( p_instance->base_rid ); - ERR_FAIL_COND(!baked_light); - new_aabb=baked_light->octree_aabb; - - } break; - case VisualServer::INSTANCE_BAKED_LIGHT_SAMPLER: { - - BakedLightSampler *baked_light_sampler = baked_light_sampler_owner.get( p_instance->base_rid ); - ERR_FAIL_COND(!baked_light_sampler); - float radius = baked_light_sampler->params[VS::BAKED_LIGHT_SAMPLER_RADIUS]; - - new_aabb=AABB(Vector3(-radius,-radius,-radius),Vector3(radius*2,radius*2,radius*2)); - - } break; - - default: {} - } - - if (p_instance->extra_margin) - new_aabb.grow_by(p_instance->extra_margin); - - p_instance->aabb=new_aabb; - -} - -void VisualServerRaster::_update_instances() { - - while(instance_update_list) { - - Instance *instance=instance_update_list; - - instance_update_list=instance_update_list->update_next; - - if (instance->update_aabb) - _update_instance_aabb(instance); - - if (instance->update_materials) { - if (instance->base_type==INSTANCE_MESH) { - instance->data.materials.resize(rasterizer->mesh_get_surface_count(instance->base_rid)); - } - } - - _update_instance(instance); - - instance->update=false; - instance->update_aabb=false; - instance->update_materials=false; - instance->update_next=0; - } -} - -void VisualServerRaster::instance_light_set_enabled(RID p_instance,bool p_enabled) { - - VS_CHANGED; - Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND( !instance ); - ERR_FAIL_COND( instance->base_type!=INSTANCE_LIGHT ); - - if (p_enabled==instance->light_info->enabled) - return; - - instance->light_info->enabled=p_enabled; - if (light_get_type(instance->base_rid)!=VS::LIGHT_DIRECTIONAL && instance->octree_id && instance->scenario) - instance->scenario->octree.set_pairable(instance->octree_id,p_enabled,1<<INSTANCE_LIGHT,p_enabled?INSTANCE_GEOMETRY_MASK:0); - - //_instance_queue_update( instance , true ); - -} - -bool VisualServerRaster::instance_light_is_enabled(RID p_instance) const { - - const Instance *instance = instance_owner.get( p_instance ); - ERR_FAIL_COND_V( !instance,false ); - ERR_FAIL_COND_V( instance->base_type!=INSTANCE_LIGHT,false ); - - return instance->light_info->enabled; -} - -/****** CANVAS *********/ -RID VisualServerRaster::canvas_create() { - - Canvas * canvas = memnew( Canvas ); - ERR_FAIL_COND_V(!canvas,RID()); - RID rid = canvas_owner.make_rid( canvas ); - - return rid; -} - - -void VisualServerRaster::canvas_set_item_mirroring(RID p_canvas,RID p_item,const Point2& p_mirroring) { - - Canvas * canvas = canvas_owner.get(p_canvas); - ERR_FAIL_COND(!canvas); - CanvasItem *canvas_item = canvas_item_owner.get(p_item); - ERR_FAIL_COND(!canvas_item); - - int idx = canvas->find_item(canvas_item); - ERR_FAIL_COND(idx==-1); - canvas->child_items[idx].mirror=p_mirroring; - -} - -Point2 VisualServerRaster::canvas_get_item_mirroring(RID p_canvas,RID p_item) const { - - Canvas * canvas = canvas_owner.get(p_canvas); - ERR_FAIL_COND_V(!canvas,Point2()); - CanvasItem *canvas_item = memnew( CanvasItem ); - ERR_FAIL_COND_V(!canvas_item,Point2()); - - int idx = canvas->find_item(canvas_item); - ERR_FAIL_COND_V(idx==-1,Point2()); - return canvas->child_items[idx].mirror; -} - -void VisualServerRaster::canvas_set_modulate(RID p_canvas,const Color& p_color) { - - Canvas * canvas = canvas_owner.get(p_canvas); - ERR_FAIL_COND(!canvas); - canvas->modulate=p_color; -} - - - -RID VisualServerRaster::canvas_item_create() { - - CanvasItem *canvas_item = memnew( CanvasItem ); - ERR_FAIL_COND_V(!canvas_item,RID()); - - return canvas_item_owner.make_rid( canvas_item ); -} - -void VisualServerRaster::canvas_item_set_parent(RID p_item,RID p_parent) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - if (canvas_item->parent.is_valid()) { - - if (canvas_owner.owns(canvas_item->parent)) { - - Canvas *canvas = canvas_owner.get(canvas_item->parent); - canvas->erase_item(canvas_item); - } else if (canvas_item_owner.owns(canvas_item->parent)) { - - CanvasItem *item_owner = canvas_item_owner.get(canvas_item->parent); - item_owner->child_items.erase(canvas_item); - } - - canvas_item->parent; - } - - - if (p_parent.is_valid()) { - if (canvas_owner.owns(p_parent)) { - - Canvas *canvas = canvas_owner.get(p_parent); - Canvas::ChildItem ci; - ci.item=canvas_item; - canvas->child_items.push_back(ci); - } else if (canvas_item_owner.owns(p_parent)) { - - CanvasItem *item_owner = canvas_item_owner.get(p_parent); - item_owner->child_items.push_back(canvas_item); - - } else { - - ERR_EXPLAIN("Invalid parent"); - ERR_FAIL(); - } - - - } - - canvas_item->parent=p_parent; - - -} - -RID VisualServerRaster::canvas_item_get_parent(RID p_canvas_item) const { - - CanvasItem *canvas_item = canvas_item_owner.get( p_canvas_item ); - ERR_FAIL_COND_V(!canvas_item,RID()); - - return canvas_item->parent; -} - -void VisualServerRaster::canvas_item_set_visible(RID p_item,bool p_visible) { - - VS_CHANGED; - - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - canvas_item->visible=p_visible; -} - - -bool VisualServerRaster::canvas_item_is_visible(RID p_item) const { - - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND_V(!canvas_item,RID()); - - return canvas_item->visible; - -} - -void VisualServerRaster::canvas_item_set_light_mask(RID p_canvas_item,int p_mask) { - - VS_CHANGED; - - CanvasItem *canvas_item = canvas_item_owner.get( p_canvas_item ); - ERR_FAIL_COND(!canvas_item); - - if (canvas_item->light_mask==p_mask) - return; - VS_CHANGED; - - canvas_item->light_mask=p_mask; - -} - - -void VisualServerRaster::canvas_item_set_blend_mode(RID p_canvas_item,MaterialBlendMode p_blend) { - - VS_CHANGED; - - CanvasItem *canvas_item = canvas_item_owner.get( p_canvas_item ); - ERR_FAIL_COND(!canvas_item); - - if (canvas_item->blend_mode==p_blend) - return; - VS_CHANGED; - - canvas_item->blend_mode=p_blend; - -} - -void VisualServerRaster::canvas_item_attach_viewport(RID p_canvas_item, RID p_viewport) { - - CanvasItem *canvas_item = canvas_item_owner.get( p_canvas_item ); - ERR_FAIL_COND(!canvas_item); - - VS_CHANGED; - - canvas_item->viewport=p_viewport; - -} - - -/* -void VisualServerRaster::canvas_item_set_rect(RID p_item, const Rect2& p_rect) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - canvas_item->rect=p_rect; -}*/ - -void VisualServerRaster::canvas_item_set_clip(RID p_item, bool p_clip) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - canvas_item->clip=p_clip; -} - -void VisualServerRaster::canvas_item_set_distance_field_mode(RID p_item, bool p_distance_field) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - canvas_item->distance_field=p_distance_field; -} - - -void VisualServerRaster::canvas_item_set_transform(RID p_item, const Matrix32& p_transform) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - canvas_item->xform=p_transform; - -} - - -void VisualServerRaster::canvas_item_set_custom_rect(RID p_item, bool p_custom_rect,const Rect2& p_rect) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - canvas_item->custom_rect=p_custom_rect; - if (p_custom_rect) - canvas_item->rect=p_rect; - -} - -void VisualServerRaster::canvas_item_set_opacity(RID p_item, float p_opacity) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - canvas_item->opacity=p_opacity; - -} -float VisualServerRaster::canvas_item_get_opacity(RID p_item, float p_opacity) const { - - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND_V(!canvas_item,-1); - return canvas_item->opacity; - -} - -void VisualServerRaster::canvas_item_set_on_top(RID p_item, bool p_on_top) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - canvas_item->ontop=p_on_top; - -} - -bool VisualServerRaster::canvas_item_is_on_top(RID p_item) const{ - const CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND_V(!canvas_item,false); - return canvas_item->ontop; - -} - - -void VisualServerRaster::canvas_item_set_self_opacity(RID p_item, float p_self_opacity) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - canvas_item->self_opacity=p_self_opacity; - -} -float VisualServerRaster::canvas_item_get_self_opacity(RID p_item, float p_self_opacity) const { - - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND_V(!canvas_item,-1); - return canvas_item->self_opacity; - -} - - -void VisualServerRaster::canvas_item_add_line(RID p_item, const Point2& p_from, const Point2& p_to,const Color& p_color,float p_width,bool p_antialiased) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - CanvasItem::CommandLine * line = memnew( CanvasItem::CommandLine ); - ERR_FAIL_COND(!line); - line->color=p_color; - line->from=p_from; - line->to=p_to; - line->width=p_width; - line->antialiased=p_antialiased; - canvas_item->rect_dirty=true; - - - canvas_item->commands.push_back(line); -} - -void VisualServerRaster::canvas_item_add_rect(RID p_item, const Rect2& p_rect, const Color& p_color) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - CanvasItem::CommandRect * rect = memnew( CanvasItem::CommandRect ); - ERR_FAIL_COND(!rect); - rect->modulate=p_color; - rect->rect=p_rect; - canvas_item->rect_dirty=true; - - canvas_item->commands.push_back(rect); -} - -void VisualServerRaster::canvas_item_add_circle(RID p_item, const Point2& p_pos, float p_radius,const Color& p_color) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - CanvasItem::CommandCircle * circle = memnew( CanvasItem::CommandCircle ); - ERR_FAIL_COND(!circle); - circle->color=p_color; - circle->pos=p_pos; - circle->radius=p_radius; - - canvas_item->commands.push_back(circle); - -} - -void VisualServerRaster::canvas_item_add_texture_rect(RID p_item, const Rect2& p_rect, RID p_texture,bool p_tile,const Color& p_modulate,bool p_transpose) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - CanvasItem::CommandRect * rect = memnew( CanvasItem::CommandRect ); - ERR_FAIL_COND(!rect); - rect->modulate=p_modulate; - rect->rect=p_rect; - rect->flags=0; - if (p_tile) { - rect->flags|=Rasterizer::CANVAS_RECT_TILE; - rect->flags|=Rasterizer::CANVAS_RECT_REGION; - rect->source=Rect2(0,0,p_rect.size.width,p_rect.size.height); - } - - if (p_rect.size.x<0) { - - rect->flags|=Rasterizer::CANVAS_RECT_FLIP_H; - rect->rect.size.x = -rect->rect.size.x; - } - if (p_rect.size.y<0) { - - rect->flags|=Rasterizer::CANVAS_RECT_FLIP_V; - rect->rect.size.y = -rect->rect.size.y; - } - if (p_transpose) { - rect->flags|=Rasterizer::CANVAS_RECT_TRANSPOSE; - SWAP(rect->rect.size.x, rect->rect.size.y); - } - rect->texture=p_texture; - canvas_item->rect_dirty=true; - canvas_item->commands.push_back(rect); -} - -void VisualServerRaster::canvas_item_add_texture_rect_region(RID p_item, const Rect2& p_rect, RID p_texture,const Rect2& p_src_rect,const Color& p_modulate,bool p_transpose) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - CanvasItem::CommandRect * rect = memnew( CanvasItem::CommandRect ); - ERR_FAIL_COND(!rect); - rect->modulate=p_modulate; - rect->rect=p_rect; - rect->texture=p_texture; - rect->source=p_src_rect; - rect->flags=Rasterizer::CANVAS_RECT_REGION; - - if (p_rect.size.x<0) { - - rect->flags|=Rasterizer::CANVAS_RECT_FLIP_H; - rect->rect.size.x = -rect->rect.size.x; - } - if (p_rect.size.y<0) { - - rect->flags|=Rasterizer::CANVAS_RECT_FLIP_V; - rect->rect.size.y = -rect->rect.size.y; - } - if (p_transpose) { - rect->flags|=Rasterizer::CANVAS_RECT_TRANSPOSE; - SWAP(rect->rect.size.x, rect->rect.size.y); - } - - canvas_item->rect_dirty=true; - - canvas_item->commands.push_back(rect); - -} - -void VisualServerRaster::canvas_item_add_style_box(RID p_item, const Rect2& p_rect, const Rect2& p_source, RID p_texture, const Vector2& p_topleft, const Vector2& p_bottomright, bool p_draw_center,const Color& p_modulate) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - CanvasItem::CommandStyle * style = memnew( CanvasItem::CommandStyle ); - ERR_FAIL_COND(!style); - style->texture=p_texture; - style->rect=p_rect; - style->source=p_source; - style->draw_center=p_draw_center; - style->color=p_modulate; - style->margin[MARGIN_LEFT]=p_topleft.x; - style->margin[MARGIN_TOP]=p_topleft.y; - style->margin[MARGIN_RIGHT]=p_bottomright.x; - style->margin[MARGIN_BOTTOM]=p_bottomright.y; - canvas_item->rect_dirty=true; - - canvas_item->commands.push_back(style); -} -void VisualServerRaster::canvas_item_add_primitive(RID p_item,const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - CanvasItem::CommandPrimitive * prim = memnew( CanvasItem::CommandPrimitive ); - ERR_FAIL_COND(!prim); - prim->texture=p_texture; - prim->points=p_points; - prim->uvs=p_uvs; - prim->colors=p_colors; - prim->width=p_width; - canvas_item->rect_dirty=true; - - canvas_item->commands.push_back(prim); -} - -void VisualServerRaster::canvas_item_add_polygon(RID p_item, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); -#ifdef DEBUG_ENABLED - int pointcount = p_points.size(); - ERR_FAIL_COND(pointcount<3); - int color_size=p_colors.size(); - int uv_size=p_uvs.size(); - ERR_FAIL_COND(color_size!=0 && color_size!=1 && color_size!=pointcount); - ERR_FAIL_COND(uv_size!=0 && (uv_size!=pointcount || !p_texture.is_valid())); -#endif - Vector<int> indices = Geometry::triangulate_polygon(p_points); - - if (indices.empty()) { - - ERR_EXPLAIN("Bad Polygon!"); - ERR_FAIL_V(); - } - - CanvasItem::CommandPolygon * polygon = memnew( CanvasItem::CommandPolygon ); - ERR_FAIL_COND(!polygon); - polygon->texture=p_texture; - polygon->points=p_points; - polygon->uvs=p_uvs; - polygon->colors=p_colors; - polygon->indices=indices; - polygon->count=indices.size(); - canvas_item->rect_dirty=true; - - canvas_item->commands.push_back(polygon); - -} - -void VisualServerRaster::canvas_item_add_triangle_array_ptr(RID p_item, int p_count, const int* p_indices, const Point2* p_points, const Color* p_colors,const Point2* p_uvs, RID p_texture) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - ERR_FAIL_COND(p_count <= 0); - - ERR_FAIL_COND(p_points == NULL); - - CanvasItem::CommandPolygonPtr * polygon = memnew( CanvasItem::CommandPolygonPtr ); - ERR_FAIL_COND(!polygon); - polygon->texture=p_texture; - polygon->points=p_points; - polygon->uvs=p_uvs; - polygon->colors=p_colors; - polygon->indices=p_indices; - polygon->count = p_count * 3; - canvas_item->rect_dirty=true; - - canvas_item->commands.push_back(polygon); -}; - -void VisualServerRaster::canvas_item_add_triangle_array(RID p_item, const Vector<int>& p_indices, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture, int p_count) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - int ps = p_points.size(); - ERR_FAIL_COND(!p_colors.empty() && p_colors.size()!=ps && p_colors.size()!=1); - ERR_FAIL_COND(!p_uvs.empty() && p_uvs.size()!=ps); - - Vector<int> indices = p_indices; - - int count = p_count * 3; - - if (indices.empty()) { - - ERR_FAIL_COND( ps % 3 != 0 ); - if (p_count == -1) - count = ps; - } else { - - ERR_FAIL_COND( indices.size() % 3 != 0 ); - if (p_count == -1) - count = indices.size(); - } - - CanvasItem::CommandPolygon * polygon = memnew( CanvasItem::CommandPolygon ); - ERR_FAIL_COND(!polygon); - polygon->texture=p_texture; - polygon->points=p_points; - polygon->uvs=p_uvs; - polygon->colors=p_colors; - polygon->indices=indices; - polygon->count = count; - canvas_item->rect_dirty=true; - - canvas_item->commands.push_back(polygon); -} - - -void VisualServerRaster::canvas_item_add_set_transform(RID p_item,const Matrix32& p_transform) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - CanvasItem::CommandTransform * tr = memnew( CanvasItem::CommandTransform ); - ERR_FAIL_COND(!tr); - tr->xform=p_transform; - - canvas_item->commands.push_back(tr); - -} - -void VisualServerRaster::canvas_item_add_set_blend_mode(RID p_item, MaterialBlendMode p_blend) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - CanvasItem::CommandBlendMode * bm = memnew( CanvasItem::CommandBlendMode ); - ERR_FAIL_COND(!bm); - bm->blend_mode = p_blend; - - canvas_item->commands.push_back(bm); -}; - -void VisualServerRaster::canvas_item_set_z(RID p_item, int p_z) { - - ERR_FAIL_COND(p_z<CANVAS_ITEM_Z_MIN || p_z>CANVAS_ITEM_Z_MAX); - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - canvas_item->z=p_z; - -} - -void VisualServerRaster::canvas_item_set_z_as_relative_to_parent(RID p_item, bool p_enable) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - canvas_item->z_relative=p_enable; - -} - -void VisualServerRaster::canvas_item_set_copy_to_backbuffer(RID p_item, bool p_enable, const Rect2& p_rect) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - if (bool(canvas_item->copy_back_buffer!=NULL) !=p_enable) { - if (p_enable) { - canvas_item->copy_back_buffer = memnew( Rasterizer::CanvasItem::CopyBackBuffer ); - } else { - memdelete(canvas_item->copy_back_buffer); - canvas_item->copy_back_buffer=NULL; - } - } - - if (p_enable) { - canvas_item->copy_back_buffer->rect=p_rect; - canvas_item->copy_back_buffer->full=p_rect==Rect2(); - } - -} - -void VisualServerRaster::canvas_item_set_use_parent_material(RID p_item, bool p_enable) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - canvas_item->use_parent_material=p_enable; - -} - -void VisualServerRaster::canvas_item_set_material(RID p_item, RID p_material) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - if (canvas_item->material) - canvas_item->material->owners.erase(canvas_item); - - canvas_item->material=NULL; - - if (canvas_item_material_owner.owns(p_material)) { - canvas_item->material=canvas_item_material_owner.get(p_material); - canvas_item->material->owners.insert(canvas_item); - } -} - -void VisualServerRaster::canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - canvas_item->sort_y=p_enable; -} - - -void VisualServerRaster::canvas_item_add_clip_ignore(RID p_item, bool p_ignore) { - - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - CanvasItem::CommandClipIgnore * ci = memnew( CanvasItem::CommandClipIgnore); - ERR_FAIL_COND(!ci); - ci->ignore=p_ignore; - - canvas_item->commands.push_back(ci); - -} - -void VisualServerRaster::canvas_item_clear(RID p_item) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - - canvas_item->clear(); - -} - -void VisualServerRaster::canvas_item_raise(RID p_item) { - VS_CHANGED; - CanvasItem *canvas_item = canvas_item_owner.get( p_item ); - ERR_FAIL_COND(!canvas_item); - - if (canvas_item->parent.is_valid()) { - - if (canvas_owner.owns(canvas_item->parent)) { - - Canvas *canvas = canvas_owner.get(canvas_item->parent); - int idx = canvas->find_item(canvas_item); - ERR_FAIL_COND(idx<0); - Canvas::ChildItem ci = canvas->child_items[idx]; - canvas->child_items.remove(idx); - canvas->child_items.push_back(ci); - - } else if (canvas_item_owner.owns(canvas_item->parent)) { - - CanvasItem *item_owner = canvas_item_owner.get(canvas_item->parent); - int idx = item_owner->child_items.find(canvas_item); - ERR_FAIL_COND(idx<0); - item_owner->child_items.remove(idx); - item_owner->child_items.push_back(canvas_item); - - } - } - -} - -/***** CANVAS LIGHT *******/ - -RID VisualServerRaster::canvas_light_create() { - - Rasterizer::CanvasLight *clight = memnew( Rasterizer::CanvasLight ); - return canvas_light_owner.make_rid(clight); -} - -void VisualServerRaster::canvas_light_attach_to_canvas(RID p_light,RID p_canvas){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - - if (clight->canvas.is_valid()) { - - Canvas *canvas = canvas_owner.get(clight->canvas); - canvas->lights.erase(clight); - } - - if (!canvas_owner.owns(p_canvas)) - p_canvas; - clight->canvas=p_canvas; - - if (clight->canvas.is_valid()) { - - Canvas *canvas = canvas_owner.get(clight->canvas); - canvas->lights.insert(clight); - } - - - -} -void VisualServerRaster::canvas_light_set_enabled(RID p_light, bool p_enabled){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->enabled=p_enabled; - -} -void VisualServerRaster::canvas_light_set_transform(RID p_light, const Matrix32& p_transform){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->xform=p_transform; - -} -void VisualServerRaster::canvas_light_set_scale(RID p_light, float p_scale) { - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->scale=p_scale; - -} - - -void VisualServerRaster::canvas_light_set_texture(RID p_light, RID p_texture){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->texture=p_texture; - -} -void VisualServerRaster::canvas_light_set_texture_offset(RID p_light, const Vector2& p_offset){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->texture_offset=p_offset; - -} -void VisualServerRaster::canvas_light_set_color(RID p_light, const Color& p_color){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->color=p_color; - - -} -void VisualServerRaster::canvas_light_set_height(RID p_light, float p_height){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->height=p_height; - -} - -void VisualServerRaster::canvas_light_set_energy(RID p_light, float p_energy){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->energy=p_energy; - -} - -void VisualServerRaster::canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->z_min=p_min_z; - clight->z_max=p_max_z; - -} - -void VisualServerRaster::canvas_light_set_layer_range(RID p_light, int p_min_layer,int p_max_layer) { - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->layer_min=p_min_layer; - clight->layer_max=p_max_layer; - -} - -void VisualServerRaster::canvas_light_set_item_mask(RID p_light, int p_mask){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->item_mask=p_mask; - -} - -void VisualServerRaster::canvas_light_set_item_shadow_mask(RID p_light, int p_mask){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->item_shadow_mask=p_mask; - -} - - -void VisualServerRaster::canvas_light_set_mode(RID p_light, CanvasLightMode p_mode) { - - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->mode=p_mode; - -} -void VisualServerRaster::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - - if (clight->shadow_buffer.is_valid()==p_enabled) - return; - if (p_enabled) { - clight->shadow_buffer=rasterizer->canvas_light_shadow_buffer_create(clight->shadow_buffer_size); - } else { - rasterizer->free(clight->shadow_buffer); - clight->shadow_buffer; - - } - -} - -void VisualServerRaster::canvas_light_set_shadow_buffer_size(RID p_light, int p_size){ - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - - ERR_FAIL_COND(p_size<32 || p_size>16384); - - clight->shadow_buffer_size=next_power_of_2(p_size); - - - if (clight->shadow_buffer.is_valid()) { - rasterizer->free(clight->shadow_buffer); - clight->shadow_buffer=rasterizer->canvas_light_shadow_buffer_create(clight->shadow_buffer_size); - } - -} - -void VisualServerRaster::canvas_light_set_shadow_esm_multiplier(RID p_light, float p_multiplier) { - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->shadow_esm_mult=p_multiplier; - -} - -void VisualServerRaster::canvas_light_set_shadow_color(RID p_light, const Color& p_color) { - - Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); - ERR_FAIL_COND(!clight); - clight->shadow_color=p_color; - -} - - -/****** CANVAS LIGHT OCCLUDER ******/ - -RID VisualServerRaster::canvas_light_occluder_create() { - - Rasterizer::CanvasLightOccluderInstance *occluder = memnew( Rasterizer::CanvasLightOccluderInstance ); - - return canvas_light_occluder_owner.make_rid( occluder ); - -} - -void VisualServerRaster::canvas_light_occluder_attach_to_canvas(RID p_occluder,RID p_canvas) { - - Rasterizer::CanvasLightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder); - ERR_FAIL_COND(!occluder); - - if (occluder->canvas.is_valid()) { - - Canvas *canvas = canvas_owner.get(occluder->canvas); - canvas->occluders.erase(occluder); - } - - if (!canvas_owner.owns(p_canvas)) - p_canvas; - - occluder->canvas=p_canvas; - - if (occluder->canvas.is_valid()) { - - Canvas *canvas = canvas_owner.get(occluder->canvas); - canvas->occluders.insert(occluder); - } -} - -void VisualServerRaster::canvas_light_occluder_set_enabled(RID p_occluder,bool p_enabled){ - - Rasterizer::CanvasLightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder); - ERR_FAIL_COND(!occluder); - - occluder->enabled=p_enabled; - -} - -void VisualServerRaster::canvas_light_occluder_set_polygon(RID p_occluder,RID p_polygon) { - - Rasterizer::CanvasLightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder); - ERR_FAIL_COND(!occluder); - - if (occluder->polygon.is_valid()) { - CanvasLightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_polygon); - if (occluder_poly) { - occluder_poly->owners.erase(occluder); - } - } - - occluder->polygon=p_polygon; - occluder->polygon_buffer; - - if (occluder->polygon.is_valid()) { - CanvasLightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_polygon); - if (!occluder_poly) - occluder->polygon; - ERR_FAIL_COND(!occluder_poly); - occluder_poly->owners.insert(occluder); - occluder->polygon_buffer=occluder_poly->occluder; - occluder->aabb_cache=occluder_poly->aabb; - occluder->cull_cache=occluder_poly->cull_mode; - } - -} - - - - -void VisualServerRaster::canvas_light_occluder_set_transform(RID p_occluder,const Matrix32& p_xform) { - - Rasterizer::CanvasLightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder); - ERR_FAIL_COND(!occluder); - - occluder->xform=p_xform; - -} - -void VisualServerRaster::canvas_light_occluder_set_light_mask(RID p_occluder,int p_mask) { - - Rasterizer::CanvasLightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder); - ERR_FAIL_COND(!occluder); - - occluder->light_mask=p_mask; - -} - - -RID VisualServerRaster::canvas_occluder_polygon_create() { - - CanvasLightOccluderPolygon * occluder_poly = memnew( CanvasLightOccluderPolygon ); - occluder_poly->occluder=rasterizer->canvas_light_occluder_create(); - return canvas_light_occluder_polygon_owner.make_rid(occluder_poly); - -} - -void VisualServerRaster::canvas_occluder_polygon_set_shape(RID p_occluder_polygon, const PoolVector<Vector2>& p_shape, bool p_close){ - - if (p_shape.size()<3) { - canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon,p_shape); - return; - } - - PoolVector<Vector2> lines; - int lc = p_shape.size()*2; - - lines.resize(lc-(p_close?0:2)); - { - PoolVector<Vector2>::Write w = lines.write(); - PoolVector<Vector2>::Read r = p_shape.read(); - - int max=lc/2; - if (!p_close) { - max--; - } - for(int i=0;i<max;i++) { - - Vector2 a = r[i]; - Vector2 b = r[(i+1)%(lc/2)]; - w[i*2+0]=a; - w[i*2+1]=b; - } - - } - - canvas_occluder_polygon_set_shape_as_lines(p_occluder_polygon,lines); -} - -void VisualServerRaster::canvas_occluder_polygon_set_shape_as_lines(RID p_occluder_polygon,const PoolVector<Vector2>& p_shape) { - - CanvasLightOccluderPolygon * occluder_poly = canvas_light_occluder_polygon_owner.get(p_occluder_polygon); - ERR_FAIL_COND(!occluder_poly); - ERR_FAIL_COND(p_shape.size()&1); - - int lc = p_shape.size(); - occluder_poly->aabb=Rect2(); - { - PoolVector<Vector2>::Read r = p_shape.read(); - for(int i=0;i<lc;i++) { - if (i==0) - occluder_poly->aabb.pos=r[i]; - else - occluder_poly->aabb.expand_to(r[i]); - } - } - - rasterizer->canvas_light_occluder_set_polylines(occluder_poly->occluder,p_shape); - for( Set<Rasterizer::CanvasLightOccluderInstance*>::Element *E=occluder_poly->owners.front();E;E=E->next()) { - E->get()->aabb_cache=occluder_poly->aabb; - } -} - -void VisualServerRaster::canvas_occluder_polygon_set_cull_mode(RID p_occluder_polygon,CanvasOccluderPolygonCullMode p_mode) { - - CanvasLightOccluderPolygon * occluder_poly = canvas_light_occluder_polygon_owner.get(p_occluder_polygon); - ERR_FAIL_COND(!occluder_poly); - occluder_poly->cull_mode=p_mode; - for( Set<Rasterizer::CanvasLightOccluderInstance*>::Element *E=occluder_poly->owners.front();E;E=E->next()) { - E->get()->cull_cache=p_mode; - } - -} - -RID VisualServerRaster::canvas_item_material_create() { - - Rasterizer::ShaderMaterial *material = memnew( Rasterizer::ShaderMaterial ); - return canvas_item_material_owner.make_rid(material); - -} - -void VisualServerRaster::canvas_item_material_set_shader(RID p_material, RID p_shader){ - - VS_CHANGED; - Rasterizer::ShaderMaterial *material = canvas_item_material_owner.get( p_material ); - ERR_FAIL_COND(!material); - material->shader=p_shader; - -} -void VisualServerRaster::canvas_item_material_set_shader_param(RID p_material, const StringName& p_param, const Variant& p_value){ - - VS_CHANGED; - Rasterizer::ShaderMaterial *material = canvas_item_material_owner.get( p_material ); - ERR_FAIL_COND(!material); - if (p_value.get_type()==Variant::NIL) - material->shader_param.erase(p_param); - else - material->shader_param[p_param]=p_value; - - -} -Variant VisualServerRaster::canvas_item_material_get_shader_param(RID p_material, const StringName& p_param) const{ - Rasterizer::ShaderMaterial *material = canvas_item_material_owner.get( p_material ); - ERR_FAIL_COND_V(!material,Variant()); - if (!material->shader_param.has(p_param)) { - ERR_FAIL_COND_V(!material->shader.is_valid(),Variant()); - return rasterizer->shader_get_default_param(material->shader,p_param); - } - - return material->shader_param[p_param]; -} - -void VisualServerRaster::canvas_item_material_set_shading_mode(RID p_material, CanvasItemShadingMode p_mode) { - - VS_CHANGED; - Rasterizer::ShaderMaterial *material = canvas_item_material_owner.get( p_material ); - ERR_FAIL_COND(!material); - material->shading_mode=p_mode; - -} - - -/******** CANVAS *********/ - - -void VisualServerRaster::cursor_set_rotation(float p_rotation, int p_cursor) { - VS_CHANGED; - ERR_FAIL_INDEX(p_cursor, MAX_CURSORS); - - cursors[p_cursor].rot = p_rotation; -}; - -void VisualServerRaster::cursor_set_texture(RID p_texture, const Point2 &p_center_offset, int p_cursor, const Rect2 &p_region) { - VS_CHANGED; - ERR_FAIL_INDEX(p_cursor, MAX_CURSORS); - - cursors[p_cursor].texture = p_texture; - cursors[p_cursor].center = p_center_offset; - cursors[p_cursor].region = p_region; -}; - -void VisualServerRaster::cursor_set_visible(bool p_visible, int p_cursor) { - VS_CHANGED; - ERR_FAIL_INDEX(p_cursor, MAX_CURSORS); - - cursors[p_cursor].visible = p_visible; -}; - -void VisualServerRaster::cursor_set_pos(const Point2& p_pos, int p_cursor) { - - ERR_FAIL_INDEX(p_cursor, MAX_CURSORS); - if (cursors[p_cursor].pos==p_pos) - return; - VS_CHANGED; - cursors[p_cursor].pos = p_pos; -}; - - -void VisualServerRaster::black_bars_set_margins(int p_left, int p_top, int p_right, int p_bottom) { - - black_margin[MARGIN_LEFT]=p_left; - black_margin[MARGIN_TOP]=p_top; - black_margin[MARGIN_RIGHT]=p_right; - black_margin[MARGIN_BOTTOM]=p_bottom; -} - -void VisualServerRaster::black_bars_set_images(RID p_left, RID p_top, RID p_right, RID p_bottom) { - - black_image[MARGIN_LEFT]=p_left; - black_image[MARGIN_TOP]=p_top; - black_image[MARGIN_RIGHT]=p_right; - black_image[MARGIN_BOTTOM]=p_bottom; -} - -void VisualServerRaster::_free_attached_instances(RID p_rid,bool p_free_scenario) { - - Map< RID, Set<RID> >::Element * E = instance_dependency_map.find( p_rid ); - - if (E) { - // has instances - while( E->get().size() ) { - // erase all attached instances - if (p_free_scenario) - instance_set_scenario( E->get().front()->get(), RID() ); - else - instance_set_base( E->get().front()->get(), RID() ); - - } - } - - instance_dependency_map.erase(p_rid); - -} - -void VisualServerRaster::custom_shade_model_set_shader(int p_model, RID p_shader) { - - VS_CHANGED; - //rasterizer->custom_shade_model_set_shader(p_model,p_shader); -} - -RID VisualServerRaster::custom_shade_model_get_shader(int p_model) const { - - //return rasterizer->custom_shade_model_get_shader(p_model); - return RID(); - -} -void VisualServerRaster::custom_shade_model_set_name(int p_model, const String& p_name) { - - //rasterizer->custom_shade_model_set_name(p_model,p_name); - -} -String VisualServerRaster::custom_shade_model_get_name(int p_model) const { - - //return rasterizer->custom_shade_model_get_name(p_model); - return ""; -} -void VisualServerRaster::custom_shade_model_set_param_info(int p_model, const List<PropertyInfo>& p_info) { - - VS_CHANGED; - //rasterizer->custom_shade_model_set_param_info(p_model,p_info); -} -void VisualServerRaster::custom_shade_model_get_param_info(int p_model, List<PropertyInfo>* p_info) const { - - //rasterizer->custom_shade_model_get_param_info(p_model,p_info); -} - -void VisualServerRaster::free( RID p_rid ) { - - VS_CHANGED; - - if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_shader(p_rid) || rasterizer->is_environment(p_rid)) { - - rasterizer->free(p_rid); - } else if (rasterizer->is_skeleton(p_rid)) { - - Map< RID, Set<Instance*> >::Element *E=skeleton_dependency_map.find(p_rid); - - if (E) { - //detach skeletons - for (Set<Instance*>::Element *F=E->get().front();F;F=F->next()) { - - F->get()->data.skeleton; - } - skeleton_dependency_map.erase(E); - } - - rasterizer->free(p_rid); - } else if (rasterizer->is_mesh(p_rid) || rasterizer->is_multimesh(p_rid) || rasterizer->is_light(p_rid) || rasterizer->is_particles(p_rid) || rasterizer->is_immediate(p_rid)) { - //delete the resource - - _free_attached_instances(p_rid); - rasterizer->free(p_rid); - } else if (room_owner.owns(p_rid)) { - - _free_attached_instances(p_rid); - Room *room = room_owner.get(p_rid); - ERR_FAIL_COND(!room); - room_owner.free(p_rid); - memdelete(room); - - - } else if (portal_owner.owns(p_rid)) { - - _free_attached_instances(p_rid); - - Portal *portal = portal_owner.get(p_rid); - ERR_FAIL_COND(!portal); - portal_owner.free(p_rid); - memdelete(portal); - - } else if (baked_light_owner.owns(p_rid)) { - - _free_attached_instances(p_rid); - - BakedLight *baked_light = baked_light_owner.get(p_rid); - ERR_FAIL_COND(!baked_light); - if (baked_light->data.octree_texture.is_valid()) - rasterizer->free(baked_light->data.octree_texture); - baked_light_owner.free(p_rid); - memdelete(baked_light); - - } else if (baked_light_sampler_owner.owns(p_rid)) { - - _free_attached_instances(p_rid); - - BakedLightSampler *baked_light_sampler = baked_light_sampler_owner.get(p_rid); - ERR_FAIL_COND(!baked_light_sampler); - /* - if (baked_light->data.octree_texture.is_valid()) - rasterizer->free(baked_light->data.octree_texture); - */ - baked_light_sampler_owner.free(p_rid); - memdelete(baked_light_sampler); - - } else if (camera_owner.owns(p_rid)) { - // delete te camera - - Camera *camera = camera_owner.get(p_rid); - ERR_FAIL_COND(!camera); - - camera_owner.free( p_rid ); - memdelete(camera); - - } else if (viewport_owner.owns(p_rid)) { - // delete the viewport - - Viewport *viewport = viewport_owner.get( p_rid ); - ERR_FAIL_COND(!viewport); - - //Viewport *parent=NULL; - - rasterizer->free(viewport->viewport_data); - if (viewport->render_target.is_valid()) { - - rasterizer->free(viewport->render_target); - } - - if (viewport->update_list.in_list()) - viewport_update_list.remove(&viewport->update_list); - if (screen_viewports.has(p_rid)) - screen_viewports.erase(p_rid); - - while(viewport->canvas_map.size()) { - - Canvas *c = viewport->canvas_map.front()->get().canvas; - c->viewports.erase(p_rid); - - viewport->canvas_map.erase(viewport->canvas_map.front()); - } - - - viewport_owner.free(p_rid); - memdelete(viewport); - - } else if (instance_owner.owns(p_rid)) { - // delete the instance - - _update_instances(); // be sure - - Instance *instance = instance_owner.get(p_rid); - ERR_FAIL_COND(!instance); - - instance_set_room(p_rid,RID()); - instance_set_scenario(p_rid,RID()); - instance_geometry_set_baked_light(p_rid,RID()); - instance_geometry_set_baked_light_sampler(p_rid,RID()); - instance_set_base(p_rid,RID()); - - if (instance->data.skeleton.is_valid()) - instance_attach_skeleton(p_rid,RID()); - - instance_owner.free(p_rid); - memdelete(instance); - - } else if (canvas_owner.owns(p_rid)) { - - Canvas *canvas = canvas_owner.get(p_rid); - ERR_FAIL_COND(!canvas); - - while(canvas->viewports.size()) { - - Viewport *vp = viewport_owner.get(canvas->viewports.front()->get()); - ERR_FAIL_COND(!vp); - - Map<RID,Viewport::CanvasData>::Element *E=vp->canvas_map.find(p_rid); - ERR_FAIL_COND(!E); - vp->canvas_map.erase(p_rid); - - canvas->viewports.erase( canvas->viewports.front() ); - } - - for (int i=0;i<canvas->child_items.size();i++) { - - canvas->child_items[i].item->parent; - } - - for (Set<Rasterizer::CanvasLight*>::Element *E=canvas->lights.front();E;E=E->next()) { - - E->get()->canvas; - } - - for (Set<Rasterizer::CanvasLightOccluderInstance*>::Element *E=canvas->occluders.front();E;E=E->next()) { - - E->get()->canvas; - } - - canvas_owner.free( p_rid ); - - memdelete( canvas ); - - } else if (canvas_item_owner.owns(p_rid)) { - - CanvasItem *canvas_item = canvas_item_owner.get(p_rid); - ERR_FAIL_COND(!canvas_item); - - if (canvas_item->parent.is_valid()) { - - if (canvas_owner.owns(canvas_item->parent)) { - - Canvas *canvas = canvas_owner.get(canvas_item->parent); - canvas->erase_item(canvas_item); - } else if (canvas_item_owner.owns(canvas_item->parent)) { - - CanvasItem *item_owner = canvas_item_owner.get(canvas_item->parent); - item_owner->child_items.erase(canvas_item); - - } - } - - for (int i=0;i<canvas_item->child_items.size();i++) { - - canvas_item->child_items[i]->parent; - } - - if (canvas_item->material) { - canvas_item->material->owners.erase(canvas_item); - } - - canvas_item_owner.free( p_rid ); - - memdelete( canvas_item ); - - } else if (canvas_item_material_owner.owns(p_rid)) { - - Rasterizer::ShaderMaterial *material = canvas_item_material_owner.get(p_rid); - ERR_FAIL_COND(!material); - for(Set<Rasterizer::CanvasItem*>::Element *E=material->owners.front();E;E=E->next()) { - - E->get()->material=NULL; - } - - canvas_item_material_owner.free(p_rid); - memdelete(material); - - } else if (canvas_light_owner.owns(p_rid)) { - - Rasterizer::CanvasLight *canvas_light = canvas_light_owner.get(p_rid); - ERR_FAIL_COND(!canvas_light); - - if (canvas_light->canvas.is_valid()) { - Canvas* canvas = canvas_owner.get(canvas_light->canvas); - if (canvas) - canvas->lights.erase(canvas_light); - } - - if (canvas_light->shadow_buffer.is_valid()) - rasterizer->free(canvas_light->shadow_buffer); - - canvas_light_owner.free( p_rid ); - memdelete( canvas_light ); - - } else if (canvas_light_occluder_owner.owns(p_rid)) { - - Rasterizer::CanvasLightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_rid); - ERR_FAIL_COND(!occluder); - - if (occluder->polygon.is_valid()) { - - CanvasLightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(occluder->polygon); - if (occluder_poly) { - occluder_poly->owners.erase(occluder); - } - - } - - if (occluder->canvas.is_valid() && canvas_owner.owns(occluder->canvas)) { - - Canvas *canvas = canvas_owner.get(occluder->canvas); - canvas->occluders.erase(occluder); - - } - - canvas_light_occluder_owner.free( p_rid ); - memdelete(occluder); - - } else if (canvas_light_occluder_polygon_owner.owns(p_rid)) { - - CanvasLightOccluderPolygon *occluder_poly = canvas_light_occluder_polygon_owner.get(p_rid); - ERR_FAIL_COND(!occluder_poly); - rasterizer->free(occluder_poly->occluder); - - while(occluder_poly->owners.size()) { - - occluder_poly->owners.front()->get()->polygon; - occluder_poly->owners.erase( occluder_poly->owners.front() ); - } - - canvas_light_occluder_polygon_owner.free( p_rid ); - memdelete(occluder_poly); - - } else if (scenario_owner.owns(p_rid)) { - - Scenario *scenario=scenario_owner.get(p_rid); - ERR_FAIL_COND(!scenario); - - _update_instances(); // be sure - _free_attached_instances(p_rid,true); - - //rasterizer->free( scenario->environment ); - scenario_owner.free(p_rid); - memdelete(scenario); - - } else { - - ERR_FAIL(); - } - -} - - - -void VisualServerRaster::_instance_draw(Instance *p_instance) { - - if (p_instance->light_cache_dirty) { - int l=0; - //add positional lights - InstanceSet::Element *LE=p_instance->lights.front(); - p_instance->data.light_instances.resize(p_instance->lights.size()); - while(LE) { - - p_instance->data.light_instances[l++]=LE->get()->light_info->instance; - LE=LE->next(); - } - p_instance->light_cache_dirty=false; - } - - - switch(p_instance->base_type) { - - case INSTANCE_MESH: { - rasterizer->add_mesh(p_instance->base_rid, &p_instance->data); - } break; - case INSTANCE_MULTIMESH: { - rasterizer->add_multimesh(p_instance->base_rid, &p_instance->data); - } break; - case INSTANCE_IMMEDIATE: { - rasterizer->add_immediate(p_instance->base_rid, &p_instance->data); - } break; - case INSTANCE_PARTICLES: { - rasterizer->add_particles(p_instance->particles_info->instance, &p_instance->data); - } break; - default: {}; - } -} - - -Vector<Vector3> VisualServerRaster::_camera_generate_endpoints(Instance *p_light,Camera *p_camera,float p_range_min, float p_range_max) { - - // setup a camera matrix for that range! - CameraMatrix camera_matrix; - - switch(p_camera->type) { - - case Camera::ORTHOGONAL: { - - camera_matrix.set_orthogonal(p_camera->size,viewport_rect.width / (float)viewport_rect.height,p_range_min,p_range_max,p_camera->vaspect); - } break; - case Camera::PERSPECTIVE: { - - camera_matrix.set_perspective( - p_camera->fov, - viewport_rect.width / (float)viewport_rect.height, - p_range_min, - p_range_max, - p_camera->vaspect - ); - - } break; - } - - //obtain the frustum endpoints - - Vector<Vector3> endpoints; - endpoints.resize(8); - bool res = camera_matrix.get_endpoints(p_camera->transform,&endpoints[0]); - ERR_FAIL_COND_V(!res,Vector<Vector3>()); - - return endpoints; -} - -Vector<Plane> VisualServerRaster::_camera_generate_orthogonal_planes(Instance *p_light,Camera *p_camera,float p_range_min, float p_range_max) { - - Vector<Vector3> endpoints=_camera_generate_endpoints(p_light,p_camera,p_range_min,p_range_max); // frustum plane endpoints - ERR_FAIL_COND_V(endpoints.empty(),Vector<Plane>()); - - // obtain the light frustm ranges (given endpoints) - - Vector3 x_vec=p_light->data.transform.basis.get_axis( Vector3::AXIS_X ).normalized(); - Vector3 y_vec=p_light->data.transform.basis.get_axis( Vector3::AXIS_Y ).normalized(); - Vector3 z_vec=p_light->data.transform.basis.get_axis( Vector3::AXIS_Z ).normalized(); - - float x_min,x_max; - float y_min,y_max; - float z_min,z_max; - - for(int j=0;j<8;j++) { - - float d_x=x_vec.dot(endpoints[j]); - float d_y=y_vec.dot(endpoints[j]); - float d_z=z_vec.dot(endpoints[j]); - - if (j==0 || d_x<x_min) - x_min=d_x; - if (j==0 || d_x>x_max) - x_max=d_x; - - if (j==0 || d_y<y_min) - y_min=d_y; - if (j==0 || d_y>y_max) - y_max=d_y; - - if (j==0 || d_z<z_min) - z_min=d_z; - if (j==0 || d_z>z_max) - z_max=d_z; - - - } - //now that we now all ranges, we can proceed to make the light frustum planes, for culling octree - - Vector<Plane> light_frustum_planes; - light_frustum_planes.resize(6); - - //right/left - light_frustum_planes[0]=Plane( x_vec, x_max ); - light_frustum_planes[1]=Plane( -x_vec, -x_min ); - //top/bottom - light_frustum_planes[2]=Plane( y_vec, y_max ); - light_frustum_planes[3]=Plane( -y_vec, -y_min ); - //near/far - light_frustum_planes[4]=Plane( z_vec, z_max+1e6 ); - light_frustum_planes[5]=Plane( -z_vec, -z_min ); // z_min is ok, since casters further than far-light plane are not needed - - //TODO@ add more actual frustum planes to minimize get - - return light_frustum_planes; - -} -void VisualServerRaster::_light_instance_update_pssm_shadow(Instance *p_light,Scenario *p_scenario,Camera *p_camera,const CullRange& p_cull_range) { - - int splits = rasterizer->light_instance_get_shadow_passes( p_light->light_info->instance ); - - float split_weight=rasterizer->light_directional_get_shadow_param(p_light->base_rid,LIGHT_DIRECTIONAL_SHADOW_PARAM_PSSM_SPLIT_WEIGHT); - - - float distances[5]; - float texsize=rasterizer->light_instance_get_shadow_size( p_light->light_info->instance ); - - //float cull_min=p_cull_range.min; - //float cull_max=p_cull_range.max; - - - bool overlap = rasterizer->light_instance_get_pssm_shadow_overlap(p_light->light_info->instance); - - float cull_min=p_camera->znear; - float cull_max=p_camera->zfar; - float max_dist = rasterizer->light_directional_get_shadow_param(p_light->base_rid,VS::LIGHT_DIRECTIONAL_SHADOW_PARAM_MAX_DISTANCE); - if (max_dist>0.0) - cull_max=MIN(cull_max,max_dist); - - for(int i = 0; i < splits; i++) { - float idm = i / (float)splits; - float lg = cull_min * Math::pow(cull_max/cull_min, idm); - float uniform = cull_min + (cull_max - cull_min) * idm; - distances[i] = lg * split_weight + uniform * (1.0 - split_weight); - - } - - distances[0]=cull_min; - distances[splits]=cull_max; - - for (int i=0;i<splits;i++) { - - // setup a camera matrix for that range! - CameraMatrix camera_matrix; - - switch(p_camera->type) { - - case Camera::ORTHOGONAL: { - - camera_matrix.set_orthogonal( - p_camera->size, - viewport_rect.width / (float)viewport_rect.height, - distances[(i==0 || !overlap )?i:i-1], - distances[i+1], - p_camera->vaspect - - ); - } break; - case Camera::PERSPECTIVE: { - - - camera_matrix.set_perspective( - p_camera->fov, - viewport_rect.width / (float)viewport_rect.height, - distances[(i==0 || !overlap )?i:i-1], - distances[i+1], - p_camera->vaspect - - ); - - } break; - } - - //obtain the frustum endpoints - - Vector3 endpoints[8]; // frustum plane endpoints - bool res = camera_matrix.get_endpoints(p_camera->transform,endpoints); - ERR_CONTINUE(!res); - - // obtain the light frustm ranges (given endpoints) - - Vector3 x_vec=p_light->data.transform.basis.get_axis( Vector3::AXIS_X ).normalized(); - Vector3 y_vec=p_light->data.transform.basis.get_axis( Vector3::AXIS_Y ).normalized(); - Vector3 z_vec=p_light->data.transform.basis.get_axis( Vector3::AXIS_Z ).normalized(); - //z_vec points agsint the camera, like in default opengl - - float x_min,x_max; - float y_min,y_max; - float z_min,z_max; - - float x_min_cam,x_max_cam; - float y_min_cam,y_max_cam; - float z_min_cam,z_max_cam; - - - //used for culling - for(int j=0;j<8;j++) { - - float d_x=x_vec.dot(endpoints[j]); - float d_y=y_vec.dot(endpoints[j]); - float d_z=z_vec.dot(endpoints[j]); - - if (j==0 || d_x<x_min) - x_min=d_x; - if (j==0 || d_x>x_max) - x_max=d_x; - - if (j==0 || d_y<y_min) - y_min=d_y; - if (j==0 || d_y>y_max) - y_max=d_y; - - if (j==0 || d_z<z_min) - z_min=d_z; - if (j==0 || d_z>z_max) - z_max=d_z; - - - } - - - - - - { - //camera viewport stuff - //this trick here is what stabilizes the shadow (make potential jaggies to not move) - //at the cost of some wasted resolution. Still the quality increase is very well worth it - - - Vector3 center; - - for(int j=0;j<8;j++) { - - center+=endpoints[j]; - } - center/=8.0; - - //center=x_vec*(x_max-x_min)*0.5 + y_vec*(y_max-y_min)*0.5 + z_vec*(z_max-z_min)*0.5; - - float radius=0; - - for(int j=0;j<8;j++) { - - float d = center.distance_to(endpoints[j]); - if (d>radius) - radius=d; - } - - - radius *= texsize/(texsize-2.0); //add a texel by each side, so stepified texture will always fit - - x_max_cam=x_vec.dot(center)+radius; - x_min_cam=x_vec.dot(center)-radius; - y_max_cam=y_vec.dot(center)+radius; - y_min_cam=y_vec.dot(center)-radius; - z_max_cam=z_vec.dot(center)+radius; - z_min_cam=z_vec.dot(center)-radius; - - float unit = radius*2.0/texsize; - - x_max_cam=Math::stepify(x_max_cam,unit); - x_min_cam=Math::stepify(x_min_cam,unit); - y_max_cam=Math::stepify(y_max_cam,unit); - y_min_cam=Math::stepify(y_min_cam,unit); - - } - - //now that we now all ranges, we can proceed to make the light frustum planes, for culling octree - - Vector<Plane> light_frustum_planes; - light_frustum_planes.resize(6); - - //right/left - light_frustum_planes[0]=Plane( x_vec, x_max ); - light_frustum_planes[1]=Plane( -x_vec, -x_min ); - //top/bottom - light_frustum_planes[2]=Plane( y_vec, y_max ); - light_frustum_planes[3]=Plane( -y_vec, -y_min ); - //near/far - light_frustum_planes[4]=Plane( z_vec, z_max+1e6 ); - light_frustum_planes[5]=Plane( -z_vec, -z_min ); // z_min is ok, since casters further than far-light plane are not needed - - int caster_cull_count = p_scenario->octree.cull_convex(light_frustum_planes,instance_shadow_cull_result,MAX_INSTANCE_CULL,INSTANCE_GEOMETRY_MASK); - - // a pre pass will need to be needed to determine the actual z-near to be used - for(int j=0;j<caster_cull_count;j++) { - - float min,max; - Instance *ins=instance_shadow_cull_result[j]; - if (!ins->visible || ins->data.cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) - continue; - ins->transformed_aabb.project_range_in_plane(Plane(z_vec,0),min,max); - - if (max>z_max) - z_max=max; - } - - { - CameraMatrix ortho_camera; - real_t half_x = (x_max_cam-x_min_cam) * 0.5; - real_t half_y = (y_max_cam-y_min_cam) * 0.5; - - - ortho_camera.set_orthogonal( -half_x, half_x,-half_y,half_y, 0, (z_max-z_min_cam) ); - - Transform ortho_transform; - ortho_transform.basis=p_light->data.transform.basis; - ortho_transform.origin=x_vec*(x_min_cam+half_x)+y_vec*(y_min_cam+half_y)+z_vec*z_max; - - rasterizer->light_instance_set_shadow_transform(p_light->light_info->instance, i, ortho_camera, ortho_transform,distances[i],distances[i+1] ); - } - - rasterizer->begin_shadow_map( p_light->light_info->instance, i ); - - for (int j=0;j<caster_cull_count;j++) { - - Instance *instance = instance_shadow_cull_result[j]; - if (!instance->visible || instance->data.cast_shadows==VS::SHADOW_CASTING_SETTING_OFF) - continue; - _instance_draw(instance); - } - - rasterizer->end_shadow_map(); - - - } - - -} - - -CameraMatrix _lispm_look( const Vector3 pos, const Vector3 dir, const Vector3 up) { - - Vector3 dirN; - Vector3 upN; - Vector3 lftN; - - lftN=dir.cross(up); - lftN.normalize(); - - upN=lftN.cross(dir); - upN.normalize(); - dirN=dir.normalized(); - - CameraMatrix cmout; - float *output=&cmout.matrix[0][0]; - output[ 0] = lftN[0]; - output[ 1] = upN[0]; - output[ 2] = -dirN[0]; - output[ 3] = 0.0; - - output[ 4] = lftN[1]; - output[ 5] = upN[1]; - output[ 6] = -dirN[1]; - output[ 7] = 0.0; - - output[ 8] = lftN[2]; - output[ 9] = upN[2]; - output[10] = -dirN[2]; - output[11] = 0.0; - - output[12] = -lftN.dot(pos); - output[13] = -upN.dot(pos); - output[14] = dirN.dot(pos); - output[15] = 1.0; - - return cmout; -} - -#if 1 - -void VisualServerRaster::_light_instance_update_lispsm_shadow(Instance *p_light,Scenario *p_scenario,Camera *p_camera,const CullRange& p_cull_range) { - - Vector3 light_vec = -p_light->data.transform.basis.get_axis(2); - Vector3 view_vec = -p_camera->transform.basis.get_axis(2); - - float near_dist=1; - - Vector<Plane> light_frustum_planes = _camera_generate_orthogonal_planes(p_light,p_camera,p_cull_range.min,p_cull_range.max); - int caster_count = p_scenario->octree.cull_convex(light_frustum_planes,instance_shadow_cull_result,MAX_INSTANCE_CULL,INSTANCE_GEOMETRY_MASK); - - // this could be faster by just getting supports from the AABBs.. - // but, safer to do as the original implementation explains for now.. - - Vector<Vector3> caster_pointcloud; - caster_pointcloud.resize(caster_count*8); - int caster_pointcloud_size=0; - - { - - //fill pointcloud - Vector3* caster_pointcloud_ptr=&caster_pointcloud[0]; - - for(int i=0;i<caster_count;i++) { - - Instance *ins = instance_shadow_cull_result[i]; - if (!ins->visible || ins->data.cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) - continue; - - for(int j=0;j<8;j++) { - - Vector3 v = ins->aabb.get_endpoint(j); - v = ins->data.transform.xform(v); - caster_pointcloud_ptr[caster_pointcloud_size+j]=v; - } - - caster_pointcloud_size+=8; - - } - } - - // now generate a pointcloud that contains the maximum bound (camera extruded by light) - - Vector<Vector3> camera_pointcloud = _camera_generate_endpoints(p_light,p_camera,p_cull_range.min,p_cull_range.max); - int cpcsize=camera_pointcloud.size(); - camera_pointcloud.resize( cpcsize*2 ); - - for(int i=0;i<cpcsize;i++) { - - camera_pointcloud[i+cpcsize]=camera_pointcloud[i]-light_vec*1000; - } - - - - // Vector<Vector3> frustum_points=_camera_generate_endpoints(p_light,p_camera,p_cull_range.min,p_cull_range.max); - - - // compute the "light-space" basis, using the algorithm described in the paper - // note: since bodyB is defined in eye space, all of these vectors should also be defined in eye space - - - Vector3 eye = p_camera->transform.origin; - Vector3 up = light_vec.cross(view_vec).cross(light_vec).normalized(); - - - CameraMatrix light_space_basis = _lispm_look(eye,light_vec,up); - - AABB light_space_aabb; - - - { //create an optimal AABB from both the camera pointcloud and the objects pointcloud - AABB light_space_pointcloud_aabb; - AABB light_space_camera_aabb; - //xform pointcloud - const Vector3* caster_pointcloud_ptr=&caster_pointcloud[0]; - - for(int i=0;i<caster_pointcloud_size;i++) { - - Vector3 p = light_space_basis.xform(caster_pointcloud_ptr[i]); - if (i==0) { - light_space_pointcloud_aabb.pos=p; - } else { - light_space_pointcloud_aabb.expand_to(p); - } - } - for(int i=0;i<camera_pointcloud.size();i++) { - - Vector3 p = light_space_basis.xform(camera_pointcloud[i]); - if (i==0) { - light_space_camera_aabb.pos=p; - } else { - light_space_camera_aabb.expand_to(p); - } - } - - light_space_aabb=light_space_pointcloud_aabb.intersection(light_space_camera_aabb); - } - - float lvdp = light_vec.dot(view_vec); - - float sin_gamma = Math::sqrt(1.0-lvdp*lvdp); - //use the formulas of the paper to get n (and f) - float factor = 1.0/sin_gamma; - float z_n = factor*near_dist; //often 1 - float d = Math::abs(light_space_aabb.size.y); //perspective transform depth //light space y extents - float z_f = z_n + d*sin_gamma; - float n = (z_n+Math::sqrt(z_f*z_n))/sin_gamma; - float f = n+d; - - Vector3 pos = eye - up*(n-near_dist); - - CameraMatrix light_space_basis2 = _lispm_look(pos,light_vec,up); - //Transform light_space_basis2; - //light_space_basis2.set_look_at(pos,light_vec-pos,up); - //light_space_basis2.affine_invert(); - - //one possibility for a simple perspective transformation matrix - //with the two parameters n(near) and f(far) in y direction - - CameraMatrix lisp_matrix; - lisp_matrix.matrix[1][1]=(f+n)/(f-n); - lisp_matrix.matrix[3][1]=-2*f*n/(f-n); - lisp_matrix.matrix[1][3]=1; - lisp_matrix.matrix[3][3]=0; - - CameraMatrix projection = lisp_matrix * light_space_basis2; - //CameraMatrix projection = light_space_basis2 * lisp_matrix; - - - AABB proj_space_aabb; - - { - - AABB proj_space_pointcloud_aabb; - AABB proj_space_camera_aabb; - //xform pointcloud - Vector3* caster_pointcloud_ptr=&caster_pointcloud[0]; - for(int i=0;i<caster_pointcloud_size;i++) { - - Vector3 p = projection.xform(caster_pointcloud_ptr[i]); - if (i==0) { - proj_space_pointcloud_aabb.pos=p; - } else { - proj_space_pointcloud_aabb.expand_to(p); - } - } - - for(int i=0;i<camera_pointcloud.size();i++) { - - Vector3 p = projection.xform(camera_pointcloud[i]); - if (i==0) { - proj_space_camera_aabb.pos=p; - } else { - proj_space_camera_aabb.expand_to(p); - } - } - - //proj_space_aabb=proj_space_pointcloud_aabb.intersection_with(proj_space_camera_aabb); - proj_space_aabb=proj_space_pointcloud_aabb; - } - - projection.scale_translate_to_fit(proj_space_aabb); - projection=projection * lisp_matrix; - - CameraMatrix scale; - scale.make_scale(Vector3(1.0,1.0,-1.0)); // transform to left handed - - projection=scale * projection; - - rasterizer->light_instance_set_shadow_transform(p_light->light_info->instance,0, projection , light_space_basis2.inverse() ); - - rasterizer->begin_shadow_map( p_light->light_info->instance, 0 ); - - for(int i=0;i<caster_count;i++) { - - Instance *instance = instance_shadow_cull_result[i]; - - if (!instance->visible || instance->data.cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) - continue; - _instance_draw(instance); - } - - rasterizer->end_shadow_map(); - - -} - -#else - - -void VisualServerRaster::_light_instance_update_lispsm_shadow(Instance *p_light,Scenario *p_scenario,Camera *p_camera,const CullRange& p_cull_range) { - - /* STEP 1: GENERATE LIGHT TRANSFORM */ - - - - Vector3 light_vec = -p_light->data.transform.basis.get_axis(2); - Vector3 view_vec = -p_camera->transform.basis.get_axis(2); - float viewdot = Math::absf(light_vec.dot(view_vec)); - - Vector3 up = light_vec.cross(view_vec).cross(light_vec).normalized(); - - Transform light_transform; - light_transform.set_look_at(Vector3(),light_vec,up); - - - /* STEP 2: GENERATE WORDLSPACE PLANES AND VECTORS*/ - float range_min=0.01; //p_cull_range.min - float range_max=20;//p_cull_range.max; - - Vector<Vector3> camera_endpoints=_camera_generate_endpoints(p_light,p_camera,range_min,range_max); // frustum plane endpoints - ERR_FAIL_COND(camera_endpoints.empty()); - - // obtain the light frustm ranges (given endpoints) - - - Vector3 light_x_vec=light_transform.basis.get_axis( Vector3::AXIS_X ).normalized(); - Vector3 light_y_vec=light_transform.basis.get_axis( Vector3::AXIS_Y ).normalized(); - Vector3 light_z_vec=light_transform.basis.get_axis( Vector3::AXIS_Z ).normalized(); - - Vector3 light_axis_max; - Vector3 light_axis_min; - - for(int j=0;j<8;j++) { - - float d_x=light_x_vec.dot(camera_endpoints[j]); - float d_y=light_y_vec.dot(camera_endpoints[j]); - float d_z=light_z_vec.dot(camera_endpoints[j]); - - if (j==0 || d_x<light_axis_min.x) - light_axis_min.x=d_x; - if (j==0 || d_x>light_axis_max.x) - light_axis_max.x=d_x; - - if (j==0 || d_y<light_axis_min.y) - light_axis_min.y=d_y; - if (j==0 || d_y>light_axis_max.y) - light_axis_max.y=d_y; - - if (j==0 || d_z<light_axis_min.z) - light_axis_min.z=d_z; - if (j==0 || d_z>light_axis_max.z) - light_axis_max.z=d_z; - - - } - - //now that we now all ranges, we can proceed to make the light frustum planes, for culling octree - - Vector<Plane> light_cull_planes; - light_cull_planes.resize(6); - - - //right/left - light_cull_planes[0]=Plane( light_x_vec, light_axis_max.x ); - light_cull_planes[1]=Plane( -light_x_vec, -light_axis_min.x ); - //top/bottom - light_cull_planes[2]=Plane( light_y_vec, light_axis_max.y ); - light_cull_planes[3]=Plane( -light_y_vec, -light_axis_min.y ); - //near/far - light_cull_planes[4]=Plane( light_z_vec, light_axis_max.z+1e6 ); - light_cull_planes[5]=Plane( -light_z_vec, -light_axis_min.z ); // z_min is ok, since casters further than far-light plane are not needed - - - /* STEP 3: CULL CASTERS */ - - int caster_count = p_scenario->octree.cull_convex(light_cull_planes,instance_shadow_cull_result,MAX_INSTANCE_CULL,INSTANCE_GEOMETRY_MASK); - - /* STEP 4: ADJUST FAR Z PLANE */ - - float caster_max_z=1e-1; - for(int i=0;i<caster_count;i++) { - - Instance *ins=instance_shadow_cull_result[i]; - if (!ins->visible || ins->cast_shadows==VS::SHADOW_CASTING_SETTING_OFF) - continue; - - //@TODO optimize using support mapping - for(int j=0;j<8;j++) { - - Vector3 v=ins->data.transform.xform(ins->aabb.get_endpoint(j)); - float d = light_z_vec.dot(v); - if (d>caster_max_z) - caster_max_z=d; - - } - - } - - float expand = caster_max_z-light_axis_max.z; - if (expand<0) - expand=0; - light_axis_max.z=MAX(caster_max_z,light_axis_max.z); - - /* STEP 5: CREATE ORTHOGONAL PROJECTION */ - - CameraMatrix light_projection; - - real_t half_x = (light_axis_max.x-light_axis_min.x) * 0.5; - real_t half_y = (light_axis_max.y-light_axis_min.y) * 0.5; - light_projection.set_orthogonal( -half_x, half_x,half_y, -half_y, 0, (light_axis_max.z-light_axis_min.z) ); - light_transform.origin=light_x_vec*(light_axis_min.x+half_x)+light_y_vec*(light_axis_min.y+half_y)+light_z_vec*light_axis_max.z; - - - if (/*false &&*/ viewdot<0.96) { - - float lvdp = light_vec.dot(view_vec); - - float near_dist=1.0; - float sin_gamma = Math::sqrt(1.0-lvdp*lvdp); - //use the formulas of the paper to get n (and f) - float factor = 1.0/sin_gamma; - float z_n = factor*near_dist; //often 1 - float d = Math::abs(light_axis_max.y-light_axis_min.y); //perspective transform depth //light space y extents - float z_f = z_n + d*sin_gamma; - float n = (z_n+Math::sqrt(z_f*z_n))/sin_gamma; - float f = n+d; - - CameraMatrix lisp_matrix; - lisp_matrix.matrix[1][1]=(f+n)/(f-n); - lisp_matrix.matrix[3][1]=-2*f*n/(f-n); - lisp_matrix.matrix[1][3]=1; - lisp_matrix.matrix[3][3]=0; - - Vector3 pos = p_camera->transform.origin - up*(n-near_dist); - - CameraMatrix world2light = _lispm_look(pos,light_vec,up); - CameraMatrix projection = lisp_matrix * world2light; - - AABB projection_bounds; - for(int i=0;i<camera_endpoints.size();i++) { - - Vector3 p=camera_endpoints[i]; - if (i==0) - projection_bounds.pos=projection.xform(p); - else - projection_bounds.expand_to(projection.xform(p)); - - projection_bounds.expand_to(projection.xform(p+light_vec*-expand)); - } - - CameraMatrix scaletrans; - scaletrans.scale_translate_to_fit(projection_bounds); - projection=scaletrans * lisp_matrix; - - CameraMatrix scale; - scale.make_scale(Vector3(1.0,1.0,-1.0)); // transform to left handed - - projection=scale * projection; - - - rasterizer->light_instance_set_shadow_transform(p_light->light_info->instance,0, projection, world2light.inverse(), viewdot); - - } else { - //orthogonal - rasterizer->light_instance_set_shadow_transform(p_light->light_info->instance,0, light_projection , light_transform, viewdot); - } - - rasterizer->begin_shadow_map( p_light->light_info->instance, 0 ); - - for(int i=0;i<caster_count;i++) { - - Instance *instance = instance_shadow_cull_result[i]; - - if (!instance->visible || instance->cast_shadows==VS::SHADOW_CASTING_SETTING_OFF) - continue; - _instance_draw(instance); - } - - rasterizer->end_shadow_map(); - -} - -#endif - - -void VisualServerRaster::_light_instance_update_shadow(Instance *p_light,Scenario *p_scenario,Camera *p_camera,const CullRange& p_cull_range) { - - - - if (!rasterizer->shadow_allocate_near( p_light->light_info->instance )) - return; // shadow could not be updated - - - /* VisualServerRaster supports for many shadow techniques, using the one the rasterizer requests */ - - Rasterizer::ShadowType shadow_type = rasterizer->light_instance_get_shadow_type(p_light->light_info->instance); - - switch(shadow_type) { - - case Rasterizer::SHADOW_SIMPLE: { - /* SPOT SHADOW */ - - - rasterizer->begin_shadow_map( p_light->light_info->instance, 0 ); - - //using this one ensures that raster deferred will have it - - float far = rasterizer->light_get_var( p_light->base_rid, VS::LIGHT_PARAM_RADIUS); - - float angle = rasterizer->light_get_var( p_light->base_rid, VS::LIGHT_PARAM_SPOT_ANGLE ); - - CameraMatrix cm; - cm.set_perspective( angle*2.0, 1.0, 0.001, far ); - - Vector<Plane> planes = cm.get_projection_planes(p_light->data.transform); - int cull_count = p_scenario->octree.cull_convex(planes,instance_shadow_cull_result,MAX_INSTANCE_CULL,INSTANCE_GEOMETRY_MASK); - - - for (int i=0;i<cull_count;i++) { - - Instance *instance = instance_shadow_cull_result[i]; - if (!instance->visible || instance->data.cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) - continue; - _instance_draw(instance); - } - - rasterizer->end_shadow_map(); - - } break; - case Rasterizer::SHADOW_DUAL_PARABOLOID: { - - /* OMNI SHADOW */ - - int passes = rasterizer->light_instance_get_shadow_passes( p_light->light_info->instance ); - - if (passes==2) { - - for(int i=0;i<2;i++) { - - rasterizer->begin_shadow_map( p_light->light_info->instance, i ); - - - //using this one ensures that raster deferred will have it - - float radius = rasterizer->light_get_var( p_light->base_rid, VS::LIGHT_PARAM_RADIUS); - - float z =i==0?-1:1; - Vector<Plane> planes; - planes.resize(5); - planes[0]=p_light->data.transform.xform(Plane(Vector3(0,0,z),radius)); - planes[1]=p_light->data.transform.xform(Plane(Vector3(1,0,z).normalized(),radius)); - planes[2]=p_light->data.transform.xform(Plane(Vector3(-1,0,z).normalized(),radius)); - planes[3]=p_light->data.transform.xform(Plane(Vector3(0,1,z).normalized(),radius)); - planes[4]=p_light->data.transform.xform(Plane(Vector3(0,-1,z).normalized(),radius)); - - - int cull_count = p_scenario->octree.cull_convex(planes,instance_shadow_cull_result,MAX_INSTANCE_CULL,INSTANCE_GEOMETRY_MASK); - - - for (int j=0;j<cull_count;j++) { - - Instance *instance = instance_shadow_cull_result[j]; - if (!instance->visible || instance->data.cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) - continue; - - _instance_draw(instance); - } - - rasterizer->end_shadow_map(); - } - } else if (passes==1) { - //one go - - - - } - - } break; - case Rasterizer::SHADOW_CUBE: { - - // todo - } break; - case Rasterizer::SHADOW_ORTHOGONAL: { - - _light_instance_update_pssm_shadow(p_light,p_scenario,p_camera,p_cull_range); - } break; - case Rasterizer::SHADOW_PSSM: { - - _light_instance_update_pssm_shadow(p_light,p_scenario,p_camera,p_cull_range); - } break; - case Rasterizer::SHADOW_PSM: { - - _light_instance_update_lispsm_shadow(p_light,p_scenario,p_camera,p_cull_range); - // todo - } break; - default: {} - } - -} - -void VisualServerRaster::_portal_disconnect(Instance *p_portal,bool p_cleanup) { - - if (p_portal->portal_info->connected) { - - //disconnect first - p_portal->portal_info->connected->portal_info->connected=NULL; - p_portal->portal_info->connected=NULL; - - } - - if (p_portal->room && p_portal->room->room) { - - if (p_cleanup) { - - p_portal->room->room->room_info->disconnected_child_portals.erase(p_portal); - //p_portal->room->room->room_info->disconnected_child_portals.erase(p_portal); - } else { - p_portal->room->room->room_info->disconnected_child_portals.insert(p_portal); - } - } - -} - -void VisualServerRaster::_instance_validate_autorooms(Instance *p_geometry) { - - if (p_geometry->auto_rooms.size()==0) - return; - - p_geometry->valid_auto_rooms.clear(); - - int point_count = aabb_random_points.size(); - const Vector3 * src_points = &aabb_random_points[0]; - - for(Set<Instance*>::Element *E=p_geometry->valid_auto_rooms.front();E;E=E->next()) { - - Instance *room = E->get(); - Vector3 *dst_points=&transformed_aabb_random_points[0]; - - //generate points - for(int i=0;i<point_count;i++) { - - dst_points[i] = room->room_info->affine_inverse.xform(p_geometry->data.transform.xform((src_points[i]*p_geometry->transformed_aabb.size)+p_geometry->transformed_aabb.pos)); - } - - int pass = room->room_info->room->bounds.get_points_inside(dst_points,point_count); - - float ratio = pass; - if( point_count != 0 ) { - ratio /= (float)point_count; - } - - if (ratio>0.5) // should make some constant - p_geometry->valid_auto_rooms.insert(room); - } -} - -void VisualServerRaster::_portal_attempt_connect(Instance *p_portal) { - - - _portal_disconnect(p_portal); - - Vector3 A_norm = p_portal->data.transform.basis.get_axis(Vector3::AXIS_Z).normalized(); - Plane A_plane( p_portal->data.transform.origin, A_norm ); - float A_surface = p_portal->portal_info->portal->bounds.get_area(); - if (A_surface==0) - return; //wtf - - Instance *found=NULL; - Transform affine_inverse = p_portal->data.transform.affine_inverse(); - - for(Set<Instance*>::Element *E=p_portal->portal_info->candidate_set.front();E;E=E->next()) { - - Instance *B = E->get(); - - if (B->portal_info->connected) - continue; // in use - - Vector3 B_norm = B->data.transform.basis.get_axis(Vector3::AXIS_Z).normalized(); - - // check that they are in front of another - float dot = A_norm.dot(-B_norm); - - if (dot<0.707) // 45 degrees, TODO unharcode this - continue; - - // check the max distance to the other portal - - bool valid=true; - - Rect2 local_bounds; - - for(int i=0;i<B->portal_info->portal->shape.size();i++) { - - Point2 point2 = B->portal_info->portal->shape[i]; - - Vector3 point = B->data.transform.xform( Vector3( point2.x, point2.y, 0 ) ); - - float dist = Math::abs(A_plane.distance_to(point)); - - if ( - dist>p_portal->portal_info->portal->connect_range || - dist>B->portal_info->portal->connect_range ) { - valid=false; - break; - } - - - Vector3 point_local = affine_inverse.xform(A_plane.project(point)); - point2 = Point2(point_local.x,point_local.y); - - if (i==0) - local_bounds.pos=point2; - else - local_bounds.expand_to(point2); - - - } - - if (!valid) - continue; - - float B_surface = B->portal_info->portal->bounds.get_area(); - if (B_surface==0) - continue; //wtf - - float clip_area = p_portal->portal_info->portal->bounds.clip(local_bounds).get_area(); - - - //check that most of the area is shared - - if ( (clip_area/A_surface) < 0.5 || (clip_area/B_surface) < 0.5) // TODO change for something else - continue; - - found=B; - break; - - - - } - - - if (!found) { - - if (p_portal->room && p_portal->room->room) { - - p_portal->room->room->room_info->disconnected_child_portals.insert(p_portal); - } - - return; - } - - p_portal->portal_info->connected=found; - found->portal_info->connected=p_portal; - - -} - -void* VisualServerRaster::instance_pair(void *p_self, OctreeElementID, Instance *p_A,int, OctreeElementID, Instance *p_B,int) { - - VisualServerRaster *self = (VisualServerRaster*)p_self; - Instance *A = p_A; - Instance *B = p_B; - - if (A->base_type==INSTANCE_PORTAL) { - - ERR_FAIL_COND_V( B->base_type!=INSTANCE_PORTAL,NULL ); - - A->portal_info->candidate_set.insert(B); - B->portal_info->candidate_set.insert(A); - - self->_portal_attempt_connect(A); - //attempt to conncet portal A (will go through B anyway) - //this is a little hackish, but works fine in practice - - } else if (A->base_type==INSTANCE_BAKED_LIGHT || B->base_type==INSTANCE_BAKED_LIGHT) { - - if (B->base_type==INSTANCE_BAKED_LIGHT) { - SWAP(A,B); - } - - ERR_FAIL_COND_V(B->base_type!=INSTANCE_BAKED_LIGHT_SAMPLER,NULL); - B->baked_light_sampler_info->baked_lights.insert(A); - - } else if (A->base_type==INSTANCE_ROOM || B->base_type==INSTANCE_ROOM) { - - if (B->base_type==INSTANCE_ROOM) - SWAP(A,B); - - ERR_FAIL_COND_V(! ((1<<B->base_type)&INSTANCE_GEOMETRY_MASK ),NULL); - - B->auto_rooms.insert(A); - A->room_info->owned_autoroom_geometry.insert(B); - - self->_instance_validate_autorooms(B); - - - } else { - - if (B->base_type==INSTANCE_LIGHT) { - - SWAP(A,B); - } else if (A->base_type!=INSTANCE_LIGHT) { - return NULL; - } - - - A->light_info->affected.insert(B); - B->lights.insert(A); - B->light_cache_dirty=true; - } - - return NULL; - -} -void VisualServerRaster::instance_unpair(void *p_self, OctreeElementID, Instance *p_A,int, OctreeElementID, Instance *p_B,int,void*) { - - VisualServerRaster *self = (VisualServerRaster*)p_self; - Instance *A = p_A; - Instance *B = p_B; - - if (A->base_type==INSTANCE_PORTAL) { - - ERR_FAIL_COND( B->base_type!=INSTANCE_PORTAL ); - - - A->portal_info->candidate_set.erase(B); - B->portal_info->candidate_set.erase(A); - - //after disconnecting them, see if they can connect again - self->_portal_attempt_connect(A); - self->_portal_attempt_connect(B); - - } else if (A->base_type==INSTANCE_BAKED_LIGHT || B->base_type==INSTANCE_BAKED_LIGHT) { - - if (B->base_type==INSTANCE_BAKED_LIGHT) { - SWAP(A,B); - } - - ERR_FAIL_COND(B->base_type!=INSTANCE_BAKED_LIGHT_SAMPLER); - B->baked_light_sampler_info->baked_lights.erase(A); - - } else if (A->base_type==INSTANCE_ROOM || B->base_type==INSTANCE_ROOM) { - - if (B->base_type==INSTANCE_ROOM) - SWAP(A,B); - - ERR_FAIL_COND(! ((1<<B->base_type)&INSTANCE_GEOMETRY_MASK )); - - B->auto_rooms.erase(A); - B->valid_auto_rooms.erase(A); - A->room_info->owned_autoroom_geometry.erase(B); - - }else { - - - if (B->base_type==INSTANCE_LIGHT) { - - SWAP(A,B); - } else if (A->base_type!=INSTANCE_LIGHT) { - return; - } - - - A->light_info->affected.erase(B); - B->lights.erase(A); - B->light_cache_dirty=true; - } -} - -bool VisualServerRaster::_test_portal_cull(Camera *p_camera, Instance *p_from_portal, Instance *p_to_portal) { - - - int src_point_count=p_from_portal->portal_info->transformed_point_cache.size(); - int dst_point_count=p_to_portal->portal_info->transformed_point_cache.size(); - - if (src_point_count<2 || dst_point_count<2) - return false; - - const Vector3 *src_points=&p_from_portal->portal_info->transformed_point_cache[0]; - const Vector3 *dst_points=&p_to_portal->portal_info->transformed_point_cache[0]; - - bool outside=false; - - bool clockwise = !p_from_portal->portal_info->plane_cache.is_point_over(p_camera->transform.origin); - - for(int i=0;i<src_point_count;i++) { - - const Vector3& point_prev = src_points[i?(i-1):(src_point_count-1)]; - const Vector3& point = src_points[i]; - - Plane p = clockwise?Plane(p_camera->transform.origin,point,point_prev):Plane(p_camera->transform.origin,point_prev,point); - - bool all_over=true; - - for(int j=0;j<dst_point_count;j++) { - - if (!p.is_point_over(dst_points[j])) { - - all_over=false; - break; - } - - } - - if (all_over) { - outside=true; - break; - } - - } - - return !outside; - -} - -void VisualServerRaster::_cull_portal(Camera *p_camera, Instance *p_portal,Instance *p_from_portal) { - - ERR_FAIL_COND(!p_portal->scenario); //scenario outside - - Instance *portal = p_portal; - - if (!portal->room) { - - return; //portals need all to belong to a room, it may be unconfigured yet - } else if (portal->last_render_pass!=render_pass) { - - return; //invalid portal, ignore - } else if (portal->portal_info->last_visited_pass==render_pass) { - - return; //portal already visited - } else if (portal==p_from_portal) { - - return; // came from this portal, don't even bother testing - } - - /* TEST DISABLE DISTANCE */ - - float disable_distance = p_portal->portal_info->portal->disable_distance; - if (disable_distance) { - //has disable distance.. - float distance = p_camera->transform.origin.distance_to(portal->data.transform.origin); - if (disable_distance < distance) { - - return; - } - } - - /* TEST PORTAL NOT FACING OPTIMIZATION */ - - - if (p_portal->portal_info->connected) { - //connected portal means, it must face against the camera to be seen - if (p_portal->portal_info->plane_cache.is_point_over(p_camera->transform.origin)) { //portal facing against camera (exterior) - - return; - } - } else { - //disconencted portals (go from room to parent room or exterior) must face towards the canera - if (!p_portal->portal_info->plane_cache.is_point_over(p_camera->transform.origin)) { //portal facing against camera (exterior) - - return; - } - } - - if (p_from_portal && !_test_portal_cull(p_camera, p_from_portal, portal)) { - return; // portal not visible (culled) - } - - portal->portal_info->last_visited_pass=render_pass; - - if (portal->portal_info->connected) { - - //interior<->interior portal - Instance *to_room = portal->portal_info->connected->room; - if (!to_room) { - return; //wtf.. oh well, connected to a roomless (invalid) portal - } - - _cull_room(p_camera, to_room, portal->portal_info->connected); - - } else { - //to exterior/to parent roomportal - - Instance *parent_room = portal->room->room; - - _cull_room(p_camera, parent_room, portal); - } - -} - -void VisualServerRaster::_cull_room(Camera *p_camera, Instance *p_room,Instance *p_from_portal) { - - if (p_room==NULL) { - //exterior - exterior_visited=true; - - for(int i=0;i<exterior_portal_cull_count;i++) { - - _cull_portal(p_camera, exterior_portal_cull_result[i],p_from_portal); - } - - } else { - - ERR_FAIL_COND(!p_room->scenario); - - if (p_room->last_render_pass!=render_pass) - return; //this room is invalid - - //interior - //first of all, validate the room - p_room->room_info->last_visited_pass=render_pass; - //see about going around portals - if (!p_room->room_info->room->occlude_exterior) - exterior_visited=true; - - for(List<Instance*>::Element * E=p_room->room_info->owned_portal_instances.front();E;E=E->next()) { - - _cull_portal(p_camera, E->get(),p_from_portal); - - } - - for(Set<Instance*>::Element * E=p_room->room_info->disconnected_child_portals.front();E;E=E->next()) { - - _cull_portal(p_camera, E->get(),p_from_portal); - - } - - - } - -} - -void VisualServerRaster::_process_sampled_light(const Transform& p_camera,Instance *p_sampled_light,bool p_linear_colorspace) { - - - BakedLightSampler *sampler_opts = p_sampled_light->baked_light_sampler_info->sampler; - int res = sampler_opts->resolution; - int dp_size = res*res*2; - Color * dp_map = (Color*)alloca( sizeof(Color)*dp_size); //allocate the dual parabolloid colors - Vector3 * dp_normals = (Vector3*)alloca( sizeof(Vector3)*dp_size); //allocate the dual parabolloid normals - const Vector3 * dp_src_normals = p_sampled_light->baked_light_sampler_info->sampler->dp_cache.ptr(); - - - if (!p_sampled_light->baked_light_sampler_info->sampled_light.is_valid() || p_sampled_light->baked_light_sampler_info->resolution!=sampler_opts->resolution) { - if (p_sampled_light->baked_light_sampler_info->sampled_light.is_valid()) { - rasterizer->free(p_sampled_light->baked_light_sampler_info->sampled_light); - } - - p_sampled_light->baked_light_sampler_info->resolution=sampler_opts->resolution; - p_sampled_light->baked_light_sampler_info->sampled_light=rasterizer->sampled_light_dp_create(sampler_opts->resolution,sampler_opts->resolution*2); - - - } - - - zeromem(dp_map,sizeof(Color)*dp_size); - bool valid=false; - int samples=0; - - - for(Set<Instance*>::Element *E=p_sampled_light->baked_light_sampler_info->baked_lights.front();E;E=E->next()) { - - Instance *bl = E->get(); - if (bl->baked_light_info->baked_light->sampler.size()==0) - continue; //not usable - - - Matrix3 norm_xform = bl->baked_light_info->affine_inverse.basis;//.inverse(); - for(int i=0;i<dp_size;i++) { - dp_normals[i]=norm_xform.xform(dp_src_normals[i]).normalized(); - } - - //normals in place - - - //sample octree - - float r = sampler_opts->params[VS::BAKED_LIGHT_SAMPLER_RADIUS]; - float att = sampler_opts->params[VS::BAKED_LIGHT_SAMPLER_ATTENUATION]; - float str = sampler_opts->params[VS::BAKED_LIGHT_SAMPLER_STRENGTH]; - Vector3 s = p_sampled_light->data.transform.basis.get_scale(); - - r*=MAX(MAX(s.x,s.y),s.z); - AABB sample_aabb= bl->data.transform.affine_inverse().xform(AABB(Vector3(-r,-r,-r)+p_sampled_light->data.transform.origin,Vector3(r*2,r*2,r*2))); - //ok got octree local AABB - - PoolVector<int>::Read rp = bl->baked_light_info->baked_light->sampler.read(); - const int *rptr = rp.ptr(); - - int first = rptr[1]; - int depth = rptr[2]; - bool islinear = rptr[3]&1; - depth+=1; - - AABB aabb; - aabb.pos.x=decode_float((const uint8_t*)&rptr[4]); - aabb.pos.y=decode_float((const uint8_t*)&rptr[5]); - aabb.pos.z=decode_float((const uint8_t*)&rptr[6]); - aabb.size.x=decode_float((const uint8_t*)&rptr[7]); - aabb.size.y=decode_float((const uint8_t*)&rptr[8]); - aabb.size.z=decode_float((const uint8_t*)&rptr[9]); - - uint32_t *stack=(uint32_t*)alloca(depth*sizeof(uint32_t)); - int *stack_ptr=(int*)alloca(depth*sizeof(int)); - AABB *aabb_stack=(AABB*)alloca(depth*sizeof(AABB)); - - stack[0]=0; - stack_ptr[0]=first; - aabb_stack[0]=aabb; - Vector3 center = sample_aabb.pos + sample_aabb.size * 0.5; - - - int stack_pos=0; - Color max_col; - - //int reso = sampler_opts->params[VS::BAKED_LIGHT_SAMPLER_DETAIL_RATIO]; - - int lalimit = sample_aabb.get_longest_axis_index(); - float limit = sampler_opts->params[VS::BAKED_LIGHT_SAMPLER_DETAIL_RATIO]*sample_aabb.size[lalimit]; - - - while(true) { - - - bool leaf = (rptr[ stack_ptr[stack_pos] ]>>16)==0; - - if (aabb_stack[stack_pos].size[lalimit]<limit) { - leaf=true; - } - - - if (leaf) { - - Vector3 from = aabb_stack[stack_pos].pos + aabb_stack[stack_pos].size * 0.5; - Vector3 norm = (from-center).normalized(); - - - Color col; - col.r = ((rptr[ stack_ptr[stack_pos] ]&0xFFFF)/256.0); - col.g = ((rptr[ stack_ptr[stack_pos]+1 ]>>16)/256.0); - col.b = ((rptr[ stack_ptr[stack_pos]+1 ]&0xFFFF)/256.0); - - - max_col.r = MAX(max_col.r,col.r); - max_col.g = MAX(max_col.g,col.g); - max_col.b = MAX(max_col.b,col.b); - - if (!islinear && p_linear_colorspace) { - col=col.to_linear(); - } - - float distance; - - if (aabb_stack[stack_pos].has_point(center)) { - distance=0; - } else { - - Vector3 support = aabb_stack[stack_pos].get_support(norm); - distance = Math::absf(norm.dot(support)-norm.dot(center)); - - } - - if (distance>r) - distance=r; - - float mult = Math::pow(1.0-distance/r,att)*str; - if (mult>0) { - col.r*=mult; - col.g*=mult; - col.b*=mult; - - - - for(int i=0;i<dp_size;i++) { - float mult2 = norm.dot(dp_normals[i]); - if (mult2<0) - mult2=0; - Color col2(col.r*mult2,col.g*mult2,col.b*mult2,1.0); - dp_map[i].r=MAX(dp_map[i].r,col2.r); - dp_map[i].g=MAX(dp_map[i].g,col2.g); - dp_map[i].b=MAX(dp_map[i].b,col2.b); - } - - } - - samples++; - //nothing is valid unless you hit a leaf - valid=true; - stack_pos--; - } else if ((stack[stack_pos]&0xFF)<8) { - - int i = stack[stack_pos]&0xFF; - int base = (stack[stack_pos]>>8); - - if (!((rptr[ stack_ptr[stack_pos] ]>>16)&(1<<i))) { - //no bit, no test - stack[stack_pos]=(base<<8)+(i+1); - continue; - } - - stack[stack_pos]=((base+1)<<8)+(i+1); - - AABB child_aabb = aabb_stack[stack_pos]; - child_aabb.size*=0.5; - if (i&1) - child_aabb.pos.x+=child_aabb.size.x; - if (i&2) - child_aabb.pos.y+=child_aabb.size.y; - if (i&4) - child_aabb.pos.z+=child_aabb.size.z; - - if (!child_aabb.intersects(sample_aabb)) { - continue; - } - - if (child_aabb.encloses(sample_aabb)) { - stack[stack_pos]=(base<<8)|8; //don't test the rest - } - - stack_pos++; - ERR_FAIL_COND(stack_pos>=depth); - - stack[stack_pos]=0; - stack_ptr[stack_pos]=rptr[ stack_ptr[stack_pos-1]+2+base ]; - aabb_stack[stack_pos]=child_aabb; - } else { - stack_pos--; - if (stack_pos<0) - break; - } - } - - - } - - //print_line("samples "+itos(samples) ); - - if (valid) { - - for(int i=0;i<res;i++) { - //average seams to avoid aliasing - { - //top - int ofs1 = i; - int ofs2 = dp_size-res+i; - Color avg( - (dp_map[ofs1].r+dp_map[ofs2].r)*0.5, - (dp_map[ofs1].g+dp_map[ofs2].g)*0.5, - (dp_map[ofs1].b+dp_map[ofs2].b)*0.5, - 1.0 - ); - dp_map[ofs1]=avg; - dp_map[ofs2]=avg; - } - { - //bottom - int ofs1 = res*res-res+i; - int ofs2 = res*res+i; - Color avg( - (dp_map[ofs1].r+dp_map[ofs2].r)*0.5, - (dp_map[ofs1].g+dp_map[ofs2].g)*0.5, - (dp_map[ofs1].b+dp_map[ofs2].b)*0.5, - 1.0 - ); - dp_map[ofs1]=avg; - dp_map[ofs2]=avg; - } - { - //left - int ofs1 = i*res; - int ofs2 = res*res+(res-i-1)*res; - Color avg( - (dp_map[ofs1].r+dp_map[ofs2].r)*0.5, - (dp_map[ofs1].g+dp_map[ofs2].g)*0.5, - (dp_map[ofs1].b+dp_map[ofs2].b)*0.5, - 1.0 - ); - dp_map[ofs1]=avg; - dp_map[ofs2]=avg; - } - { - //right - int ofs1 = i*res+(res-1); - int ofs2 = res*res+(res-i-1)*res+(res-1); - Color avg( - (dp_map[ofs1].r+dp_map[ofs2].r)*0.5, - (dp_map[ofs1].g+dp_map[ofs2].g)*0.5, - (dp_map[ofs1].b+dp_map[ofs2].b)*0.5, - 1.0 - ); - dp_map[ofs1]=avg; - dp_map[ofs2]=avg; - } - - } - - rasterizer->sampled_light_dp_update(p_sampled_light->baked_light_sampler_info->sampled_light,dp_map,1.0); - for(Set<Instance*>::Element *F=p_sampled_light->baked_light_sampler_info->owned_instances.front();F;F=F->next()) { - - F->get()->data.sampled_light=p_sampled_light->baked_light_sampler_info->sampled_light; - } - - - } else { - - for(Set<Instance*>::Element *F=p_sampled_light->baked_light_sampler_info->owned_instances.front();F;F=F->next()) { - - F->get()->data.sampled_light; //do not use because nothing close - } - } - - - - -/* - highp vec3 vtx = vertex_interp; - vtx.z*=dual_paraboloid.y; //side to affect - vtx.z+=0.01; - dp_clip=vtx.z; - highp float len=length( vtx ); - vtx=normalize(vtx); - vtx.xy/=1.0+vtx.z; - vtx.z = len*dual_paraboloid.x; // it's a reciprocal(len - z_near) / (z_far - z_near); - vtx+=normalize(vtx)*0.025; - vtx.z = vtx.z * 2.0 - 1.0; // fit to clipspace - vertex_interp=vtx; -*/ - - - - -} - - -void VisualServerRaster::_render_no_camera(Viewport *p_viewport,Camera *p_camera, Scenario *p_scenario) { - RID environment; - if (p_scenario->environment.is_valid()) - environment=p_scenario->environment; - else - environment=p_scenario->fallback_environment; - - rasterizer->set_camera(Transform(),CameraMatrix(),false); - rasterizer->begin_scene(p_viewport->viewport_data,environment,p_scenario->debug); - rasterizer->set_viewport(viewport_rect); - rasterizer->end_scene(); -} - - -void VisualServerRaster::_render_camera(Viewport *p_viewport,Camera *p_camera, Scenario *p_scenario) { - - - render_pass++; - uint32_t camera_layer_mask=p_camera->visible_layers; - - /* STEP 1 - SETUP CAMERA */ - CameraMatrix camera_matrix; - bool ortho=false; - - switch(p_camera->type) { - case Camera::ORTHOGONAL: { - - camera_matrix.set_orthogonal( - p_camera->size, - viewport_rect.width / (float)viewport_rect.height, - p_camera->znear, - p_camera->zfar, - p_camera->vaspect - - ); - ortho=true; - } break; - case Camera::PERSPECTIVE: { - - camera_matrix.set_perspective( - p_camera->fov, - viewport_rect.width / (float)viewport_rect.height, - p_camera->znear, - p_camera->zfar, - p_camera->vaspect - - ); - ortho=false; - - } break; - } - - - rasterizer->set_camera(p_camera->transform, camera_matrix,ortho); - - Vector<Plane> planes = camera_matrix.get_projection_planes(p_camera->transform); - - CullRange cull_range; // cull range is used for PSSM, and having an idea of the rendering depth - cull_range.nearp=Plane(p_camera->transform.origin,-p_camera->transform.basis.get_axis(2).normalized()); - cull_range.z_near=camera_matrix.get_z_near(); - cull_range.z_far=camera_matrix.get_z_far(); - cull_range.min=cull_range.z_far; - cull_range.max=cull_range.z_near; - - /* STEP 2 - CULL */ - int cull_count = p_scenario->octree.cull_convex(planes,instance_cull_result,MAX_INSTANCE_CULL); - light_cull_count=0; - light_samplers_culled=0; - -/* print_line("OT: "+rtos( (OS::get_singleton()->get_ticks_usec()-t)/1000.0)); - print_line("OTO: "+itos(p_scenario->octree.get_octant_count())); - //print_line("OTE: "+itos(p_scenario->octree.get_elem_count())); - print_line("OTP: "+itos(p_scenario->octree.get_pair_count())); -*/ - - /* STEP 3 - PROCESS PORTALS, VALIDATE ROOMS */ - - - // compute portals - - exterior_visited=false; - exterior_portal_cull_count=0; - - if (room_cull_enabled) { - for(int i=0;i<cull_count;i++) { - - Instance *ins = instance_cull_result[i]; - ins->last_render_pass=render_pass; - - if (ins->base_type!=INSTANCE_PORTAL) - continue; - - if (ins->room) - continue; - - ERR_CONTINUE(exterior_portal_cull_count>=MAX_EXTERIOR_PORTALS); - exterior_portal_cull_result[exterior_portal_cull_count++]=ins; - - } - - room_cull_count = p_scenario->octree.cull_point(p_camera->transform.origin,room_cull_result,MAX_ROOM_CULL,NULL,(1<<INSTANCE_ROOM)|(1<<INSTANCE_PORTAL)); - - - Set<Instance*> current_rooms; - Set<Instance*> portal_rooms; - //add to set - for(int i=0;i<room_cull_count;i++) { - - if (room_cull_result[i]->base_type==INSTANCE_ROOM) { - current_rooms.insert(room_cull_result[i]); - } - if (room_cull_result[i]->base_type==INSTANCE_PORTAL) { - //assume inside that room if also inside the portal.. - if (room_cull_result[i]->room) { - portal_rooms.insert(room_cull_result[i]->room); - } - - SWAP(room_cull_result[i],room_cull_result[room_cull_count-1]); - room_cull_count--; - i--; - } - } - - //remove from set if it has a parent room or BSP doesn't contain - for(int i=0;i<room_cull_count;i++) { - Instance *r = room_cull_result[i]; - - //check inside BSP - Vector3 room_local_point = r->room_info->affine_inverse.xform( p_camera->transform.origin ); - - if (!portal_rooms.has(r) && !r->room_info->room->bounds.point_is_inside(room_local_point)) { - - current_rooms.erase(r); - continue; - } - - //check parent - while (r->room) {// has parent room - - current_rooms.erase(r); - r=r->room; - } - - } - - if (current_rooms.size()) { - //camera is inside a room - // go through rooms - for(Set<Instance*>::Element *E=current_rooms.front();E;E=E->next()) { - _cull_room(p_camera,E->get()); - } - - } else { - //start from exterior - _cull_room(p_camera,NULL); - - } - } - - /* STEP 4 - REMOVE FURTHER CULLED OBJECTS, ADD LIGHTS */ - - for(int i=0;i<cull_count;i++) { - - Instance *ins = instance_cull_result[i]; - - bool keep=false; - - - if ((camera_layer_mask&ins->layer_mask)==0) { - - //failure - } else if (ins->base_type==INSTANCE_LIGHT) { - - if (light_cull_count<MAX_LIGHTS_CULLED) { - light_cull_result[light_cull_count++]=ins; - //rasterizer->light_instance_set_active_hint(ins->light_info->instance); - { - //compute distance to camera using aabb support - Vector3 n = ins->data.transform.basis.xform_inv(cull_range.nearp.normal).normalized(); - Vector3 s = ins->data.transform.xform(ins->aabb.get_support(n)); - ins->light_info->dtc=cull_range.nearp.distance_to(s); - } - } - - } else if ((1<<ins->base_type)&INSTANCE_GEOMETRY_MASK && ins->visible && ins->data.cast_shadows!=VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) { - - - bool discarded=false; - - if (ins->draw_range_end>0) { - - float d = cull_range.nearp.distance_to(ins->data.transform.origin); - if (d<0) - d=0; - discarded=(d<ins->draw_range_begin || d>=ins->draw_range_end); - - - } - - if (!discarded) { - - // test if this geometry should be visible - - if (room_cull_enabled) { - - - if (ins->visible_in_all_rooms) { - keep=true; - } else if (ins->room) { - - if (ins->room->room_info->last_visited_pass==render_pass) - keep=true; - } else if (ins->auto_rooms.size()) { - - - for(Set<Instance*>::Element *E=ins->auto_rooms.front();E;E=E->next()) { - - if (E->get()->room_info->last_visited_pass==render_pass) { - keep=true; - break; - } - } - } else if(exterior_visited) - keep=true; - } else { - - keep=true; - } - - - } - - - if (keep) { - // update cull range - float min,max; - ins->transformed_aabb.project_range_in_plane(cull_range.nearp,min,max); - - if (min<cull_range.min) - cull_range.min=min; - if (max>cull_range.max) - cull_range.max=max; - - if (ins->sampled_light && ins->sampled_light->baked_light_sampler_info->last_pass!=render_pass) { - if (light_samplers_culled<MAX_LIGHT_SAMPLERS) { - light_sampler_cull_result[light_samplers_culled++]=ins->sampled_light; - ins->sampled_light->baked_light_sampler_info->last_pass=render_pass; - } - } - } - - } - - if (!keep) { - // remove, no reason to keep - cull_count--; - SWAP( instance_cull_result[i], instance_cull_result[ cull_count ] ); - i--; - ins->last_render_pass=0; // make invalid - } else { - - ins->last_render_pass=render_pass; - } - } - - if (cull_range.max > cull_range.z_far ) - cull_range.max=cull_range.z_far; - if (cull_range.min < cull_range.z_near ) - cull_range.min=cull_range.z_near; - - /* STEP 5 - PROCESS LIGHTS */ - - rasterizer->shadow_clear_near(); //clear near shadows, will be recreated - - // directional lights - { - List<RID>::Element *E=p_scenario->directional_lights.front(); - - - while(E) { - - Instance *light = E->get().is_valid()?instance_owner.get(E->get()):NULL; - - if (light && light->light_info->enabled && rasterizer->light_has_shadow(light->base_rid)) { - //rasterizer->light_instance_set_active_hint(light->light_info->instance); - _light_instance_update_shadow(light,p_scenario,p_camera,cull_range); - } - - E=E->next(); - } - } - - - //discard lights not affecting anything (useful for deferred rendering, shadowmaps, etc) - - for (int i=0;i<light_cull_count;i++) { - - Instance *ins = light_cull_result[i]; - - if (light_discard_enabled) { - - //see if the light should be pre discarded because no one is seeing it - //this test may seem expensive, but in reality, it shouldn't be - //because of early out condition. It will only go through everything - //if it's being discarded. - - bool valid=false; - InstanceSet::Element *E =ins->light_info->affected.front(); - while(E) { - - if (E->get()->last_render_pass==render_pass) { - - valid=true; // early out. - break; - } - E=E->next(); - } - if (!valid) { - - light_cull_count--; - SWAP( light_cull_result[i], light_cull_result[ light_cull_count ] ); - i--; - - } - } - - } - - { //this should eventually change to - //assign shadows by distance to camera - SortArray<Instance*,_InstanceLightsort> sorter; - sorter.sort(light_cull_result,light_cull_count); - for (int i=0;i<light_cull_count;i++) { - - Instance *ins = light_cull_result[i]; - - if (!rasterizer->light_has_shadow(ins->base_rid) || !shadows_enabled) - continue; - - /* for far shadows? - if (ins->version == ins->light_info->last_version && rasterizer->light_instance_has_far_shadow(ins->light_info->instance)) - continue; // didn't change - */ - - _light_instance_update_shadow(ins,p_scenario,p_camera,cull_range); - ins->light_info->last_version=ins->version; - } - } - - /* ENVIRONMENT */ - - RID environment; - if (p_camera->env.is_valid()) //camera has more environment priority - environment=p_camera->env; - else if (p_scenario->environment.is_valid()) - environment=p_scenario->environment; - else - environment=p_scenario->fallback_environment; - - - /* STEP 6 - SAMPLE BAKED LIGHT */ - - bool islinear =false; - if (environment.is_valid()) { - islinear = rasterizer->environment_is_fx_enabled(environment,VS::ENV_FX_SRGB); - } - - for(int i=0;i<light_samplers_culled;i++) { - - _process_sampled_light(p_camera->transform,light_sampler_cull_result[i],islinear); - } - - /* STEP 7 - PROCESS GEOMETRY AND DRAW SCENE*/ - - - rasterizer->begin_scene(p_viewport->viewport_data,environment,p_scenario->debug); - rasterizer->set_viewport(viewport_rect); - - // add lights - - { - List<RID>::Element *E=p_scenario->directional_lights.front(); - - - for(;E;E=E->next()) { - Instance *light = E->get().is_valid()?instance_owner.get(E->get()):NULL; - - ERR_CONTINUE(!light); - if (!light->light_info->enabled) - continue; - - rasterizer->add_light(light->light_info->instance); - light->light_info->last_add_pass=render_pass; - } - - for (int i=0;i<light_cull_count;i++) { - - Instance *ins = light_cull_result[i]; - rasterizer->add_light(ins->light_info->instance); - ins->light_info->last_add_pass=render_pass; - } - } - // add geometry - - for(int i=0;i<cull_count;i++) { - - Instance *ins = instance_cull_result[i]; - - ERR_CONTINUE(!((1<<ins->base_type)&INSTANCE_GEOMETRY_MASK)); - - _instance_draw(ins); - } - - rasterizer->end_scene(); -} - - -void VisualServerRaster::_render_canvas_item_tree(CanvasItem *p_canvas_item, const Matrix32& p_transform, const Rect2& p_clip_rect, const Color& p_modulate, Rasterizer::CanvasLight *p_lights) { - - - static const int z_range = CANVAS_ITEM_Z_MAX-CANVAS_ITEM_Z_MIN+1; - Rasterizer::CanvasItem *z_list[z_range]; - Rasterizer::CanvasItem *z_last_list[z_range]; - - for(int i=0;i<z_range;i++) { - z_list[i]=NULL; - z_last_list[i]=NULL; - } - - - _render_canvas_item(p_canvas_item,p_transform,p_clip_rect,1.0,0,z_list,z_last_list,NULL,NULL); - - for(int i=0;i<z_range;i++) { - if (!z_list[i]) - continue; - rasterizer->canvas_render_items(z_list[i],CANVAS_ITEM_Z_MIN+i,p_modulate,p_lights); - } - -} - - -void VisualServerRaster::_render_canvas_item_viewport(VisualServer* p_self,void *p_vp,const Rect2& p_rect) { - - VisualServerRaster *self=(VisualServerRaster*)(p_self); - Viewport *vp=(Viewport*)p_vp; - self->_draw_viewport(vp,p_rect.pos.x,p_rect.pos.y,p_rect.size.x,p_rect.size.y); - self->rasterizer->canvas_begin(); - -} - - -void VisualServerRaster::_render_canvas_item(CanvasItem *p_canvas_item,const Matrix32& p_transform,const Rect2& p_clip_rect, float p_opacity,int p_z,Rasterizer::CanvasItem **z_list,Rasterizer::CanvasItem **z_last_list,CanvasItem *p_canvas_clip,CanvasItem *p_material_owner) { - - CanvasItem *ci = p_canvas_item; - - if (!ci->visible) - return; - - if (p_opacity<0.007) - return; - - - Rect2 rect = ci->get_rect(); - Matrix32 xform = p_transform * ci->xform; - Rect2 global_rect = xform.xform(rect); - global_rect.pos+=p_clip_rect.pos; - - - if (global_rect.intersects(p_clip_rect) && ci->viewport.is_valid() && viewport_owner.owns(ci->viewport)) { - - Viewport *vp = viewport_owner.get(ci->viewport); - - Point2i from = xform.get_origin() + Point2(viewport_rect.x,viewport_rect.y); - Point2i size = rect.size; - size.x *= xform[0].length(); - size.y *= xform[1].length(); - - ci->vp_render = memnew( Rasterizer::CanvasItem::ViewportRender ); - ci->vp_render->owner=this; - ci->vp_render->udata=vp; - ci->vp_render->rect=Rect2(from.x, - from.y, - size.x, - size.y); -/* - _draw_viewport(vp, - from.x, - from.y, - size.x, - size.y); -*/ - //rasterizer->canvas_begin(); - } else { - ci->vp_render=NULL; - } - - if (ci->use_parent_material && p_material_owner) - ci->material_owner=p_material_owner; - else { - p_material_owner=ci; - ci->material_owner=NULL; - } - - - float opacity = ci->opacity * p_opacity; - - - int child_item_count=ci->child_items.size(); - CanvasItem **child_items=(CanvasItem**)alloca(child_item_count*sizeof(CanvasItem*)); - copymem(child_items,ci->child_items.ptr(),child_item_count*sizeof(CanvasItem*)); - - if (ci->clip) { - if (p_canvas_clip != NULL) { - ci->final_clip_rect=p_canvas_clip->final_clip_rect.clip(global_rect); - } else { - ci->final_clip_rect=global_rect; - } - ci->final_clip_owner=ci; - - } else { - ci->final_clip_owner=p_canvas_clip; - } - - if (ci->sort_y) { - - SortArray<CanvasItem*,CanvasItemPtrSort> sorter; - sorter.sort(child_items,child_item_count); - } - - if (ci->z_relative) - p_z=CLAMP(p_z+ci->z,CANVAS_ITEM_Z_MIN,CANVAS_ITEM_Z_MAX); - else - p_z=ci->z; - - for(int i=0;i<child_item_count;i++) { - - if (child_items[i]->ontop) - continue; - _render_canvas_item(child_items[i],xform,p_clip_rect,opacity,p_z,z_list,z_last_list,(CanvasItem*)ci->final_clip_owner,p_material_owner); - } - - if (ci->copy_back_buffer) { - - ci->copy_back_buffer->screen_rect = xform.xform(ci->copy_back_buffer->rect).clip(p_clip_rect); - } - - if ((!ci->commands.empty() && p_clip_rect.intersects(global_rect)) || ci->vp_render || ci->copy_back_buffer) { - //something to draw? - ci->final_transform=xform; - ci->final_opacity=opacity * ci->self_opacity; - ci->global_rect_cache=global_rect; - ci->global_rect_cache.pos-=p_clip_rect.pos; - ci->light_masked=false; - - int zidx = p_z-CANVAS_ITEM_Z_MIN; - - if (z_last_list[zidx]) { - z_last_list[zidx]->next=ci; - z_last_list[zidx]=ci; - - } else { - z_list[zidx]=ci; - z_last_list[zidx]=ci; - } - - - - ci->next=NULL; - - } - - for(int i=0;i<child_item_count;i++) { - - if (!child_items[i]->ontop) - continue; - _render_canvas_item(child_items[i],xform,p_clip_rect,opacity,p_z,z_list,z_last_list,(CanvasItem*)ci->final_clip_owner,p_material_owner); - } - -} - -void VisualServerRaster::_light_mask_canvas_items(int p_z,Rasterizer::CanvasItem *p_canvas_item,Rasterizer::CanvasLight *p_masked_lights) { - - if (!p_masked_lights) - return; - - Rasterizer::CanvasItem *ci=p_canvas_item; - - while(ci) { - - Rasterizer::CanvasLight *light=p_masked_lights; - while(light) { - - if (ci->light_mask&light->item_mask && p_z>=light->z_min && p_z<=light->z_max && ci->global_rect_cache.intersects_transformed(light->xform_cache,light->rect_cache)) { - ci->light_masked=true; - } - - light=light->mask_next_ptr; - } - - ci=ci->next; - } - - - - -} - -void VisualServerRaster::_render_canvas(Canvas *p_canvas,const Matrix32 &p_transform,Rasterizer::CanvasLight *p_lights,Rasterizer::CanvasLight *p_masked_lights) { - - rasterizer->canvas_begin(); - - int l = p_canvas->child_items.size(); - Canvas::ChildItem *ci=p_canvas->child_items.ptr(); - - bool has_mirror=false; - for(int i=0;i<l;i++) { - if (ci[i].mirror.x || ci[i].mirror.y) { - has_mirror=true; - break; - } - } - - Rect2 clip_rect(viewport_rect.x,viewport_rect.y,viewport_rect.width,viewport_rect.height); - if (!has_mirror) { - - static const int z_range = CANVAS_ITEM_Z_MAX-CANVAS_ITEM_Z_MIN+1; - Rasterizer::CanvasItem *z_list[z_range]; - Rasterizer::CanvasItem *z_last_list[z_range]; - - for(int i=0;i<z_range;i++) { - z_list[i]=NULL; - z_last_list[i]=NULL; - } - for(int i=0;i<l;i++) { - _render_canvas_item(ci[i].item,p_transform,clip_rect,1.0,0,z_list,z_last_list,NULL,NULL); - } - - for(int i=0;i<z_range;i++) { - if (!z_list[i]) - continue; - - if (p_masked_lights) { - _light_mask_canvas_items(CANVAS_ITEM_Z_MIN+i,z_list[i],p_masked_lights); - } - - rasterizer->canvas_render_items(z_list[i],CANVAS_ITEM_Z_MIN+i,p_canvas->modulate,p_lights); - } - } else { - - for(int i=0;i<l;i++) { - - Canvas::ChildItem& ci=p_canvas->child_items[i]; - _render_canvas_item_tree(ci.item,p_transform,clip_rect,p_canvas->modulate,p_lights); - - //mirroring (useful for scrolling backgrounds) - if (ci.mirror.x!=0) { - - Matrix32 xform2 = p_transform * Matrix32(0,Vector2(ci.mirror.x,0)); - _render_canvas_item_tree(ci.item,xform2,clip_rect,p_canvas->modulate,p_lights); - } - if (ci.mirror.y!=0) { - - Matrix32 xform2 = p_transform * Matrix32(0,Vector2(0,ci.mirror.y)); - _render_canvas_item_tree(ci.item,xform2,clip_rect,p_canvas->modulate,p_lights); - } - if (ci.mirror.y!=0 && ci.mirror.x!=0) { - - Matrix32 xform2 = p_transform * Matrix32(0,ci.mirror); - _render_canvas_item_tree(ci.item,xform2,clip_rect,p_canvas->modulate,p_lights); - } - - } - } - -} - - -void VisualServerRaster::_draw_viewport_camera(Viewport *p_viewport,bool p_ignore_camera) { - - - Camera *camera=NULL; - if (camera_owner.owns( p_viewport->camera )) - camera=camera_owner.get( p_viewport->camera ); - Scenario *scenario = scenario_owner.get( p_viewport->scenario ); - - _update_instances(); // check dirty instances before rendering - - if (p_ignore_camera) - _render_no_camera(p_viewport, camera,scenario ); - else - _render_camera(p_viewport, camera,scenario ); - -} - -void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_ofs_y,int p_parent_w,int p_parent_h) { - - ViewportRect desired_rect=p_viewport->rect; - ViewportRect old_rect = viewport_rect; - //bool vpchanged=false; - // convert default expanding viewports to actual size - //if (desired_rect.x==0 && desired_rect.y==0 && desired_rect.width==0 && desired_rect.height==0) { - if (p_parent_w != 0 && p_parent_h != 0) { - - desired_rect.width=p_parent_w; - desired_rect.height=p_parent_h; - } - - ERR_FAIL_COND(desired_rect.width<=0 || desired_rect.height<=0); - - desired_rect.x+=p_ofs_x; - desired_rect.y+=p_ofs_y; - - - // if the viewport is different than the actual one, change it - - if ( p_viewport->render_target.is_valid() || viewport_rect.x != desired_rect.x || - viewport_rect.y != desired_rect.y || - viewport_rect.width != desired_rect.width || - viewport_rect.height != desired_rect.height ) { - - - viewport_rect=desired_rect; - rasterizer->set_viewport(viewport_rect); - - } - - /* Camera should always be BEFORE any other 3D */ - - bool scenario_draw_canvas_bg=false; - int scenario_canvas_max_layer=0; - - if (!p_viewport->hide_canvas && !p_viewport->disable_environment && scenario_owner.owns(p_viewport->scenario)) { - - Scenario *scenario=scenario_owner.get(p_viewport->scenario); - if (scenario->environment.is_valid()) { - if (rasterizer->is_environment(scenario->environment)) { - scenario_draw_canvas_bg=rasterizer->environment_get_background(scenario->environment)==VS::ENV_BG_CANVAS; - scenario_canvas_max_layer=rasterizer->environment_get_background_param(scenario->environment,VS::ENV_BG_PARAM_CANVAS_MAX_LAYER); - } - } - } - - bool can_draw_3d=!p_viewport->hide_scenario && camera_owner.owns(p_viewport->camera) && scenario_owner.owns(p_viewport->scenario); - - - if (scenario_draw_canvas_bg) { - - rasterizer->begin_canvas_bg(); - } - - if (!scenario_draw_canvas_bg && can_draw_3d) { - - _draw_viewport_camera(p_viewport,false); - - } else if (true /*|| !p_viewport->canvas_list.empty()*/){ - - //clear the viewport black because of no camera? i seriously should.. - if (p_viewport->render_target_clear_on_new_frame || p_viewport->render_target_clear) { - if (p_viewport->transparent_bg) { - rasterizer->clear_viewport(Color(0,0,0,0)); - } - else { - Color cc=clear_color; - if (scenario_draw_canvas_bg) - cc.a=0; - rasterizer->clear_viewport(cc); - } - p_viewport->render_target_clear=false; - } - } - - if (!p_viewport->hide_canvas) { - int i=0; - - Map<Viewport::CanvasKey,Viewport::CanvasData*> canvas_map; - - Rect2 clip_rect(0,0,viewport_rect.width,viewport_rect.height); - Rasterizer::CanvasLight *lights=NULL; - Rasterizer::CanvasLight *lights_with_shadow=NULL; - Rasterizer::CanvasLight *lights_with_mask=NULL; - Rect2 shadow_rect; - - int light_count=0; - - for (Map<RID,Viewport::CanvasData>::Element *E=p_viewport->canvas_map.front();E;E=E->next()) { - - Matrix32 xf = p_viewport->global_transform * E->get().transform; - - //find lights in canvas - - - for(Set<Rasterizer::CanvasLight*>::Element *F=E->get().canvas->lights.front();F;F=F->next()) { - - - Rasterizer::CanvasLight* cl=F->get(); - if (cl->enabled && cl->texture.is_valid()) { - //not super efficient.. - Size2 tsize(rasterizer->texture_get_width(cl->texture),rasterizer->texture_get_height(cl->texture)); - tsize*=cl->scale; - - Vector2 offset=tsize/2.0; - cl->rect_cache=Rect2(-offset+cl->texture_offset,tsize); - cl->xform_cache=xf * cl->xform; - - - if (clip_rect.intersects_transformed(cl->xform_cache,cl->rect_cache)) { - - cl->filter_next_ptr=lights; - lights=cl; - cl->texture_cache=NULL; - Matrix32 scale; - scale.scale(cl->rect_cache.size); - scale.elements[2]=cl->rect_cache.pos; - cl->light_shader_xform = (cl->xform_cache * scale).affine_inverse(); - cl->light_shader_pos=cl->xform_cache[2]; - if (cl->shadow_buffer.is_valid()) { - - cl->shadows_next_ptr=lights_with_shadow; - if (lights_with_shadow==NULL) { - shadow_rect = cl->xform_cache.xform(cl->rect_cache); - } else { - shadow_rect=shadow_rect.merge( cl->xform_cache.xform(cl->rect_cache) ); - } - lights_with_shadow=cl; - cl->radius_cache=cl->rect_cache.size.length(); - - } - if (cl->mode==CANVAS_LIGHT_MODE_MASK) { - cl->mask_next_ptr=lights_with_mask; - lights_with_mask=cl; - } - - light_count++; - } - - } - } - - //print_line("lights: "+itos(light_count)); - canvas_map[ Viewport::CanvasKey( E->key(), E->get().layer) ]=&E->get(); - - } - - if (lights_with_shadow) { - //update shadows if any - - Rasterizer::CanvasLightOccluderInstance * occluders=NULL; - - //make list of occluders - for (Map<RID,Viewport::CanvasData>::Element *E=p_viewport->canvas_map.front();E;E=E->next()) { - - Matrix32 xf = p_viewport->global_transform * E->get().transform; - - for(Set<Rasterizer::CanvasLightOccluderInstance*>::Element *F=E->get().canvas->occluders.front();F;F=F->next()) { - - if (!F->get()->enabled) - continue; - F->get()->xform_cache = xf * F->get()->xform; - if (shadow_rect.intersects_transformed(F->get()->xform_cache,F->get()->aabb_cache)) { - - F->get()->next=occluders; - occluders=F->get(); - - } - } - } - //update the light shadowmaps with them - Rasterizer::CanvasLight *light=lights_with_shadow; - while(light) { - - rasterizer->canvas_light_shadow_buffer_update(light->shadow_buffer,light->xform_cache.affine_inverse(),light->item_mask,light->radius_cache/1000.0,light->radius_cache*1.1,occluders,&light->shadow_matrix_cache); - light=light->shadows_next_ptr; - } - - rasterizer->set_viewport(viewport_rect); //must reset viewport afterwards - } - - - - - if (scenario_draw_canvas_bg && canvas_map.front() && canvas_map.front()->key().layer>scenario_canvas_max_layer) { - - _draw_viewport_camera(p_viewport,!can_draw_3d); - scenario_draw_canvas_bg=false; - - } - - for (Map<Viewport::CanvasKey,Viewport::CanvasData*>::Element *E=canvas_map.front();E;E=E->next()) { - - - //print_line("canvas "+itos(i)+" size: "+itos(I->get()->canvas->child_items.size())); - //print_line("GT "+p_viewport->global_transform+". CT: "+E->get()->transform); - Matrix32 xform = p_viewport->global_transform * E->get()->transform; - - Rasterizer::CanvasLight *canvas_lights=NULL; - - Rasterizer::CanvasLight *ptr=lights; - while(ptr) { - if (E->get()->layer>=ptr->layer_min && E->get()->layer<=ptr->layer_max) { - ptr->next_ptr=canvas_lights; - canvas_lights=ptr; - } - ptr=ptr->filter_next_ptr; - } - - _render_canvas( E->get()->canvas,xform,canvas_lights,lights_with_mask ); - i++; - - if (scenario_draw_canvas_bg && E->key().layer>=scenario_canvas_max_layer) { - _draw_viewport_camera(p_viewport,!can_draw_3d); - scenario_draw_canvas_bg=false; - } - - - } - - if (scenario_draw_canvas_bg) { - _draw_viewport_camera(p_viewport,!can_draw_3d); - scenario_draw_canvas_bg=false; - } - - - //rasterizer->canvas_debug_viewport_shadows(lights_with_shadow); - } - - //capture - - if (p_viewport->queue_capture) { - - rasterizer->capture_viewport(&p_viewport->capture); - p_viewport->queue_capture = false; - } - - //restore - if ( viewport_rect.x != old_rect.x || - viewport_rect.y != old_rect.y || - viewport_rect.width != old_rect.width || - viewport_rect.height != old_rect.height ) { - - viewport_rect=old_rect; - - rasterizer->set_viewport(viewport_rect); - } - - -} - -void VisualServerRaster::_draw_viewports() { - - //draw viewports for render targets - - List<Viewport*> to_blit; - List<Viewport*> to_disable; - for(SelfList<Viewport> *E=viewport_update_list.first();E;E=E->next()) { - - Viewport *vp = E->self(); - ERR_CONTINUE(!vp); - if ( - vp->render_target_update_mode==RENDER_TARGET_UPDATE_WHEN_VISIBLE && - !vp->rendered_in_prev_frame && - !vp->queue_capture - ) { - - continue; - } - - if (vp->rt_to_screen_rect!=Rect2()) - to_blit.push_back(vp); - - rasterizer->set_render_target(vp->render_target,vp->transparent_bg,vp->render_target_vflip); - _draw_viewport(vp,0,0,vp->rect.width,vp->rect.height); - - if ( (vp->queue_capture && vp->render_target_update_mode==RENDER_TARGET_UPDATE_DISABLED) || vp->render_target_update_mode==RENDER_TARGET_UPDATE_ONCE) { - //was only enabled for capture - to_disable.push_back(vp); - vp->render_target_update_mode=RENDER_TARGET_UPDATE_DISABLED; - } - - } - - rasterizer->set_render_target(RID()); - - while(to_disable.size()) { - //disable again because it was only for capture - viewport_update_list.remove(&to_disable.front()->get()->update_list); - to_disable.pop_front(); - } - - - //draw RTs directly to screen when requested - - for (List<Viewport*>::Element *E=to_blit.front();E;E=E->next()) { - - int window_w = OS::get_singleton()->get_video_mode().width; - int window_h = OS::get_singleton()->get_video_mode().height; - - ViewportRect desired_rect; - desired_rect.x = desired_rect.y = 0; - desired_rect.width = window_w; - desired_rect.height = window_h; - - if ( viewport_rect.x != desired_rect.x || - viewport_rect.y != desired_rect.y || - viewport_rect.width != desired_rect.width || - viewport_rect.height != desired_rect.height ) { - - viewport_rect=desired_rect; - - rasterizer->set_viewport(viewport_rect); - } - - rasterizer->canvas_begin(); - rasterizer->canvas_disable_blending(); - rasterizer->canvas_begin_rect(Matrix32()); - rasterizer->canvas_draw_rect(E->get()->rt_to_screen_rect,0,Rect2(Point2(),E->get()->rt_to_screen_rect.size),E->get()->render_target_texture,Color(1,1,1)); - - } - - - - //draw viewports attached to screen - - for(Map<RID,int>::Element *E=screen_viewports.front();E;E=E->next()) { - - Viewport *vp = viewport_owner.get(E->key()); - ERR_CONTINUE(!vp); - - int window_w = OS::get_singleton()->get_video_mode(E->get()).width; - int window_h = OS::get_singleton()->get_video_mode(E->get()).height; - - Rect2 r(0,0,vp->rect.width,vp->rect.height); - if (r.size.width==0) - r.size.width=window_w; - if (r.size.height==0) - r.size.height=window_h; - - - _draw_viewport(vp,r.pos.x,r.pos.y,r.size.width,r.size.height); - } - - - //check when a viewport associated to a render target was drawn - - for(SelfList<Viewport> *E=viewport_update_list.first();E;E=E->next()) { - - Viewport *vp = E->self(); - ERR_CONTINUE(!vp); - if (vp->render_target_update_mode!=RENDER_TARGET_UPDATE_WHEN_VISIBLE) - continue; - vp->rendered_in_prev_frame=rasterizer->render_target_renedered_in_frame(vp->render_target); - } - -} - - - -void VisualServerRaster::_draw_cursors_and_margins() { - - int window_w = OS::get_singleton()->get_video_mode().width; - int window_h = OS::get_singleton()->get_video_mode().height; - - ViewportRect desired_rect; - desired_rect.x = desired_rect.y = 0; - desired_rect.width = window_w; - desired_rect.height = window_h; - - if ( viewport_rect.x != desired_rect.x || - viewport_rect.y != desired_rect.y || - viewport_rect.width != desired_rect.width || - viewport_rect.height != desired_rect.height ) { - - viewport_rect=desired_rect; - - rasterizer->set_viewport(viewport_rect); - } - - rasterizer->canvas_begin(); - rasterizer->canvas_begin_rect(Matrix32()); - - for (int i=0; i<MAX_CURSORS; i++) { - - if (!cursors[i].visible) { - - continue; - }; - - RID tex = cursors[i].texture?cursors[i].texture:default_cursor_texture; - ERR_CONTINUE( !tex ); - if (cursors[i].region.has_no_area()) { - Point2 size(texture_get_width(tex), texture_get_height(tex)); - rasterizer->canvas_draw_rect(Rect2(cursors[i].pos-cursors[i].center, size), 0, Rect2(), tex, Color(1, 1, 1, 1)); - } else { - Point2 size = cursors[i].region.size; - rasterizer->canvas_draw_rect(Rect2(cursors[i].pos-cursors[i].center, size), Rasterizer::CANVAS_RECT_REGION, cursors[i].region, tex, Color(1, 1, 1, 1)); - } - }; - - - - if (black_image[MARGIN_LEFT].is_valid()) { - Size2 sz(rasterizer->texture_get_width(black_image[MARGIN_LEFT]),rasterizer->texture_get_height(black_image[MARGIN_LEFT])); - rasterizer->canvas_draw_rect(Rect2(0,0,black_margin[MARGIN_LEFT],window_h),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_LEFT],Color(1,1,1)); - } else if (black_margin[MARGIN_LEFT]) - rasterizer->canvas_draw_rect(Rect2(0,0,black_margin[MARGIN_LEFT],window_h),0,Rect2(0,0,1,1),RID(),Color(0,0,0)); - - if (black_image[MARGIN_RIGHT].is_valid()) { - Size2 sz(rasterizer->texture_get_width(black_image[MARGIN_RIGHT]),rasterizer->texture_get_height(black_image[MARGIN_RIGHT])); - rasterizer->canvas_draw_rect(Rect2(window_w-black_margin[MARGIN_RIGHT],0,black_margin[MARGIN_RIGHT],window_h),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_RIGHT],Color(1,1,1)); - } else if (black_margin[MARGIN_RIGHT]) - rasterizer->canvas_draw_rect(Rect2(window_w-black_margin[MARGIN_RIGHT],0,black_margin[MARGIN_RIGHT],window_h),0,Rect2(0,0,1,1),RID(),Color(0,0,0)); - - if (black_image[MARGIN_TOP].is_valid()) { - Size2 sz(rasterizer->texture_get_width(black_image[MARGIN_TOP]),rasterizer->texture_get_height(black_image[MARGIN_TOP])); - rasterizer->canvas_draw_rect(Rect2(0,0,window_w,black_margin[MARGIN_TOP]),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_TOP],Color(1,1,1)); - - } else if (black_margin[MARGIN_TOP]) { - rasterizer->canvas_draw_rect(Rect2(0,0,window_w,black_margin[MARGIN_TOP]),0,Rect2(0,0,1,1),RID(),Color(0,0,0)); - } - - if (black_image[MARGIN_BOTTOM].is_valid()) { - - Size2 sz(rasterizer->texture_get_width(black_image[MARGIN_BOTTOM]),rasterizer->texture_get_height(black_image[MARGIN_BOTTOM])); - rasterizer->canvas_draw_rect(Rect2(0,window_h-black_margin[MARGIN_BOTTOM],window_w,black_margin[MARGIN_BOTTOM]),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_BOTTOM],Color(1,1,1)); - } else if (black_margin[MARGIN_BOTTOM]) { - rasterizer->canvas_draw_rect(Rect2(0,window_h-black_margin[MARGIN_BOTTOM],window_w,black_margin[MARGIN_BOTTOM]),0,Rect2(0,0,1,1),RID(),Color(0,0,0)); - } - - rasterizer->canvas_end_rect(); -}; - -void VisualServerRaster::sync() { - //do none -} - -void VisualServerRaster::draw() { - /* - if (changes) - print_line("changes: "+itos(changes)); - */ - changes=0; - shadows_enabled=GLOBAL_DEF("render/shadows_enabled",true); - room_cull_enabled = GLOBAL_DEF("render/room_cull_enabled",true); - light_discard_enabled = GLOBAL_DEF("render/light_discard_enabled",true); - rasterizer->begin_frame(); - _draw_viewports(); - _draw_cursors_and_margins(); - rasterizer->end_frame(); - draw_extra_frame=rasterizer->needs_to_draw_next_frame(); -} - -bool VisualServerRaster::has_changed() const { - - return changes>0 || draw_extra_frame; -} - -int VisualServerRaster::get_render_info(RenderInfo p_info) { - - return rasterizer->get_render_info(p_info); -} - -bool VisualServerRaster::has_feature(Features p_feature) const { - - return rasterizer->has_feature(p_feature); // lies for now -} - -void VisualServerRaster::set_default_clear_color(const Color& p_color) { - - clear_color=p_color; -} - -void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_color,bool p_scale) { - - if (p_image.empty()) - return; - - rasterizer->restore_framebuffer(); - - rasterizer->begin_frame(); - - int window_w = OS::get_singleton()->get_video_mode(0).width; - int window_h = OS::get_singleton()->get_video_mode(0).height; - ViewportRect vr; - vr.x=0; - vr.y=0; - vr.width=OS::get_singleton()->get_video_mode(0).width; - vr.height=OS::get_singleton()->get_video_mode(0).height; - rasterizer->set_viewport(vr); - rasterizer->clear_viewport(p_color); - rasterizer->canvas_begin(); - RID texture = texture_create(); - texture_allocate(texture,p_image.get_width(),p_image.get_height(),p_image.get_format(),TEXTURE_FLAG_FILTER); - texture_set_data(texture,p_image); - rasterizer->canvas_begin_rect(Matrix32()); - Rect2 imgrect(0,0,p_image.get_width(),p_image.get_height()); - Rect2 screenrect; - if (p_scale) { - - if (window_w > window_h) { - //scale horizontally - screenrect.size.y = window_h; - screenrect.size.x = imgrect.size.x * window_h / imgrect.size.y; - screenrect.pos.x = (window_w - screenrect.size.x)/2; - - } else { - //scale vertically - screenrect.size.x = window_w; - screenrect.size.y = imgrect.size.y * window_w / imgrect.size.x; - screenrect.pos.y = (window_h - screenrect.size.y)/2; - } - } else { - - screenrect=imgrect; - screenrect.pos+=((Size2(vr.width,vr.height)-screenrect.size)/2.0).floor(); - - } - rasterizer->canvas_draw_rect(screenrect,0,imgrect,texture,Color(1,1,1,1)); - rasterizer->canvas_end_rect(); - - rasterizer->end_frame(); - rasterizer->flush_frame(); - - free(texture); // free since it's only one frame that stays there - -} - -void VisualServerRaster::init() { - - rasterizer->init(); - - shadows_enabled=GLOBAL_DEF("render/shadows_enabled",true); - //default_scenario = scenario_create(); - //default_viewport = viewport_create(); - for(int i=0;i<4;i++) - black_margin[i]=0; - - Image img; - img.create(default_mouse_cursor_xpm); - //img.convert(Image::FORMAT_RGB8); - default_cursor_texture = texture_create_from_image(img, 0); - - aabb_random_points.resize( GLOBAL_DEF("render/aabb_random_points",16) ); - for(int i=0;i<aabb_random_points.size();i++) - aabb_random_points[i]=Vector3(Math::random(0,1),Math::random(0,1),Math::random(0,1)); - transformed_aabb_random_points.resize(aabb_random_points.size()); - changes=0; -} - -void VisualServerRaster::_clean_up_owner(RID_OwnerBase *p_owner,String p_type) { - - List<RID> rids; - p_owner->get_owned_list(&rids); - - int lost=0; - for(List<RID>::Element *I=rids.front();I;I=I->next()) { - if (OS::get_singleton()->is_stdout_verbose()) { - lost++; - } - free(I->get()); - } - - if (lost) - print_line("VisualServerRaster: WARNING: Lost "+itos(lost)+" RIDs of type "+p_type); - -} - -void VisualServerRaster::finish() { - - - free(default_cursor_texture); - if (test_cube.is_valid()) - free(test_cube); - - _free_internal_rids(); - - _clean_up_owner( &room_owner,"Room" ); - _clean_up_owner( &portal_owner,"Portal" ); - - _clean_up_owner( &camera_owner,"Camera" ); - _clean_up_owner( &viewport_owner,"Viewport" ); - - _clean_up_owner( &scenario_owner,"Scenario" ); - _clean_up_owner( &instance_owner,"Instance" ); - - _clean_up_owner( &canvas_owner,"Canvas" ); - _clean_up_owner( &canvas_item_owner,"CanvasItem" ); - - rasterizer->finish(); - octree_allocator.clear(); - - if (instance_dependency_map.size()) { - print_line("Base resources missing amount: "+itos(instance_dependency_map.size())); - } - ERR_FAIL_COND( instance_dependency_map.size() ); -} - - -RID VisualServerRaster::get_test_cube() { - - if (test_cube.is_valid()) - return test_cube; - - test_cube=_make_test_cube(); - return test_cube; - -} - - - -VisualServerRaster::VisualServerRaster(Rasterizer *p_rasterizer) { - - rasterizer=p_rasterizer; - rasterizer->draw_viewport_func=_render_canvas_item_viewport; - instance_update_list=NULL; - render_pass=0; - clear_color=Color(0.3,0.3,0.3,1.0); - OctreeAllocator::allocator=&octree_allocator; - draw_extra_frame=false; - -} - - -VisualServerRaster::~VisualServerRaster() -{ -} -#endif diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 70492afe83..774b692a22 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -73,6 +73,7 @@ class VisualServerRaster : public VisualServer { List<FrameDrawnCallbacks> frame_drawn_callbacks; +// FIXME: Kept as reference for future implementation #if 0 struct Room { diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index a0c7420270..95ac876ec0 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -761,13 +761,6 @@ void VisualServerScene::_update_instance(Instance *p_instance) { return; } -#if 0 - if (p_instance->base_type == VS::INSTANCE_PARTICLES) { - - rasterizer->particles_instance_set_transform( p_instance->particles_info->instance, p_instance->data.transform ); - } - -#endif if ((1 << p_instance->base_type) & VS::INSTANCE_GEOMETRY_MASK) { InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data); @@ -1606,20 +1599,7 @@ void VisualServerScene::_render_scene(const Transform p_cam_transform, const Cam else environment = scenario->fallback_environment; -#if 0 - /* STEP 6 - SAMPLE BAKED LIGHT */ - - bool islinear =false; - if (environment.is_valid()) { - islinear = rasterizer->environment_is_fx_enabled(environment,VS::ENV_FX_SRGB); - } - - for(int i=0;i<light_samplers_culled;i++) { - - _process_sampled_light(camera->transform,light_sampler_cull_result[i],islinear); - } -#endif - /* STEP 7 - PROCESS GEOMETRY AND DRAW SCENE*/ + /* STEP 6 - PROCESS GEOMETRY AND DRAW SCENE*/ VSG::scene_render->render_scene(p_cam_transform, p_cam_projection, p_cam_orthogonal, (RasterizerScene::InstanceBase **)instance_cull_result, cull_count, light_instance_cull_result, light_cull_count + directional_light_count, reflection_probe_instance_cull_result, reflection_probe_cull_count, environment, p_shadow_atlas, scenario->reflection_atlas, p_reflection_probe, p_reflection_probe_pass); } diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h index 177521e267..ac771030cf 100644 --- a/servers/visual/visual_server_scene.h +++ b/servers/visual/visual_server_scene.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -54,6 +54,8 @@ public: uint64_t render_pass; static VisualServerScene *singleton; + +// FIXME: Kept as reference for future implementation #if 0 struct Portal { diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp index ad9dec090a..0dca09a5bf 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/visual/visual_server_viewport.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "visual_server_viewport.h" + #include "project_settings.h" #include "visual_server_canvas.h" #include "visual_server_global.h" @@ -51,36 +52,6 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E } bool can_draw_3d = !p_viewport->disable_3d && !p_viewport->disable_3d_by_usage && VSG::scene->camera_owner.owns(p_viewport->camera); -#if 0 - - - - if (scenario_draw_canvas_bg) { - - rasterizer->begin_canvas_bg(); - } - - if (!scenario_draw_canvas_bg && can_draw_3d) { - - _draw_viewport_camera(p_viewport,false); - - } else if (true /*|| !p_viewport->canvas_list.empty()*/){ - - //clear the viewport black because of no camera? i seriously should.. - if (p_viewport->render_target_clear_on_new_frame || p_viewport->render_target_clear) { - if (p_viewport->transparent_bg) { - rasterizer->clear_viewport(Color(0,0,0,0)); - } - else { - Color cc=clear_color; - if (scenario_draw_canvas_bg) - cc.a=0; - rasterizer->clear_viewport(cc); - } - p_viewport->render_target_clear=false; - } - } -#endif if (p_viewport->clear_mode != VS::VIEWPORT_CLEAR_NEVER) { VSG::rasterizer->clear_render_target(clear_color); diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h index 93227d1c31..8a294a9129 100644 --- a/servers/visual/visual_server_viewport.h +++ b/servers/visual/visual_server_viewport.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp index 827f47a16e..d9a0077e60 100644 --- a/servers/visual/visual_server_wrap_mt.cpp +++ b/servers/visual/visual_server_wrap_mt.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 476412a4f1..7143178b04 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index cb1f96c23f..777feffb06 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "visual_server.h" + #include "method_bind_ext.gen.inc" #include "project_settings.h" @@ -39,25 +40,6 @@ VisualServer *VisualServer::get_singleton() { return singleton; } -PoolVector<String> VisualServer::_shader_get_param_list(RID p_shader) const { - - //remove at some point - - PoolVector<String> pl; - -#if 0 - List<StringName> params; - shader_get_param_list(p_shader,¶ms); - - - for(List<StringName>::Element *E=params.front();E;E=E->next()) { - - pl.push_back(E->get()); - } -#endif - return pl; -} - VisualServer *VisualServer::create() { ERR_FAIL_COND_V(singleton, NULL); @@ -1466,7 +1448,6 @@ void VisualServer::_camera_set_orthogonal(RID p_camera, float p_size, float p_z_ void VisualServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data) { -#if 1 PoolVector<Vector3> vertices; PoolVector<Vector3> normals; @@ -1491,24 +1472,6 @@ void VisualServer::mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::M d[ARRAY_VERTEX] = vertices; d[ARRAY_NORMAL] = normals; mesh_add_surface_from_arrays(p_mesh, PRIMITIVE_TRIANGLES, d); - -#else - - PoolVector<Vector3> vertices; - - for (int i = 0; i < p_mesh_data.edges.size(); i++) { - - const Geometry::MeshData::Edge &f = p_mesh_data.edges[i]; - vertices.push_back(p_mesh_data.vertices[f.a]); - vertices.push_back(p_mesh_data.vertices[f.b]); - } - - Array d; - d.resize(VS::ARRAY_MAX); - d[ARRAY_VERTEX] = vertices; - mesh_add_surface(p_mesh, PRIMITIVE_LINES, d); - -#endif } void VisualServer::mesh_add_surface_from_planes(RID p_mesh, const PoolVector<Plane> &p_planes) { diff --git a/servers/visual_server.h b/servers/visual_server.h index cf32dcd1d5..9f2d685531 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -49,7 +49,6 @@ class VisualServer : public Object { int mm_policy; - PoolVector<String> _shader_get_param_list(RID p_shader) const; void _camera_set_orthogonal(RID p_camera, float p_size, float p_z_near, float p_z_far); void _canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate = Color(1, 1, 1)); Array _get_array_from_surface(uint32_t p_format, PoolVector<uint8_t> p_vertex_data, int p_vertex_len, PoolVector<uint8_t> p_index_data, int p_index_len) const; diff --git a/thirdparty/README.md b/thirdparty/README.md index 804395f8d3..56b4a07d9b 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -107,7 +107,7 @@ Files extracted from upstream source: ## libpng - Upstream: http://libpng.org/pub/png/libpng.html -- Version: 1.6.31rc01 +- Version: 1.6.32 - License: libpng/zlib Files extracted from upstream source: @@ -129,6 +129,19 @@ Files extracted from upstream source: TODO. +## libtheora + +- Upstream: https://www.theora.org +- Version: 1.1.1 +- License: BSD-3-Clause + +Files extracted from upstream source: + +- all .c, .h in lib/ +- all .h files in include/theora/ as theora/ +- COPYING and LICENSE + + ## libvorbis - Upstream: https://www.xiph.org/vorbis @@ -247,18 +260,30 @@ Collection of single-file libraries used in Godot components. * License: zlib - `stb_truetype.h` * Upstream: https://github.com/nothings/stb - * Version: 1.11 + * Version: 1.17 * License: Public Domain (Unlicense) or MIT - `stb_vorbis.c` * Upstream: https://github.com/nothings/stb - * Version: 1.09 + * Version: 1.11 * License: Public Domain (Unlicense) or MIT +## nanosvg + +- Upstream: https://github.com/memononen/nanosvg +- Version: 9a74da4 (git) +- License: zlib + +Files extracted from the upstream source: + +- All .h files in `src/` +- LICENSE.txt + + ## openssl - Upstream: https://www.openssl.org -- Version: 1.0.2h +- Version: 1.0.2l - License: OpenSSL license / BSD-like Files extracted from the upstream source: @@ -331,19 +356,6 @@ Files extracted from upstream source: - all .cpp, .h and .inl files -## theora - -- Upstream: https://www.theora.org -- Version: 1.1.1 -- License: BSD-3-Clause - -Files extracted from upstream source: - -- all .c, .h in lib/ -- all .h files in include/theora/ as theora/ -- COPYING and LICENSE - - ## tinyexr - Upstream: https://github.com/syoyo/tinyexr @@ -369,13 +381,14 @@ Files extracted from upstream source: - all .c and .h files + ## zstd - Upstream: https://github.com/facebook/zstd -- Version: 1.3.0 +- Version: 1.3.1 - License: BSD-3-Clause Files extracted from upstream source: -- all .c and .h under lib/ -- README.md, LICENSE, PATENTS +- lib/{common/,compress/,decompress/,zstd.h} +- README.md, LICENSE diff --git a/thirdparty/enet/enet/godot.h b/thirdparty/enet/enet/godot.h index 75645153dd..937c4fa60e 100644 --- a/thirdparty/enet/enet/godot.h +++ b/thirdparty/enet/enet/godot.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp index f050b7b916..2fc264345b 100644 --- a/thirdparty/enet/godot.cpp +++ b/thirdparty/enet/godot.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/thirdparty/libpng/arm/filter_neon.S b/thirdparty/libpng/arm/filter_neon.S index 09267c6030..000764cd21 100644 --- a/thirdparty/libpng/arm/filter_neon.S +++ b/thirdparty/libpng/arm/filter_neon.S @@ -3,7 +3,7 @@ * * Copyright (c) 2014,2017 Glenn Randers-Pehrson * Written by Mans Rullgard, 2011. - * Last changed in libpng 1.6.31 [(PENDING RELEASE)] + * Last changed in libpng 1.6.31 [July 27, 2017] * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer diff --git a/thirdparty/libpng/png.c b/thirdparty/libpng/png.c index 87fda0b306..2352df13cb 100644 --- a/thirdparty/libpng/png.c +++ b/thirdparty/libpng/png.c @@ -1,7 +1,7 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.6.31 [(PENDING RELEASE)] + * Last changed in libpng 1.6.32 [August 24, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_31rc01 Your_png_h_is_not_version_1_6_31rc01; +typedef png_libpng_version_1_6_32 Your_png_h_is_not_version_1_6_32; #ifdef __GNUC__ /* The version tests may need to be added to, but the problem warning has @@ -619,8 +619,18 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, /* Free any eXIf entry */ if (((mask & PNG_FREE_EXIF) & info_ptr->free_me) != 0) { - png_free(png_ptr, info_ptr->exif); - info_ptr->exif = NULL; +# ifdef PNG_READ_eXIf_SUPPORTED + if (info_ptr->eXIf_buf) + { + png_free(png_ptr, info_ptr->eXIf_buf); + info_ptr->eXIf_buf = NULL; + } +# endif + if (info_ptr->exif) + { + png_free(png_ptr, info_ptr->exif); + info_ptr->exif = NULL; + } info_ptr->valid &= ~PNG_INFO_eXIf; } #endif @@ -806,14 +816,14 @@ png_get_copyright(png_const_structrp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.6.31rc01 - July 19, 2017" PNG_STRING_NEWLINE \ + "libpng version 1.6.32 - August 24, 2017" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.6.31rc01 - July 19, 2017\ + return "libpng version 1.6.32 - August 24, 2017\ Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; diff --git a/thirdparty/libpng/png.h b/thirdparty/libpng/png.h index 80ecc82c3a..51ac8abe74 100644 --- a/thirdparty/libpng/png.h +++ b/thirdparty/libpng/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.31rc01, July 19, 2017 + * libpng version 1.6.32, August 24, 2017 * * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) @@ -12,7 +12,7 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.6.31rc01, July 19, 2017: + * libpng versions 0.97, January 1998, through 1.6.32, August 24, 2017: * Glenn Randers-Pehrson. * See also "Contributing Authors", below. */ @@ -25,7 +25,7 @@ * * This code is released under the libpng license. * - * libpng versions 1.0.7, July 1, 2000 through 1.6.31rc01, July 19, 2017 are + * libpng versions 1.0.7, July 1, 2000 through 1.6.32, August 24, 2017 are * Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are * derived from libpng-1.0.6, and are distributed according to the same * disclaimer and license as libpng-1.0.6 with the following individuals @@ -213,7 +213,7 @@ * ... * 1.5.28 15 10527 15.so.15.28[.0] * ... - * 1.6.31 16 10631 16.so.16.31[.0] + * 1.6.32 16 10632 16.so.16.32[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -241,13 +241,13 @@ * Y2K compliance in libpng: * ========================= * - * July 19, 2017 + * August 24, 2017 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.6.31rc01 are Y2K compliant. It is my belief that + * upward through 1.6.32 are Y2K compliant. It is my belief that * earlier versions were also Y2K compliant. * * Libpng only has two year fields. One is a 2-byte unsigned integer @@ -309,8 +309,8 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.31rc01" -#define PNG_HEADER_VERSION_STRING " libpng version 1.6.31rc01 - July 19, 2017\n" +#define PNG_LIBPNG_VER_STRING "1.6.32" +#define PNG_HEADER_VERSION_STRING " libpng version 1.6.32 - August 24, 2017\n" #define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_DLLNUM 16 @@ -318,13 +318,13 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 31 +#define PNG_LIBPNG_VER_RELEASE 32 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ -#define PNG_LIBPNG_VER_BUILD 01 +#define PNG_LIBPNG_VER_BUILD 0 /* Release Status */ #define PNG_LIBPNG_BUILD_ALPHA 1 @@ -341,7 +341,7 @@ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_RC +#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE /* Careful here. At one time, Guy wanted to use 082, but that would be octal. * We must not include leading zeros. @@ -349,7 +349,7 @@ * version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10631 /* 1.6.31 */ +#define PNG_LIBPNG_VER 10632 /* 1.6.32 */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -459,7 +459,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_31rc01; +typedef char* png_libpng_version_1_6_32; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * @@ -2014,6 +2014,11 @@ PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *exif)); PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr, png_inforp info_ptr, const png_bytep exif)); + +PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr, + png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif)); +PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr, + png_inforp info_ptr, const png_uint_32 num_exif, const png_bytep exif)); #endif #ifdef PNG_gAMA_SUPPORTED @@ -3259,7 +3264,7 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, * one to use is one more than this.) */ #ifdef PNG_EXPORT_LAST_ORDINAL - PNG_EXPORT_LAST_ORDINAL(247); + PNG_EXPORT_LAST_ORDINAL(249); #endif #ifdef __cplusplus diff --git a/thirdparty/libpng/pngconf.h b/thirdparty/libpng/pngconf.h index 9308d6a60a..c0f15547be 100644 --- a/thirdparty/libpng/pngconf.h +++ b/thirdparty/libpng/pngconf.h @@ -1,7 +1,7 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.6.31rc01, July 19, 2017 + * libpng version 1.6.32, August 24, 2017 * * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) diff --git a/thirdparty/libpng/pngerror.c b/thirdparty/libpng/pngerror.c index 37f26c6558..ad48bfb986 100644 --- a/thirdparty/libpng/pngerror.c +++ b/thirdparty/libpng/pngerror.c @@ -1,7 +1,7 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.6.31 [(PENDING RELEASE)] + * Last changed in libpng 1.6.31 [July 27, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) diff --git a/thirdparty/libpng/pngget.c b/thirdparty/libpng/pngget.c index ace9e6351f..26e9fb1c35 100644 --- a/thirdparty/libpng/pngget.c +++ b/thirdparty/libpng/pngget.c @@ -1,8 +1,8 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.6.26 [October 20, 2016] - * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -778,11 +778,22 @@ png_uint_32 PNGAPI png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *exif) { + png_warning(png_ptr, "png_get_eXIf does not work; use png_get_eXIf_1"); + PNG_UNUSED(info_ptr) + PNG_UNUSED(exif) + return 0; +} + +png_uint_32 PNGAPI +png_get_eXIf_1(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32 *num_exif, png_bytep *exif) +{ png_debug1(1, "in %s retrieval function", "eXIf"); if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_eXIf) != 0 && exif != NULL) { + *num_exif = info_ptr->num_exif; *exif = info_ptr->exif; return (PNG_INFO_eXIf); } diff --git a/thirdparty/libpng/pnginfo.h b/thirdparty/libpng/pnginfo.h index 6e6d46a62b..d5f6149dbd 100644 --- a/thirdparty/libpng/pnginfo.h +++ b/thirdparty/libpng/pnginfo.h @@ -186,8 +186,11 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) #endif #ifdef PNG_eXIf_SUPPORTED - int num_exif; + int num_exif; /* Added at libpng-1.6.31 */ png_bytep exif; +# ifdef PNG_READ_eXIf_SUPPORTED + png_bytep eXIf_buf; /* Added at libpng-1.6.32 */ +# endif #endif #ifdef PNG_hIST_SUPPORTED diff --git a/thirdparty/libpng/pnglibconf.h b/thirdparty/libpng/pnglibconf.h index 8738ebdfc2..9e45f73129 100644 --- a/thirdparty/libpng/pnglibconf.h +++ b/thirdparty/libpng/pnglibconf.h @@ -1,8 +1,8 @@ -/* libpng 1.6.31rc01 STANDARD API DEFINITION */ +/* libpng 1.6.32 STANDARD API DEFINITION */ /* pnglibconf.h - library build configuration */ -/* Libpng version 1.6.31rc01 - July 19, 2017 */ +/* Libpng version 1.6.32 - August 24, 2017 */ /* Copyright (c) 1998-2017 Glenn Randers-Pehrson */ diff --git a/thirdparty/libpng/pngpread.c b/thirdparty/libpng/pngpread.c index 650ba1e232..fbe361dc34 100644 --- a/thirdparty/libpng/pngpread.c +++ b/thirdparty/libpng/pngpread.c @@ -1,8 +1,8 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.6.24 [August 4, 2016] - * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -189,6 +189,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) png_crc_read(png_ptr, chunk_tag, 4); png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); png_check_chunk_name(png_ptr, png_ptr->chunk_name); + png_check_chunk_length(png_ptr, png_ptr->push_length); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; } diff --git a/thirdparty/libpng/pngpriv.h b/thirdparty/libpng/pngpriv.h index 7c273bd5e3..1f2e90f2b3 100644 --- a/thirdparty/libpng/pngpriv.h +++ b/thirdparty/libpng/pngpriv.h @@ -1,7 +1,7 @@ /* pngpriv.h - private declarations for use inside libpng * - * Last changed in libpng 1.6.31 [(PENDING RELEASE)] + * Last changed in libpng 1.6.32 [August 24, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -1143,6 +1143,11 @@ PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr, int intent),PNG_EMPTY); #endif +#ifdef PNG_WRITE_eXIf_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_eXIf,(png_structrp png_ptr, + png_bytep exif, int num_exif),PNG_EMPTY); +#endif + #ifdef PNG_WRITE_iCCP_SUPPORTED PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr, png_const_charp name, png_const_bytep profile), PNG_EMPTY); @@ -1522,8 +1527,11 @@ PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); #endif -PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr, - png_uint_32 chunk_name),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr, + const png_uint_32 chunk_name),PNG_EMPTY); + +PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr, + const png_uint_32 chunk_length),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY); diff --git a/thirdparty/libpng/pngread.c b/thirdparty/libpng/pngread.c index b44d4dfbb5..e34ddd99a0 100644 --- a/thirdparty/libpng/pngread.c +++ b/thirdparty/libpng/pngread.c @@ -1,7 +1,7 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.6.31 [(PENDING RELEASE)] + * Last changed in libpng 1.6.32 [August 24, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -175,6 +175,11 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) png_handle_cHRM(png_ptr, info_ptr, length); #endif +#ifdef PNG_READ_eXIf_SUPPORTED + else if (chunk_name == png_eXIf) + png_handle_eXIf(png_ptr, info_ptr, length); +#endif + #ifdef PNG_READ_gAMA_SUPPORTED else if (chunk_name == png_gAMA) png_handle_gAMA(png_ptr, info_ptr, length); @@ -534,6 +539,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) png_error(png_ptr, "Invalid attempt to read row data"); /* Fill the row with IDAT data: */ + png_ptr->row_buf[0]=255; /* to force error if no data was found */ png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1); if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE) @@ -842,6 +848,11 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) png_handle_cHRM(png_ptr, info_ptr, length); #endif +#ifdef PNG_READ_eXIf_SUPPORTED + else if (chunk_name == png_eXIf) + png_handle_eXIf(png_ptr, info_ptr, length); +#endif + #ifdef PNG_READ_gAMA_SUPPORTED else if (chunk_name == png_gAMA) png_handle_gAMA(png_ptr, info_ptr, length); diff --git a/thirdparty/libpng/pngrtran.c b/thirdparty/libpng/pngrtran.c index 9285983848..9a30ddf22b 100644 --- a/thirdparty/libpng/pngrtran.c +++ b/thirdparty/libpng/pngrtran.c @@ -1,7 +1,7 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.6.31 [(PENDING RELEASE)] + * Last changed in libpng 1.6.31 [July 27, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) diff --git a/thirdparty/libpng/pngrutil.c b/thirdparty/libpng/pngrutil.c index 9cde64845c..a4fa71457b 100644 --- a/thirdparty/libpng/pngrutil.c +++ b/thirdparty/libpng/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.6.31 [(PENDING RELEASE)] + * Last changed in libpng 1.6.32 [August 24, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -181,6 +181,9 @@ png_read_chunk_header(png_structrp png_ptr) /* Check to see if chunk name is valid. */ png_check_chunk_name(png_ptr, png_ptr->chunk_name); + /* Check for too-large chunk length */ + png_check_chunk_length(png_ptr, length); + #ifdef PNG_IO_STATE_SUPPORTED png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA; #endif @@ -1377,11 +1380,13 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * chunk is just ignored, so does not invalidate the color space. An * alternative is to set the 'invalid' flags at the start of this routine * and only clear them in they were not set before and all the tests pass. - * The minimum 'deflate' stream is assumed to be just the 2 byte header and - * 4 byte checksum. The keyword must be at least one character and there is - * a terminator (0) byte and the compression method. */ - if (length < 9) + + /* The keyword must be at least one character and there is a + * terminator (0) byte and the compression method byte, and the + * 'zlib' datastream is at least 11 bytes. + */ + if (length < 14) { png_crc_finish(png_ptr, length); png_chunk_benign_error(png_ptr, "too short"); @@ -1413,6 +1418,16 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_crc_read(png_ptr, (png_bytep)keyword, read_length); length -= read_length; + /* The minimum 'zlib' stream is assumed to be just the 2 byte header, + * 5 bytes minimum 'deflate' stream, and the 4 byte checksum. + */ + if (length < 11) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "too short"); + return; + } + keyword_length = 0; while (keyword_length < 80 && keyword_length < read_length && keyword[keyword_length] != 0) @@ -1431,7 +1446,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK) { - Byte profile_header[132]; + Byte profile_header[132]={0}; Byte local_buffer[PNG_INFLATE_BUF_SIZE]; png_alloc_size_t size = (sizeof profile_header); @@ -2014,36 +2029,61 @@ void /* PRIVATE */ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { unsigned int i; - png_bytep eXIf_buf; png_debug(1, "in png_handle_eXIf"); if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) png_chunk_error(png_ptr, "missing IHDR"); - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_eXIf) != 0) + if (length < 2) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "too short"); + return; + } + + else if (info_ptr == NULL || (info_ptr->valid & PNG_INFO_eXIf) != 0) { png_crc_finish(png_ptr, length); png_chunk_benign_error(png_ptr, "duplicate"); return; } - eXIf_buf = png_voidcast(png_bytep, + info_ptr->free_me |= PNG_FREE_EXIF; + + info_ptr->eXIf_buf = png_voidcast(png_bytep, png_malloc_warn(png_ptr, length)); + if (info_ptr->eXIf_buf == NULL) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of memory"); + return; + } + for (i = 0; i < length; i++) { png_byte buf[1]; png_crc_read(png_ptr, buf, 1); - eXIf_buf[i] = buf[0]; + info_ptr->eXIf_buf[i] = buf[0]; + if (i == 1 && buf[0] != 'M' && buf[0] != 'I' + && info_ptr->eXIf_buf[0] != buf[0]) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "incorrect byte-order specifier"); + png_free(png_ptr, info_ptr->eXIf_buf); + info_ptr->eXIf_buf = NULL; + return; + } } if (png_crc_finish(png_ptr, 0) != 0) return; - info_ptr->num_exif = length; + png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf); - png_set_eXIf(png_ptr, info_ptr, eXIf_buf); + png_free(png_ptr, info_ptr->eXIf_buf); + info_ptr->eXIf_buf = NULL; } #endif @@ -2624,23 +2664,28 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) { png_text text; - /* It worked; png_ptr->read_buffer now looks like a tEXt chunk except - * for the extra compression type byte and the fact that it isn't - * necessarily '\0' terminated. - */ - buffer = png_ptr->read_buffer; - buffer[uncompressed_length+(keyword_length+2)] = 0; - - text.compression = PNG_TEXT_COMPRESSION_zTXt; - text.key = (png_charp)buffer; - text.text = (png_charp)(buffer + keyword_length+2); - text.text_length = uncompressed_length; - text.itxt_length = 0; - text.lang = NULL; - text.lang_key = NULL; - - if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0) - errmsg = "insufficient memory"; + if (png_ptr->read_buffer == NULL) + errmsg="Read failure in png_handle_zTXt"; + else + { + /* It worked; png_ptr->read_buffer now looks like a tEXt chunk + * except for the extra compression type byte and the fact that + * it isn't necessarily '\0' terminated. + */ + buffer = png_ptr->read_buffer; + buffer[uncompressed_length+(keyword_length+2)] = 0; + + text.compression = PNG_TEXT_COMPRESSION_zTXt; + text.key = (png_charp)buffer; + text.text = (png_charp)(buffer + keyword_length+2); + text.text_length = uncompressed_length; + text.itxt_length = 0; + text.lang = NULL; + text.lang_key = NULL; + + if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0) + errmsg = "insufficient memory"; + } } else @@ -3076,20 +3121,58 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, */ void /* PRIVATE */ -png_check_chunk_name(png_structrp png_ptr, png_uint_32 chunk_name) +png_check_chunk_name(png_const_structrp png_ptr, const png_uint_32 chunk_name) { int i; + png_uint_32 cn=chunk_name; png_debug(1, "in png_check_chunk_name"); for (i=1; i<=4; ++i) { - int c = chunk_name & 0xff; + int c = cn & 0xff; if (c < 65 || c > 122 || (c > 90 && c < 97)) png_chunk_error(png_ptr, "invalid chunk type"); - chunk_name >>= 8; + cn >>= 8; + } +} + +void /* PRIVATE */ +png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length) +{ + png_alloc_size_t limit = PNG_UINT_31_MAX; + + if (png_ptr->chunk_name != png_IDAT) + { +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + if (png_ptr->user_chunk_malloc_max > 0 && + png_ptr->user_chunk_malloc_max < limit) + limit = png_ptr->user_chunk_malloc_max; +# elif PNG_USER_CHUNK_MALLOC_MAX > 0 + if (PNG_USER_CHUNK_MALLOC_MAX < limit) + limit = PNG_USER_CHUNK_MALLOC_MAX; +# endif + } + else + { + size_t row_factor = + (png_ptr->width * png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1) + + 1 + (png_ptr->interlaced? 6: 0)); + if (png_ptr->height > PNG_UINT_32_MAX/row_factor) + limit=PNG_UINT_31_MAX; + else + limit = png_ptr->height * row_factor; + limit += 6 + 5*(limit/32566+1); /* zlib+deflate overhead */ + limit=limit < PNG_UINT_31_MAX? limit : PNG_UINT_31_MAX; + } + + if (length > limit) + { + png_debug2(0," length = %lu, limit = %lu", + (unsigned long)length,(unsigned long)limit); + png_chunk_error(png_ptr, "chunk data is too large"); } } diff --git a/thirdparty/libpng/pngset.c b/thirdparty/libpng/pngset.c index 998473557f..6f3a1ee11e 100644 --- a/thirdparty/libpng/pngset.c +++ b/thirdparty/libpng/pngset.c @@ -1,7 +1,7 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.6.30 [June 28, 2017] + * Last changed in libpng 1.6.32 [August 24, 2017] * Copyright (c) 1998-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -139,6 +139,15 @@ void PNGAPI png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, const png_bytep eXIf_buf) { + png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1"); + PNG_UNUSED(info_ptr) + PNG_UNUSED(eXIf_buf) +} + +void PNGAPI +png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr, + const png_uint_32 num_exif, const png_bytep eXIf_buf) +{ int i; png_debug1(1, "in %s storage function", "eXIf"); @@ -146,7 +155,13 @@ png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, if (png_ptr == NULL || info_ptr == NULL) return; - png_free_data(png_ptr, info_ptr, PNG_FREE_EXIF, 0); + if (info_ptr->exif) + { + png_free(png_ptr, info_ptr->exif); + info_ptr->exif = NULL; + } + + info_ptr->num_exif = num_exif; info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr, info_ptr->num_exif)); @@ -154,13 +169,12 @@ png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, if (info_ptr->exif == NULL) { png_warning(png_ptr, "Insufficient memory for eXIf chunk data"); - return; } info_ptr->free_me |= PNG_FREE_EXIF; - for (i = 0; i < info_ptr->num_exif; i++) + for (i = 0; i < (int) info_ptr->num_exif; i++) info_ptr->exif[i] = eXIf_buf[i]; info_ptr->valid |= PNG_INFO_eXIf; @@ -1388,6 +1402,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, static PNG_CONST png_byte chunks_to_ignore[] = { 98, 75, 71, 68, '\0', /* bKGD */ 99, 72, 82, 77, '\0', /* cHRM */ + 101, 88, 73, 102, '\0', /* eXIf */ 103, 65, 77, 65, '\0', /* gAMA */ 104, 73, 83, 84, '\0', /* hIST */ 105, 67, 67, 80, '\0', /* iCCP */ diff --git a/thirdparty/libpng/pngstruct.h b/thirdparty/libpng/pngstruct.h index 44b79dea74..d83f971253 100644 --- a/thirdparty/libpng/pngstruct.h +++ b/thirdparty/libpng/pngstruct.h @@ -1,7 +1,7 @@ /* pngstruct.h - header file for PNG reference library * - * Last changed in libpng 1.6.28 [January 5, 2017] + * Last changed in libpng 1.6.32 [August 24, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -479,8 +479,5 @@ struct png_struct_def png_colorspace colorspace; #endif #endif - -/* New member added in libpng-1.6.31 */ - int num_exif; }; #endif /* PNGSTRUCT_H */ diff --git a/thirdparty/libpng/pngwrite.c b/thirdparty/libpng/pngwrite.c index 8c2952e794..a7662acb71 100644 --- a/thirdparty/libpng/pngwrite.c +++ b/thirdparty/libpng/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.6.31 [(PENDING RELEASE)] + * Last changed in libpng 1.6.32 [August 24, 2017] * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -237,6 +237,11 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); #endif +#ifdef PNG_WRITE_eXIf_SUPPORTED + if ((info_ptr->valid & PNG_INFO_eXIf) != 0) + png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif); +#endif + #ifdef PNG_WRITE_hIST_SUPPORTED if ((info_ptr->valid & PNG_INFO_hIST) != 0) png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); @@ -432,6 +437,12 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr) } } #endif + +#ifdef PNG_WRITE_eXIf_SUPPORTED + if ((info_ptr->valid & PNG_INFO_eXIf) != 0) + png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif); +#endif + #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT); #endif diff --git a/thirdparty/libpng/pngwutil.c b/thirdparty/libpng/pngwutil.c index 348bb524dd..0d4fb1336c 100644 --- a/thirdparty/libpng/pngwutil.c +++ b/thirdparty/libpng/pngwutil.c @@ -1,8 +1,8 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.6.26 [October 20, 2016] - * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -1479,24 +1479,15 @@ void /* PRIVATE */ png_write_eXIf(png_structrp png_ptr, png_bytep exif, int num_exif) { int i; - png_byte buf[3]; + png_byte buf[1]; png_debug(1, "in png_write_eXIf"); - if (num_exif > (int)png_ptr->num_exif) - { - png_debug2(3, "num_exif = %d, png_ptr->num_exif = %d", num_exif, - png_ptr->num_exif); - - png_warning(png_ptr, "Invalid number of exif bytes specified"); - return; - } - png_write_chunk_header(png_ptr, png_eXIf, (png_uint_32)(num_exif)); for (i = 0; i < num_exif; i++) { - buf[i] = exif[i]; + buf[0] = exif[i]; png_write_chunk_data(png_ptr, buf, (png_size_t)1); } diff --git a/thirdparty/misc/stb_truetype.h b/thirdparty/misc/stb_truetype.h index 016972785a..cec2425471 100644 --- a/thirdparty/misc/stb_truetype.h +++ b/thirdparty/misc/stb_truetype.h @@ -1,11 +1,12 @@ -// stb_truetype.h - v1.11 - public domain -// authored from 2009-2015 by Sean Barrett / RAD Game Tools +// stb_truetype.h - v1.17 - public domain +// authored from 2009-2016 by Sean Barrett / RAD Game Tools // // This library processes TrueType files: // parse files // extract glyph metrics // extract glyph shapes // render glyphs to one-channel bitmaps with antialiasing (box filter) +// render glyphs to one-channel SDF bitmaps (signed-distance field/function) // // Todo: // non-MS cmaps @@ -20,16 +21,19 @@ // // Mikko Mononen: compound shape support, more cmap formats // Tor Andersson: kerning, subpixel rendering +// Dougall Johnson: OpenType / Type 2 font handling // // Misc other: // Ryan Gordon // Simon Glass +// github:IntellectualKitty +// Imanol Celaya // // Bug/warning reports/fixes: -// "Zer" on mollyrocket (with fix) +// "Zer" on mollyrocket // Cass Everitt // stoiko (Haemimont Games) -// Brian Hook +// Brian Hook // Walter van Niftrik // David Gow // David Given @@ -48,9 +52,17 @@ // Higor Euripedes // Thomas Fields // Derek Vinyard +// Cort Stratton +// github:oyvindjam // // VERSION HISTORY // +// 1.17 (2017-07-23) make more arguments const; doc fix +// 1.16 (2017-07-12) SDF support +// 1.15 (2017-03-03) make more arguments const +// 1.14 (2017-01-16) num-fonts-in-TTC function +// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts +// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual // 1.11 (2016-04-02) fix unused-variable warning // 1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef // 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly @@ -60,20 +72,12 @@ // fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); // fixed an assert() bug in the new rasterizer // replace assert() with STBTT_assert() in new rasterizer -// 1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine) -// also more precise AA rasterizer, except if shapes overlap -// remove need for STBTT_sort -// 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC -// 1.04 (2015-04-15) typo in example -// 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes // // Full history can be found at the end of this file. // // LICENSE // -// This software is dual-licensed to the public domain and under the following -// license: you are granted a perpetual, irrevocable license to copy, modify, -// publish, and distribute this file as you see fit. +// See end of file for license information. // // USAGE // @@ -93,14 +97,15 @@ // Improved 3D API (more shippable): // #include "stb_rect_pack.h" -- optional, but you really want it // stbtt_PackBegin() -// stbtt_PackSetOversample() -- for improved quality on small fonts +// stbtt_PackSetOversampling() -- for improved quality on small fonts // stbtt_PackFontRanges() -- pack and renders // stbtt_PackEnd() // stbtt_GetPackedQuad() // // "Load" a font file from a memory buffer (you have to keep the buffer loaded) // stbtt_InitFont() -// stbtt_GetFontOffsetForIndex() -- use for TTC font collections +// stbtt_GetFontOffsetForIndex() -- indexing for TTC font collections +// stbtt_GetNumberOfFonts() -- number of fonts for TTC font collections // // Render a unicode codepoint to a bitmap // stbtt_GetCodepointBitmap() -- allocates and returns a bitmap @@ -110,6 +115,7 @@ // Character advance/positioning // stbtt_GetCodepointHMetrics() // stbtt_GetFontVMetrics() +// stbtt_GetFontVMetricsOS2() // stbtt_GetCodepointKernAdvance() // // Starting with version 1.06, the rasterizer was replaced with a new, @@ -218,7 +224,7 @@ // Curve tesselation 120 LOC \__ 550 LOC Bitmap creation // Bitmap management 100 LOC / // Baked bitmap interface 70 LOC / -// Font name matching & access 150 LOC ---- 150 +// Font name matching & access 150 LOC ---- 150 // C runtime library abstraction 60 LOC ---- 60 // // @@ -311,7 +317,7 @@ int main(int argc, char **argv) } return 0; } -#endif +#endif // // Output: // @@ -325,9 +331,9 @@ int main(int argc, char **argv) // :@@. M@M // @@@o@@@@ // :M@@V:@@. -// +// ////////////////////////////////////////////////////////////////////////////// -// +// // Complete program: print "Hello World!" banner, with bugs // #if 0 @@ -407,6 +413,18 @@ int main(int arg, char **argv) #ifndef STBTT_sqrt #include <math.h> #define STBTT_sqrt(x) sqrt(x) + #define STBTT_pow(x,y) pow(x,y) + #endif + + #ifndef STBTT_cos + #include <math.h> + #define STBTT_cos(x) cos(x) + #define STBTT_acos(x) acos(x) + #endif + + #ifndef STBTT_fabs + #include <math.h> + #define STBTT_fabs(x) fabs(x) #endif #ifndef STBTT_fabs @@ -432,7 +450,7 @@ int main(int arg, char **argv) #endif #ifndef STBTT_memcpy - #include <memory.h> + #include <string.h> #define STBTT_memcpy memcpy #define STBTT_memset memset #endif @@ -458,6 +476,14 @@ int main(int arg, char **argv) extern "C" { #endif +// private structure +typedef struct +{ + unsigned char *data; + int cursor; + int size; +} stbtt__buf; + ////////////////////////////////////////////////////////////////////////////// // // TEXTURE BAKING API @@ -487,7 +513,7 @@ typedef struct float x1,y1,s1,t1; // bottom-right } stbtt_aligned_quad; -STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, // same data as above +STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw @@ -527,7 +553,7 @@ typedef struct stbrp_rect stbrp_rect; STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context); // Initializes a packing context stored in the passed-in stbtt_pack_context. // Future calls using this context will pack characters into the bitmap passed -// in here: a 1-channel bitmap that is weight x height. stride_in_bytes is +// in here: a 1-channel bitmap that is width * height. stride_in_bytes is // the distance from one row to the next (or 0 to mean they are packed tightly // together). "padding" is the amount of padding to leave between each // character (normally you want '1' for bitmaps you'll use as textures with @@ -540,7 +566,7 @@ STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); #define STBTT_POINT_SIZE(x) (-(x)) -STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size, +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); // Creates character bitmaps from the font_index'th font found in fontdata (use // font_index=0 if you don't know what that is). It creates num_chars_in_range @@ -565,7 +591,7 @@ typedef struct unsigned char h_oversample, v_oversample; // don't set these, they're used internally } stbtt_pack_range; -STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); // Creates character bitmaps from multiple ranges of characters stored in // ranges. This will usually create a better-packed bitmap than multiple // calls to stbtt_PackFontRange. Note that you can call this multiple @@ -587,19 +613,19 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h // To use with PackFontRangesGather etc., you must set it before calls // call to PackFontRangesGatherRects. -STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, // same data as above +STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above int char_index, // character to display float *xpos, float *ypos, // pointers to current position in screen pixel space stbtt_aligned_quad *q, // output: quad to draw int align_to_integer); -STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects); -STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); // Calling these functions in sequence is roughly equivalent to calling // stbtt_PackFontRanges(). If you more control over the packing of multiple // fonts, or if you want to pack custom data into a font texture, take a look -// at the source to of stbtt_PackFontRanges() and create a custom version +// at the source to of stbtt_PackFontRanges() and create a custom version // using these functions, e.g. call GatherRects multiple times, // building up a single array of rects, then call PackRects once, // then call RenderIntoRects repeatedly. This may result in a @@ -626,14 +652,19 @@ struct stbtt_pack_context { // // +STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data); +// This function will determine the number of fonts in a font file. TrueType +// collection (.ttc) files may contain multiple fonts, while TrueType font +// (.ttf) files only contain one font. The number of fonts can be used for +// indexing with the previous function where the index is between zero and one +// less than the total fonts. If an error occurs, -1 is returned. + STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); // Each .ttf/.ttc file may have more than one font. Each font has a sequential // index number starting from 0. Call this function to get the font offset for // a given index; it returns -1 if the index is out of range. A regular .ttf // file will only define one font and it always be at offset 0, so it will -// return '0' for index 0, and -1 for all other indices. You can just skip -// this step if you know it's that kind of font. - +// return '0' for index 0, and -1 for all other indices. // The following structure is defined publically so you can declare one on // the stack or as a global or etc, but you should treat it as opaque. @@ -648,6 +679,13 @@ struct stbtt_fontinfo int loca,head,glyf,hhea,hmtx,kern; // table locations as offset from start of .ttf int index_map; // a cmap mapping for our chosen character encoding int indexToLocFormat; // format needed to map from glyph index to glyph + + stbtt__buf cff; // cff font data + stbtt__buf charstrings; // the charstring index + stbtt__buf gsubrs; // global charstring subroutines index + stbtt__buf subrs; // private charstring subroutines index + stbtt__buf fontdicts; // array of font dicts + stbtt__buf fdselect; // map from glyph to fontdict }; STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); @@ -695,6 +733,12 @@ STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, in // these are expressed in unscaled coordinates, so you must multiply by // the scale factor for a given size +STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap); +// analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2 +// table (specific to MS/Windows TTF files). +// +// Returns 1 on success (table present), 0 on failure. + STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); // the bounding box around all possible characters @@ -725,7 +769,8 @@ STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, in enum { STBTT_vmove=1, STBTT_vline, - STBTT_vcurve + STBTT_vcurve, + STBTT_vcubic }; #endif @@ -734,7 +779,7 @@ STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, in #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file typedef struct { - stbtt_vertex_type x,y,cx,cy; + stbtt_vertex_type x,y,cx,cy,cx1,cy1; unsigned char type,padding; } stbtt_vertex; #endif @@ -788,6 +833,10 @@ STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, uns // same as stbtt_MakeCodepointBitmap, but you can specify a subpixel // shift for the character +STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint); +// same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering +// is performed (see stbtt_PackSetOversampling) + STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); // get the bbox of the bitmap centered around the glyph origin; so the // bitmap width is ix1-ix0, height is iy1-iy0, and location to place @@ -805,6 +854,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph); STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); @@ -829,6 +879,64 @@ STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap ////////////////////////////////////////////////////////////////////////////// // +// Signed Distance Function (or Field) rendering + +STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata); +// frees the SDF bitmap allocated below + +STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); +STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); +// These functions compute a discretized SDF field for a single character, suitable for storing +// in a single-channel texture, sampling with bilinear filtering, and testing against +// larger than some threshhold to produce scalable fonts. +// info -- the font +// scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap +// glyph/codepoint -- the character to generate the SDF for +// padding -- extra "pixels" around the character which are filled with the distance to the character (not 0), +// which allows effects like bit outlines +// onedge_value -- value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character) +// pixel_dist_scale -- what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale) +// if positive, > onedge_value is inside; if negative, < onedge_value is inside +// width,height -- output height & width of the SDF bitmap (including padding) +// xoff,yoff -- output origin of the character +// return value -- a 2D array of bytes 0..255, width*height in size +// +// pixel_dist_scale & onedge_value are a scale & bias that allows you to make +// optimal use of the limited 0..255 for your application, trading off precision +// and special effects. SDF values outside the range 0..255 are clamped to 0..255. +// +// Example: +// scale = stbtt_ScaleForPixelHeight(22) +// padding = 5 +// onedge_value = 180 +// pixel_dist_scale = 180/5.0 = 36.0 +// +// This will create an SDF bitmap in which the character is about 22 pixels +// high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled +// shape, sample the SDF at each pixel and fill the pixel if the SDF value +// is greater than or equal to 180/255. (You'll actually want to antialias, +// which is beyond the scope of this example.) Additionally, you can compute +// offset outlines (e.g. to stroke the character border inside & outside, +// or only outside). For example, to fill outside the character up to 3 SDF +// pixels, you would compare against (180-36.0*3)/255 = 72/255. The above +// choice of variables maps a range from 5 pixels outside the shape to +// 2 pixels inside the shape to 0..255; this is intended primarily for apply +// outside effects only (the interior range is needed to allow proper +// antialiasing of the font at *smaller* sizes) +// +// The function computes the SDF analytically at each SDF pixel, not by e.g. +// building a higher-res bitmap and approximating it. In theory the quality +// should be as high as possible for an SDF of this size & representation, but +// unclear if this is true in practice (perhaps building a higher-res bitmap +// and computing from that can allow drop-out prevention). +// +// The algorithm has not been optimized at all, so expect it to be slow +// if computing lots of characters or very large sizes. + + + +////////////////////////////////////////////////////////////////////////////// +// // Finding the right font... // // You should really just solve this offline, keep your own tables @@ -958,6 +1066,152 @@ typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERS ////////////////////////////////////////////////////////////////////////// // +// stbtt__buf helpers to parse data from file +// + +static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b) +{ + if (b->cursor >= b->size) + return 0; + return b->data[b->cursor++]; +} + +static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) +{ + if (b->cursor >= b->size) + return 0; + return b->data[b->cursor]; +} + +static void stbtt__buf_seek(stbtt__buf *b, int o) +{ + STBTT_assert(!(o > b->size || o < 0)); + b->cursor = (o > b->size || o < 0) ? b->size : o; +} + +static void stbtt__buf_skip(stbtt__buf *b, int o) +{ + stbtt__buf_seek(b, b->cursor + o); +} + +static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) +{ + stbtt_uint32 v = 0; + int i; + STBTT_assert(n >= 1 && n <= 4); + for (i = 0; i < n; i++) + v = (v << 8) | stbtt__buf_get8(b); + return v; +} + +static stbtt__buf stbtt__new_buf(const void *p, size_t size) +{ + stbtt__buf r; + STBTT_assert(size < 0x40000000); + r.data = (stbtt_uint8*) p; + r.size = (int) size; + r.cursor = 0; + return r; +} + +#define stbtt__buf_get16(b) stbtt__buf_get((b), 2) +#define stbtt__buf_get32(b) stbtt__buf_get((b), 4) + +static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s) +{ + stbtt__buf r = stbtt__new_buf(NULL, 0); + if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r; + r.data = b->data + o; + r.size = s; + return r; +} + +static stbtt__buf stbtt__cff_get_index(stbtt__buf *b) +{ + int count, start, offsize; + start = b->cursor; + count = stbtt__buf_get16(b); + if (count) { + offsize = stbtt__buf_get8(b); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(b, offsize * count); + stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); + } + return stbtt__buf_range(b, start, b->cursor - start); +} + +static stbtt_uint32 stbtt__cff_int(stbtt__buf *b) +{ + int b0 = stbtt__buf_get8(b); + if (b0 >= 32 && b0 <= 246) return b0 - 139; + else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108; + else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108; + else if (b0 == 28) return stbtt__buf_get16(b); + else if (b0 == 29) return stbtt__buf_get32(b); + STBTT_assert(0); + return 0; +} + +static void stbtt__cff_skip_operand(stbtt__buf *b) { + int v, b0 = stbtt__buf_peek8(b); + STBTT_assert(b0 >= 28); + if (b0 == 30) { + stbtt__buf_skip(b, 1); + while (b->cursor < b->size) { + v = stbtt__buf_get8(b); + if ((v & 0xF) == 0xF || (v >> 4) == 0xF) + break; + } + } else { + stbtt__cff_int(b); + } +} + +static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) +{ + stbtt__buf_seek(b, 0); + while (b->cursor < b->size) { + int start = b->cursor, end, op; + while (stbtt__buf_peek8(b) >= 28) + stbtt__cff_skip_operand(b); + end = b->cursor; + op = stbtt__buf_get8(b); + if (op == 12) op = stbtt__buf_get8(b) | 0x100; + if (op == key) return stbtt__buf_range(b, start, end-start); + } + return stbtt__buf_range(b, 0, 0); +} + +static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out) +{ + int i; + stbtt__buf operands = stbtt__dict_get(b, key); + for (i = 0; i < outcount && operands.cursor < operands.size; i++) + out[i] = stbtt__cff_int(&operands); +} + +static int stbtt__cff_index_count(stbtt__buf *b) +{ + stbtt__buf_seek(b, 0); + return stbtt__buf_get16(b); +} + +static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i) +{ + int count, offsize, start, end; + stbtt__buf_seek(&b, 0); + count = stbtt__buf_get16(&b); + offsize = stbtt__buf_get8(&b); + STBTT_assert(i >= 0 && i < count); + STBTT_assert(offsize >= 1 && offsize <= 4); + stbtt__buf_skip(&b, i*offsize); + start = stbtt__buf_get(&b, offsize); + end = stbtt__buf_get(&b, offsize); + return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start); +} + +////////////////////////////////////////////////////////////////////////// +// // accessors to parse data from file // @@ -968,32 +1222,22 @@ typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERS #define ttCHAR(p) (* (stbtt_int8 *) (p)) #define ttFixed(p) ttLONG(p) -#if defined(STB_TRUETYPE_BIGENDIAN) && !defined(ALLOW_UNALIGNED_TRUETYPE) - - #define ttUSHORT(p) (* (stbtt_uint16 *) (p)) - #define ttSHORT(p) (* (stbtt_int16 *) (p)) - #define ttULONG(p) (* (stbtt_uint32 *) (p)) - #define ttLONG(p) (* (stbtt_int32 *) (p)) - -#else - - static stbtt_uint16 ttUSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; } - static stbtt_int16 ttSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; } - static stbtt_uint32 ttULONG(const stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } - static stbtt_int32 ttLONG(const stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } - -#endif +static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } +static stbtt_int16 ttSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } +static stbtt_uint32 ttULONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } +static stbtt_int32 ttLONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } #define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) #define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3]) -static int stbtt__isfont(const stbtt_uint8 *font) +static int stbtt__isfont(stbtt_uint8 *font) { // check the version number if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1 if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this! if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0 + if (stbtt_tag(font, "true")) return 1; // Apple specification for TrueType fonts return 0; } @@ -1011,7 +1255,7 @@ static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, return 0; } -STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index) +static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index) { // if it's just a font, there's only one valid index if (stbtt__isfont(font_collection)) @@ -1030,14 +1274,43 @@ STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, return -1; } -STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontstart) +static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection) +{ + // if it's just a font, there's only one valid font + if (stbtt__isfont(font_collection)) + return 1; + + // check if it's a TTC + if (stbtt_tag(font_collection, "ttcf")) { + // version 1? + if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { + return ttLONG(font_collection+8); + } + } + return 0; +} + +static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict) +{ + stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 }; + stbtt__buf pdict; + stbtt__dict_get_ints(&fontdict, 18, 2, private_loc); + if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0); + pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]); + stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff); + if (!subrsoff) return stbtt__new_buf(NULL, 0); + stbtt__buf_seek(&cff, private_loc[1]+subrsoff); + return stbtt__cff_get_index(&cff); +} + +static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) { - stbtt_uint8 *data = (stbtt_uint8 *) data2; stbtt_uint32 cmap, t; stbtt_int32 i,numTables; info->data = data; info->fontstart = fontstart; + info->cff = stbtt__new_buf(NULL, 0); cmap = stbtt__find_table(data, fontstart, "cmap"); // required info->loca = stbtt__find_table(data, fontstart, "loca"); // required @@ -1046,8 +1319,61 @@ STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, i info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required info->kern = stbtt__find_table(data, fontstart, "kern"); // not required - if (!cmap || !info->loca || !info->head || !info->glyf || !info->hhea || !info->hmtx) + + if (!cmap || !info->head || !info->hhea || !info->hmtx) return 0; + if (info->glyf) { + // required for truetype + if (!info->loca) return 0; + } else { + // initialization for CFF / Type2 fonts (OTF) + stbtt__buf b, topdict, topdictidx; + stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; + stbtt_uint32 cff; + + cff = stbtt__find_table(data, fontstart, "CFF "); + if (!cff) return 0; + + info->fontdicts = stbtt__new_buf(NULL, 0); + info->fdselect = stbtt__new_buf(NULL, 0); + + // @TODO this should use size from table (not 512MB) + info->cff = stbtt__new_buf(data+cff, 512*1024*1024); + b = info->cff; + + // read the header + stbtt__buf_skip(&b, 2); + stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize + + // @TODO the name INDEX could list multiple fonts, + // but we just use the first one. + stbtt__cff_get_index(&b); // name INDEX + topdictidx = stbtt__cff_get_index(&b); + topdict = stbtt__cff_index_get(topdictidx, 0); + stbtt__cff_get_index(&b); // string INDEX + info->gsubrs = stbtt__cff_get_index(&b); + + stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); + stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); + stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); + stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); + info->subrs = stbtt__get_subrs(b, topdict); + + // we only support Type 2 charstrings + if (cstype != 2) return 0; + if (charstrings == 0) return 0; + + if (fdarrayoff) { + // looks like a CID font + if (!fdselectoff) return 0; + stbtt__buf_seek(&b, fdarrayoff); + info->fontdicts = stbtt__cff_get_index(&b); + info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); + } + + stbtt__buf_seek(&b, charstrings); + info->charstrings = stbtt__cff_get_index(&b); + } t = stbtt__find_table(data, fontstart, "maxp"); if (t) @@ -1198,6 +1524,8 @@ static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) { int g1,g2; + STBTT_assert(!info->cff.size); + if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format @@ -1212,15 +1540,21 @@ static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) return g1==g2 ? -1 : g1; // if length is 0, return -1 } +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); + STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) { - int g = stbtt__GetGlyfOffset(info, glyph_index); - if (g < 0) return 0; + if (info->cff.size) { + stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); + } else { + int g = stbtt__GetGlyfOffset(info, glyph_index); + if (g < 0) return 0; - if (x0) *x0 = ttSHORT(info->data + g + 2); - if (y0) *y0 = ttSHORT(info->data + g + 4); - if (x1) *x1 = ttSHORT(info->data + g + 6); - if (y1) *y1 = ttSHORT(info->data + g + 8); + if (x0) *x0 = ttSHORT(info->data + g + 2); + if (y0) *y0 = ttSHORT(info->data + g + 4); + if (x1) *x1 = ttSHORT(info->data + g + 6); + if (y1) *y1 = ttSHORT(info->data + g + 8); + } return 1; } @@ -1232,7 +1566,10 @@ STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, i STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) { stbtt_int16 numberOfContours; - int g = stbtt__GetGlyfOffset(info, glyph_index); + int g; + if (info->cff.size) + return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; + g = stbtt__GetGlyfOffset(info, glyph_index); if (g < 0) return 1; numberOfContours = ttSHORT(info->data + g); return numberOfContours == 0; @@ -1254,7 +1591,7 @@ static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_ return num_vertices; } -STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) { stbtt_int16 numberOfContours; stbtt_uint8 *endPtsOfContours; @@ -1350,7 +1687,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s if (i != 0) num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); - // now start the new one + // now start the new one start_off = !(flags & 1); if (start_off) { // if we start off with an off-curve point, then when we need to find a point on the curve @@ -1403,7 +1740,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s int comp_num_verts = 0, i; stbtt_vertex *comp_verts = 0, *tmp = 0; float mtx[6] = {1,0,0,1,0,0}, m, n; - + flags = ttSHORT(comp); comp+=2; gidx = ttSHORT(comp); comp+=2; @@ -1433,7 +1770,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; } - + // Find transformation scales. m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); @@ -1480,6 +1817,416 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s return num_vertices; } +typedef struct +{ + int bounds; + int started; + float first_x, first_y; + float x, y; + stbtt_int32 min_x, max_x, min_y, max_y; + + stbtt_vertex *pvertices; + int num_vertices; +} stbtt__csctx; + +#define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0} + +static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) +{ + if (x > c->max_x || !c->started) c->max_x = x; + if (y > c->max_y || !c->started) c->max_y = y; + if (x < c->min_x || !c->started) c->min_x = x; + if (y < c->min_y || !c->started) c->min_y = y; + c->started = 1; +} + +static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) +{ + if (c->bounds) { + stbtt__track_vertex(c, x, y); + if (type == STBTT_vcubic) { + stbtt__track_vertex(c, cx, cy); + stbtt__track_vertex(c, cx1, cy1); + } + } else { + stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); + c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; + c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; + } + c->num_vertices++; +} + +static void stbtt__csctx_close_shape(stbtt__csctx *ctx) +{ + if (ctx->first_x != ctx->x || ctx->first_y != ctx->y) + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) +{ + stbtt__csctx_close_shape(ctx); + ctx->first_x = ctx->x = ctx->x + dx; + ctx->first_y = ctx->y = ctx->y + dy; + stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy) +{ + ctx->x += dx; + ctx->y += dy; + stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); +} + +static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) +{ + float cx1 = ctx->x + dx1; + float cy1 = ctx->y + dy1; + float cx2 = cx1 + dx2; + float cy2 = cy1 + dy2; + ctx->x = cx2 + dx3; + ctx->y = cy2 + dy3; + stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2); +} + +static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) +{ + int count = stbtt__cff_index_count(&idx); + int bias = 107; + if (count >= 33900) + bias = 32768; + else if (count >= 1240) + bias = 1131; + n += bias; + if (n < 0 || n >= count) + return stbtt__new_buf(NULL, 0); + return stbtt__cff_index_get(idx, n); +} + +static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index) +{ + stbtt__buf fdselect = info->fdselect; + int nranges, start, end, v, fmt, fdselector = -1, i; + + stbtt__buf_seek(&fdselect, 0); + fmt = stbtt__buf_get8(&fdselect); + if (fmt == 0) { + // untested + stbtt__buf_skip(&fdselect, glyph_index); + fdselector = stbtt__buf_get8(&fdselect); + } else if (fmt == 3) { + nranges = stbtt__buf_get16(&fdselect); + start = stbtt__buf_get16(&fdselect); + for (i = 0; i < nranges; i++) { + v = stbtt__buf_get8(&fdselect); + end = stbtt__buf_get16(&fdselect); + if (glyph_index >= start && glyph_index < end) { + fdselector = v; + break; + } + start = end; + } + } + if (fdselector == -1) stbtt__new_buf(NULL, 0); + return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector)); +} + +static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c) +{ + int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0; + int has_subrs = 0, clear_stack; + float s[48]; + stbtt__buf subr_stack[10], subrs = info->subrs, b; + float f; + +#define STBTT__CSERR(s) (0) + + // this currently ignores the initial width value, which isn't needed if we have hmtx + b = stbtt__cff_index_get(info->charstrings, glyph_index); + while (b.cursor < b.size) { + i = 0; + clear_stack = 1; + b0 = stbtt__buf_get8(&b); + switch (b0) { + // @TODO implement hinting + case 0x13: // hintmask + case 0x14: // cntrmask + if (in_header) + maskbits += (sp / 2); // implicit "vstem" + in_header = 0; + stbtt__buf_skip(&b, (maskbits + 7) / 8); + break; + + case 0x01: // hstem + case 0x03: // vstem + case 0x12: // hstemhm + case 0x17: // vstemhm + maskbits += (sp / 2); + break; + + case 0x15: // rmoveto + in_header = 0; + if (sp < 2) return STBTT__CSERR("rmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); + break; + case 0x04: // vmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("vmoveto stack"); + stbtt__csctx_rmove_to(c, 0, s[sp-1]); + break; + case 0x16: // hmoveto + in_header = 0; + if (sp < 1) return STBTT__CSERR("hmoveto stack"); + stbtt__csctx_rmove_to(c, s[sp-1], 0); + break; + + case 0x05: // rlineto + if (sp < 2) return STBTT__CSERR("rlineto stack"); + for (; i + 1 < sp; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical + // starting from a different place. + + case 0x07: // vlineto + if (sp < 1) return STBTT__CSERR("vlineto stack"); + goto vlineto; + case 0x06: // hlineto + if (sp < 1) return STBTT__CSERR("hlineto stack"); + for (;;) { + if (i >= sp) break; + stbtt__csctx_rline_to(c, s[i], 0); + i++; + vlineto: + if (i >= sp) break; + stbtt__csctx_rline_to(c, 0, s[i]); + i++; + } + break; + + case 0x1F: // hvcurveto + if (sp < 4) return STBTT__CSERR("hvcurveto stack"); + goto hvcurveto; + case 0x1E: // vhcurveto + if (sp < 4) return STBTT__CSERR("vhcurveto stack"); + for (;;) { + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); + i += 4; + hvcurveto: + if (i + 3 >= sp) break; + stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); + i += 4; + } + break; + + case 0x08: // rrcurveto + if (sp < 6) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x18: // rcurveline + if (sp < 8) return STBTT__CSERR("rcurveline stack"); + for (; i + 5 < sp - 2; i += 6) + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); + stbtt__csctx_rline_to(c, s[i], s[i+1]); + break; + + case 0x19: // rlinecurve + if (sp < 8) return STBTT__CSERR("rlinecurve stack"); + for (; i + 1 < sp - 6; i += 2) + stbtt__csctx_rline_to(c, s[i], s[i+1]); + if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); + stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); + break; + + case 0x1A: // vvcurveto + case 0x1B: // hhcurveto + if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); + f = 0.0; + if (sp & 1) { f = s[i]; i++; } + for (; i + 3 < sp; i += 4) { + if (b0 == 0x1B) + stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); + else + stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); + f = 0.0; + } + break; + + case 0x0A: // callsubr + if (!has_subrs) { + if (info->fdselect.size) + subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); + has_subrs = 1; + } + // fallthrough + case 0x1D: // callgsubr + if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); + v = (int) s[--sp]; + if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); + subr_stack[subr_stack_height++] = b; + b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); + if (b.size == 0) return STBTT__CSERR("subr not found"); + b.cursor = 0; + clear_stack = 0; + break; + + case 0x0B: // return + if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); + b = subr_stack[--subr_stack_height]; + clear_stack = 0; + break; + + case 0x0E: // endchar + stbtt__csctx_close_shape(c); + return 1; + + case 0x0C: { // two-byte escape + float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; + float dx, dy; + int b1 = stbtt__buf_get8(&b); + switch (b1) { + // @TODO These "flex" implementations ignore the flex-depth and resolution, + // and always draw beziers. + case 0x22: // hflex + if (sp < 7) return STBTT__CSERR("hflex stack"); + dx1 = s[0]; + dx2 = s[1]; + dy2 = s[2]; + dx3 = s[3]; + dx4 = s[4]; + dx5 = s[5]; + dx6 = s[6]; + stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); + break; + + case 0x23: // flex + if (sp < 13) return STBTT__CSERR("flex stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = s[10]; + dy6 = s[11]; + //fd is s[12] + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + case 0x24: // hflex1 + if (sp < 9) return STBTT__CSERR("hflex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dx4 = s[5]; + dx5 = s[6]; + dy5 = s[7]; + dx6 = s[8]; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); + stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); + break; + + case 0x25: // flex1 + if (sp < 11) return STBTT__CSERR("flex1 stack"); + dx1 = s[0]; + dy1 = s[1]; + dx2 = s[2]; + dy2 = s[3]; + dx3 = s[4]; + dy3 = s[5]; + dx4 = s[6]; + dy4 = s[7]; + dx5 = s[8]; + dy5 = s[9]; + dx6 = dy6 = s[10]; + dx = dx1+dx2+dx3+dx4+dx5; + dy = dy1+dy2+dy3+dy4+dy5; + if (STBTT_fabs(dx) > STBTT_fabs(dy)) + dy6 = -dy; + else + dx6 = -dx; + stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); + stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); + break; + + default: + return STBTT__CSERR("unimplemented"); + } + } break; + + default: + if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) + return STBTT__CSERR("reserved operator"); + + // push immediate + if (b0 == 255) { + f = (float)stbtt__buf_get32(&b) / 0x10000; + } else { + stbtt__buf_skip(&b, -1); + f = (float)(stbtt_int16)stbtt__cff_int(&b); + } + if (sp >= 48) return STBTT__CSERR("push stack overflow"); + s[sp++] = f; + clear_stack = 0; + break; + } + if (clear_stack) sp = 0; + } + return STBTT__CSERR("no endchar"); + +#undef STBTT__CSERR +} + +static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + // runs the charstring twice, once to count and once to output (to avoid realloc) + stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); + stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0); + if (stbtt__run_charstring(info, glyph_index, &count_ctx)) { + *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); + output_ctx.pvertices = *pvertices; + if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { + STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); + return output_ctx.num_vertices; + } + } + *pvertices = NULL; + return 0; +} + +static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) +{ + stbtt__csctx c = STBTT__CSCTX_INIT(1); + int r = stbtt__run_charstring(info, glyph_index, &c); + if (x0) { + *x0 = r ? c.min_x : 0; + *y0 = r ? c.min_y : 0; + *x1 = r ? c.max_x : 0; + *y1 = r ? c.max_y : 0; + } + return r ? c.num_vertices : 0; +} + +STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) +{ + if (!info->cff.size) + return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); + else + return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); +} + STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) { stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); @@ -1541,6 +2288,17 @@ STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, in if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); } +STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap) +{ + int tab = stbtt__find_table(info->data, info->fontstart, "OS/2"); + if (!tab) + return 0; + if (typoAscent ) *typoAscent = ttSHORT(info->data+tab + 68); + if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70); + if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72); + return 1; +} + STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) { *x0 = ttSHORT(info->data + info->head + 36); @@ -1691,7 +2449,7 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); STBTT_assert(z != NULL); if (!z) return z; - + // round dx down to avoid overshooting if (dxdy < 0) z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); @@ -1769,7 +2527,7 @@ static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__ac } } } - + e = e->next; } } @@ -2033,19 +2791,18 @@ static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, // from the other y segment, and it might ignored as an empty segment. to avoid // that, we need to explicitly produce segments based on x positions. - // rename variables to clear pairs + // rename variables to clearly-defined pairs float y0 = y_top; float x1 = (float) (x); float x2 = (float) (x+1); float x3 = xb; float y3 = y_bottom; - float y1,y2; // x = e->x + e->dx * (y-y_top) // (y-y_top) = (x - e->x) / e->dx // y = (x - e->x) / e->dx + y_top - y1 = (x - x0) / dx + y_top; - y2 = (x+1 - x0) / dx + y_top; + float y1 = (x - x0) / dx + y_top; + float y2 = (x+1 - x0) / dx + y_top; if (x0 < x1 && x3 > x2) { // three segments descending down-right stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); @@ -2350,6 +3107,48 @@ static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x return 1; } +static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n) +{ + // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough + float dx0 = x1-x0; + float dy0 = y1-y0; + float dx1 = x2-x1; + float dy1 = y2-y1; + float dx2 = x3-x2; + float dy2 = y3-y2; + float dx = x3-x0; + float dy = y3-y0; + float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2)); + float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy); + float flatness_squared = longlen*longlen-shortlen*shortlen; + + if (n > 16) // 65536 segments on one curve better be enough! + return; + + if (flatness_squared > objspace_flatness_squared) { + float x01 = (x0+x1)/2; + float y01 = (y0+y1)/2; + float x12 = (x1+x2)/2; + float y12 = (y1+y2)/2; + float x23 = (x2+x3)/2; + float y23 = (y2+y3)/2; + + float xa = (x01+x12)/2; + float ya = (y01+y12)/2; + float xb = (x12+x23)/2; + float yb = (y12+y23)/2; + + float mx = (xa+xb)/2; + float my = (ya+yb)/2; + + stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); + stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); + } else { + stbtt__add_point(points, *num_points,x3,y3); + *num_points = *num_points+1; + } +} + // returns number of contours static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) { @@ -2406,6 +3205,14 @@ static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, objspace_flatness_squared, 0); x = vertices[i].x, y = vertices[i].y; break; + case STBTT_vcubic: + stbtt__tesselate_cubic(points, &num_points, x,y, + vertices[i].cx, vertices[i].cy, + vertices[i].cx1, vertices[i].cy1, + vertices[i].x, vertices[i].y, + objspace_flatness_squared, 0); + x = vertices[i].x, y = vertices[i].y; + break; } } (*contour_lengths)[n] = num_points - start; @@ -2441,7 +3248,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info { int ix0,iy0,ix1,iy1; stbtt__bitmap gbm; - stbtt_vertex *vertices; + stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); if (scale_x == 0) scale_x = scale_y; @@ -2464,7 +3271,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info if (height) *height = gbm.h; if (xoff ) *xoff = ix0; if (yoff ) *yoff = iy0; - + if (gbm.w && gbm.h) { gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); if (gbm.pixels) { @@ -2475,7 +3282,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info } STBTT_free(vertices, info->userdata); return gbm.pixels; -} +} STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) { @@ -2487,7 +3294,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigne int ix0,iy0; stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); - stbtt__bitmap gbm; + stbtt__bitmap gbm; stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); gbm.pixels = output; @@ -2509,7 +3316,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char * STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); -} +} STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) { @@ -2519,7 +3326,7 @@ STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, uns STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); -} +} STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) { @@ -2532,7 +3339,7 @@ STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned ch // // This is SUPER-CRAPPY packing to keep source code small -STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) +static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) float pixel_height, // height of font in pixels unsigned char *pixels, int pw, int ph, // bitmap to be filled in int first_char, int num_chars, // characters to bake @@ -2578,11 +3385,11 @@ STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // fo return bottom_y; } -STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) +STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) { float d3d_bias = opengl_fillrule ? 0 : -0.5f; float ipw = 1.0f / pw, iph = 1.0f / ph; - stbtt_bakedchar *b = chardata + char_index; + const stbtt_bakedchar *b = chardata + char_index; int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); @@ -2644,7 +3451,7 @@ static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *no con->y = 0; con->bottom_y = 0; STBTT__NOTUSED(nodes); - STBTT__NOTUSED(num_nodes); + STBTT__NOTUSED(num_nodes); } static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) @@ -2862,7 +3669,7 @@ static float stbtt__oversample_shift(int oversample) } // rects array must be big enough to accommodate all characters in the given ranges -STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) { int i,j,k; @@ -2890,8 +3697,31 @@ STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fon return k; } +STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph) +{ + stbtt_MakeGlyphBitmapSubpixel(info, + output, + out_w - (prefilter_x - 1), + out_h - (prefilter_y - 1), + out_stride, + scale_x, + scale_y, + shift_x, + shift_y, + glyph); + + if (prefilter_x > 1) + stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x); + + if (prefilter_y > 1) + stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y); + + *sub_x = stbtt__oversample_shift(prefilter_x); + *sub_y = stbtt__oversample_shift(prefilter_y); +} + // rects array must be big enough to accommodate all characters in the given ranges -STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) +STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) { int i,j,k, return_value = 1; @@ -2978,7 +3808,7 @@ STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects); } -STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) +STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) { stbtt_fontinfo info; int i,j,n, return_value = 1; @@ -2996,7 +3826,7 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontd n = 0; for (i=0; i < num_ranges; ++i) n += ranges[i].num_chars; - + rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); if (rects == NULL) return 0; @@ -3007,14 +3837,14 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontd n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects); stbtt_PackFontRangesPackRects(spc, rects, n); - + return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects); STBTT_free(rects, spc->user_allocator_context); return return_value; } -STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size, +STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) { stbtt_pack_range range; @@ -3026,10 +3856,10 @@ STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontda return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); } -STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) +STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) { float ipw = 1.0f / pw, iph = 1.0f / ph; - stbtt_packedchar *b = chardata + char_index; + const stbtt_packedchar *b = chardata + char_index; if (align_to_integer) { float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); @@ -3053,6 +3883,387 @@ STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, i *xpos += b->xadvance; } +////////////////////////////////////////////////////////////////////////////// +// +// sdf computation +// + +#define STBTT_min(a,b) ((a) < (b) ? (a) : (b)) +#define STBTT_max(a,b) ((a) < (b) ? (b) : (a)) + +static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2]) +{ + float q0perp = q0[1]*ray[0] - q0[0]*ray[1]; + float q1perp = q1[1]*ray[0] - q1[0]*ray[1]; + float q2perp = q2[1]*ray[0] - q2[0]*ray[1]; + float roperp = orig[1]*ray[0] - orig[0]*ray[1]; + + float a = q0perp - 2*q1perp + q2perp; + float b = q1perp - q0perp; + float c = q0perp - roperp; + + float s0 = 0., s1 = 0.; + int num_s = 0; + + if (a != 0.0) { + float discr = b*b - a*c; + if (discr > 0.0) { + float rcpna = -1 / a; + float d = (float) sqrt(discr); + s0 = (b+d) * rcpna; + s1 = (b-d) * rcpna; + if (s0 >= 0.0 && s0 <= 1.0) + num_s = 1; + if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) { + if (num_s == 0) s0 = s1; + ++num_s; + } + } + } else { + // 2*b*s + c = 0 + // s = -c / (2*b) + s0 = c / (-2 * b); + if (s0 >= 0.0 && s0 <= 1.0) + num_s = 1; + } + + if (num_s == 0) + return 0; + else { + float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]); + float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2; + + float q0d = q0[0]*rayn_x + q0[1]*rayn_y; + float q1d = q1[0]*rayn_x + q1[1]*rayn_y; + float q2d = q2[0]*rayn_x + q2[1]*rayn_y; + float rod = orig[0]*rayn_x + orig[1]*rayn_y; + + float q10d = q1d - q0d; + float q20d = q2d - q0d; + float q0rd = q0d - rod; + + hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d; + hits[0][1] = a*s0+b; + + if (num_s > 1) { + hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d; + hits[1][1] = a*s1+b; + return 2; + } else { + return 1; + } + } +} + +static int equal(float *a, float *b) +{ + return (a[0] == b[0] && a[1] == b[1]); +} + +static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts) +{ + int i; + float orig[2], ray[2] = { 1, 0 }; + float y_frac; + int winding = 0; + + orig[0] = x; + orig[1] = y; + + // make sure y never passes through a vertex of the shape + y_frac = (float) fmod(y, 1.0f); + if (y_frac < 0.01f) + y += 0.01f; + else if (y_frac > 0.99f) + y -= 0.01f; + orig[1] = y; + + // test a ray from (-infinity,y) to (x,y) + for (i=0; i < nverts; ++i) { + if (verts[i].type == STBTT_vline) { + int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y; + int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y; + if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { + float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; + if (x_inter < x) + winding += (y0 < y1) ? 1 : -1; + } + } + if (verts[i].type == STBTT_vcurve) { + int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ; + int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy; + int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ; + int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2)); + int by = STBTT_max(y0,STBTT_max(y1,y2)); + if (y > ay && y < by && x > ax) { + float q0[2],q1[2],q2[2]; + float hits[2][2]; + q0[0] = (float)x0; + q0[1] = (float)y0; + q1[0] = (float)x1; + q1[1] = (float)y1; + q2[0] = (float)x2; + q2[1] = (float)y2; + if (equal(q0,q1) || equal(q1,q2)) { + x0 = (int)verts[i-1].x; + y0 = (int)verts[i-1].y; + x1 = (int)verts[i ].x; + y1 = (int)verts[i ].y; + if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { + float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; + if (x_inter < x) + winding += (y0 < y1) ? 1 : -1; + } + } else { + int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits); + if (num_hits >= 1) + if (hits[0][0] < 0) + winding += (hits[0][1] < 0 ? -1 : 1); + if (num_hits >= 2) + if (hits[1][0] < 0) + winding += (hits[1][1] < 0 ? -1 : 1); + } + } + } + } + return winding; +} + +static float stbtt__cuberoot( float x ) +{ + if (x<0) + return -(float) STBTT_pow(-x,1.0f/3.0f); + else + return (float) STBTT_pow( x,1.0f/3.0f); +} + +// x^3 + c*x^2 + b*x + a = 0 +static int stbtt__solve_cubic(float a, float b, float c, float* r) +{ + float s = -a / 3; + float p = b - a*a / 3; + float q = a * (2*a*a - 9*b) / 27 + c; + float p3 = p*p*p; + float d = q*q + 4*p3 / 27; + if (d >= 0) { + float z = (float) STBTT_sqrt(d); + float u = (-q + z) / 2; + float v = (-q - z) / 2; + u = stbtt__cuberoot(u); + v = stbtt__cuberoot(v); + r[0] = s + u + v; + return 1; + } else { + float u = (float) STBTT_sqrt(-p/3); + float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative + float m = (float) STBTT_cos(v); + float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f; + r[0] = s + u * 2 * m; + r[1] = s - u * (m + n); + r[2] = s - u * (m - n); + + //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? + //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); + //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); + return 3; + } +} + +STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) +{ + float scale_x = scale, scale_y = scale; + int ix0,iy0,ix1,iy1; + int w,h; + unsigned char *data; + + // if one scale is 0, use same scale for both + if (scale_x == 0) scale_x = scale_y; + if (scale_y == 0) { + if (scale_x == 0) return NULL; // if both scales are 0, return NULL + scale_y = scale_x; + } + + stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1); + + // if empty, return NULL + if (ix0 == ix1 || iy0 == iy1) + return NULL; + + ix0 -= padding; + iy0 -= padding; + ix1 += padding; + iy1 += padding; + + w = (ix1 - ix0); + h = (iy1 - iy0); + + if (width ) *width = w; + if (height) *height = h; + if (xoff ) *xoff = ix0; + if (yoff ) *yoff = iy0; + + // invert for y-downwards bitmaps + scale_y = -scale_y; + + { + int x,y,i,j; + float *precompute; + stbtt_vertex *verts; + int num_verts = stbtt_GetGlyphShape(info, glyph, &verts); + data = (unsigned char *) STBTT_malloc(w * h, info->userdata); + precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata); + + for (i=0,j=num_verts-1; i < num_verts; j=i++) { + if (verts[i].type == STBTT_vline) { + float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; + float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y; + float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); + precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist; + } else if (verts[i].type == STBTT_vcurve) { + float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y; + float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y; + float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y; + float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; + float len2 = bx*bx + by*by; + if (len2 != 0.0f) + precompute[i] = 1.0f / (bx*bx + by*by); + else + precompute[i] = 0.0f; + } else + precompute[i] = 0.0f; + } + + for (y=iy0; y < iy1; ++y) { + for (x=ix0; x < ix1; ++x) { + float val; + float min_dist = 999999.0f; + float sx = (float) x + 0.5f; + float sy = (float) y + 0.5f; + float x_gspace = (sx / scale_x); + float y_gspace = (sy / scale_y); + + int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path + + for (i=0; i < num_verts; ++i) { + float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; + + // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve + float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); + if (dist2 < min_dist*min_dist) + min_dist = (float) STBTT_sqrt(dist2); + + if (verts[i].type == STBTT_vline) { + float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y; + + // coarse culling against bbox + //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && + // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) + float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i]; + STBTT_assert(i != 0); + if (dist < min_dist) { + // check position along line + // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0) + // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy) + float dx = x1-x0, dy = y1-y0; + float px = x0-sx, py = y0-sy; + // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy + // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve + float t = -(px*dx + py*dy) / (dx*dx + dy*dy); + if (t >= 0.0f && t <= 1.0f) + min_dist = dist; + } + } else if (verts[i].type == STBTT_vcurve) { + float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y; + float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y; + float box_x0 = STBTT_min(STBTT_min(x0,x1),x2); + float box_y0 = STBTT_min(STBTT_min(y0,y1),y2); + float box_x1 = STBTT_max(STBTT_max(x0,x1),x2); + float box_y1 = STBTT_max(STBTT_max(y0,y1),y2); + // coarse culling against bbox to avoid computing cubic unnecessarily + if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) { + int num=0; + float ax = x1-x0, ay = y1-y0; + float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; + float mx = x0 - sx, my = y0 - sy; + float res[3],px,py,t,it; + float a_inv = precompute[i]; + if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula + float a = 3*(ax*bx + ay*by); + float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by); + float c = mx*ax+my*ay; + if (a == 0.0) { // if a is 0, it's linear + if (b != 0.0) { + res[num++] = -c/b; + } + } else { + float discriminant = b*b - 4*a*c; + if (discriminant < 0) + num = 0; + else { + float root = (float) STBTT_sqrt(discriminant); + res[0] = (-b - root)/(2*a); + res[1] = (-b + root)/(2*a); + num = 2; // don't bother distinguishing 1-solution case, as code below will still work + } + } + } else { + float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point + float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv; + float d = (mx*ax+my*ay) * a_inv; + num = stbtt__solve_cubic(b, c, d, res); + } + if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) { + t = res[0], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) { + t = res[1], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) { + t = res[2], it = 1.0f - t; + px = it*it*x0 + 2*t*it*x1 + t*t*x2; + py = it*it*y0 + 2*t*it*y1 + t*t*y2; + dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); + if (dist2 < min_dist * min_dist) + min_dist = (float) STBTT_sqrt(dist2); + } + } + } + } + if (winding == 0) + min_dist = -min_dist; // if outside the shape, value is negative + val = onedge_value + pixel_dist_scale * min_dist; + if (val < 0) + val = 0; + else if (val > 255) + val = 255; + data[(y-iy0)*w+(x-ix0)] = (unsigned char) val; + } + } + STBTT_free(precompute, info->userdata); + STBTT_free(verts, info->userdata); + } + return data; +} + +STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) +{ + return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff); +} + +STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata) +{ + STBTT_free(bitmap, userdata); +} ////////////////////////////////////////////////////////////////////////////// // @@ -3060,7 +4271,7 @@ STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, i // // check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string -static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 *s1, stbtt_int32 len1, const stbtt_uint8 *s2, stbtt_int32 len2) +static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) { stbtt_int32 i=0; @@ -3099,9 +4310,9 @@ static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 return i; } -STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2) { - return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((const stbtt_uint8*) s1, len1, (const stbtt_uint8*) s2, len2); + return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2); } // returns results in whatever encoding you request... but note that 2-byte encodings @@ -3157,7 +4368,7 @@ static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, return 1; } else if (matchlen < nlen && name[matchlen] == ' ') { ++matchlen; - if (stbtt_CompareUTF8toUTF16_bigendian((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) + if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) return 1; } } else { @@ -3203,7 +4414,7 @@ static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *nam return 0; } -STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const char *name_utf8, stbtt_int32 flags) +static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags) { stbtt_int32 i; for (i=0;;++i) { @@ -3214,11 +4425,57 @@ STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const } } +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" +#endif + +STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, + float pixel_height, unsigned char *pixels, int pw, int ph, + int first_char, int num_chars, stbtt_bakedchar *chardata) +{ + return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); +} + +STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index) +{ + return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index); +} + +STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data) +{ + return stbtt_GetNumberOfFonts_internal((unsigned char *) data); +} + +STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset) +{ + return stbtt_InitFont_internal(info, (unsigned char *) data, offset); +} + +STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags) +{ + return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags); +} + +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +{ + return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + #endif // STB_TRUETYPE_IMPLEMENTATION // FULL VERSION HISTORY // +// 1.16 (2017-07-12) SDF support +// 1.15 (2017-03-03) make more arguments const +// 1.14 (2017-01-16) num-fonts-in-TTC function +// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts +// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual // 1.11 (2016-04-02) fix unused-variable warning // 1.10 (2016-04-02) allow user-defined fabs() replacement // fix memory leak if fontsize=0.0 @@ -3265,3 +4522,45 @@ STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const // 0.2 (2009-03-11) Fix unsigned/signed char warnings // 0.1 (2009-03-09) First public release // + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +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. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +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 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. +------------------------------------------------------------------------------ +*/ diff --git a/thirdparty/misc/stb_vorbis.c b/thirdparty/misc/stb_vorbis.c index c4f24d5898..14cebbf87e 100644 --- a/thirdparty/misc/stb_vorbis.c +++ b/thirdparty/misc/stb_vorbis.c @@ -1,4 +1,4 @@ -// Ogg Vorbis audio decoder - v1.09 - public domain +// Ogg Vorbis audio decoder - v1.11 - public domain // http://nothings.org/stb_vorbis/ // // Original version written by Sean Barrett in 2007. @@ -9,12 +9,7 @@ // // LICENSE // -// This software is dual-licensed to the public domain and under the following -// license: you are granted a perpetual, irrevocable license to copy, modify, -// publish, and distribute this file as you see fit. -// -// No warranty for any purpose is expressed or implied by the author (nor -// by RAD Game Tools). Report bugs and send enhancements to the author. +// See end of file for license information. // // Limitations: // @@ -34,9 +29,11 @@ // Bernhard Wodo Evan Balster alxprd@github // Tom Beaumont Ingo Leitgeb Nicolas Guillemot // Phillip Bennefall Rohit Thiago Goulart -// manxorist@github saga musix +// manxorist@github saga musix github:infatum // // Partial history: +// 1.11 - 2017/07/23 - fix MinGW compilation +// 1.10 - 2017/03/03 - more robust seeking; fix negative ilog(); clear error in open_memory // 1.09 - 2016/04/04 - back out 'truncation of last frame' fix from previous version // 1.08 - 2016/04/02 - warnings; setup memory leaks; truncation of last frame // 1.07 - 2015/01/16 - fixes for crashes on invalid files; warning fixes; const @@ -275,7 +272,7 @@ extern int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number); // do not need to seek to EXACTLY the target sample when using get_samples_*, // you can also use seek_frame(). -extern void stb_vorbis_seek_start(stb_vorbis *f); +extern int stb_vorbis_seek_start(stb_vorbis *f); // this function is equivalent to stb_vorbis_seek(f,0) extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f); @@ -555,7 +552,7 @@ enum STBVorbisError #include <math.h> // find definition of alloca if it's not in stdlib.h: - #ifdef _MSC_VER + #if defined(_MSC_VER) || defined(__MINGW32__) #include <malloc.h> #endif #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) @@ -580,6 +577,7 @@ enum STBVorbisError #undef __forceinline #endif #define __forceinline + #define alloca __builtin_alloca #elif !defined(_MSC_VER) #if __GNUC__ #define __forceinline inline @@ -986,17 +984,18 @@ static int ilog(int32 n) { static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 }; + if (n < 0) return 0; // signed n returns 0 + // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29) if (n < (1 << 14)) - if (n < (1 << 4)) return 0 + log2_4[n ]; - else if (n < (1 << 9)) return 5 + log2_4[n >> 5]; + if (n < (1 << 4)) return 0 + log2_4[n ]; + else if (n < (1 << 9)) return 5 + log2_4[n >> 5]; else return 10 + log2_4[n >> 10]; else if (n < (1 << 24)) - if (n < (1 << 19)) return 15 + log2_4[n >> 15]; + if (n < (1 << 19)) return 15 + log2_4[n >> 15]; else return 20 + log2_4[n >> 20]; - else if (n < (1 << 29)) return 25 + log2_4[n >> 25]; - else if (n < (1 << 31)) return 30 + log2_4[n >> 30]; - else return 0; // signed n returns 0 + else if (n < (1 << 29)) return 25 + log2_4[n >> 25]; + else return 30 + log2_4[n >> 30]; } #ifndef M_PI @@ -1269,13 +1268,13 @@ static void neighbors(uint16 *x, int n, int *plow, int *phigh) // this has been repurposed so y is now the original index instead of y typedef struct { - uint16 x,y; -} Point; + uint16 x,id; +} stbv__floor_ordering; static int STBV_CDECL point_compare(const void *p, const void *q) { - Point *a = (Point *) p; - Point *b = (Point *) q; + stbv__floor_ordering *a = (stbv__floor_ordering *) p; + stbv__floor_ordering *b = (stbv__floor_ordering *) q; return a->x < b->x ? -1 : a->x > b->x; } @@ -3484,11 +3483,13 @@ static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) return right - left; } -static void vorbis_pump_first_frame(stb_vorbis *f) +static int vorbis_pump_first_frame(stb_vorbis *f) { - int len, right, left; - if (vorbis_decode_packet(f, &len, &left, &right)) + int len, right, left, res; + res = vorbis_decode_packet(f, &len, &left, &right); + if (res) vorbis_finish_frame(f, len, left, right); + return res; } #ifndef STB_VORBIS_NO_PUSHDATA_API @@ -3871,7 +3872,7 @@ static int start_decoder(vorb *f) g->book_list[j] = get_bits(f,8); return error(f, VORBIS_feature_not_supported); } else { - Point p[31*8+2]; + stbv__floor_ordering p[31*8+2]; Floor1 *g = &f->floor_config[i].floor1; int max_class = -1; g->partitions = get_bits(f, 5); @@ -3907,11 +3908,11 @@ static int start_decoder(vorb *f) // precompute the sorting for (j=0; j < g->values; ++j) { p[j].x = g->Xlist[j]; - p[j].y = j; + p[j].id = j; } qsort(p, g->values, sizeof(p[0]), point_compare); for (j=0; j < g->values; ++j) - g->sorted_order[j] = (uint8) p[j].y; + g->sorted_order[j] = (uint8) p[j].id; // precompute the neighbors for (j=2; j < g->values; ++j) { int low,hi; @@ -4615,8 +4616,9 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) // starting from the start is handled differently if (sample_number <= left.last_decoded_sample) { - stb_vorbis_seek_start(f); - return 1; + if (stb_vorbis_seek_start(f)) + return 1; + return 0; } while (left.page_end != right.page_start) { @@ -4717,7 +4719,10 @@ static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) skip(f, f->segments[i]); // start decoding (optimizable - this frame is generally discarded) - vorbis_pump_first_frame(f); + if (!vorbis_pump_first_frame(f)) + return 0; + if (f->current_loc > sample_number) + return error(f, VORBIS_seek_failed); return 1; error: @@ -4808,14 +4813,14 @@ int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number) return 1; } -void stb_vorbis_seek_start(stb_vorbis *f) +int stb_vorbis_seek_start(stb_vorbis *f) { - if (IS_PUSH_MODE(f)) { error(f, VORBIS_invalid_api_mixing); return; } + if (IS_PUSH_MODE(f)) { return error(f, VORBIS_invalid_api_mixing); } set_file_offset(f, f->first_audio_page_offset); f->previous_length = 0; f->first_decode = TRUE; f->next_seg = -1; - vorbis_pump_first_frame(f); + return vorbis_pump_first_frame(f); } unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) @@ -4980,6 +4985,7 @@ stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *err if (f) { *f = p; vorbis_pump_first_frame(f); + if (error) *error = VORBIS__no_error; return f; } } @@ -5345,6 +5351,7 @@ int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, in #endif // STB_VORBIS_NO_PULLDATA_API /* Version history + 1.10 - 2017/03/03 - more robust seeking; fix negative ilog(); clear error in open_memory 1.09 - 2016/04/04 - back out 'avoid discarding last frame' fix from previous version 1.08 - 2016/04/02 - fixed multiple warnings; fix setup memory leaks; avoid discarding last frame of audio data @@ -5397,3 +5404,46 @@ int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, in */ #endif // STB_VORBIS_HEADER_ONLY + + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +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. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +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 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. +------------------------------------------------------------------------------ +*/ diff --git a/thirdparty/nanosvg/README.md b/thirdparty/nanosvg/README.md deleted file mode 100644 index 919a1ec5e8..0000000000 --- a/thirdparty/nanosvg/README.md +++ /dev/null @@ -1,2 +0,0 @@ -See: -https://github.com/memononen/nanosvg diff --git a/thirdparty/nanosvg/src/nanosvg.cc b/thirdparty/nanosvg/nanosvg.cc index 3e8e86c792..3e8e86c792 100644 --- a/thirdparty/nanosvg/src/nanosvg.cc +++ b/thirdparty/nanosvg/nanosvg.cc diff --git a/thirdparty/nanosvg/src/nanosvg.h b/thirdparty/nanosvg/nanosvg.h index 2321c56fd2..2321c56fd2 100644 --- a/thirdparty/nanosvg/src/nanosvg.h +++ b/thirdparty/nanosvg/nanosvg.h diff --git a/thirdparty/nanosvg/src/nanosvgrast.h b/thirdparty/nanosvg/nanosvgrast.h index 2940c1f916..2940c1f916 100644 --- a/thirdparty/nanosvg/src/nanosvgrast.h +++ b/thirdparty/nanosvg/nanosvgrast.h diff --git a/thirdparty/zstd/PATENTS b/thirdparty/zstd/PATENTS deleted file mode 100644 index 15b4a2ea5c..0000000000 --- a/thirdparty/zstd/PATENTS +++ /dev/null @@ -1,33 +0,0 @@ -Additional Grant of Patent Rights Version 2 - -"Software" means the Zstandard software distributed by Facebook, Inc. - -Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software -("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable -(subject to the termination provision below) license under any Necessary -Claims, to make, have made, use, sell, offer to sell, import, and otherwise -transfer the Software. For avoidance of doubt, no license is granted under -Facebook’s rights in any patent claims that are infringed by (i) modifications -to the Software made by you or any third party or (ii) the Software in -combination with any software or other technology. - -The license granted hereunder will terminate, automatically and without notice, -if you (or any of your subsidiaries, corporate affiliates or agents) initiate -directly or indirectly, or take a direct financial interest in, any Patent -Assertion: (i) against Facebook or any of its subsidiaries or corporate -affiliates, (ii) against any party if such Patent Assertion arises in whole or -in part from any software, technology, product or service of Facebook or any of -its subsidiaries or corporate affiliates, or (iii) against any party relating -to the Software. Notwithstanding the foregoing, if Facebook or any of its -subsidiaries or corporate affiliates files a lawsuit alleging patent -infringement against you in the first instance, and you respond by filing a -patent infringement counterclaim in that lawsuit against that party that is -unrelated to the Software, the license granted hereunder will not terminate -under section (i) of this paragraph due to such counterclaim. - -A "Necessary Claim" is a claim of a patent owned by Facebook that is -necessarily infringed by the Software standing alone. - -A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, -or contributory infringement or inducement to infringe any patent, including a -cross-claim or counterclaim. diff --git a/thirdparty/zstd/README.md b/thirdparty/zstd/README.md deleted file mode 100644 index f37be4542c..0000000000 --- a/thirdparty/zstd/README.md +++ /dev/null @@ -1,153 +0,0 @@ - __Zstandard__, or `zstd` as short version, is a fast lossless compression algorithm, - targeting real-time compression scenarios at zlib-level and better compression ratios. - -It is provided as an open-source BSD-licensed **C** library, -and a command line utility producing and decoding `.zst` and `.gz` files. -For other programming languages, -you can consult a list of known ports on [Zstandard homepage](http://www.zstd.net/#other-languages). - -| dev branch status | -|-------------------| -| [![Build Status][travisDevBadge]][travisLink] [![Build status][AppveyorDevBadge]][AppveyorLink] [![Build status][CircleDevBadge]][CircleLink] - -[travisDevBadge]: https://travis-ci.org/facebook/zstd.svg?branch=dev "Continuous Integration test suite" -[travisLink]: https://travis-ci.org/facebook/zstd -[AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/xt38wbdxjk5mrbem/branch/dev?svg=true "Windows test suite" -[AppveyorLink]: https://ci.appveyor.com/project/YannCollet/zstd-p0yf0 -[CircleDevBadge]: https://circleci.com/gh/facebook/zstd/tree/dev.svg?style=shield "Short test suite" -[CircleLink]: https://circleci.com/gh/facebook/zstd - - -As a reference, several fast compression algorithms were tested and compared -on a server running Linux Debian (`Linux version 4.8.0-1-amd64`), -with a Core i7-6700K CPU @ 4.0GHz, -using [lzbench], an open-source in-memory benchmark by @inikep -compiled with GCC 6.3.0, -on the [Silesia compression corpus]. - -[lzbench]: https://github.com/inikep/lzbench -[Silesia compression corpus]: http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia - -| Compressor name | Ratio | Compression| Decompress.| -| --------------- | ------| -----------| ---------- | -| **zstd 1.1.3 -1** | 2.877 | 430 MB/s | 1110 MB/s | -| zlib 1.2.8 -1 | 2.743 | 110 MB/s | 400 MB/s | -| brotli 0.5.2 -0 | 2.708 | 400 MB/s | 430 MB/s | -| quicklz 1.5.0 -1 | 2.238 | 550 MB/s | 710 MB/s | -| lzo1x 2.09 -1 | 2.108 | 650 MB/s | 830 MB/s | -| lz4 1.7.5 | 2.101 | 720 MB/s | 3600 MB/s | -| snappy 1.1.3 | 2.091 | 500 MB/s | 1650 MB/s | -| lzf 3.6 -1 | 2.077 | 400 MB/s | 860 MB/s | - -[zlib]:http://www.zlib.net/ -[LZ4]: http://www.lz4.org/ - -Zstd can also offer stronger compression ratios at the cost of compression speed. -Speed vs Compression trade-off is configurable by small increments. Decompression speed is preserved and remains roughly the same at all settings, a property shared by most LZ compression algorithms, such as [zlib] or lzma. - -The following tests were run -on a server running Linux Debian (`Linux version 4.8.0-1-amd64`) -with a Core i7-6700K CPU @ 4.0GHz, -using [lzbench], an open-source in-memory benchmark by @inikep -compiled with GCC 6.3.0, -on the [Silesia compression corpus]. - -Compression Speed vs Ratio | Decompression Speed ----------------------------|-------------------- - |  - -Several algorithms can produce higher compression ratios, but at slower speeds, falling outside of the graph. -For a larger picture including very slow modes, [click on this link](doc/images/DCspeed5.png) . - - -### The case for Small Data compression - -Previous charts provide results applicable to typical file and stream scenarios (several MB). Small data comes with different perspectives. - -The smaller the amount of data to compress, the more difficult it is to compress. This problem is common to all compression algorithms, and reason is, compression algorithms learn from past data how to compress future data. But at the beginning of a new data set, there is no "past" to build upon. - -To solve this situation, Zstd offers a __training mode__, which can be used to tune the algorithm for a selected type of data. -Training Zstandard is achieved by providing it with a few samples (one file per sample). The result of this training is stored in a file called "dictionary", which must be loaded before compression and decompression. -Using this dictionary, the compression ratio achievable on small data improves dramatically. - -The following example uses the `github-users` [sample set](https://github.com/facebook/zstd/releases/tag/v1.1.3), created from [github public API](https://developer.github.com/v3/users/#get-all-users). -It consists of roughly 10K records weighing about 1KB each. - -Compression Ratio | Compression Speed | Decompression Speed -------------------|-------------------|-------------------- - |  |  - - -These compression gains are achieved while simultaneously providing _faster_ compression and decompression speeds. - -Training works if there is some correlation in a family of small data samples. The more data-specific a dictionary is, the more efficient it is (there is no _universal dictionary_). -Hence, deploying one dictionary per type of data will provide the greatest benefits. -Dictionary gains are mostly effective in the first few KB. Then, the compression algorithm will gradually use previously decoded content to better compress the rest of the file. - -#### Dictionary compression How To : - -1) Create the dictionary - -`zstd --train FullPathToTrainingSet/* -o dictionaryName` - -2) Compress with dictionary - -`zstd -D dictionaryName FILE` - -3) Decompress with dictionary - -`zstd -D dictionaryName --decompress FILE.zst` - - -### Build - -Once you have the repository cloned, there are multiple ways provided to build Zstandard. - -#### Makefile - -If your system is compatible with a standard `make` (or `gmake`) binary generator, -you can simply run it at the root directory. -It will generate `zstd` within root directory. - -Other available options include : -- `make install` : create and install zstd binary, library and man page -- `make test` : create and run `zstd` and test tools on local platform - -#### cmake - -A `cmake` project generator is provided within `build/cmake`. -It can generate Makefiles or other build scripts -to create `zstd` binary, and `libzstd` dynamic and static libraries. - -#### Meson - -A Meson project is provided within `contrib/meson`. - -#### Visual Studio (Windows) - -Going into `build` directory, you will find additional possibilities : -- Projects for Visual Studio 2005, 2008 and 2010 - + VS2010 project is compatible with VS2012, VS2013 and VS2015 -- Automated build scripts for Visual compiler by @KrzysFR , in `build/VS_scripts`, - which will build `zstd` cli and `libzstd` library without any need to open Visual Studio solution. - - -### Status - -Zstandard is currently deployed within Facebook. It is used daily to compress and decompress very large amounts of data in multiple formats and use cases. -Zstandard is considered safe for production environments. - -### License - -Zstandard is [BSD-licensed](LICENSE). We also provide an [additional patent grant](PATENTS). - -### Contributing - -The "dev" branch is the one where all contributions will be merged before reaching "master". -If you plan to propose a patch, please commit into the "dev" branch or its own feature branch. -Direct commit to "master" are not permitted. -For more information, please read [CONTRIBUTING](CONTRIBUTING.md). - -### Miscellaneous - -Zstd entropy stage is provided by [Huff0 and FSE, from Finite State Entropy library](https://github.com/Cyan4973/FiniteStateEntropy). diff --git a/thirdparty/zstd/common/bitstream.h b/thirdparty/zstd/common/bitstream.h index 07b85026c9..06121f21c5 100644 --- a/thirdparty/zstd/common/bitstream.h +++ b/thirdparty/zstd/common/bitstream.h @@ -80,9 +80,9 @@ extern "C" { * bitStream encoding API (write forward) ********************************************/ /* bitStream can mix input from multiple sources. -* A critical property of these streams is that they encode and decode in **reverse** direction. -* So the first bit sequence you add will be the last to be read, like a LIFO stack. -*/ + * A critical property of these streams is that they encode and decode in **reverse** direction. + * So the first bit sequence you add will be the last to be read, like a LIFO stack. + */ typedef struct { size_t bitContainer; @@ -203,7 +203,7 @@ static const unsigned BIT_mask[] = { 0, 1, 3, 7, 0xF, 0x1F, 0x3F, 0x7F, /*! BIT_initCStream() : * `dstCapacity` must be > sizeof(size_t) * @return : 0 if success, - otherwise an error code (can be tested using ERR_isError() ) */ + * otherwise an error code (can be tested using ERR_isError()) */ MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, void* startPtr, size_t dstCapacity) { @@ -217,8 +217,8 @@ MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, } /*! BIT_addBits() : - can add up to 26 bits into `bitC`. - Does not check for register overflow ! */ + * can add up to 26 bits into `bitC`. + * Note : does not check for register overflow ! */ MEM_STATIC void BIT_addBits(BIT_CStream_t* bitC, size_t value, unsigned nbBits) { @@ -268,7 +268,7 @@ MEM_STATIC void BIT_flushBits(BIT_CStream_t* bitC) /*! BIT_closeCStream() : * @return : size of CStream, in bytes, - or 0 if it could not fit into dstBuffer */ + * or 0 if it could not fit into dstBuffer */ MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC) { BIT_addBitsFast(bitC, 1, 1); /* endMark */ @@ -279,14 +279,14 @@ MEM_STATIC size_t BIT_closeCStream(BIT_CStream_t* bitC) /*-******************************************************** -* bitStream decoding +* bitStream decoding **********************************************************/ /*! BIT_initDStream() : -* Initialize a BIT_DStream_t. -* `bitD` : a pointer to an already allocated BIT_DStream_t structure. -* `srcSize` must be the *exact* size of the bitStream, in bytes. -* @return : size of stream (== srcSize) or an errorCode if a problem is detected -*/ + * Initialize a BIT_DStream_t. + * `bitD` : a pointer to an already allocated BIT_DStream_t structure. + * `srcSize` must be the *exact* size of the bitStream, in bytes. + * @return : size of stream (== srcSize), or an errorCode if a problem is detected + */ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, size_t srcSize) { if (srcSize < 1) { memset(bitD, 0, sizeof(*bitD)); return ERROR(srcSize_wrong); } @@ -305,29 +305,30 @@ MEM_STATIC size_t BIT_initDStream(BIT_DStream_t* bitD, const void* srcBuffer, si bitD->bitContainer = *(const BYTE*)(bitD->start); switch(srcSize) { - case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16); - /* fall-through */ + case 7: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[6]) << (sizeof(bitD->bitContainer)*8 - 16); + /* fall-through */ - case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24); - /* fall-through */ + case 6: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[5]) << (sizeof(bitD->bitContainer)*8 - 24); + /* fall-through */ - case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32); - /* fall-through */ + case 5: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[4]) << (sizeof(bitD->bitContainer)*8 - 32); + /* fall-through */ - case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24; - /* fall-through */ + case 4: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[3]) << 24; + /* fall-through */ - case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16; - /* fall-through */ + case 3: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[2]) << 16; + /* fall-through */ - case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8; - /* fall-through */ + case 2: bitD->bitContainer += (size_t)(((const BYTE*)(srcBuffer))[1]) << 8; + /* fall-through */ - default: break; + default: break; + } + { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1]; + bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; + if (lastByte == 0) return ERROR(corruption_detected); /* endMark not present */ } - { BYTE const lastByte = ((const BYTE*)srcBuffer)[srcSize-1]; - bitD->bitsConsumed = lastByte ? 8 - BIT_highbit32(lastByte) : 0; - if (lastByte == 0) return ERROR(GENERIC); /* endMark not present */ } bitD->bitsConsumed += (U32)(sizeof(bitD->bitContainer) - srcSize)*8; } @@ -363,9 +364,8 @@ MEM_STATIC size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits) * local register is not modified. * On 32-bits, maxNbBits==24. * On 64-bits, maxNbBits==56. - * @return : value extracted - */ - MEM_STATIC size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits) + * @return : value extracted */ +MEM_STATIC size_t BIT_lookBits(const BIT_DStream_t* bitD, U32 nbBits) { #if defined(__BMI__) && defined(__GNUC__) /* experimental; fails if bitD->bitsConsumed + nbBits > sizeof(bitD->bitContainer)*8 */ return BIT_getMiddleBits(bitD->bitContainer, (sizeof(bitD->bitContainer)*8) - bitD->bitsConsumed - nbBits, nbBits); @@ -392,8 +392,7 @@ MEM_STATIC void BIT_skipBits(BIT_DStream_t* bitD, U32 nbBits) /*! BIT_readBits() : * Read (consume) next n bits from local register and update. * Pay attention to not read more than nbBits contained into local register. - * @return : extracted value. - */ + * @return : extracted value. */ MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits) { size_t const value = BIT_lookBits(bitD, nbBits); @@ -402,7 +401,7 @@ MEM_STATIC size_t BIT_readBits(BIT_DStream_t* bitD, U32 nbBits) } /*! BIT_readBitsFast() : -* unsafe version; only works only if nbBits >= 1 */ + * unsafe version; only works only if nbBits >= 1 */ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits) { size_t const value = BIT_lookBitsFast(bitD, nbBits); @@ -412,10 +411,10 @@ MEM_STATIC size_t BIT_readBitsFast(BIT_DStream_t* bitD, U32 nbBits) } /*! BIT_reloadDStream() : -* Refill `bitD` from buffer previously set in BIT_initDStream() . -* This function is safe, it guarantees it will not read beyond src buffer. -* @return : status of `BIT_DStream_t` internal register. - if status == BIT_DStream_unfinished, internal register is filled with >= (sizeof(bitD->bitContainer)*8 - 7) bits */ + * Refill `bitD` from buffer previously set in BIT_initDStream() . + * This function is safe, it guarantees it will not read beyond src buffer. + * @return : status of `BIT_DStream_t` internal register. + * when status == BIT_DStream_unfinished, internal register is filled with at least 25 or 57 bits */ MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD) { if (bitD->bitsConsumed > (sizeof(bitD->bitContainer)*8)) /* overflow detected, like end of stream */ @@ -446,8 +445,8 @@ MEM_STATIC BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD) } /*! BIT_endOfDStream() : -* @return Tells if DStream has exactly reached its end (all bits consumed). -*/ + * @return : 1 if DStream has _exactly_ reached its end (all bits consumed). + */ MEM_STATIC unsigned BIT_endOfDStream(const BIT_DStream_t* DStream) { return ((DStream->ptr == DStream->start) && (DStream->bitsConsumed == sizeof(DStream->bitContainer)*8)); diff --git a/thirdparty/zstd/common/compiler.h b/thirdparty/zstd/common/compiler.h new file mode 100644 index 0000000000..d7225c443e --- /dev/null +++ b/thirdparty/zstd/common/compiler.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). + */ + +#ifndef ZSTD_COMPILER_H +#define ZSTD_COMPILER_H + +/*-******************************************************* +* Compiler specifics +*********************************************************/ +/* force inlining */ +#if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# define INLINE_KEYWORD inline +#else +# define INLINE_KEYWORD +#endif + +#if defined(__GNUC__) +# define FORCE_INLINE_ATTR __attribute__((always_inline)) +#elif defined(_MSC_VER) +# define FORCE_INLINE_ATTR __forceinline +#else +# define FORCE_INLINE_ATTR +#endif + +/** + * FORCE_INLINE_TEMPLATE is used to define C "templates", which take constant + * parameters. They must be inlined for the compiler to elimininate the constant + * branches. + */ +#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR +/** + * HINT_INLINE is used to help the compiler generate better code. It is *not* + * used for "templates", so it can be tweaked based on the compilers + * performance. + * + * gcc-4.8 and gcc-4.9 have been shown to benefit from leaving off the + * always_inline attribute. + * + * clang up to 5.0.0 (trunk) benefit tremendously from the always_inline + * attribute. + */ +#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8 && __GNUC__ < 5 +# define HINT_INLINE static INLINE_KEYWORD +#else +# define HINT_INLINE static INLINE_KEYWORD FORCE_INLINE_ATTR +#endif + +/* force no inlining */ +#ifdef _MSC_VER +# define FORCE_NOINLINE static __declspec(noinline) +#else +# ifdef __GNUC__ +# define FORCE_NOINLINE static __attribute__((__noinline__)) +# else +# define FORCE_NOINLINE static +# endif +#endif + +/* prefetch */ +#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */ +# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ +# define PREFETCH(ptr) _mm_prefetch((const char*)ptr, _MM_HINT_T0) +#elif defined(__GNUC__) +# define PREFETCH(ptr) __builtin_prefetch(ptr, 0, 0) +#else +# define PREFETCH(ptr) /* disabled */ +#endif + +/* disable warnings */ +#ifdef _MSC_VER /* Visual Studio */ +# include <intrin.h> /* For Visual 2005 */ +# pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */ +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ +# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */ +# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */ +# pragma warning(disable : 4324) /* disable: C4324: padded structure */ +#endif + +#endif /* ZSTD_COMPILER_H */ diff --git a/thirdparty/zstd/common/error_private.c b/thirdparty/zstd/common/error_private.c index 2d752cd23a..b5b14b509c 100644 --- a/thirdparty/zstd/common/error_private.c +++ b/thirdparty/zstd/common/error_private.c @@ -1,10 +1,10 @@ -/** +/* * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ /* The purpose of this file is to have a single list of error strings embedded in binary */ @@ -20,19 +20,17 @@ const char* ERR_getErrorString(ERR_enum code) case PREFIX(GENERIC): return "Error (generic)"; case PREFIX(prefix_unknown): return "Unknown frame descriptor"; case PREFIX(version_unsupported): return "Version not supported"; - case PREFIX(parameter_unknown): return "Unknown parameter type"; case PREFIX(frameParameter_unsupported): return "Unsupported frame parameter"; - case PREFIX(frameParameter_unsupportedBy32bits): return "Frame parameter unsupported in 32-bits mode"; case PREFIX(frameParameter_windowTooLarge): return "Frame requires too much memory for decoding"; - case PREFIX(compressionParameter_unsupported): return "Compression parameter is not supported"; - case PREFIX(compressionParameter_outOfBound): return "Compression parameter is out of bound"; + case PREFIX(corruption_detected): return "Corrupted block detected"; + case PREFIX(checksum_wrong): return "Restored data doesn't match checksum"; + case PREFIX(parameter_unsupported): return "Unsupported parameter"; + case PREFIX(parameter_outOfBound): return "Parameter is out of bound"; case PREFIX(init_missing): return "Context should be init first"; case PREFIX(memory_allocation): return "Allocation error : not enough memory"; case PREFIX(stage_wrong): return "Operation not authorized at current processing stage"; case PREFIX(dstSize_tooSmall): return "Destination buffer is too small"; case PREFIX(srcSize_wrong): return "Src size is incorrect"; - case PREFIX(corruption_detected): return "Corrupted block detected"; - case PREFIX(checksum_wrong): return "Restored data doesn't match checksum"; case PREFIX(tableLog_tooLarge): return "tableLog requires too much memory : unsupported"; case PREFIX(maxSymbolValue_tooLarge): return "Unsupported max Symbol Value : too large"; case PREFIX(maxSymbolValue_tooSmall): return "Specified maxSymbolValue is too small"; diff --git a/thirdparty/zstd/common/error_private.h b/thirdparty/zstd/common/error_private.h index 1bc2e49548..9dd9a87cfa 100644 --- a/thirdparty/zstd/common/error_private.h +++ b/thirdparty/zstd/common/error_private.h @@ -1,10 +1,10 @@ -/** +/* * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ /* Note : this module is expected to remain private, do not expose it */ diff --git a/thirdparty/zstd/common/fse.h b/thirdparty/zstd/common/fse.h index 6d5d41def1..1c44f83750 100644 --- a/thirdparty/zstd/common/fse.h +++ b/thirdparty/zstd/common/fse.h @@ -31,13 +31,14 @@ You can contact the author at : - Source repository : https://github.com/Cyan4973/FiniteStateEntropy ****************************************************************** */ -#ifndef FSE_H -#define FSE_H #if defined (__cplusplus) extern "C" { #endif +#ifndef FSE_H +#define FSE_H + /*-***************************************** * Dependencies @@ -297,8 +298,10 @@ FSE_decompress_usingDTable() result will tell how many bytes were regenerated (< If there is an error, the function will return an error code, which can be tested using FSE_isError(). (ex: dst buffer too small) */ +#endif /* FSE_H */ -#ifdef FSE_STATIC_LINKING_ONLY +#if defined(FSE_STATIC_LINKING_ONLY) && !defined(FSE_H_FSE_STATIC_LINKING_ONLY) +#define FSE_H_FSE_STATIC_LINKING_ONLY /* *** Dependency *** */ #include "bitstream.h" @@ -381,6 +384,11 @@ size_t FSE_buildDTable_rle (FSE_DTable* dt, unsigned char symbolValue); size_t FSE_decompress_wksp(void* dst, size_t dstCapacity, const void* cSrc, size_t cSrcSize, FSE_DTable* workSpace, unsigned maxLog); /**< same as FSE_decompress(), using an externally allocated `workSpace` produced with `FSE_DTABLE_SIZE_U32(maxLog)` */ +typedef enum { + FSE_repeat_none, /**< Cannot use the previous table */ + FSE_repeat_check, /**< Can use the previous table but it must be checked */ + FSE_repeat_valid /**< Can use the previous table and it is asumed to be valid */ + } FSE_repeat; /* ***************************************** * FSE symbol compression API @@ -694,5 +702,3 @@ MEM_STATIC unsigned FSE_endOfDState(const FSE_DState_t* DStatePtr) #if defined (__cplusplus) } #endif - -#endif /* FSE_H */ diff --git a/thirdparty/zstd/common/fse_decompress.c b/thirdparty/zstd/common/fse_decompress.c index 8474a4c079..8e3f0035f6 100644 --- a/thirdparty/zstd/common/fse_decompress.c +++ b/thirdparty/zstd/common/fse_decompress.c @@ -34,34 +34,15 @@ /* ************************************************************** -* Compiler specifics -****************************************************************/ -#ifdef _MSC_VER /* Visual Studio */ -# define FORCE_INLINE static __forceinline -# include <intrin.h> /* For Visual 2005 */ -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */ -#else -# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -# ifdef __GNUC__ -# define FORCE_INLINE static inline __attribute__((always_inline)) -# else -# define FORCE_INLINE static inline -# endif -# else -# define FORCE_INLINE static -# endif /* __STDC_VERSION__ */ -#endif - - -/* ************************************************************** * Includes ****************************************************************/ #include <stdlib.h> /* malloc, free, qsort */ #include <string.h> /* memcpy, memset */ #include "bitstream.h" +#include "compiler.h" #define FSE_STATIC_LINKING_ONLY #include "fse.h" +#include "error_private.h" /* ************************************************************** @@ -216,7 +197,7 @@ size_t FSE_buildDTable_raw (FSE_DTable* dt, unsigned nbBits) return 0; } -FORCE_INLINE size_t FSE_decompress_usingDTable_generic( +FORCE_INLINE_TEMPLATE size_t FSE_decompress_usingDTable_generic( void* dst, size_t maxDstSize, const void* cSrc, size_t cSrcSize, const FSE_DTable* dt, const unsigned fast) diff --git a/thirdparty/zstd/common/huf.h b/thirdparty/zstd/common/huf.h index dabd359915..2b3015a84c 100644 --- a/thirdparty/zstd/common/huf.h +++ b/thirdparty/zstd/common/huf.h @@ -31,13 +31,13 @@ You can contact the author at : - Source repository : https://github.com/Cyan4973/FiniteStateEntropy ****************************************************************** */ -#ifndef HUF_H_298734234 -#define HUF_H_298734234 #if defined (__cplusplus) extern "C" { #endif +#ifndef HUF_H_298734234 +#define HUF_H_298734234 /* *** Dependencies *** */ #include <stddef.h> /* size_t */ @@ -124,6 +124,7 @@ HUF_PUBLIC_API size_t HUF_compress4X_wksp (void* dst, size_t dstCapacity, const #define HUF_DECOMPRESS_WORKSPACE_SIZE (2 << 10) #define HUF_DECOMPRESS_WORKSPACE_SIZE_U32 (HUF_DECOMPRESS_WORKSPACE_SIZE / sizeof(U32)) +#endif /* HUF_H_298734234 */ /* ****************************************************************** * WARNING !! @@ -132,7 +133,8 @@ HUF_PUBLIC_API size_t HUF_compress4X_wksp (void* dst, size_t dstCapacity, const * because they are not guaranteed to remain stable in the future. * Only consider them in association with static linking. *******************************************************************/ -#ifdef HUF_STATIC_LINKING_ONLY +#if defined(HUF_STATIC_LINKING_ONLY) && !defined(HUF_H_HUF_STATIC_LINKING_ONLY) +#define HUF_H_HUF_STATIC_LINKING_ONLY /* *** Dependencies *** */ #include "mem.h" /* U32 */ @@ -295,9 +297,6 @@ size_t HUF_decompress1X4_usingDTable(void* dst, size_t maxDstSize, const void* c #endif /* HUF_STATIC_LINKING_ONLY */ - #if defined (__cplusplus) } #endif - -#endif /* HUF_H_298734234 */ diff --git a/thirdparty/zstd/common/mem.h b/thirdparty/zstd/common/mem.h index b0e5bf60b4..df85404fb8 100644 --- a/thirdparty/zstd/common/mem.h +++ b/thirdparty/zstd/common/mem.h @@ -1,10 +1,10 @@ -/** +/* * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ #ifndef MEM_H_MODULE @@ -110,7 +110,7 @@ Only use if no other choice to achieve best performance on target platform */ MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; } MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; } MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; } -MEM_STATIC U64 MEM_readST(const void* memPtr) { return *(const size_t*) memPtr; } +MEM_STATIC size_t MEM_readST(const void* memPtr) { return *(const size_t*) memPtr; } MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; } MEM_STATIC void MEM_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; } @@ -131,7 +131,7 @@ MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; } MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign*)ptr)->u16; } MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign*)ptr)->u32; } MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign*)ptr)->u64; } -MEM_STATIC U64 MEM_readST(const void* ptr) { return ((const unalign*)ptr)->st; } +MEM_STATIC size_t MEM_readST(const void* ptr) { return ((const unalign*)ptr)->st; } MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign*)memPtr)->u16 = value; } MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign*)memPtr)->u32 = value; } diff --git a/thirdparty/zstd/common/pool.c b/thirdparty/zstd/common/pool.c index 749fa4f2f7..a227044f7f 100644 --- a/thirdparty/zstd/common/pool.c +++ b/thirdparty/zstd/common/pool.c @@ -1,10 +1,10 @@ -/** - * Copyright (c) 2016-present, Facebook, Inc. +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ @@ -39,6 +39,12 @@ struct POOL_ctx_s { size_t queueHead; size_t queueTail; size_t queueSize; + + /* The number of threads working on jobs */ + size_t numThreadsBusy; + /* Indicates if the queue is empty */ + int queueEmpty; + /* The mutex protects the queue */ pthread_mutex_t queueMutex; /* Condition variable for pushers to wait on when the queue is full */ @@ -60,30 +66,41 @@ static void* POOL_thread(void* opaque) { for (;;) { /* Lock the mutex and wait for a non-empty queue or until shutdown */ pthread_mutex_lock(&ctx->queueMutex); - while (ctx->queueHead == ctx->queueTail && !ctx->shutdown) { + + while (ctx->queueEmpty && !ctx->shutdown) { pthread_cond_wait(&ctx->queuePopCond, &ctx->queueMutex); } /* empty => shutting down: so stop */ - if (ctx->queueHead == ctx->queueTail) { + if (ctx->queueEmpty) { pthread_mutex_unlock(&ctx->queueMutex); return opaque; } /* Pop a job off the queue */ { POOL_job const job = ctx->queue[ctx->queueHead]; ctx->queueHead = (ctx->queueHead + 1) % ctx->queueSize; + ctx->numThreadsBusy++; + ctx->queueEmpty = ctx->queueHead == ctx->queueTail; /* Unlock the mutex, signal a pusher, and run the job */ pthread_mutex_unlock(&ctx->queueMutex); pthread_cond_signal(&ctx->queuePushCond); + job.function(job.opaque); - } - } + + /* If the intended queue size was 0, signal after finishing job */ + if (ctx->queueSize == 1) { + pthread_mutex_lock(&ctx->queueMutex); + ctx->numThreadsBusy--; + pthread_mutex_unlock(&ctx->queueMutex); + pthread_cond_signal(&ctx->queuePushCond); + } } + } /* for (;;) */ /* Unreachable */ } POOL_ctx *POOL_create(size_t numThreads, size_t queueSize) { POOL_ctx *ctx; /* Check the parameters */ - if (!numThreads || !queueSize) { return NULL; } + if (!numThreads) { return NULL; } /* Allocate the context and zero initialize */ ctx = (POOL_ctx *)calloc(1, sizeof(POOL_ctx)); if (!ctx) { return NULL; } @@ -92,15 +109,17 @@ POOL_ctx *POOL_create(size_t numThreads, size_t queueSize) { * and full queues. */ ctx->queueSize = queueSize + 1; - ctx->queue = (POOL_job *)malloc(ctx->queueSize * sizeof(POOL_job)); + ctx->queue = (POOL_job*) malloc(ctx->queueSize * sizeof(POOL_job)); ctx->queueHead = 0; ctx->queueTail = 0; - pthread_mutex_init(&ctx->queueMutex, NULL); - pthread_cond_init(&ctx->queuePushCond, NULL); - pthread_cond_init(&ctx->queuePopCond, NULL); + ctx->numThreadsBusy = 0; + ctx->queueEmpty = 1; + (void)pthread_mutex_init(&ctx->queueMutex, NULL); + (void)pthread_cond_init(&ctx->queuePushCond, NULL); + (void)pthread_cond_init(&ctx->queuePopCond, NULL); ctx->shutdown = 0; /* Allocate space for the thread handles */ - ctx->threads = (pthread_t *)malloc(numThreads * sizeof(pthread_t)); + ctx->threads = (pthread_t*)malloc(numThreads * sizeof(pthread_t)); ctx->numThreads = 0; /* Check for errors */ if (!ctx->threads || !ctx->queue) { POOL_free(ctx); return NULL; } @@ -153,22 +172,37 @@ size_t POOL_sizeof(POOL_ctx *ctx) { + ctx->numThreads * sizeof(pthread_t); } -void POOL_add(void *ctxVoid, POOL_function function, void *opaque) { - POOL_ctx *ctx = (POOL_ctx *)ctxVoid; +/** + * Returns 1 if the queue is full and 0 otherwise. + * + * If the queueSize is 1 (the pool was created with an intended queueSize of 0), + * then a queue is empty if there is a thread free and no job is waiting. + */ +static int isQueueFull(POOL_ctx const* ctx) { + if (ctx->queueSize > 1) { + return ctx->queueHead == ((ctx->queueTail + 1) % ctx->queueSize); + } else { + return ctx->numThreadsBusy == ctx->numThreads || + !ctx->queueEmpty; + } +} + +void POOL_add(void* ctxVoid, POOL_function function, void *opaque) { + POOL_ctx* const ctx = (POOL_ctx*)ctxVoid; if (!ctx) { return; } pthread_mutex_lock(&ctx->queueMutex); { POOL_job const job = {function, opaque}; + /* Wait until there is space in the queue for the new job */ - size_t newTail = (ctx->queueTail + 1) % ctx->queueSize; - while (ctx->queueHead == newTail && !ctx->shutdown) { + while (isQueueFull(ctx) && !ctx->shutdown) { pthread_cond_wait(&ctx->queuePushCond, &ctx->queueMutex); - newTail = (ctx->queueTail + 1) % ctx->queueSize; } /* The queue is still going => there is space */ if (!ctx->shutdown) { + ctx->queueEmpty = 0; ctx->queue[ctx->queueTail] = job; - ctx->queueTail = newTail; + ctx->queueTail = (ctx->queueTail + 1) % ctx->queueSize; } } pthread_mutex_unlock(&ctx->queueMutex); @@ -183,22 +217,22 @@ struct POOL_ctx_s { int data; }; -POOL_ctx *POOL_create(size_t numThreads, size_t queueSize) { +POOL_ctx* POOL_create(size_t numThreads, size_t queueSize) { (void)numThreads; (void)queueSize; - return (POOL_ctx *)malloc(sizeof(POOL_ctx)); + return (POOL_ctx*)malloc(sizeof(POOL_ctx)); } -void POOL_free(POOL_ctx *ctx) { - if (ctx) free(ctx); +void POOL_free(POOL_ctx* ctx) { + free(ctx); } -void POOL_add(void *ctx, POOL_function function, void *opaque) { +void POOL_add(void* ctx, POOL_function function, void* opaque) { (void)ctx; function(opaque); } -size_t POOL_sizeof(POOL_ctx *ctx) { +size_t POOL_sizeof(POOL_ctx* ctx) { if (ctx==NULL) return 0; /* supports sizeof NULL */ return sizeof(*ctx); } diff --git a/thirdparty/zstd/common/pool.h b/thirdparty/zstd/common/pool.h index 386cd674b7..264c5c9ca7 100644 --- a/thirdparty/zstd/common/pool.h +++ b/thirdparty/zstd/common/pool.h @@ -1,11 +1,12 @@ -/** - * Copyright (c) 2016-present, Facebook, Inc. +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ + #ifndef POOL_H #define POOL_H @@ -19,11 +20,10 @@ extern "C" { typedef struct POOL_ctx_s POOL_ctx; /*! POOL_create() : - Create a thread pool with at most `numThreads` threads. - `numThreads` must be at least 1. - The maximum number of queued jobs before blocking is `queueSize`. - `queueSize` must be at least 1. - @return : The POOL_ctx pointer on success else NULL. + * Create a thread pool with at most `numThreads` threads. + * `numThreads` must be at least 1. + * The maximum number of queued jobs before blocking is `queueSize`. + * @return : POOL_ctx pointer on success, else NULL. */ POOL_ctx *POOL_create(size_t numThreads, size_t queueSize); diff --git a/thirdparty/zstd/common/threading.h b/thirdparty/zstd/common/threading.h index c0086139ea..ab09977a86 100644 --- a/thirdparty/zstd/common/threading.h +++ b/thirdparty/zstd/common/threading.h @@ -1,4 +1,3 @@ - /** * Copyright (c) 2016 Tino Reichardt * All rights reserved. @@ -42,14 +41,14 @@ extern "C" { /* mutex */ #define pthread_mutex_t CRITICAL_SECTION -#define pthread_mutex_init(a,b) InitializeCriticalSection((a)) +#define pthread_mutex_init(a,b) (InitializeCriticalSection((a)), 0) #define pthread_mutex_destroy(a) DeleteCriticalSection((a)) #define pthread_mutex_lock(a) EnterCriticalSection((a)) #define pthread_mutex_unlock(a) LeaveCriticalSection((a)) /* condition variable */ #define pthread_cond_t CONDITION_VARIABLE -#define pthread_cond_init(a, b) InitializeConditionVariable((a)) +#define pthread_cond_init(a, b) (InitializeConditionVariable((a)), 0) #define pthread_cond_destroy(a) /* No delete */ #define pthread_cond_wait(a, b) SleepConditionVariableCS((a), (b), INFINITE) #define pthread_cond_signal(a) WakeConditionVariable((a)) @@ -80,14 +79,14 @@ int _pthread_join(pthread_t* thread, void** value_ptr); #else /* ZSTD_MULTITHREAD not defined */ /* No multithreading support */ -#define pthread_mutex_t int /* #define rather than typedef, as sometimes pthread support is implicit, resulting in duplicated symbols */ -#define pthread_mutex_init(a,b) +#define pthread_mutex_t int /* #define rather than typedef, because sometimes pthread support is implicit, resulting in duplicated symbols */ +#define pthread_mutex_init(a,b) ((void)a, 0) #define pthread_mutex_destroy(a) #define pthread_mutex_lock(a) #define pthread_mutex_unlock(a) #define pthread_cond_t int -#define pthread_cond_init(a,b) +#define pthread_cond_init(a,b) ((void)a, 0) #define pthread_cond_destroy(a) #define pthread_cond_wait(a,b) #define pthread_cond_signal(a) diff --git a/thirdparty/zstd/common/xxhash.c b/thirdparty/zstd/common/xxhash.c index eb44222c5f..9d9c0e963c 100644 --- a/thirdparty/zstd/common/xxhash.c +++ b/thirdparty/zstd/common/xxhash.c @@ -113,19 +113,25 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcp /* ************************************* * Compiler Specific Options ***************************************/ -#ifdef _MSC_VER /* Visual Studio */ -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -# define FORCE_INLINE static __forceinline +#if defined (__GNUC__) || defined(__cplusplus) || defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# define INLINE_KEYWORD inline #else -# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -# ifdef __GNUC__ -# define FORCE_INLINE static inline __attribute__((always_inline)) -# else -# define FORCE_INLINE static inline -# endif -# else -# define FORCE_INLINE static -# endif /* __STDC_VERSION__ */ +# define INLINE_KEYWORD +#endif + +#if defined(__GNUC__) +# define FORCE_INLINE_ATTR __attribute__((always_inline)) +#elif defined(_MSC_VER) +# define FORCE_INLINE_ATTR __forceinline +#else +# define FORCE_INLINE_ATTR +#endif + +#define FORCE_INLINE_TEMPLATE static INLINE_KEYWORD FORCE_INLINE_ATTR + + +#ifdef _MSC_VER +# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ #endif @@ -248,7 +254,7 @@ typedef enum { XXH_bigEndian=0, XXH_littleEndian=1 } XXH_endianess; *****************************/ typedef enum { XXH_aligned, XXH_unaligned } XXH_alignment; -FORCE_INLINE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align) +FORCE_INLINE_TEMPLATE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_alignment align) { if (align==XXH_unaligned) return endian==XXH_littleEndian ? XXH_read32(ptr) : XXH_swap32(XXH_read32(ptr)); @@ -256,7 +262,7 @@ FORCE_INLINE U32 XXH_readLE32_align(const void* ptr, XXH_endianess endian, XXH_a return endian==XXH_littleEndian ? *(const U32*)ptr : XXH_swap32(*(const U32*)ptr); } -FORCE_INLINE U32 XXH_readLE32(const void* ptr, XXH_endianess endian) +FORCE_INLINE_TEMPLATE U32 XXH_readLE32(const void* ptr, XXH_endianess endian) { return XXH_readLE32_align(ptr, endian, XXH_unaligned); } @@ -266,7 +272,7 @@ static U32 XXH_readBE32(const void* ptr) return XXH_CPU_LITTLE_ENDIAN ? XXH_swap32(XXH_read32(ptr)) : XXH_read32(ptr); } -FORCE_INLINE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align) +FORCE_INLINE_TEMPLATE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_alignment align) { if (align==XXH_unaligned) return endian==XXH_littleEndian ? XXH_read64(ptr) : XXH_swap64(XXH_read64(ptr)); @@ -274,7 +280,7 @@ FORCE_INLINE U64 XXH_readLE64_align(const void* ptr, XXH_endianess endian, XXH_a return endian==XXH_littleEndian ? *(const U64*)ptr : XXH_swap64(*(const U64*)ptr); } -FORCE_INLINE U64 XXH_readLE64(const void* ptr, XXH_endianess endian) +FORCE_INLINE_TEMPLATE U64 XXH_readLE64(const void* ptr, XXH_endianess endian) { return XXH_readLE64_align(ptr, endian, XXH_unaligned); } @@ -335,7 +341,7 @@ static U32 XXH32_round(U32 seed, U32 input) return seed; } -FORCE_INLINE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align) +FORCE_INLINE_TEMPLATE U32 XXH32_endian_align(const void* input, size_t len, U32 seed, XXH_endianess endian, XXH_alignment align) { const BYTE* p = (const BYTE*)input; const BYTE* bEnd = p + len; @@ -435,7 +441,7 @@ static U64 XXH64_mergeRound(U64 acc, U64 val) return acc; } -FORCE_INLINE U64 XXH64_endian_align(const void* input, size_t len, U64 seed, XXH_endianess endian, XXH_alignment align) +FORCE_INLINE_TEMPLATE U64 XXH64_endian_align(const void* input, size_t len, U64 seed, XXH_endianess endian, XXH_alignment align) { const BYTE* p = (const BYTE*)input; const BYTE* const bEnd = p + len; @@ -584,7 +590,7 @@ XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, unsigned long } -FORCE_INLINE XXH_errorcode XXH32_update_endian (XXH32_state_t* state, const void* input, size_t len, XXH_endianess endian) +FORCE_INLINE_TEMPLATE XXH_errorcode XXH32_update_endian (XXH32_state_t* state, const void* input, size_t len, XXH_endianess endian) { const BYTE* p = (const BYTE*)input; const BYTE* const bEnd = p + len; @@ -654,7 +660,7 @@ XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* state_in, const void* -FORCE_INLINE U32 XXH32_digest_endian (const XXH32_state_t* state, XXH_endianess endian) +FORCE_INLINE_TEMPLATE U32 XXH32_digest_endian (const XXH32_state_t* state, XXH_endianess endian) { const BYTE * p = (const BYTE*)state->mem32; const BYTE* const bEnd = (const BYTE*)(state->mem32) + state->memsize; @@ -704,7 +710,7 @@ XXH_PUBLIC_API unsigned int XXH32_digest (const XXH32_state_t* state_in) /* **** XXH64 **** */ -FORCE_INLINE XXH_errorcode XXH64_update_endian (XXH64_state_t* state, const void* input, size_t len, XXH_endianess endian) +FORCE_INLINE_TEMPLATE XXH_errorcode XXH64_update_endian (XXH64_state_t* state, const void* input, size_t len, XXH_endianess endian) { const BYTE* p = (const BYTE*)input; const BYTE* const bEnd = p + len; @@ -771,7 +777,7 @@ XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* state_in, const void* -FORCE_INLINE U64 XXH64_digest_endian (const XXH64_state_t* state, XXH_endianess endian) +FORCE_INLINE_TEMPLATE U64 XXH64_digest_endian (const XXH64_state_t* state, XXH_endianess endian) { const BYTE * p = (const BYTE*)state->mem64; const BYTE* const bEnd = (const BYTE*)state->mem64 + state->memsize; diff --git a/thirdparty/zstd/common/zstd_common.c b/thirdparty/zstd/common/zstd_common.c index f681672381..08384cabf5 100644 --- a/thirdparty/zstd/common/zstd_common.c +++ b/thirdparty/zstd/common/zstd_common.c @@ -1,10 +1,10 @@ -/** +/* * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ diff --git a/thirdparty/zstd/common/zstd_errors.h b/thirdparty/zstd/common/zstd_errors.h index 19f1597aa3..a69387b714 100644 --- a/thirdparty/zstd/common/zstd_errors.h +++ b/thirdparty/zstd/common/zstd_errors.h @@ -1,10 +1,10 @@ -/** +/* * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ #ifndef ZSTD_ERRORS_H_398273423 @@ -37,43 +37,41 @@ extern "C" { /*-**************************************** * error codes list * note : this API is still considered unstable - * it should not be used with a dynamic library + * and shall not be used with a dynamic library. * only static linking is allowed ******************************************/ typedef enum { - ZSTD_error_no_error, - ZSTD_error_GENERIC, - ZSTD_error_prefix_unknown, - ZSTD_error_version_unsupported, - ZSTD_error_parameter_unknown, - ZSTD_error_frameParameter_unsupported, - ZSTD_error_frameParameter_unsupportedBy32bits, - ZSTD_error_frameParameter_windowTooLarge, - ZSTD_error_compressionParameter_unsupported, - ZSTD_error_compressionParameter_outOfBound, - ZSTD_error_init_missing, - ZSTD_error_memory_allocation, - ZSTD_error_stage_wrong, - ZSTD_error_dstSize_tooSmall, - ZSTD_error_srcSize_wrong, - ZSTD_error_corruption_detected, - ZSTD_error_checksum_wrong, - ZSTD_error_tableLog_tooLarge, - ZSTD_error_maxSymbolValue_tooLarge, - ZSTD_error_maxSymbolValue_tooSmall, - ZSTD_error_dictionary_corrupted, - ZSTD_error_dictionary_wrong, - ZSTD_error_dictionaryCreation_failed, - ZSTD_error_frameIndex_tooLarge, - ZSTD_error_seekableIO, - ZSTD_error_maxCode + ZSTD_error_no_error = 0, + ZSTD_error_GENERIC = 1, + ZSTD_error_prefix_unknown = 10, + ZSTD_error_version_unsupported = 12, + ZSTD_error_frameParameter_unsupported = 14, + ZSTD_error_frameParameter_windowTooLarge = 16, + ZSTD_error_corruption_detected = 20, + ZSTD_error_checksum_wrong = 22, + ZSTD_error_dictionary_corrupted = 30, + ZSTD_error_dictionary_wrong = 32, + ZSTD_error_dictionaryCreation_failed = 34, + ZSTD_error_parameter_unsupported = 40, + ZSTD_error_parameter_outOfBound = 42, + ZSTD_error_tableLog_tooLarge = 44, + ZSTD_error_maxSymbolValue_tooLarge = 46, + ZSTD_error_maxSymbolValue_tooSmall = 48, + ZSTD_error_stage_wrong = 60, + ZSTD_error_init_missing = 62, + ZSTD_error_memory_allocation = 64, + ZSTD_error_dstSize_tooSmall = 70, + ZSTD_error_srcSize_wrong = 72, + ZSTD_error_frameIndex_tooLarge = 100, + ZSTD_error_seekableIO = 102, + ZSTD_error_maxCode = 120 /* never EVER use this value directly, it may change in future versions! Use ZSTD_isError() instead */ } ZSTD_ErrorCode; /*! ZSTD_getErrorCode() : convert a `size_t` function result into a `ZSTD_ErrorCode` enum type, which can be used to compare with enum list published above */ ZSTDERRORLIB_API ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult); -ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); +ZSTDERRORLIB_API const char* ZSTD_getErrorString(ZSTD_ErrorCode code); /**< Same as ZSTD_getErrorName, but using a `ZSTD_ErrorCode` enum argument */ #if defined (__cplusplus) diff --git a/thirdparty/zstd/common/zstd_internal.h b/thirdparty/zstd/common/zstd_internal.h index 49a4796476..2610528608 100644 --- a/thirdparty/zstd/common/zstd_internal.h +++ b/thirdparty/zstd/common/zstd_internal.h @@ -1,55 +1,28 @@ -/** +/* * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ #ifndef ZSTD_CCOMMON_H_MODULE #define ZSTD_CCOMMON_H_MODULE -/*-******************************************************* -* Compiler specifics -*********************************************************/ -#ifdef _MSC_VER /* Visual Studio */ -# define FORCE_INLINE static __forceinline -# include <intrin.h> /* For Visual 2005 */ -# pragma warning(disable : 4100) /* disable: C4100: unreferenced formal parameter */ -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -# pragma warning(disable : 4204) /* disable: C4204: non-constant aggregate initializer */ -# pragma warning(disable : 4324) /* disable: C4324: padded structure */ -#else -# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -# ifdef __GNUC__ -# define FORCE_INLINE static inline __attribute__((always_inline)) -# else -# define FORCE_INLINE static inline -# endif -# else -# define FORCE_INLINE static -# endif /* __STDC_VERSION__ */ -#endif - -#ifdef _MSC_VER -# define FORCE_NOINLINE static __declspec(noinline) -#else -# ifdef __GNUC__ -# define FORCE_NOINLINE static __attribute__((__noinline__)) -# else -# define FORCE_NOINLINE static -# endif -#endif - /*-************************************* * Dependencies ***************************************/ +#include "compiler.h" #include "mem.h" #include "error_private.h" #define ZSTD_STATIC_LINKING_ONLY #include "zstd.h" +#define FSE_STATIC_LINKING_ONLY +#include "fse.h" +#define HUF_STATIC_LINKING_ONLY +#include "huf.h" #ifndef XXH_STATIC_LINKING_ONLY # define XXH_STATIC_LINKING_ONLY /* XXH64_state_t */ #endif @@ -211,20 +184,6 @@ MEM_STATIC void ZSTD_wildcopy_e(void* dst, const void* src, void* dstEnd) /* s *********************************************/ typedef struct ZSTD_stats_s ZSTD_stats_t; -typedef struct { - U32 off; - U32 len; -} ZSTD_match_t; - -typedef struct { - U32 price; - U32 off; - U32 mlen; - U32 litlen; - U32 rep[ZSTD_REP_NUM]; -} ZSTD_optimal_t; - - typedef struct seqDef_s { U32 offset; U16 litLength; @@ -242,13 +201,31 @@ typedef struct { BYTE* ofCode; U32 longLengthID; /* 0 == no longLength; 1 == Lit.longLength; 2 == Match.longLength; */ U32 longLengthPos; - /* opt */ - ZSTD_optimal_t* priceTable; - ZSTD_match_t* matchTable; - U32* matchLengthFreq; - U32* litLengthFreq; + U32 rep[ZSTD_REP_NUM]; + U32 repToConfirm[ZSTD_REP_NUM]; +} seqStore_t; + +typedef struct { + U32 off; + U32 len; +} ZSTD_match_t; + +typedef struct { + U32 price; + U32 off; + U32 mlen; + U32 litlen; + U32 rep[ZSTD_REP_NUM]; +} ZSTD_optimal_t; + +typedef struct { U32* litFreq; + U32* litLengthFreq; + U32* matchLengthFreq; U32* offCodeFreq; + ZSTD_match_t* matchTable; + ZSTD_optimal_t* priceTable; + U32 matchLengthSum; U32 matchSum; U32 litLengthSum; @@ -264,7 +241,19 @@ typedef struct { U32 cachedPrice; U32 cachedLitLength; const BYTE* cachedLiterals; -} seqStore_t; +} optState_t; + +typedef struct { + U32 hufCTable[HUF_CTABLE_SIZE_U32(255)]; + FSE_CTable offcodeCTable[FSE_CTABLE_SIZE_U32(OffFSELog, MaxOff)]; + FSE_CTable matchlengthCTable[FSE_CTABLE_SIZE_U32(MLFSELog, MaxML)]; + FSE_CTable litlengthCTable[FSE_CTABLE_SIZE_U32(LLFSELog, MaxLL)]; + U32 workspace[HUF_WORKSPACE_SIZE_U32]; + HUF_repeat hufCTable_repeatMode; + FSE_repeat offcode_repeatMode; + FSE_repeat matchlength_repeatMode; + FSE_repeat litlength_repeatMode; +} ZSTD_entropyCTables_t; const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); void ZSTD_seqToCodes(const seqStore_t* seqStorePtr); @@ -338,9 +327,9 @@ typedef struct { } blockProperties_t; /*! ZSTD_getcBlockSize() : - * Provides the size of compressed block from block header `src` */ - size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, - blockProperties_t* bpPtr); +* Provides the size of compressed block from block header `src` */ +size_t ZSTD_getcBlockSize(const void* src, size_t srcSize, + blockProperties_t* bpPtr); #endif /* ZSTD_CCOMMON_H_MODULE */ diff --git a/thirdparty/zstd/compress/fse_compress.c b/thirdparty/zstd/compress/fse_compress.c index 26e8052ddc..cc9fa73514 100644 --- a/thirdparty/zstd/compress/fse_compress.c +++ b/thirdparty/zstd/compress/fse_compress.c @@ -33,40 +33,22 @@ ****************************************************************** */ /* ************************************************************** -* Compiler specifics -****************************************************************/ -#ifdef _MSC_VER /* Visual Studio */ -# define FORCE_INLINE static __forceinline -# include <intrin.h> /* For Visual 2005 */ -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -# pragma warning(disable : 4214) /* disable: C4214: non-int bitfields */ -#else -# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -# ifdef __GNUC__ -# define FORCE_INLINE static inline __attribute__((always_inline)) -# else -# define FORCE_INLINE static inline -# endif -# else -# define FORCE_INLINE static -# endif /* __STDC_VERSION__ */ -#endif - - -/* ************************************************************** * Includes ****************************************************************/ #include <stdlib.h> /* malloc, free, qsort */ #include <string.h> /* memcpy, memset */ #include <stdio.h> /* printf (debug) */ #include "bitstream.h" +#include "compiler.h" #define FSE_STATIC_LINKING_ONLY #include "fse.h" +#include "error_private.h" /* ************************************************************** * Error Management ****************************************************************/ +#define FSE_isError ERR_isError #define FSE_STATIC_ASSERT(c) { enum { FSE_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ @@ -781,7 +763,7 @@ size_t FSE_compress_usingCTable (void* dst, size_t dstSize, size_t FSE_compressBound(size_t size) { return FSE_COMPRESSBOUND(size); } -#define CHECK_V_F(e, f) size_t const e = f; if (ERR_isError(e)) return f +#define CHECK_V_F(e, f) size_t const e = f; if (ERR_isError(e)) return e #define CHECK_F(f) { CHECK_V_F(_var_err__, f); } /* FSE_compress_wksp() : diff --git a/thirdparty/zstd/compress/huf_compress.c b/thirdparty/zstd/compress/huf_compress.c index 7af0789a9c..2a47c18205 100644 --- a/thirdparty/zstd/compress/huf_compress.c +++ b/thirdparty/zstd/compress/huf_compress.c @@ -50,13 +50,15 @@ #include "fse.h" /* header compression */ #define HUF_STATIC_LINKING_ONLY #include "huf.h" +#include "error_private.h" /* ************************************************************** * Error Management ****************************************************************/ +#define HUF_isError ERR_isError #define HUF_STATIC_ASSERT(c) { enum { HUF_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ -#define CHECK_V_F(e, f) size_t const e = f; if (ERR_isError(e)) return f +#define CHECK_V_F(e, f) size_t const e = f; if (ERR_isError(e)) return e #define CHECK_F(f) { CHECK_V_F(_var_err__, f); } @@ -436,7 +438,7 @@ static void HUF_encodeSymbol(BIT_CStream_t* bitCPtr, U32 symbol, const HUF_CElt* size_t HUF_compressBound(size_t size) { return HUF_COMPRESSBOUND(size); } -#define HUF_FLUSHBITS(s) (fast ? BIT_flushBitsFast(s) : BIT_flushBits(s)) +#define HUF_FLUSHBITS(s) BIT_flushBits(s) #define HUF_FLUSHBITS_1(stream) \ if (sizeof((stream)->bitContainer)*8 < HUF_TABLELOG_MAX*2+7) HUF_FLUSHBITS(stream) @@ -451,7 +453,6 @@ size_t HUF_compress1X_usingCTable(void* dst, size_t dstSize, const void* src, si BYTE* const oend = ostart + dstSize; BYTE* op = ostart; size_t n; - const unsigned fast = (dstSize >= HUF_BLOCKBOUND(srcSize)); BIT_CStream_t bitC; /* init */ diff --git a/thirdparty/zstd/compress/zstd_compress.c b/thirdparty/zstd/compress/zstd_compress.c index 9300357f2d..0322c03eb3 100644 --- a/thirdparty/zstd/compress/zstd_compress.c +++ b/thirdparty/zstd/compress/zstd_compress.c @@ -1,10 +1,10 @@ -/** +/* * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ @@ -36,13 +36,6 @@ static const U32 g_searchStrength = 8; /* control skip over incompressible dat #define HASH_READ_SIZE 8 typedef enum { ZSTDcs_created=0, ZSTDcs_init, ZSTDcs_ongoing, ZSTDcs_ending } ZSTD_compressionStage_e; -/* entropy tables always have same size */ -static size_t const hufCTable_size = HUF_CTABLE_SIZE(255); -static size_t const litlengthCTable_size = FSE_CTABLE_SIZE(LLFSELog, MaxLL); -static size_t const offcodeCTable_size = FSE_CTABLE_SIZE(OffFSELog, MaxOff); -static size_t const matchlengthCTable_size = FSE_CTABLE_SIZE(MLFSELog, MaxML); -static size_t const entropyScratchSpace_size = HUF_WORKSPACE_SIZE; - /*-************************************* * Helper functions @@ -89,8 +82,6 @@ struct ZSTD_CCtx_s { U32 loadedDictEnd; /* index of end of dictionary */ U32 forceWindow; /* force back-references to respect limit of 1<<wLog, even for dictionary */ ZSTD_compressionStage_e stage; - U32 rep[ZSTD_REP_NUM]; - U32 repToConfirm[ZSTD_REP_NUM]; U32 dictID; int compressionLevel; ZSTD_parameters requestedParams; @@ -105,16 +96,11 @@ struct ZSTD_CCtx_s { size_t staticSize; seqStore_t seqStore; /* sequences storage ptrs */ + optState_t optState; U32* hashTable; U32* hashTable3; U32* chainTable; - HUF_repeat hufCTable_repeatMode; - HUF_CElt* hufCTable; - U32 fseCTables_ready; - FSE_CTable* offcodeCTable; - FSE_CTable* matchlengthCTable; - FSE_CTable* litlengthCTable; - unsigned* entropyScratchSpace; + ZSTD_entropyCTables_t* entropy; /* streaming */ char* inBuff; @@ -174,19 +160,9 @@ ZSTD_CCtx* ZSTD_initStaticCCtx(void *workspace, size_t workspaceSize) cctx->workSpaceSize = workspaceSize - sizeof(ZSTD_CCtx); /* entropy space (never moves) */ - /* note : this code should be shared with resetCCtx, rather than copy/pasted */ - { void* ptr = cctx->workSpace; - cctx->hufCTable = (HUF_CElt*)ptr; - ptr = (char*)cctx->hufCTable + hufCTable_size; - cctx->offcodeCTable = (FSE_CTable*) ptr; - ptr = (char*)ptr + offcodeCTable_size; - cctx->matchlengthCTable = (FSE_CTable*) ptr; - ptr = (char*)ptr + matchlengthCTable_size; - cctx->litlengthCTable = (FSE_CTable*) ptr; - ptr = (char*)ptr + litlengthCTable_size; - assert(((size_t)ptr & 3) == 0); /* ensure correct alignment */ - cctx->entropyScratchSpace = (unsigned*) ptr; - } + if (cctx->workSpaceSize < sizeof(ZSTD_entropyCTables_t)) return NULL; + assert(((size_t)cctx->workSpace & 7) == 0); /* ensure correct alignment */ + cctx->entropy = (ZSTD_entropyCTables_t*)cctx->workSpace; return cctx; } @@ -237,7 +213,7 @@ size_t ZSTD_setCCtxParameter(ZSTD_CCtx* cctx, ZSTD_CCtxParameter param, unsigned ZSTD_STATIC_ASSERT(ZSTD_dm_auto==0); ZSTD_STATIC_ASSERT(ZSTD_dm_rawContent==1); case ZSTD_p_forceRawDict : cctx->dictMode = (ZSTD_dictMode_e)(value>0); return 0; - default: return ERROR(parameter_unknown); + default: return ERROR(parameter_unsupported); } } @@ -251,9 +227,9 @@ static void ZSTD_cLevelToCParams(ZSTD_CCtx* cctx) cctx->compressionLevel = ZSTD_CLEVEL_CUSTOM; } -#define CLAMPCHECK(val,min,max) { \ - if (((val)<(min)) | ((val)>(max))) { \ - return ERROR(compressionParameter_outOfBound); \ +#define CLAMPCHECK(val,min,max) { \ + if (((val)<(min)) | ((val)>(max))) { \ + return ERROR(parameter_outOfBound); \ } } size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value) @@ -349,7 +325,7 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned v /* restrict dictionary mode, to "rawContent" or "fullDict" only */ ZSTD_STATIC_ASSERT((U32)ZSTD_dm_fullDict > (U32)ZSTD_dm_rawContent); if (value > (unsigned)ZSTD_dm_fullDict) - return ERROR(compressionParameter_outOfBound); + return ERROR(parameter_outOfBound); cctx->dictMode = (ZSTD_dictMode_e)value; return 0; @@ -370,31 +346,31 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned v if (value==0) return 0; DEBUGLOG(5, " setting nbThreads : %u", value); #ifndef ZSTD_MULTITHREAD - if (value > 1) return ERROR(compressionParameter_unsupported); + if (value > 1) return ERROR(parameter_unsupported); #endif if ((value>1) && (cctx->nbThreads != value)) { if (cctx->staticSize) /* MT not compatible with static alloc */ - return ERROR(compressionParameter_unsupported); + return ERROR(parameter_unsupported); ZSTDMT_freeCCtx(cctx->mtctx); cctx->nbThreads = 1; - cctx->mtctx = ZSTDMT_createCCtx(value); + cctx->mtctx = ZSTDMT_createCCtx_advanced(value, cctx->customMem); if (cctx->mtctx == NULL) return ERROR(memory_allocation); } cctx->nbThreads = value; return 0; case ZSTD_p_jobSize: - if (cctx->nbThreads <= 1) return ERROR(compressionParameter_unsupported); + if (cctx->nbThreads <= 1) return ERROR(parameter_unsupported); assert(cctx->mtctx != NULL); return ZSTDMT_setMTCtxParameter(cctx->mtctx, ZSTDMT_p_sectionSize, value); case ZSTD_p_overlapSizeLog: DEBUGLOG(5, " setting overlap with nbThreads == %u", cctx->nbThreads); - if (cctx->nbThreads <= 1) return ERROR(compressionParameter_unsupported); + if (cctx->nbThreads <= 1) return ERROR(parameter_unsupported); assert(cctx->mtctx != NULL); return ZSTDMT_setMTCtxParameter(cctx->mtctx, ZSTDMT_p_overlapSectionLog, value); - default: return ERROR(parameter_unknown); + default: return ERROR(parameter_unsupported); } } @@ -474,7 +450,8 @@ size_t ZSTD_checkCParams(ZSTD_compressionParameters cParams) CLAMPCHECK(cParams.searchLog, ZSTD_SEARCHLOG_MIN, ZSTD_SEARCHLOG_MAX); CLAMPCHECK(cParams.searchLength, ZSTD_SEARCHLENGTH_MIN, ZSTD_SEARCHLENGTH_MAX); CLAMPCHECK(cParams.targetLength, ZSTD_TARGETLENGTH_MIN, ZSTD_TARGETLENGTH_MAX); - if ((U32)(cParams.strategy) > (U32)ZSTD_btultra) return ERROR(compressionParameter_unsupported); + if ((U32)(cParams.strategy) > (U32)ZSTD_btultra) + return ERROR(parameter_unsupported); return 0; } @@ -551,9 +528,7 @@ size_t ZSTD_estimateCCtxSize_advanced(ZSTD_compressionParameters cParams) size_t const hSize = ((size_t)1) << cParams.hashLog; U32 const hashLog3 = (cParams.searchLength>3) ? 0 : MIN(ZSTD_HASHLOG3_MAX, cParams.windowLog); size_t const h3Size = ((size_t)1) << hashLog3; - size_t const entropySpace = hufCTable_size + litlengthCTable_size - + offcodeCTable_size + matchlengthCTable_size - + entropyScratchSpace_size; + size_t const entropySpace = sizeof(ZSTD_entropyCTables_t); size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32); size_t const optBudget = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits))*sizeof(U32) @@ -620,8 +595,8 @@ static size_t ZSTD_continueCCtx(ZSTD_CCtx* cctx, ZSTD_parameters params, U64 ple cctx->stage = ZSTDcs_init; cctx->dictID = 0; cctx->loadedDictEnd = 0; - { int i; for (i=0; i<ZSTD_REP_NUM; i++) cctx->rep[i] = repStartValue[i]; } - cctx->seqStore.litLengthSum = 0; /* force reset of btopt stats */ + { int i; for (i=0; i<ZSTD_REP_NUM; i++) cctx->seqStore.rep[i] = repStartValue[i]; } + cctx->optState.litLengthSum = 0; /* force reset of btopt stats */ XXH64_reset(&cctx->xxhState, 0); return 0; } @@ -641,8 +616,10 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc, if (crp == ZSTDcrp_continue) { if (ZSTD_equivalentParams(params.cParams, zc->appliedParams.cParams)) { DEBUGLOG(5, "ZSTD_equivalentParams()==1"); - zc->fseCTables_ready = 0; - zc->hufCTable_repeatMode = HUF_repeat_none; + zc->entropy->hufCTable_repeatMode = HUF_repeat_none; + zc->entropy->offcode_repeatMode = FSE_repeat_none; + zc->entropy->matchlength_repeatMode = FSE_repeat_none; + zc->entropy->litlength_repeatMode = FSE_repeat_none; return ZSTD_continueCCtx(zc, params, pledgedSrcSize); } } @@ -662,9 +639,7 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc, void* ptr; /* Check if workSpace is large enough, alloc a new one if needed */ - { size_t const entropySpace = hufCTable_size + litlengthCTable_size - + offcodeCTable_size + matchlengthCTable_size - + entropyScratchSpace_size; + { size_t const entropySpace = sizeof(ZSTD_entropyCTables_t); size_t const optPotentialSpace = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits)) * sizeof(U32) + (ZSTD_OPT_NUM+1) * (sizeof(ZSTD_match_t)+sizeof(ZSTD_optimal_t)); size_t const optSpace = ( (params.cParams.strategy == ZSTD_btopt) @@ -689,16 +664,9 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc, ptr = zc->workSpace; /* entropy space */ - zc->hufCTable = (HUF_CElt*)ptr; - ptr = (char*)zc->hufCTable + hufCTable_size; /* note : HUF_CElt* is incomplete type, size is estimated via macro */ - zc->offcodeCTable = (FSE_CTable*) ptr; - ptr = (char*)ptr + offcodeCTable_size; - zc->matchlengthCTable = (FSE_CTable*) ptr; - ptr = (char*)ptr + matchlengthCTable_size; - zc->litlengthCTable = (FSE_CTable*) ptr; - ptr = (char*)ptr + litlengthCTable_size; - assert(((size_t)ptr & 3) == 0); /* ensure correct alignment */ - zc->entropyScratchSpace = (unsigned*) ptr; + assert(((size_t)zc->workSpace & 3) == 0); /* ensure correct alignment */ + assert(zc->workSpaceSize >= sizeof(ZSTD_entropyCTables_t)); + zc->entropy = (ZSTD_entropyCTables_t*)zc->workSpace; } } /* init params */ @@ -715,39 +683,35 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc, zc->stage = ZSTDcs_init; zc->dictID = 0; zc->loadedDictEnd = 0; - zc->fseCTables_ready = 0; - zc->hufCTable_repeatMode = HUF_repeat_none; + zc->entropy->hufCTable_repeatMode = HUF_repeat_none; + zc->entropy->offcode_repeatMode = FSE_repeat_none; + zc->entropy->matchlength_repeatMode = FSE_repeat_none; + zc->entropy->litlength_repeatMode = FSE_repeat_none; zc->nextToUpdate = 1; zc->nextSrc = NULL; zc->base = NULL; zc->dictBase = NULL; zc->dictLimit = 0; zc->lowLimit = 0; - { int i; for (i=0; i<ZSTD_REP_NUM; i++) zc->rep[i] = repStartValue[i]; } + { int i; for (i=0; i<ZSTD_REP_NUM; i++) zc->seqStore.rep[i] = repStartValue[i]; } zc->hashLog3 = hashLog3; - zc->seqStore.litLengthSum = 0; + zc->optState.litLengthSum = 0; - /* ensure entropy tables are close together at the beginning */ - assert((void*)zc->hufCTable == zc->workSpace); - assert((char*)zc->offcodeCTable == (char*)zc->hufCTable + hufCTable_size); - assert((char*)zc->matchlengthCTable == (char*)zc->offcodeCTable + offcodeCTable_size); - assert((char*)zc->litlengthCTable == (char*)zc->matchlengthCTable + matchlengthCTable_size); - assert((char*)zc->entropyScratchSpace == (char*)zc->litlengthCTable + litlengthCTable_size); - ptr = (char*)zc->entropyScratchSpace + entropyScratchSpace_size; + ptr = zc->entropy + 1; /* opt parser space */ if ((params.cParams.strategy == ZSTD_btopt) || (params.cParams.strategy == ZSTD_btultra)) { DEBUGLOG(5, "reserving optimal parser space"); assert(((size_t)ptr & 3) == 0); /* ensure ptr is properly aligned */ - zc->seqStore.litFreq = (U32*)ptr; - zc->seqStore.litLengthFreq = zc->seqStore.litFreq + (1<<Litbits); - zc->seqStore.matchLengthFreq = zc->seqStore.litLengthFreq + (MaxLL+1); - zc->seqStore.offCodeFreq = zc->seqStore.matchLengthFreq + (MaxML+1); - ptr = zc->seqStore.offCodeFreq + (MaxOff+1); - zc->seqStore.matchTable = (ZSTD_match_t*)ptr; - ptr = zc->seqStore.matchTable + ZSTD_OPT_NUM+1; - zc->seqStore.priceTable = (ZSTD_optimal_t*)ptr; - ptr = zc->seqStore.priceTable + ZSTD_OPT_NUM+1; + zc->optState.litFreq = (U32*)ptr; + zc->optState.litLengthFreq = zc->optState.litFreq + (1<<Litbits); + zc->optState.matchLengthFreq = zc->optState.litLengthFreq + (MaxLL+1); + zc->optState.offCodeFreq = zc->optState.matchLengthFreq + (MaxML+1); + ptr = zc->optState.offCodeFreq + (MaxOff+1); + zc->optState.matchTable = (ZSTD_match_t*)ptr; + ptr = zc->optState.matchTable + ZSTD_OPT_NUM+1; + zc->optState.priceTable = (ZSTD_optimal_t*)ptr; + ptr = zc->optState.priceTable + ZSTD_OPT_NUM+1; } /* table Space */ @@ -783,7 +747,7 @@ static size_t ZSTD_resetCCtx_internal(ZSTD_CCtx* zc, * do not use with extDict variant ! */ void ZSTD_invalidateRepCodes(ZSTD_CCtx* cctx) { int i; - for (i=0; i<ZSTD_REP_NUM; i++) cctx->rep[i] = 0; + for (i=0; i<ZSTD_REP_NUM; i++) cctx->seqStore.rep[i] = 0; } @@ -830,16 +794,7 @@ static size_t ZSTD_copyCCtx_internal(ZSTD_CCtx* dstCCtx, dstCCtx->dictID = srcCCtx->dictID; /* copy entropy tables */ - dstCCtx->fseCTables_ready = srcCCtx->fseCTables_ready; - if (srcCCtx->fseCTables_ready) { - memcpy(dstCCtx->litlengthCTable, srcCCtx->litlengthCTable, litlengthCTable_size); - memcpy(dstCCtx->matchlengthCTable, srcCCtx->matchlengthCTable, matchlengthCTable_size); - memcpy(dstCCtx->offcodeCTable, srcCCtx->offcodeCTable, offcodeCTable_size); - } - dstCCtx->hufCTable_repeatMode = srcCCtx->hufCTable_repeatMode; - if (srcCCtx->hufCTable_repeatMode) { - memcpy(dstCCtx->hufCTable, srcCCtx->hufCTable, hufCTable_size); - } + memcpy(dstCCtx->entropy, srcCCtx->entropy, sizeof(ZSTD_entropyCTables_t)); return 0; } @@ -956,7 +911,8 @@ static size_t ZSTD_compressRleLiteralsBlock (void* dst, size_t dstCapacity, cons static size_t ZSTD_minGain(size_t srcSize) { return (srcSize >> 6) + 2; } -static size_t ZSTD_compressLiterals (ZSTD_CCtx* zc, +static size_t ZSTD_compressLiterals (ZSTD_entropyCTables_t * entropy, + ZSTD_strategy strategy, void* dst, size_t dstCapacity, const void* src, size_t srcSize) { @@ -970,28 +926,28 @@ static size_t ZSTD_compressLiterals (ZSTD_CCtx* zc, /* small ? don't even attempt compression (speed opt) */ # define LITERAL_NOENTROPY 63 - { size_t const minLitSize = zc->hufCTable_repeatMode == HUF_repeat_valid ? 6 : LITERAL_NOENTROPY; + { size_t const minLitSize = entropy->hufCTable_repeatMode == HUF_repeat_valid ? 6 : LITERAL_NOENTROPY; if (srcSize <= minLitSize) return ZSTD_noCompressLiterals(dst, dstCapacity, src, srcSize); } if (dstCapacity < lhSize+1) return ERROR(dstSize_tooSmall); /* not enough space for compression */ - { HUF_repeat repeat = zc->hufCTable_repeatMode; - int const preferRepeat = zc->appliedParams.cParams.strategy < ZSTD_lazy ? srcSize <= 1024 : 0; + { HUF_repeat repeat = entropy->hufCTable_repeatMode; + int const preferRepeat = strategy < ZSTD_lazy ? srcSize <= 1024 : 0; if (repeat == HUF_repeat_valid && lhSize == 3) singleStream = 1; cLitSize = singleStream ? HUF_compress1X_repeat(ostart+lhSize, dstCapacity-lhSize, src, srcSize, 255, 11, - zc->entropyScratchSpace, entropyScratchSpace_size, zc->hufCTable, &repeat, preferRepeat) + entropy->workspace, sizeof(entropy->workspace), (HUF_CElt*)entropy->hufCTable, &repeat, preferRepeat) : HUF_compress4X_repeat(ostart+lhSize, dstCapacity-lhSize, src, srcSize, 255, 11, - zc->entropyScratchSpace, entropyScratchSpace_size, zc->hufCTable, &repeat, preferRepeat); + entropy->workspace, sizeof(entropy->workspace), (HUF_CElt*)entropy->hufCTable, &repeat, preferRepeat); if (repeat != HUF_repeat_none) { hType = set_repeat; } /* reused the existing table */ - else { zc->hufCTable_repeatMode = HUF_repeat_check; } /* now have a table to reuse */ + else { entropy->hufCTable_repeatMode = HUF_repeat_check; } /* now have a table to reuse */ } - if ((cLitSize==0) | (cLitSize >= srcSize - minGain)) { - zc->hufCTable_repeatMode = HUF_repeat_none; + if ((cLitSize==0) | (cLitSize >= srcSize - minGain) | ERR_isError(cLitSize)) { + entropy->hufCTable_repeatMode = HUF_repeat_none; return ZSTD_noCompressLiterals(dst, dstCapacity, src, srcSize); } if (cLitSize==1) { - zc->hufCTable_repeatMode = HUF_repeat_none; + entropy->hufCTable_repeatMode = HUF_repeat_none; return ZSTD_compressRleLiteralsBlock(dst, dstCapacity, src, srcSize); } @@ -1062,17 +1018,154 @@ void ZSTD_seqToCodes(const seqStore_t* seqStorePtr) mlCodeTable[seqStorePtr->longLengthPos] = MaxML; } -MEM_STATIC size_t ZSTD_compressSequences (ZSTD_CCtx* zc, - void* dst, size_t dstCapacity, - size_t srcSize) +MEM_STATIC symbolEncodingType_e ZSTD_selectEncodingType(FSE_repeat* repeatMode, + size_t const mostFrequent, size_t nbSeq, U32 defaultNormLog) +{ +#define MIN_SEQ_FOR_DYNAMIC_FSE 64 +#define MAX_SEQ_FOR_STATIC_FSE 1000 + + if ((mostFrequent == nbSeq) && (nbSeq > 2)) { + *repeatMode = FSE_repeat_check; + return set_rle; + } + if ((*repeatMode == FSE_repeat_valid) && (nbSeq < MAX_SEQ_FOR_STATIC_FSE)) { + return set_repeat; + } + if ((nbSeq < MIN_SEQ_FOR_DYNAMIC_FSE) || (mostFrequent < (nbSeq >> (defaultNormLog-1)))) { + *repeatMode = FSE_repeat_valid; + return set_basic; + } + *repeatMode = FSE_repeat_check; + return set_compressed; +} + +MEM_STATIC size_t ZSTD_buildCTable(void* dst, size_t dstCapacity, + FSE_CTable* CTable, U32 FSELog, symbolEncodingType_e type, + U32* count, U32 max, + BYTE const* codeTable, size_t nbSeq, + S16 const* defaultNorm, U32 defaultNormLog, U32 defaultMax, + void* workspace, size_t workspaceSize) +{ + BYTE* op = (BYTE*)dst; + BYTE const* const oend = op + dstCapacity; + + switch (type) { + case set_rle: + *op = codeTable[0]; + CHECK_F(FSE_buildCTable_rle(CTable, (BYTE)max)); + return 1; + case set_repeat: + return 0; + case set_basic: + CHECK_F(FSE_buildCTable_wksp(CTable, defaultNorm, defaultMax, defaultNormLog, workspace, workspaceSize)); + return 0; + case set_compressed: { + S16 norm[MaxSeq + 1]; + size_t nbSeq_1 = nbSeq; + const U32 tableLog = FSE_optimalTableLog(FSELog, nbSeq, max); + if (count[codeTable[nbSeq-1]] > 1) { + count[codeTable[nbSeq-1]]--; + nbSeq_1--; + } + CHECK_F(FSE_normalizeCount(norm, tableLog, count, nbSeq_1, max)); + { size_t const NCountSize = FSE_writeNCount(op, oend - op, norm, max, tableLog); /* overflow protected */ + if (FSE_isError(NCountSize)) return NCountSize; + CHECK_F(FSE_buildCTable_wksp(CTable, norm, max, tableLog, workspace, workspaceSize)); + return NCountSize; + } + } + default: return assert(0), ERROR(GENERIC); + } +} + +MEM_STATIC size_t ZSTD_encodeSequences(void* dst, size_t dstCapacity, + FSE_CTable const* CTable_MatchLength, BYTE const* mlCodeTable, + FSE_CTable const* CTable_OffsetBits, BYTE const* ofCodeTable, + FSE_CTable const* CTable_LitLength, BYTE const* llCodeTable, + seqDef const* sequences, size_t nbSeq, int longOffsets) +{ + BIT_CStream_t blockStream; + FSE_CState_t stateMatchLength; + FSE_CState_t stateOffsetBits; + FSE_CState_t stateLitLength; + + CHECK_E(BIT_initCStream(&blockStream, dst, dstCapacity), dstSize_tooSmall); /* not enough space remaining */ + + /* first symbols */ + FSE_initCState2(&stateMatchLength, CTable_MatchLength, mlCodeTable[nbSeq-1]); + FSE_initCState2(&stateOffsetBits, CTable_OffsetBits, ofCodeTable[nbSeq-1]); + FSE_initCState2(&stateLitLength, CTable_LitLength, llCodeTable[nbSeq-1]); + BIT_addBits(&blockStream, sequences[nbSeq-1].litLength, LL_bits[llCodeTable[nbSeq-1]]); + if (MEM_32bits()) BIT_flushBits(&blockStream); + BIT_addBits(&blockStream, sequences[nbSeq-1].matchLength, ML_bits[mlCodeTable[nbSeq-1]]); + if (MEM_32bits()) BIT_flushBits(&blockStream); + if (longOffsets) { + U32 const ofBits = ofCodeTable[nbSeq-1]; + int const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN-1); + if (extraBits) { + BIT_addBits(&blockStream, sequences[nbSeq-1].offset, extraBits); + BIT_flushBits(&blockStream); + } + BIT_addBits(&blockStream, sequences[nbSeq-1].offset >> extraBits, + ofBits - extraBits); + } else { + BIT_addBits(&blockStream, sequences[nbSeq-1].offset, ofCodeTable[nbSeq-1]); + } + BIT_flushBits(&blockStream); + + { size_t n; + for (n=nbSeq-2 ; n<nbSeq ; n--) { /* intentional underflow */ + BYTE const llCode = llCodeTable[n]; + BYTE const ofCode = ofCodeTable[n]; + BYTE const mlCode = mlCodeTable[n]; + U32 const llBits = LL_bits[llCode]; + U32 const ofBits = ofCode; /* 32b*/ /* 64b*/ + U32 const mlBits = ML_bits[mlCode]; + /* (7)*/ /* (7)*/ + FSE_encodeSymbol(&blockStream, &stateOffsetBits, ofCode); /* 15 */ /* 15 */ + FSE_encodeSymbol(&blockStream, &stateMatchLength, mlCode); /* 24 */ /* 24 */ + if (MEM_32bits()) BIT_flushBits(&blockStream); /* (7)*/ + FSE_encodeSymbol(&blockStream, &stateLitLength, llCode); /* 16 */ /* 33 */ + if (MEM_32bits() || (ofBits+mlBits+llBits >= 64-7-(LLFSELog+MLFSELog+OffFSELog))) + BIT_flushBits(&blockStream); /* (7)*/ + BIT_addBits(&blockStream, sequences[n].litLength, llBits); + if (MEM_32bits() && ((llBits+mlBits)>24)) BIT_flushBits(&blockStream); + BIT_addBits(&blockStream, sequences[n].matchLength, mlBits); + if (MEM_32bits()) BIT_flushBits(&blockStream); /* (7)*/ + if (longOffsets) { + int const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN-1); + if (extraBits) { + BIT_addBits(&blockStream, sequences[n].offset, extraBits); + BIT_flushBits(&blockStream); /* (7)*/ + } + BIT_addBits(&blockStream, sequences[n].offset >> extraBits, + ofBits - extraBits); /* 31 */ + } else { + BIT_addBits(&blockStream, sequences[n].offset, ofBits); /* 31 */ + } + BIT_flushBits(&blockStream); /* (7)*/ + } } + + FSE_flushCState(&blockStream, &stateMatchLength); + FSE_flushCState(&blockStream, &stateOffsetBits); + FSE_flushCState(&blockStream, &stateLitLength); + + { size_t const streamSize = BIT_closeCStream(&blockStream); + if (streamSize==0) return ERROR(dstSize_tooSmall); /* not enough space */ + return streamSize; + } +} + +MEM_STATIC size_t ZSTD_compressSequences_internal(seqStore_t* seqStorePtr, + ZSTD_entropyCTables_t* entropy, + ZSTD_compressionParameters const* cParams, + void* dst, size_t dstCapacity) { - const int longOffsets = zc->appliedParams.cParams.windowLog > STREAM_ACCUMULATOR_MIN; - const seqStore_t* seqStorePtr = &(zc->seqStore); + const int longOffsets = cParams->windowLog > STREAM_ACCUMULATOR_MIN; U32 count[MaxSeq+1]; - S16 norm[MaxSeq+1]; - FSE_CTable* CTable_LitLength = zc->litlengthCTable; - FSE_CTable* CTable_OffsetBits = zc->offcodeCTable; - FSE_CTable* CTable_MatchLength = zc->matchlengthCTable; + FSE_CTable* CTable_LitLength = entropy->litlengthCTable; + FSE_CTable* CTable_OffsetBits = entropy->offcodeCTable; + FSE_CTable* CTable_MatchLength = entropy->matchlengthCTable; U32 LLtype, Offtype, MLtype; /* compressed, raw or rle */ const seqDef* const sequences = seqStorePtr->sequencesStart; const BYTE* const ofCodeTable = seqStorePtr->ofCode; @@ -1083,13 +1176,16 @@ MEM_STATIC size_t ZSTD_compressSequences (ZSTD_CCtx* zc, BYTE* op = ostart; size_t const nbSeq = seqStorePtr->sequences - seqStorePtr->sequencesStart; BYTE* seqHead; - BYTE scratchBuffer[1<<MAX(MLFSELog,LLFSELog)]; + + ZSTD_STATIC_ASSERT(sizeof(entropy->workspace) >= (1<<MAX(MLFSELog,LLFSELog))); /* Compress literals */ { const BYTE* const literals = seqStorePtr->litStart; size_t const litSize = seqStorePtr->lit - literals; - size_t const cSize = ZSTD_compressLiterals(zc, op, dstCapacity, literals, litSize); - if (ZSTD_isError(cSize)) return cSize; + size_t const cSize = ZSTD_compressLiterals( + entropy, cParams->strategy, op, dstCapacity, literals, litSize); + if (ZSTD_isError(cSize)) + return cSize; op += cSize; } @@ -1098,177 +1194,89 @@ MEM_STATIC size_t ZSTD_compressSequences (ZSTD_CCtx* zc, if (nbSeq < 0x7F) *op++ = (BYTE)nbSeq; else if (nbSeq < LONGNBSEQ) op[0] = (BYTE)((nbSeq>>8) + 0x80), op[1] = (BYTE)nbSeq, op+=2; else op[0]=0xFF, MEM_writeLE16(op+1, (U16)(nbSeq - LONGNBSEQ)), op+=3; - if (nbSeq==0) goto _check_compressibility; + if (nbSeq==0) return op - ostart; /* seqHead : flags for FSE encoding type */ seqHead = op++; -#define MIN_SEQ_FOR_DYNAMIC_FSE 64 -#define MAX_SEQ_FOR_STATIC_FSE 1000 - /* convert length/distances into codes */ ZSTD_seqToCodes(seqStorePtr); - /* CTable for Literal Lengths */ { U32 max = MaxLL; - size_t const mostFrequent = FSE_countFast_wksp(count, &max, llCodeTable, nbSeq, zc->entropyScratchSpace); - if ((mostFrequent == nbSeq) && (nbSeq > 2)) { - *op++ = llCodeTable[0]; - FSE_buildCTable_rle(CTable_LitLength, (BYTE)max); - LLtype = set_rle; - } else if ((zc->fseCTables_ready) && (nbSeq < MAX_SEQ_FOR_STATIC_FSE)) { - LLtype = set_repeat; - } else if ((nbSeq < MIN_SEQ_FOR_DYNAMIC_FSE) || (mostFrequent < (nbSeq >> (LL_defaultNormLog-1)))) { - FSE_buildCTable_wksp(CTable_LitLength, LL_defaultNorm, MaxLL, LL_defaultNormLog, scratchBuffer, sizeof(scratchBuffer)); - LLtype = set_basic; - } else { - size_t nbSeq_1 = nbSeq; - const U32 tableLog = FSE_optimalTableLog(LLFSELog, nbSeq, max); - if (count[llCodeTable[nbSeq-1]]>1) { count[llCodeTable[nbSeq-1]]--; nbSeq_1--; } - FSE_normalizeCount(norm, tableLog, count, nbSeq_1, max); - { size_t const NCountSize = FSE_writeNCount(op, oend-op, norm, max, tableLog); /* overflow protected */ - if (FSE_isError(NCountSize)) return NCountSize; - op += NCountSize; } - FSE_buildCTable_wksp(CTable_LitLength, norm, max, tableLog, scratchBuffer, sizeof(scratchBuffer)); - LLtype = set_compressed; + size_t const mostFrequent = FSE_countFast_wksp(count, &max, llCodeTable, nbSeq, entropy->workspace); + LLtype = ZSTD_selectEncodingType(&entropy->litlength_repeatMode, mostFrequent, nbSeq, LL_defaultNormLog); + { size_t const countSize = ZSTD_buildCTable(op, oend - op, CTable_LitLength, LLFSELog, (symbolEncodingType_e)LLtype, + count, max, llCodeTable, nbSeq, LL_defaultNorm, LL_defaultNormLog, MaxLL, + entropy->workspace, sizeof(entropy->workspace)); + if (ZSTD_isError(countSize)) return countSize; + op += countSize; } } - /* CTable for Offsets */ { U32 max = MaxOff; - size_t const mostFrequent = FSE_countFast_wksp(count, &max, ofCodeTable, nbSeq, zc->entropyScratchSpace); - if ((mostFrequent == nbSeq) && (nbSeq > 2)) { - *op++ = ofCodeTable[0]; - FSE_buildCTable_rle(CTable_OffsetBits, (BYTE)max); - Offtype = set_rle; - } else if ((zc->fseCTables_ready) && (nbSeq < MAX_SEQ_FOR_STATIC_FSE)) { - Offtype = set_repeat; - } else if ((nbSeq < MIN_SEQ_FOR_DYNAMIC_FSE) || (mostFrequent < (nbSeq >> (OF_defaultNormLog-1)))) { - FSE_buildCTable_wksp(CTable_OffsetBits, OF_defaultNorm, MaxOff, OF_defaultNormLog, scratchBuffer, sizeof(scratchBuffer)); - Offtype = set_basic; - } else { - size_t nbSeq_1 = nbSeq; - const U32 tableLog = FSE_optimalTableLog(OffFSELog, nbSeq, max); - if (count[ofCodeTable[nbSeq-1]]>1) { count[ofCodeTable[nbSeq-1]]--; nbSeq_1--; } - FSE_normalizeCount(norm, tableLog, count, nbSeq_1, max); - { size_t const NCountSize = FSE_writeNCount(op, oend-op, norm, max, tableLog); /* overflow protected */ - if (FSE_isError(NCountSize)) return NCountSize; - op += NCountSize; } - FSE_buildCTable_wksp(CTable_OffsetBits, norm, max, tableLog, scratchBuffer, sizeof(scratchBuffer)); - Offtype = set_compressed; + size_t const mostFrequent = FSE_countFast_wksp(count, &max, ofCodeTable, nbSeq, entropy->workspace); + Offtype = ZSTD_selectEncodingType(&entropy->offcode_repeatMode, mostFrequent, nbSeq, OF_defaultNormLog); + { size_t const countSize = ZSTD_buildCTable(op, oend - op, CTable_OffsetBits, OffFSELog, (symbolEncodingType_e)Offtype, + count, max, ofCodeTable, nbSeq, OF_defaultNorm, OF_defaultNormLog, MaxOff, + entropy->workspace, sizeof(entropy->workspace)); + if (ZSTD_isError(countSize)) return countSize; + op += countSize; } } - /* CTable for MatchLengths */ { U32 max = MaxML; - size_t const mostFrequent = FSE_countFast_wksp(count, &max, mlCodeTable, nbSeq, zc->entropyScratchSpace); - if ((mostFrequent == nbSeq) && (nbSeq > 2)) { - *op++ = *mlCodeTable; - FSE_buildCTable_rle(CTable_MatchLength, (BYTE)max); - MLtype = set_rle; - } else if ((zc->fseCTables_ready) && (nbSeq < MAX_SEQ_FOR_STATIC_FSE)) { - MLtype = set_repeat; - } else if ((nbSeq < MIN_SEQ_FOR_DYNAMIC_FSE) || (mostFrequent < (nbSeq >> (ML_defaultNormLog-1)))) { - FSE_buildCTable_wksp(CTable_MatchLength, ML_defaultNorm, MaxML, ML_defaultNormLog, scratchBuffer, sizeof(scratchBuffer)); - MLtype = set_basic; - } else { - size_t nbSeq_1 = nbSeq; - const U32 tableLog = FSE_optimalTableLog(MLFSELog, nbSeq, max); - if (count[mlCodeTable[nbSeq-1]]>1) { count[mlCodeTable[nbSeq-1]]--; nbSeq_1--; } - FSE_normalizeCount(norm, tableLog, count, nbSeq_1, max); - { size_t const NCountSize = FSE_writeNCount(op, oend-op, norm, max, tableLog); /* overflow protected */ - if (FSE_isError(NCountSize)) return NCountSize; - op += NCountSize; } - FSE_buildCTable_wksp(CTable_MatchLength, norm, max, tableLog, scratchBuffer, sizeof(scratchBuffer)); - MLtype = set_compressed; + size_t const mostFrequent = FSE_countFast_wksp(count, &max, mlCodeTable, nbSeq, entropy->workspace); + MLtype = ZSTD_selectEncodingType(&entropy->matchlength_repeatMode, mostFrequent, nbSeq, ML_defaultNormLog); + { size_t const countSize = ZSTD_buildCTable(op, oend - op, CTable_MatchLength, MLFSELog, (symbolEncodingType_e)MLtype, + count, max, mlCodeTable, nbSeq, ML_defaultNorm, ML_defaultNormLog, MaxML, + entropy->workspace, sizeof(entropy->workspace)); + if (ZSTD_isError(countSize)) return countSize; + op += countSize; } } *seqHead = (BYTE)((LLtype<<6) + (Offtype<<4) + (MLtype<<2)); - zc->fseCTables_ready = 0; - - /* Encoding Sequences */ - { BIT_CStream_t blockStream; - FSE_CState_t stateMatchLength; - FSE_CState_t stateOffsetBits; - FSE_CState_t stateLitLength; - - CHECK_E(BIT_initCStream(&blockStream, op, oend-op), dstSize_tooSmall); /* not enough space remaining */ - - /* first symbols */ - FSE_initCState2(&stateMatchLength, CTable_MatchLength, mlCodeTable[nbSeq-1]); - FSE_initCState2(&stateOffsetBits, CTable_OffsetBits, ofCodeTable[nbSeq-1]); - FSE_initCState2(&stateLitLength, CTable_LitLength, llCodeTable[nbSeq-1]); - BIT_addBits(&blockStream, sequences[nbSeq-1].litLength, LL_bits[llCodeTable[nbSeq-1]]); - if (MEM_32bits()) BIT_flushBits(&blockStream); - BIT_addBits(&blockStream, sequences[nbSeq-1].matchLength, ML_bits[mlCodeTable[nbSeq-1]]); - if (MEM_32bits()) BIT_flushBits(&blockStream); - if (longOffsets) { - U32 const ofBits = ofCodeTable[nbSeq-1]; - int const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN-1); - if (extraBits) { - BIT_addBits(&blockStream, sequences[nbSeq-1].offset, extraBits); - BIT_flushBits(&blockStream); - } - BIT_addBits(&blockStream, sequences[nbSeq-1].offset >> extraBits, - ofBits - extraBits); - } else { - BIT_addBits(&blockStream, sequences[nbSeq-1].offset, ofCodeTable[nbSeq-1]); - } - BIT_flushBits(&blockStream); - - { size_t n; - for (n=nbSeq-2 ; n<nbSeq ; n--) { /* intentional underflow */ - BYTE const llCode = llCodeTable[n]; - BYTE const ofCode = ofCodeTable[n]; - BYTE const mlCode = mlCodeTable[n]; - U32 const llBits = LL_bits[llCode]; - U32 const ofBits = ofCode; /* 32b*/ /* 64b*/ - U32 const mlBits = ML_bits[mlCode]; - /* (7)*/ /* (7)*/ - FSE_encodeSymbol(&blockStream, &stateOffsetBits, ofCode); /* 15 */ /* 15 */ - FSE_encodeSymbol(&blockStream, &stateMatchLength, mlCode); /* 24 */ /* 24 */ - if (MEM_32bits()) BIT_flushBits(&blockStream); /* (7)*/ - FSE_encodeSymbol(&blockStream, &stateLitLength, llCode); /* 16 */ /* 33 */ - if (MEM_32bits() || (ofBits+mlBits+llBits >= 64-7-(LLFSELog+MLFSELog+OffFSELog))) - BIT_flushBits(&blockStream); /* (7)*/ - BIT_addBits(&blockStream, sequences[n].litLength, llBits); - if (MEM_32bits() && ((llBits+mlBits)>24)) BIT_flushBits(&blockStream); - BIT_addBits(&blockStream, sequences[n].matchLength, mlBits); - if (MEM_32bits()) BIT_flushBits(&blockStream); /* (7)*/ - if (longOffsets) { - int const extraBits = ofBits - MIN(ofBits, STREAM_ACCUMULATOR_MIN-1); - if (extraBits) { - BIT_addBits(&blockStream, sequences[n].offset, extraBits); - BIT_flushBits(&blockStream); /* (7)*/ - } - BIT_addBits(&blockStream, sequences[n].offset >> extraBits, - ofBits - extraBits); /* 31 */ - } else { - BIT_addBits(&blockStream, sequences[n].offset, ofBits); /* 31 */ - } - BIT_flushBits(&blockStream); /* (7)*/ - } } - FSE_flushCState(&blockStream, &stateMatchLength); - FSE_flushCState(&blockStream, &stateOffsetBits); - FSE_flushCState(&blockStream, &stateLitLength); + { size_t const streamSize = ZSTD_encodeSequences(op, oend - op, + CTable_MatchLength, mlCodeTable, + CTable_OffsetBits, ofCodeTable, + CTable_LitLength, llCodeTable, + sequences, nbSeq, longOffsets); + if (ZSTD_isError(streamSize)) return streamSize; + op += streamSize; + } - { size_t const streamSize = BIT_closeCStream(&blockStream); - if (streamSize==0) return ERROR(dstSize_tooSmall); /* not enough space */ - op += streamSize; - } } + return op - ostart; +} - /* check compressibility */ -_check_compressibility: - { size_t const minGain = ZSTD_minGain(srcSize); - size_t const maxCSize = srcSize - minGain; - if ((size_t)(op-ostart) >= maxCSize) { - zc->hufCTable_repeatMode = HUF_repeat_none; - return 0; - } } +MEM_STATIC size_t ZSTD_compressSequences(seqStore_t* seqStorePtr, + ZSTD_entropyCTables_t* entropy, + ZSTD_compressionParameters const* cParams, + void* dst, size_t dstCapacity, + size_t srcSize) +{ + size_t const cSize = ZSTD_compressSequences_internal(seqStorePtr, entropy, cParams, + dst, dstCapacity); + size_t const minGain = ZSTD_minGain(srcSize); + size_t const maxCSize = srcSize - minGain; + /* If the srcSize <= dstCapacity, then there is enough space to write a + * raw uncompressed block. Since we ran out of space, the block must not + * be compressible, so fall back to a raw uncompressed block. + */ + int const uncompressibleError = cSize == ERROR(dstSize_tooSmall) && srcSize <= dstCapacity; + + if (ZSTD_isError(cSize) && !uncompressibleError) + return cSize; + /* Check compressibility */ + if (cSize >= maxCSize || uncompressibleError) { + entropy->hufCTable_repeatMode = HUF_repeat_none; + entropy->offcode_repeatMode = FSE_repeat_none; + entropy->matchlength_repeatMode = FSE_repeat_none; + entropy->litlength_repeatMode = FSE_repeat_none; + return 0; + } + assert(!ZSTD_isError(cSize)); /* confirm repcodes */ - { int i; for (i=0; i<ZSTD_REP_NUM; i++) zc->rep[i] = zc->repToConfirm[i]; } - - return op - ostart; + { int i; for (i=0; i<ZSTD_REP_NUM; i++) seqStorePtr->rep[i] = seqStorePtr->repToConfirm[i]; } + return cSize; } @@ -1475,7 +1483,7 @@ static void ZSTD_fillHashTable (ZSTD_CCtx* zc, const void* end, const U32 mls) } -FORCE_INLINE +FORCE_INLINE_TEMPLATE void ZSTD_compressBlock_fast_generic(ZSTD_CCtx* cctx, const void* src, size_t srcSize, const U32 mls) @@ -1491,7 +1499,7 @@ void ZSTD_compressBlock_fast_generic(ZSTD_CCtx* cctx, const BYTE* const lowest = base + lowestIndex; const BYTE* const iend = istart + srcSize; const BYTE* const ilimit = iend - HASH_READ_SIZE; - U32 offset_1=cctx->rep[0], offset_2=cctx->rep[1]; + U32 offset_1=seqStorePtr->rep[0], offset_2=seqStorePtr->rep[1]; U32 offsetSaved = 0; /* init */ @@ -1552,8 +1560,8 @@ void ZSTD_compressBlock_fast_generic(ZSTD_CCtx* cctx, } } } /* save reps for next block */ - cctx->repToConfirm[0] = offset_1 ? offset_1 : offsetSaved; - cctx->repToConfirm[1] = offset_2 ? offset_2 : offsetSaved; + seqStorePtr->repToConfirm[0] = offset_1 ? offset_1 : offsetSaved; + seqStorePtr->repToConfirm[1] = offset_2 ? offset_2 : offsetSaved; /* Last Literals */ { size_t const lastLLSize = iend - anchor; @@ -1601,7 +1609,7 @@ static void ZSTD_compressBlock_fast_extDict_generic(ZSTD_CCtx* ctx, const BYTE* const dictEnd = dictBase + dictLimit; const BYTE* const iend = istart + srcSize; const BYTE* const ilimit = iend - 8; - U32 offset_1=ctx->rep[0], offset_2=ctx->rep[1]; + U32 offset_1=seqStorePtr->rep[0], offset_2=seqStorePtr->rep[1]; /* Search Loop */ while (ip < ilimit) { /* < instead of <=, because (ip+1) */ @@ -1667,7 +1675,7 @@ static void ZSTD_compressBlock_fast_extDict_generic(ZSTD_CCtx* ctx, } } } /* save reps for next block */ - ctx->repToConfirm[0] = offset_1; ctx->repToConfirm[1] = offset_2; + seqStorePtr->repToConfirm[0] = offset_1; seqStorePtr->repToConfirm[1] = offset_2; /* Last Literals */ { size_t const lastLLSize = iend - anchor; @@ -1718,7 +1726,7 @@ static void ZSTD_fillDoubleHashTable (ZSTD_CCtx* cctx, const void* end, const U3 } -FORCE_INLINE +FORCE_INLINE_TEMPLATE void ZSTD_compressBlock_doubleFast_generic(ZSTD_CCtx* cctx, const void* src, size_t srcSize, const U32 mls) @@ -1736,7 +1744,7 @@ void ZSTD_compressBlock_doubleFast_generic(ZSTD_CCtx* cctx, const BYTE* const lowest = base + lowestIndex; const BYTE* const iend = istart + srcSize; const BYTE* const ilimit = iend - HASH_READ_SIZE; - U32 offset_1=cctx->rep[0], offset_2=cctx->rep[1]; + U32 offset_1=seqStorePtr->rep[0], offset_2=seqStorePtr->rep[1]; U32 offsetSaved = 0; /* init */ @@ -1823,8 +1831,8 @@ void ZSTD_compressBlock_doubleFast_generic(ZSTD_CCtx* cctx, } } } /* save reps for next block */ - cctx->repToConfirm[0] = offset_1 ? offset_1 : offsetSaved; - cctx->repToConfirm[1] = offset_2 ? offset_2 : offsetSaved; + seqStorePtr->repToConfirm[0] = offset_1 ? offset_1 : offsetSaved; + seqStorePtr->repToConfirm[1] = offset_2 ? offset_2 : offsetSaved; /* Last Literals */ { size_t const lastLLSize = iend - anchor; @@ -1873,7 +1881,7 @@ static void ZSTD_compressBlock_doubleFast_extDict_generic(ZSTD_CCtx* ctx, const BYTE* const dictEnd = dictBase + dictLimit; const BYTE* const iend = istart + srcSize; const BYTE* const ilimit = iend - 8; - U32 offset_1=ctx->rep[0], offset_2=ctx->rep[1]; + U32 offset_1=seqStorePtr->rep[0], offset_2=seqStorePtr->rep[1]; /* Search Loop */ while (ip < ilimit) { /* < instead of <=, because (ip+1) */ @@ -1973,7 +1981,7 @@ static void ZSTD_compressBlock_doubleFast_extDict_generic(ZSTD_CCtx* ctx, } } } /* save reps for next block */ - ctx->repToConfirm[0] = offset_1; ctx->repToConfirm[1] = offset_2; + seqStorePtr->repToConfirm[0] = offset_1; seqStorePtr->repToConfirm[1] = offset_2; /* Last Literals */ { size_t const lastLLSize = iend - anchor; @@ -2276,7 +2284,7 @@ static size_t ZSTD_BtFindBestMatch_selectMLS_extDict ( /* Update chains up to ip (excluded) Assumption : always within prefix (i.e. not within extDict) */ -FORCE_INLINE +FORCE_INLINE_TEMPLATE U32 ZSTD_insertAndFindFirstIndex (ZSTD_CCtx* zc, const BYTE* ip, U32 mls) { U32* const hashTable = zc->hashTable; @@ -2300,7 +2308,7 @@ U32 ZSTD_insertAndFindFirstIndex (ZSTD_CCtx* zc, const BYTE* ip, U32 mls) /* inlining is important to hardwire a hot branch (template emulation) */ -FORCE_INLINE +FORCE_INLINE_TEMPLATE size_t ZSTD_HcFindBestMatch_generic ( ZSTD_CCtx* zc, /* Index table will be updated */ const BYTE* const ip, const BYTE* const iLimit, @@ -2352,7 +2360,7 @@ size_t ZSTD_HcFindBestMatch_generic ( } -FORCE_INLINE size_t ZSTD_HcFindBestMatch_selectMLS ( +FORCE_INLINE_TEMPLATE size_t ZSTD_HcFindBestMatch_selectMLS ( ZSTD_CCtx* zc, const BYTE* ip, const BYTE* const iLimit, size_t* offsetPtr, @@ -2369,7 +2377,7 @@ FORCE_INLINE size_t ZSTD_HcFindBestMatch_selectMLS ( } -FORCE_INLINE size_t ZSTD_HcFindBestMatch_extDict_selectMLS ( +FORCE_INLINE_TEMPLATE size_t ZSTD_HcFindBestMatch_extDict_selectMLS ( ZSTD_CCtx* zc, const BYTE* ip, const BYTE* const iLimit, size_t* offsetPtr, @@ -2389,7 +2397,7 @@ FORCE_INLINE size_t ZSTD_HcFindBestMatch_extDict_selectMLS ( /* ******************************* * Common parser - lazy strategy *********************************/ -FORCE_INLINE +FORCE_INLINE_TEMPLATE void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx, const void* src, size_t srcSize, const U32 searchMethod, const U32 depth) @@ -2409,7 +2417,7 @@ void ZSTD_compressBlock_lazy_generic(ZSTD_CCtx* ctx, size_t* offsetPtr, U32 maxNbAttempts, U32 matchLengthSearch); searchMax_f const searchMax = searchMethod ? ZSTD_BtFindBestMatch_selectMLS : ZSTD_HcFindBestMatch_selectMLS; - U32 offset_1 = ctx->rep[0], offset_2 = ctx->rep[1], savedOffset=0; + U32 offset_1 = seqStorePtr->rep[0], offset_2 = seqStorePtr->rep[1], savedOffset=0; /* init */ ip += (ip==base); @@ -2519,8 +2527,8 @@ _storeSequence: } } /* Save reps for next block */ - ctx->repToConfirm[0] = offset_1 ? offset_1 : savedOffset; - ctx->repToConfirm[1] = offset_2 ? offset_2 : savedOffset; + seqStorePtr->repToConfirm[0] = offset_1 ? offset_1 : savedOffset; + seqStorePtr->repToConfirm[1] = offset_2 ? offset_2 : savedOffset; /* Last Literals */ { size_t const lastLLSize = iend - anchor; @@ -2551,7 +2559,7 @@ static void ZSTD_compressBlock_greedy(ZSTD_CCtx* ctx, const void* src, size_t sr } -FORCE_INLINE +FORCE_INLINE_TEMPLATE void ZSTD_compressBlock_lazy_extDict_generic(ZSTD_CCtx* ctx, const void* src, size_t srcSize, const U32 searchMethod, const U32 depth) @@ -2578,7 +2586,7 @@ void ZSTD_compressBlock_lazy_extDict_generic(ZSTD_CCtx* ctx, U32 maxNbAttempts, U32 matchLengthSearch); searchMax_f searchMax = searchMethod ? ZSTD_BtFindBestMatch_selectMLS_extDict : ZSTD_HcFindBestMatch_extDict_selectMLS; - U32 offset_1 = ctx->rep[0], offset_2 = ctx->rep[1]; + U32 offset_1 = seqStorePtr->rep[0], offset_2 = seqStorePtr->rep[1]; /* init */ ctx->nextToUpdate3 = ctx->nextToUpdate; @@ -2714,7 +2722,7 @@ _storeSequence: } } /* Save reps for next block */ - ctx->repToConfirm[0] = offset_1; ctx->repToConfirm[1] = offset_2; + seqStorePtr->repToConfirm[0] = offset_1; seqStorePtr->repToConfirm[1] = offset_2; /* Last Literals */ { size_t const lastLLSize = iend - anchor; @@ -2823,7 +2831,7 @@ static size_t ZSTD_compressBlock_internal(ZSTD_CCtx* zc, void* dst, size_t dstCa if (current > zc->nextToUpdate + 384) zc->nextToUpdate = current - MIN(192, (U32)(current - zc->nextToUpdate - 384)); /* limited update after finding a very long match */ blockCompressor(zc, src, srcSize); - return ZSTD_compressSequences(zc, dst, dstCapacity, srcSize); + return ZSTD_compressSequences(&zc->seqStore, zc->entropy, &zc->appliedParams.cParams, dst, dstCapacity, srcSize); } @@ -3000,7 +3008,6 @@ static size_t ZSTD_compressContinue_internal (ZSTD_CCtx* cctx, return fhSize; } - size_t ZSTD_compressContinue (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize) @@ -3106,13 +3113,14 @@ static size_t ZSTD_loadZstdDictionary(ZSTD_CCtx* cctx, const void* dict, size_t const BYTE* const dictEnd = dictPtr + dictSize; short offcodeNCount[MaxOff+1]; unsigned offcodeMaxValue = MaxOff; - BYTE scratchBuffer[1<<MAX(MLFSELog,LLFSELog)]; + + ZSTD_STATIC_ASSERT(sizeof(cctx->entropy->workspace) >= (1<<MAX(MLFSELog,LLFSELog))); dictPtr += 4; /* skip magic number */ cctx->dictID = cctx->appliedParams.fParams.noDictIDFlag ? 0 : MEM_readLE32(dictPtr); dictPtr += 4; - { size_t const hufHeaderSize = HUF_readCTable(cctx->hufCTable, 255, dictPtr, dictEnd-dictPtr); + { size_t const hufHeaderSize = HUF_readCTable((HUF_CElt*)cctx->entropy->hufCTable, 255, dictPtr, dictEnd-dictPtr); if (HUF_isError(hufHeaderSize)) return ERROR(dictionary_corrupted); dictPtr += hufHeaderSize; } @@ -3122,7 +3130,7 @@ static size_t ZSTD_loadZstdDictionary(ZSTD_CCtx* cctx, const void* dict, size_t if (FSE_isError(offcodeHeaderSize)) return ERROR(dictionary_corrupted); if (offcodeLog > OffFSELog) return ERROR(dictionary_corrupted); /* Defer checking offcodeMaxValue because we need to know the size of the dictionary content */ - CHECK_E( FSE_buildCTable_wksp(cctx->offcodeCTable, offcodeNCount, offcodeMaxValue, offcodeLog, scratchBuffer, sizeof(scratchBuffer)), + CHECK_E( FSE_buildCTable_wksp(cctx->entropy->offcodeCTable, offcodeNCount, offcodeMaxValue, offcodeLog, cctx->entropy->workspace, sizeof(cctx->entropy->workspace)), dictionary_corrupted); dictPtr += offcodeHeaderSize; } @@ -3134,7 +3142,7 @@ static size_t ZSTD_loadZstdDictionary(ZSTD_CCtx* cctx, const void* dict, size_t if (matchlengthLog > MLFSELog) return ERROR(dictionary_corrupted); /* Every match length code must have non-zero probability */ CHECK_F( ZSTD_checkDictNCount(matchlengthNCount, matchlengthMaxValue, MaxML)); - CHECK_E( FSE_buildCTable_wksp(cctx->matchlengthCTable, matchlengthNCount, matchlengthMaxValue, matchlengthLog, scratchBuffer, sizeof(scratchBuffer)), + CHECK_E( FSE_buildCTable_wksp(cctx->entropy->matchlengthCTable, matchlengthNCount, matchlengthMaxValue, matchlengthLog, cctx->entropy->workspace, sizeof(cctx->entropy->workspace)), dictionary_corrupted); dictPtr += matchlengthHeaderSize; } @@ -3146,15 +3154,15 @@ static size_t ZSTD_loadZstdDictionary(ZSTD_CCtx* cctx, const void* dict, size_t if (litlengthLog > LLFSELog) return ERROR(dictionary_corrupted); /* Every literal length code must have non-zero probability */ CHECK_F( ZSTD_checkDictNCount(litlengthNCount, litlengthMaxValue, MaxLL)); - CHECK_E( FSE_buildCTable_wksp(cctx->litlengthCTable, litlengthNCount, litlengthMaxValue, litlengthLog, scratchBuffer, sizeof(scratchBuffer)), + CHECK_E( FSE_buildCTable_wksp(cctx->entropy->litlengthCTable, litlengthNCount, litlengthMaxValue, litlengthLog, cctx->entropy->workspace, sizeof(cctx->entropy->workspace)), dictionary_corrupted); dictPtr += litlengthHeaderSize; } if (dictPtr+12 > dictEnd) return ERROR(dictionary_corrupted); - cctx->rep[0] = MEM_readLE32(dictPtr+0); - cctx->rep[1] = MEM_readLE32(dictPtr+4); - cctx->rep[2] = MEM_readLE32(dictPtr+8); + cctx->seqStore.rep[0] = MEM_readLE32(dictPtr+0); + cctx->seqStore.rep[1] = MEM_readLE32(dictPtr+4); + cctx->seqStore.rep[2] = MEM_readLE32(dictPtr+8); dictPtr += 12; { size_t const dictContentSize = (size_t)(dictEnd - dictPtr); @@ -3168,12 +3176,14 @@ static size_t ZSTD_loadZstdDictionary(ZSTD_CCtx* cctx, const void* dict, size_t /* All repCodes must be <= dictContentSize and != 0*/ { U32 u; for (u=0; u<3; u++) { - if (cctx->rep[u] == 0) return ERROR(dictionary_corrupted); - if (cctx->rep[u] > dictContentSize) return ERROR(dictionary_corrupted); + if (cctx->seqStore.rep[u] == 0) return ERROR(dictionary_corrupted); + if (cctx->seqStore.rep[u] > dictContentSize) return ERROR(dictionary_corrupted); } } - cctx->fseCTables_ready = 1; - cctx->hufCTable_repeatMode = HUF_repeat_valid; + cctx->entropy->hufCTable_repeatMode = HUF_repeat_valid; + cctx->entropy->offcode_repeatMode = FSE_repeat_valid; + cctx->entropy->matchlength_repeatMode = FSE_repeat_valid; + cctx->entropy->litlength_repeatMode = FSE_repeat_valid; return ZSTD_loadDictionaryContent(cctx, dictPtr, dictContentSize); } } diff --git a/thirdparty/zstd/compress/zstd_opt.h b/thirdparty/zstd/compress/zstd_opt.h index e8e98915ea..ae24732c7d 100644 --- a/thirdparty/zstd/compress/zstd_opt.h +++ b/thirdparty/zstd/compress/zstd_opt.h @@ -1,10 +1,10 @@ -/** - * Copyright (c) 2016-present, Przemyslaw Skibinski, Yann Collet, Facebook, Inc. +/* + * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ @@ -22,173 +22,173 @@ /*-************************************* * Price functions for optimal parser ***************************************/ -FORCE_INLINE void ZSTD_setLog2Prices(seqStore_t* ssPtr) +static void ZSTD_setLog2Prices(optState_t* optPtr) { - ssPtr->log2matchLengthSum = ZSTD_highbit32(ssPtr->matchLengthSum+1); - ssPtr->log2litLengthSum = ZSTD_highbit32(ssPtr->litLengthSum+1); - ssPtr->log2litSum = ZSTD_highbit32(ssPtr->litSum+1); - ssPtr->log2offCodeSum = ZSTD_highbit32(ssPtr->offCodeSum+1); - ssPtr->factor = 1 + ((ssPtr->litSum>>5) / ssPtr->litLengthSum) + ((ssPtr->litSum<<1) / (ssPtr->litSum + ssPtr->matchSum)); + optPtr->log2matchLengthSum = ZSTD_highbit32(optPtr->matchLengthSum+1); + optPtr->log2litLengthSum = ZSTD_highbit32(optPtr->litLengthSum+1); + optPtr->log2litSum = ZSTD_highbit32(optPtr->litSum+1); + optPtr->log2offCodeSum = ZSTD_highbit32(optPtr->offCodeSum+1); + optPtr->factor = 1 + ((optPtr->litSum>>5) / optPtr->litLengthSum) + ((optPtr->litSum<<1) / (optPtr->litSum + optPtr->matchSum)); } -MEM_STATIC void ZSTD_rescaleFreqs(seqStore_t* ssPtr, const BYTE* src, size_t srcSize) +static void ZSTD_rescaleFreqs(optState_t* optPtr, const BYTE* src, size_t srcSize) { unsigned u; - ssPtr->cachedLiterals = NULL; - ssPtr->cachedPrice = ssPtr->cachedLitLength = 0; - ssPtr->staticPrices = 0; + optPtr->cachedLiterals = NULL; + optPtr->cachedPrice = optPtr->cachedLitLength = 0; + optPtr->staticPrices = 0; - if (ssPtr->litLengthSum == 0) { - if (srcSize <= 1024) ssPtr->staticPrices = 1; + if (optPtr->litLengthSum == 0) { + if (srcSize <= 1024) optPtr->staticPrices = 1; - assert(ssPtr->litFreq!=NULL); + assert(optPtr->litFreq!=NULL); for (u=0; u<=MaxLit; u++) - ssPtr->litFreq[u] = 0; + optPtr->litFreq[u] = 0; for (u=0; u<srcSize; u++) - ssPtr->litFreq[src[u]]++; + optPtr->litFreq[src[u]]++; - ssPtr->litSum = 0; - ssPtr->litLengthSum = MaxLL+1; - ssPtr->matchLengthSum = MaxML+1; - ssPtr->offCodeSum = (MaxOff+1); - ssPtr->matchSum = (ZSTD_LITFREQ_ADD<<Litbits); + optPtr->litSum = 0; + optPtr->litLengthSum = MaxLL+1; + optPtr->matchLengthSum = MaxML+1; + optPtr->offCodeSum = (MaxOff+1); + optPtr->matchSum = (ZSTD_LITFREQ_ADD<<Litbits); for (u=0; u<=MaxLit; u++) { - ssPtr->litFreq[u] = 1 + (ssPtr->litFreq[u]>>ZSTD_FREQ_DIV); - ssPtr->litSum += ssPtr->litFreq[u]; + optPtr->litFreq[u] = 1 + (optPtr->litFreq[u]>>ZSTD_FREQ_DIV); + optPtr->litSum += optPtr->litFreq[u]; } for (u=0; u<=MaxLL; u++) - ssPtr->litLengthFreq[u] = 1; + optPtr->litLengthFreq[u] = 1; for (u=0; u<=MaxML; u++) - ssPtr->matchLengthFreq[u] = 1; + optPtr->matchLengthFreq[u] = 1; for (u=0; u<=MaxOff; u++) - ssPtr->offCodeFreq[u] = 1; + optPtr->offCodeFreq[u] = 1; } else { - ssPtr->matchLengthSum = 0; - ssPtr->litLengthSum = 0; - ssPtr->offCodeSum = 0; - ssPtr->matchSum = 0; - ssPtr->litSum = 0; + optPtr->matchLengthSum = 0; + optPtr->litLengthSum = 0; + optPtr->offCodeSum = 0; + optPtr->matchSum = 0; + optPtr->litSum = 0; for (u=0; u<=MaxLit; u++) { - ssPtr->litFreq[u] = 1 + (ssPtr->litFreq[u]>>(ZSTD_FREQ_DIV+1)); - ssPtr->litSum += ssPtr->litFreq[u]; + optPtr->litFreq[u] = 1 + (optPtr->litFreq[u]>>(ZSTD_FREQ_DIV+1)); + optPtr->litSum += optPtr->litFreq[u]; } for (u=0; u<=MaxLL; u++) { - ssPtr->litLengthFreq[u] = 1 + (ssPtr->litLengthFreq[u]>>(ZSTD_FREQ_DIV+1)); - ssPtr->litLengthSum += ssPtr->litLengthFreq[u]; + optPtr->litLengthFreq[u] = 1 + (optPtr->litLengthFreq[u]>>(ZSTD_FREQ_DIV+1)); + optPtr->litLengthSum += optPtr->litLengthFreq[u]; } for (u=0; u<=MaxML; u++) { - ssPtr->matchLengthFreq[u] = 1 + (ssPtr->matchLengthFreq[u]>>ZSTD_FREQ_DIV); - ssPtr->matchLengthSum += ssPtr->matchLengthFreq[u]; - ssPtr->matchSum += ssPtr->matchLengthFreq[u] * (u + 3); + optPtr->matchLengthFreq[u] = 1 + (optPtr->matchLengthFreq[u]>>ZSTD_FREQ_DIV); + optPtr->matchLengthSum += optPtr->matchLengthFreq[u]; + optPtr->matchSum += optPtr->matchLengthFreq[u] * (u + 3); } - ssPtr->matchSum *= ZSTD_LITFREQ_ADD; + optPtr->matchSum *= ZSTD_LITFREQ_ADD; for (u=0; u<=MaxOff; u++) { - ssPtr->offCodeFreq[u] = 1 + (ssPtr->offCodeFreq[u]>>ZSTD_FREQ_DIV); - ssPtr->offCodeSum += ssPtr->offCodeFreq[u]; + optPtr->offCodeFreq[u] = 1 + (optPtr->offCodeFreq[u]>>ZSTD_FREQ_DIV); + optPtr->offCodeSum += optPtr->offCodeFreq[u]; } } - ZSTD_setLog2Prices(ssPtr); + ZSTD_setLog2Prices(optPtr); } -FORCE_INLINE U32 ZSTD_getLiteralPrice(seqStore_t* ssPtr, U32 litLength, const BYTE* literals) +static U32 ZSTD_getLiteralPrice(optState_t* optPtr, U32 litLength, const BYTE* literals) { U32 price, u; - if (ssPtr->staticPrices) + if (optPtr->staticPrices) return ZSTD_highbit32((U32)litLength+1) + (litLength*6); if (litLength == 0) - return ssPtr->log2litLengthSum - ZSTD_highbit32(ssPtr->litLengthFreq[0]+1); + return optPtr->log2litLengthSum - ZSTD_highbit32(optPtr->litLengthFreq[0]+1); /* literals */ - if (ssPtr->cachedLiterals == literals) { - U32 const additional = litLength - ssPtr->cachedLitLength; - const BYTE* literals2 = ssPtr->cachedLiterals + ssPtr->cachedLitLength; - price = ssPtr->cachedPrice + additional * ssPtr->log2litSum; + if (optPtr->cachedLiterals == literals) { + U32 const additional = litLength - optPtr->cachedLitLength; + const BYTE* literals2 = optPtr->cachedLiterals + optPtr->cachedLitLength; + price = optPtr->cachedPrice + additional * optPtr->log2litSum; for (u=0; u < additional; u++) - price -= ZSTD_highbit32(ssPtr->litFreq[literals2[u]]+1); - ssPtr->cachedPrice = price; - ssPtr->cachedLitLength = litLength; + price -= ZSTD_highbit32(optPtr->litFreq[literals2[u]]+1); + optPtr->cachedPrice = price; + optPtr->cachedLitLength = litLength; } else { - price = litLength * ssPtr->log2litSum; + price = litLength * optPtr->log2litSum; for (u=0; u < litLength; u++) - price -= ZSTD_highbit32(ssPtr->litFreq[literals[u]]+1); + price -= ZSTD_highbit32(optPtr->litFreq[literals[u]]+1); if (litLength >= 12) { - ssPtr->cachedLiterals = literals; - ssPtr->cachedPrice = price; - ssPtr->cachedLitLength = litLength; + optPtr->cachedLiterals = literals; + optPtr->cachedPrice = price; + optPtr->cachedLitLength = litLength; } } /* literal Length */ { const BYTE LL_deltaCode = 19; const BYTE llCode = (litLength>63) ? (BYTE)ZSTD_highbit32(litLength) + LL_deltaCode : LL_Code[litLength]; - price += LL_bits[llCode] + ssPtr->log2litLengthSum - ZSTD_highbit32(ssPtr->litLengthFreq[llCode]+1); + price += LL_bits[llCode] + optPtr->log2litLengthSum - ZSTD_highbit32(optPtr->litLengthFreq[llCode]+1); } return price; } -FORCE_INLINE U32 ZSTD_getPrice(seqStore_t* seqStorePtr, U32 litLength, const BYTE* literals, U32 offset, U32 matchLength, const int ultra) +FORCE_INLINE_TEMPLATE U32 ZSTD_getPrice(optState_t* optPtr, U32 litLength, const BYTE* literals, U32 offset, U32 matchLength, const int ultra) { /* offset */ U32 price; BYTE const offCode = (BYTE)ZSTD_highbit32(offset+1); - if (seqStorePtr->staticPrices) - return ZSTD_getLiteralPrice(seqStorePtr, litLength, literals) + ZSTD_highbit32((U32)matchLength+1) + 16 + offCode; + if (optPtr->staticPrices) + return ZSTD_getLiteralPrice(optPtr, litLength, literals) + ZSTD_highbit32((U32)matchLength+1) + 16 + offCode; - price = offCode + seqStorePtr->log2offCodeSum - ZSTD_highbit32(seqStorePtr->offCodeFreq[offCode]+1); + price = offCode + optPtr->log2offCodeSum - ZSTD_highbit32(optPtr->offCodeFreq[offCode]+1); if (!ultra && offCode >= 20) price += (offCode-19)*2; /* match Length */ { const BYTE ML_deltaCode = 36; const BYTE mlCode = (matchLength>127) ? (BYTE)ZSTD_highbit32(matchLength) + ML_deltaCode : ML_Code[matchLength]; - price += ML_bits[mlCode] + seqStorePtr->log2matchLengthSum - ZSTD_highbit32(seqStorePtr->matchLengthFreq[mlCode]+1); + price += ML_bits[mlCode] + optPtr->log2matchLengthSum - ZSTD_highbit32(optPtr->matchLengthFreq[mlCode]+1); } - return price + ZSTD_getLiteralPrice(seqStorePtr, litLength, literals) + seqStorePtr->factor; + return price + ZSTD_getLiteralPrice(optPtr, litLength, literals) + optPtr->factor; } -MEM_STATIC void ZSTD_updatePrice(seqStore_t* seqStorePtr, U32 litLength, const BYTE* literals, U32 offset, U32 matchLength) +static void ZSTD_updatePrice(optState_t* optPtr, U32 litLength, const BYTE* literals, U32 offset, U32 matchLength) { U32 u; /* literals */ - seqStorePtr->litSum += litLength*ZSTD_LITFREQ_ADD; + optPtr->litSum += litLength*ZSTD_LITFREQ_ADD; for (u=0; u < litLength; u++) - seqStorePtr->litFreq[literals[u]] += ZSTD_LITFREQ_ADD; + optPtr->litFreq[literals[u]] += ZSTD_LITFREQ_ADD; /* literal Length */ { const BYTE LL_deltaCode = 19; const BYTE llCode = (litLength>63) ? (BYTE)ZSTD_highbit32(litLength) + LL_deltaCode : LL_Code[litLength]; - seqStorePtr->litLengthFreq[llCode]++; - seqStorePtr->litLengthSum++; + optPtr->litLengthFreq[llCode]++; + optPtr->litLengthSum++; } /* match offset */ { BYTE const offCode = (BYTE)ZSTD_highbit32(offset+1); - seqStorePtr->offCodeSum++; - seqStorePtr->offCodeFreq[offCode]++; + optPtr->offCodeSum++; + optPtr->offCodeFreq[offCode]++; } /* match Length */ { const BYTE ML_deltaCode = 36; const BYTE mlCode = (matchLength>127) ? (BYTE)ZSTD_highbit32(matchLength) + ML_deltaCode : ML_Code[matchLength]; - seqStorePtr->matchLengthFreq[mlCode]++; - seqStorePtr->matchLengthSum++; + optPtr->matchLengthFreq[mlCode]++; + optPtr->matchLengthSum++; } - ZSTD_setLog2Prices(seqStorePtr); + ZSTD_setLog2Prices(optPtr); } @@ -203,7 +203,7 @@ MEM_STATIC void ZSTD_updatePrice(seqStore_t* seqStorePtr, U32 litLength, const B /* function safe only for comparisons */ -MEM_STATIC U32 ZSTD_readMINMATCH(const void* memPtr, U32 length) +static U32 ZSTD_readMINMATCH(const void* memPtr, U32 length) { switch (length) { @@ -219,7 +219,7 @@ MEM_STATIC U32 ZSTD_readMINMATCH(const void* memPtr, U32 length) /* Update hashTable3 up to ip (excluded) Assumption : always within prefix (i.e. not within extDict) */ -FORCE_INLINE +static U32 ZSTD_insertAndFindFirstIndexHash3 (ZSTD_CCtx* zc, const BYTE* ip) { U32* const hashTable3 = zc->hashTable3; @@ -412,11 +412,12 @@ static U32 ZSTD_BtGetAllMatches_selectMLS_extDict ( /*-******************************* * Optimal parser *********************************/ -FORCE_INLINE +FORCE_INLINE_TEMPLATE void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx, const void* src, size_t srcSize, const int ultra) { seqStore_t* seqStorePtr = &(ctx->seqStore); + optState_t* optStatePtr = &(ctx->optState); const BYTE* const istart = (const BYTE*)src; const BYTE* ip = istart; const BYTE* anchor = istart; @@ -430,16 +431,16 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx, const U32 mls = ctx->appliedParams.cParams.searchLength; const U32 minMatch = (ctx->appliedParams.cParams.searchLength == 3) ? 3 : 4; - ZSTD_optimal_t* opt = seqStorePtr->priceTable; - ZSTD_match_t* matches = seqStorePtr->matchTable; + ZSTD_optimal_t* opt = optStatePtr->priceTable; + ZSTD_match_t* matches = optStatePtr->matchTable; const BYTE* inr; U32 offset, rep[ZSTD_REP_NUM]; /* init */ ctx->nextToUpdate3 = ctx->nextToUpdate; - ZSTD_rescaleFreqs(seqStorePtr, (const BYTE*)src, srcSize); + ZSTD_rescaleFreqs(optStatePtr, (const BYTE*)src, srcSize); ip += (ip==prefixStart); - { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) rep[i]=ctx->rep[i]; } + { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) rep[i]=seqStorePtr->rep[i]; } /* Match Loop */ while (ip < ilimit) { @@ -462,7 +463,7 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx, } best_off = i - (ip == anchor); do { - price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); + price = ZSTD_getPrice(optStatePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); if (mlen > last_pos || price < opt[mlen].price) SET_PRICE(mlen, mlen, i, litlen, price); /* note : macro modifies last_pos */ mlen--; @@ -487,7 +488,7 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx, mlen = (u>0) ? matches[u-1].len+1 : best_mlen; best_mlen = matches[u].len; while (mlen <= best_mlen) { - price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off-1, mlen - MINMATCH, ultra); + price = ZSTD_getPrice(optStatePtr, litlen, anchor, matches[u].off-1, mlen - MINMATCH, ultra); if (mlen > last_pos || price < opt[mlen].price) SET_PRICE(mlen, mlen, matches[u].off, litlen, price); /* note : macro modifies last_pos */ mlen++; @@ -507,12 +508,12 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx, if (opt[cur-1].mlen == 1) { litlen = opt[cur-1].litlen + 1; if (cur > litlen) { - price = opt[cur - litlen].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr-litlen); + price = opt[cur - litlen].price + ZSTD_getLiteralPrice(optStatePtr, litlen, inr-litlen); } else - price = ZSTD_getLiteralPrice(seqStorePtr, litlen, anchor); + price = ZSTD_getLiteralPrice(optStatePtr, litlen, anchor); } else { litlen = 1; - price = opt[cur - 1].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr-1); + price = opt[cur - 1].price + ZSTD_getLiteralPrice(optStatePtr, litlen, inr-1); } if (cur > last_pos || price <= opt[cur].price) @@ -554,12 +555,12 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx, if (opt[cur].mlen == 1) { litlen = opt[cur].litlen; if (cur > litlen) { - price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, inr-litlen, best_off, mlen - MINMATCH, ultra); + price = opt[cur - litlen].price + ZSTD_getPrice(optStatePtr, litlen, inr-litlen, best_off, mlen - MINMATCH, ultra); } else - price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); + price = ZSTD_getPrice(optStatePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); } else { litlen = 0; - price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, best_off, mlen - MINMATCH, ultra); + price = opt[cur].price + ZSTD_getPrice(optStatePtr, 0, NULL, best_off, mlen - MINMATCH, ultra); } if (cur + mlen > last_pos || price <= opt[cur + mlen].price) @@ -586,12 +587,12 @@ void ZSTD_compressBlock_opt_generic(ZSTD_CCtx* ctx, if (opt[cur].mlen == 1) { litlen = opt[cur].litlen; if (cur > litlen) - price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, ip+cur-litlen, matches[u].off-1, mlen - MINMATCH, ultra); + price = opt[cur - litlen].price + ZSTD_getPrice(optStatePtr, litlen, ip+cur-litlen, matches[u].off-1, mlen - MINMATCH, ultra); else - price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off-1, mlen - MINMATCH, ultra); + price = ZSTD_getPrice(optStatePtr, litlen, anchor, matches[u].off-1, mlen - MINMATCH, ultra); } else { litlen = 0; - price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, matches[u].off-1, mlen - MINMATCH, ultra); + price = opt[cur].price + ZSTD_getPrice(optStatePtr, 0, NULL, matches[u].off-1, mlen - MINMATCH, ultra); } if (cur + mlen > last_pos || (price < opt[cur + mlen].price)) @@ -645,13 +646,13 @@ _storeSequence: /* cur, last_pos, best_mlen, best_off have to be set */ if (litLength==0) offset--; } - ZSTD_updatePrice(seqStorePtr, litLength, anchor, offset, mlen-MINMATCH); + ZSTD_updatePrice(optStatePtr, litLength, anchor, offset, mlen-MINMATCH); ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset, mlen-MINMATCH); anchor = ip = ip + mlen; } } /* for (cur=0; cur < last_pos; ) */ /* Save reps for next block */ - { int i; for (i=0; i<ZSTD_REP_NUM; i++) ctx->repToConfirm[i] = rep[i]; } + { int i; for (i=0; i<ZSTD_REP_NUM; i++) seqStorePtr->repToConfirm[i] = rep[i]; } /* Last Literals */ { size_t const lastLLSize = iend - anchor; @@ -661,11 +662,12 @@ _storeSequence: /* cur, last_pos, best_mlen, best_off have to be set */ } -FORCE_INLINE +FORCE_INLINE_TEMPLATE void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx, const void* src, size_t srcSize, const int ultra) { seqStore_t* seqStorePtr = &(ctx->seqStore); + optState_t* optStatePtr = &(ctx->optState); const BYTE* const istart = (const BYTE*)src; const BYTE* ip = istart; const BYTE* anchor = istart; @@ -683,16 +685,16 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx, const U32 mls = ctx->appliedParams.cParams.searchLength; const U32 minMatch = (ctx->appliedParams.cParams.searchLength == 3) ? 3 : 4; - ZSTD_optimal_t* opt = seqStorePtr->priceTable; - ZSTD_match_t* matches = seqStorePtr->matchTable; + ZSTD_optimal_t* opt = optStatePtr->priceTable; + ZSTD_match_t* matches = optStatePtr->matchTable; const BYTE* inr; /* init */ U32 offset, rep[ZSTD_REP_NUM]; - { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) rep[i]=ctx->rep[i]; } + { U32 i; for (i=0; i<ZSTD_REP_NUM; i++) rep[i]=seqStorePtr->rep[i]; } ctx->nextToUpdate3 = ctx->nextToUpdate; - ZSTD_rescaleFreqs(seqStorePtr, (const BYTE*)src, srcSize); + ZSTD_rescaleFreqs(optStatePtr, (const BYTE*)src, srcSize); ip += (ip==prefixStart); /* Match Loop */ @@ -726,7 +728,7 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx, best_off = i - (ip==anchor); litlen = opt[0].litlen; do { - price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); + price = ZSTD_getPrice(optStatePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); if (mlen > last_pos || price < opt[mlen].price) SET_PRICE(mlen, mlen, i, litlen, price); /* note : macro modifies last_pos */ mlen--; @@ -756,7 +758,7 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx, best_mlen = matches[u].len; litlen = opt[0].litlen; while (mlen <= best_mlen) { - price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off-1, mlen - MINMATCH, ultra); + price = ZSTD_getPrice(optStatePtr, litlen, anchor, matches[u].off-1, mlen - MINMATCH, ultra); if (mlen > last_pos || price < opt[mlen].price) SET_PRICE(mlen, mlen, matches[u].off, litlen, price); mlen++; @@ -773,12 +775,12 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx, if (opt[cur-1].mlen == 1) { litlen = opt[cur-1].litlen + 1; if (cur > litlen) { - price = opt[cur - litlen].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr-litlen); + price = opt[cur - litlen].price + ZSTD_getLiteralPrice(optStatePtr, litlen, inr-litlen); } else - price = ZSTD_getLiteralPrice(seqStorePtr, litlen, anchor); + price = ZSTD_getLiteralPrice(optStatePtr, litlen, anchor); } else { litlen = 1; - price = opt[cur - 1].price + ZSTD_getLiteralPrice(seqStorePtr, litlen, inr-1); + price = opt[cur - 1].price + ZSTD_getLiteralPrice(optStatePtr, litlen, inr-1); } if (cur > last_pos || price <= opt[cur].price) @@ -826,12 +828,12 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx, if (opt[cur].mlen == 1) { litlen = opt[cur].litlen; if (cur > litlen) { - price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, inr-litlen, best_off, mlen - MINMATCH, ultra); + price = opt[cur - litlen].price + ZSTD_getPrice(optStatePtr, litlen, inr-litlen, best_off, mlen - MINMATCH, ultra); } else - price = ZSTD_getPrice(seqStorePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); + price = ZSTD_getPrice(optStatePtr, litlen, anchor, best_off, mlen - MINMATCH, ultra); } else { litlen = 0; - price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, best_off, mlen - MINMATCH, ultra); + price = opt[cur].price + ZSTD_getPrice(optStatePtr, 0, NULL, best_off, mlen - MINMATCH, ultra); } if (cur + mlen > last_pos || price <= opt[cur + mlen].price) @@ -858,12 +860,12 @@ void ZSTD_compressBlock_opt_extDict_generic(ZSTD_CCtx* ctx, if (opt[cur].mlen == 1) { litlen = opt[cur].litlen; if (cur > litlen) - price = opt[cur - litlen].price + ZSTD_getPrice(seqStorePtr, litlen, ip+cur-litlen, matches[u].off-1, mlen - MINMATCH, ultra); + price = opt[cur - litlen].price + ZSTD_getPrice(optStatePtr, litlen, ip+cur-litlen, matches[u].off-1, mlen - MINMATCH, ultra); else - price = ZSTD_getPrice(seqStorePtr, litlen, anchor, matches[u].off-1, mlen - MINMATCH, ultra); + price = ZSTD_getPrice(optStatePtr, litlen, anchor, matches[u].off-1, mlen - MINMATCH, ultra); } else { litlen = 0; - price = opt[cur].price + ZSTD_getPrice(seqStorePtr, 0, NULL, matches[u].off-1, mlen - MINMATCH, ultra); + price = opt[cur].price + ZSTD_getPrice(optStatePtr, 0, NULL, matches[u].off-1, mlen - MINMATCH, ultra); } if (cur + mlen > last_pos || (price < opt[cur + mlen].price)) @@ -918,13 +920,13 @@ _storeSequence: /* cur, last_pos, best_mlen, best_off have to be set */ if (litLength==0) offset--; } - ZSTD_updatePrice(seqStorePtr, litLength, anchor, offset, mlen-MINMATCH); + ZSTD_updatePrice(optStatePtr, litLength, anchor, offset, mlen-MINMATCH); ZSTD_storeSeq(seqStorePtr, litLength, anchor, offset, mlen-MINMATCH); anchor = ip = ip + mlen; } } /* for (cur=0; cur < last_pos; ) */ /* Save reps for next block */ - { int i; for (i=0; i<ZSTD_REP_NUM; i++) ctx->repToConfirm[i] = rep[i]; } + { int i; for (i=0; i<ZSTD_REP_NUM; i++) seqStorePtr->repToConfirm[i] = rep[i]; } /* Last Literals */ { size_t lastLLSize = iend - anchor; diff --git a/thirdparty/zstd/compress/zstdmt_compress.c b/thirdparty/zstd/compress/zstdmt_compress.c index 0cee01eacb..8564bc4392 100644 --- a/thirdparty/zstd/compress/zstdmt_compress.c +++ b/thirdparty/zstd/compress/zstdmt_compress.c @@ -1,15 +1,16 @@ -/** +/* * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ /* ====== Tuning parameters ====== */ -#define ZSTDMT_NBTHREADS_MAX 128 +#define ZSTDMT_NBTHREADS_MAX 256 +#define ZSTDMT_OVERLAPLOG_DEFAULT 6 /* ====== Compiler specifics ====== */ @@ -73,6 +74,7 @@ static unsigned long long GetCurrentClockTimeMicroseconds(void) /* ===== Buffer Pool ===== */ +/* a single Buffer Pool can be invoked from multiple threads in parallel */ typedef struct buffer_s { void* start; @@ -82,6 +84,8 @@ typedef struct buffer_s { static const buffer_t g_nullBuffer = { NULL, 0 }; typedef struct ZSTDMT_bufferPool_s { + pthread_mutex_t poolMutex; + size_t bufferSize; unsigned totalBuffers; unsigned nbBuffers; ZSTD_customMem cMem; @@ -90,10 +94,15 @@ typedef struct ZSTDMT_bufferPool_s { static ZSTDMT_bufferPool* ZSTDMT_createBufferPool(unsigned nbThreads, ZSTD_customMem cMem) { - unsigned const maxNbBuffers = 2*nbThreads + 2; + unsigned const maxNbBuffers = 2*nbThreads + 3; ZSTDMT_bufferPool* const bufPool = (ZSTDMT_bufferPool*)ZSTD_calloc( sizeof(ZSTDMT_bufferPool) + (maxNbBuffers-1) * sizeof(buffer_t), cMem); if (bufPool==NULL) return NULL; + if (pthread_mutex_init(&bufPool->poolMutex, NULL)) { + ZSTD_free(bufPool, cMem); + return NULL; + } + bufPool->bufferSize = 64 KB; bufPool->totalBuffers = maxNbBuffers; bufPool->nbBuffers = 0; bufPool->cMem = cMem; @@ -106,6 +115,7 @@ static void ZSTDMT_freeBufferPool(ZSTDMT_bufferPool* bufPool) if (!bufPool) return; /* compatibility with free on NULL */ for (u=0; u<bufPool->totalBuffers; u++) ZSTD_free(bufPool->bTable[u].start, bufPool->cMem); + pthread_mutex_destroy(&bufPool->poolMutex); ZSTD_free(bufPool, bufPool->cMem); } @@ -116,65 +126,85 @@ static size_t ZSTDMT_sizeof_bufferPool(ZSTDMT_bufferPool* bufPool) + (bufPool->totalBuffers - 1) * sizeof(buffer_t); unsigned u; size_t totalBufferSize = 0; + pthread_mutex_lock(&bufPool->poolMutex); for (u=0; u<bufPool->totalBuffers; u++) totalBufferSize += bufPool->bTable[u].size; + pthread_mutex_unlock(&bufPool->poolMutex); return poolSize + totalBufferSize; } -/** ZSTDMT_getBuffer() : - * assumption : invocation from main thread only ! */ -static buffer_t ZSTDMT_getBuffer(ZSTDMT_bufferPool* pool, size_t bSize) +static void ZSTDMT_setBufferSize(ZSTDMT_bufferPool* bufPool, size_t bSize) { - if (pool->nbBuffers) { /* try to use an existing buffer */ - buffer_t const buf = pool->bTable[--(pool->nbBuffers)]; + bufPool->bufferSize = bSize; +} + +/** ZSTDMT_getBuffer() : + * assumption : bufPool must be valid */ +static buffer_t ZSTDMT_getBuffer(ZSTDMT_bufferPool* bufPool) +{ + size_t const bSize = bufPool->bufferSize; + DEBUGLOG(5, "ZSTDMT_getBuffer"); + pthread_mutex_lock(&bufPool->poolMutex); + if (bufPool->nbBuffers) { /* try to use an existing buffer */ + buffer_t const buf = bufPool->bTable[--(bufPool->nbBuffers)]; size_t const availBufferSize = buf.size; - if ((availBufferSize >= bSize) & (availBufferSize <= 10*bSize)) + if ((availBufferSize >= bSize) & (availBufferSize <= 10*bSize)) { /* large enough, but not too much */ + pthread_mutex_unlock(&bufPool->poolMutex); return buf; + } /* size conditions not respected : scratch this buffer, create new one */ - ZSTD_free(buf.start, pool->cMem); + DEBUGLOG(5, "existing buffer does not meet size conditions => freeing"); + ZSTD_free(buf.start, bufPool->cMem); } + pthread_mutex_unlock(&bufPool->poolMutex); /* create new buffer */ + DEBUGLOG(5, "create a new buffer"); { buffer_t buffer; - void* const start = ZSTD_malloc(bSize, pool->cMem); - if (start==NULL) bSize = 0; + void* const start = ZSTD_malloc(bSize, bufPool->cMem); buffer.start = start; /* note : start can be NULL if malloc fails ! */ - buffer.size = bSize; + buffer.size = (start==NULL) ? 0 : bSize; return buffer; } } /* store buffer for later re-use, up to pool capacity */ -static void ZSTDMT_releaseBuffer(ZSTDMT_bufferPool* pool, buffer_t buf) -{ - if (buf.start == NULL) return; /* release on NULL */ - if (pool->nbBuffers < pool->totalBuffers) { - pool->bTable[pool->nbBuffers++] = buf; /* store for later re-use */ +static void ZSTDMT_releaseBuffer(ZSTDMT_bufferPool* bufPool, buffer_t buf) +{ + if (buf.start == NULL) return; /* compatible with release on NULL */ + DEBUGLOG(5, "ZSTDMT_releaseBuffer"); + pthread_mutex_lock(&bufPool->poolMutex); + if (bufPool->nbBuffers < bufPool->totalBuffers) { + bufPool->bTable[bufPool->nbBuffers++] = buf; /* stored for later use */ + pthread_mutex_unlock(&bufPool->poolMutex); return; } + pthread_mutex_unlock(&bufPool->poolMutex); /* Reached bufferPool capacity (should not happen) */ - ZSTD_free(buf.start, pool->cMem); + DEBUGLOG(5, "buffer pool capacity reached => freeing "); + ZSTD_free(buf.start, bufPool->cMem); } /* ===== CCtx Pool ===== */ +/* a single CCtx Pool can be invoked from multiple threads in parallel */ typedef struct { + pthread_mutex_t poolMutex; unsigned totalCCtx; unsigned availCCtx; ZSTD_customMem cMem; ZSTD_CCtx* cctx[1]; /* variable size */ } ZSTDMT_CCtxPool; -/* assumption : CCtxPool invocation only from main thread */ - /* note : all CCtx borrowed from the pool should be released back to the pool _before_ freeing the pool */ static void ZSTDMT_freeCCtxPool(ZSTDMT_CCtxPool* pool) { unsigned u; for (u=0; u<pool->totalCCtx; u++) ZSTD_freeCCtx(pool->cctx[u]); /* note : compatible with free on NULL */ + pthread_mutex_destroy(&pool->poolMutex); ZSTD_free(pool, pool->cMem); } @@ -186,6 +216,10 @@ static ZSTDMT_CCtxPool* ZSTDMT_createCCtxPool(unsigned nbThreads, ZSTDMT_CCtxPool* const cctxPool = (ZSTDMT_CCtxPool*) ZSTD_calloc( sizeof(ZSTDMT_CCtxPool) + (nbThreads-1)*sizeof(ZSTD_CCtx*), cMem); if (!cctxPool) return NULL; + if (pthread_mutex_init(&cctxPool->poolMutex, NULL)) { + ZSTD_free(cctxPool, cMem); + return NULL; + } cctxPool->cMem = cMem; cctxPool->totalCCtx = nbThreads; cctxPool->availCCtx = 1; /* at least one cctx for single-thread mode */ @@ -198,50 +232,57 @@ static ZSTDMT_CCtxPool* ZSTDMT_createCCtxPool(unsigned nbThreads, /* only works during initialization phase, not during compression */ static size_t ZSTDMT_sizeof_CCtxPool(ZSTDMT_CCtxPool* cctxPool) { - unsigned const nbThreads = cctxPool->totalCCtx; - size_t const poolSize = sizeof(*cctxPool) - + (nbThreads-1)*sizeof(ZSTD_CCtx*); - unsigned u; - size_t totalCCtxSize = 0; - for (u=0; u<nbThreads; u++) - totalCCtxSize += ZSTD_sizeof_CCtx(cctxPool->cctx[u]); - - return poolSize + totalCCtxSize; + pthread_mutex_lock(&cctxPool->poolMutex); + { unsigned const nbThreads = cctxPool->totalCCtx; + size_t const poolSize = sizeof(*cctxPool) + + (nbThreads-1)*sizeof(ZSTD_CCtx*); + unsigned u; + size_t totalCCtxSize = 0; + for (u=0; u<nbThreads; u++) { + totalCCtxSize += ZSTD_sizeof_CCtx(cctxPool->cctx[u]); + } + pthread_mutex_unlock(&cctxPool->poolMutex); + return poolSize + totalCCtxSize; + } } -static ZSTD_CCtx* ZSTDMT_getCCtx(ZSTDMT_CCtxPool* pool) +static ZSTD_CCtx* ZSTDMT_getCCtx(ZSTDMT_CCtxPool* cctxPool) { - if (pool->availCCtx) { - pool->availCCtx--; - return pool->cctx[pool->availCCtx]; - } - return ZSTD_createCCtx(); /* note : can be NULL, when creation fails ! */ + DEBUGLOG(5, "ZSTDMT_getCCtx"); + pthread_mutex_lock(&cctxPool->poolMutex); + if (cctxPool->availCCtx) { + cctxPool->availCCtx--; + { ZSTD_CCtx* const cctx = cctxPool->cctx[cctxPool->availCCtx]; + pthread_mutex_unlock(&cctxPool->poolMutex); + return cctx; + } } + pthread_mutex_unlock(&cctxPool->poolMutex); + DEBUGLOG(5, "create one more CCtx"); + return ZSTD_createCCtx_advanced(cctxPool->cMem); /* note : can be NULL, when creation fails ! */ } static void ZSTDMT_releaseCCtx(ZSTDMT_CCtxPool* pool, ZSTD_CCtx* cctx) { if (cctx==NULL) return; /* compatibility with release on NULL */ + pthread_mutex_lock(&pool->poolMutex); if (pool->availCCtx < pool->totalCCtx) pool->cctx[pool->availCCtx++] = cctx; - else + else { /* pool overflow : should not happen, since totalCCtx==nbThreads */ + DEBUGLOG(5, "CCtx pool overflow : free cctx"); ZSTD_freeCCtx(cctx); + } + pthread_mutex_unlock(&pool->poolMutex); } /* ===== Thread worker ===== */ typedef struct { - buffer_t buffer; - size_t filled; -} inBuff_t; - -typedef struct { - ZSTD_CCtx* cctx; buffer_t src; const void* srcStart; - size_t srcSize; size_t dictSize; + size_t srcSize; buffer_t dstBuff; size_t cSize; size_t dstFlushed; @@ -253,6 +294,8 @@ typedef struct { pthread_cond_t* jobCompleted_cond; ZSTD_parameters params; const ZSTD_CDict* cdict; + ZSTDMT_CCtxPool* cctxPool; + ZSTDMT_bufferPool* bufPool; unsigned long long fullFrameSize; } ZSTDMT_jobDescription; @@ -260,37 +303,56 @@ typedef struct { void ZSTDMT_compressChunk(void* jobDescription) { ZSTDMT_jobDescription* const job = (ZSTDMT_jobDescription*)jobDescription; + ZSTD_CCtx* cctx = ZSTDMT_getCCtx(job->cctxPool); const void* const src = (const char*)job->srcStart + job->dictSize; - buffer_t const dstBuff = job->dstBuff; + buffer_t dstBuff = job->dstBuff; DEBUGLOG(5, "job (first:%u) (last:%u) : dictSize %u, srcSize %u", job->firstChunk, job->lastChunk, (U32)job->dictSize, (U32)job->srcSize); + + if (cctx==NULL) { + job->cSize = ERROR(memory_allocation); + goto _endJob; + } + + if (dstBuff.start == NULL) { + dstBuff = ZSTDMT_getBuffer(job->bufPool); + if (dstBuff.start==NULL) { + job->cSize = ERROR(memory_allocation); + goto _endJob; + } + job->dstBuff = dstBuff; + } + if (job->cdict) { /* should only happen for first segment */ - size_t const initError = ZSTD_compressBegin_usingCDict_advanced(job->cctx, job->cdict, job->params.fParams, job->fullFrameSize); + size_t const initError = ZSTD_compressBegin_usingCDict_advanced(cctx, job->cdict, job->params.fParams, job->fullFrameSize); DEBUGLOG(5, "using CDict"); if (ZSTD_isError(initError)) { job->cSize = initError; goto _endJob; } } else { /* srcStart points at reloaded section */ if (!job->firstChunk) job->params.fParams.contentSizeFlag = 0; /* ensure no srcSize control */ - { size_t const dictModeError = ZSTD_setCCtxParameter(job->cctx, ZSTD_p_forceRawDict, 1); /* Force loading dictionary in "content-only" mode (no header analysis) */ - size_t const initError = ZSTD_compressBegin_advanced(job->cctx, job->srcStart, job->dictSize, job->params, job->fullFrameSize); + { size_t const dictModeError = ZSTD_setCCtxParameter(cctx, ZSTD_p_forceRawDict, 1); /* Force loading dictionary in "content-only" mode (no header analysis) */ + size_t const initError = ZSTD_compressBegin_advanced(cctx, job->srcStart, job->dictSize, job->params, job->fullFrameSize); if (ZSTD_isError(initError) || ZSTD_isError(dictModeError)) { job->cSize = initError; goto _endJob; } - ZSTD_setCCtxParameter(job->cctx, ZSTD_p_forceWindow, 1); + ZSTD_setCCtxParameter(cctx, ZSTD_p_forceWindow, 1); } } if (!job->firstChunk) { /* flush and overwrite frame header when it's not first segment */ - size_t const hSize = ZSTD_compressContinue(job->cctx, dstBuff.start, dstBuff.size, src, 0); + size_t const hSize = ZSTD_compressContinue(cctx, dstBuff.start, dstBuff.size, src, 0); if (ZSTD_isError(hSize)) { job->cSize = hSize; goto _endJob; } - ZSTD_invalidateRepCodes(job->cctx); + ZSTD_invalidateRepCodes(cctx); } DEBUGLOG(5, "Compressing : "); DEBUG_PRINTHEX(4, job->srcStart, 12); job->cSize = (job->lastChunk) ? - ZSTD_compressEnd (job->cctx, dstBuff.start, dstBuff.size, src, job->srcSize) : - ZSTD_compressContinue(job->cctx, dstBuff.start, dstBuff.size, src, job->srcSize); + ZSTD_compressEnd (cctx, dstBuff.start, dstBuff.size, src, job->srcSize) : + ZSTD_compressContinue(cctx, dstBuff.start, dstBuff.size, src, job->srcSize); DEBUGLOG(5, "compressed %u bytes into %u bytes (first:%u) (last:%u)", (unsigned)job->srcSize, (unsigned)job->cSize, job->firstChunk, job->lastChunk); DEBUGLOG(5, "dstBuff.size : %u ; => %s", (U32)dstBuff.size, ZSTD_getErrorName(job->cSize)); _endJob: + ZSTDMT_releaseCCtx(job->cctxPool, cctx); + ZSTDMT_releaseBuffer(job->bufPool, job->src); + job->src = g_nullBuffer; job->srcStart = NULL; PTHREAD_MUTEX_LOCK(job->jobCompleted_mutex); job->jobCompleted = 1; job->jobScanned = 0; @@ -303,15 +365,19 @@ _endJob: /* ===== Multi-threaded compression ===== */ /* ------------------------------------------ */ +typedef struct { + buffer_t buffer; + size_t filled; +} inBuff_t; + struct ZSTDMT_CCtx_s { POOL_ctx* factory; ZSTDMT_jobDescription* jobs; - ZSTDMT_bufferPool* buffPool; + ZSTDMT_bufferPool* bufPool; ZSTDMT_CCtxPool* cctxPool; pthread_mutex_t jobCompleted_mutex; pthread_cond_t jobCompleted_cond; size_t targetSectionSize; - size_t marginSize; size_t inBuffSize; size_t dictSize; size_t targetDictSize; @@ -324,7 +390,7 @@ struct ZSTDMT_CCtx_s { unsigned nextJobID; unsigned frameEnded; unsigned allJobsCompleted; - unsigned overlapRLog; + unsigned overlapLog; unsigned long long frameContentSize; size_t sectionSize; ZSTD_customMem cMem; @@ -347,7 +413,8 @@ ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbThreads, ZSTD_customMem cMem) U32 nbJobs = nbThreads + 2; DEBUGLOG(3, "ZSTDMT_createCCtx_advanced"); - if ((nbThreads < 1) | (nbThreads > ZSTDMT_NBTHREADS_MAX)) return NULL; + if (nbThreads < 1) return NULL; + nbThreads = MIN(nbThreads , ZSTDMT_NBTHREADS_MAX); if ((cMem.customAlloc!=NULL) ^ (cMem.customFree!=NULL)) /* invalid custom allocator */ return NULL; @@ -358,18 +425,24 @@ ZSTDMT_CCtx* ZSTDMT_createCCtx_advanced(unsigned nbThreads, ZSTD_customMem cMem) mtctx->nbThreads = nbThreads; mtctx->allJobsCompleted = 1; mtctx->sectionSize = 0; - mtctx->overlapRLog = 3; - mtctx->factory = POOL_create(nbThreads, 1); + mtctx->overlapLog = ZSTDMT_OVERLAPLOG_DEFAULT; + mtctx->factory = POOL_create(nbThreads, 0); mtctx->jobs = ZSTDMT_allocJobsTable(&nbJobs, cMem); mtctx->jobIDMask = nbJobs - 1; - mtctx->buffPool = ZSTDMT_createBufferPool(nbThreads, cMem); + mtctx->bufPool = ZSTDMT_createBufferPool(nbThreads, cMem); mtctx->cctxPool = ZSTDMT_createCCtxPool(nbThreads, cMem); - if (!mtctx->factory | !mtctx->jobs | !mtctx->buffPool | !mtctx->cctxPool) { + if (!mtctx->factory | !mtctx->jobs | !mtctx->bufPool | !mtctx->cctxPool) { + ZSTDMT_freeCCtx(mtctx); + return NULL; + } + if (pthread_mutex_init(&mtctx->jobCompleted_mutex, NULL)) { + ZSTDMT_freeCCtx(mtctx); + return NULL; + } + if (pthread_cond_init(&mtctx->jobCompleted_cond, NULL)) { ZSTDMT_freeCCtx(mtctx); return NULL; } - pthread_mutex_init(&mtctx->jobCompleted_mutex, NULL); /* Todo : check init function return */ - pthread_cond_init(&mtctx->jobCompleted_cond, NULL); DEBUGLOG(3, "mt_cctx created, for %u threads", nbThreads); return mtctx; } @@ -386,15 +459,13 @@ static void ZSTDMT_releaseAllJobResources(ZSTDMT_CCtx* mtctx) unsigned jobID; DEBUGLOG(3, "ZSTDMT_releaseAllJobResources"); for (jobID=0; jobID <= mtctx->jobIDMask; jobID++) { - ZSTDMT_releaseBuffer(mtctx->buffPool, mtctx->jobs[jobID].dstBuff); + ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[jobID].dstBuff); mtctx->jobs[jobID].dstBuff = g_nullBuffer; - ZSTDMT_releaseBuffer(mtctx->buffPool, mtctx->jobs[jobID].src); + ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[jobID].src); mtctx->jobs[jobID].src = g_nullBuffer; - ZSTDMT_releaseCCtx(mtctx->cctxPool, mtctx->jobs[jobID].cctx); - mtctx->jobs[jobID].cctx = NULL; } memset(mtctx->jobs, 0, (mtctx->jobIDMask+1)*sizeof(ZSTDMT_jobDescription)); - ZSTDMT_releaseBuffer(mtctx->buffPool, mtctx->inBuff.buffer); + ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->inBuff.buffer); mtctx->inBuff.buffer = g_nullBuffer; mtctx->allJobsCompleted = 1; } @@ -404,7 +475,7 @@ size_t ZSTDMT_freeCCtx(ZSTDMT_CCtx* mtctx) if (mtctx==NULL) return 0; /* compatible with free on NULL */ POOL_free(mtctx->factory); if (!mtctx->allJobsCompleted) ZSTDMT_releaseAllJobResources(mtctx); /* stop workers first */ - ZSTDMT_freeBufferPool(mtctx->buffPool); /* release job resources into pools first */ + ZSTDMT_freeBufferPool(mtctx->bufPool); /* release job resources into pools first */ ZSTD_free(mtctx->jobs, mtctx->cMem); ZSTDMT_freeCCtxPool(mtctx->cctxPool); ZSTD_freeCDict(mtctx->cdictLocal); @@ -418,11 +489,11 @@ size_t ZSTDMT_sizeof_CCtx(ZSTDMT_CCtx* mtctx) { if (mtctx == NULL) return 0; /* supports sizeof NULL */ return sizeof(*mtctx) - + POOL_sizeof(mtctx->factory) - + ZSTDMT_sizeof_bufferPool(mtctx->buffPool) - + (mtctx->jobIDMask+1) * sizeof(ZSTDMT_jobDescription) - + ZSTDMT_sizeof_CCtxPool(mtctx->cctxPool) - + ZSTD_sizeof_CDict(mtctx->cdictLocal); + + POOL_sizeof(mtctx->factory) + + ZSTDMT_sizeof_bufferPool(mtctx->bufPool) + + (mtctx->jobIDMask+1) * sizeof(ZSTDMT_jobDescription) + + ZSTDMT_sizeof_CCtxPool(mtctx->cctxPool) + + ZSTD_sizeof_CDict(mtctx->cdictLocal); } size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSDTMT_parameter parameter, unsigned value) @@ -434,10 +505,10 @@ size_t ZSTDMT_setMTCtxParameter(ZSTDMT_CCtx* mtctx, ZSDTMT_parameter parameter, return 0; case ZSTDMT_p_overlapSectionLog : DEBUGLOG(5, "ZSTDMT_p_overlapSectionLog : %u", value); - mtctx->overlapRLog = (value >= 9) ? 0 : 9 - value; + mtctx->overlapLog = (value >= 9) ? 9 : value; return 0; default : - return ERROR(compressionParameter_unsupported); + return ERROR(parameter_unsupported); } } @@ -459,12 +530,13 @@ static unsigned computeNbChunks(size_t srcSize, unsigned windowLog, unsigned nbT size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const ZSTD_CDict* cdict, - ZSTD_parameters const params, - unsigned overlapRLog) + void* dst, size_t dstCapacity, + const void* src, size_t srcSize, + const ZSTD_CDict* cdict, + ZSTD_parameters const params, + unsigned overlapLog) { + unsigned const overlapRLog = (overlapLog>9) ? 0 : 9-overlapLog; size_t const overlapSize = (overlapRLog>=9) ? 0 : (size_t)1 << (params.cParams.windowLog - overlapRLog); unsigned nbChunks = computeNbChunks(srcSize, params.cParams.windowLog, mtctx->nbThreads); size_t const proposedChunkSize = (srcSize + (nbChunks-1)) / nbChunks; @@ -473,6 +545,7 @@ size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx, size_t remainingSrcSize = srcSize; unsigned const compressWithinDst = (dstCapacity >= ZSTD_compressBound(srcSize)) ? nbChunks : (unsigned)(dstCapacity / ZSTD_compressBound(avgChunkSize)); /* presumes avgChunkSize >= 256 KB, which should be the case */ size_t frameStartPos = 0, dstBufferPos = 0; + XXH64_state_t xxh64; DEBUGLOG(4, "nbChunks : %2u (chunkSize : %u bytes) ", nbChunks, (U32)avgChunkSize); if (nbChunks==1) { /* fallback to single-thread mode */ @@ -480,7 +553,9 @@ size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx, if (cdict) return ZSTD_compress_usingCDict_advanced(cctx, dst, dstCapacity, src, srcSize, cdict, params.fParams); return ZSTD_compress_advanced(cctx, dst, dstCapacity, src, srcSize, NULL, 0, params); } - assert(avgChunkSize >= 256 KB); /* condition for ZSTD_compressBound(A) + ZSTD_compressBound(B) <= ZSTD_compressBound(A+B), which is useful to avoid allocating extra buffers */ + assert(avgChunkSize >= 256 KB); /* condition for ZSTD_compressBound(A) + ZSTD_compressBound(B) <= ZSTD_compressBound(A+B), which is required for compressWithinDst */ + ZSTDMT_setBufferSize(mtctx->bufPool, ZSTD_compressBound(avgChunkSize) ); + XXH64_reset(&xxh64, 0); if (nbChunks > mtctx->jobIDMask+1) { /* enlarge job table */ U32 nbJobs = nbChunks; @@ -496,17 +571,10 @@ size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx, size_t const chunkSize = MIN(remainingSrcSize, avgChunkSize); size_t const dstBufferCapacity = ZSTD_compressBound(chunkSize); buffer_t const dstAsBuffer = { (char*)dst + dstBufferPos, dstBufferCapacity }; - buffer_t const dstBuffer = u < compressWithinDst ? dstAsBuffer : ZSTDMT_getBuffer(mtctx->buffPool, dstBufferCapacity); - ZSTD_CCtx* const cctx = ZSTDMT_getCCtx(mtctx->cctxPool); + buffer_t const dstBuffer = u < compressWithinDst ? dstAsBuffer : g_nullBuffer; size_t dictSize = u ? overlapSize : 0; - if ((cctx==NULL) || (dstBuffer.start==NULL)) { - mtctx->jobs[u].cSize = ERROR(memory_allocation); /* job result */ - mtctx->jobs[u].jobCompleted = 1; - nbChunks = u+1; /* only wait and free u jobs, instead of initially expected nbChunks ones */ - break; /* let's wait for previous jobs to complete, but don't start new ones */ - } - + mtctx->jobs[u].src = g_nullBuffer; mtctx->jobs[u].srcStart = srcStart + frameStartPos - dictSize; mtctx->jobs[u].dictSize = dictSize; mtctx->jobs[u].srcSize = chunkSize; @@ -516,13 +584,18 @@ size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx, /* do not calculate checksum within sections, but write it in header for first section */ if (u!=0) mtctx->jobs[u].params.fParams.checksumFlag = 0; mtctx->jobs[u].dstBuff = dstBuffer; - mtctx->jobs[u].cctx = cctx; + mtctx->jobs[u].cctxPool = mtctx->cctxPool; + mtctx->jobs[u].bufPool = mtctx->bufPool; mtctx->jobs[u].firstChunk = (u==0); mtctx->jobs[u].lastChunk = (u==nbChunks-1); mtctx->jobs[u].jobCompleted = 0; mtctx->jobs[u].jobCompleted_mutex = &mtctx->jobCompleted_mutex; mtctx->jobs[u].jobCompleted_cond = &mtctx->jobCompleted_cond; + if (params.fParams.checksumFlag) { + XXH64_update(&xxh64, srcStart + frameStartPos, chunkSize); + } + DEBUGLOG(5, "posting job %u (%u bytes)", u, (U32)chunkSize); DEBUG_PRINTHEX(6, mtctx->jobs[u].srcStart, 12); POOL_add(mtctx->factory, ZSTDMT_compressChunk, &mtctx->jobs[u]); @@ -533,8 +606,8 @@ size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx, } } /* collect result */ - { unsigned chunkID; - size_t error = 0, dstPos = 0; + { size_t error = 0, dstPos = 0; + unsigned chunkID; for (chunkID=0; chunkID<nbChunks; chunkID++) { DEBUGLOG(5, "waiting for chunk %u ", chunkID); PTHREAD_MUTEX_LOCK(&mtctx->jobCompleted_mutex); @@ -545,8 +618,6 @@ size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx, pthread_mutex_unlock(&mtctx->jobCompleted_mutex); DEBUGLOG(5, "ready to write chunk %u ", chunkID); - ZSTDMT_releaseCCtx(mtctx->cctxPool, mtctx->jobs[chunkID].cctx); - mtctx->jobs[chunkID].cctx = NULL; mtctx->jobs[chunkID].srcStart = NULL; { size_t const cSize = mtctx->jobs[chunkID].cSize; if (ZSTD_isError(cSize)) error = cSize; @@ -556,13 +627,25 @@ size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx, memmove((char*)dst + dstPos, mtctx->jobs[chunkID].dstBuff.start, cSize); /* may overlap when chunk compressed within dst */ if (chunkID >= compressWithinDst) { /* chunk compressed into its own buffer, which must be released */ DEBUGLOG(5, "releasing buffer %u>=%u", chunkID, compressWithinDst); - ZSTDMT_releaseBuffer(mtctx->buffPool, mtctx->jobs[chunkID].dstBuff); + ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->jobs[chunkID].dstBuff); } mtctx->jobs[chunkID].dstBuff = g_nullBuffer; } dstPos += cSize ; } - } + } /* for (chunkID=0; chunkID<nbChunks; chunkID++) */ + + DEBUGLOG(4, "checksumFlag : %u ", params.fParams.checksumFlag); + if (params.fParams.checksumFlag) { + U32 const checksum = (U32)XXH64_digest(&xxh64); + if (dstPos + 4 > dstCapacity) { + error = ERROR(dstSize_tooSmall); + } else { + DEBUGLOG(4, "writing checksum : %08X \n", checksum); + MEM_writeLE32((char*)dst + dstPos, checksum); + dstPos += 4; + } } + if (!error) DEBUGLOG(4, "compressed size : %u ", (U32)dstPos); return error ? error : dstPos; } @@ -574,10 +657,10 @@ size_t ZSTDMT_compressCCtx(ZSTDMT_CCtx* mtctx, const void* src, size_t srcSize, int compressionLevel) { - U32 const overlapRLog = (compressionLevel >= ZSTD_maxCLevel()) ? 0 : 3; + U32 const overlapLog = (compressionLevel >= ZSTD_maxCLevel()) ? 9 : ZSTDMT_OVERLAPLOG_DEFAULT; ZSTD_parameters params = ZSTD_getParams(compressionLevel, srcSize, 0); params.fParams.contentSizeFlag = 1; - return ZSTDMT_compress_advanced(mtctx, dst, dstCapacity, src, srcSize, NULL, params, overlapRLog); + return ZSTDMT_compress_advanced(mtctx, dst, dstCapacity, src, srcSize, NULL, params, overlapLog); } @@ -615,8 +698,8 @@ size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs, if (zcs->nbThreads==1) { DEBUGLOG(4, "single thread mode"); return ZSTD_initCStream_internal(zcs->cctxPool->cctx[0], - dict, dictSize, cdict, - params, pledgedSrcSize); + dict, dictSize, cdict, + params, pledgedSrcSize); } if (zcs->allJobsCompleted == 0) { /* previous compression not correctly finished */ @@ -642,18 +725,16 @@ size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs, zcs->cdict = cdict; } - zcs->targetDictSize = (zcs->overlapRLog>=9) ? 0 : (size_t)1 << (zcs->params.cParams.windowLog - zcs->overlapRLog); - DEBUGLOG(4, "overlapRLog : %u ", zcs->overlapRLog); + zcs->targetDictSize = (zcs->overlapLog==0) ? 0 : (size_t)1 << (zcs->params.cParams.windowLog - (9 - zcs->overlapLog)); + DEBUGLOG(4, "overlapLog : %u ", zcs->overlapLog); DEBUGLOG(4, "overlap Size : %u KB", (U32)(zcs->targetDictSize>>10)); zcs->targetSectionSize = zcs->sectionSize ? zcs->sectionSize : (size_t)1 << (zcs->params.cParams.windowLog + 2); zcs->targetSectionSize = MAX(ZSTDMT_SECTION_SIZE_MIN, zcs->targetSectionSize); zcs->targetSectionSize = MAX(zcs->targetDictSize, zcs->targetSectionSize); DEBUGLOG(4, "Section Size : %u KB", (U32)(zcs->targetSectionSize>>10)); - zcs->marginSize = zcs->targetSectionSize >> 2; - zcs->inBuffSize = zcs->targetDictSize + zcs->targetSectionSize + zcs->marginSize; - zcs->inBuff.buffer = ZSTDMT_getBuffer(zcs->buffPool, zcs->inBuffSize); - if (zcs->inBuff.buffer.start == NULL) return ERROR(memory_allocation); - zcs->inBuff.filled = 0; + zcs->inBuffSize = zcs->targetDictSize + zcs->targetSectionSize; + ZSTDMT_setBufferSize(zcs->bufPool, MAX(zcs->inBuffSize, ZSTD_compressBound(zcs->targetSectionSize)) ); + zcs->inBuff.buffer = g_nullBuffer; zcs->dictSize = 0; zcs->doneJobID = 0; zcs->nextJobID = 0; @@ -664,8 +745,9 @@ size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs, } size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx, - const void* dict, size_t dictSize, - ZSTD_parameters params, unsigned long long pledgedSrcSize) + const void* dict, size_t dictSize, + ZSTD_parameters params, + unsigned long long pledgedSrcSize) { DEBUGLOG(5, "ZSTDMT_initCStream_advanced"); return ZSTDMT_initCStream_internal(mtctx, dict, dictSize, NULL, params, pledgedSrcSize); @@ -701,19 +783,8 @@ size_t ZSTDMT_initCStream(ZSTDMT_CCtx* zcs, int compressionLevel) { static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* zcs, size_t srcSize, unsigned endFrame) { - size_t const dstBufferCapacity = ZSTD_compressBound(srcSize); - buffer_t const dstBuffer = ZSTDMT_getBuffer(zcs->buffPool, dstBufferCapacity); - ZSTD_CCtx* const cctx = ZSTDMT_getCCtx(zcs->cctxPool); unsigned const jobID = zcs->nextJobID & zcs->jobIDMask; - if ((cctx==NULL) || (dstBuffer.start==NULL)) { - zcs->jobs[jobID].jobCompleted = 1; - zcs->nextJobID++; - ZSTDMT_waitForAllJobsCompleted(zcs); - ZSTDMT_releaseAllJobResources(zcs); - return ERROR(memory_allocation); - } - DEBUGLOG(4, "preparing job %u to compress %u bytes with %u preload ", zcs->nextJobID, (U32)srcSize, (U32)zcs->dictSize); zcs->jobs[jobID].src = zcs->inBuff.buffer; @@ -726,8 +797,9 @@ static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* zcs, size_t srcSize, unsi if (zcs->nextJobID) zcs->jobs[jobID].params.fParams.checksumFlag = 0; zcs->jobs[jobID].cdict = zcs->nextJobID==0 ? zcs->cdict : NULL; zcs->jobs[jobID].fullFrameSize = zcs->frameContentSize; - zcs->jobs[jobID].dstBuff = dstBuffer; - zcs->jobs[jobID].cctx = cctx; + zcs->jobs[jobID].dstBuff = g_nullBuffer; + zcs->jobs[jobID].cctxPool = zcs->cctxPool; + zcs->jobs[jobID].bufPool = zcs->bufPool; zcs->jobs[jobID].firstChunk = (zcs->nextJobID==0); zcs->jobs[jobID].lastChunk = endFrame; zcs->jobs[jobID].jobCompleted = 0; @@ -735,11 +807,13 @@ static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* zcs, size_t srcSize, unsi zcs->jobs[jobID].jobCompleted_mutex = &zcs->jobCompleted_mutex; zcs->jobs[jobID].jobCompleted_cond = &zcs->jobCompleted_cond; + if (zcs->params.fParams.checksumFlag) + XXH64_update(&zcs->xxhState, (const char*)zcs->inBuff.buffer.start + zcs->dictSize, srcSize); + /* get a new buffer for next input */ if (!endFrame) { size_t const newDictSize = MIN(srcSize + zcs->dictSize, zcs->targetDictSize); - DEBUGLOG(5, "ZSTDMT_createCompressionJob::endFrame = %u", endFrame); - zcs->inBuff.buffer = ZSTDMT_getBuffer(zcs->buffPool, zcs->inBuffSize); + zcs->inBuff.buffer = ZSTDMT_getBuffer(zcs->bufPool); if (zcs->inBuff.buffer.start == NULL) { /* not enough memory to allocate next input buffer */ zcs->jobs[jobID].jobCompleted = 1; zcs->nextJobID++; @@ -747,26 +821,20 @@ static size_t ZSTDMT_createCompressionJob(ZSTDMT_CCtx* zcs, size_t srcSize, unsi ZSTDMT_releaseAllJobResources(zcs); return ERROR(memory_allocation); } - DEBUGLOG(5, "inBuff currently filled to %u", (U32)zcs->inBuff.filled); zcs->inBuff.filled -= srcSize + zcs->dictSize - newDictSize; - DEBUGLOG(5, "new job : inBuff filled to %u, with %u dict and %u src", - (U32)zcs->inBuff.filled, (U32)newDictSize, - (U32)(zcs->inBuff.filled - newDictSize)); memmove(zcs->inBuff.buffer.start, (const char*)zcs->jobs[jobID].srcStart + zcs->dictSize + srcSize - newDictSize, zcs->inBuff.filled); - DEBUGLOG(5, "new inBuff pre-filled"); zcs->dictSize = newDictSize; } else { /* if (endFrame==1) */ - DEBUGLOG(5, "ZSTDMT_createCompressionJob::endFrame = %u", endFrame); zcs->inBuff.buffer = g_nullBuffer; zcs->inBuff.filled = 0; zcs->dictSize = 0; zcs->frameEnded = 1; - if (zcs->nextJobID == 0) + if (zcs->nextJobID == 0) { /* single chunk exception : checksum is calculated directly within worker thread */ zcs->params.fParams.checksumFlag = 0; - } + } } DEBUGLOG(4, "posting job %u : %u bytes (end:%u) (note : doneJob = %u=>%u)", zcs->nextJobID, @@ -804,11 +872,8 @@ static size_t ZSTDMT_flushNextJob(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output, unsi ZSTDMT_releaseAllJobResources(zcs); return job.cSize; } - ZSTDMT_releaseCCtx(zcs->cctxPool, job.cctx); - zcs->jobs[wJobID].cctx = NULL; DEBUGLOG(5, "zcs->params.fParams.checksumFlag : %u ", zcs->params.fParams.checksumFlag); if (zcs->params.fParams.checksumFlag) { - XXH64_update(&zcs->xxhState, (const char*)job.srcStart + job.dictSize, job.srcSize); if (zcs->frameEnded && (zcs->doneJobID+1 == zcs->nextJobID)) { /* write checksum at end of last section */ U32 const checksum = (U32)XXH64_digest(&zcs->xxhState); DEBUGLOG(5, "writing checksum : %08X \n", checksum); @@ -816,9 +881,6 @@ static size_t ZSTDMT_flushNextJob(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output, unsi job.cSize += 4; zcs->jobs[wJobID].cSize += 4; } } - ZSTDMT_releaseBuffer(zcs->buffPool, job.src); - zcs->jobs[wJobID].srcStart = NULL; - zcs->jobs[wJobID].src = g_nullBuffer; zcs->jobs[wJobID].jobScanned = 1; } { size_t const toWrite = MIN(job.cSize - job.dstFlushed, output->size - output->pos); @@ -828,7 +890,7 @@ static size_t ZSTDMT_flushNextJob(ZSTDMT_CCtx* zcs, ZSTD_outBuffer* output, unsi job.dstFlushed += toWrite; } if (job.dstFlushed == job.cSize) { /* output buffer fully flushed => move to next one */ - ZSTDMT_releaseBuffer(zcs->buffPool, job.dstBuff); + ZSTDMT_releaseBuffer(zcs->bufPool, job.dstBuff); zcs->jobs[wJobID].dstBuff = g_nullBuffer; zcs->jobs[wJobID].jobCompleted = 0; zcs->doneJobID++; @@ -852,18 +914,18 @@ size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx, ZSTD_inBuffer* input, ZSTD_EndDirective endOp) { - size_t const newJobThreshold = mtctx->dictSize + mtctx->targetSectionSize + mtctx->marginSize; + size_t const newJobThreshold = mtctx->dictSize + mtctx->targetSectionSize; assert(output->pos <= output->size); assert(input->pos <= input->size); if ((mtctx->frameEnded) && (endOp==ZSTD_e_continue)) { /* current frame being ended. Only flush/end are allowed. Or start new frame with init */ return ERROR(stage_wrong); } - if (mtctx->nbThreads==1) { + if (mtctx->nbThreads==1) { /* delegate to single-thread (synchronous) */ return ZSTD_compressStream_generic(mtctx->cctxPool->cctx[0], output, input, endOp); } - /* single-pass shortcut (note : this is blocking-mode) */ + /* single-pass shortcut (note : this is synchronous-mode) */ if ( (mtctx->nextJobID==0) /* just started */ && (mtctx->inBuff.filled==0) /* nothing buffered */ && (endOp==ZSTD_e_end) /* end order */ @@ -871,24 +933,29 @@ size_t ZSTDMT_compressStream_generic(ZSTDMT_CCtx* mtctx, size_t const cSize = ZSTDMT_compress_advanced(mtctx, (char*)output->dst + output->pos, output->size - output->pos, (const char*)input->src + input->pos, input->size - input->pos, - mtctx->cdict, mtctx->params, mtctx->overlapRLog); + mtctx->cdict, mtctx->params, mtctx->overlapLog); if (ZSTD_isError(cSize)) return cSize; input->pos = input->size; output->pos += cSize; - ZSTDMT_releaseBuffer(mtctx->buffPool, mtctx->inBuff.buffer); /* was allocated in initStream */ + ZSTDMT_releaseBuffer(mtctx->bufPool, mtctx->inBuff.buffer); /* was allocated in initStream */ mtctx->allJobsCompleted = 1; mtctx->frameEnded = 1; return 0; } /* fill input buffer */ - if ((input->src) && (mtctx->inBuff.buffer.start)) { /* support NULL input */ - size_t const toLoad = MIN(input->size - input->pos, mtctx->inBuffSize - mtctx->inBuff.filled); - DEBUGLOG(2, "inBuff:%08X; inBuffSize=%u; ToCopy=%u", (U32)(size_t)mtctx->inBuff.buffer.start, (U32)mtctx->inBuffSize, (U32)toLoad); - memcpy((char*)mtctx->inBuff.buffer.start + mtctx->inBuff.filled, (const char*)input->src + input->pos, toLoad); - input->pos += toLoad; - mtctx->inBuff.filled += toLoad; - } + if (input->size > input->pos) { /* support NULL input */ + if (mtctx->inBuff.buffer.start == NULL) { + mtctx->inBuff.buffer = ZSTDMT_getBuffer(mtctx->bufPool); + if (mtctx->inBuff.buffer.start == NULL) return ERROR(memory_allocation); + mtctx->inBuff.filled = 0; + } + { size_t const toLoad = MIN(input->size - input->pos, mtctx->inBuffSize - mtctx->inBuff.filled); + DEBUGLOG(5, "inBuff:%08X; inBuffSize=%u; ToCopy=%u", (U32)(size_t)mtctx->inBuff.buffer.start, (U32)mtctx->inBuffSize, (U32)toLoad); + memcpy((char*)mtctx->inBuff.buffer.start + mtctx->inBuff.filled, (const char*)input->src + input->pos, toLoad); + input->pos += toLoad; + mtctx->inBuff.filled += toLoad; + } } if ( (mtctx->inBuff.filled >= newJobThreshold) /* filled enough : let's compress */ && (mtctx->nextJobID <= mtctx->doneJobID + mtctx->jobIDMask) ) { /* avoid overwriting job round buffer */ diff --git a/thirdparty/zstd/compress/zstdmt_compress.h b/thirdparty/zstd/compress/zstdmt_compress.h index fad63b6d86..0f0fc2b03f 100644 --- a/thirdparty/zstd/compress/zstdmt_compress.h +++ b/thirdparty/zstd/compress/zstdmt_compress.h @@ -1,10 +1,10 @@ -/** +/* * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ #ifndef ZSTDMT_COMPRESS_H @@ -15,10 +15,11 @@ #endif -/* Note : All prototypes defined in this file are labelled experimental. - * No guarantee of API continuity is provided on any of them. - * In fact, the expectation is that these prototypes will be replaced - * by ZSTD_compress_generic() API in the near future */ +/* Note : This is an internal API. + * Some methods are still exposed (ZSTDLIB_API), + * because it used to be the only way to invoke MT compression. + * Now, it's recommended to use ZSTD_compress_generic() instead. + * These methods will stop being exposed in a future version */ /* === Dependencies === */ #include <stddef.h> /* size_t */ @@ -67,7 +68,7 @@ ZSTDLIB_API size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx, const void* src, size_t srcSize, const ZSTD_CDict* cdict, ZSTD_parameters const params, - unsigned overlapRLog); + unsigned overlapLog); ZSTDLIB_API size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx, const void* dict, size_t dictSize, /* dict can be released after init, a local copy is preserved within zcs */ diff --git a/thirdparty/zstd/decompress/huf_decompress.c b/thirdparty/zstd/decompress/huf_decompress.c index 2a1b70ea5e..79ded96bf6 100644 --- a/thirdparty/zstd/decompress/huf_decompress.c +++ b/thirdparty/zstd/decompress/huf_decompress.c @@ -33,37 +33,21 @@ ****************************************************************** */ /* ************************************************************** -* Compiler specifics -****************************************************************/ -#ifdef _MSC_VER /* Visual Studio */ -# define FORCE_INLINE static __forceinline -# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */ -#else -# if defined (__cplusplus) || defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ -# ifdef __GNUC__ -# define FORCE_INLINE static inline __attribute__((always_inline)) -# else -# define FORCE_INLINE static inline -# endif -# else -# define FORCE_INLINE static -# endif /* __STDC_VERSION__ */ -#endif - - -/* ************************************************************** * Dependencies ****************************************************************/ #include <string.h> /* memcpy, memset */ #include "bitstream.h" /* BIT_* */ +#include "compiler.h" #include "fse.h" /* header compression */ #define HUF_STATIC_LINKING_ONLY #include "huf.h" +#include "error_private.h" /* ************************************************************** * Error Management ****************************************************************/ +#define HUF_isError ERR_isError #define HUF_STATIC_ASSERT(c) { enum { HUF_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */ @@ -180,7 +164,7 @@ static BYTE HUF_decodeSymbolX2(BIT_DStream_t* Dstream, const HUF_DEltX2* dt, con if (MEM_64bits()) \ HUF_DECODE_SYMBOLX2_0(ptr, DStreamPtr) -FORCE_INLINE size_t HUF_decodeStreamX2(BYTE* p, BIT_DStream_t* const bitDPtr, BYTE* const pEnd, const HUF_DEltX2* const dt, const U32 dtLog) +HINT_INLINE size_t HUF_decodeStreamX2(BYTE* p, BIT_DStream_t* const bitDPtr, BYTE* const pEnd, const HUF_DEltX2* const dt, const U32 dtLog) { BYTE* const pStart = p; @@ -639,7 +623,7 @@ static U32 HUF_decodeLastSymbolX4(void* op, BIT_DStream_t* DStream, const HUF_DE if (MEM_64bits()) \ ptr += HUF_decodeSymbolX4(ptr, DStreamPtr, dt, dtLog) -FORCE_INLINE size_t HUF_decodeStreamX4(BYTE* p, BIT_DStream_t* bitDPtr, BYTE* const pEnd, const HUF_DEltX4* const dt, const U32 dtLog) +HINT_INLINE size_t HUF_decodeStreamX4(BYTE* p, BIT_DStream_t* bitDPtr, BYTE* const pEnd, const HUF_DEltX4* const dt, const U32 dtLog) { BYTE* const pStart = p; @@ -917,11 +901,11 @@ static const algo_time_t algoTime[16 /* Quantization */][3 /* single, double, qu * Tells which decoder is likely to decode faster, * based on a set of pre-determined metrics. * @return : 0==HUF_decompress4X2, 1==HUF_decompress4X4 . -* Assumption : 0 < cSrcSize < dstSize <= 128 KB */ +* Assumption : 0 < cSrcSize, dstSize <= 128 KB */ U32 HUF_selectDecoder (size_t dstSize, size_t cSrcSize) { /* decoder timing evaluation */ - U32 const Q = (U32)(cSrcSize * 16 / dstSize); /* Q < 16 since dstSize > cSrcSize */ + U32 const Q = cSrcSize >= dstSize ? 15 : (U32)(cSrcSize * 16 / dstSize); /* Q < 16 */ U32 const D256 = (U32)(dstSize >> 8); U32 const DTime0 = algoTime[Q][0].tableTime + (algoTime[Q][0].decode256Time * D256); U32 DTime1 = algoTime[Q][1].tableTime + (algoTime[Q][1].decode256Time * D256); @@ -977,7 +961,7 @@ size_t HUF_decompress4X_hufOnly_wksp(HUF_DTable* dctx, void* dst, { /* validation checks */ if (dstSize == 0) return ERROR(dstSize_tooSmall); - if ((cSrcSize >= dstSize) || (cSrcSize <= 1)) return ERROR(corruption_detected); /* invalid */ + if (cSrcSize == 0) return ERROR(corruption_detected); { U32 const algoNb = HUF_selectDecoder(dstSize, cSrcSize); return algoNb ? HUF_decompress4X4_DCtx_wksp(dctx, dst, dstSize, cSrc, cSrcSize, workSpace, wkspSize): diff --git a/thirdparty/zstd/decompress/zstd_decompress.c b/thirdparty/zstd/decompress/zstd_decompress.c index 465bcc20b5..d2bc545e52 100644 --- a/thirdparty/zstd/decompress/zstd_decompress.c +++ b/thirdparty/zstd/decompress/zstd_decompress.c @@ -1,10 +1,10 @@ -/** +/* * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ @@ -53,15 +53,6 @@ # include "zstd_legacy.h" #endif -#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86)) /* _mm_prefetch() is not defined outside of x86/x64 */ -# include <mmintrin.h> /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ -# define ZSTD_PREFETCH(ptr) _mm_prefetch((const char*)ptr, _MM_HINT_T0) -#elif defined(__GNUC__) -# define ZSTD_PREFETCH(ptr) __builtin_prefetch(ptr, 0, 0) -#else -# define ZSTD_PREFETCH(ptr) /* disabled */ -#endif - /*-************************************* * Errors @@ -95,7 +86,7 @@ typedef struct { HUF_DTable hufTable[HUF_DTABLE_SIZE(HufLog)]; /* can accommodate HUF_decompress4X */ U32 workspace[HUF_DECOMPRESS_WORKSPACE_SIZE_U32]; U32 rep[ZSTD_REP_NUM]; -} ZSTD_entropyTables_t; +} ZSTD_entropyDTables_t; struct ZSTD_DCtx_s { @@ -103,7 +94,7 @@ struct ZSTD_DCtx_s const FSE_DTable* MLTptr; const FSE_DTable* OFTptr; const HUF_DTable* HUFptr; - ZSTD_entropyTables_t entropy; + ZSTD_entropyDTables_t entropy; const void* previousDstEnd; /* detect continuity */ const void* base; /* start of current segment */ const void* vBase; /* virtual start of previous segment if it was just before current one */ @@ -304,15 +295,18 @@ size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t src return ZSTD_skippableHeaderSize; /* magic number + frame length */ memset(zfhPtr, 0, sizeof(*zfhPtr)); zfhPtr->frameContentSize = MEM_readLE32((const char *)src + 4); - zfhPtr->windowSize = 0; /* windowSize==0 means a frame is skippable */ + zfhPtr->frameType = ZSTD_skippableFrame; + zfhPtr->windowSize = 0; return 0; } return ERROR(prefix_unknown); } /* ensure there is enough `srcSize` to fully read/decode frame header */ - { size_t const fhsize = ZSTD_frameHeaderSize(src, srcSize); - if (srcSize < fhsize) return fhsize; } + { size_t const fhsize = ZSTD_frameHeaderSize(src, srcSize); + if (srcSize < fhsize) return fhsize; + zfhPtr->headerSize = (U32)fhsize; + } { BYTE const fhdByte = ip[4]; size_t pos = 5; @@ -320,24 +314,23 @@ size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t src U32 const checksumFlag = (fhdByte>>2)&1; U32 const singleSegment = (fhdByte>>5)&1; U32 const fcsID = fhdByte>>6; - U32 const windowSizeMax = 1U << ZSTD_WINDOWLOG_MAX; - U32 windowSize = 0; + U64 windowSize = 0; U32 dictID = 0; - U64 frameContentSize = 0; + U64 frameContentSize = ZSTD_CONTENTSIZE_UNKNOWN; if ((fhdByte & 0x08) != 0) - return ERROR(frameParameter_unsupported); /* reserved bits, must be zero */ + return ERROR(frameParameter_unsupported); /* reserved bits, must be zero */ + if (!singleSegment) { BYTE const wlByte = ip[pos++]; U32 const windowLog = (wlByte >> 3) + ZSTD_WINDOWLOG_ABSOLUTEMIN; if (windowLog > ZSTD_WINDOWLOG_MAX) return ERROR(frameParameter_windowTooLarge); - windowSize = (1U << windowLog); + windowSize = (1ULL << windowLog); windowSize += (windowSize >> 3) * (wlByte&7); } - switch(dictIDSizeCode) { - default: /* impossible */ + default: assert(0); /* impossible */ case 0 : break; case 1 : dictID = ip[pos]; pos++; break; case 2 : dictID = MEM_readLE16(ip+pos); pos+=2; break; @@ -345,14 +338,15 @@ size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t src } switch(fcsID) { - default: /* impossible */ + default: assert(0); /* impossible */ case 0 : if (singleSegment) frameContentSize = ip[pos]; break; case 1 : frameContentSize = MEM_readLE16(ip+pos)+256; break; case 2 : frameContentSize = MEM_readLE32(ip+pos); break; case 3 : frameContentSize = MEM_readLE64(ip+pos); break; } - if (!windowSize) windowSize = (U32)frameContentSize; - if (windowSize > windowSizeMax) return ERROR(frameParameter_windowTooLarge); + if (singleSegment) windowSize = frameContentSize; + + zfhPtr->frameType = ZSTD_frame; zfhPtr->frameContentSize = frameContentSize; zfhPtr->windowSize = windowSize; zfhPtr->dictID = dictID; @@ -362,10 +356,10 @@ size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t src } /** ZSTD_getFrameContentSize() : -* compatible with legacy mode -* @return : decompressed size of the single frame pointed to be `src` if known, otherwise -* - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined -* - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) */ + * compatible with legacy mode + * @return : decompressed size of the single frame pointed to be `src` if known, otherwise + * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined + * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) */ unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize) { #if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1) @@ -374,17 +368,14 @@ unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize) return ret == 0 ? ZSTD_CONTENTSIZE_UNKNOWN : ret; } #endif - { ZSTD_frameHeader fParams; - if (ZSTD_getFrameHeader(&fParams, src, srcSize) != 0) return ZSTD_CONTENTSIZE_ERROR; - if (fParams.windowSize == 0) { - /* Either skippable or empty frame, size == 0 either way */ + { ZSTD_frameHeader zfh; + if (ZSTD_getFrameHeader(&zfh, src, srcSize) != 0) + return ZSTD_CONTENTSIZE_ERROR; + if (zfh.frameType == ZSTD_skippableFrame) { return 0; - } else if (fParams.frameContentSize != 0) { - return fParams.frameContentSize; } else { - return ZSTD_CONTENTSIZE_UNKNOWN; - } - } + return zfh.frameContentSize; + } } } /** ZSTD_findDecompressedSize() : @@ -442,7 +433,8 @@ unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize) * compatible with legacy mode * @return : decompressed size if known, 0 otherwise note : 0 can mean any of the following : - - decompressed size is not present within frame header + - frame content is empty + - decompressed size field is not present in frame header - frame header unknown / not supported - frame header not complete (`srcSize` too small) */ unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize) @@ -460,7 +452,8 @@ static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t he size_t const result = ZSTD_getFrameHeader(&(dctx->fParams), src, headerSize); if (ZSTD_isError(result)) return result; /* invalid header */ if (result>0) return ERROR(srcSize_wrong); /* headerSize too small */ - if (dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID)) return ERROR(dictionary_wrong); + if (dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID)) + return ERROR(dictionary_wrong); if (dctx->fParams.checksumFlag) XXH64_reset(&dctx->xxhState, 0); return 0; } @@ -951,7 +944,7 @@ static seq_t ZSTD_decodeSequence(seqState_t* seqState) } -FORCE_INLINE +HINT_INLINE size_t ZSTD_execSequence(BYTE* op, BYTE* const oend, seq_t sequence, const BYTE** litPtr, const BYTE* const litLimit, @@ -1095,7 +1088,7 @@ static size_t ZSTD_decompressSequences( } -FORCE_INLINE seq_t ZSTD_decodeSequenceLong_generic(seqState_t* seqState, int const longOffsets) +FORCE_INLINE_TEMPLATE seq_t ZSTD_decodeSequenceLong_generic(seqState_t* seqState, int const longOffsets) { seq_t seq; @@ -1195,7 +1188,7 @@ static seq_t ZSTD_decodeSequenceLong(seqState_t* seqState, unsigned const window } } -FORCE_INLINE +HINT_INLINE size_t ZSTD_execSequenceLong(BYTE* op, BYTE* const oend, seq_t sequence, const BYTE** litPtr, const BYTE* const litLimit, @@ -1331,7 +1324,7 @@ static size_t ZSTD_decompressSequencesLong( seq_t const sequence = ZSTD_decodeSequenceLong(&seqState, windowSize32); size_t const oneSeqSize = ZSTD_execSequenceLong(op, oend, sequences[(seqNb-ADVANCED_SEQS) & STOSEQ_MASK], &litPtr, litEnd, base, vBase, dictEnd); if (ZSTD_isError(oneSeqSize)) return oneSeqSize; - ZSTD_PREFETCH(sequence.match); + PREFETCH(sequence.match); sequences[seqNb&STOSEQ_MASK] = sequence; op += oneSeqSize; } @@ -1433,28 +1426,26 @@ size_t ZSTD_generateNxBytes(void* dst, size_t dstCapacity, BYTE byte, size_t len size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize) { #if defined(ZSTD_LEGACY_SUPPORT) && (ZSTD_LEGACY_SUPPORT >= 1) - if (ZSTD_isLegacy(src, srcSize)) return ZSTD_findFrameCompressedSizeLegacy(src, srcSize); + if (ZSTD_isLegacy(src, srcSize)) + return ZSTD_findFrameCompressedSizeLegacy(src, srcSize); #endif - if (srcSize >= ZSTD_skippableHeaderSize && - (MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) { + if ( (srcSize >= ZSTD_skippableHeaderSize) + && (MEM_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START ) { return ZSTD_skippableHeaderSize + MEM_readLE32((const BYTE*)src + 4); } else { const BYTE* ip = (const BYTE*)src; const BYTE* const ipstart = ip; size_t remainingSize = srcSize; - ZSTD_frameHeader fParams; + ZSTD_frameHeader zfh; - size_t const headerSize = ZSTD_frameHeaderSize(ip, remainingSize); - if (ZSTD_isError(headerSize)) return headerSize; - - /* Frame Header */ - { size_t const ret = ZSTD_getFrameHeader(&fParams, ip, remainingSize); + /* Extract Frame Header */ + { size_t const ret = ZSTD_getFrameHeader(&zfh, src, srcSize); if (ZSTD_isError(ret)) return ret; if (ret > 0) return ERROR(srcSize_wrong); } - ip += headerSize; - remainingSize -= headerSize; + ip += zfh.headerSize; + remainingSize -= zfh.headerSize; /* Loop on each block */ while (1) { @@ -1462,7 +1453,8 @@ size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize) size_t const cBlockSize = ZSTD_getcBlockSize(ip, remainingSize, &blockProperties); if (ZSTD_isError(cBlockSize)) return cBlockSize; - if (ZSTD_blockHeaderSize + cBlockSize > remainingSize) return ERROR(srcSize_wrong); + if (ZSTD_blockHeaderSize + cBlockSize > remainingSize) + return ERROR(srcSize_wrong); ip += ZSTD_blockHeaderSize + cBlockSize; remainingSize -= ZSTD_blockHeaderSize + cBlockSize; @@ -1470,7 +1462,7 @@ size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize) if (blockProperties.lastBlock) break; } - if (fParams.checksumFlag) { /* Frame content checksum */ + if (zfh.checksumFlag) { /* Final frame content checksum */ if (remainingSize < 4) return ERROR(srcSize_wrong); ip += 4; remainingSize -= 4; @@ -1483,8 +1475,8 @@ size_t ZSTD_findFrameCompressedSize(const void *src, size_t srcSize) /*! ZSTD_decompressFrame() : * @dctx must be properly initialized */ static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx, - void* dst, size_t dstCapacity, - const void** srcPtr, size_t *srcSizePtr) + void* dst, size_t dstCapacity, + const void** srcPtr, size_t *srcSizePtr) { const BYTE* ip = (const BYTE*)(*srcPtr); BYTE* const ostart = (BYTE* const)dst; @@ -1493,13 +1485,15 @@ static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx, size_t remainingSize = *srcSizePtr; /* check */ - if (remainingSize < ZSTD_frameHeaderSize_min+ZSTD_blockHeaderSize) return ERROR(srcSize_wrong); + if (remainingSize < ZSTD_frameHeaderSize_min+ZSTD_blockHeaderSize) + return ERROR(srcSize_wrong); /* Frame Header */ { size_t const frameHeaderSize = ZSTD_frameHeaderSize(ip, ZSTD_frameHeaderSize_prefix); if (ZSTD_isError(frameHeaderSize)) return frameHeaderSize; - if (remainingSize < frameHeaderSize+ZSTD_blockHeaderSize) return ERROR(srcSize_wrong); - CHECK_F(ZSTD_decodeFrameHeader(dctx, ip, frameHeaderSize)); + if (remainingSize < frameHeaderSize+ZSTD_blockHeaderSize) + return ERROR(srcSize_wrong); + CHECK_F( ZSTD_decodeFrameHeader(dctx, ip, frameHeaderSize) ); ip += frameHeaderSize; remainingSize -= frameHeaderSize; } @@ -1531,14 +1525,15 @@ static size_t ZSTD_decompressFrame(ZSTD_DCtx* dctx, } if (ZSTD_isError(decodedSize)) return decodedSize; - if (dctx->fParams.checksumFlag) XXH64_update(&dctx->xxhState, op, decodedSize); + if (dctx->fParams.checksumFlag) + XXH64_update(&dctx->xxhState, op, decodedSize); op += decodedSize; ip += cBlockSize; remainingSize -= cBlockSize; if (blockProperties.lastBlock) break; } - if (dctx->fParams.checksumFlag) { /* Frame content checksum verification */ + if (dctx->fParams.checksumFlag) { /* Frame content checksum verification */ U32 const checkCalc = (U32)XXH64_digest(&dctx->xxhState); U32 checkRead; if (remainingSize<4) return ERROR(checksum_wrong); @@ -1560,17 +1555,13 @@ static size_t ZSTD_DDictDictSize(const ZSTD_DDict* ddict); static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize, - const void *dict, size_t dictSize, + const void* dict, size_t dictSize, const ZSTD_DDict* ddict) { void* const dststart = dst; + assert(dict==NULL || ddict==NULL); /* either dict or ddict set, not both */ if (ddict) { - if (dict) { - /* programmer error, these two cases should be mutually exclusive */ - return ERROR(GENERIC); - } - dict = ZSTD_DDictDictContent(ddict); dictSize = ZSTD_DDictDictSize(ddict); } @@ -1583,7 +1574,7 @@ static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx, size_t decodedSize; size_t const frameSize = ZSTD_findFrameCompressedSizeLegacy(src, srcSize); if (ZSTD_isError(frameSize)) return frameSize; - /* legacy support is incompatible with static dctx */ + /* legacy support is not compatible with static dctx */ if (dctx->staticSize) return ERROR(memory_allocation); decodedSize = ZSTD_decompressLegacy(dst, dstCapacity, src, frameSize, dict, dictSize); @@ -1606,16 +1597,13 @@ static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx, return ERROR(srcSize_wrong); skippableSize = MEM_readLE32((const BYTE *)src + 4) + ZSTD_skippableHeaderSize; - if (srcSize < skippableSize) { - return ERROR(srcSize_wrong); - } + if (srcSize < skippableSize) return ERROR(srcSize_wrong); src = (const BYTE *)src + skippableSize; srcSize -= skippableSize; continue; - } else { - return ERROR(prefix_unknown); } + return ERROR(prefix_unknown); } if (ddict) { @@ -1631,12 +1619,11 @@ static size_t ZSTD_decompressMultiFrame(ZSTD_DCtx* dctx, { const size_t res = ZSTD_decompressFrame(dctx, dst, dstCapacity, &src, &srcSize); if (ZSTD_isError(res)) return res; - /* don't need to bounds check this, ZSTD_decompressFrame will have - * already */ + /* no need to bound check, ZSTD_decompressFrame already has */ dst = (BYTE*)dst + res; dstCapacity -= res; } - } + } /* while (srcSize >= ZSTD_frameHeaderSize_prefix) */ if (srcSize) return ERROR(srcSize_wrong); /* input not entirely consumed */ @@ -1735,7 +1722,7 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, c return 0; } dctx->expected = 0; /* not necessary to copy more */ - + /* fall-through */ case ZSTDds_decodeFrameHeader: assert(src != NULL); memcpy(dctx->headerBuffer + ZSTD_frameHeaderSize_prefix, src, dctx->expected); @@ -1846,7 +1833,7 @@ static size_t ZSTD_refDictContent(ZSTD_DCtx* dctx, const void* dict, size_t dict /* ZSTD_loadEntropy() : * dict : must point at beginning of a valid zstd dictionary * @return : size of entropy tables read */ -static size_t ZSTD_loadEntropy(ZSTD_entropyTables_t* entropy, const void* const dict, size_t const dictSize) +static size_t ZSTD_loadEntropy(ZSTD_entropyDTables_t* entropy, const void* const dict, size_t const dictSize) { const BYTE* dictPtr = (const BYTE*)dict; const BYTE* const dictEnd = dictPtr + dictSize; @@ -1924,8 +1911,9 @@ static size_t ZSTD_decompress_insertDictionary(ZSTD_DCtx* dctx, const void* dict size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize) { - CHECK_F(ZSTD_decompressBegin(dctx)); - if (dict && dictSize) CHECK_E(ZSTD_decompress_insertDictionary(dctx, dict, dictSize), dictionary_corrupted); + CHECK_F( ZSTD_decompressBegin(dctx) ); + if (dict && dictSize) + CHECK_E(ZSTD_decompress_insertDictionary(dctx, dict, dictSize), dictionary_corrupted); return 0; } @@ -1936,7 +1924,7 @@ struct ZSTD_DDict_s { void* dictBuffer; const void* dictContent; size_t dictSize; - ZSTD_entropyTables_t entropy; + ZSTD_entropyDTables_t entropy; U32 dictID; U32 entropyPresent; ZSTD_customMem cMem; @@ -1954,7 +1942,7 @@ static size_t ZSTD_DDictDictSize(const ZSTD_DDict* ddict) size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dstDCtx, const ZSTD_DDict* ddict) { - CHECK_F(ZSTD_decompressBegin(dstDCtx)); + CHECK_F( ZSTD_decompressBegin(dstDCtx) ); if (ddict) { /* support begin on NULL */ dstDCtx->dictID = ddict->dictID; dstDCtx->base = ddict->dictContent; @@ -2135,7 +2123,7 @@ unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict) * ZSTD_getFrameHeader(), which will provide a more precise error code. */ unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize) { - ZSTD_frameHeader zfp = { 0 , 0 , 0 , 0 }; + ZSTD_frameHeader zfp = { 0, 0, ZSTD_frame, 0, 0, 0 }; size_t const hError = ZSTD_getFrameHeader(&zfp, src, srcSize); if (ZSTD_isError(hError)) return 0; return zfp.dictID; @@ -2230,7 +2218,7 @@ size_t ZSTD_setDStreamParameter(ZSTD_DStream* zds, { switch(paramType) { - default : return ERROR(parameter_unknown); + default : return ERROR(parameter_unsupported); case DStream_p_maxWindowSize : zds->maxWindowSize = paramValue ? paramValue : (U32)(-1); break; } return 0; @@ -2247,16 +2235,19 @@ size_t ZSTD_estimateDStreamSize(size_t windowSize) size_t const blockSize = MIN(windowSize, ZSTD_BLOCKSIZE_MAX); size_t const inBuffSize = blockSize; /* no block can be larger */ size_t const outBuffSize = windowSize + blockSize + (WILDCOPY_OVERLENGTH * 2); - return sizeof(ZSTD_DStream) + ZSTD_estimateDCtxSize() + inBuffSize + outBuffSize; + return ZSTD_estimateDCtxSize() + inBuffSize + outBuffSize; } ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize) { - ZSTD_frameHeader fh; - size_t const err = ZSTD_getFrameHeader(&fh, src, srcSize); + U32 const windowSizeMax = 1U << ZSTD_WINDOWLOG_MAX; + ZSTD_frameHeader zfh; + size_t const err = ZSTD_getFrameHeader(&zfh, src, srcSize); if (ZSTD_isError(err)) return err; if (err>0) return ERROR(srcSize_wrong); - return ZSTD_estimateDStreamSize(fh.windowSize); + if (zfh.windowSize > windowSizeMax) + return ERROR(frameParameter_windowTooLarge); + return ZSTD_estimateDStreamSize((size_t)zfh.windowSize); } @@ -2307,16 +2298,14 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB size_t const dictSize = zds->ddict ? zds->ddict->dictSize : 0; /* legacy support is incompatible with static dctx */ if (zds->staticSize) return ERROR(memory_allocation); - CHECK_F(ZSTD_initLegacyStream(&zds->legacyContext, zds->previousLegacyVersion, legacyVersion, - dict, dictSize)); + CHECK_F(ZSTD_initLegacyStream(&zds->legacyContext, + zds->previousLegacyVersion, legacyVersion, + dict, dictSize)); zds->legacyVersion = zds->previousLegacyVersion = legacyVersion; - return ZSTD_decompressLegacyStream(zds->legacyContext, zds->legacyVersion, output, input); - } else { - return hSize; /* error */ + return ZSTD_decompressLegacyStream(zds->legacyContext, legacyVersion, output, input); } -#else - return hSize; #endif + return hSize; /* error */ } if (hSize != 0) { /* need more input */ size_t const toLoad = hSize - zds->lhSize; /* if hSize!=0, hSize > zds->lhSize */ @@ -2367,8 +2356,8 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB if (zds->fParams.windowSize > zds->maxWindowSize) return ERROR(frameParameter_windowTooLarge); /* Adapt buffer sizes to frame header instructions */ - { size_t const blockSize = MIN(zds->fParams.windowSize, ZSTD_BLOCKSIZE_MAX); - size_t const neededOutSize = zds->fParams.windowSize + blockSize + WILDCOPY_OVERLENGTH * 2; + { size_t const blockSize = (size_t)(MIN(zds->fParams.windowSize, ZSTD_BLOCKSIZE_MAX)); + size_t const neededOutSize = (size_t)(zds->fParams.windowSize + blockSize + WILDCOPY_OVERLENGTH * 2); zds->blockSize = blockSize; if ((zds->inBuffSize < blockSize) || (zds->outBuffSize < neededOutSize)) { size_t const bufferSize = blockSize + neededOutSize; @@ -2393,7 +2382,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB zds->outBuffSize = neededOutSize; } } zds->streamStage = zdss_read; - /* pass-through */ + /* fall-through */ case zdss_read: DEBUGLOG(5, "stage zdss_read"); @@ -2418,8 +2407,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB } } if (ip==iend) { someMoreWork = 0; break; } /* no more input */ zds->streamStage = zdss_load; - /* pass-through */ - + /* fall-through */ case zdss_load: { size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds); size_t const toLoad = neededInSize - zds->inPos; /* should always be <= remaining space within inBuff */ @@ -2441,8 +2429,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inB zds->outEnd = zds->outStart + decodedSize; } } zds->streamStage = zdss_flush; - /* pass-through */ - + /* fall-through */ case zdss_flush: { size_t const toFlushSize = zds->outEnd - zds->outStart; size_t const flushedSize = ZSTD_limitCopy(op, oend-op, zds->outBuff + zds->outStart, toFlushSize); diff --git a/thirdparty/zstd/zstd.h b/thirdparty/zstd/zstd.h index 58e9a5606d..13b4563fd6 100644 --- a/thirdparty/zstd/zstd.h +++ b/thirdparty/zstd/zstd.h @@ -2,11 +2,10 @@ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under both the BSD-style license (found in the + * LICENSE file in the root directory of this source tree) and the GPLv2 (found + * in the COPYING file in the root directory of this source tree). */ - #if defined (__cplusplus) extern "C" { #endif @@ -59,7 +58,7 @@ extern "C" { /*------ Version ------*/ #define ZSTD_VERSION_MAJOR 1 #define ZSTD_VERSION_MINOR 3 -#define ZSTD_VERSION_RELEASE 0 +#define ZSTD_VERSION_RELEASE 1 #define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE) ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< useful to check dll version */ @@ -425,13 +424,6 @@ typedef struct { ZSTD_frameParameters fParams; } ZSTD_parameters; -typedef struct { - unsigned long long frameContentSize; - size_t windowSize; - unsigned dictID; - unsigned checksumFlag; -} ZSTD_frameHeader; - /*= Custom memory allocation functions */ typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size); typedef void (*ZSTD_freeFunction) (void* opaque, void* address); @@ -809,7 +801,6 @@ ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstC ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); - /*- Buffer-less streaming decompression (synchronous mode) @@ -874,6 +865,15 @@ ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapaci */ /*===== Buffer-less streaming decompression functions =====*/ +typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_frameType_e; +typedef struct { + unsigned long long frameContentSize; /* ZSTD_CONTENTSIZE_UNKNOWN means this field is not available. 0 means "empty" */ + unsigned long long windowSize; /* can be very large, up to <= frameContentSize */ + ZSTD_frameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */ + unsigned headerSize; + unsigned dictID; + unsigned checksumFlag; +} ZSTD_frameHeader; ZSTDLIB_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */ ZSTDLIB_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx); ZSTDLIB_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); @@ -953,7 +953,9 @@ typedef enum { * Special: value 0 means "do not change strategy". */ /* frame parameters */ - ZSTD_p_contentSizeFlag=200, /* Content size is written into frame header _whenever known_ (default:1) */ + ZSTD_p_contentSizeFlag=200, /* Content size is written into frame header _whenever known_ (default:1) + * note that content size must be known at the beginning, + * it is sent using ZSTD_CCtx_setPledgedSrcSize() */ ZSTD_p_checksumFlag, /* A 32-bits checksum of content is written at end of frame (default:0) */ ZSTD_p_dictIDFlag, /* When applicable, dictID of dictionary is provided in frame header (default:1) */ |