summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/SCsub6
-rw-r--r--core/bind/core_bind.cpp24
-rw-r--r--core/bind/core_bind.h8
-rw-r--r--core/class_db.cpp14
-rw-r--r--core/class_db.h3
-rw-r--r--core/command_queue_mt.h44
-rw-r--r--core/core_string_names.cpp3
-rw-r--r--core/core_string_names.h3
-rw-r--r--core/dvector.h8
-rw-r--r--core/global_config.cpp8
-rw-r--r--core/image.cpp207
-rw-r--r--core/image.h21
-rw-r--r--core/io/compression.cpp4
-rw-r--r--core/math/a_star.cpp2
-rw-r--r--core/math/math_funcs.h8
-rw-r--r--core/math/matrix3.h6
-rw-r--r--core/math/transform.cpp13
-rw-r--r--core/math/transform.h10
-rw-r--r--core/method_bind.h2
-rw-r--r--core/object.cpp42
-rw-r--r--core/object.h6
-rw-r--r--core/os/input_event.cpp41
-rw-r--r--core/os/input_event.h4
-rw-r--r--core/reference.h2
-rw-r--r--core/translation.h2
-rw-r--r--core/ustring.cpp14
-rw-r--r--core/variant_call.cpp41
-rw-r--r--core/variant_op.cpp42
-rw-r--r--core/version.h2
29 files changed, 521 insertions, 69 deletions
diff --git a/core/SCsub b/core/SCsub
index da2403f1d3..02abaa2bb6 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/bind/core_bind.cpp b/core/bind/core_bind.cpp
index d81ccf0265..095f058ed9 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -31,6 +31,7 @@
#include "core/global_config.h"
#include "geometry.h"
+#include "io/file_access_compressed.h"
#include "io/file_access_encrypted.h"
#include "io/marshalls.h"
#include "os/keyboard.h"
@@ -1395,6 +1396,24 @@ Error _File::open_encrypted_pass(const String &p_path, int p_mode_flags, const S
return OK;
}
+Error _File::open_compressed(const String &p_path, int p_mode_flags, int p_compress_mode) {
+
+ FileAccessCompressed *fac = memnew(FileAccessCompressed);
+ Error err = OK;
+
+ fac->configure("GCPF", (Compression::Mode)p_compress_mode);
+
+ err = fac->_open(p_path, p_mode_flags);
+
+ if (err) {
+ memdelete(fac);
+ return err;
+ }
+
+ f = fac;
+ return OK;
+}
+
Error _File::open(const String &p_path, int p_mode_flags) {
close();
@@ -1700,6 +1719,7 @@ void _File::_bind_methods() {
ClassDB::bind_method(D_METHOD("open_encrypted", "path", "mode_flags", "key"), &_File::open_encrypted);
ClassDB::bind_method(D_METHOD("open_encrypted_with_pass", "path", "mode_flags", "pass"), &_File::open_encrypted_pass);
+ ClassDB::bind_method(D_METHOD("open_compressed", "path", "mode_flags", "compression_mode"), &_File::open_compressed, DEFVAL(0));
ClassDB::bind_method(D_METHOD("open", "path", "flags"), &_File::open);
ClassDB::bind_method(D_METHOD("close"), &_File::close);
@@ -1749,6 +1769,10 @@ void _File::_bind_methods() {
BIND_CONSTANT(WRITE);
BIND_CONSTANT(READ_WRITE);
BIND_CONSTANT(WRITE_READ);
+
+ BIND_CONSTANT(COMPRESSION_FASTLZ);
+ BIND_CONSTANT(COMPRESSION_DEFLATE);
+ BIND_CONSTANT(COMPRESSION_ZSTD);
}
_File::_File() {
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index a2fb6c966c..87d84c0732 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -31,6 +31,7 @@
#define CORE_BIND_H
#include "image.h"
+#include "io/compression.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "os/dir_access.h"
@@ -366,8 +367,15 @@ public:
WRITE_READ = 7,
};
+ enum CompressionMode {
+ COMPRESSION_FASTLZ = Compression::MODE_FASTLZ,
+ COMPRESSION_DEFLATE = Compression::MODE_DEFLATE,
+ COMPRESSION_ZSTD = Compression::MODE_ZSTD
+ };
+
Error open_encrypted(const String &p_path, int p_mode_flags, const Vector<uint8_t> &p_key);
Error open_encrypted_pass(const String &p_path, int p_mode_flags, const String &p_pass);
+ Error open_compressed(const String &p_path, int p_mode_flags, int p_compress_mode = 0);
Error open(const String &p_path, int p_mode_flags); ///< open a file
void close(); ///< close a file
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 1fe02c8cd9..6b8c290a99 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -497,7 +497,7 @@ void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherit
}
}
-void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance) {
+void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance, bool p_exclude_from_properties) {
OBJTYPE_RLOCK;
@@ -528,6 +528,9 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b
minfo.name = E->get();
minfo.id = method->get_method_id();
+ if (p_exclude_from_properties && type->methods_in_properties.has(minfo.name))
+ continue;
+
for (int i = 0; i < method->get_argument_count(); i++) {
//Variant::Type t=method->get_argument_type(i);
@@ -802,7 +805,14 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
OBJTYPE_WLOCK
type->property_list.push_back(p_pinfo);
-
+#ifdef DEBUG_METHODS_ENABLED
+ if (mb_get) {
+ type->methods_in_properties.insert(p_getter);
+ }
+ if (mb_set) {
+ type->methods_in_properties.insert(p_setter);
+ }
+#endif
PropertySetGet psg;
psg.setter = p_setter;
psg.getter = p_getter;
diff --git a/core/class_db.h b/core/class_db.h
index 547068da5f..4f00a16e91 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -139,6 +139,7 @@ public:
#ifdef DEBUG_METHODS_ENABLED
List<StringName> constant_order;
List<StringName> method_order;
+ Set<StringName> methods_in_properties;
List<MethodInfo> virtual_methods;
StringName category;
#endif
@@ -486,7 +487,7 @@ public:
static bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false);
static void set_method_flags(StringName p_class, StringName p_method, int p_flags);
- static void get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance = false);
+ static void get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance = false, bool p_exclude_from_properties = false);
static MethodBind *get_method(StringName p_class, StringName p_name);
static void add_virtual_method(const StringName &p_class, const MethodInfo &p_method, bool p_virtual = true);
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index 83c90a925c..2e0c478108 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -207,6 +207,26 @@ class CommandQueueMT {
virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
};
+ 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>
+ struct Command11 : 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;
+
+ virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
+ };
+
/* comands that return */
template <class T, class M, class R>
@@ -862,6 +882,30 @@ 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>
+ 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) {
+
+ Command11<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> *cmd = allocate_and_lock<Command11<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> >();
+
+ 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;
+
+ unlock();
+
+ if (sync) sync->post();
+ }
+
/*** PUSH AND RET COMMANDS ***/
template <class T, class M, class R>
diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp
index e35ac2b72c..0ed44b0cb7 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 6672772432..4b4f87a8f0 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/dvector.h b/core/dvector.h
index 2e951b9661..4584a300f9 100644
--- a/core/dvector.h
+++ b/core/dvector.h
@@ -92,6 +92,7 @@ class PoolVector {
// ERR_FAIL_COND(alloc->lock>0); should not be illegal to lock this for copy on write, as it's a copy on write after all
+ // Refcount should not be zero, otherwise it's a misuse of COW
if (alloc->refcount.get() == 1)
return; //nothing to do
@@ -216,7 +217,12 @@ class PoolVector {
{
int cur_elements = alloc->size / sizeof(T);
- Write w = write();
+
+ // Don't use write() here because it could otherwise provoke COW,
+ // which is not desirable here because we are destroying the last reference anyways
+ Write w;
+ // Reference to still prevent other threads from touching the alloc
+ w._ref(alloc);
for (int i = 0; i < cur_elements; i++) {
diff --git a/core/global_config.cpp b/core/global_config.cpp
index 0729d4c482..ba0a7f3e31 100644
--- a/core/global_config.cpp
+++ b/core/global_config.cpp
@@ -970,10 +970,10 @@ GlobalConfig::GlobalConfig() {
GLOBAL_DEF("debug/profiler/max_functions", 16384);
- GLOBAL_DEF("compression/zstd_compression_level", 3);
- custom_prop_info["compression/zstd_compression_level"] = PropertyInfo(Variant::INT, "compression/zstd_compression_level", PROPERTY_HINT_RANGE, "1,22,1");
- GLOBAL_DEF("compression/zlib_compression_level", Z_DEFAULT_COMPRESSION);
- custom_prop_info["compression/zlib_compression_level"] = PropertyInfo(Variant::INT, "compression/zlib_compression_level", PROPERTY_HINT_RANGE, "-1,9,1");
+ GLOBAL_DEF("compression/zstd/compression_level", 3);
+ custom_prop_info["compression/zstd/compression_level"] = PropertyInfo(Variant::INT, "compression/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1");
+ GLOBAL_DEF("compression/zlib/compression_level", Z_DEFAULT_COMPRESSION);
+ custom_prop_info["compression/zlib/compression_level"] = PropertyInfo(Variant::INT, "compression/zlib/compression_level", PROPERTY_HINT_RANGE, "-1,9,1");
using_datapack = false;
}
diff --git a/core/image.cpp b/core/image.cpp
index 380b307020..023a058667 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1492,14 +1492,14 @@ Error Image::decompress() {
return OK;
}
-Error Image::compress(CompressMode p_mode, bool p_for_srgb, float p_lossy_quality) {
+Error Image::compress(CompressMode p_mode, CompressSource p_source, float p_lossy_quality) {
switch (p_mode) {
case COMPRESS_S3TC: {
ERR_FAIL_COND_V(!_image_compress_bc_func, ERR_UNAVAILABLE);
- _image_compress_bc_func(this, p_for_srgb);
+ _image_compress_bc_func(this, p_source);
} break;
case COMPRESS_PVRTC2: {
@@ -1519,7 +1519,7 @@ Error Image::compress(CompressMode p_mode, bool p_for_srgb, float p_lossy_qualit
case COMPRESS_ETC2: {
ERR_FAIL_COND_V(!_image_compress_etc2_func, ERR_UNAVAILABLE);
- _image_compress_etc2_func(this, p_lossy_quality);
+ _image_compress_etc2_func(this, p_lossy_quality, p_source);
} break;
}
@@ -1646,14 +1646,197 @@ 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());
+ int dsize = data.size();
+ int srcdsize = p_src->data.size();
+ ERR_FAIL_COND(dsize == 0);
+ ERR_FAIL_COND(srcdsize == 0);
+ 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));
+
+ lock();
+ Ref<Image> img = p_src;
+ img->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;
+
+ int dst_x = dest_rect.position.x + j;
+ int dst_y = dest_rect.position.y + i;
+
+ Color sc = img->get_pixel(src_x, src_y);
+ Color dc = get_pixel(dst_x, dst_y);
+ dc.r = (double)(sc.a * sc.r + dc.a * (1.0 - sc.a) * dc.r);
+ dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
+ dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
+ dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
+ put_pixel(dst_x, dst_y, dc);
+ }
+ }
+
+ img->unlock();
+ unlock();
+}
+
+void Image::blend_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));
+
+ lock();
+ Ref<Image> img = p_src;
+ Ref<Image> msk = p_mask;
+ img->lock();
+ 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 the mask's pixel is transparent then we skip it
+ //Color c = msk->get_pixel(src_x, src_y);
+ //if (c.a == 0) continue;
+ 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;
+
+ Color sc = img->get_pixel(src_x, src_y);
+ Color dc = get_pixel(dst_x, dst_y);
+ dc.r = (double)(sc.a * sc.r + dc.a * (1.0 - sc.a) * dc.r);
+ dc.g = (double)(sc.a * sc.g + dc.a * (1.0 - sc.a) * dc.g);
+ dc.b = (double)(sc.a * sc.b + dc.a * (1.0 - sc.a) * dc.b);
+ dc.a = (double)(sc.a + dc.a * (1.0 - sc.a));
+ put_pixel(dst_x, dst_y, dc);
+ }
+ }
+ }
+
+ msk->unlock();
+ img->unlock();
+ unlock();
+}
+
+void Image::fill(const Color &c) {
+
+ lock();
+
+ PoolVector<uint8_t>::Write wp = data.write();
+ uint8_t *dst_data_ptr = wp.ptr();
+
+ int pixel_size = get_format_pixel_size(format);
+
+ // put first pixel with the format-aware API
+ put_pixel(0, 0, c);
+
+ for (int y = 0; y < height; y++) {
+
+ for (int x = 0; x < width; x++) {
+
+ uint8_t *dst = &dst_data_ptr[(y * width + x) * pixel_size];
+
+ for (int k = 0; k < pixel_size; k++) {
+ dst[k] = dst_data_ptr[k];
+ }
+ }
+ }
+
+ unlock();
+}
+
Ref<Image> (*Image::_png_mem_loader_func)(const uint8_t *, int) = NULL;
Ref<Image> (*Image::_jpg_mem_loader_func)(const uint8_t *, int) = NULL;
-void (*Image::_image_compress_bc_func)(Image *, bool) = NULL;
+void (*Image::_image_compress_bc_func)(Image *, Image::CompressSource) = NULL;
void (*Image::_image_compress_pvrtc2_func)(Image *) = NULL;
void (*Image::_image_compress_pvrtc4_func)(Image *) = NULL;
void (*Image::_image_compress_etc1_func)(Image *, float) = NULL;
-void (*Image::_image_compress_etc2_func)(Image *, float) = NULL;
+void (*Image::_image_compress_etc2_func)(Image *, float, Image::CompressSource) = NULL;
void (*Image::_image_decompress_pvrtc)(Image *) = NULL;
void (*Image::_image_decompress_bc)(Image *) = NULL;
void (*Image::_image_decompress_etc1)(Image *) = NULL;
@@ -1712,7 +1895,7 @@ void Image::unlock() {
write_lock = PoolVector<uint8_t>::Write();
}
-Color Image::get_pixel(int p_x, int p_y) {
+Color Image::get_pixel(int p_x, int p_y) const {
uint8_t *ptr = write_lock.ptr();
#ifdef DEBUG_ENABLED
@@ -2040,7 +2223,7 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_mipmap_offset", "mipmap"), &Image::get_mipmap_offset);
- ClassDB::bind_method(D_METHOD("resize_to_po2", "square"), &Image::resize_to_po2, DEFVAL("false"));
+ ClassDB::bind_method(D_METHOD("resize_to_po2", "square"), &Image::resize_to_po2, DEFVAL(false));
ClassDB::bind_method(D_METHOD("resize", "width", "height", "interpolation"), &Image::resize, DEFVAL(INTERPOLATE_BILINEAR));
ClassDB::bind_method(D_METHOD("shrink_x2"), &Image::shrink_x2);
ClassDB::bind_method(D_METHOD("expand_x2_hq2x"), &Image::expand_x2_hq2x);
@@ -2072,6 +2255,10 @@ 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);
ClassDB::bind_method(D_METHOD("get_used_rect"), &Image::get_used_rect);
ClassDB::bind_method(D_METHOD("get_rect:Image", "rect"), &Image::get_rect);
@@ -2140,9 +2327,13 @@ void Image::_bind_methods() {
BIND_CONSTANT(COMPRESS_PVRTC4);
BIND_CONSTANT(COMPRESS_ETC);
BIND_CONSTANT(COMPRESS_ETC2);
+
+ BIND_CONSTANT(COMPRESS_SOURCE_GENERIC);
+ BIND_CONSTANT(COMPRESS_SOURCE_SRGB);
+ BIND_CONSTANT(COMPRESS_SOURCE_NORMAL);
}
-void Image::set_compress_bc_func(void (*p_compress_func)(Image *, bool)) {
+void Image::set_compress_bc_func(void (*p_compress_func)(Image *, CompressSource)) {
_image_compress_bc_func = p_compress_func;
}
diff --git a/core/image.h b/core/image.h
index 790c5de9f6..e523f703fa 100644
--- a/core/image.h
+++ b/core/image.h
@@ -109,16 +109,22 @@ public:
/* INTERPOLATE GAUSS */
};
+ enum CompressSource {
+ COMPRESS_SOURCE_GENERIC,
+ COMPRESS_SOURCE_SRGB,
+ COMPRESS_SOURCE_NORMAL
+ };
+
//some functions provided by something else
static Ref<Image> (*_png_mem_loader_func)(const uint8_t *p_png, int p_size);
static Ref<Image> (*_jpg_mem_loader_func)(const uint8_t *p_png, int p_size);
- static void (*_image_compress_bc_func)(Image *, bool p_srgb);
+ static void (*_image_compress_bc_func)(Image *, CompressSource p_source);
static void (*_image_compress_pvrtc2_func)(Image *);
static void (*_image_compress_pvrtc4_func)(Image *);
static void (*_image_compress_etc1_func)(Image *, float);
- static void (*_image_compress_etc2_func)(Image *, float);
+ static void (*_image_compress_etc2_func)(Image *, float, CompressSource p_source);
static void (*_image_decompress_pvrtc)(Image *);
static void (*_image_decompress_bc)(Image *);
@@ -267,7 +273,7 @@ public:
COMPRESS_ETC2,
};
- Error compress(CompressMode p_mode = COMPRESS_S3TC, bool p_for_srgb = false, float p_lossy_quality = 0.7);
+ Error compress(CompressMode p_mode = COMPRESS_S3TC, CompressSource p_source = COMPRESS_SOURCE_GENERIC, float p_lossy_quality = 0.7);
Error decompress();
bool is_compressed() const;
@@ -277,11 +283,15 @@ 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);
Rect2 get_used_rect() const;
Ref<Image> get_rect(const Rect2 &p_area) const;
- static void set_compress_bc_func(void (*p_compress_func)(Image *, bool));
+ static void set_compress_bc_func(void (*p_compress_func)(Image *, CompressSource));
static String get_format_name(Format p_format);
Image(const uint8_t *p_mem_png_jpg, int p_len = -1);
@@ -304,7 +314,7 @@ public:
DetectChannels get_detected_channels();
- Color get_pixel(int p_x, int p_y);
+ Color get_pixel(int p_x, int p_y) const;
void put_pixel(int p_x, int p_y, const Color &p_color);
void copy_internals_from(const Ref<Image> &p_image) {
@@ -322,6 +332,7 @@ public:
VARIANT_ENUM_CAST(Image::Format)
VARIANT_ENUM_CAST(Image::Interpolation)
VARIANT_ENUM_CAST(Image::CompressMode)
+VARIANT_ENUM_CAST(Image::CompressSource)
VARIANT_ENUM_CAST(Image::AlphaMode)
#endif
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index 9ae54c38af..f806c4da6d 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -58,7 +58,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
strm.zalloc = zipio_alloc;
strm.zfree = zipio_free;
strm.opaque = Z_NULL;
- int level = GLOBAL_GET("compression/zlib_compression_level");
+ int level = GLOBAL_GET("compression/zlib/compression_level");
int err = deflateInit(&strm, level);
if (err != Z_OK)
return -1;
@@ -81,7 +81,7 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
case MODE_ZSTD: {
int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD);
- int level = GLOBAL_GET("compression/zstd_compression_level");
+ int level = GLOBAL_GET("compression/zstd/compression_level");
return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, level);
} break;
}
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 320990cc50..838fec22f0 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -401,7 +401,7 @@ void AStar::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_point_weight_scale", "id"), &AStar::get_point_weight_scale);
ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar::remove_point);
- ClassDB::bind_method(D_METHOD("connect_points", "id", "to_id"), &AStar::connect_points, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("connect_points", "id", "to_id", "bidirectional"), &AStar::connect_points, DEFVAL(true));
ClassDB::bind_method(D_METHOD("disconnect_points", "id", "to_id"), &AStar::disconnect_points);
ClassDB::bind_method(D_METHOD("are_points_connected", "id", "to_id"), &AStar::are_points_connected);
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index dd64b10f88..45509a0808 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -110,8 +110,8 @@ public:
static _ALWAYS_INLINE_ bool is_inf(double p_val) {
#ifdef _MSC_VER
return !_finite(p_val);
-// workaround for mingw builds on travis
-#elif defined(__MINGW32__) || defined(__MINGW64__)
+// use an inline implementation of isinf as a workaround for problematic libstdc++ versions from gcc 5.x era
+#elif defined(__GNUC__) && __GNUC__ < 6
union {
uint64_t u;
double f;
@@ -127,8 +127,8 @@ public:
static _ALWAYS_INLINE_ bool is_inf(float p_val) {
#ifdef _MSC_VER
return !_finite(p_val);
-// workaround for mingw builds on travis
-#elif defined(__MINGW32__) || defined(__MINGW64__)
+// use an inline implementation of isinf as a workaround for problematic libstdc++ versions from gcc 5.x era
+#elif defined(__GNUC__) && __GNUC__ < 6
union {
uint32_t u;
float f;
diff --git a/core/math/matrix3.h b/core/math/matrix3.h
index c3eeb1f705..8897c692f7 100644
--- a/core/math/matrix3.h
+++ b/core/math/matrix3.h
@@ -145,6 +145,12 @@ public:
elements[2][1] = zy;
elements[2][2] = zz;
}
+ _FORCE_INLINE_ void set(const Vector3 &p_x, const Vector3 &p_y, const Vector3 &p_z) {
+
+ set_axis(0, p_x);
+ set_axis(1, p_y);
+ set_axis(2, p_z);
+ }
_FORCE_INLINE_ Vector3 get_column(int i) const {
return Vector3(elements[0][i], elements[1][i], elements[2][i]);
diff --git a/core/math/transform.cpp b/core/math/transform.cpp
index e53e6cf519..7a50214596 100644
--- a/core/math/transform.cpp
+++ b/core/math/transform.cpp
@@ -82,7 +82,10 @@ Transform Transform::looking_at(const Vector3 &p_target, const Vector3 &p_up) co
}
void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up) {
-
+#ifdef MATH_CHECKS
+ ERR_FAIL_COND(p_eye == p_target);
+ ERR_FAIL_COND(p_up.length() == 0);
+#endif
// Reference: MESA source code
Vector3 v_x, v_y, v_z;
@@ -96,6 +99,9 @@ void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const
v_y = p_up;
v_x = v_y.cross(v_z);
+#ifdef MATH_CHECKS
+ ERR_FAIL_COND(v_x.length() == 0);
+#endif
/* Recompute Y = Z cross X */
v_y = v_z.cross(v_x);
@@ -103,9 +109,8 @@ void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const
v_x.normalize();
v_y.normalize();
- basis.set_axis(0, v_x);
- basis.set_axis(1, v_y);
- basis.set_axis(2, v_z);
+ basis.set(v_x, v_y, v_z);
+
origin = p_eye;
}
diff --git a/core/math/transform.h b/core/math/transform.h
index c39ea7826f..48467f2ed7 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -97,15 +97,7 @@ public:
void set(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz, real_t tx, real_t ty, real_t tz) {
- basis.elements[0][0] = xx;
- basis.elements[0][1] = xy;
- basis.elements[0][2] = xz;
- basis.elements[1][0] = yx;
- basis.elements[1][1] = yy;
- basis.elements[1][2] = yz;
- basis.elements[2][0] = zx;
- basis.elements[2][1] = zy;
- basis.elements[2][2] = zz;
+ basis.set(xx, xy, xz, yx, yy, yz, zx, zy, zz);
origin.x = tx;
origin.y = ty;
origin.z = tz;
diff --git a/core/method_bind.h b/core/method_bind.h
index 8d72c8573a..dbc9cca082 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 c760a9ea98..3416cd8c5a 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) {
@@ -1586,6 +1611,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 384e9e6fe2..dec4949c8d 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;
@@ -667,6 +668,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 dbdf9628e3..1c575aa970 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -89,6 +89,11 @@ bool InputEvent::action_match(const Ref<InputEvent> &p_event) const {
return false;
}
+bool InputEvent::shortcut_match(const Ref<InputEvent> &p_event) const {
+
+ return false;
+}
+
bool InputEvent::is_action_type() const {
return false;
@@ -130,10 +135,13 @@ void InputEvent::_bind_methods() {
ClassDB::bind_method(D_METHOD("as_text"), &InputEvent::as_text);
ClassDB::bind_method(D_METHOD("action_match", "event:InputEvent"), &InputEvent::action_match);
+ ClassDB::bind_method(D_METHOD("shortcut_match", "event:InputEvent"), &InputEvent::shortcut_match);
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() {
@@ -276,6 +284,27 @@ uint32_t InputEventKey::get_scancode_with_modifiers() const {
return sc;
}
+String InputEventKey::as_text() const {
+
+ String kc = keycode_get_string(scancode);
+ if (kc == String())
+ return kc;
+
+ if (get_metakey()) {
+ kc = "Meta+" + kc;
+ }
+ if (get_alt()) {
+ kc = "Alt+" + kc;
+ }
+ if (get_shift()) {
+ kc = "Shift+" + kc;
+ }
+ if (get_control()) {
+ kc = "Ctrl+" + kc;
+ }
+ return kc;
+}
+
bool InputEventKey::action_match(const Ref<InputEvent> &p_event) const {
Ref<InputEventKey> key = p_event;
@@ -288,6 +317,18 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event) const {
return get_scancode() == key->get_scancode() && (!key->is_pressed() || (code & event_code) == code);
}
+bool InputEventKey::shortcut_match(const Ref<InputEvent> &p_event) const {
+
+ Ref<InputEventKey> key = p_event;
+ if (key.is_null())
+ return false;
+
+ uint32_t code = get_scancode_with_modifiers();
+ uint32_t event_code = key->get_scancode_with_modifiers();
+
+ return code == event_code;
+}
+
void InputEventKey::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventKey::set_pressed);
diff --git a/core/os/input_event.h b/core/os/input_event.h
index 6a694df345..b120d4b840 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -165,6 +165,7 @@ public:
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
virtual bool action_match(const Ref<InputEvent> &p_event) const;
+ virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
virtual bool is_action_type() const;
InputEvent();
@@ -243,9 +244,12 @@ public:
uint32_t get_scancode_with_modifiers() const;
virtual bool action_match(const Ref<InputEvent> &p_event) const;
+ virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
virtual bool is_action_type() const { return true; }
+ virtual String as_text() const;
+
InputEventKey();
};
diff --git a/core/reference.h b/core/reference.h
index afc097817a..4e2d6c36c0 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -344,7 +344,7 @@ struct PtrToArg<const Ref<T> &> {
_FORCE_INLINE_ static Ref<T> convert(const void *p_ptr) {
- return Ref<T>(reinterpret_cast<const T *>(p_ptr));
+ return Ref<T>((T *)p_ptr);
}
};
diff --git a/core/translation.h b/core/translation.h
index 577282b45f..8630b8a478 100644
--- a/core/translation.h
+++ b/core/translation.h
@@ -36,7 +36,7 @@ class Translation : public Resource {
GDCLASS(Translation, Resource);
OBJ_SAVE_TYPE(Translation);
- RES_BASE_EXTENSION("xl");
+ RES_BASE_EXTENSION("translation");
String locale;
Map<StringName, StringName> translation_map;
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 6a93d7789e..ab4528e495 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -65,7 +65,7 @@ bool CharString::operator<(const CharString &p_right) const {
}
const char *this_str = get_data();
- const char *that_str = get_data();
+ const char *that_str = p_right.get_data();
while (true) {
if (*that_str == 0 && *this_str == 0)
@@ -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_call.cpp b/core/variant_call.cpp
index 9ead727a80..6936a362e1 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -30,6 +30,7 @@
#include "variant.h"
#include "core_string_names.h"
+#include "io/compression.h"
#include "object.h"
#include "os/os.h"
#include "script_language.h"
@@ -509,6 +510,44 @@ struct _VariantCall {
r_ret = s;
}
+ static void _call_PoolByteArray_compress(Variant &r_ret, Variant &p_self, const Variant **p_args) {
+
+ PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
+ PoolByteArray compressed;
+ Compression::Mode mode = (Compression::Mode)(int)(*p_args[0]);
+
+ compressed.resize(Compression::get_max_compressed_buffer_size(ba->size()));
+ int result = Compression::compress(compressed.write().ptr(), ba->read().ptr(), ba->size(), mode);
+
+ result = result >= 0 ? result : 0;
+ compressed.resize(result);
+
+ r_ret = compressed;
+ }
+
+ static void _call_PoolByteArray_decompress(Variant &r_ret, Variant &p_self, const Variant **p_args) {
+
+ PoolByteArray *ba = reinterpret_cast<PoolByteArray *>(p_self._data._mem);
+ PoolByteArray decompressed;
+ Compression::Mode mode = (Compression::Mode)(int)(*p_args[1]);
+
+ int buffer_size = (int)(*p_args[0]);
+
+ if (buffer_size < 0) {
+ r_ret = decompressed;
+ ERR_EXPLAIN("Decompression buffer size is less than zero");
+ ERR_FAIL();
+ }
+
+ decompressed.resize(buffer_size);
+ int result = Compression::decompress(decompressed.write().ptr(), buffer_size, ba->read().ptr(), ba->size(), mode);
+
+ result = result >= 0 ? result : 0;
+ decompressed.resize(result);
+
+ r_ret = decompressed;
+ }
+
VCALL_LOCALMEM0R(PoolByteArray, size);
VCALL_LOCALMEM2(PoolByteArray, set);
VCALL_LOCALMEM1R(PoolByteArray, get);
@@ -1552,6 +1591,8 @@ void register_variant_methods() {
ADDFUNC0(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_ascii, varray());
ADDFUNC0(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_utf8, varray());
+ ADDFUNC1(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, compress, INT, "compression_mode", varray(0));
+ ADDFUNC2(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0));
ADDFUNC0(POOL_INT_ARRAY, INT, PoolIntArray, size, varray());
ADDFUNC2(POOL_INT_ARRAY, NIL, PoolIntArray, set, INT, "idx", INT, "integer", varray());
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 7b2d0f6886..a463a5a23f 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 80e50e51b9..43f6f1bbf9 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)