diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/class_db.cpp | 19 | ||||
| -rw-r--r-- | core/class_db.h | 1 | ||||
| -rw-r--r-- | core/command_queue_mt.h | 46 | ||||
| -rw-r--r-- | core/error_macros.cpp | 7 | ||||
| -rw-r--r-- | core/error_macros.h | 41 | ||||
| -rw-r--r-- | core/global_constants.cpp | 150 | ||||
| -rw-r--r-- | core/image.cpp | 1 | ||||
| -rw-r--r-- | core/io/logger.cpp | 6 | ||||
| -rw-r--r-- | core/io/resource_format_binary.cpp | 18 | ||||
| -rw-r--r-- | core/make_binders.py | 2 | ||||
| -rw-r--r-- | core/math/a_star.cpp | 1 | ||||
| -rw-r--r-- | core/math/math_funcs.h | 17 | ||||
| -rw-r--r-- | core/math/matrix3.cpp | 13 | ||||
| -rw-r--r-- | core/math/matrix3.h | 15 | ||||
| -rw-r--r-- | core/os/input_event.cpp | 2 | ||||
| -rw-r--r-- | core/os/input_event.h | 4 | ||||
| -rw-r--r-- | core/os/main_loop.cpp | 1 | ||||
| -rw-r--r-- | core/typedefs.h | 4 | ||||
| -rw-r--r-- | core/variant.h | 8 | ||||
| -rw-r--r-- | core/variant_op.cpp | 8 |
20 files changed, 217 insertions, 147 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp index 12310f6151..57e88044b5 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -187,6 +187,25 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_ return md; } +MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11) { + + MethodDefinition md; + md.name = StaticCString::create(p_name); + md.args.resize(11); + md.args[0] = StaticCString::create(p_arg1); + md.args[1] = StaticCString::create(p_arg2); + md.args[2] = StaticCString::create(p_arg3); + md.args[3] = StaticCString::create(p_arg4); + md.args[4] = StaticCString::create(p_arg5); + md.args[5] = StaticCString::create(p_arg6); + md.args[6] = StaticCString::create(p_arg7); + md.args[7] = StaticCString::create(p_arg8); + md.args[8] = StaticCString::create(p_arg9); + md.args[9] = StaticCString::create(p_arg10); + md.args[10] = StaticCString::create(p_arg11); + return md; +} + #endif ClassDB::APIType ClassDB::current_api = API_CORE; diff --git a/core/class_db.h b/core/class_db.h index 5910a2ce01..24db4c61bb 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -66,6 +66,7 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8); MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9); MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10); +MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11); #else diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index f99e16da15..e37d593f9f 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -227,6 +227,27 @@ class CommandQueueMT { virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); } }; + template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12> + struct Command12 : public CommandBase { + + T *instance; + M method; + typename GetSimpleTypeT<P1>::type_t p1; + typename GetSimpleTypeT<P2>::type_t p2; + typename GetSimpleTypeT<P3>::type_t p3; + typename GetSimpleTypeT<P4>::type_t p4; + typename GetSimpleTypeT<P5>::type_t p5; + typename GetSimpleTypeT<P6>::type_t p6; + typename GetSimpleTypeT<P7>::type_t p7; + typename GetSimpleTypeT<P8>::type_t p8; + typename GetSimpleTypeT<P9>::type_t p9; + typename GetSimpleTypeT<P10>::type_t p10; + typename GetSimpleTypeT<P11>::type_t p11; + typename GetSimpleTypeT<P12>::type_t p12; + + virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); } + }; + /* comands that return */ template <class T, class M, class R> @@ -906,6 +927,31 @@ public: if (sync) sync->post(); } + template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12> + void push(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12) { + + Command12<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> *cmd = allocate_and_lock<Command12<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> >(); + + cmd->instance = p_instance; + cmd->method = p_method; + cmd->p1 = p1; + cmd->p2 = p2; + cmd->p3 = p3; + cmd->p4 = p4; + cmd->p5 = p5; + cmd->p6 = p6; + cmd->p7 = p7; + cmd->p8 = p8; + cmd->p9 = p9; + cmd->p10 = p10; + cmd->p11 = p11; + cmd->p12 = p12; + + unlock(); + + if (sync) sync->post(); + } + /*** PUSH AND RET COMMANDS ***/ template <class T, class M, class R> diff --git a/core/error_macros.cpp b/core/error_macros.cpp index 170a22e8dd..7d85aa9001 100644 --- a/core/error_macros.cpp +++ b/core/error_macros.cpp @@ -97,3 +97,10 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co _err_error_exists = false; } } + +void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, bool fatal) { + + String fstr(fatal ? "FATAL: " : ""); + String err(fstr + "Index" + p_index_str + "=" + itos(p_index) + " out of size (" + p_size_str + "=" + itos(p_size) + ")"); + _err_print_error(p_function, p_file, p_line, err.utf8().get_data()); +} diff --git a/core/error_macros.h b/core/error_macros.h index 1fa7f2c134..8d2f588706 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -76,6 +76,7 @@ void add_error_handler(ErrorHandlerList *p_handler); void remove_error_handler(ErrorHandlerList *p_handler); void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, ErrorHandlerType p_type = ERR_HANDLER_ERROR); +void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, bool fatal = false); #ifndef _STR #define _STR(m_x) #m_x @@ -129,13 +130,13 @@ extern bool _err_error_exists; // (*): See https://stackoverflow.com/questions/257418/do-while-0-what-is-it-good-for -#define ERR_FAIL_INDEX(m_index, m_size) \ - do { \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ - _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Index " _STR(m_index) " out of size (" _STR(m_size) ")."); \ - return; \ - } else \ - _err_error_exists = false; \ +#define ERR_FAIL_INDEX(m_index, m_size) \ + do { \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ + _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \ + return; \ + } else \ + _err_error_exists = false; \ } while (0); // (*) /** An index has failed if m_index<0 or m_index >=m_size, the function exists. @@ -143,24 +144,24 @@ extern bool _err_error_exists; * appropriate error condition from error_macros.h */ -#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \ - do { \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ - _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Index " _STR(m_index) " out of size (" _STR(m_size) ")."); \ - return m_retval; \ - } else \ - _err_error_exists = false; \ +#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \ + do { \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ + _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \ + return m_retval; \ + } else \ + _err_error_exists = false; \ } while (0); // (*) /** Use this one if there is no sensible fallback, that is, the error is unrecoverable. * We'll return a null reference and try to keep running. */ -#define CRASH_BAD_INDEX(m_index, m_size) \ - do { \ - if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ - _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Index " _STR(m_index) " out of size (" _STR(m_size) ")."); \ - GENERATE_TRAP \ - } \ +#define CRASH_BAD_INDEX(m_index, m_size) \ + do { \ + if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \ + _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), true); \ + GENERATE_TRAP \ + } \ } while (0); // (*) /** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert(). diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 6f58af2ccf..8bddeae69a 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -86,6 +86,8 @@ static Vector<_GlobalConstant> _global_constants; VARIANT_ENUM_CAST(KeyList); VARIANT_ENUM_CAST(KeyModifierMask); +VARIANT_ENUM_CAST(ButtonList); +VARIANT_ENUM_CAST(JoystickList); void register_global_constants() { @@ -367,82 +369,82 @@ void register_global_constants() { BIND_GLOBAL_ENUM_CONSTANT(KEY_MASK_GROUP_SWITCH); // mouse - BIND_GLOBAL_CONSTANT(BUTTON_LEFT); - BIND_GLOBAL_CONSTANT(BUTTON_RIGHT); - BIND_GLOBAL_CONSTANT(BUTTON_MIDDLE); - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_UP); - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_DOWN); - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_LEFT); - BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_RIGHT); - BIND_GLOBAL_CONSTANT(BUTTON_MASK_LEFT); - BIND_GLOBAL_CONSTANT(BUTTON_MASK_RIGHT); - BIND_GLOBAL_CONSTANT(BUTTON_MASK_MIDDLE); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_RIGHT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MIDDLE); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_UP); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_DOWN); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_RIGHT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_RIGHT); + BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_MIDDLE); //joypads - BIND_GLOBAL_CONSTANT(JOY_BUTTON_0); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_1); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_2); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_3); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_4); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_5); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_6); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_7); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_8); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_9); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_10); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_11); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_12); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_13); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_14); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_15); - BIND_GLOBAL_CONSTANT(JOY_BUTTON_MAX); - - BIND_GLOBAL_CONSTANT(JOY_SONY_CIRCLE); - BIND_GLOBAL_CONSTANT(JOY_SONY_X); - BIND_GLOBAL_CONSTANT(JOY_SONY_SQUARE); - BIND_GLOBAL_CONSTANT(JOY_SONY_TRIANGLE); - - BIND_GLOBAL_CONSTANT(JOY_XBOX_B); - BIND_GLOBAL_CONSTANT(JOY_XBOX_A); - BIND_GLOBAL_CONSTANT(JOY_XBOX_X); - BIND_GLOBAL_CONSTANT(JOY_XBOX_Y); - - BIND_GLOBAL_CONSTANT(JOY_DS_A); - BIND_GLOBAL_CONSTANT(JOY_DS_B); - BIND_GLOBAL_CONSTANT(JOY_DS_X); - BIND_GLOBAL_CONSTANT(JOY_DS_Y); - - BIND_GLOBAL_CONSTANT(JOY_SELECT); - BIND_GLOBAL_CONSTANT(JOY_START); - BIND_GLOBAL_CONSTANT(JOY_DPAD_UP); - BIND_GLOBAL_CONSTANT(JOY_DPAD_DOWN); - BIND_GLOBAL_CONSTANT(JOY_DPAD_LEFT); - BIND_GLOBAL_CONSTANT(JOY_DPAD_RIGHT); - BIND_GLOBAL_CONSTANT(JOY_L); - BIND_GLOBAL_CONSTANT(JOY_L2); - BIND_GLOBAL_CONSTANT(JOY_L3); - BIND_GLOBAL_CONSTANT(JOY_R); - BIND_GLOBAL_CONSTANT(JOY_R2); - BIND_GLOBAL_CONSTANT(JOY_R3); - - BIND_GLOBAL_CONSTANT(JOY_AXIS_0); - BIND_GLOBAL_CONSTANT(JOY_AXIS_1); - BIND_GLOBAL_CONSTANT(JOY_AXIS_2); - BIND_GLOBAL_CONSTANT(JOY_AXIS_3); - BIND_GLOBAL_CONSTANT(JOY_AXIS_4); - BIND_GLOBAL_CONSTANT(JOY_AXIS_5); - BIND_GLOBAL_CONSTANT(JOY_AXIS_6); - BIND_GLOBAL_CONSTANT(JOY_AXIS_7); - BIND_GLOBAL_CONSTANT(JOY_AXIS_MAX); - - BIND_GLOBAL_CONSTANT(JOY_ANALOG_LX); - BIND_GLOBAL_CONSTANT(JOY_ANALOG_LY); - - BIND_GLOBAL_CONSTANT(JOY_ANALOG_RX); - BIND_GLOBAL_CONSTANT(JOY_ANALOG_RY); - - BIND_GLOBAL_CONSTANT(JOY_ANALOG_L2); - BIND_GLOBAL_CONSTANT(JOY_ANALOG_R2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_0); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_1); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_3); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_4); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_5); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_6); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_7); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_8); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_9); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_10); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_11); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_12); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_13); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_14); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_15); + BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_MAX); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_CIRCLE); + BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_X); + BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_SQUARE); + BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_TRIANGLE); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_B); + BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_A); + BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_X); + BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_Y); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_A); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_B); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_X); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_Y); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_SELECT); + BIND_GLOBAL_ENUM_CONSTANT(JOY_START); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_UP); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_DOWN); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_LEFT); + BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_RIGHT); + BIND_GLOBAL_ENUM_CONSTANT(JOY_L); + BIND_GLOBAL_ENUM_CONSTANT(JOY_L2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_L3); + BIND_GLOBAL_ENUM_CONSTANT(JOY_R); + BIND_GLOBAL_ENUM_CONSTANT(JOY_R2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_R3); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_0); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_1); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_3); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_4); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_5); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_6); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_7); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_MAX); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_LX); + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_LY); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_RX); + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_RY); + + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_L2); + BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_R2); // error list diff --git a/core/image.cpp b/core/image.cpp index 943cbaf51d..42684e7ea7 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1061,7 +1061,6 @@ Error Image::generate_mipmaps() { int size = _get_dst_image_size(width, height, format, mmcount); data.resize(size); - print_line("to gen mipmaps w " + itos(width) + " h " + itos(height) + " format " + get_format_name(format) + " mipmaps " + itos(mmcount) + " new size is: " + itos(size)); PoolVector<uint8_t>::Write wp = data.write(); diff --git a/core/io/logger.cpp b/core/io/logger.cpp index ad6371f1e1..ce2ce44b1d 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -110,7 +110,7 @@ void RotatedFileLogger::close_file() { void RotatedFileLogger::clear_old_backups() { int max_backups = max_files - 1; // -1 for the current file - String basename = base_path.get_basename(); + String basename = base_path.get_file().get_basename(); String extension = "." + base_path.get_extension(); DirAccess *da = DirAccess::open(base_path.get_base_dir()); @@ -122,7 +122,7 @@ void RotatedFileLogger::clear_old_backups() { String f = da->get_next(); Set<String> backups; while (f != String()) { - if (!da->current_is_dir() && f.begins_with(basename) && f.ends_with(extension) && f != base_path) { + if (!da->current_is_dir() && f.begins_with(basename) && f.ends_with(extension) && f != base_path.get_file()) { backups.insert(f); } f = da->get_next(); @@ -149,7 +149,7 @@ void RotatedFileLogger::rotate_file() { char timestamp[21]; OS::Date date = OS::get_singleton()->get_date(); OS::Time time = OS::get_singleton()->get_time(); - sprintf(timestamp, "-%04d-%02d-%02d-%02d-%02d-%02d", date.year, date.month, date.day + 1, time.hour, time.min, time.sec); + sprintf(timestamp, "-%04d-%02d-%02d-%02d-%02d-%02d", date.year, date.month, date.day, time.hour, time.min, time.sec); String backup_name = base_path.get_basename() + timestamp + "." + base_path.get_extension(); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 900db7c2dc..03c3c5f615 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -282,7 +282,6 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { property = _get_string(); NodePath np = NodePath(names, subnames, absolute, property); - //print_line("got path: "+String(np)); r_v = np; @@ -640,7 +639,6 @@ Error ResourceInteractiveLoaderBinary::poll() { String path = external_resources[s].path; - print_line("load external res: " + path); if (remaps.has(path)) { path = remaps[path]; } @@ -706,8 +704,6 @@ Error ResourceInteractiveLoaderBinary::poll() { String t = get_unicode_string(); - // print_line("loading resource of type "+t+" path is "+path); - Object *obj = ClassDB::instance(t); if (!obj) { error = ERR_FILE_CORRUPT; @@ -907,20 +903,6 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) { external_resources.push_back(er); } - //see if the exporter has different set of external resources for more efficient loading - /* - String preload_depts = "deps/"+res_path.md5_text(); - if (Globals::get_singleton()->has(preload_depts)) { - external_resources.clear(); - //ignore external resources and use these - NodePath depts=Globals::get_singleton()->get(preload_depts); - external_resources.resize(depts.get_name_count()); - for(int i=0;i<depts.get_name_count();i++) { - external_resources[i].path=depts.get_name(i); - } - print_line(res_path+" - EXTERNAL RESOURCES: "+itos(external_resources.size())); - }*/ - print_bl("ext resources: " + itos(ext_resources_size)); uint32_t int_resources_size = f->get_32(); diff --git a/core/make_binders.py b/core/make_binders.py index 6468c029f0..6f42c6e8eb 100644 --- a/core/make_binders.py +++ b/core/make_binders.py @@ -244,7 +244,7 @@ def make_version(template, nargs, argmax, const, ret): def run(target, source, env): - versions = 10 + versions = 11 versions_ext = 6 text = "" text_ext = "" diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 4f80fb2491..ffe1089965 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -443,4 +443,5 @@ AStar::AStar() { AStar::~AStar() { pass = 1; + clear(); } diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index d63da322a5..65b2ffb0df 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -387,6 +387,23 @@ public: return hf; } + + static _ALWAYS_INLINE_ float snap_scalar(float p_offset, float p_step, float p_target) { + return p_step != 0 ? Math::stepify(p_target - p_offset, p_step) + p_offset : p_target; + } + + static _ALWAYS_INLINE_ float snap_scalar_seperation(float p_offset, float p_step, float p_target, float p_separation) { + if (p_step != 0) { + float a = Math::stepify(p_target - p_offset, p_step + p_separation) + p_offset; + float b = a; + if (p_target >= 0) + b -= p_separation; + else + b += p_step; + return (Math::abs(p_target - a) < Math::abs(p_target - b)) ? a : b; + } + return p_target; + } }; #endif // MATH_FUNCS_H diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index 4051de7afb..85421c074b 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -538,7 +538,7 @@ Basis::operator String() const { return mtx; } -Basis::operator Quat() const { +Quat Basis::get_quat() const { //commenting this check because precision issues cause it to fail when it shouldn't //#ifdef MATH_CHECKS //ERR_FAIL_COND_V(is_rotation() == false, Quat()); @@ -710,12 +710,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const { r_angle = angle; } -Basis::Basis(const Vector3 &p_euler) { - - set_euler(p_euler); -} - -Basis::Basis(const Quat &p_quat) { +void Basis::set_quat(const Quat &p_quat) { real_t d = p_quat.length_squared(); real_t s = 2.0 / d; @@ -750,7 +745,3 @@ void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) { elements[2][1] = p_axis.y * p_axis.z * (1.0 - cosine) + p_axis.x * sine; elements[2][2] = axis_sq.z + cosine * (1.0 - axis_sq.z); } - -Basis::Basis(const Vector3 &p_axis, real_t p_phi) { - set_axis_angle(p_axis, p_phi); -} diff --git a/core/math/matrix3.h b/core/math/matrix3.h index 23429888e0..9a33b8203d 100644 --- a/core/math/matrix3.h +++ b/core/math/matrix3.h @@ -88,8 +88,11 @@ public: Vector3 get_euler_yxz() const; void set_euler_yxz(const Vector3 &p_euler); - Vector3 get_euler() const { return get_euler_yxz(); }; - void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); }; + Quat get_quat() const; + void set_quat(const Quat &p_quat); + + Vector3 get_euler() const { return get_euler_yxz(); } + void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); } void get_axis_angle(Vector3 &r_axis, real_t &r_angle) const; void set_axis_angle(const Vector3 &p_axis, real_t p_phi); @@ -205,11 +208,11 @@ public: bool is_symmetric() const; Basis diagonalize(); - operator Quat() const; + operator Quat() const { return get_quat(); } - Basis(const Quat &p_quat); // euler - Basis(const Vector3 &p_euler); // euler - Basis(const Vector3 &p_axis, real_t p_phi); + Basis(const Quat &p_quat) { set_quat(p_quat); }; + Basis(const Vector3 &p_euler) { set_euler(p_euler); } + Basis(const Vector3 &p_axis, real_t p_phi) { set_axis_angle(p_axis, p_phi); } _FORCE_INLINE_ Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) { elements[0] = row0; diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index bef98ac3f2..6b43f2c63b 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -637,7 +637,7 @@ bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event) const if (jm.is_null()) return false; - return (axis == jm->axis && (axis_value < 0) == (jm->axis_value < 0)); + return (axis == jm->axis && ((axis_value < 0) == (jm->axis_value < 0) || jm->axis_value == 0)); } String InputEventJoypadMotion::as_text() const { diff --git a/core/os/input_event.h b/core/os/input_event.h index 5dc0f91d5f..f2c8cc802d 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -44,7 +44,7 @@ * The events are pretty obvious. */ -enum { +enum ButtonList { BUTTON_LEFT = 1, BUTTON_RIGHT = 2, BUTTON_MIDDLE = 3, @@ -58,7 +58,7 @@ enum { }; -enum { +enum JoystickList { JOY_BUTTON_0 = 0, JOY_BUTTON_1 = 1, diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index b146d370f1..8b4449586b 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -52,6 +52,7 @@ void MainLoop::_bind_methods() { BIND_CONSTANT(NOTIFICATION_WM_FOCUS_IN); BIND_CONSTANT(NOTIFICATION_WM_FOCUS_OUT); BIND_CONSTANT(NOTIFICATION_WM_QUIT_REQUEST); + BIND_CONSTANT(NOTIFICATION_WM_GO_BACK_REQUEST); BIND_CONSTANT(NOTIFICATION_WM_UNFOCUS_REQUEST); BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING); BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED); diff --git a/core/typedefs.h b/core/typedefs.h index bf5c8b0f75..c509edf9fe 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -98,11 +98,11 @@ T *_nullptr() { #undef OK #endif +#include "int_types.h" + #include "error_list.h" #include "error_macros.h" -#include "int_types.h" - /** Generic ABS function, for math uses please use Math::abs */ #ifndef ABS diff --git a/core/variant.h b/core/variant.h index e0d0bf05c8..45066af401 100644 --- a/core/variant.h +++ b/core/variant.h @@ -99,15 +99,15 @@ public: _RID, OBJECT, DICTIONARY, - ARRAY, // 20 + ARRAY, // arrays - POOL_BYTE_ARRAY, + POOL_BYTE_ARRAY, // 20 POOL_INT_ARRAY, POOL_REAL_ARRAY, POOL_STRING_ARRAY, - POOL_VECTOR2_ARRAY, // 25 - POOL_VECTOR3_ARRAY, + POOL_VECTOR2_ARRAY, + POOL_VECTOR3_ARRAY, // 25 POOL_COLOR_ARRAY, VARIANT_MAX diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 03ec336291..6362090902 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -1655,13 +1655,13 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } else if (p_index == CoreStringNames::singleton->a) { return v->a; } else if (p_index == CoreStringNames::singleton->r8) { - return v->r * 255.0; + return int(v->r * 255.0); } else if (p_index == CoreStringNames::singleton->g8) { - return v->g * 255.0; + return int(v->g * 255.0); } else if (p_index == CoreStringNames::singleton->b8) { - return v->b * 255.0; + return int(v->b * 255.0); } else if (p_index == CoreStringNames::singleton->a8) { - return v->a * 255.0; + return int(v->a * 255.0); } else if (p_index == CoreStringNames::singleton->h) { return v->get_h(); } else if (p_index == CoreStringNames::singleton->s) { |