summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp20
-rw-r--r--core/bind/core_bind.h5
-rw-r--r--core/command_queue_mt.cpp2
-rw-r--r--core/command_queue_mt.h63
-rw-r--r--core/engine.cpp1
-rw-r--r--core/engine.h14
-rw-r--r--core/image.cpp6
-rw-r--r--core/io/file_access_compressed.cpp20
-rw-r--r--core/io/image_loader.cpp4
-rw-r--r--core/io/image_loader.h4
-rw-r--r--core/io/marshalls.cpp213
-rw-r--r--core/io/marshalls.h21
-rw-r--r--core/io/packet_peer.cpp20
-rw-r--r--core/io/packet_peer.h2
-rw-r--r--core/math/geometry.cpp4
-rw-r--r--core/math/math_funcs.h10
-rw-r--r--core/math/rect3.h4
-rw-r--r--core/object.cpp8
-rw-r--r--core/object.h5
-rw-r--r--core/reference.h7
-rw-r--r--core/register_core_types.cpp3
-rw-r--r--core/script_debugger_remote.cpp62
-rw-r--r--core/script_debugger_remote.h2
-rw-r--r--core/typedefs.h21
-rw-r--r--core/variant_call.cpp4
-rw-r--r--core/vector.h4
26 files changed, 343 insertions, 186 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 273ef78669..1c9eef3d16 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -2534,11 +2534,6 @@ float _Engine::get_frames_per_second() const {
return Engine::get_singleton()->get_frames_per_second();
}
-String _Engine::get_custom_level() const {
-
- return Engine::get_singleton()->get_custom_level();
-}
-
void _Engine::set_time_scale(float p_scale) {
Engine::get_singleton()->set_time_scale(p_scale);
}
@@ -2568,6 +2563,16 @@ bool _Engine::is_in_fixed_frame() const {
return Engine::get_singleton()->is_in_fixed_frame();
}
+void _Engine::set_editor_hint(bool p_enabled) {
+
+ Engine::get_singleton()->set_editor_hint(p_enabled);
+}
+
+bool _Engine::is_editor_hint() const {
+
+ return Engine::get_singleton()->is_editor_hint();
+}
+
void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_iterations_per_second", "iterations_per_second"), &_Engine::set_iterations_per_second);
@@ -2578,8 +2583,6 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_time_scale", "time_scale"), &_Engine::set_time_scale);
ClassDB::bind_method(D_METHOD("get_time_scale"), &_Engine::get_time_scale);
- ClassDB::bind_method(D_METHOD("get_custom_level"), &_Engine::get_custom_level);
-
ClassDB::bind_method(D_METHOD("get_frames_drawn"), &_Engine::get_frames_drawn);
ClassDB::bind_method(D_METHOD("get_frames_per_second"), &_Engine::get_frames_per_second);
@@ -2588,6 +2591,9 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_version_info"), &_Engine::get_version_info);
ClassDB::bind_method(D_METHOD("is_in_fixed_frame"), &_Engine::is_in_fixed_frame);
+
+ ClassDB::bind_method(D_METHOD("set_editor_hint", "enabled"), &_Engine::set_editor_hint);
+ ClassDB::bind_method(D_METHOD("is_editor_hint"), &_Engine::is_editor_hint);
}
_Engine *_Engine::singleton = NULL;
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 61c80aaba3..d3314cc3b3 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -639,14 +639,15 @@ public:
void set_time_scale(float p_scale);
float get_time_scale();
- String get_custom_level() const;
-
MainLoop *get_main_loop() const;
Dictionary get_version_info() const;
bool is_in_fixed_frame() const;
+ void set_editor_hint(bool p_enabled);
+ bool is_editor_hint() const;
+
_Engine();
};
diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp
index 823494ff67..c9edd1d47b 100644
--- a/core/command_queue_mt.cpp
+++ b/core/command_queue_mt.cpp
@@ -55,6 +55,7 @@ CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() {
while (true) {
+ lock();
for (int i = 0; i < SYNC_SEMAPHORES; i++) {
if (!sync_sems[i].in_use) {
@@ -63,6 +64,7 @@ CommandQueueMT::SyncSemaphore *CommandQueueMT::_alloc_sync_sem() {
break;
}
}
+ unlock();
if (idx == -1) {
wait_for_flush();
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index 2e0c478108..c3e44f731f 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -911,12 +911,14 @@ public:
template <class T, class M, class R>
void push_and_ret(T *p_instance, M p_method, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet0<T, M, R> *cmd = allocate_and_lock<CommandRet0<T, M, R> >();
cmd->instance = p_instance;
cmd->method = p_method;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -928,13 +930,15 @@ public:
template <class T, class M, class P1, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet1<T, M, P1, R> *cmd = allocate_and_lock<CommandRet1<T, M, P1, R> >();
cmd->instance = p_instance;
cmd->method = p_method;
cmd->p1 = p1;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -946,6 +950,8 @@ public:
template <class T, class M, class P1, class P2, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet2<T, M, P1, P2, R> *cmd = allocate_and_lock<CommandRet2<T, M, P1, P2, R> >();
cmd->instance = p_instance;
@@ -953,7 +959,7 @@ public:
cmd->p1 = p1;
cmd->p2 = p2;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -965,6 +971,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet3<T, M, P1, P2, P3, R> *cmd = allocate_and_lock<CommandRet3<T, M, P1, P2, P3, R> >();
cmd->instance = p_instance;
@@ -973,7 +981,7 @@ public:
cmd->p2 = p2;
cmd->p3 = p3;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -985,6 +993,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet4<T, M, P1, P2, P3, P4, R> *cmd = allocate_and_lock<CommandRet4<T, M, P1, P2, P3, P4, R> >();
cmd->instance = p_instance;
@@ -994,7 +1004,7 @@ public:
cmd->p3 = p3;
cmd->p4 = p4;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -1006,6 +1016,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet5<T, M, P1, P2, P3, P4, P5, R> *cmd = allocate_and_lock<CommandRet5<T, M, P1, P2, P3, P4, P5, R> >();
cmd->instance = p_instance;
@@ -1016,7 +1028,7 @@ public:
cmd->p4 = p4;
cmd->p5 = p5;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -1028,6 +1040,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet6<T, M, P1, P2, P3, P4, P5, P6, R> *cmd = allocate_and_lock<CommandRet6<T, M, P1, P2, P3, P4, P5, P6, R> >();
cmd->instance = p_instance;
@@ -1039,7 +1053,7 @@ public:
cmd->p5 = p5;
cmd->p6 = p6;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -1051,6 +1065,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet7<T, M, P1, P2, P3, P4, P5, P6, P7, R> *cmd = allocate_and_lock<CommandRet7<T, M, P1, P2, P3, P4, P5, P6, P7, R> >();
cmd->instance = p_instance;
@@ -1063,7 +1079,7 @@ public:
cmd->p6 = p6;
cmd->p7 = p7;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -1075,6 +1091,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class R>
void push_and_ret(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, R *r_ret) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandRet8<T, M, P1, P2, P3, P4, P5, P6, P7, P8, R> *cmd = allocate_and_lock<CommandRet8<T, M, P1, P2, P3, P4, P5, P6, P7, P8, R> >();
cmd->instance = p_instance;
@@ -1088,7 +1106,7 @@ public:
cmd->p7 = p7;
cmd->p8 = p8;
cmd->ret = r_ret;
- SyncSemaphore *ss = _alloc_sync_sem();
+
cmd->sync = ss;
unlock();
@@ -1100,12 +1118,13 @@ public:
template <class T, class M>
void push_and_sync(T *p_instance, M p_method) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync0<T, M> *cmd = allocate_and_lock<CommandSync0<T, M> >();
cmd->instance = p_instance;
cmd->method = p_method;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1117,13 +1136,14 @@ public:
template <class T, class M, class P1>
void push_and_sync(T *p_instance, M p_method, P1 p1) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync1<T, M, P1> *cmd = allocate_and_lock<CommandSync1<T, M, P1> >();
cmd->instance = p_instance;
cmd->method = p_method;
cmd->p1 = p1;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1135,6 +1155,8 @@ public:
template <class T, class M, class P1, class P2>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync2<T, M, P1, P2> *cmd = allocate_and_lock<CommandSync2<T, M, P1, P2> >();
cmd->instance = p_instance;
@@ -1142,7 +1164,6 @@ public:
cmd->p1 = p1;
cmd->p2 = p2;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1154,6 +1175,8 @@ public:
template <class T, class M, class P1, class P2, class P3>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync3<T, M, P1, P2, P3> *cmd = allocate_and_lock<CommandSync3<T, M, P1, P2, P3> >();
cmd->instance = p_instance;
@@ -1162,7 +1185,6 @@ public:
cmd->p2 = p2;
cmd->p3 = p3;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1174,6 +1196,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync4<T, M, P1, P2, P3, P4> *cmd = allocate_and_lock<CommandSync4<T, M, P1, P2, P3, P4> >();
cmd->instance = p_instance;
@@ -1183,7 +1207,6 @@ public:
cmd->p3 = p3;
cmd->p4 = p4;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1195,6 +1218,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync5<T, M, P1, P2, P3, P4, P5> *cmd = allocate_and_lock<CommandSync5<T, M, P1, P2, P3, P4, P5> >();
cmd->instance = p_instance;
@@ -1205,7 +1230,6 @@ public:
cmd->p4 = p4;
cmd->p5 = p5;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1217,6 +1241,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync6<T, M, P1, P2, P3, P4, P5, P6> *cmd = allocate_and_lock<CommandSync6<T, M, P1, P2, P3, P4, P5, P6> >();
cmd->instance = p_instance;
@@ -1228,7 +1254,6 @@ public:
cmd->p5 = p5;
cmd->p6 = p6;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1240,6 +1265,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync7<T, M, P1, P2, P3, P4, P5, P6, P7> *cmd = allocate_and_lock<CommandSync7<T, M, P1, P2, P3, P4, P5, P6, P7> >();
cmd->instance = p_instance;
@@ -1252,7 +1279,6 @@ public:
cmd->p6 = p6;
cmd->p7 = p7;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
@@ -1264,6 +1290,8 @@ public:
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
void push_and_sync(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {
+ SyncSemaphore *ss = _alloc_sync_sem();
+
CommandSync8<T, M, P1, P2, P3, P4, P5, P6, P7, P8> *cmd = allocate_and_lock<CommandSync8<T, M, P1, P2, P3, P4, P5, P6, P7, P8> >();
cmd->instance = p_instance;
@@ -1277,7 +1305,6 @@ public:
cmd->p7 = p7;
cmd->p8 = p8;
- SyncSemaphore *ss = _alloc_sync_sem();
cmd->sync = ss;
unlock();
diff --git a/core/engine.cpp b/core/engine.cpp
index c16a2903d3..c8218e47ac 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -121,4 +121,5 @@ Engine::Engine() {
_in_fixed = false;
_frame_ticks = 0;
_frame_step = 0;
+ editor_hint = false;
}
diff --git a/core/engine.h b/core/engine.h
index 16dfb77593..c46ae1cb64 100644
--- a/core/engine.h
+++ b/core/engine.h
@@ -39,7 +39,6 @@ class Engine {
friend class Main;
- String _custom_level;
uint64_t frames_drawn;
uint32_t _frame_delay;
uint64_t _frame_ticks;
@@ -51,9 +50,12 @@ class Engine {
float _time_scale;
bool _pixel_snap;
uint64_t _fixed_frames;
+
uint64_t _idle_frames;
bool _in_fixed;
+ bool editor_hint;
+
static Engine *singleton;
public:
@@ -67,8 +69,6 @@ public:
virtual float get_frames_per_second() const { return _fps; }
- String get_custom_level() const { return _custom_level; }
-
uint64_t get_frames_drawn();
uint64_t get_fixed_frames() const { return _fixed_frames; }
@@ -85,6 +85,14 @@ public:
_FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; }
+#ifdef TOOLS_ENABLED
+ _FORCE_INLINE_ void set_editor_hint(bool p_enabled) { editor_hint = p_enabled; }
+ _FORCE_INLINE_ bool is_editor_hint() const { return editor_hint; }
+#else
+ _FORCE_INLINE_ void set_editor_hint(bool p_enabled) {}
+ _FORCE_INLINE_ bool is_editor_hint() const { return false; }
+#endif
+
Dictionary get_version_info() const;
Engine();
diff --git a/core/image.cpp b/core/image.cpp
index 2db9cb1571..a4864458b5 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -676,8 +676,8 @@ void Image::resize_to_po2(bool p_square) {
ERR_FAIL();
}
- int w = nearest_power_of_2(width);
- int h = nearest_power_of_2(height);
+ int w = next_power_of_2(width);
+ int h = next_power_of_2(height);
if (w == width && h == height) {
@@ -1060,7 +1060,7 @@ Error Image::generate_mipmaps() {
PoolVector<uint8_t>::Write wp = data.write();
- if (nearest_power_of_2(width) == uint32_t(width) && nearest_power_of_2(height) == uint32_t(height)) {
+ if (next_power_of_2(width) == uint32_t(width) && next_power_of_2(height) == uint32_t(height)) {
//use fast code for powers of 2
int prev_ofs = 0;
int prev_h = height;
diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp
index 4e802579c6..34bce3f04f 100644
--- a/core/io/file_access_compressed.cpp
+++ b/core/io/file_access_compressed.cpp
@@ -43,16 +43,16 @@ void FileAccessCompressed::configure(const String &p_magic, Compression::Mode p_
block_size = p_block_size;
}
-#define WRITE_FIT(m_bytes) \
- { \
- if (write_pos + (m_bytes) > write_max) { \
- write_max = write_pos + (m_bytes); \
- } \
- if (write_max > write_buffer_size) { \
- write_buffer_size = nearest_power_of_2(write_max); \
- buffer.resize(write_buffer_size); \
- write_ptr = buffer.ptr(); \
- } \
+#define WRITE_FIT(m_bytes) \
+ { \
+ if (write_pos + (m_bytes) > write_max) { \
+ write_max = write_pos + (m_bytes); \
+ } \
+ if (write_max > write_buffer_size) { \
+ write_buffer_size = next_power_of_2(write_max); \
+ buffer.resize(write_buffer_size); \
+ write_ptr = buffer.ptr(); \
+ } \
}
Error FileAccessCompressed::open_after_magic(FileAccess *p_base) {
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index 23719940be..7b5b4a13ea 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -43,7 +43,7 @@ bool ImageFormatLoader::recognize(const String &p_extension) const {
return false;
}
-Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom, bool p_force_linear) {
+Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom, bool p_force_linear, float p_scale) {
ERR_FAIL_COND_V(p_image.is_null(), ERR_INVALID_PARAMETER);
FileAccess *f = p_custom;
@@ -62,7 +62,7 @@ Error ImageLoader::load_image(String p_file, Ref<Image> p_image, FileAccess *p_c
if (!loader[i]->recognize(extension))
continue;
- Error err = loader[i]->load_image(p_image, f, p_force_linear);
+ Error err = loader[i]->load_image(p_image, f, p_force_linear, p_scale);
if (err != ERR_FILE_UNRECOGNIZED) {
diff --git a/core/io/image_loader.h b/core/io/image_loader.h
index e528d1423b..f79d9789bf 100644
--- a/core/io/image_loader.h
+++ b/core/io/image_loader.h
@@ -56,7 +56,7 @@ class ImageFormatLoader {
friend class ImageLoader;
protected:
- virtual Error load_image(Ref<Image> p_image, FileAccess *p_fileaccess, bool p_force_linear) = 0;
+ virtual Error load_image(Ref<Image> p_image, FileAccess *p_fileaccess, bool p_force_linear, float p_scale) = 0;
virtual void get_recognized_extensions(List<String> *p_extensions) const = 0;
bool recognize(const String &p_extension) const;
@@ -75,7 +75,7 @@ class ImageLoader {
protected:
public:
- static Error load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom = NULL, bool p_force_linear = false);
+ static Error load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom = NULL, bool p_force_linear = false, float p_scale = 1.0);
static void get_recognized_extensions(List<String> *p_extensions);
static bool recognize(const String &p_extension);
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 8eb40b61d7..e701a89c78 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -33,8 +33,28 @@
#include "reference.h"
#include <stdio.h>
+void EncodedObjectAsID::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_object_id", "id"), &EncodedObjectAsID::set_object_id);
+ ClassDB::bind_method(D_METHOD("get_object_id"), &EncodedObjectAsID::get_object_id);
+}
+
+void EncodedObjectAsID::set_object_id(ObjectID p_id) {
+ id = p_id;
+}
+
+ObjectID EncodedObjectAsID::get_object_id() const {
+
+ return id;
+}
+
+EncodedObjectAsID::EncodedObjectAsID() {
+
+ id = 0;
+}
+
#define ENCODE_MASK 0xFF
#define ENCODE_FLAG_64 1 << 16
+#define ENCODE_FLAG_OBJECT_AS_ID 1 << 16
static Error _decode_string(const uint8_t *&buf, int &len, int *r_len, String &r_string) {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
@@ -381,56 +401,74 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::OBJECT: {
- ERR_FAIL_COND_V(!p_allow_objects, ERR_UNAUTHORIZED);
-
- String str;
- Error err = _decode_string(buf, len, r_len, str);
- if (err)
- return err;
+ if (type & ENCODE_FLAG_OBJECT_AS_ID) {
+ //this _is_ allowed
+ ObjectID val = decode_uint64(buf);
+ if (r_len)
+ (*r_len) += 8;
- if (str == String()) {
- r_variant = (Object *)NULL;
- } else {
+ if (val == 0) {
+ r_variant = (Object *)NULL;
+ } else {
+ Ref<EncodedObjectAsID> obj_as_id;
+ obj_as_id.instance();
+ obj_as_id->set_object_id(val);
- Object *obj = ClassDB::instance(str);
+ r_variant = obj_as_id;
+ }
- ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE);
- ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
+ } else {
+ ERR_FAIL_COND_V(!p_allow_objects, ERR_UNAUTHORIZED);
- int32_t count = decode_uint32(buf);
- buf += 4;
- len -= 4;
- if (r_len) {
- (*r_len) += 4;
- }
+ String str;
+ Error err = _decode_string(buf, len, r_len, str);
+ if (err)
+ return err;
- for (int i = 0; i < count; i++) {
+ if (str == String()) {
+ r_variant = (Object *)NULL;
+ } else {
- str = String();
- err = _decode_string(buf, len, r_len, str);
- if (err)
- return err;
+ Object *obj = ClassDB::instance(str);
- Variant value;
- int used;
- err = decode_variant(value, buf, len, &used, p_allow_objects);
- if (err)
- return err;
+ ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE);
+ ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
- buf += used;
- len -= used;
+ int32_t count = decode_uint32(buf);
+ buf += 4;
+ len -= 4;
if (r_len) {
- (*r_len) += used;
+ (*r_len) += 4;
}
- obj->set(str, value);
- }
+ for (int i = 0; i < count; i++) {
- if (obj->cast_to<Reference>()) {
- REF ref = REF(obj->cast_to<Reference>());
- r_variant = ref;
- } else {
- r_variant = obj;
+ str = String();
+ err = _decode_string(buf, len, r_len, str);
+ if (err)
+ return err;
+
+ Variant value;
+ int used;
+ err = decode_variant(value, buf, len, &used, p_allow_objects);
+ if (err)
+ return err;
+
+ buf += used;
+ len -= used;
+ if (r_len) {
+ (*r_len) += used;
+ }
+
+ obj->set(str, value);
+ }
+
+ if (obj->cast_to<Reference>()) {
+ REF ref = REF(obj->cast_to<Reference>());
+ r_variant = ref;
+ } else {
+ r_variant = obj;
+ }
}
}
@@ -769,14 +807,19 @@ static void _encode_string(const String &p_string, uint8_t *&buf, int &r_len) {
encode_uint32(utf8.length(), buf);
buf += 4;
copymem(buf, utf8.get_data(), utf8.length());
+ buf += utf8.length();
}
r_len += 4 + utf8.length();
- while (r_len % 4)
+ while (r_len % 4) {
r_len++; //pad
+ if (buf) {
+ buf++;
+ }
+ }
}
-Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
+Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_object_as_id) {
uint8_t *buf = r_buffer;
@@ -800,6 +843,11 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
flags |= ENCODE_FLAG_64; //always encode real as double
}
} break;
+ case Variant::OBJECT: {
+ if (p_object_as_id) {
+ flags |= ENCODE_FLAG_OBJECT_AS_ID;
+ }
+ } break;
}
if (buf) {
@@ -1071,49 +1119,66 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
} break;
case Variant::OBJECT: {
- Object *obj = p_variant;
- if (!obj) {
+ if (p_object_as_id) {
+
if (buf) {
- encode_uint32(0, buf);
- buf += 4;
- r_len += 4;
+
+ Object *obj = p_variant;
+ ObjectID id = 0;
+ if (obj && ObjectDB::instance_validate(obj)) {
+ id = obj->get_instance_id();
+ }
+
+ encode_uint64(id, buf);
}
+
+ r_len += 8;
+
} else {
- _encode_string(obj->get_class(), buf, r_len);
+ Object *obj = p_variant;
+ if (!obj) {
+ if (buf) {
+ encode_uint32(0, buf);
+ buf += 4;
+ r_len += 4;
+ }
+ } else {
+ _encode_string(obj->get_class(), buf, r_len);
- List<PropertyInfo> props;
- obj->get_property_list(&props);
+ List<PropertyInfo> props;
+ obj->get_property_list(&props);
- int pc = 0;
- for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+ int pc = 0;
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
- continue;
- pc++;
- }
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ continue;
+ pc++;
+ }
- if (buf) {
- encode_uint32(pc, buf);
- buf += 4;
- }
+ if (buf) {
+ encode_uint32(pc, buf);
+ buf += 4;
+ }
- r_len += 4;
+ r_len += 4;
- for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
- continue;
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ continue;
- _encode_string(E->get().name, buf, r_len);
+ _encode_string(E->get().name, buf, r_len);
- int len;
- Error err = encode_variant(obj->get(E->get().name), buf, len);
- if (err)
- return err;
- ERR_FAIL_COND_V(len % 4, ERR_BUG);
- r_len += len;
- if (buf)
- buf += len;
+ int len;
+ Error err = encode_variant(obj->get(E->get().name), buf, len, p_object_as_id);
+ if (err)
+ return err;
+ ERR_FAIL_COND_V(len % 4, ERR_BUG);
+ r_len += len;
+ if (buf)
+ buf += len;
+ }
}
}
@@ -1147,12 +1212,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
r_len++; //pad
*/
int len;
- encode_variant(E->get(), buf, len);
+ encode_variant(E->get(), buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
buf += len;
- encode_variant(d[E->get()], buf, len);
+ encode_variant(d[E->get()], buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
@@ -1174,7 +1239,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
for (int i = 0; i < v.size(); i++) {
int len;
- encode_variant(v.get(i), buf, len);
+ encode_variant(v.get(i), buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
diff --git a/core/io/marshalls.h b/core/io/marshalls.h
index a6cc72b691..234ae3b183 100644
--- a/core/io/marshalls.h
+++ b/core/io/marshalls.h
@@ -32,8 +32,8 @@
#include "typedefs.h"
+#include "reference.h"
#include "variant.h"
-
/**
* Miscellaneous helpers for marshalling data types, and encoding
* in an endian independent way
@@ -183,7 +183,22 @@ static inline double decode_double(const uint8_t *p_arr) {
return md.d;
}
-Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects=true);
-Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len);
+class EncodedObjectAsID : public Reference {
+ GDCLASS(EncodedObjectAsID, Reference);
+
+ ObjectID id;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_object_id(ObjectID p_id);
+ ObjectID get_object_id() const;
+
+ EncodedObjectAsID();
+};
+
+Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects = true);
+Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_object_as_id = false);
#endif
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index f62ffd7183..ca00b8b480 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -92,7 +92,7 @@ Error PacketPeer::get_var(Variant &r_variant) const {
Error PacketPeer::put_var(const Variant &p_packet) {
int len;
- Error err = encode_variant(p_packet, NULL, len); // compute len first
+ Error err = encode_variant(p_packet, NULL, len, !allow_object_decoding); // compute len first
if (err)
return err;
@@ -101,7 +101,7 @@ Error PacketPeer::put_var(const Variant &p_packet) {
uint8_t *buf = (uint8_t *)alloca(len);
ERR_FAIL_COND_V(!buf, ERR_OUT_OF_MEMORY);
- err = encode_variant(p_packet, buf, len);
+ err = encode_variant(p_packet, buf, len, !allow_object_decoding);
ERR_FAIL_COND_V(err, err);
return put_packet(buf, len);
@@ -155,6 +155,8 @@ void PacketPeerStream::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::_set_stream_peer);
ClassDB::bind_method(D_METHOD("set_input_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_input_buffer_max_size);
ClassDB::bind_method(D_METHOD("set_output_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_output_buffer_max_size);
+ ClassDB::bind_method(D_METHOD("get_input_buffer_max_size"), &PacketPeerStream::get_input_buffer_max_size);
+ ClassDB::bind_method(D_METHOD("get_output_buffer_max_size"), &PacketPeerStream::get_output_buffer_max_size);
}
Error PacketPeerStream::_poll_buffer() const {
@@ -265,12 +267,22 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
ERR_EXPLAIN("Buffer in use, resizing would cause loss of data");
ERR_FAIL_COND(ring_buffer.data_left());
ring_buffer.resize(nearest_shift(p_max_size + 4));
- input_buffer.resize(nearest_power_of_2(p_max_size + 4));
+ input_buffer.resize(next_power_of_2(p_max_size + 4));
+}
+
+int PacketPeerStream::get_input_buffer_max_size() const {
+
+ return input_buffer.size() - 4;
}
void PacketPeerStream::set_output_buffer_max_size(int p_max_size) {
- output_buffer.resize(nearest_power_of_2(p_max_size + 4));
+ output_buffer.resize(next_power_of_2(p_max_size + 4));
+}
+
+int PacketPeerStream::get_output_buffer_max_size() const {
+
+ return output_buffer.size() - 4;
}
PacketPeerStream::PacketPeerStream() {
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index 3bd6876aa7..597119f7f4 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -98,7 +98,9 @@ public:
void set_stream_peer(const Ref<StreamPeer> &p_peer);
void set_input_buffer_max_size(int p_max_size);
+ int get_input_buffer_max_size() const;
void set_output_buffer_max_size(int p_max_size);
+ int get_output_buffer_max_size() const;
PacketPeerStream();
};
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 2bea514d37..9a5811244a 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -1076,8 +1076,8 @@ void Geometry::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_resu
for (int i = 0; i < results.size(); i++) {
- real_t h = nearest_power_of_2(results[i].max_h);
- real_t w = nearest_power_of_2(results[i].max_w);
+ real_t h = next_power_of_2(results[i].max_h);
+ real_t w = next_power_of_2(results[i].max_w);
real_t aspect = h > w ? h / w : w / h;
if (aspect < best_aspect) {
best = i;
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 45509a0808..2ce9a88622 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -153,8 +153,14 @@ public:
static _ALWAYS_INLINE_ double rad2deg(double p_y) { return p_y * 180.0 / Math_PI; }
static _ALWAYS_INLINE_ float rad2deg(float p_y) { return p_y * 180.0 / Math_PI; }
- static _ALWAYS_INLINE_ double lerp(double a, double b, double c) { return a + (b - a) * c; }
- static _ALWAYS_INLINE_ float lerp(float a, float b, float c) { return a + (b - a) * c; }
+ static _ALWAYS_INLINE_ double lerp(double p_from, double p_to, double p_weight) { return p_from + (p_to - p_from) * p_weight; }
+ static _ALWAYS_INLINE_ float lerp(float p_from, float p_to, float p_weight) { return p_from + (p_to - p_from) * p_weight; }
+
+ static _ALWAYS_INLINE_ double inverse_lerp(double p_from, double p_to, double p_value) { return (p_value - p_from) / (p_to - p_from); }
+ static _ALWAYS_INLINE_ float inverse_lerp(float p_from, float p_to, float p_value) { return (p_value - p_from) / (p_to - p_from); }
+
+ static _ALWAYS_INLINE_ double range_lerp(double p_value, double p_istart, double p_istop, double p_ostart, double p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); }
+ static _ALWAYS_INLINE_ float range_lerp(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); }
static _ALWAYS_INLINE_ double linear2db(double p_linear) { return Math::log(p_linear) * 8.6858896380650365530225783783321; }
static _ALWAYS_INLINE_ float linear2db(float p_linear) { return Math::log(p_linear) * 8.6858896380650365530225783783321; }
diff --git a/core/math/rect3.h b/core/math/rect3.h
index 7c971f5ac7..4890a19d99 100644
--- a/core/math/rect3.h
+++ b/core/math/rect3.h
@@ -47,12 +47,12 @@ public:
real_t get_area() const; /// get area
_FORCE_INLINE_ bool has_no_area() const {
- return (size.x <= CMP_EPSILON || size.y <= CMP_EPSILON || size.z <= CMP_EPSILON);
+ return (size.x <= 0 || size.y <= 0 || size.z <= 0);
}
_FORCE_INLINE_ bool has_no_surface() const {
- return (size.x <= CMP_EPSILON && size.y <= CMP_EPSILON && size.z <= CMP_EPSILON);
+ return (size.x <= 0 && size.y <= 0 && size.z <= 0);
}
const Vector3 &get_position() const { return position; }
diff --git a/core/object.cpp b/core/object.cpp
index 3cfd74a448..06c2603b74 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1560,7 +1560,7 @@ void Object::initialize_class() {
initialized = true;
}
-StringName Object::localize(const StringName &p_message) const {
+StringName Object::tr(const StringName &p_message) const {
if (!_can_translate || !TranslationServer::get_singleton())
return p_message;
@@ -1707,11 +1707,11 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_block_signals", "enable"), &Object::set_block_signals);
ClassDB::bind_method(D_METHOD("is_blocking_signals"), &Object::is_blocking_signals);
- ClassDB::bind_method(D_METHOD("set_message_localization", "enable"), &Object::set_message_localization);
- ClassDB::bind_method(D_METHOD("can_translate_messages"), &Object::can_translate_messages);
ClassDB::bind_method(D_METHOD("property_list_changed_notify"), &Object::property_list_changed_notify);
- ClassDB::bind_method(D_METHOD("localize", "message"), &Object::localize);
+ ClassDB::bind_method(D_METHOD("set_message_translation", "enable"), &Object::set_message_translation);
+ ClassDB::bind_method(D_METHOD("can_translate_messages"), &Object::can_translate_messages);
+ ClassDB::bind_method(D_METHOD("tr", "message"), &Object::tr);
ClassDB::bind_method(D_METHOD("is_queued_for_deletion"), &Object::is_queued_for_deletion);
diff --git a/core/object.h b/core/object.h
index ebcd4afeb9..8a858b5b00 100644
--- a/core/object.h
+++ b/core/object.h
@@ -83,6 +83,7 @@ enum PropertyHint {
PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type
PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance
PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base
+ PROPERTY_HINT_OBJECT_TOO_BIG, ///< object is too big to send
PROPERTY_HINT_MAX,
};
@@ -678,12 +679,12 @@ public:
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
- StringName localize(const StringName &p_message) const; //translate message (internationalization)
+ StringName tr(const StringName &p_message) const; // translate message (internationalization)
bool _is_queued_for_deletion; // set to true by SceneTree::queue_delete()
bool is_queued_for_deletion() const;
- _FORCE_INLINE_ void set_message_localization(bool p_enable) { _can_translate = p_enable; }
+ _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
diff --git a/core/reference.h b/core/reference.h
index 7f48f8323e..69250a4701 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -374,6 +374,10 @@ struct PtrToArg<const RefPtr &> {
}
};
+#endif // PTRCALL_ENABLED
+
+#ifdef DEBUG_METHODS_ENABLED
+
template <class T>
struct GetTypeInfo<Ref<T> > {
enum { VARIANT_TYPE = Variant::OBJECT };
@@ -392,5 +396,6 @@ struct GetTypeInfo<const Ref<T> &> {
}
};
-#endif
+#endif // DEBUG_METHODS_ENABLED
+
#endif // REFERENCE_H
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 43f781af55..fca9afbf5e 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -39,6 +39,7 @@
#include "input_map.h"
#include "io/config_file.h"
#include "io/http_client.h"
+#include "io/marshalls.h"
#include "io/packet_peer.h"
#include "io/packet_peer_udp.h"
#include "io/pck_packer.h"
@@ -56,7 +57,6 @@
#include "project_settings.h"
#include "translation.h"
#include "undo_redo.h"
-
static ResourceFormatSaverBinary *resource_saver_binary = NULL;
static ResourceFormatLoaderBinary *resource_loader_binary = NULL;
static ResourceFormatImporter *resource_format_importer = NULL;
@@ -157,6 +157,7 @@ void register_core_types() {
ClassDB::register_class<PackedDataContainer>();
ClassDB::register_virtual_class<PackedDataContainerRef>();
ClassDB::register_class<AStar>();
+ ClassDB::register_class<EncodedObjectAsID>();
ip = IP::create();
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 44e86bca6a..9e4f4380c9 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -30,10 +30,10 @@
#include "script_debugger_remote.h"
#include "io/ip.h"
+#include "io/marshalls.h"
#include "os/input.h"
#include "os/os.h"
#include "project_settings.h"
-
void ScriptDebuggerRemote::_send_video_memory() {
List<ResourceUsage> usage;
@@ -120,6 +120,18 @@ static ObjectID safe_get_instance_id(const Variant &p_v) {
}
}
+void ScriptDebuggerRemote::_put_variable(const String &p_name, const Variant &p_variable) {
+
+ packet_peer_stream->put_var(p_name);
+ int len = 0;
+ Error err = encode_variant(p_variable, NULL, len);
+ if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size
+ packet_peer_stream->put_var(Variant());
+ } else {
+ packet_peer_stream->put_var(p_variable);
+ }
+}
+
void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) {
//this function is called when there is a debugger break (bug on script)
@@ -130,8 +142,6 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
ERR_FAIL();
}
- OS::get_singleton()->enable_for_stealing_focus(ProjectSettings::get_singleton()->get("editor_pid"));
-
packet_peer_stream->put_var("debug_enter");
packet_peer_stream->put_var(2);
packet_peer_stream->put_var(p_can_continue);
@@ -210,14 +220,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
while (E) {
- if (F->get().get_type() == Variant::OBJECT) {
- packet_peer_stream->put_var("*" + E->get());
- String pretty_print = F->get().operator String();
- packet_peer_stream->put_var(pretty_print.ascii().get_data());
- } else {
- packet_peer_stream->put_var(E->get());
- packet_peer_stream->put_var(F->get());
- }
+ _put_variable(E->get(), F->get());
E = E->next();
F = F->next();
@@ -231,15 +234,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
List<Variant>::Element *F = local_vals.front();
while (E) {
-
- if (F->get().get_type() == Variant::OBJECT) {
- packet_peer_stream->put_var("*" + E->get());
- String pretty_print = F->get().operator String();
- packet_peer_stream->put_var(pretty_print.ascii().get_data());
- } else {
- packet_peer_stream->put_var(E->get());
- packet_peer_stream->put_var(F->get());
- }
+ _put_variable(E->get(), F->get());
E = E->next();
F = F->next();
@@ -566,30 +561,19 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
}
Variant var = obj->get(E->get().name);
+ packet_peer_stream->put_var(E->get().type);
+ //only send information that can be sent..
- if (E->get().type == Variant::OBJECT || var.get_type() == Variant::OBJECT) {
-
- ObjectID id2;
- Object *obj = var;
- if (obj) {
- id2 = obj->get_instance_id();
- } else {
- id2 = 0;
- }
+ int len = 0; //test how big is this to encode
+ encode_variant(var, NULL, len);
- packet_peer_stream->put_var(Variant::INT); //hint string
- packet_peer_stream->put_var(PROPERTY_HINT_OBJECT_ID); //hint
- packet_peer_stream->put_var(E->get().hint_string); //hint string
- packet_peer_stream->put_var(id2); //value
+ if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size
+ packet_peer_stream->put_var(PROPERTY_HINT_OBJECT_TOO_BIG);
+ packet_peer_stream->put_var("");
+ packet_peer_stream->put_var(Variant());
} else {
- packet_peer_stream->put_var(E->get().type);
packet_peer_stream->put_var(E->get().hint);
packet_peer_stream->put_var(E->get().hint_string);
- //only send information that can be sent..
-
- if (var.get_type() >= Variant::DICTIONARY) {
- var = Array(); //send none for now, may be to big
- }
packet_peer_stream->put_var(var);
}
}
diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h
index 924e3774a2..cf75c0eb4a 100644
--- a/core/script_debugger_remote.h
+++ b/core/script_debugger_remote.h
@@ -126,6 +126,8 @@ class ScriptDebuggerRemote : public ScriptDebugger {
Vector<FrameData> profile_frame_data;
+ void _put_variable(const String &p_name, const Variant &p_variable);
+
public:
struct ResourceUsage {
diff --git a/core/typedefs.h b/core/typedefs.h
index 40d9ea37b5..34a1a93a3b 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -162,9 +162,9 @@ inline void __swap_tmpl(T &x, T &y) {
#define _add_overflow __builtin_add_overflow
#endif
-/** Function to find the nearest (bigger) power of 2 to an integer */
+/** Function to find the next power of 2 to an integer */
-static _FORCE_INLINE_ unsigned int nearest_power_of_2(unsigned int x) {
+static _FORCE_INLINE_ unsigned int next_power_of_2(unsigned int x) {
--x;
x |= x >> 1;
@@ -176,6 +176,23 @@ static _FORCE_INLINE_ unsigned int nearest_power_of_2(unsigned int x) {
return ++x;
}
+static _FORCE_INLINE_ unsigned int previous_power_of_2(unsigned int x) {
+
+ x |= x >> 1;
+ x |= x >> 2;
+ x |= x >> 4;
+ x |= x >> 8;
+ x |= x >> 16;
+ return x - (x >> 1);
+}
+
+static _FORCE_INLINE_ unsigned int closest_power_of_2(unsigned int x) {
+
+ unsigned int nx = next_power_of_2(x);
+ unsigned int px = previous_power_of_2(x);
+ return (nx - x) > (x - px) ? px : nx;
+}
+
// We need this definition inside the function below.
static inline int get_shift_from_power_of_2(unsigned int p_pixel);
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index aabc2546bc..59d31d2586 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -747,6 +747,7 @@ struct _VariantCall {
VCALL_PTR1R(Transform, translated);
VCALL_PTR0R(Transform, orthonormalized);
VCALL_PTR2R(Transform, looking_at);
+ VCALL_PTR2R(Transform, interpolate_with);
static void _call_Transform_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) {
@@ -1691,7 +1692,7 @@ void register_variant_methods() {
ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, xform_inv, NIL, "v", varray());
ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, basis_xform, NIL, "v", varray());
ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, basis_xform_inv, NIL, "v", varray());
- ADDFUNC2(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "m", REAL, "c", varray());
+ ADDFUNC2(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", REAL, "weight", varray());
ADDFUNC0(BASIS, BASIS, Basis, inverse, varray());
ADDFUNC0(BASIS, BASIS, Basis, transposed, varray());
@@ -1718,6 +1719,7 @@ void register_variant_methods() {
ADDFUNC1(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray());
ADDFUNC1(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "ofs", varray());
ADDFUNC2(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray());
+ ADDFUNC2(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray());
ADDFUNC1(TRANSFORM, NIL, Transform, xform, NIL, "v", varray());
ADDFUNC1(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray());
diff --git a/core/vector.h b/core/vector.h
index 9f523c567c..966832ac50 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -71,7 +71,7 @@ class Vector {
_FORCE_INLINE_ size_t _get_alloc_size(size_t p_elements) const {
//return nearest_power_of_2_templated(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int));
- return nearest_power_of_2(p_elements * sizeof(T));
+ return next_power_of_2(p_elements * sizeof(T));
}
_FORCE_INLINE_ bool _get_alloc_size_checked(size_t p_elements, size_t *out) const {
@@ -79,7 +79,7 @@ class Vector {
size_t o;
size_t p;
if (_mul_overflow(p_elements, sizeof(T), &o)) return false;
- *out = nearest_power_of_2(o);
+ *out = next_power_of_2(o);
if (_add_overflow(o, static_cast<size_t>(32), &p)) return false; //no longer allocated here
return true;
#else