diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/SCsub | 6 | ||||
| -rw-r--r-- | core/core_string_names.cpp | 3 | ||||
| -rw-r--r-- | core/core_string_names.h | 3 | ||||
| -rw-r--r-- | core/image.cpp | 57 | ||||
| -rw-r--r-- | core/image.h | 1 | ||||
| -rw-r--r-- | core/method_bind.h | 2 | ||||
| -rw-r--r-- | core/object.cpp | 42 | ||||
| -rw-r--r-- | core/object.h | 6 | ||||
| -rw-r--r-- | core/os/input_event.cpp | 2 | ||||
| -rw-r--r-- | core/ustring.cpp | 12 | ||||
| -rw-r--r-- | core/variant_op.cpp | 42 | ||||
| -rw-r--r-- | core/version.h | 2 |
12 files changed, 153 insertions, 25 deletions
diff --git a/core/SCsub b/core/SCsub index da2403f1d..02abaa2bb 100644 --- a/core/SCsub +++ b/core/SCsub @@ -18,7 +18,7 @@ gd_cpp = '#include "global_config.h"\n' gd_cpp += gd_inc gd_cpp += "void GlobalConfig::register_global_defaults() {\n" + gd_call + "\n}\n" -f = open("global_defaults.cpp", "wb") +f = open("global_defaults.gen.cpp", "wb") 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.cpp", "wb") +f = open("script_encryption_key.gen.cpp", "wb") f.write("#include \"global_config.h\"\nuint8_t script_encryption_key[32]={" + txt + "};\n") f.close() @@ -109,7 +109,7 @@ env.add_source_files(env.core_sources, "*.cpp") # Make binders import make_binders -env.Command(['method_bind.inc', 'method_bind_ext.inc'], 'make_binders.py', make_binders.run) +env.Command(['method_bind.gen.inc', 'method_bind_ext.gen.inc'], 'make_binders.py', make_binders.run) # Chain load SCsubs diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp index e35ac2b72..0ed44b0cb 100644 --- a/core/core_string_names.cpp +++ b/core/core_string_names.cpp @@ -44,4 +44,7 @@ CoreStringNames::CoreStringNames() { _iter_next = StaticCString::create("_iter_next"); _iter_get = StaticCString::create("_iter_get"); get_rid = StaticCString::create("get_rid"); +#ifdef TOOLS_ENABLED + _sections_unfolded = StaticCString::create("_sections_unfolded"); +#endif } diff --git a/core/core_string_names.h b/core/core_string_names.h index 667277243..4b4f87a8f 100644 --- a/core/core_string_names.h +++ b/core/core_string_names.h @@ -61,6 +61,9 @@ public: StringName _iter_next; StringName _iter_get; StringName get_rid; +#ifdef TOOLS_ENABLED + StringName _sections_unfolded; +#endif }; #endif // SCENE_STRING_NAMES_H diff --git a/core/image.cpp b/core/image.cpp index e0cf82d92..023a05866 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1646,6 +1646,62 @@ void Image::blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Po } } +void Image::blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest) { + + ERR_FAIL_COND(p_src.is_null()); + ERR_FAIL_COND(p_mask.is_null()); + int dsize = data.size(); + int srcdsize = p_src->data.size(); + int maskdsize = p_mask->data.size(); + ERR_FAIL_COND(dsize == 0); + ERR_FAIL_COND(srcdsize == 0); + ERR_FAIL_COND(maskdsize == 0); + ERR_FAIL_COND(p_src->width != p_mask->width); + ERR_FAIL_COND(p_src->height != p_mask->height); + ERR_FAIL_COND(format != p_src->format); + + Rect2i clipped_src_rect = Rect2i(0, 0, p_src->width, p_src->height).clip(p_src_rect); + if (clipped_src_rect.size.x <= 0 || clipped_src_rect.size.y <= 0) + return; + + Rect2i dest_rect = Rect2i(0, 0, width, height).clip(Rect2i(p_dest, clipped_src_rect.size)); + + PoolVector<uint8_t>::Write wp = data.write(); + uint8_t *dst_data_ptr = wp.ptr(); + + PoolVector<uint8_t>::Read rp = p_src->data.read(); + const uint8_t *src_data_ptr = rp.ptr(); + + int pixel_size = get_format_pixel_size(format); + + Ref<Image> msk = p_mask; + msk->lock(); + + for (int i = 0; i < dest_rect.size.y; i++) { + + for (int j = 0; j < dest_rect.size.x; j++) { + + int src_x = clipped_src_rect.position.x + j; + int src_y = clipped_src_rect.position.y + i; + + if (msk->get_pixel(src_x, src_y).a != 0) { + + int dst_x = dest_rect.position.x + j; + int dst_y = dest_rect.position.y + i; + + const uint8_t *src = &src_data_ptr[(src_y * p_src->width + src_x) * pixel_size]; + uint8_t *dst = &dst_data_ptr[(dst_y * width + dst_x) * pixel_size]; + + for (int k = 0; k < pixel_size; k++) { + dst[k] = src[k]; + } + } + } + } + + msk->unlock(); +} + void Image::blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest) { ERR_FAIL_COND(p_src.is_null()); @@ -2199,6 +2255,7 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("normalmap_to_xy"), &Image::normalmap_to_xy); ClassDB::bind_method(D_METHOD("blit_rect", "src:Image", "src_rect", "dst"), &Image::blit_rect); + ClassDB::bind_method(D_METHOD("blit_rect_mask", "src:Image", "mask:Image", "src_rect", "dst"), &Image::blit_rect_mask); ClassDB::bind_method(D_METHOD("blend_rect", "src:Image", "src_rect", "dst"), &Image::blend_rect); ClassDB::bind_method(D_METHOD("blend_rect_mask", "src:Image", "mask:Image", "src_rect", "dst"), &Image::blend_rect_mask); ClassDB::bind_method(D_METHOD("fill", "color"), &Image::fill); diff --git a/core/image.h b/core/image.h index 3323afdc4..e523f703f 100644 --- a/core/image.h +++ b/core/image.h @@ -283,6 +283,7 @@ public: void normalmap_to_xy(); void blit_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest); + void blit_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest); void blend_rect(const Ref<Image> &p_src, const Rect2 &p_src_rect, const Point2 &p_dest); void blend_rect_mask(const Ref<Image> &p_src, const Ref<Image> &p_mask, const Rect2 &p_src_rect, const Point2 &p_dest); void fill(const Color &c); diff --git a/core/method_bind.h b/core/method_bind.h index 8d72c8573..dbc9cca08 100644 --- a/core/method_bind.h +++ b/core/method_bind.h @@ -343,6 +343,6 @@ MethodBind *create_vararg_method_bind(Variant (T::*p_method)(const Variant **, i // if you declare an nonexistent class.. class __UnexistingClass; -#include "method_bind.inc" +#include "method_bind.gen.inc" #endif diff --git a/core/object.cpp b/core/object.cpp index f20e93f9d..d83b2d0c6 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -419,6 +419,16 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid if (r_valid) *r_valid = true; return; +#ifdef TOOLS_ENABLED + } else if (p_name == CoreStringNames::get_singleton()->_sections_unfolded) { + Array arr = p_value; + for (int i = 0; i < arr.size(); i++) { + editor_section_folding.insert(arr[i]); + } + if (r_valid) + *r_valid = true; + return; +#endif } else { //something inside the object... :| bool success = _setv(p_name, p_value); @@ -464,6 +474,16 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const { if (r_valid) *r_valid = true; return ret; +#ifdef TOOLS_ENABLED + } else if (p_name == CoreStringNames::get_singleton()->_sections_unfolded) { + Array array; + for (Set<String>::Element *E = editor_section_folding.front(); E; E = E->next()) { + array.push_back(E->get()); + } + if (r_valid) + *r_valid = true; + return array; +#endif } else { //something inside the object... :| bool success = _getv(p_name, ret); @@ -516,6 +536,11 @@ void Object::get_property_list(List<PropertyInfo> *p_list, bool p_reversed) cons if (!is_class("Script")) // can still be set, but this is for userfriendlyness p_list->push_back(PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NONZERO)); +#ifdef TOOLS_ENABLED + if (editor_section_folding.size()) { + p_list->push_back(PropertyInfo(Variant::ARRAY, CoreStringNames::get_singleton()->_sections_unfolded, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); + } +#endif if (!metadata.empty()) p_list->push_back(PropertyInfo(Variant::DICTIONARY, "__meta__", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_STORE_IF_NONZERO)); if (script_instance && !p_reversed) { @@ -1571,6 +1596,23 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) { } } +#ifdef TOOLS_ENABLED +void Object::editor_set_section_unfold(const String &p_section, bool p_unfolded) { + + set_edited(true); + if (p_unfolded) + editor_section_folding.insert(p_section); + else + editor_section_folding.erase(p_section); +} + +bool Object::editor_is_section_unfolded(const String &p_section) { + + return editor_section_folding.has(p_section); +} + +#endif + void Object::clear_internal_resource_paths() { List<PropertyInfo> pinfo; diff --git a/core/object.h b/core/object.h index 83b03b923..fabd10fa1 100644 --- a/core/object.h +++ b/core/object.h @@ -430,6 +430,7 @@ private: #ifdef TOOLS_ENABLED bool _edited; uint32_t _edited_version; + Set<String> editor_section_folding; #endif ScriptInstance *script_instance; RefPtr script; @@ -666,6 +667,11 @@ public: _FORCE_INLINE_ void set_message_translation(bool p_enable) { _can_translate = p_enable; } _FORCE_INLINE_ bool can_translate_messages() const { return _can_translate; } +#ifdef TOOLS_ENABLED + void editor_set_section_unfold(const String &p_section, bool p_unfolded); + bool editor_is_section_unfolded(const String &p_section); +#endif + void clear_internal_resource_paths(); Object(); diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index e60f588be..1c575aa97 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -140,6 +140,8 @@ void InputEvent::_bind_methods() { ClassDB::bind_method(D_METHOD("is_action_type"), &InputEvent::is_action_type); ClassDB::bind_method(D_METHOD("xformed_by:InputEvent", "xform", "local_ofs"), &InputEvent::xformed_by, DEFVAL(Vector2())); + + ADD_PROPERTY(PropertyInfo(Variant::INT, "device"), "set_device", "get_device"); } InputEvent::InputEvent() { diff --git a/core/ustring.cpp b/core/ustring.cpp index 7ccf7fd20..ab4528e49 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -96,6 +96,12 @@ const char *CharString::get_data() const { void String::copy_from(const char *p_cstr) { + if (!p_cstr) { + + resize(0); + return; + } + int len = 0; const char *ptr = p_cstr; while (*(ptr++) != 0) @@ -119,6 +125,12 @@ void String::copy_from(const char *p_cstr) { void String::copy_from(const CharType *p_cstr, int p_clip_to) { + if (!p_cstr) { + + resize(0); + return; + } + int len = 0; const CharType *ptr = p_cstr; while (*(ptr++) != 0) diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 7b2d0f688..a463a5a23 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -2236,30 +2236,30 @@ bool Variant::iter_init(Variant &r_iter, bool &valid) const { return _data._int > 0; } break; case REAL: { - r_iter = 0.0; + r_iter = 0; return _data._real > 0.0; } break; case VECTOR2: { - real_t from = reinterpret_cast<const Vector2 *>(_data._mem)->x; - real_t to = reinterpret_cast<const Vector2 *>(_data._mem)->y; + int64_t from = reinterpret_cast<const Vector2 *>(_data._mem)->x; + int64_t to = reinterpret_cast<const Vector2 *>(_data._mem)->y; r_iter = from; return from < to; } break; case VECTOR3: { - real_t from = reinterpret_cast<const Vector3 *>(_data._mem)->x; - real_t to = reinterpret_cast<const Vector3 *>(_data._mem)->y; - real_t step = reinterpret_cast<const Vector3 *>(_data._mem)->z; + int64_t from = reinterpret_cast<const Vector3 *>(_data._mem)->x; + int64_t to = reinterpret_cast<const Vector3 *>(_data._mem)->y; + int64_t step = reinterpret_cast<const Vector3 *>(_data._mem)->z; r_iter = from; if (from == to) { return false; } else if (from < to) { - return step > 0.0; + return step > 0; } else { - return step < 0.0; + return step < 0; } //return true; } break; @@ -2387,7 +2387,6 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { valid = true; switch (type) { case INT: { - int64_t idx = r_iter; idx++; if (idx >= _data._int) @@ -2396,33 +2395,36 @@ bool Variant::iter_next(Variant &r_iter, bool &valid) const { return true; } break; case REAL: { - - double idx = r_iter; - idx += 1.0; + int64_t idx = r_iter; + idx++; if (idx >= _data._real) return false; r_iter = idx; return true; } break; case VECTOR2: { - real_t idx = r_iter; - idx += 1.0; - if (idx >= reinterpret_cast<const Vector2 *>(_data._mem)->y) + int64_t to = reinterpret_cast<const Vector3 *>(_data._mem)->y; + + int64_t idx = r_iter; + idx++; + + if (idx >= to) return false; + r_iter = idx; return true; } break; case VECTOR3: { - real_t to = reinterpret_cast<const Vector3 *>(_data._mem)->y; - real_t step = reinterpret_cast<const Vector3 *>(_data._mem)->z; + int64_t to = reinterpret_cast<const Vector3 *>(_data._mem)->y; + int64_t step = reinterpret_cast<const Vector3 *>(_data._mem)->z; - real_t idx = r_iter; + int64_t idx = r_iter; idx += step; - if (step < 0.0 && idx <= to) + if (step < 0 && idx <= to) return false; - if (step > 0.0 && idx >= to) + if (step > 0 && idx >= to) return false; r_iter = idx; diff --git a/core/version.h b/core/version.h index 80e50e51b..43f6f1bbf 100644 --- a/core/version.h +++ b/core/version.h @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version_generated.h" +#include "version_generated.gen.h" #ifdef VERSION_PATCH #define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) |
