diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/array.cpp | 72 | ||||
-rw-r--r-- | core/array.h | 3 | ||||
-rw-r--r-- | core/debugger/remote_debugger.cpp | 33 | ||||
-rw-r--r-- | core/debugger/remote_debugger.h | 11 | ||||
-rw-r--r-- | core/input/input_event.cpp | 2 | ||||
-rw-r--r-- | core/math/octree.h | 4 | ||||
-rw-r--r-- | core/os/os.h | 2 |
7 files changed, 76 insertions, 51 deletions
diff --git a/core/array.cpp b/core/array.cpp index cd4e0fb4c8..7c0129ffde 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -285,59 +285,49 @@ Array Array::duplicate(bool p_deep) const { return new_arr; } -int Array::_fix_slice_index(int p_index, int p_arr_len, int p_top_mod) { - p_index = CLAMP(p_index, -p_arr_len, p_arr_len + p_top_mod); - if (p_index < 0) { - p_index = (p_index % p_arr_len + p_arr_len) % p_arr_len; // positive modulo - } - return p_index; -} +int Array::_clamp_slice_index(int p_index) const { -int Array::_clamp_index(int p_index) const { - return CLAMP(p_index, -size() + 1, size() - 1); + int arr_size = size(); + int fixed_index = CLAMP(p_index, -arr_size, arr_size - 1); + if (fixed_index < 0) { + fixed_index = arr_size + fixed_index; + } + return fixed_index; } -#define ARRAY_GET_DEEP(idx, is_deep) is_deep ? get(idx).duplicate(is_deep) : get(idx) - Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // like python, but inclusive on upper bound - Array new_arr; - - if (empty()) // Don't try to slice empty arrays. - return new_arr; - p_begin = Array::_fix_slice_index(p_begin, size(), -1); // can't start out of range - p_end = Array::_fix_slice_index(p_end, size(), 0); + Array new_arr; - int x = p_begin; - int new_arr_i = 0; + ERR_FAIL_COND_V_MSG(p_step == 0, new_arr, "Array slice step size cannot be zero."); - ERR_FAIL_COND_V(p_step == 0, new_arr); - if (Array::_clamp_index(p_begin) == Array::_clamp_index(p_end)) { // don't include element twice - new_arr.resize(1); - // new_arr[0] = 1; - new_arr[0] = ARRAY_GET_DEEP(Array::_clamp_index(p_begin), p_deep); + if (empty()) // Don't try to slice empty arrays. return new_arr; - } else { - int element_count = ceil((int)MAX(0, (p_end - p_begin) / p_step)) + 1; - if (element_count == 1) { // delta going in wrong direction to reach end - new_arr.resize(0); + if (p_step > 0) { + if (p_begin >= size() || p_end < -size()) + return new_arr; + } else { // p_step < 0 + if (p_begin < -size() || p_end >= size()) return new_arr; - } - new_arr.resize(element_count); } - // if going backwards, have to have a different terminating condition - if (p_step < 0) { - while (x >= p_end) { - new_arr[new_arr_i] = ARRAY_GET_DEEP(Array::_clamp_index(x), p_deep); - x += p_step; - new_arr_i += 1; + int begin = _clamp_slice_index(p_begin); + int end = _clamp_slice_index(p_end); + + int new_arr_size = MAX(((end - begin + p_step) / p_step), 0); + new_arr.resize(new_arr_size); + + if (p_step > 0) { + int dest_idx = 0; + for (int idx = begin; idx <= end; idx += p_step) { + ERR_FAIL_COND_V_MSG(dest_idx < 0 || dest_idx >= new_arr_size, Array(), "Bug in Array slice()"); + new_arr[dest_idx++] = p_deep ? get(idx).duplicate(p_deep) : get(idx); } - } else if (p_step > 0) { - while (x <= p_end) { - new_arr[new_arr_i] = ARRAY_GET_DEEP(Array::_clamp_index(x), p_deep); - x += p_step; - new_arr_i += 1; + } else { // p_step < 0 + int dest_idx = 0; + for (int idx = begin; idx >= end; idx += p_step) { + ERR_FAIL_COND_V_MSG(dest_idx < 0 || dest_idx >= new_arr_size, Array(), "Bug in Array slice()"); + new_arr[dest_idx++] = p_deep ? get(idx).duplicate(p_deep) : get(idx); } } diff --git a/core/array.h b/core/array.h index 2840ce199c..14db57f15f 100644 --- a/core/array.h +++ b/core/array.h @@ -44,8 +44,7 @@ class Array { void _ref(const Array &p_from) const; void _unref() const; - int _clamp_index(int p_index) const; - static int _fix_slice_index(int p_index, int p_arr_len, int p_top_mod); + inline int _clamp_slice_index(int p_index) const; protected: Array(const Array &p_base, uint32_t p_type, const StringName &p_class_name, const Variant &p_script); diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index 95babc1784..97d5c71b6f 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -480,10 +480,16 @@ void RemoteDebugger::_print_handler(void *p_this, const String &p_string, bool p if (rd->is_peer_connected()) { if (overflowed) s += "[...]"; - rd->output_strings.push_back(s); + + OutputString output_string; + output_string.message = s; + output_string.type = p_error ? MESSAGE_TYPE_ERROR : MESSAGE_TYPE_LOG; + rd->output_strings.push_back(output_string); if (overflowed) { - rd->output_strings.push_back("[output overflow, print less text!]"); + output_string.message = "[output overflow, print less text!]"; + output_string.type = MESSAGE_TYPE_ERROR; + rd->output_strings.push_back(output_string); } } } @@ -517,15 +523,32 @@ void RemoteDebugger::flush_output() { if (output_strings.size()) { // Join output strings so we generate less messages. + Vector<String> joined_log_strings; Vector<String> strings; - strings.resize(output_strings.size()); - String *w = strings.ptrw(); + Vector<int> types; for (int i = 0; i < output_strings.size(); i++) { - w[i] = output_strings[i]; + const OutputString &output_string = output_strings[i]; + if (output_string.type == MESSAGE_TYPE_ERROR) { + if (!joined_log_strings.empty()) { + strings.push_back(String("\n").join(joined_log_strings)); + types.push_back(MESSAGE_TYPE_LOG); + joined_log_strings.clear(); + } + strings.push_back(output_string.message); + types.push_back(MESSAGE_TYPE_ERROR); + } else { + joined_log_strings.push_back(output_string.message); + } + } + + if (!joined_log_strings.empty()) { + strings.push_back(String("\n").join(joined_log_strings)); + types.push_back(MESSAGE_TYPE_LOG); } Array arr; arr.push_back(strings); + arr.push_back(types); _put_msg("output", arr); output_strings.clear(); } diff --git a/core/debugger/remote_debugger.h b/core/debugger/remote_debugger.h index f805eec631..cac0bc3730 100644 --- a/core/debugger/remote_debugger.h +++ b/core/debugger/remote_debugger.h @@ -40,6 +40,11 @@ #include "core/ustring.h" class RemoteDebugger : public EngineDebugger { +public: + enum MessageType { + MESSAGE_TYPE_LOG, + MESSAGE_TYPE_ERROR, + }; private: typedef DebuggerMarshalls::OutputError ErrorMessage; @@ -57,7 +62,11 @@ private: Ref<RemoteDebuggerPeer> peer; - List<String> output_strings; + struct OutputString { + String message; + MessageType type; + }; + List<OutputString> output_strings; List<ErrorMessage> errors; int n_messages_dropped = 0; diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index d18adb1983..4b8c104f39 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -708,7 +708,7 @@ String InputEventMouseMotion::as_text() const { button_mask_string = itos(get_button_mask()); break; } - return "InputEventMouseMotion : button_mask=" + button_mask_string + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")"; + return "InputEventMouseMotion : button_mask=" + button_mask_string + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + "), pressure=(" + rtos(get_pressure()) + "), tilt=(" + String(get_tilt()) + ")"; } bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) { diff --git a/core/math/octree.h b/core/math/octree.h index 2060a61b4b..ffb405bd0f 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -1290,10 +1290,12 @@ void Octree<T, use_pairs, AL>::_cull_point(Octant *p_octant, const Vector3 &p_po template <class T, bool use_pairs, class AL> int Octree<T, use_pairs, AL>::cull_convex(const Vector<Plane> &p_convex, T **p_result_array, int p_result_max, uint32_t p_mask) { - if (!root) + if (!root || p_convex.size() == 0) return 0; Vector<Vector3> convex_points = Geometry::compute_convex_mesh_points(&p_convex[0], p_convex.size()); + if (convex_points.size() == 0) + return 0; int result_count = 0; pass++; diff --git a/core/os/os.h b/core/os/os.h index 714a10bf76..38114e6814 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -59,6 +59,7 @@ class OS { bool _allow_layered; bool _use_vsync; bool _vsync_via_compositor; + bool _disable_wintab; char *last_error; @@ -148,6 +149,7 @@ public: bool is_layered_allowed() const { return _allow_layered; } bool is_hidpi_allowed() const { return _allow_hidpi; } + bool is_wintab_disabled() const { return _disable_wintab; } void ensure_user_data_dir(); |