summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/array.cpp54
-rw-r--r--core/array.h8
-rw-r--r--core/bind/core_bind.cpp32
-rw-r--r--core/bind/core_bind.h7
-rw-r--r--core/class_db.cpp29
-rw-r--r--core/class_db.h9
-rw-r--r--core/command_queue_mt.h46
-rw-r--r--core/dictionary.cpp103
-rw-r--r--core/engine.cpp33
-rw-r--r--core/engine.h19
-rw-r--r--core/error_macros.cpp7
-rw-r--r--core/error_macros.h41
-rw-r--r--core/global_constants.cpp154
-rw-r--r--core/helper/math_fieldwise.cpp8
-rw-r--r--core/image.cpp25
-rw-r--r--core/image.h1
-rw-r--r--core/io/SCsub1
-rw-r--r--core/io/compression.cpp20
-rw-r--r--core/io/compression.h2
-rw-r--r--core/io/config_file.cpp20
-rw-r--r--core/io/config_file.h3
-rw-r--r--core/io/file_access_encrypted.cpp4
-rw-r--r--core/io/http_client.cpp147
-rw-r--r--core/io/http_client.h14
-rw-r--r--core/io/logger.cpp22
-rw-r--r--core/io/logger.h2
-rw-r--r--core/io/marshalls.cpp15
-rw-r--r--core/io/resource_format_binary.cpp30
-rw-r--r--core/make_binders.py2
-rw-r--r--core/map.h1
-rw-r--r--core/math/a_star.cpp73
-rw-r--r--core/math/a_star.h7
-rw-r--r--core/math/aabb.cpp (renamed from core/math/rect3.cpp)52
-rw-r--r--core/math/aabb.h (renamed from core/math/rect3.h)54
-rw-r--r--core/math/bsp_tree.cpp6
-rw-r--r--core/math/bsp_tree.h10
-rw-r--r--core/math/camera_matrix.cpp2
-rw-r--r--core/math/camera_matrix.h2
-rw-r--r--core/math/face3.cpp4
-rw-r--r--core/math/face3.h14
-rw-r--r--core/math/geometry.cpp4
-rw-r--r--core/math/math_funcs.cpp15
-rw-r--r--core/math/math_funcs.h21
-rw-r--r--core/math/matrix3.cpp38
-rw-r--r--core/math/matrix3.h15
-rw-r--r--core/math/octree.h38
-rw-r--r--core/math/quick_hull.cpp2
-rw-r--r--core/math/quick_hull.h2
-rw-r--r--core/math/transform.h14
-rw-r--r--core/math/triangle_mesh.cpp4
-rw-r--r--core/math/triangle_mesh.h4
-rw-r--r--core/method_ptrcall.h2
-rw-r--r--core/ordered_hash_map.h42
-rw-r--r--core/os/dir_access.cpp101
-rw-r--r--core/os/dir_access.h4
-rw-r--r--core/os/file_access.cpp2
-rw-r--r--core/os/input.cpp1
-rw-r--r--core/os/input_event.cpp92
-rw-r--r--core/os/input_event.h48
-rw-r--r--core/os/keyboard.cpp22
-rw-r--r--core/os/main_loop.cpp1
-rw-r--r--core/os/memory.cpp20
-rw-r--r--core/os/memory.h8
-rw-r--r--core/os/os.cpp102
-rw-r--r--core/os/os.h31
-rw-r--r--core/packed_data_container.cpp2
-rw-r--r--core/print_string.cpp20
-rw-r--r--core/print_string.h3
-rw-r--r--core/project_settings.cpp93
-rw-r--r--core/project_settings.h19
-rw-r--r--core/register_core_types.cpp45
-rw-r--r--core/script_debugger_remote.cpp174
-rw-r--r--core/script_debugger_remote.h2
-rw-r--r--core/script_language.cpp1
-rw-r--r--core/script_language.h10
-rw-r--r--core/set.h1
-rw-r--r--core/string_db.h3
-rw-r--r--core/translation.cpp149
-rw-r--r--core/translation.h7
-rw-r--r--core/type_info.h2
-rw-r--r--core/typedefs.h4
-rw-r--r--core/ustring.cpp77
-rw-r--r--core/ustring.h7
-rw-r--r--core/variant.cpp59
-rw-r--r--core/variant.h18
-rw-r--r--core/variant_call.cpp663
-rw-r--r--core/variant_op.cpp68
-rw-r--r--core/variant_parser.cpp10
-rw-r--r--core/version.h6
89 files changed, 1966 insertions, 1193 deletions
diff --git a/core/array.cpp b/core/array.cpp
index 30184a002e..b7d4ae413a 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -233,9 +233,10 @@ struct _ArrayVariantSort {
}
};
-void Array::sort() {
+Array &Array::sort() {
_p->array.sort_custom<_ArrayVariantSort>();
+ return *this;
}
struct _ArrayVariantSortCustom {
@@ -253,19 +254,64 @@ struct _ArrayVariantSortCustom {
return res;
}
};
-void Array::sort_custom(Object *p_obj, const StringName &p_function) {
+Array &Array::sort_custom(Object *p_obj, const StringName &p_function) {
- ERR_FAIL_NULL(p_obj);
+ ERR_FAIL_NULL_V(p_obj, *this);
SortArray<Variant, _ArrayVariantSortCustom> avs;
avs.compare.obj = p_obj;
avs.compare.func = p_function;
avs.sort(_p->array.ptr(), _p->array.size());
+ return *this;
+}
+
+template <typename Less>
+_FORCE_INLINE_ int bisect(const Vector<Variant> &p_array, const Variant &p_value, bool p_before, const Less &p_less) {
+
+ int lo = 0;
+ int hi = p_array.size();
+ if (p_before) {
+ while (lo < hi) {
+ const int mid = (lo + hi) / 2;
+ if (p_less(p_array.get(mid), p_value)) {
+ lo = mid + 1;
+ } else {
+ hi = mid;
+ }
+ }
+ } else {
+ while (lo < hi) {
+ const int mid = (lo + hi) / 2;
+ if (p_less(p_value, p_array.get(mid))) {
+ hi = mid;
+ } else {
+ lo = mid + 1;
+ }
+ }
+ }
+ return lo;
+}
+
+int Array::bsearch(const Variant &p_value, bool p_before) {
+
+ return bisect(_p->array, p_value, p_before, _ArrayVariantSort());
+}
+
+int Array::bsearch_custom(const Variant &p_value, Object *p_obj, const StringName &p_function, bool p_before) {
+
+ ERR_FAIL_NULL_V(p_obj, 0);
+
+ _ArrayVariantSortCustom less;
+ less.obj = p_obj;
+ less.func = p_function;
+
+ return bisect(_p->array, p_value, p_before, less);
}
-void Array::invert() {
+Array &Array::invert() {
_p->array.invert();
+ return *this;
}
void Array::push_front(const Variant &p_value) {
diff --git a/core/array.h b/core/array.h
index 8a647dd13b..3d70a31d2f 100644
--- a/core/array.h
+++ b/core/array.h
@@ -68,9 +68,11 @@ public:
Variant front() const;
Variant back() const;
- void sort();
- void sort_custom(Object *p_obj, const StringName &p_function);
- void invert();
+ Array &sort();
+ Array &sort_custom(Object *p_obj, const StringName &p_function);
+ int bsearch(const Variant &p_value, bool p_before = true);
+ int bsearch_custom(const Variant &p_value, Object *p_obj, const StringName &p_function, bool p_before = true);
+ Array &invert();
int find(const Variant &p_value, int p_from = 0) const;
int rfind(const Variant &p_value, int p_from = -1) const;
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index b47e611a51..999befaf67 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -413,6 +413,7 @@ String _OS::get_latin_keyboard_variant() const {
case OS::LATIN_KEYBOARD_QZERTY: return "QZERTY";
case OS::LATIN_KEYBOARD_DVORAK: return "DVORAK";
case OS::LATIN_KEYBOARD_NEO: return "NEO";
+ case OS::LATIN_KEYBOARD_COLEMAK: return "COLEMAK";
default: return "ERROR";
}
}
@@ -887,9 +888,9 @@ void _OS::dump_resources_to_file(const String &p_file) {
OS::get_singleton()->dump_resources_to_file(p_file.utf8().get_data());
}
-String _OS::get_data_dir() const {
+String _OS::get_user_data_dir() const {
- return OS::get_singleton()->get_data_dir();
+ return OS::get_singleton()->get_user_data_dir();
};
Error _OS::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) {
@@ -1087,7 +1088,7 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_static_memory_peak_usage"), &_OS::get_static_memory_peak_usage);
ClassDB::bind_method(D_METHOD("get_dynamic_memory_usage"), &_OS::get_dynamic_memory_usage);
- ClassDB::bind_method(D_METHOD("get_data_dir"), &_OS::get_data_dir);
+ ClassDB::bind_method(D_METHOD("get_user_data_dir"), &_OS::get_user_data_dir);
ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir);
ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id);
@@ -1315,6 +1316,16 @@ Vector<int> _Geometry::triangulate_polygon(const Vector<Vector2> &p_polygon) {
return Geometry::triangulate_polygon(p_polygon);
}
+Vector<Point2> _Geometry::convex_hull_2d(const Vector<Point2> &p_points) {
+
+ return Geometry::convex_hull_2d(p_points);
+}
+
+Vector<Vector3> _Geometry::clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane) {
+
+ return Geometry::clip_polygon(p_points, p_plane);
+}
+
Dictionary _Geometry::make_atlas(const Vector<Size2> &p_rects) {
Dictionary ret;
@@ -1375,6 +1386,8 @@ void _Geometry::_bind_methods() {
ClassDB::bind_method(D_METHOD("point_is_inside_triangle", "point", "a", "b", "c"), &_Geometry::point_is_inside_triangle);
ClassDB::bind_method(D_METHOD("triangulate_polygon", "polygon"), &_Geometry::triangulate_polygon);
+ ClassDB::bind_method(D_METHOD("convex_hull_2d", "points"), &_Geometry::convex_hull_2d);
+ ClassDB::bind_method(D_METHOD("clip_polygon", "points", "plane"), &_Geometry::clip_polygon);
ClassDB::bind_method(D_METHOD("make_atlas", "sizes"), &_Geometry::make_atlas);
}
@@ -2579,6 +2592,16 @@ bool _Engine::is_in_physics_frame() const {
return Engine::get_singleton()->is_in_physics_frame();
}
+bool _Engine::has_singleton(const String &p_name) const {
+
+ return Engine::get_singleton()->has_singleton(p_name);
+}
+
+Object *_Engine::get_singleton_object(const String &p_name) const {
+
+ return Engine::get_singleton()->get_singleton_object(p_name);
+}
+
void _Engine::set_editor_hint(bool p_enabled) {
Engine::get_singleton()->set_editor_hint(p_enabled);
@@ -2608,6 +2631,9 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_in_physics_frame"), &_Engine::is_in_physics_frame);
+ ClassDB::bind_method(D_METHOD("has_singleton", "name"), &_Engine::has_singleton);
+ ClassDB::bind_method(D_METHOD("get_singleton", "name"), &_Engine::get_singleton_object);
+
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);
}
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 7f8c734e36..8163b08d76 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -297,7 +297,7 @@ public:
String get_system_dir(SystemDir p_dir) const;
- String get_data_dir() const;
+ String get_user_data_dir() const;
void alert(const String &p_alert, const String &p_title = "ALERT!");
@@ -363,6 +363,8 @@ public:
int get_uv84_normal_bit(const Vector3 &p_vector);
Vector<int> triangulate_polygon(const Vector<Vector2> &p_polygon);
+ Vector<Point2> convex_hull_2d(const Vector<Point2> &p_points);
+ Vector<Vector3> clip_polygon(const Vector<Vector3> &p_points, const Plane &p_plane);
Dictionary make_atlas(const Vector<Size2> &p_rects);
@@ -668,6 +670,9 @@ public:
bool is_in_physics_frame() const;
+ bool has_singleton(const String &p_name) const;
+ Object *get_singleton_object(const String &p_name) const;
+
void set_editor_hint(bool p_enabled);
bool is_editor_hint() const;
diff --git a/core/class_db.cpp b/core/class_db.cpp
index f5ddd9c761..57e88044b5 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -187,6 +187,25 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
return md;
}
+MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11) {
+
+ MethodDefinition md;
+ md.name = StaticCString::create(p_name);
+ md.args.resize(11);
+ md.args[0] = StaticCString::create(p_arg1);
+ md.args[1] = StaticCString::create(p_arg2);
+ md.args[2] = StaticCString::create(p_arg3);
+ md.args[3] = StaticCString::create(p_arg4);
+ md.args[4] = StaticCString::create(p_arg5);
+ md.args[5] = StaticCString::create(p_arg6);
+ md.args[6] = StaticCString::create(p_arg7);
+ md.args[7] = StaticCString::create(p_arg8);
+ md.args[8] = StaticCString::create(p_arg9);
+ md.args[9] = StaticCString::create(p_arg10);
+ md.args[10] = StaticCString::create(p_arg11);
+ return md;
+}
+
#endif
ClassDB::APIType ClassDB::current_api = API_CORE;
@@ -205,6 +224,7 @@ ClassDB::ClassInfo::ClassInfo() {
creation_func = NULL;
inherits_ptr = NULL;
disabled = false;
+ exposed = false;
}
ClassDB::ClassInfo::~ClassInfo() {
}
@@ -1284,6 +1304,15 @@ bool ClassDB::is_class_enabled(StringName p_class) {
return !ti->disabled;
}
+bool ClassDB::is_class_exposed(StringName p_class) {
+
+ OBJTYPE_RLOCK;
+
+ ClassInfo *ti = classes.getptr(p_class);
+ ERR_FAIL_COND_V(!ti, false);
+ return ti->exposed;
+}
+
StringName ClassDB::get_category(const StringName &p_node) {
ERR_FAIL_COND_V(!classes.has(p_node), StringName());
diff --git a/core/class_db.h b/core/class_db.h
index f6b97748b0..24db4c61bb 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -66,6 +66,7 @@ MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8);
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9);
MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10);
+MethodDefinition D_METHOD(const char *p_name, const char *p_arg1, const char *p_arg2, const char *p_arg3, const char *p_arg4, const char *p_arg5, const char *p_arg6, const char *p_arg7, const char *p_arg8, const char *p_arg9, const char *p_arg10, const char *p_arg11);
#else
@@ -127,6 +128,7 @@ public:
StringName inherits;
StringName name;
bool disabled;
+ bool exposed;
Object *(*creation_func)();
ClassInfo();
~ClassInfo();
@@ -168,6 +170,7 @@ public:
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
t->creation_func = &creator<T>;
+ t->exposed = true;
T::register_custom_data_to_otdb();
}
@@ -176,6 +179,9 @@ public:
GLOBAL_LOCK_FUNCTION;
T::initialize_class();
+ ClassInfo *t = classes.getptr(T::get_class_static());
+ ERR_FAIL_COND(!t);
+ t->exposed = true;
//nothing
}
@@ -193,6 +199,7 @@ public:
ClassInfo *t = classes.getptr(T::get_class_static());
ERR_FAIL_COND(!t);
t->creation_func = &_create_ptr_func<T>;
+ t->exposed = true;
T::register_custom_data_to_otdb();
}
@@ -347,6 +354,8 @@ public:
static void set_class_enabled(StringName p_class, bool p_enable);
static bool is_class_enabled(StringName p_class);
+ static bool is_class_exposed(StringName p_class);
+
static void add_resource_base_extension(const StringName &p_extension, const StringName &p_class);
static void get_resource_base_extensions(List<String> *p_extensions);
static void get_extensions_for_type(const StringName &p_class, List<String> *p_extensions);
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index f99e16da15..e37d593f9f 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -227,6 +227,27 @@ class CommandQueueMT {
virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
};
+ template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
+ struct Command12 : public CommandBase {
+
+ T *instance;
+ M method;
+ typename GetSimpleTypeT<P1>::type_t p1;
+ typename GetSimpleTypeT<P2>::type_t p2;
+ typename GetSimpleTypeT<P3>::type_t p3;
+ typename GetSimpleTypeT<P4>::type_t p4;
+ typename GetSimpleTypeT<P5>::type_t p5;
+ typename GetSimpleTypeT<P6>::type_t p6;
+ typename GetSimpleTypeT<P7>::type_t p7;
+ typename GetSimpleTypeT<P8>::type_t p8;
+ typename GetSimpleTypeT<P9>::type_t p9;
+ typename GetSimpleTypeT<P10>::type_t p10;
+ typename GetSimpleTypeT<P11>::type_t p11;
+ typename GetSimpleTypeT<P12>::type_t p12;
+
+ virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
+ };
+
/* comands that return */
template <class T, class M, class R>
@@ -906,6 +927,31 @@ public:
if (sync) sync->post();
}
+ template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11, class P12>
+ void push(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12) {
+
+ Command12<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> *cmd = allocate_and_lock<Command12<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> >();
+
+ cmd->instance = p_instance;
+ cmd->method = p_method;
+ cmd->p1 = p1;
+ cmd->p2 = p2;
+ cmd->p3 = p3;
+ cmd->p4 = p4;
+ cmd->p5 = p5;
+ cmd->p6 = p6;
+ cmd->p7 = p7;
+ cmd->p8 = p8;
+ cmd->p9 = p9;
+ cmd->p10 = p10;
+ cmd->p11 = p11;
+ cmd->p12 = p12;
+
+ unlock();
+
+ if (sync) sync->post();
+ }
+
/*** PUSH AND RET COMMANDS ***/
template <class T, class M, class R>
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index bb2e892951..48e65c734f 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "dictionary.h"
+#include "ordered_hash_map.h"
#include "safe_refcount.h"
#include "variant.h"
@@ -39,22 +40,8 @@ struct _DictionaryVariantHash {
struct DictionaryPrivate {
- struct Data {
- Variant variant;
- int order;
- };
-
SafeRefCount refcount;
- HashMap<Variant, Data, _DictionaryVariantHash> variant_map;
- int counter;
-};
-
-struct DictionaryPrivateSort {
-
- bool operator()(const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *A, const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *B) const {
-
- return A->data.order < B->data.order;
- }
+ OrderedHashMap<Variant, Variant, _DictionaryVariantHash> variant_map;
};
void Dictionary::get_key_list(List<Variant> *p_keys) const {
@@ -62,61 +49,45 @@ void Dictionary::get_key_list(List<Variant> *p_keys) const {
if (_p->variant_map.empty())
return;
- int count = _p->variant_map.size();
- const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **pairs = (const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **)alloca(count * sizeof(HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *));
- _p->variant_map.get_key_value_ptr_array(pairs);
-
- SortArray<const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *, DictionaryPrivateSort> sort;
- sort.sort(pairs, count);
-
- for (int i = 0; i < count; i++) {
- p_keys->push_back(pairs[i]->key);
+ for (OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.front(); E; E = E.next()) {
+ p_keys->push_back(E.key());
}
}
Variant &Dictionary::operator[](const Variant &p_key) {
- DictionaryPrivate::Data *v = _p->variant_map.getptr(p_key);
-
- if (!v) {
-
- DictionaryPrivate::Data d;
- d.order = _p->counter++;
- _p->variant_map[p_key] = d;
- v = _p->variant_map.getptr(p_key);
- }
- return v->variant;
+ return _p->variant_map[p_key];
}
const Variant &Dictionary::operator[](const Variant &p_key) const {
- return _p->variant_map[p_key].variant;
+ return _p->variant_map[p_key];
}
const Variant *Dictionary::getptr(const Variant &p_key) const {
- const DictionaryPrivate::Data *v = _p->variant_map.getptr(p_key);
- if (!v)
+ OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::ConstElement E = ((const OrderedHashMap<Variant, Variant, _DictionaryVariantHash> *)&_p->variant_map)->find(p_key);
+
+ if (!E)
return NULL;
- else
- return &v->variant;
+ return &E.get();
}
Variant *Dictionary::getptr(const Variant &p_key) {
- DictionaryPrivate::Data *v = _p->variant_map.getptr(p_key);
- if (!v)
+ OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.find(p_key);
+
+ if (!E)
return NULL;
- else
- return &v->variant;
+ return &E.get();
}
Variant Dictionary::get_valid(const Variant &p_key) const {
- DictionaryPrivate::Data *v = _p->variant_map.getptr(p_key);
- if (!v)
+ OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::ConstElement E = ((const OrderedHashMap<Variant, Variant, _DictionaryVariantHash> *)&_p->variant_map)->find(p_key);
+
+ if (!E)
return Variant();
- else
- return v->variant;
+ return E.get();
}
int Dictionary::size() const {
@@ -171,7 +142,6 @@ void Dictionary::_ref(const Dictionary &p_from) const {
void Dictionary::clear() {
_p->variant_map.clear();
- _p->counter = 0;
}
void Dictionary::_unref() const {
@@ -205,15 +175,10 @@ Array Dictionary::keys() const {
if (_p->variant_map.empty())
return varr;
- int count = _p->variant_map.size();
- const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **pairs = (const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **)alloca(count * sizeof(HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *));
- _p->variant_map.get_key_value_ptr_array(pairs);
-
- SortArray<const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *, DictionaryPrivateSort> sort;
- sort.sort(pairs, count);
-
- for (int i = 0; i < count; i++) {
- varr[i] = pairs[i]->key;
+ int i = 0;
+ for (OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.front(); E; E = E.next()) {
+ varr[i] = E.key();
+ i++;
}
return varr;
@@ -226,15 +191,10 @@ Array Dictionary::values() const {
if (_p->variant_map.empty())
return varr;
- int count = _p->variant_map.size();
- const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **pairs = (const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair **)alloca(count * sizeof(HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *));
- _p->variant_map.get_key_value_ptr_array(pairs);
-
- SortArray<const HashMap<Variant, DictionaryPrivate::Data, _DictionaryVariantHash>::Pair *, DictionaryPrivateSort> sort;
- sort.sort(pairs, count);
-
- for (int i = 0; i < count; i++) {
- varr[i] = pairs[i]->data.variant;
+ int i = 0;
+ for (OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.front(); E; E = E.next()) {
+ varr[i] = E.get();
+ i++;
}
return varr;
@@ -242,7 +202,15 @@ Array Dictionary::values() const {
const Variant *Dictionary::next(const Variant *p_key) const {
- return _p->variant_map.next(p_key);
+ if (p_key == NULL) {
+ // caller wants to get the first element
+ return &_p->variant_map.front().key();
+ }
+ OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.find(*p_key);
+
+ if (E && E.next())
+ return &E.next().key();
+ return NULL;
}
Dictionary Dictionary::copy() const {
@@ -273,7 +241,6 @@ Dictionary::Dictionary() {
_p = memnew(DictionaryPrivate);
_p->refcount.init();
- _p->counter = 0;
}
Dictionary::~Dictionary() {
diff --git a/core/engine.cpp b/core/engine.cpp
index c609ae9520..53c7a73b43 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -84,22 +84,47 @@ Dictionary Engine::get_version_info() const {
#else
dict["patch"] = 0;
#endif
- dict["status"] = _MKSTR(VERSION_STATUS);
- dict["revision"] = _MKSTR(VERSION_REVISION);
+ dict["status"] = VERSION_STATUS;
+ dict["build"] = VERSION_BUILD;
dict["year"] = VERSION_YEAR;
- String hash = String(VERSION_HASH);
+ String hash = VERSION_HASH;
dict["hash"] = hash.length() == 0 ? String("unknown") : hash;
String stringver = String(dict["major"]) + "." + String(dict["minor"]);
if ((int)dict["patch"] != 0)
stringver += "." + String(dict["patch"]);
- stringver += "-" + String(dict["status"]) + " (" + String(dict["revision"]) + ")";
+ stringver += "-" + String(dict["status"]) + " (" + String(dict["build"]) + ")";
dict["string"] = stringver;
return dict;
}
+void Engine::add_singleton(const Singleton &p_singleton) {
+
+ singletons.push_back(p_singleton);
+ singleton_ptrs[p_singleton.name] = p_singleton.ptr;
+}
+
+Object *Engine::get_singleton_object(const String &p_name) const {
+
+ const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
+ ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'");
+ ERR_FAIL_COND_V(!E, NULL);
+ return E->get();
+};
+
+bool Engine::has_singleton(const String &p_name) const {
+
+ return singleton_ptrs.has(p_name);
+};
+
+void Engine::get_singletons(List<Singleton> *p_singletons) {
+
+ for (List<Singleton>::Element *E = singletons.front(); E; E = E->next())
+ p_singletons->push_back(E->get());
+}
+
Engine *Engine::singleton = NULL;
Engine *Engine::get_singleton() {
diff --git a/core/engine.h b/core/engine.h
index 3b4979582f..4a573c1539 100644
--- a/core/engine.h
+++ b/core/engine.h
@@ -37,6 +37,17 @@
class Engine {
+public:
+ struct Singleton {
+ StringName name;
+ Object *ptr;
+ Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL)
+ : name(p_name),
+ ptr(p_ptr) {
+ }
+ };
+
+private:
friend class Main;
uint64_t frames_drawn;
@@ -54,6 +65,9 @@ class Engine {
uint64_t _idle_frames;
bool _in_physics;
+ List<Singleton> singletons;
+ Map<StringName, Object *> singleton_ptrs;
+
bool editor_hint;
static Engine *singleton;
@@ -83,6 +97,11 @@ public:
void set_frame_delay(uint32_t p_msec);
uint32_t get_frame_delay() const;
+ void add_singleton(const Singleton &p_singleton);
+ void get_singletons(List<Singleton> *p_singletons);
+ bool has_singleton(const String &p_name) const;
+ Object *get_singleton_object(const String &p_name) const;
+
_FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; }
#ifdef TOOLS_ENABLED
diff --git a/core/error_macros.cpp b/core/error_macros.cpp
index 170a22e8dd..7d85aa9001 100644
--- a/core/error_macros.cpp
+++ b/core/error_macros.cpp
@@ -97,3 +97,10 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co
_err_error_exists = false;
}
}
+
+void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, bool fatal) {
+
+ String fstr(fatal ? "FATAL: " : "");
+ String err(fstr + "Index" + p_index_str + "=" + itos(p_index) + " out of size (" + p_size_str + "=" + itos(p_size) + ")");
+ _err_print_error(p_function, p_file, p_line, err.utf8().get_data());
+}
diff --git a/core/error_macros.h b/core/error_macros.h
index 1fa7f2c134..8d2f588706 100644
--- a/core/error_macros.h
+++ b/core/error_macros.h
@@ -76,6 +76,7 @@ void add_error_handler(ErrorHandlerList *p_handler);
void remove_error_handler(ErrorHandlerList *p_handler);
void _err_print_error(const char *p_function, const char *p_file, int p_line, const char *p_error, ErrorHandlerType p_type = ERR_HANDLER_ERROR);
+void _err_print_index_error(const char *p_function, const char *p_file, int p_line, int64_t p_index, int64_t p_size, const char *p_index_str, const char *p_size_str, bool fatal = false);
#ifndef _STR
#define _STR(m_x) #m_x
@@ -129,13 +130,13 @@ extern bool _err_error_exists;
// (*): See https://stackoverflow.com/questions/257418/do-while-0-what-is-it-good-for
-#define ERR_FAIL_INDEX(m_index, m_size) \
- do { \
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Index " _STR(m_index) " out of size (" _STR(m_size) ")."); \
- return; \
- } else \
- _err_error_exists = false; \
+#define ERR_FAIL_INDEX(m_index, m_size) \
+ do { \
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
+ return; \
+ } else \
+ _err_error_exists = false; \
} while (0); // (*)
/** An index has failed if m_index<0 or m_index >=m_size, the function exists.
@@ -143,24 +144,24 @@ extern bool _err_error_exists;
* appropriate error condition from error_macros.h
*/
-#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \
- do { \
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Index " _STR(m_index) " out of size (" _STR(m_size) ")."); \
- return m_retval; \
- } else \
- _err_error_exists = false; \
+#define ERR_FAIL_INDEX_V(m_index, m_size, m_retval) \
+ do { \
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size)); \
+ return m_retval; \
+ } else \
+ _err_error_exists = false; \
} while (0); // (*)
/** Use this one if there is no sensible fallback, that is, the error is unrecoverable.
* We'll return a null reference and try to keep running.
*/
-#define CRASH_BAD_INDEX(m_index, m_size) \
- do { \
- if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Index " _STR(m_index) " out of size (" _STR(m_size) ")."); \
- GENERATE_TRAP \
- } \
+#define CRASH_BAD_INDEX(m_index, m_size) \
+ do { \
+ if (unlikely((m_index) < 0 || (m_index) >= (m_size))) { \
+ _err_print_index_error(FUNCTION_STR, __FILE__, __LINE__, m_index, m_size, _STR(m_index), _STR(m_size), true); \
+ GENERATE_TRAP \
+ } \
} while (0); // (*)
/** An error condition happened (m_cond tested true) (WARNING this is the opposite as assert().
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 6f58af2ccf..48101c8cf1 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -86,6 +86,8 @@ static Vector<_GlobalConstant> _global_constants;
VARIANT_ENUM_CAST(KeyList);
VARIANT_ENUM_CAST(KeyModifierMask);
+VARIANT_ENUM_CAST(ButtonList);
+VARIANT_ENUM_CAST(JoystickList);
void register_global_constants() {
@@ -367,82 +369,84 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT(KEY_MASK_GROUP_SWITCH);
// mouse
- BIND_GLOBAL_CONSTANT(BUTTON_LEFT);
- BIND_GLOBAL_CONSTANT(BUTTON_RIGHT);
- BIND_GLOBAL_CONSTANT(BUTTON_MIDDLE);
- BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_UP);
- BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_DOWN);
- BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_LEFT);
- BIND_GLOBAL_CONSTANT(BUTTON_WHEEL_RIGHT);
- BIND_GLOBAL_CONSTANT(BUTTON_MASK_LEFT);
- BIND_GLOBAL_CONSTANT(BUTTON_MASK_RIGHT);
- BIND_GLOBAL_CONSTANT(BUTTON_MASK_MIDDLE);
+ BIND_GLOBAL_ENUM_CONSTANT(BUTTON_LEFT);
+ BIND_GLOBAL_ENUM_CONSTANT(BUTTON_RIGHT);
+ BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MIDDLE);
+ BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_UP);
+ BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_DOWN);
+ BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_LEFT);
+ BIND_GLOBAL_ENUM_CONSTANT(BUTTON_WHEEL_RIGHT);
+ BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_LEFT);
+ BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_RIGHT);
+ BIND_GLOBAL_ENUM_CONSTANT(BUTTON_MASK_MIDDLE);
//joypads
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_0);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_1);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_2);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_3);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_4);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_5);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_6);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_7);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_8);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_9);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_10);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_11);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_12);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_13);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_14);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_15);
- BIND_GLOBAL_CONSTANT(JOY_BUTTON_MAX);
-
- BIND_GLOBAL_CONSTANT(JOY_SONY_CIRCLE);
- BIND_GLOBAL_CONSTANT(JOY_SONY_X);
- BIND_GLOBAL_CONSTANT(JOY_SONY_SQUARE);
- BIND_GLOBAL_CONSTANT(JOY_SONY_TRIANGLE);
-
- BIND_GLOBAL_CONSTANT(JOY_XBOX_B);
- BIND_GLOBAL_CONSTANT(JOY_XBOX_A);
- BIND_GLOBAL_CONSTANT(JOY_XBOX_X);
- BIND_GLOBAL_CONSTANT(JOY_XBOX_Y);
-
- BIND_GLOBAL_CONSTANT(JOY_DS_A);
- BIND_GLOBAL_CONSTANT(JOY_DS_B);
- BIND_GLOBAL_CONSTANT(JOY_DS_X);
- BIND_GLOBAL_CONSTANT(JOY_DS_Y);
-
- BIND_GLOBAL_CONSTANT(JOY_SELECT);
- BIND_GLOBAL_CONSTANT(JOY_START);
- BIND_GLOBAL_CONSTANT(JOY_DPAD_UP);
- BIND_GLOBAL_CONSTANT(JOY_DPAD_DOWN);
- BIND_GLOBAL_CONSTANT(JOY_DPAD_LEFT);
- BIND_GLOBAL_CONSTANT(JOY_DPAD_RIGHT);
- BIND_GLOBAL_CONSTANT(JOY_L);
- BIND_GLOBAL_CONSTANT(JOY_L2);
- BIND_GLOBAL_CONSTANT(JOY_L3);
- BIND_GLOBAL_CONSTANT(JOY_R);
- BIND_GLOBAL_CONSTANT(JOY_R2);
- BIND_GLOBAL_CONSTANT(JOY_R3);
-
- BIND_GLOBAL_CONSTANT(JOY_AXIS_0);
- BIND_GLOBAL_CONSTANT(JOY_AXIS_1);
- BIND_GLOBAL_CONSTANT(JOY_AXIS_2);
- BIND_GLOBAL_CONSTANT(JOY_AXIS_3);
- BIND_GLOBAL_CONSTANT(JOY_AXIS_4);
- BIND_GLOBAL_CONSTANT(JOY_AXIS_5);
- BIND_GLOBAL_CONSTANT(JOY_AXIS_6);
- BIND_GLOBAL_CONSTANT(JOY_AXIS_7);
- BIND_GLOBAL_CONSTANT(JOY_AXIS_MAX);
-
- BIND_GLOBAL_CONSTANT(JOY_ANALOG_LX);
- BIND_GLOBAL_CONSTANT(JOY_ANALOG_LY);
-
- BIND_GLOBAL_CONSTANT(JOY_ANALOG_RX);
- BIND_GLOBAL_CONSTANT(JOY_ANALOG_RY);
-
- BIND_GLOBAL_CONSTANT(JOY_ANALOG_L2);
- BIND_GLOBAL_CONSTANT(JOY_ANALOG_R2);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_0);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_1);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_2);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_3);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_4);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_5);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_6);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_7);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_8);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_9);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_10);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_11);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_12);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_13);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_14);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_15);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_BUTTON_MAX);
+
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_CIRCLE);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_X);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_SQUARE);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_SONY_TRIANGLE);
+
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_B);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_A);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_X);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_XBOX_Y);
+
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_A);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_B);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_X);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_DS_Y);
+
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_SELECT);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_START);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_UP);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_DOWN);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_LEFT);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_DPAD_RIGHT);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_L);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_L2);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_L3);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_R);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_R2);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_R3);
+
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_0);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_1);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_2);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_3);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_4);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_5);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_6);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_7);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_8);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_9);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_MAX);
+
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_LX);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_LY);
+
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_RX);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_RY);
+
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_L2);
+ BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_R2);
// error list
@@ -553,7 +557,7 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM2D", Variant::TRANSFORM2D);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_PLANE", Variant::PLANE);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUAT", Variant::QUAT); // 10
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT3", Variant::RECT3);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_AABB", Variant::AABB);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BASIS", Variant::BASIS);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM", Variant::TRANSFORM);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR", Variant::COLOR);
diff --git a/core/helper/math_fieldwise.cpp b/core/helper/math_fieldwise.cpp
index 228611f8b3..2cd8a4f392 100644
--- a/core/helper/math_fieldwise.cpp
+++ b/core/helper/math_fieldwise.cpp
@@ -46,8 +46,8 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const
switch (p_source.get_type()) {
- /* clang-format makes a mess of this macro usage */
- /* clang-format off */
+ /* clang-format makes a mess of this macro usage */
+ /* clang-format off */
case Variant::VECTOR2: {
@@ -106,9 +106,9 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const
return target;
}
- case Variant::RECT3: {
+ case Variant::AABB: {
- SETUP_TYPE(Rect3)
+ SETUP_TYPE(AABB)
/**/ TRY_TRANSFER_FIELD("px", position.x)
else TRY_TRANSFER_FIELD("py", position.y)
diff --git a/core/image.cpp b/core/image.cpp
index c7f21d5599..422c0e407b 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -757,22 +757,24 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
_copy_internals_from(dst);
}
-void Image::crop(int p_width, int p_height) {
+void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) {
if (!_can_modify(format)) {
ERR_EXPLAIN("Cannot crop in indexed, compressed or custom image formats.");
ERR_FAIL();
}
+ ERR_FAIL_COND(p_x < 0);
+ ERR_FAIL_COND(p_y < 0);
ERR_FAIL_COND(p_width <= 0);
ERR_FAIL_COND(p_height <= 0);
- ERR_FAIL_COND(p_width > MAX_WIDTH);
- ERR_FAIL_COND(p_height > MAX_HEIGHT);
+ ERR_FAIL_COND(p_x + p_width > MAX_WIDTH);
+ ERR_FAIL_COND(p_y + p_height > MAX_HEIGHT);
/* to save memory, cropping should be done in-place, however, since this function
will most likely either not be used much, or in critical areas, for now it wont, because
it's a waste of time. */
- if (p_width == width && p_height == height)
+ if (p_width == width && p_height == height && p_x == 0 && p_y == 0)
return;
uint8_t pdata[16]; //largest is 16
@@ -784,9 +786,11 @@ void Image::crop(int p_width, int p_height) {
PoolVector<uint8_t>::Read r = data.read();
PoolVector<uint8_t>::Write w = dst.data.write();
- for (int y = 0; y < p_height; y++) {
+ int m_h = p_y + p_height;
+ int m_w = p_x + p_width;
+ for (int y = p_y; y < m_h; y++) {
- for (int x = 0; x < p_width; x++) {
+ for (int x = p_x; x < m_w; x++) {
if ((x >= width || y >= height)) {
for (uint32_t i = 0; i < pixel_size; i++)
@@ -795,7 +799,7 @@ void Image::crop(int p_width, int p_height) {
_get_pixelb(x, y, pixel_size, r.ptr(), pdata);
}
- dst._put_pixelb(x, y, pixel_size, w.ptr(), pdata);
+ dst._put_pixelb(x - p_x, y - p_y, pixel_size, w.ptr(), pdata);
}
}
}
@@ -805,6 +809,11 @@ void Image::crop(int p_width, int p_height) {
_copy_internals_from(dst);
}
+void Image::crop(int p_width, int p_height) {
+
+ crop_from_point(0, 0, p_width, p_height);
+}
+
void Image::flip_y() {
if (!_can_modify(format)) {
@@ -1061,7 +1070,6 @@ Error Image::generate_mipmaps() {
int size = _get_dst_image_size(width, height, format, mmcount);
data.resize(size);
- print_line("to gen mipmaps w " + itos(width) + " h " + itos(height) + " format " + get_format_name(format) + " mipmaps " + itos(mmcount) + " new size is: " + itos(size));
PoolVector<uint8_t>::Write wp = data.write();
@@ -2474,6 +2482,7 @@ void Image::fix_alpha_edges() {
if (rp[3] < alpha_threshold)
continue;
+ closest_dist = dist;
closest_color[0] = rp[0];
closest_color[1] = rp[1];
closest_color[2] = rp[2];
diff --git a/core/image.h b/core/image.h
index 27df65a898..24693aa706 100644
--- a/core/image.h
+++ b/core/image.h
@@ -207,6 +207,7 @@ public:
/**
* Crop the image to a specific size, if larger, then the image is filled by black
*/
+ void crop_from_point(int p_x, int p_y, int p_width, int p_height);
void crop(int p_width, int p_height);
void flip_x();
diff --git a/core/io/SCsub b/core/io/SCsub
index 4efc902717..79b56cb716 100644
--- a/core/io/SCsub
+++ b/core/io/SCsub
@@ -5,3 +5,4 @@ Import('env')
env.add_source_files(env.core_sources, "*.cpp")
Export('env')
+
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index fbe97e54c7..51d48901cf 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -78,9 +78,16 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
} break;
case MODE_ZSTD: {
-
+ ZSTD_CCtx *cctx = ZSTD_createCCtx();
+ ZSTD_CCtx_setParameter(cctx, ZSTD_p_compressionLevel, zstd_level);
+ if (zstd_long_distance_matching) {
+ ZSTD_CCtx_setParameter(cctx, ZSTD_p_enableLongDistanceMatching, 1);
+ ZSTD_CCtx_setParameter(cctx, ZSTD_p_windowLog, zstd_window_log_size);
+ }
int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD);
- return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, zstd_level);
+ int ret = ZSTD_compressCCtx(cctx, p_dst, max_dst_size, p_src, p_src_size, zstd_level);
+ ZSTD_freeCCtx(cctx);
+ return ret;
} break;
}
@@ -165,8 +172,11 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
return total;
} break;
case MODE_ZSTD: {
-
- return ZSTD_decompress(p_dst, p_dst_max_size, p_src, p_src_size);
+ ZSTD_DCtx *dctx = ZSTD_createDCtx();
+ if (zstd_long_distance_matching) ZSTD_DCtx_setMaxWindowSize(dctx, 1 << zstd_window_log_size);
+ int ret = ZSTD_decompressDCtx(dctx, p_dst, p_dst_max_size, p_src, p_src_size);
+ ZSTD_freeDCtx(dctx);
+ return ret;
} break;
}
@@ -176,3 +186,5 @@ int Compression::decompress(uint8_t *p_dst, int p_dst_max_size, const uint8_t *p
int Compression::zlib_level = Z_DEFAULT_COMPRESSION;
int Compression::gzip_level = Z_DEFAULT_COMPRESSION;
int Compression::zstd_level = 3;
+bool Compression::zstd_long_distance_matching = false;
+int Compression::zstd_window_log_size = 27;
diff --git a/core/io/compression.h b/core/io/compression.h
index 22d8109d4f..5a9aedec31 100644
--- a/core/io/compression.h
+++ b/core/io/compression.h
@@ -38,6 +38,8 @@ public:
static int zlib_level;
static int gzip_level;
static int zstd_level;
+ static bool zstd_long_distance_matching;
+ static int zstd_window_log_size;
enum Mode {
MODE_FASTLZ,
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp
index daa6b01d6e..2b60150832 100644
--- a/core/io/config_file.cpp
+++ b/core/io/config_file.cpp
@@ -75,7 +75,7 @@ void ConfigFile::set_value(const String &p_section, const String &p_key, const V
} else {
if (!values.has(p_section)) {
- values[p_section] = Map<String, Variant>();
+ values[p_section] = OrderedHashMap<String, Variant>();
}
values[p_section][p_key] = p_value;
@@ -106,16 +106,16 @@ bool ConfigFile::has_section_key(const String &p_section, const String &p_key) c
void ConfigFile::get_sections(List<String> *r_sections) const {
- for (const Map<String, Map<String, Variant> >::Element *E = values.front(); E; E = E->next()) {
- r_sections->push_back(E->key());
+ for (OrderedHashMap<String, OrderedHashMap<String, Variant> >::ConstElement E = values.front(); E; E = E.next()) {
+ r_sections->push_back(E.key());
}
}
void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) const {
ERR_FAIL_COND(!values.has(p_section));
- for (const Map<String, Variant>::Element *E = values[p_section].front(); E; E = E->next()) {
- r_keys->push_back(E->key());
+ for (OrderedHashMap<String, Variant>::ConstElement E = values[p_section].front(); E; E = E.next()) {
+ r_keys->push_back(E.key());
}
}
@@ -135,17 +135,17 @@ Error ConfigFile::save(const String &p_path) {
return err;
}
- for (Map<String, Map<String, Variant> >::Element *E = values.front(); E; E = E->next()) {
+ for (OrderedHashMap<String, OrderedHashMap<String, Variant> >::Element E = values.front(); E; E = E.next()) {
if (E != values.front())
file->store_string("\n");
- file->store_string("[" + E->key() + "]\n\n");
+ file->store_string("[" + E.key() + "]\n\n");
- for (Map<String, Variant>::Element *F = E->get().front(); F; F = F->next()) {
+ for (OrderedHashMap<String, Variant>::Element F = E.get().front(); F; F = F.next()) {
String vstr;
- VariantWriter::write_to_string(F->get(), vstr);
- file->store_string(F->key() + "=" + vstr + "\n");
+ VariantWriter::write_to_string(F.get(), vstr);
+ file->store_string(F.key() + "=" + vstr + "\n");
}
}
diff --git a/core/io/config_file.h b/core/io/config_file.h
index 8ed8a069e4..29bd369a24 100644
--- a/core/io/config_file.h
+++ b/core/io/config_file.h
@@ -30,13 +30,14 @@
#ifndef CONFIG_FILE_H
#define CONFIG_FILE_H
+#include "core/ordered_hash_map.h"
#include "reference.h"
class ConfigFile : public Reference {
GDCLASS(ConfigFile, Reference);
- Map<String, Map<String, Variant> > values;
+ OrderedHashMap<String, OrderedHashMap<String, Variant> > values;
PoolStringArray _get_sections() const;
PoolStringArray _get_section_keys(const String &p_section) const;
diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp
index c93e12f7da..e5da307153 100644
--- a/core/io/file_access_encrypted.cpp
+++ b/core/io/file_access_encrypted.cpp
@@ -62,12 +62,12 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
writing = false;
key = p_key;
uint32_t magic = p_base->get_32();
- print_line("MAGIC: " + itos(magic));
ERR_FAIL_COND_V(magic != COMP_MAGIC, ERR_FILE_UNRECOGNIZED);
+
mode = Mode(p_base->get_32());
ERR_FAIL_INDEX_V(mode, MODE_MAX, ERR_FILE_CORRUPT);
ERR_FAIL_COND_V(mode == 0, ERR_FILE_CORRUPT);
- print_line("MODE: " + itos(mode));
+
unsigned char md5d[16];
p_base->get_buffer(md5d, 16);
length = p_base->get_64();
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index b8c0a2b616..5097898314 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -30,6 +30,7 @@
#include "http_client.h"
#include "io/stream_peer_ssl.h"
+#ifndef JAVASCRIPT_ENABLED
Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) {
close();
@@ -189,16 +190,6 @@ Error HTTPClient::request(Method p_method, const String &p_url, const Vector<Str
return OK;
}
-Error HTTPClient::send_body_text(const String &p_body) {
-
- return OK;
-}
-
-Error HTTPClient::send_body_data(const PoolByteArray &p_body) {
-
- return OK;
-}
-
bool HTTPClient::has_response() const {
return response_headers.size() != 0;
@@ -415,38 +406,6 @@ Error HTTPClient::poll() {
return OK;
}
-Dictionary HTTPClient::_get_response_headers_as_dictionary() {
-
- List<String> rh;
- get_response_headers(&rh);
- Dictionary ret;
- for (const List<String>::Element *E = rh.front(); E; E = E->next()) {
- String s = E->get();
- int sp = s.find(":");
- if (sp == -1)
- continue;
- String key = s.substr(0, sp).strip_edges();
- String value = s.substr(sp + 1, s.length()).strip_edges();
- ret[key] = value;
- }
-
- return ret;
-}
-
-PoolStringArray HTTPClient::_get_response_headers() {
-
- List<String> rh;
- get_response_headers(&rh);
- PoolStringArray ret;
- ret.resize(rh.size());
- int idx = 0;
- for (const List<String>::Element *E = rh.front(); E; E = E->next()) {
- ret.set(idx++, E->get());
- }
-
- return ret;
-}
-
int HTTPClient::get_response_body_length() const {
return body_size;
@@ -622,6 +581,74 @@ Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received
}
}
+void HTTPClient::set_read_chunk_size(int p_size) {
+ ERR_FAIL_COND(p_size < 256 || p_size > (1 << 24));
+ read_chunk_size = p_size;
+}
+
+HTTPClient::HTTPClient() {
+
+ tcp_connection = StreamPeerTCP::create_ref();
+ resolving = IP::RESOLVER_INVALID_ID;
+ status = STATUS_DISCONNECTED;
+ conn_port = 80;
+ body_size = 0;
+ chunked = false;
+ body_left = 0;
+ chunk_left = 0;
+ response_num = 0;
+ ssl = false;
+ blocking = false;
+ read_chunk_size = 4096;
+}
+
+HTTPClient::~HTTPClient() {
+}
+
+#endif // #ifndef JAVASCRIPT_ENABLED
+
+String HTTPClient::query_string_from_dict(const Dictionary &p_dict) {
+ String query = "";
+ Array keys = p_dict.keys();
+ for (int i = 0; i < keys.size(); ++i) {
+ query += "&" + String(keys[i]).http_escape() + "=" + String(p_dict[keys[i]]).http_escape();
+ }
+ query.erase(0, 1);
+ return query;
+}
+
+Dictionary HTTPClient::_get_response_headers_as_dictionary() {
+
+ List<String> rh;
+ get_response_headers(&rh);
+ Dictionary ret;
+ for (const List<String>::Element *E = rh.front(); E; E = E->next()) {
+ String s = E->get();
+ int sp = s.find(":");
+ if (sp == -1)
+ continue;
+ String key = s.substr(0, sp).strip_edges();
+ String value = s.substr(sp + 1, s.length()).strip_edges();
+ ret[key] = value;
+ }
+
+ return ret;
+}
+
+PoolStringArray HTTPClient::_get_response_headers() {
+
+ List<String> rh;
+ get_response_headers(&rh);
+ PoolStringArray ret;
+ ret.resize(rh.size());
+ int idx = 0;
+ for (const List<String>::Element *E = rh.front(); E; E = E->next()) {
+ ret.set(idx++, E->get());
+ }
+
+ return ret;
+}
+
void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(false), DEFVAL(true));
@@ -629,8 +656,6 @@ void HTTPClient::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_connection"), &HTTPClient::get_connection);
ClassDB::bind_method(D_METHOD("request_raw", "method", "url", "headers", "body"), &HTTPClient::request_raw);
ClassDB::bind_method(D_METHOD("request", "method", "url", "headers", "body"), &HTTPClient::request, DEFVAL(String()));
- ClassDB::bind_method(D_METHOD("send_body_text", "body"), &HTTPClient::send_body_text);
- ClassDB::bind_method(D_METHOD("send_body_data", "body"), &HTTPClient::send_body_data);
ClassDB::bind_method(D_METHOD("close"), &HTTPClient::close);
ClassDB::bind_method(D_METHOD("has_response"), &HTTPClient::has_response);
@@ -729,37 +754,3 @@ void HTTPClient::_bind_methods() {
BIND_ENUM_CONSTANT(RESPONSE_INSUFFICIENT_STORAGE);
BIND_ENUM_CONSTANT(RESPONSE_NOT_EXTENDED);
}
-
-void HTTPClient::set_read_chunk_size(int p_size) {
- ERR_FAIL_COND(p_size < 256 || p_size > (1 << 24));
- read_chunk_size = p_size;
-}
-
-String HTTPClient::query_string_from_dict(const Dictionary &p_dict) {
- String query = "";
- Array keys = p_dict.keys();
- for (int i = 0; i < keys.size(); ++i) {
- query += "&" + String(keys[i]).http_escape() + "=" + String(p_dict[keys[i]]).http_escape();
- }
- query.erase(0, 1);
- return query;
-}
-
-HTTPClient::HTTPClient() {
-
- tcp_connection = StreamPeerTCP::create_ref();
- resolving = IP::RESOLVER_INVALID_ID;
- status = STATUS_DISCONNECTED;
- conn_port = 80;
- body_size = 0;
- chunked = false;
- body_left = 0;
- chunk_left = 0;
- response_num = 0;
- ssl = false;
- blocking = false;
- read_chunk_size = 4096;
-}
-
-HTTPClient::~HTTPClient() {
-}
diff --git a/core/io/http_client.h b/core/io/http_client.h
index 023370ae81..db5dd115bd 100644
--- a/core/io/http_client.h
+++ b/core/io/http_client.h
@@ -131,6 +131,7 @@ public:
};
private:
+#ifndef JAVASCRIPT_ENABLED
Status status;
IP::ResolverID resolving;
int conn_port;
@@ -152,13 +153,18 @@ private:
int response_num;
Vector<String> response_headers;
+ int read_chunk_size;
+
+ Error _get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received);
+
+#else
+#include "platform/javascript/http_client.h.inc"
+#endif
- static void _bind_methods();
PoolStringArray _get_response_headers();
Dictionary _get_response_headers_as_dictionary();
- int read_chunk_size;
- Error _get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received);
+ static void _bind_methods();
public:
//Error connect_and_get(const String& p_url,bool p_verify_host=true); //connects to a full url and perform request
@@ -169,8 +175,6 @@ public:
Error request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const PoolVector<uint8_t> &p_body);
Error request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body = String());
- Error send_body_text(const String &p_body);
- Error send_body_data(const PoolByteArray &p_body);
void close();
diff --git a/core/io/logger.cpp b/core/io/logger.cpp
index b94007d316..7177359c8a 100644
--- a/core/io/logger.cpp
+++ b/core/io/logger.cpp
@@ -29,10 +29,22 @@
/*************************************************************************/
#include "logger.h"
+
#include "os/dir_access.h"
#include "os/os.h"
#include "print_string.h"
+// va_copy was defined in the C99, but not in C++ standards before C++11.
+// When you compile C++ without --std=c++<XX> option, compilers still define
+// va_copy, otherwise you have to use the internal version (__va_copy).
+#if !defined(va_copy)
+#if defined(__GNUC__)
+#define va_copy(d, s) __va_copy(d, s)
+#else
+#define va_copy(d, s) ((d) = (s))
+#endif
+#endif
+
bool Logger::should_log(bool p_err) {
return (!p_err || _print_error_enabled) && (p_err || _print_line_enabled);
}
@@ -99,7 +111,7 @@ void RotatedFileLogger::close_file() {
void RotatedFileLogger::clear_old_backups() {
int max_backups = max_files - 1; // -1 for the current file
- String basename = base_path.get_basename();
+ String basename = base_path.get_file().get_basename();
String extension = "." + base_path.get_extension();
DirAccess *da = DirAccess::open(base_path.get_base_dir());
@@ -111,7 +123,7 @@ void RotatedFileLogger::clear_old_backups() {
String f = da->get_next();
Set<String> backups;
while (f != String()) {
- if (!da->current_is_dir() && f.begins_with(basename) && f.ends_with(extension) && f != base_path) {
+ if (!da->current_is_dir() && f.begins_with(basename) && f.ends_with(extension) && f != base_path.get_file()) {
backups.insert(f);
}
f = da->get_next();
@@ -138,7 +150,7 @@ void RotatedFileLogger::rotate_file() {
char timestamp[21];
OS::Date date = OS::get_singleton()->get_date();
OS::Time time = OS::get_singleton()->get_time();
- sprintf(timestamp, "-%04d-%02d-%02d-%02d-%02d-%02d", date.year, date.month, date.day + 1, time.hour, time.min, time.sec);
+ sprintf(timestamp, "-%04d-%02d-%02d-%02d-%02d-%02d", date.year, date.month, date.day, time.hour, time.min, time.sec);
String backup_name = base_path.get_basename() + timestamp + "." + base_path.get_extension();
@@ -248,6 +260,10 @@ void CompositeLogger::log_error(const char *p_function, const char *p_file, int
}
}
+void CompositeLogger::add_logger(Logger *p_logger) {
+ loggers.push_back(p_logger);
+}
+
CompositeLogger::~CompositeLogger() {
for (int i = 0; i < loggers.size(); ++i) {
memdelete(loggers[i]);
diff --git a/core/io/logger.h b/core/io/logger.h
index cf0cc7699f..f8a394193f 100644
--- a/core/io/logger.h
+++ b/core/io/logger.h
@@ -101,6 +101,8 @@ public:
virtual void logv(const char *p_format, va_list p_list, bool p_err);
virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR);
+ void add_logger(Logger *p_logger);
+
virtual ~CompositeLogger();
};
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 0834d6c321..1d9d2dd959 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -159,7 +159,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
r_variant = str;
} break;
- // math types
+ // math types
case Variant::VECTOR2: {
@@ -245,10 +245,10 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
(*r_len) += 4 * 4;
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
ERR_FAIL_COND_V(len < (int)4 * 6, ERR_INVALID_DATA);
- Rect3 val;
+ AABB val;
val.position.x = decode_float(&buf[0]);
val.position.y = decode_float(&buf[4]);
val.position.z = decode_float(&buf[8]);
@@ -967,7 +967,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
_encode_string(p_variant, buf, r_len);
} break;
- // math types
+ // math types
case Variant::VECTOR2: {
@@ -1045,10 +1045,10 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4 * 4;
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
if (buf) {
- Rect3 aabb = p_variant;
+ AABB aabb = p_variant;
encode_float(aabb.position.x, &buf[0]);
encode_float(aabb.position.y, &buf[4]);
encode_float(aabb.position.z, &buf[8]);
@@ -1140,8 +1140,9 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
if (buf) {
encode_uint32(0, buf);
buf += 4;
- r_len += 4;
}
+ r_len += 4;
+
} else {
_encode_string(obj->get_class(), buf, r_len);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 900db7c2dc..8dc396c362 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -52,7 +52,7 @@ enum {
VARIANT_VECTOR3 = 12,
VARIANT_PLANE = 13,
VARIANT_QUAT = 14,
- VARIANT_RECT3 = 15,
+ VARIANT_AABB = 15,
VARIANT_MATRIX3 = 16,
VARIANT_TRANSFORM = 17,
VARIANT_MATRIX32 = 18,
@@ -196,9 +196,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
r_v = v;
} break;
- case VARIANT_RECT3: {
+ case VARIANT_AABB: {
- Rect3 v;
+ AABB v;
v.position.x = f->get_real();
v.position.y = f->get_real();
v.position.z = f->get_real();
@@ -282,7 +282,6 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
property = _get_string();
NodePath np = NodePath(names, subnames, absolute, property);
- //print_line("got path: "+String(np));
r_v = np;
@@ -640,7 +639,6 @@ Error ResourceInteractiveLoaderBinary::poll() {
String path = external_resources[s].path;
- print_line("load external res: " + path);
if (remaps.has(path)) {
path = remaps[path];
}
@@ -706,8 +704,6 @@ Error ResourceInteractiveLoaderBinary::poll() {
String t = get_unicode_string();
- // print_line("loading resource of type "+t+" path is "+path);
-
Object *obj = ClassDB::instance(t);
if (!obj) {
error = ERR_FILE_CORRUPT;
@@ -907,20 +903,6 @@ void ResourceInteractiveLoaderBinary::open(FileAccess *p_f) {
external_resources.push_back(er);
}
- //see if the exporter has different set of external resources for more efficient loading
- /*
- String preload_depts = "deps/"+res_path.md5_text();
- if (Globals::get_singleton()->has(preload_depts)) {
- external_resources.clear();
- //ignore external resources and use these
- NodePath depts=Globals::get_singleton()->get(preload_depts);
- external_resources.resize(depts.get_name_count());
- for(int i=0;i<depts.get_name_count();i++) {
- external_resources[i].path=depts.get_name(i);
- }
- print_line(res_path+" - EXTERNAL RESOURCES: "+itos(external_resources.size()));
- }*/
-
print_bl("ext resources: " + itos(ext_resources_size));
uint32_t int_resources_size = f->get_32();
@@ -1392,10 +1374,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant &p_property,
f->store_real(val.w);
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
- f->store_32(VARIANT_RECT3);
- Rect3 val = p_property;
+ f->store_32(VARIANT_AABB);
+ AABB val = p_property;
f->store_real(val.position.x);
f->store_real(val.position.y);
f->store_real(val.position.z);
diff --git a/core/make_binders.py b/core/make_binders.py
index 6468c029f0..6f42c6e8eb 100644
--- a/core/make_binders.py
+++ b/core/make_binders.py
@@ -244,7 +244,7 @@ def make_version(template, nargs, argmax, const, ret):
def run(target, source, env):
- versions = 10
+ versions = 11
versions_ext = 6
text = ""
text_ext = ""
diff --git a/core/map.h b/core/map.h
index f01062ebed..fb24a5868c 100644
--- a/core/map.h
+++ b/core/map.h
@@ -438,7 +438,6 @@ private:
Element *rp = ((p_node->left == _data._nil) || (p_node->right == _data._nil)) ? p_node : p_node->_next;
Element *node = (rp->left == _data._nil) ? rp->right : rp->left;
- node->parent = rp->parent;
Element *sibling;
if (rp == rp->parent->left) {
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 4f80fb2491..7e26761abf 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -42,8 +42,10 @@ int AStar::get_available_point_id() const {
}
void AStar::add_point(int p_id, const Vector3 &p_pos, real_t p_weight_scale) {
+
ERR_FAIL_COND(p_id < 0);
ERR_FAIL_COND(p_weight_scale < 1);
+
if (!points.has(p_id)) {
Point *pt = memnew(Point);
pt->id = p_id;
@@ -64,12 +66,29 @@ Vector3 AStar::get_point_position(int p_id) const {
return points[p_id]->pos;
}
+
+void AStar::set_point_position(int p_id, const Vector3 &p_pos) {
+
+ ERR_FAIL_COND(!points.has(p_id));
+
+ points[p_id]->pos = p_pos;
+}
+
real_t AStar::get_point_weight_scale(int p_id) const {
ERR_FAIL_COND_V(!points.has(p_id), 0);
return points[p_id]->weight_scale;
}
+
+void AStar::set_point_weight_scale(int p_id, real_t p_weight_scale) {
+
+ ERR_FAIL_COND(!points.has(p_id));
+ ERR_FAIL_COND(p_weight_scale < 1);
+
+ points[p_id]->weight_scale = p_weight_scale;
+}
+
void AStar::remove_point(int p_id) {
ERR_FAIL_COND(!points.has(p_id));
@@ -130,6 +149,7 @@ bool AStar::has_point(int p_id) const {
}
Array AStar::get_points() {
+
Array point_list;
for (const Map<int, Point *>::Element *E = points.front(); E; E = E->next()) {
@@ -139,6 +159,21 @@ Array AStar::get_points() {
return point_list;
}
+PoolVector<int> AStar::get_point_connections(int p_id) {
+
+ ERR_FAIL_COND_V(!points.has(p_id), PoolVector<int>());
+
+ PoolVector<int> point_list;
+
+ Point *p = points[p_id];
+
+ for (int i = 0; i < p->neighbours.size(); i++) {
+ point_list.push_back(p->neighbours[i]->id);
+ }
+
+ return point_list;
+}
+
bool AStar::are_points_connected(int p_id, int p_with_id) const {
Segment s(p_id, p_with_id);
@@ -171,6 +206,7 @@ int AStar::get_closest_point(const Vector3 &p_point) const {
return closest_id;
}
+
Vector3 AStar::get_closest_position_in_segment(const Vector3 &p_point) const {
real_t closest_dist = 1e20;
@@ -222,15 +258,15 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
while (!found_route) {
if (open_list.first() == NULL) {
- //could not find path sadly
+ // No path found
break;
}
- //check open list
+ // Check open list
SelfList<Point> *least_cost_point = NULL;
real_t least_cost = 1e30;
- //this could be faster (cache previous results)
+ // TODO: Cache previous results
for (SelfList<Point> *E = open_list.first(); E; E = E->next()) {
Point *p = E->self();
@@ -246,7 +282,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
}
Point *p = least_cost_point->self();
- //open the neighbours for search
+ // Open the neighbours for search
int es = p->neighbours.size();
for (int i = 0; i < es; i++) {
@@ -256,7 +292,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
real_t distance = _compute_cost(p->id, e->id) * e->weight_scale + p->distance;
if (e->last_pass == pass) {
- //oh this was visited already, can we win the cost?
+ // Already visited, is this cheaper?
if (e->distance > distance) {
@@ -264,15 +300,15 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
e->distance = distance;
}
} else {
- //add to open neighbours
+ // Add to open neighbours
e->prev_point = p;
e->distance = distance;
- e->last_pass = pass; //mark as used
+ e->last_pass = pass; // Mark as used
open_list.add(&e->list);
if (e == end_point) {
- //oh my reached end! stop algorithm
+ // End reached; stop algorithm
found_route = true;
break;
}
@@ -285,7 +321,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
open_list.remove(least_cost_point);
}
- //clear the openf list
+ // Clear the openf list
while (open_list.first()) {
open_list.remove(open_list.first());
}
@@ -294,6 +330,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
}
float AStar::_estimate_cost(int p_from_id, int p_to_id) {
+
if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_estimate_cost))
return get_script_instance()->call(SceneStringNames::get_singleton()->_estimate_cost, p_from_id, p_to_id);
@@ -301,6 +338,7 @@ float AStar::_estimate_cost(int p_from_id, int p_to_id) {
}
float AStar::_compute_cost(int p_from_id, int p_to_id) {
+
if (get_script_instance() && get_script_instance()->has_method(SceneStringNames::get_singleton()->_compute_cost))
return get_script_instance()->call(SceneStringNames::get_singleton()->_compute_cost, p_from_id, p_to_id);
@@ -331,9 +369,9 @@ PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
if (!found_route)
return PoolVector<Vector3>();
- //midpoints
+ // Midpoints
Point *p = end_point;
- int pc = 1; //begin point
+ int pc = 1; // Begin point
while (p != begin_point) {
pc++;
p = p->prev_point;
@@ -352,7 +390,7 @@ PoolVector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
p = p->prev_point;
}
- w[0] = p->pos; //assign first
+ w[0] = p->pos; // Assign first
}
return path;
@@ -382,9 +420,9 @@ PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
if (!found_route)
return PoolVector<int>();
- //midpoints
+ // Midpoints
Point *p = end_point;
- int pc = 1; //begin point
+ int pc = 1; // Begin point
while (p != begin_point) {
pc++;
p = p->prev_point;
@@ -403,7 +441,7 @@ PoolVector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
p = p->prev_point;
}
- w[0] = p->id; //assign first
+ w[0] = p->id; // Assign first
}
return path;
@@ -414,11 +452,15 @@ void AStar::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_available_point_id"), &AStar::get_available_point_id);
ClassDB::bind_method(D_METHOD("add_point", "id", "position", "weight_scale"), &AStar::add_point, DEFVAL(1.0));
ClassDB::bind_method(D_METHOD("get_point_position", "id"), &AStar::get_point_position);
+ ClassDB::bind_method(D_METHOD("set_point_position", "id", "position"), &AStar::set_point_position);
ClassDB::bind_method(D_METHOD("get_point_weight_scale", "id"), &AStar::get_point_weight_scale);
+ ClassDB::bind_method(D_METHOD("set_point_weight_scale", "id", "weight_scale"), &AStar::set_point_weight_scale);
ClassDB::bind_method(D_METHOD("remove_point", "id"), &AStar::remove_point);
ClassDB::bind_method(D_METHOD("has_point", "id"), &AStar::has_point);
ClassDB::bind_method(D_METHOD("get_points"), &AStar::get_points);
+ ClassDB::bind_method(D_METHOD("get_point_connections"), &AStar::get_point_connections);
+
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);
@@ -443,4 +485,5 @@ AStar::AStar() {
AStar::~AStar() {
pass = 1;
+ clear();
}
diff --git a/core/math/a_star.h b/core/math/a_star.h
index 2c1e2e2cf7..b7b7e54125 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -33,6 +33,8 @@
#include "reference.h"
#include "self_list.h"
/**
+ A* pathfinding algorithm
+
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -53,7 +55,7 @@ class AStar : public Reference {
Vector<Point *> neighbours;
- //used for pathfinding
+ // Used for pathfinding
Point *prev_point;
real_t distance;
@@ -102,9 +104,12 @@ public:
void add_point(int p_id, const Vector3 &p_pos, real_t p_weight_scale = 1);
Vector3 get_point_position(int p_id) const;
+ void set_point_position(int p_id, const Vector3 &p_pos);
real_t get_point_weight_scale(int p_id) const;
+ void set_point_weight_scale(int p_id, real_t p_weight_scale);
void remove_point(int p_id);
bool has_point(int p_id) const;
+ PoolVector<int> get_point_connections(int p_id);
Array get_points();
void connect_points(int p_id, int p_with_id, bool bidirectional = true);
diff --git a/core/math/rect3.cpp b/core/math/aabb.cpp
index 6f01000f61..737a42b337 100644
--- a/core/math/rect3.cpp
+++ b/core/math/aabb.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* rect3.cpp */
+/* aabb.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,25 +27,25 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "rect3.h"
+#include "aabb.h"
#include "print_string.h"
-real_t Rect3::get_area() const {
+real_t AABB::get_area() const {
return size.x * size.y * size.z;
}
-bool Rect3::operator==(const Rect3 &p_rval) const {
+bool AABB::operator==(const AABB &p_rval) const {
return ((position == p_rval.position) && (size == p_rval.size));
}
-bool Rect3::operator!=(const Rect3 &p_rval) const {
+bool AABB::operator!=(const AABB &p_rval) const {
return ((position != p_rval.position) || (size != p_rval.size));
}
-void Rect3::merge_with(const Rect3 &p_aabb) {
+void AABB::merge_with(const AABB &p_aabb) {
Vector3 beg_1, beg_2;
Vector3 end_1, end_2;
@@ -68,7 +68,7 @@ void Rect3::merge_with(const Rect3 &p_aabb) {
size = max - min;
}
-Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
+AABB AABB::intersection(const AABB &p_aabb) const {
Vector3 src_min = position;
Vector3 src_max = position + size;
@@ -78,7 +78,7 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
Vector3 min, max;
if (src_min.x > dst_max.x || src_max.x < dst_min.x)
- return Rect3();
+ return AABB();
else {
min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x;
@@ -86,7 +86,7 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
}
if (src_min.y > dst_max.y || src_max.y < dst_min.y)
- return Rect3();
+ return AABB();
else {
min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y;
@@ -94,17 +94,17 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
}
if (src_min.z > dst_max.z || src_max.z < dst_min.z)
- return Rect3();
+ return AABB();
else {
min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z;
max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z;
}
- return Rect3(min, max - min);
+ return AABB(min, max - min);
}
-bool Rect3::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
+bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
Vector3 c1, c2;
Vector3 end = position + size;
@@ -147,7 +147,7 @@ bool Rect3::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3
return true;
}
-bool Rect3::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const {
+bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const {
real_t min = 0, max = 1;
int axis = 0;
@@ -205,7 +205,7 @@ bool Rect3::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vecto
return true;
}
-bool Rect3::intersects_plane(const Plane &p_plane) const {
+bool AABB::intersects_plane(const Plane &p_plane) const {
Vector3 points[8] = {
Vector3(position.x, position.y, position.z),
@@ -232,7 +232,7 @@ bool Rect3::intersects_plane(const Plane &p_plane) const {
return under && over;
}
-Vector3 Rect3::get_longest_axis() const {
+Vector3 AABB::get_longest_axis() const {
Vector3 axis(1, 0, 0);
real_t max_size = size.x;
@@ -249,7 +249,7 @@ Vector3 Rect3::get_longest_axis() const {
return axis;
}
-int Rect3::get_longest_axis_index() const {
+int AABB::get_longest_axis_index() const {
int axis = 0;
real_t max_size = size.x;
@@ -267,7 +267,7 @@ int Rect3::get_longest_axis_index() const {
return axis;
}
-Vector3 Rect3::get_shortest_axis() const {
+Vector3 AABB::get_shortest_axis() const {
Vector3 axis(1, 0, 0);
real_t max_size = size.x;
@@ -284,7 +284,7 @@ Vector3 Rect3::get_shortest_axis() const {
return axis;
}
-int Rect3::get_shortest_axis_index() const {
+int AABB::get_shortest_axis_index() const {
int axis = 0;
real_t max_size = size.x;
@@ -302,25 +302,25 @@ int Rect3::get_shortest_axis_index() const {
return axis;
}
-Rect3 Rect3::merge(const Rect3 &p_with) const {
+AABB AABB::merge(const AABB &p_with) const {
- Rect3 aabb = *this;
+ AABB aabb = *this;
aabb.merge_with(p_with);
return aabb;
}
-Rect3 Rect3::expand(const Vector3 &p_vector) const {
- Rect3 aabb = *this;
+AABB AABB::expand(const Vector3 &p_vector) const {
+ AABB aabb = *this;
aabb.expand_to(p_vector);
return aabb;
}
-Rect3 Rect3::grow(real_t p_by) const {
+AABB AABB::grow(real_t p_by) const {
- Rect3 aabb = *this;
+ AABB aabb = *this;
aabb.grow_by(p_by);
return aabb;
}
-void Rect3::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
+void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
ERR_FAIL_INDEX(p_edge, 12);
switch (p_edge) {
@@ -394,7 +394,7 @@ void Rect3::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
}
}
-Rect3::operator String() const {
+AABB::operator String() const {
return String() + position + " - " + size;
}
diff --git a/core/math/rect3.h b/core/math/aabb.h
index c3a2f5fbfb..c60213496a 100644
--- a/core/math/rect3.h
+++ b/core/math/aabb.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* rect3.h */
+/* aabb.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -39,7 +39,7 @@
* This is implemented by a point (position) and the box size
*/
-class Rect3 {
+class AABB {
public:
Vector3 position;
Vector3 size;
@@ -60,16 +60,16 @@ public:
const Vector3 &get_size() const { return size; }
void set_size(const Vector3 &p_size) { size = p_size; }
- bool operator==(const Rect3 &p_rval) const;
- bool operator!=(const Rect3 &p_rval) const;
+ bool operator==(const AABB &p_rval) const;
+ bool operator!=(const AABB &p_rval) const;
- _FORCE_INLINE_ bool intersects(const Rect3 &p_aabb) const; /// Both AABBs overlap
- _FORCE_INLINE_ bool intersects_inclusive(const Rect3 &p_aabb) const; /// Both AABBs (or their faces) overlap
- _FORCE_INLINE_ bool encloses(const Rect3 &p_aabb) const; /// p_aabb is completely inside this
+ _FORCE_INLINE_ bool intersects(const AABB &p_aabb) const; /// Both AABBs overlap
+ _FORCE_INLINE_ bool intersects_inclusive(const AABB &p_aabb) const; /// Both AABBs (or their faces) overlap
+ _FORCE_INLINE_ bool encloses(const AABB &p_aabb) const; /// p_aabb is completely inside this
- Rect3 merge(const Rect3 &p_with) const;
- void merge_with(const Rect3 &p_aabb); ///merge with another AABB
- Rect3 intersection(const Rect3 &p_aabb) const; ///get box where two intersect, empty if no intersection occurs
+ AABB merge(const AABB &p_with) const;
+ void merge_with(const AABB &p_aabb); ///merge with another AABB
+ AABB intersection(const AABB &p_aabb) const; ///get box where two intersect, empty if no intersection occurs
bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const;
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const;
_FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const;
@@ -88,26 +88,26 @@ public:
int get_shortest_axis_index() const;
_FORCE_INLINE_ real_t get_shortest_axis_size() const;
- Rect3 grow(real_t p_by) const;
+ AABB grow(real_t p_by) const;
_FORCE_INLINE_ void grow_by(real_t p_amount);
void get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const;
_FORCE_INLINE_ Vector3 get_endpoint(int p_point) const;
- Rect3 expand(const Vector3 &p_vector) const;
+ AABB expand(const Vector3 &p_vector) const;
_FORCE_INLINE_ void project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const;
_FORCE_INLINE_ void expand_to(const Vector3 &p_vector); /** expand to contain a point if necessary */
operator String() const;
- _FORCE_INLINE_ Rect3() {}
- inline Rect3(const Vector3 &p_pos, const Vector3 &p_size)
+ _FORCE_INLINE_ AABB() {}
+ inline AABB(const Vector3 &p_pos, const Vector3 &p_size)
: position(p_pos),
size(p_size) {
}
};
-inline bool Rect3::intersects(const Rect3 &p_aabb) const {
+inline bool AABB::intersects(const AABB &p_aabb) const {
if (position.x >= (p_aabb.position.x + p_aabb.size.x))
return false;
@@ -125,7 +125,7 @@ inline bool Rect3::intersects(const Rect3 &p_aabb) const {
return true;
}
-inline bool Rect3::intersects_inclusive(const Rect3 &p_aabb) const {
+inline bool AABB::intersects_inclusive(const AABB &p_aabb) const {
if (position.x > (p_aabb.position.x + p_aabb.size.x))
return false;
@@ -143,7 +143,7 @@ inline bool Rect3::intersects_inclusive(const Rect3 &p_aabb) const {
return true;
}
-inline bool Rect3::encloses(const Rect3 &p_aabb) const {
+inline bool AABB::encloses(const AABB &p_aabb) const {
Vector3 src_min = position;
Vector3 src_max = position + size;
@@ -159,7 +159,7 @@ inline bool Rect3::encloses(const Rect3 &p_aabb) const {
(src_max.z > dst_max.z));
}
-Vector3 Rect3::get_support(const Vector3 &p_normal) const {
+Vector3 AABB::get_support(const Vector3 &p_normal) const {
Vector3 half_extents = size * 0.5;
Vector3 ofs = position + half_extents;
@@ -171,7 +171,7 @@ Vector3 Rect3::get_support(const Vector3 &p_normal) const {
ofs;
}
-Vector3 Rect3::get_endpoint(int p_point) const {
+Vector3 AABB::get_endpoint(int p_point) const {
switch (p_point) {
case 0: return Vector3(position.x, position.y, position.z);
@@ -187,7 +187,7 @@ Vector3 Rect3::get_endpoint(int p_point) const {
ERR_FAIL_V(Vector3());
}
-bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const {
+bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const {
Vector3 half_extents = size * 0.5;
Vector3 ofs = position + half_extents;
@@ -206,7 +206,7 @@ bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) co
return true;
}
-bool Rect3::has_point(const Vector3 &p_point) const {
+bool AABB::has_point(const Vector3 &p_point) const {
if (p_point.x < position.x)
return false;
@@ -224,7 +224,7 @@ bool Rect3::has_point(const Vector3 &p_point) const {
return true;
}
-inline void Rect3::expand_to(const Vector3 &p_vector) {
+inline void AABB::expand_to(const Vector3 &p_vector) {
Vector3 begin = position;
Vector3 end = position + size;
@@ -247,7 +247,7 @@ inline void Rect3::expand_to(const Vector3 &p_vector) {
size = end - begin;
}
-void Rect3::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
+void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
Vector3 half_extents(size.x * 0.5, size.y * 0.5, size.z * 0.5);
Vector3 center(position.x + half_extents.x, position.y + half_extents.y, position.z + half_extents.z);
@@ -258,7 +258,7 @@ void Rect3::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &
r_max = distance + length;
}
-inline real_t Rect3::get_longest_axis_size() const {
+inline real_t AABB::get_longest_axis_size() const {
real_t max_size = size.x;
@@ -273,7 +273,7 @@ inline real_t Rect3::get_longest_axis_size() const {
return max_size;
}
-inline real_t Rect3::get_shortest_axis_size() const {
+inline real_t AABB::get_shortest_axis_size() const {
real_t max_size = size.x;
@@ -288,7 +288,7 @@ inline real_t Rect3::get_shortest_axis_size() const {
return max_size;
}
-bool Rect3::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
+bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
real_t divx = 1.0 / p_dir.x;
real_t divy = 1.0 / p_dir.y;
@@ -332,7 +332,7 @@ bool Rect3::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, rea
return ((tmin < t1) && (tmax > t0));
}
-void Rect3::grow_by(real_t p_amount) {
+void AABB::grow_by(real_t p_amount) {
position.x -= p_amount;
position.y -= p_amount;
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index be950568cf..bdc040160f 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -31,7 +31,7 @@
#include "error_macros.h"
#include "print_string.h"
-void BSP_Tree::from_aabb(const Rect3 &p_aabb) {
+void BSP_Tree::from_aabb(const AABB &p_aabb) {
planes.clear();
@@ -67,7 +67,7 @@ Vector<Plane> BSP_Tree::get_planes() const {
return planes;
}
-Rect3 BSP_Tree::get_aabb() const {
+AABB BSP_Tree::get_aabb() const {
return aabb;
}
@@ -577,7 +577,7 @@ BSP_Tree::BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius) {
error_radius = p_error_radius;
}
-BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius)
+BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius)
: nodes(p_nodes),
planes(p_planes),
aabb(p_aabb),
diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h
index 2e762ba4de..f64a13ce39 100644
--- a/core/math/bsp_tree.h
+++ b/core/math/bsp_tree.h
@@ -30,11 +30,11 @@
#ifndef BSP_TREE_H
#define BSP_TREE_H
+#include "aabb.h"
#include "dvector.h"
#include "face3.h"
#include "method_ptrcall.h"
#include "plane.h"
-#include "rect3.h"
#include "variant.h"
#include "vector.h"
/**
@@ -64,7 +64,7 @@ private:
Vector<Node> nodes;
Vector<Plane> planes;
- Rect3 aabb;
+ AABB aabb;
real_t error_radius;
int _get_points_inside(int p_node, const Vector3 *p_points, int *p_indices, const Vector3 &p_center, const Vector3 &p_half_extents, int p_indices_count) const;
@@ -76,7 +76,7 @@ public:
bool is_empty() const { return nodes.size() == 0; }
Vector<Node> get_nodes() const;
Vector<Plane> get_planes() const;
- Rect3 get_aabb() const;
+ AABB get_aabb() const;
bool point_is_inside(const Vector3 &p_point) const;
int get_points_inside(const Vector3 *p_points, int p_point_count) const;
@@ -85,12 +85,12 @@ public:
operator Variant() const;
- void from_aabb(const Rect3 &p_aabb);
+ void from_aabb(const AABB &p_aabb);
BSP_Tree();
BSP_Tree(const Variant &p_variant);
BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius = 0);
- BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius = 0);
+ BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius = 0);
~BSP_Tree();
};
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 2c587762e8..c5f1d57441 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -596,7 +596,7 @@ void CameraMatrix::make_scale(const Vector3 &p_scale) {
matrix[2][2] = p_scale.z;
}
-void CameraMatrix::scale_translate_to_fit(const Rect3 &p_aabb) {
+void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
Vector3 min = p_aabb.position;
Vector3 max = p_aabb.position + p_aabb.size;
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index 3145d73356..15d6b8128e 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -86,7 +86,7 @@ struct CameraMatrix {
operator String() const;
- void scale_translate_to_fit(const Rect3 &p_aabb);
+ void scale_translate_to_fit(const AABB &p_aabb);
void make_scale(const Vector3 &p_scale);
int get_pixels_per_meter(int p_for_pixel_width) const;
operator Transform() const;
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index e1b172e491..070ce77db4 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -189,13 +189,13 @@ ClockDirection Face3::get_clock_dir() const {
return (normal.dot(vertex[0]) >= 0) ? CLOCKWISE : COUNTERCLOCKWISE;
}
-bool Face3::intersects_aabb(const Rect3 &p_aabb) const {
+bool Face3::intersects_aabb(const AABB &p_aabb) const {
/** TEST PLANE **/
if (!p_aabb.intersects_plane(get_plane()))
return false;
-/** TEST FACE AXIS */
+ /** TEST FACE AXIS */
#define TEST_AXIS(m_ax) \
{ \
diff --git a/core/math/face3.h b/core/math/face3.h
index 8e4a25fb7a..561fa31238 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -30,8 +30,8 @@
#ifndef FACE3_H
#define FACE3_H
+#include "aabb.h"
#include "plane.h"
-#include "rect3.h"
#include "transform.h"
#include "vector3.h"
@@ -76,16 +76,16 @@ public:
void get_support(const Vector3 &p_normal, const Transform &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const;
void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
- Rect3 get_aabb() const {
+ AABB get_aabb() const {
- Rect3 aabb(vertex[0], Vector3());
+ AABB aabb(vertex[0], Vector3());
aabb.expand_to(vertex[1]);
aabb.expand_to(vertex[2]);
return aabb;
}
- bool intersects_aabb(const Rect3 &p_aabb) const;
- _FORCE_INLINE_ bool intersects_aabb2(const Rect3 &p_aabb) const;
+ bool intersects_aabb(const AABB &p_aabb) const;
+ _FORCE_INLINE_ bool intersects_aabb2(const AABB &p_aabb) const;
operator String() const;
inline Face3() {}
@@ -96,7 +96,7 @@ public:
}
};
-bool Face3::intersects_aabb2(const Rect3 &p_aabb) const {
+bool Face3::intersects_aabb2(const AABB &p_aabb) const {
Vector3 perp = (vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]);
@@ -256,6 +256,6 @@ bool Face3::intersects_aabb2(const Rect3 &p_aabb) const {
return true;
}
-//this sucks...
+ //this sucks...
#endif // FACE3_H
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 7c8fb6f17d..39bd34f03c 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -300,7 +300,7 @@ enum _CellFlags {
static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z, const Vector3 &voxelsize, const Face3 &p_face) {
- Rect3 aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z));
+ AABB aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z));
aabb.position = aabb.position * voxelsize;
aabb.size = aabb.size * voxelsize;
@@ -575,7 +575,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
PoolVector<Face3>::Read facesr = p_array.read();
const Face3 *faces = facesr.ptr();
- Rect3 global_aabb;
+ AABB global_aabb;
for (int i = 0; i < face_count; i++) {
diff --git a/core/math/math_funcs.cpp b/core/math/math_funcs.cpp
index 6fb688f16b..64e01e5841 100644
--- a/core/math/math_funcs.cpp
+++ b/core/math/math_funcs.cpp
@@ -176,3 +176,18 @@ float Math::random(float from, float to) {
float ret = (float)r / (float)RANDOM_MAX;
return (ret) * (to - from) + from;
}
+
+int Math::wrapi(int value, int min, int max) {
+ --max;
+ int rng = max - min + 1;
+ value = ((value - min) % rng);
+ if (value < 0)
+ return max + 1 + value;
+ else
+ return min + value;
+}
+
+float Math::wrapf(float value, float min, float max) {
+ float rng = max - min;
+ return min + (value - min) - (rng * floor((value - min) / rng));
+}
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index d63da322a5..bc0b3717ed 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -39,6 +39,7 @@
#include <math.h>
#define Math_PI 3.14159265358979323846
+#define Math_TAU 6.28318530717958647692
#define Math_SQRT12 0.7071067811865475244008443621048490
#define Math_LN2 0.693147180559945309417
#define Math_INF INFINITY
@@ -207,6 +208,9 @@ public:
static _ALWAYS_INLINE_ double round(double p_val) { return (p_val >= 0) ? Math::floor(p_val + 0.5) : -Math::floor(-p_val + 0.5); }
static _ALWAYS_INLINE_ float round(float p_val) { return (p_val >= 0) ? Math::floor(p_val + 0.5) : -Math::floor(-p_val + 0.5); }
+ static int wrapi(int value, int min, int max);
+ static float wrapf(float value, float min, float max);
+
// double only, as these functions are mainly used by the editor and not performance-critical,
static double ease(double p_x, double p_c);
static int step_decimals(double p_step);
@@ -387,6 +391,23 @@ public:
return hf;
}
+
+ static _ALWAYS_INLINE_ float snap_scalar(float p_offset, float p_step, float p_target) {
+ return p_step != 0 ? Math::stepify(p_target - p_offset, p_step) + p_offset : p_target;
+ }
+
+ static _ALWAYS_INLINE_ float snap_scalar_seperation(float p_offset, float p_step, float p_target, float p_separation) {
+ if (p_step != 0) {
+ float a = Math::stepify(p_target - p_offset, p_step + p_separation) + p_offset;
+ float b = a;
+ if (p_target >= 0)
+ b -= p_separation;
+ else
+ b += p_step;
+ return (Math::abs(p_target - a) < Math::abs(p_target - b)) ? a : b;
+ }
+ return p_target;
+ }
};
#endif // MATH_FUNCS_H
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index 4051de7afb..ab3bca79ae 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -279,7 +279,7 @@ Vector3 Basis::get_signed_scale() const {
// Decomposes a Basis into a rotation-reflection matrix (an element of the group O(3)) and a positive scaling matrix as B = O.S.
// Returns the rotation-reflection matrix via reference argument, and scaling information is returned as a Vector3.
-// This (internal) function is too specıfıc and named too ugly to expose to users, and probably there's no need to do so.
+// This (internal) function is too specific and named too ugly to expose to users, and probably there's no need to do so.
Vector3 Basis::rotref_posscale_decomposition(Basis &rotref) const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V(determinant() == 0, Vector3());
@@ -371,31 +371,30 @@ Vector3 Basis::get_euler_xyz() const {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V(is_rotation() == false, euler);
#endif
- euler.y = Math::asin(elements[0][2]);
- if (euler.y < Math_PI * 0.5) {
- if (euler.y > -Math_PI * 0.5) {
+ real_t sy = elements[0][2];
+ if (sy < 1.0) {
+ if (sy > -1.0) {
// is this a pure Y rotation?
if (elements[1][0] == 0.0 && elements[0][1] == 0.0 && elements[1][2] == 0 && elements[2][1] == 0 && elements[1][1] == 1) {
- // return the simplest form
+ // return the simplest form (human friendlier in editor and scripts)
euler.x = 0;
euler.y = atan2(elements[0][2], elements[0][0]);
euler.z = 0;
} else {
euler.x = Math::atan2(-elements[1][2], elements[2][2]);
+ euler.y = Math::asin(sy);
euler.z = Math::atan2(-elements[0][1], elements[0][0]);
}
-
} else {
- real_t r = Math::atan2(elements[1][0], elements[1][1]);
+ euler.x = -Math::atan2(elements[0][1], elements[1][1]);
+ euler.y = -Math_PI / 2.0;
euler.z = 0.0;
- euler.x = euler.z - r;
}
} else {
- real_t r = Math::atan2(elements[0][1], elements[1][1]);
- euler.z = 0;
- euler.x = r - euler.z;
+ euler.x = Math::atan2(elements[0][1], elements[1][1]);
+ euler.y = Math_PI / 2.0;
+ euler.z = 0.0;
}
-
return euler;
}
@@ -445,7 +444,7 @@ Vector3 Basis::get_euler_yxz() const {
if (m12 > -1) {
// is this a pure X rotation?
if (elements[1][0] == 0 && elements[0][1] == 0 && elements[0][2] == 0 && elements[2][0] == 0 && elements[0][0] == 1) {
- // return the simplest form
+ // return the simplest form (human friendlier in editor and scripts)
euler.x = atan2(-m12, elements[1][1]);
euler.y = 0;
euler.z = 0;
@@ -538,7 +537,7 @@ Basis::operator String() const {
return mtx;
}
-Basis::operator Quat() const {
+Quat Basis::get_quat() const {
//commenting this check because precision issues cause it to fail when it shouldn't
//#ifdef MATH_CHECKS
//ERR_FAIL_COND_V(is_rotation() == false, Quat());
@@ -710,12 +709,7 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
r_angle = angle;
}
-Basis::Basis(const Vector3 &p_euler) {
-
- set_euler(p_euler);
-}
-
-Basis::Basis(const Quat &p_quat) {
+void Basis::set_quat(const Quat &p_quat) {
real_t d = p_quat.length_squared();
real_t s = 2.0 / d;
@@ -750,7 +744,3 @@ void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) {
elements[2][1] = p_axis.y * p_axis.z * (1.0 - cosine) + p_axis.x * sine;
elements[2][2] = axis_sq.z + cosine * (1.0 - axis_sq.z);
}
-
-Basis::Basis(const Vector3 &p_axis, real_t p_phi) {
- set_axis_angle(p_axis, p_phi);
-}
diff --git a/core/math/matrix3.h b/core/math/matrix3.h
index 23429888e0..9a33b8203d 100644
--- a/core/math/matrix3.h
+++ b/core/math/matrix3.h
@@ -88,8 +88,11 @@ public:
Vector3 get_euler_yxz() const;
void set_euler_yxz(const Vector3 &p_euler);
- Vector3 get_euler() const { return get_euler_yxz(); };
- void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); };
+ Quat get_quat() const;
+ void set_quat(const Quat &p_quat);
+
+ Vector3 get_euler() const { return get_euler_yxz(); }
+ void set_euler(const Vector3 &p_euler) { set_euler_yxz(p_euler); }
void get_axis_angle(Vector3 &r_axis, real_t &r_angle) const;
void set_axis_angle(const Vector3 &p_axis, real_t p_phi);
@@ -205,11 +208,11 @@ public:
bool is_symmetric() const;
Basis diagonalize();
- operator Quat() const;
+ operator Quat() const { return get_quat(); }
- Basis(const Quat &p_quat); // euler
- Basis(const Vector3 &p_euler); // euler
- Basis(const Vector3 &p_axis, real_t p_phi);
+ Basis(const Quat &p_quat) { set_quat(p_quat); };
+ Basis(const Vector3 &p_euler) { set_euler(p_euler); }
+ Basis(const Vector3 &p_axis, real_t p_phi) { set_axis_angle(p_axis, p_phi); }
_FORCE_INLINE_ Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) {
elements[0] = row0;
diff --git a/core/math/octree.h b/core/math/octree.h
index 95a67943fd..6acd4c5f75 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -30,10 +30,10 @@
#ifndef OCTREE_H
#define OCTREE_H
+#include "aabb.h"
#include "list.h"
#include "map.h"
#include "print_string.h"
-#include "rect3.h"
#include "variant.h"
#include "vector3.h"
@@ -106,7 +106,7 @@ private:
struct Octant {
// cached for FAST plane check
- Rect3 aabb;
+ AABB aabb;
uint64_t last_pass;
Octant *parent;
@@ -152,8 +152,8 @@ private:
OctreeElementID _id;
Octant *common_parent;
- Rect3 aabb;
- Rect3 container_aabb;
+ AABB aabb;
+ AABB container_aabb;
List<PairData *, AL> pair_list;
@@ -334,7 +334,7 @@ private:
}
void _insert_element(Element *p_element, Octant *p_octant);
- void _ensure_valid_root(const Rect3 &p_aabb);
+ void _ensure_valid_root(const AABB &p_aabb);
bool _remove_element_from_octant(Element *p_element, Octant *p_octant, Octant *p_limit = NULL);
void _remove_element(Element *p_element);
void _pair_element(Element *p_element, Octant *p_octant);
@@ -351,7 +351,7 @@ private:
};
void _cull_convex(Octant *p_octant, _CullConvexData *p_cull);
- void _cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
+ void _cull_aabb(Octant *p_octant, const AABB &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
void _cull_segment(Octant *p_octant, const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
void _cull_point(Octant *p_octant, const Vector3 &p_point, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
@@ -370,8 +370,8 @@ private:
}
public:
- OctreeElementID create(T *p_userdata, const Rect3 &p_aabb = Rect3(), int p_subindex = 0, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1);
- void move(OctreeElementID p_id, const Rect3 &p_aabb);
+ OctreeElementID create(T *p_userdata, const AABB &p_aabb = AABB(), int p_subindex = 0, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1);
+ void move(OctreeElementID p_id, const AABB &p_aabb);
void set_pairable(OctreeElementID p_id, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1);
void erase(OctreeElementID p_id);
@@ -380,7 +380,7 @@ public:
int get_subindex(OctreeElementID p_id) const;
int cull_convex(const Vector<Plane> &p_convex, T **p_result_array, int p_result_max, uint32_t p_mask = 0xFFFFFFFF);
- int cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
+ int cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
int cull_segment(const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
int cull_point(const Vector3 &p_point, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
@@ -479,7 +479,7 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
} else {
/* check againt AABB where child should be */
- Rect3 aabb = p_octant->aabb;
+ AABB aabb = p_octant->aabb;
aabb.size *= 0.5;
if (i & 1)
@@ -535,12 +535,12 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
}
template <class T, bool use_pairs, class AL>
-void Octree<T, use_pairs, AL>::_ensure_valid_root(const Rect3 &p_aabb) {
+void Octree<T, use_pairs, AL>::_ensure_valid_root(const AABB &p_aabb) {
if (!root) {
// octre is empty
- Rect3 base(Vector3(), Vector3(1.0, 1.0, 1.0) * unit_size);
+ AABB base(Vector3(), Vector3(1.0, 1.0, 1.0) * unit_size);
while (!base.encloses(p_aabb)) {
@@ -563,7 +563,7 @@ void Octree<T, use_pairs, AL>::_ensure_valid_root(const Rect3 &p_aabb) {
} else {
- Rect3 base = root->aabb;
+ AABB base = root->aabb;
while (!base.encloses(p_aabb)) {
@@ -793,7 +793,7 @@ void Octree<T, use_pairs, AL>::_remove_element(Element *p_element) {
}
template <class T, bool use_pairs, class AL>
-OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const Rect3 &p_aabb, int p_subindex, bool p_pairable, uint32_t p_pairable_type, uint32_t p_pairable_mask) {
+OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const AABB &p_aabb, int p_subindex, bool p_pairable, uint32_t p_pairable_type, uint32_t p_pairable_mask) {
// check for AABB validity
#ifdef DEBUG_ENABLED
@@ -833,7 +833,7 @@ OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const Rect3 &p_a
}
template <class T, bool use_pairs, class AL>
-void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
+void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
#ifdef DEBUG_ENABLED
// check for AABB validity
@@ -859,7 +859,7 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
if (old_has_surf) {
_remove_element(&e); // removing
e.common_parent = NULL;
- e.aabb = Rect3();
+ e.aabb = AABB();
_optimize();
} else {
_ensure_valid_root(p_aabb); // inserting
@@ -886,7 +886,7 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
return;
}
- Rect3 combined = e.aabb;
+ AABB combined = e.aabb;
combined.merge_with(p_aabb);
_ensure_valid_root(combined);
@@ -1072,7 +1072,7 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
}
template <class T, bool use_pairs, class AL>
-void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
+void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const AABB &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
if (*p_result_idx == p_result_max)
return; //pointless
@@ -1313,7 +1313,7 @@ int Octree<T, use_pairs, AL>::cull_convex(const Vector<Plane> &p_convex, T **p_r
}
template <class T, bool use_pairs, class AL>
-int Octree<T, use_pairs, AL>::cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
+int Octree<T, use_pairs, AL>::cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
if (!root)
return 0;
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index e0137b6921..946d9f6b79 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -38,7 +38,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
/* CREATE AABB VOLUME */
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < p_points.size(); i++) {
if (i == 0) {
diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h
index 47ed22615b..f014d0decc 100644
--- a/core/math/quick_hull.h
+++ b/core/math/quick_hull.h
@@ -30,9 +30,9 @@
#ifndef QUICK_HULL_H
#define QUICK_HULL_H
+#include "aabb.h"
#include "geometry.h"
#include "list.h"
-#include "rect3.h"
#include "set.h"
class QuickHull {
diff --git a/core/math/transform.h b/core/math/transform.h
index 566bf482a9..4d91869121 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -30,9 +30,9 @@
#ifndef TRANSFORM_H
#define TRANSFORM_H
+#include "aabb.h"
#include "matrix3.h"
#include "plane.h"
-#include "rect3.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -80,8 +80,8 @@ public:
_FORCE_INLINE_ Plane xform(const Plane &p_plane) const;
_FORCE_INLINE_ Plane xform_inv(const Plane &p_plane) const;
- _FORCE_INLINE_ Rect3 xform(const Rect3 &p_aabb) const;
- _FORCE_INLINE_ Rect3 xform_inv(const Rect3 &p_aabb) const;
+ _FORCE_INLINE_ AABB xform(const AABB &p_aabb) const;
+ _FORCE_INLINE_ AABB xform_inv(const AABB &p_aabb) const;
void operator*=(const Transform &p_transform);
Transform operator*(const Transform &p_transform) const;
@@ -153,14 +153,14 @@ _FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const {
return Plane(normal, d);
}
-_FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const {
+_FORCE_INLINE_ AABB Transform::xform(const AABB &p_aabb) const {
/* define vertices */
Vector3 x = basis.get_axis(0) * p_aabb.size.x;
Vector3 y = basis.get_axis(1) * p_aabb.size.y;
Vector3 z = basis.get_axis(2) * p_aabb.size.z;
Vector3 pos = xform(p_aabb.position);
//could be even further optimized
- Rect3 new_aabb;
+ AABB new_aabb;
new_aabb.position = pos;
new_aabb.expand_to(pos + x);
new_aabb.expand_to(pos + y);
@@ -172,7 +172,7 @@ _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const {
return new_aabb;
}
-_FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const {
+_FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const {
/* define vertices */
Vector3 vertices[8] = {
@@ -186,7 +186,7 @@ _FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const {
Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z)
};
- Rect3 ret;
+ AABB ret;
ret.position = xform_inv(vertices[0]);
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 3b246cb183..5f57c7c26a 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -44,7 +44,7 @@ int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, in
return -1;
}
- Rect3 aabb;
+ AABB aabb;
aabb = p_bb[p_from]->aabb;
for (int i = 1; i < p_size; i++) {
@@ -166,7 +166,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
valid = true;
}
-Vector3 TriangleMesh::get_area_normal(const Rect3 &p_aabb) const {
+Vector3 TriangleMesh::get_area_normal(const AABB &p_aabb) const {
uint32_t *stack = (uint32_t *)alloca(sizeof(int) * max_depth);
diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h
index 2bf67fffcb..4bd9fecf37 100644
--- a/core/math/triangle_mesh.h
+++ b/core/math/triangle_mesh.h
@@ -47,7 +47,7 @@ class TriangleMesh : public Reference {
struct BVH {
- Rect3 aabb;
+ AABB aabb;
Vector3 center; //used for sorting
int left;
int right;
@@ -88,7 +88,7 @@ public:
bool is_valid() const;
bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const;
bool intersect_ray(const Vector3 &p_begin, const Vector3 &p_dir, Vector3 &r_point, Vector3 &r_normal) const;
- Vector3 get_area_normal(const Rect3 &p_aabb) const;
+ Vector3 get_area_normal(const AABB &p_aabb) const;
PoolVector<Face3> get_faces() const;
void create(const PoolVector<Vector3> &p_faces);
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
index 2875eb912f..d819dfbc27 100644
--- a/core/method_ptrcall.h
+++ b/core/method_ptrcall.h
@@ -119,7 +119,7 @@ MAKE_PTRARG_BY_REFERENCE(Vector3);
MAKE_PTRARG(Transform2D);
MAKE_PTRARG_BY_REFERENCE(Plane);
MAKE_PTRARG(Quat);
-MAKE_PTRARG_BY_REFERENCE(Rect3);
+MAKE_PTRARG_BY_REFERENCE(AABB);
MAKE_PTRARG_BY_REFERENCE(Basis);
MAKE_PTRARG_BY_REFERENCE(Transform);
MAKE_PTRARG_BY_REFERENCE(Color);
diff --git a/core/ordered_hash_map.h b/core/ordered_hash_map.h
index 9e95f963e1..1ed5a5d369 100644
--- a/core/ordered_hash_map.h
+++ b/core/ordered_hash_map.h
@@ -93,8 +93,12 @@ public:
return *this;
}
- friend bool operator==(const Element &, const Element &);
- friend bool operator!=(const Element &, const Element &);
+ _FORCE_INLINE_ bool operator==(const Element &p_other) const {
+ return this->list_element == p_other.list_element;
+ }
+ _FORCE_INLINE_ bool operator!=(const Element &p_other) const {
+ return this->list_element != p_other.list_element;
+ }
operator bool() const {
return (list_element != NULL);
@@ -157,8 +161,12 @@ public:
return ConstElement(list_element ? list_element->prev() : NULL);
}
- friend bool operator==(const ConstElement &, const ConstElement &);
- friend bool operator!=(const ConstElement &, const ConstElement &);
+ _FORCE_INLINE_ bool operator==(const ConstElement &p_other) const {
+ return this->list_element == p_other.list_element;
+ }
+ _FORCE_INLINE_ bool operator!=(const ConstElement &p_other) const {
+ return this->list_element != p_other.list_element;
+ }
operator bool() const {
return (list_element != NULL);
@@ -181,7 +189,7 @@ public:
};
ConstElement find(const K &p_key) const {
- typename InternalList::Element **list_element = map.getptr(p_key);
+ typename InternalList::Element *const *list_element = map.getptr(p_key);
if (list_element) {
return ConstElement(*list_element);
}
@@ -288,28 +296,4 @@ public:
}
};
-template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
-bool operator==(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &first,
- const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &second) {
- return (first.list_element == second.list_element);
-}
-
-template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
-bool operator!=(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &first,
- const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &second) {
- return (first.list_element != second.list_element);
-}
-
-template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
-bool operator==(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &first,
- const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &second) {
- return (first.list_element == second.list_element);
-}
-
-template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
-bool operator!=(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &first,
- const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &second) {
- return (first.list_element != second.list_element);
-}
-
#endif // ORDERED_HASH_MAP_H
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index 0875f78478..6d4b46f4da 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -38,7 +38,7 @@ String DirAccess::_get_root_path() const {
switch (_access_type) {
case ACCESS_RESOURCES: return ProjectSettings::get_singleton()->get_resource_path();
- case ACCESS_USERDATA: return OS::get_singleton()->get_data_dir();
+ case ACCESS_USERDATA: return OS::get_singleton()->get_user_data_dir();
default: return "";
}
@@ -98,6 +98,7 @@ static Error _erase_recursive(DirAccess *da) {
err = _erase_recursive(da);
if (err) {
print_line("err recurso " + E->get());
+ da->change_dir("..");
return err;
}
err = da->change_dir("..");
@@ -217,7 +218,7 @@ String DirAccess::fix_path(String p_path) const {
if (p_path.begins_with("user://")) {
- String data_dir = OS::get_singleton()->get_data_dir();
+ String data_dir = OS::get_singleton()->get_user_data_dir();
if (data_dir != "") {
return p_path.replace_first("user:/", data_dir);
@@ -340,6 +341,102 @@ Error DirAccess::copy(String p_from, String p_to, int chmod_flags) {
return err;
}
+// Changes dir for the current scope, returning back to the original dir
+// when scope exits
+class DirChanger {
+ DirAccess *da;
+ String original_dir;
+
+public:
+ DirChanger(DirAccess *p_da, String p_dir) {
+ da = p_da;
+ original_dir = p_da->get_current_dir();
+ p_da->change_dir(p_dir);
+ }
+
+ ~DirChanger() {
+ da->change_dir(original_dir);
+ }
+};
+
+Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags) {
+ List<String> dirs;
+
+ String curdir = get_current_dir();
+ list_dir_begin();
+ String n = get_next();
+ while (n != String()) {
+
+ if (n != "." && n != "..") {
+
+ if (current_is_dir())
+ dirs.push_back(n);
+ else {
+ String rel_path = n;
+ if (!n.is_rel_path()) {
+ list_dir_end();
+ return ERR_BUG;
+ }
+ Error err = copy(get_current_dir() + "/" + n, p_to + rel_path, p_chmod_flags);
+ if (err) {
+ list_dir_end();
+ return err;
+ }
+ }
+ }
+
+ n = get_next();
+ }
+
+ list_dir_end();
+
+ for (List<String>::Element *E = dirs.front(); E; E = E->next()) {
+ String rel_path = E->get();
+ String target_dir = p_to + rel_path;
+ if (!p_target_da->dir_exists(target_dir)) {
+ Error err = p_target_da->make_dir(target_dir);
+ ERR_FAIL_COND_V(err, err);
+ }
+
+ Error err = change_dir(E->get());
+ ERR_FAIL_COND_V(err, err);
+ err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags);
+ if (err) {
+ change_dir("..");
+ ERR_PRINT("Failed to copy recursively");
+ return err;
+ }
+ err = change_dir("..");
+ if (err) {
+ ERR_PRINT("Failed to go back");
+ return err;
+ }
+ }
+
+ return OK;
+}
+
+Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags) {
+ ERR_FAIL_COND_V(!dir_exists(p_from), ERR_FILE_NOT_FOUND);
+
+ DirAccess *target_da = DirAccess::create_for_path(p_to);
+ ERR_FAIL_COND_V(!target_da, ERR_CANT_CREATE);
+
+ if (!target_da->dir_exists(p_to)) {
+ Error err = target_da->make_dir_recursive(p_to);
+ if (err) {
+ memdelete(target_da);
+ }
+ ERR_FAIL_COND_V(err, err);
+ }
+
+ DirChanger dir_changer(this, p_from);
+ Error err = _copy_dir(target_da, p_to + "/", p_chmod_flags);
+ memdelete(target_da);
+
+ return err;
+}
+
bool DirAccess::exists(String p_dir) {
DirAccess *da = DirAccess::create_for_path(p_dir);
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index 7fa3ce5cf1..f3d1320041 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -52,6 +52,9 @@ public:
private:
AccessType _access_type;
static CreateFunc create_func[ACCESS_MAX]; ///< set this to instance a filesystem object
+
+ Error _copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags);
+
protected:
String _get_root_path() const;
String _get_root_string() const;
@@ -89,6 +92,7 @@ public:
static bool exists(String p_dir);
virtual size_t get_space_left() = 0;
+ Error copy_dir(String p_from, String p_to, int chmod_flags = -1);
virtual Error copy(String p_from, String p_to, int chmod_flags = -1);
virtual Error rename(String p_from, String p_to) = 0;
virtual Error remove(String p_name) = 0;
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index fcb3b58fed..5fdd2b9135 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -152,7 +152,7 @@ String FileAccess::fix_path(const String &p_path) const {
if (r_path.begins_with("user://")) {
- String data_dir = OS::get_singleton()->get_data_dir();
+ String data_dir = OS::get_singleton()->get_user_data_dir();
if (data_dir != "") {
return r_path.replace("user:/", data_dir);
diff --git a/core/os/input.cpp b/core/os/input.cpp
index a4b82299a7..848b003d5e 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -58,6 +58,7 @@ void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_action_just_released", "action"), &Input::is_action_just_released);
ClassDB::bind_method(D_METHOD("add_joy_mapping", "mapping", "update_existing"), &Input::add_joy_mapping, DEFVAL(false));
ClassDB::bind_method(D_METHOD("remove_joy_mapping", "guid"), &Input::remove_joy_mapping);
+ ClassDB::bind_method(D_METHOD("joy_connection_changed", "device", "connected", "name", "guid"), &Input::joy_connection_changed);
ClassDB::bind_method(D_METHOD("is_joy_known", "device"), &Input::is_joy_known);
ClassDB::bind_method(D_METHOD("get_joy_axis", "device", "axis"), &Input::get_joy_axis);
ClassDB::bind_method(D_METHOD("get_joy_name", "device"), &Input::get_joy_name);
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index b237a1113a..3cdd9ae0e0 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -177,6 +177,14 @@ bool InputEventWithModifiers::get_command() const {
return command;
}
+void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModifiers *event) {
+
+ set_alt(event->get_alt());
+ set_shift(event->get_shift());
+ set_control(event->get_control());
+ set_metakey(event->get_metakey());
+}
+
void InputEventWithModifiers::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_alt", "enable"), &InputEventWithModifiers::set_alt);
@@ -436,10 +444,7 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co
mb->set_id(get_id());
mb->set_device(get_device());
- mb->set_alt(get_alt());
- mb->set_shift(get_shift());
- mb->set_control(get_control());
- mb->set_metakey(get_metakey());
+ mb->set_modifiers_from_event(this);
mb->set_position(l);
mb->set_global_position(g);
@@ -555,10 +560,7 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co
mm->set_id(get_id());
mm->set_device(get_device());
- mm->set_alt(get_alt());
- mm->set_shift(get_shift());
- mm->set_control(get_control());
- mm->set_metakey(get_metakey());
+ mm->set_modifiers_from_event(this);
mm->set_position(l);
mm->set_global_position(g);
@@ -637,7 +639,7 @@ bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event) const
if (jm.is_null())
return false;
- return (axis == jm->axis && (axis_value < 0) == (jm->axis_value < 0));
+ return (axis == jm->axis && ((axis_value < 0) == (jm->axis_value < 0) || jm->axis_value == 0));
}
String InputEventJoypadMotion::as_text() const {
@@ -930,3 +932,75 @@ void InputEventAction::_bind_methods() {
InputEventAction::InputEventAction() {
pressed = false;
}
+/////////////////////////////
+
+void InputEventGesture::set_position(const Vector2 &p_pos) {
+
+ pos = p_pos;
+}
+
+Vector2 InputEventGesture::get_position() const {
+
+ return pos;
+}
+/////////////////////////////
+
+void InputEventMagnifyGesture::set_factor(real_t p_factor) {
+
+ factor = p_factor;
+}
+
+real_t InputEventMagnifyGesture::get_factor() const {
+
+ return factor;
+}
+
+Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
+
+ Ref<InputEventMagnifyGesture> ev;
+ ev.instance();
+
+ ev->set_id(get_id());
+ ev->set_device(get_device());
+ ev->set_modifiers_from_event(this);
+
+ ev->set_position(p_xform.xform(get_position() + p_local_ofs));
+ ev->set_factor(get_factor());
+
+ return ev;
+}
+
+InputEventMagnifyGesture::InputEventMagnifyGesture() {
+
+ factor = 1.0;
+}
+/////////////////////////////
+
+void InputEventPanGesture::set_delta(const Vector2 &p_delta) {
+
+ delta = p_delta;
+}
+
+Vector2 InputEventPanGesture::get_delta() const {
+ return delta;
+}
+
+Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
+
+ Ref<InputEventPanGesture> ev;
+ ev.instance();
+
+ ev->set_id(get_id());
+ ev->set_device(get_device());
+ ev->set_modifiers_from_event(this);
+
+ ev->set_position(p_xform.xform(get_position() + p_local_ofs));
+ ev->set_delta(get_delta());
+
+ return ev;
+}
+
+InputEventPanGesture::InputEventPanGesture() {
+
+ delta = Vector2(0, 0);
+}
diff --git a/core/os/input_event.h b/core/os/input_event.h
index 5dc0f91d5f..2cba60bede 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -44,7 +44,7 @@
* The events are pretty obvious.
*/
-enum {
+enum ButtonList {
BUTTON_LEFT = 1,
BUTTON_RIGHT = 2,
BUTTON_MIDDLE = 3,
@@ -58,7 +58,7 @@ enum {
};
-enum {
+enum JoystickList {
JOY_BUTTON_0 = 0,
JOY_BUTTON_1 = 1,
@@ -122,7 +122,9 @@ enum {
JOY_AXIS_5 = 5,
JOY_AXIS_6 = 6,
JOY_AXIS_7 = 7,
- JOY_AXIS_MAX = 8,
+ JOY_AXIS_8 = 8,
+ JOY_AXIS_9 = 9,
+ JOY_AXIS_MAX = 10,
JOY_ANALOG_LX = JOY_AXIS_0,
JOY_ANALOG_LY = JOY_AXIS_1,
@@ -211,6 +213,8 @@ public:
void set_command(bool p_enabled);
bool get_command() const;
+ void set_modifiers_from_event(const InputEventWithModifiers *event);
+
InputEventWithModifiers();
};
@@ -466,4 +470,42 @@ public:
InputEventAction();
};
+class InputEventGesture : public InputEventWithModifiers {
+
+ GDCLASS(InputEventGesture, InputEventWithModifiers)
+
+ Vector2 pos;
+
+public:
+ void set_position(const Vector2 &p_pos);
+ Vector2 get_position() const;
+};
+
+class InputEventMagnifyGesture : public InputEventGesture {
+
+ GDCLASS(InputEventMagnifyGesture, InputEventGesture)
+ real_t factor;
+
+public:
+ void set_factor(real_t p_factor);
+ real_t get_factor() const;
+
+ virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
+
+ InputEventMagnifyGesture();
+};
+
+class InputEventPanGesture : public InputEventGesture {
+
+ GDCLASS(InputEventPanGesture, InputEventGesture)
+ Vector2 delta;
+
+public:
+ void set_delta(const Vector2 &p_delta);
+ Vector2 get_delta() const;
+
+ virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
+
+ InputEventPanGesture();
+};
#endif
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp
index be1341054b..dead3b6ac0 100644
--- a/core/os/keyboard.cpp
+++ b/core/os/keyboard.cpp
@@ -532,6 +532,27 @@ static const _KeyCodeReplace _keycode_replace_neo[] = {
{ 0, 0 }
};
+static const _KeyCodeReplace _keycode_replace_colemak[] = {
+ { KEY_E, KEY_F },
+ { KEY_R, KEY_P },
+ { KEY_T, KEY_G },
+ { KEY_Y, KEY_J },
+ { KEY_U, KEY_L },
+ { KEY_I, KEY_U },
+ { KEY_O, KEY_Y },
+ { KEY_P, KEY_SEMICOLON },
+ { KEY_S, KEY_R },
+ { KEY_D, KEY_S },
+ { KEY_F, KEY_T },
+ { KEY_G, KEY_D },
+ { KEY_J, KEY_N },
+ { KEY_K, KEY_E },
+ { KEY_L, KEY_I },
+ { KEY_SEMICOLON, KEY_O },
+ { KEY_N, KEY_K },
+ { 0, 0 }
+};
+
int keycode_get_count() {
const _KeyCodeText *kct = &_keycodes[0];
@@ -564,6 +585,7 @@ int latin_keyboard_keycode_convert(int p_keycode) {
case OS::LATIN_KEYBOARD_QZERTY: kcr = _keycode_replace_qzerty; break;
case OS::LATIN_KEYBOARD_DVORAK: kcr = _keycode_replace_dvorak; break;
case OS::LATIN_KEYBOARD_NEO: kcr = _keycode_replace_neo; break;
+ case OS::LATIN_KEYBOARD_COLEMAK: kcr = _keycode_replace_colemak; break;
default: return p_keycode;
}
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index b146d370f1..8b4449586b 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -52,6 +52,7 @@ void MainLoop::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_WM_FOCUS_IN);
BIND_CONSTANT(NOTIFICATION_WM_FOCUS_OUT);
BIND_CONSTANT(NOTIFICATION_WM_QUIT_REQUEST);
+ BIND_CONSTANT(NOTIFICATION_WM_GO_BACK_REQUEST);
BIND_CONSTANT(NOTIFICATION_WM_UNFOCUS_REQUEST);
BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING);
BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED);
diff --git a/core/os/memory.cpp b/core/os/memory.cpp
index 74d5cbbea1..439951f711 100644
--- a/core/os/memory.cpp
+++ b/core/os/memory.cpp
@@ -44,6 +44,26 @@ void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)) {
return p_allocfunc(p_size);
}
+#ifdef _MSC_VER
+void operator delete(void *p_mem, const char *p_description) {
+
+ ERR_EXPLAINC("Call to placement delete should not happen.");
+ CRASH_NOW();
+}
+
+void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size)) {
+
+ ERR_EXPLAINC("Call to placement delete should not happen.");
+ CRASH_NOW();
+}
+
+void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description) {
+
+ ERR_EXPLAINC("Call to placement delete should not happen.");
+ CRASH_NOW();
+}
+#endif
+
#ifdef DEBUG_ENABLED
uint64_t Memory::mem_usage = 0;
uint64_t Memory::max_usage = 0;
diff --git a/core/os/memory.h b/core/os/memory.h
index f8b3da579b..7801d56837 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -72,6 +72,14 @@ void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)); ///< ope
void *operator new(size_t p_size, void *p_pointer, size_t check, const char *p_description); ///< operator new that takes a description and uses a pointer to the preallocated memory
+#ifdef _MSC_VER
+// When compiling with VC++ 2017, the above declarations of placement new generate many irrelevant warnings (C4291).
+// The purpose of the following definitions is to muffle these warnings, not to provide a usable implementation of placement delete.
+void operator delete(void *p_mem, const char *p_description);
+void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size));
+void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description);
+#endif
+
#define memalloc(m_size) Memory::alloc_static(m_size)
#define memrealloc(m_mem, m_size) Memory::realloc_static(m_mem, m_size)
#define memfree(m_size) Memory::free_static(m_size)
diff --git a/core/os/os.cpp b/core/os/os.cpp
index eb5d5be33d..0e7e26df73 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -33,6 +33,7 @@
#include "input.h"
#include "os/file_access.h"
#include "project_settings.h"
+#include "version_generated.gen.h"
#include <stdarg.h>
@@ -62,15 +63,21 @@ void OS::debug_break(){
// something
};
-void OS::_set_logger(Logger *p_logger) {
+void OS::_set_logger(CompositeLogger *p_logger) {
if (_logger) {
memdelete(_logger);
}
_logger = p_logger;
}
-void OS::initialize_logger() {
- _set_logger(memnew(StdLogger));
+void OS::add_logger(Logger *p_logger) {
+ if (!_logger) {
+ Vector<Logger *> loggers;
+ loggers.push_back(p_logger);
+ _logger = memnew(CompositeLogger(loggers));
+ } else {
+ _logger->add_logger(p_logger);
+ }
}
void OS::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, Logger::ErrorType p_type) {
@@ -262,16 +269,7 @@ String OS::get_locale() const {
return "en";
}
-String OS::get_resource_dir() const {
-
- return ProjectSettings::get_singleton()->get_resource_path();
-}
-
-String OS::get_system_dir(SystemDir p_dir) const {
-
- return ".";
-}
-
+// Helper function used by OS_Unix and OS_Windows
String OS::get_safe_application_name() const {
String an = ProjectSettings::get_singleton()->get("application/config/name");
Vector<String> invalid_char = String("\\ / : * ? \" < > |").split(" ");
@@ -281,11 +279,51 @@ String OS::get_safe_application_name() const {
return an;
}
-String OS::get_data_dir() const {
+// Path to data, config, cache, etc. OS-specific folders
+
+// Get properly capitalized engine name for system paths
+String OS::get_godot_dir_name() const {
+
+ // Default to lowercase, so only override when different case is needed
+ return String(VERSION_SHORT_NAME).to_lower();
+}
+
+// OS equivalent of XDG_DATA_HOME
+String OS::get_data_path() const {
+
+ return ".";
+}
+
+// OS equivalent of XDG_CONFIG_HOME
+String OS::get_config_path() const {
+
+ return ".";
+}
+
+// OS equivalent of XDG_CACHE_HOME
+String OS::get_cache_path() const {
+
+ return ".";
+}
+
+// OS specific path for user://
+String OS::get_user_data_dir() const {
return ".";
};
+// Absolute path to res://
+String OS::get_resource_dir() const {
+
+ return ProjectSettings::get_singleton()->get_resource_path();
+}
+
+// Access system-specific dirs like Documents, Downloads, etc.
+String OS::get_system_dir(SystemDir p_dir) const {
+
+ return ".";
+}
+
Error OS::shell_open(String p_uri) {
return ERR_UNAVAILABLE;
};
@@ -374,9 +412,9 @@ OS::ScreenOrientation OS::get_screen_orientation() const {
return (OS::ScreenOrientation)_orientation;
}
-void OS::_ensure_data_dir() {
+void OS::_ensure_user_data_dir() {
- String dd = get_data_dir();
+ String dd = get_user_data_dir();
DirAccess *da = DirAccess::open(dd);
if (da) {
memdelete(da);
@@ -516,6 +554,33 @@ bool OS::has_feature(const String &p_feature) {
if (sizeof(void *) == 4 && p_feature == "32") {
return true;
}
+#if defined(__x86_64) || defined(__x86_64__)
+ if (p_feature == "x86_64") {
+ return true;
+ }
+#elif (defined(__i386) || defined(__i386__))
+ if (p_feature == "x86") {
+ return true;
+ }
+#elif defined(__aarch64__)
+ if (p_feature == "arm64") {
+ return true;
+ }
+#elif defined(__arm__)
+#if defined(__ARM_ARCH_7A__)
+ if (p_feature == "armv7a" || p_feature == "armv7") {
+ return true;
+ }
+#endif
+#if defined(__ARM_ARCH_7S__)
+ if (p_feature == "armv7s" || p_feature == "armv7") {
+ return true;
+ }
+#endif
+ if (p_feature == "arm") {
+ return true;
+ }
+#endif
if (_check_internal_feature_support(p_feature))
return true;
@@ -545,7 +610,10 @@ OS::OS() {
_stack_bottom = (void *)(&stack_bottom);
_logger = NULL;
- _set_logger(memnew(StdLogger));
+
+ Vector<Logger *> loggers;
+ loggers.push_back(memnew(StdLogger));
+ _set_logger(memnew(CompositeLogger(loggers)));
}
OS::~OS() {
diff --git a/core/os/os.h b/core/os/os.h
index 6fcfd71332..fe4ffb2922 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -62,10 +62,10 @@ class OS {
void *_stack_bottom;
- Logger *_logger;
+ CompositeLogger *_logger;
protected:
- void _set_logger(Logger *p_logger);
+ void _set_logger(CompositeLogger *p_logger);
public:
typedef void (*ImeCallback)(void *p_inp, String p_text, Point2 p_selection);
@@ -90,13 +90,15 @@ public:
bool fullscreen;
bool resizable;
bool borderless_window;
+ bool maximized;
float get_aspect() const { return (float)width / (float)height; }
- VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false) {
+ VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false) {
width = p_width;
height = p_height;
fullscreen = p_fullscreen;
resizable = p_resizable;
borderless_window = p_borderless_window;
+ maximized = p_maximized;
}
};
@@ -109,12 +111,11 @@ protected:
virtual int get_video_driver_count() const = 0;
virtual const char *get_video_driver_name(int p_driver) const = 0;
- virtual VideoMode get_default_video_mode() const = 0;
-
virtual int get_audio_driver_count() const = 0;
virtual const char *get_audio_driver_name(int p_driver) const = 0;
- virtual void initialize_logger();
+ void add_logger(Logger *p_logger);
+
virtual void initialize_core() = 0;
virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) = 0;
@@ -126,7 +127,7 @@ protected:
virtual void set_cmdline(const char *p_execpath, const List<String> &p_args);
- void _ensure_data_dir();
+ void _ensure_user_data_dir();
virtual bool _check_internal_feature_support(const String &p_feature) = 0;
public:
@@ -202,9 +203,8 @@ public:
virtual void set_low_processor_usage_mode(bool p_enabled);
virtual bool is_in_low_processor_usage_mode() const;
- virtual String get_installed_templates_path() const { return ""; }
virtual String get_executable_path() const;
- virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL) = 0;
+ virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0;
virtual Error kill(const ProcessID &p_pid) = 0;
virtual int get_process_id() const;
@@ -336,10 +336,14 @@ public:
virtual String get_locale() const;
String get_safe_application_name() const;
- virtual String get_data_dir() const;
- virtual String get_resource_dir() const;
+ virtual String get_godot_dir_name() const;
- virtual Error move_to_trash(const String &p_path) { return FAILED; }
+ virtual String get_data_path() const;
+ virtual String get_config_path() const;
+ virtual String get_cache_path() const;
+
+ virtual String get_user_data_dir() const;
+ virtual String get_resource_dir() const;
enum SystemDir {
SYSTEM_DIR_DESKTOP,
@@ -354,6 +358,8 @@ public:
virtual String get_system_dir(SystemDir p_dir) const;
+ virtual Error move_to_trash(const String &p_path) { return FAILED; }
+
virtual void set_no_window_mode(bool p_enable);
virtual bool is_no_window_mode_enabled() const;
@@ -409,6 +415,7 @@ public:
LATIN_KEYBOARD_QZERTY,
LATIN_KEYBOARD_DVORAK,
LATIN_KEYBOARD_NEO,
+ LATIN_KEYBOARD_COLEMAK,
};
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index ad8438e416..3748df12f7 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -234,7 +234,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
case Variant::TRANSFORM2D:
case Variant::PLANE:
case Variant::QUAT:
- case Variant::RECT3:
+ case Variant::AABB:
case Variant::BASIS:
case Variant::TRANSFORM:
case Variant::POOL_BYTE_ARRAY:
diff --git a/core/print_string.cpp b/core/print_string.cpp
index 92a04cbf0b..520fb3daec 100644
--- a/core/print_string.cpp
+++ b/core/print_string.cpp
@@ -82,7 +82,25 @@ void print_line(String p_string) {
PrintHandlerList *l = print_handler_list;
while (l) {
- l->printfunc(l->userdata, p_string);
+ l->printfunc(l->userdata, p_string, false);
+ l = l->next;
+ }
+
+ _global_unlock();
+}
+
+void print_error(String p_string) {
+
+ if (!_print_error_enabled)
+ return;
+
+ OS::get_singleton()->printerr("%s\n", p_string.utf8().get_data());
+
+ _global_lock();
+ PrintHandlerList *l = print_handler_list;
+ while (l) {
+
+ l->printfunc(l->userdata, p_string, true);
l = l->next;
}
diff --git a/core/print_string.h b/core/print_string.h
index 9f8420c31a..6b68380b9d 100644
--- a/core/print_string.h
+++ b/core/print_string.h
@@ -34,7 +34,7 @@
extern void (*_print_func)(String);
-typedef void (*PrintHandlerFunc)(void *, const String &p_string);
+typedef void (*PrintHandlerFunc)(void *, const String &p_string, bool p_error);
struct PrintHandlerList {
@@ -56,5 +56,6 @@ void remove_print_handler(PrintHandlerList *p_handler);
extern bool _print_line_enabled;
extern bool _print_error_enabled;
extern void print_line(String p_string);
+extern void print_error(String p_string);
#endif
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index ff2be87b07..361464ee1f 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -116,7 +116,7 @@ String ProjectSettings::globalize_path(const String &p_path) const {
return p_path.replace("res://", "");
} else if (p_path.begins_with("user://")) {
- String data_dir = OS::get_singleton()->get_data_dir();
+ String data_dir = OS::get_singleton()->get_user_data_dir();
if (data_dir != "") {
return p_path.replace("user:/", data_dir);
@@ -261,7 +261,7 @@ bool ProjectSettings::_load_resource_pack(const String &p_pack) {
return true;
}
-Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) {
+Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bool p_upwards) {
//If looking for files in network, just use network!
@@ -270,11 +270,6 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) {
if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
_load_settings("res://override.cfg");
-#ifdef DEBUG_ENABLED
- } else {
- // when debug version of godot is used, provide some feedback to the developer
- print_line("Couldn't open project over network");
-#endif
}
return OK;
@@ -292,12 +287,6 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) {
if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
//load override from location of the main pack
_load_settings(p_main_pack.get_base_dir().plus_file("override.cfg"));
-#ifdef DEBUG_ENABLED
- // when debug version of godot is used, provide some feedback to the developer
- print_line("Successfully loaded " + p_main_pack + "/project.godot or project.binary");
- } else {
- print_line("Couldn't load/find " + p_main_pack + "/project.godot or project.binary");
-#endif
}
return OK;
@@ -315,18 +304,9 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) {
if (_load_resource_pack(datapack_name)) {
found = true;
} else {
-#ifdef DEBUG_ENABLED
- // when debug version of godot is used, provide some feedback to the developer
- print_line("Couldn't open " + datapack_name);
-#endif
datapack_name = filebase_name + ".pck";
if (_load_resource_pack(datapack_name)) {
found = true;
-#ifdef DEBUG_ENABLED
- } else {
- // when debug version of godot is used, provide some feedback to the developer
- print_line("Couldn't open " + datapack_name);
-#endif
}
}
@@ -335,13 +315,6 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) {
if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
// load override from location of executable
_load_settings(exec_path.get_base_dir().plus_file("override.cfg"));
-
-#ifdef DEBUG_ENABLED
- // when debug version of godot is used, provide some feedback to the developer
- print_line("Successfully loaded " + datapack_name + "/project.godot or project.binary");
- } else {
- print_line("Couldn't load/find " + datapack_name + "/project.godot or project.binary");
-#endif
}
return OK;
@@ -362,12 +335,6 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) {
if (_load_settings("res://project.godot") == OK || _load_settings_binary("res://project.binary") == OK) {
_load_settings("res://override.cfg");
-#ifdef DEBUG_ENABLED
- // when debug version of godot is used, provide some feedback to the developer
- print_line("Successfully loaded " + resource_path + "/project.godot or project.binary");
- } else {
- print_line("Couldn't load/find " + resource_path + "/project.godot or project.binary");
-#endif
}
return OK;
@@ -393,18 +360,16 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) {
candidate = current_dir;
found = true;
break;
-#ifdef DEBUG_ENABLED
- // when debug version of godot is used, provide some feedback to the developer
- print_line("Successfully loaded " + current_dir + "/project.godot or project.binary");
- } else {
- print_line("Couldn't load/find " + current_dir + "/project.godot or project.binary");
-#endif
}
- d->change_dir("..");
- if (d->get_current_dir() == current_dir)
- break; //not doing anything useful
- current_dir = d->get_current_dir();
+ if (p_upwards) {
+ d->change_dir("..");
+ if (d->get_current_dir() == current_dir)
+ break; //not doing anything useful
+ current_dir = d->get_current_dir();
+ } else {
+ break;
+ }
}
resource_path = candidate;
@@ -667,8 +632,8 @@ Error ProjectSettings::_save_settings_text(const String &p_file, const Map<Strin
file->store_line("; Engine configuration file.");
file->store_line("; It's best edited using the editor UI and not directly,");
file->store_line("; since the parameters that go here are not all obvious.");
- file->store_line("; ");
- file->store_line("; Format: ");
+ file->store_line(";");
+ file->store_line("; Format:");
file->store_line("; [section] ; section goes between []");
file->store_line("; param=value ; assign values to parameters");
file->store_line("");
@@ -811,32 +776,6 @@ Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) {
return ret;
}
-void ProjectSettings::add_singleton(const Singleton &p_singleton) {
-
- singletons.push_back(p_singleton);
- singleton_ptrs[p_singleton.name] = p_singleton.ptr;
-}
-
-Object *ProjectSettings::get_singleton_object(const String &p_name) const {
-
- const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
- if (!E)
- return NULL;
- else
- return E->get();
-};
-
-bool ProjectSettings::has_singleton(const String &p_name) const {
-
- return get_singleton_object(p_name) != NULL;
-};
-
-void ProjectSettings::get_singletons(List<Singleton> *p_singletons) {
-
- for (List<Singleton>::Element *E = singletons.front(); E; E = E->next())
- p_singletons->push_back(E->get());
-}
-
Vector<String> ProjectSettings::get_optimizer_presets() const {
List<PropertyInfo> pi;
@@ -928,8 +867,6 @@ void ProjectSettings::_bind_methods() {
ClassDB::bind_method(D_METHOD("localize_path", "path"), &ProjectSettings::localize_path);
ClassDB::bind_method(D_METHOD("globalize_path", "path"), &ProjectSettings::globalize_path);
ClassDB::bind_method(D_METHOD("save"), &ProjectSettings::save);
- ClassDB::bind_method(D_METHOD("has_singleton", "name"), &ProjectSettings::has_singleton);
- ClassDB::bind_method(D_METHOD("get_singleton", "name"), &ProjectSettings::get_singleton_object);
ClassDB::bind_method(D_METHOD("load_resource_pack", "pack"), &ProjectSettings::_load_resource_pack);
ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ProjectSettings::property_can_revert);
ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ProjectSettings::property_get_revert);
@@ -1071,10 +1008,16 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF("debug/settings/profiler/max_functions", 16384);
//assigning here, because using GLOBAL_GET on every block for compressing can be slow
+ Compression::zstd_long_distance_matching = GLOBAL_DEF("compression/formats/zstd/long_distance_matching", false);
+ custom_prop_info["compression/formats/zstd/long_distance_matching"] = PropertyInfo(Variant::BOOL, "compression/formats/zstd/long_distance_matching");
Compression::zstd_level = GLOBAL_DEF("compression/formats/zstd/compression_level", 3);
custom_prop_info["compression/formats/zstd/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1");
+ Compression::zstd_window_log_size = GLOBAL_DEF("compression/formats/zstd/window_log_size", 27);
+ custom_prop_info["compression/formats/zstd/window_log_size"] = PropertyInfo(Variant::INT, "compression/formats/zstd/window_log_size", PROPERTY_HINT_RANGE, "10,30,1");
+
Compression::zlib_level = GLOBAL_DEF("compression/formats/zlib/compression_level", Z_DEFAULT_COMPRESSION);
custom_prop_info["compression/formats/zlib/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/zlib/compression_level", PROPERTY_HINT_RANGE, "-1,9,1");
+
Compression::gzip_level = GLOBAL_DEF("compression/formats/gzip/compression_level", Z_DEFAULT_COMPRESSION);
custom_prop_info["compression/formats/gzip/compression_level"] = PropertyInfo(Variant::INT, "compression/formats/gzip/compression_level", PROPERTY_HINT_RANGE, "-1,9,1");
diff --git a/core/project_settings.h b/core/project_settings.h
index ea6034dc84..1c4078cebb 100644
--- a/core/project_settings.h
+++ b/core/project_settings.h
@@ -45,14 +45,6 @@ class ProjectSettings : public Object {
public:
typedef Map<String, Variant> CustomMap;
- struct Singleton {
- StringName name;
- Object *ptr;
- Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL)
- : name(p_name),
- ptr(p_ptr) {
- }
- };
enum {
//properties that are not for built in values begin from this value, so builtin ones are displayed first
NO_BUILTIN_ORDER_BASE = 1 << 16
@@ -106,9 +98,6 @@ protected:
Error _save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
Error _save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String());
- List<Singleton> singletons;
- Map<StringName, Object *> singleton_ptrs;
-
Error _save_custom_bnd(const String &p_file);
bool _load_resource_pack(const String &p_pack);
@@ -139,23 +128,17 @@ public:
void set_order(const String &p_name, int p_order);
void set_builtin_order(const String &p_name);
- Error setup(const String &p_path, const String &p_main_pack);
+ Error setup(const String &p_path, const String &p_main_pack, bool p_upwards = false);
Error save_custom(const String &p_path = "", const CustomMap &p_custom = CustomMap(), const Vector<String> &p_custom_features = Vector<String>(), bool p_merge_with_current = true);
Error save();
void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info);
- void add_singleton(const Singleton &p_singleton);
- void get_singletons(List<Singleton> *p_singletons);
-
- bool has_singleton(const String &p_name) const;
-
Vector<String> get_optimizer_presets() const;
List<String> get_input_presets() const { return input_presets; }
void set_disable_feature_overrides(bool p_disable);
- Object *get_singleton_object(const String &p_name) const;
void register_global_defaults();
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 0e34a3eea5..baaf738b42 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -34,12 +34,14 @@
#include "compressed_translation.h"
#include "core/io/xml_parser.h"
#include "core_string_names.h"
+#include "engine.h"
#include "func_ref.h"
#include "geometry.h"
#include "input_map.h"
#include "io/config_file.h"
#include "io/http_client.h"
#include "io/marshalls.h"
+#include "io/networked_multiplayer_peer.h"
#include "io/packet_peer.h"
#include "io/packet_peer_udp.h"
#include "io/pck_packer.h"
@@ -109,6 +111,8 @@ void register_core_types() {
ClassDB::register_class<Object>();
+ ClassDB::register_virtual_class<Script>();
+
ClassDB::register_class<Reference>();
ClassDB::register_class<WeakRef>();
ClassDB::register_class<Resource>();
@@ -136,6 +140,7 @@ void register_core_types() {
ClassDB::register_virtual_class<IP>();
ClassDB::register_virtual_class<PacketPeer>();
ClassDB::register_class<PacketPeerStream>();
+ ClassDB::register_virtual_class<NetworkedMultiplayerPeer>();
ClassDB::register_class<MainLoop>();
//ClassDB::register_type<OptimizedSaver>();
ClassDB::register_class<Translation>();
@@ -185,19 +190,33 @@ void register_core_settings() {
void register_core_singletons() {
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("IP", IP::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Geometry", _Geometry::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ResourceLoader", _ResourceLoader::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ResourceSaver", _ResourceSaver::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("OS", _OS::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Engine", _Engine::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ClassDB", _classdb));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Marshalls", _Marshalls::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("TranslationServer", TranslationServer::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Input", Input::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("InputMap", InputMap::get_singleton()));
- ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JSON", _JSON::get_singleton()));
+ ClassDB::register_class<ProjectSettings>();
+ ClassDB::register_virtual_class<IP>();
+ ClassDB::register_class<_Geometry>();
+ ClassDB::register_class<_ResourceLoader>();
+ ClassDB::register_class<_ResourceSaver>();
+ ClassDB::register_class<_OS>();
+ ClassDB::register_class<_Engine>();
+ ClassDB::register_class<_ClassDB>();
+ ClassDB::register_class<_Marshalls>();
+ ClassDB::register_class<TranslationServer>();
+ ClassDB::register_virtual_class<Input>();
+ ClassDB::register_class<InputMap>();
+ ClassDB::register_class<_JSON>();
+
+ Engine::get_singleton()->add_singleton(Engine::Singleton("ProjectSettings", ProjectSettings::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("IP", IP::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry", _Geometry::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceLoader", _ResourceLoader::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceSaver", _ResourceSaver::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("OS", _OS::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("Engine", _Engine::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("ClassDB", _classdb));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("Marshalls", _Marshalls::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("TranslationServer", TranslationServer::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("Input", Input::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("InputMap", InputMap::get_singleton()));
+ Engine::get_singleton()->add_singleton(Engine::Singleton("JSON", _JSON::get_singleton()));
}
void unregister_core_types() {
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 4653ade294..5e06339b9e 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -29,11 +29,14 @@
/*************************************************************************/
#include "script_debugger_remote.h"
+#include "engine.h"
#include "io/ip.h"
#include "io/marshalls.h"
#include "os/input.h"
#include "os/os.h"
#include "project_settings.h"
+#include "scene/main/node.h"
+
void ScriptDebuggerRemote::_send_video_memory() {
List<ResourceUsage> usage;
@@ -200,20 +203,39 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
List<String> members;
List<Variant> member_vals;
-
+ if (ScriptInstance *inst = p_script->debug_get_stack_level_instance(lv)) {
+ members.push_back("self");
+ member_vals.push_back(inst->get_owner());
+ }
p_script->debug_get_stack_level_members(lv, &members, &member_vals);
-
ERR_CONTINUE(members.size() != member_vals.size());
List<String> locals;
List<Variant> local_vals;
-
p_script->debug_get_stack_level_locals(lv, &locals, &local_vals);
-
ERR_CONTINUE(locals.size() != local_vals.size());
+ List<String> globals;
+ List<Variant> globals_vals;
+ p_script->debug_get_globals(&globals, &globals_vals);
+ ERR_CONTINUE(globals.size() != globals_vals.size());
+
packet_peer_stream->put_var("stack_frame_vars");
- packet_peer_stream->put_var(2 + locals.size() * 2 + members.size() * 2);
+ packet_peer_stream->put_var(3 + (locals.size() + members.size() + globals.size()) * 2);
+
+ { //locals
+ packet_peer_stream->put_var(locals.size());
+
+ List<String>::Element *E = locals.front();
+ List<Variant>::Element *F = local_vals.front();
+
+ while (E) {
+ _put_variable(E->get(), F->get());
+
+ E = E->next();
+ F = F->next();
+ }
+ }
{ //members
packet_peer_stream->put_var(members.size());
@@ -230,11 +252,11 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
}
}
- { //locals
- packet_peer_stream->put_var(locals.size());
+ { //globals
+ packet_peer_stream->put_var(globals.size());
- List<String>::Element *E = locals.front();
- List<Variant>::Element *F = local_vals.front();
+ List<String>::Element *E = globals.front();
+ List<Variant>::Element *F = globals_vals.front();
while (E) {
_put_variable(E->get(), F->get());
@@ -531,56 +553,88 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
if (!obj)
return;
- List<PropertyInfo> pinfo;
- obj->get_property_list(&pinfo, true);
+ typedef Pair<PropertyInfo, Variant> PropertyDesc;
+ List<PropertyDesc> properties;
- int props_to_send = 0;
- for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
+ if (ScriptInstance *si = obj->get_script_instance()) {
+ if (!si->get_script().is_null()) {
- if (E->get().usage & (PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CATEGORY)) {
- props_to_send++;
- }
- }
+ Set<StringName> members;
+ si->get_script()->get_members(&members);
+ for (Set<StringName>::Element *E = members.front(); E; E = E->next()) {
- packet_peer_stream->put_var("message:inspect_object");
- packet_peer_stream->put_var(props_to_send * 5 + 4);
- packet_peer_stream->put_var(p_id);
- packet_peer_stream->put_var(obj->get_class());
- if (obj->is_class("Resource") || obj->is_class("Node"))
- packet_peer_stream->put_var(obj->call("get_path"));
- else
- packet_peer_stream->put_var("");
+ Variant m;
+ if (si->get(E->get(), m)) {
+ PropertyInfo pi(m.get_type(), String("Members/") + E->get());
+ properties.push_back(PropertyDesc(pi, m));
+ }
+ }
- packet_peer_stream->put_var(props_to_send);
+ Map<StringName, Variant> constants;
+ si->get_script()->get_constants(&constants);
+ for (Map<StringName, Variant>::Element *E = constants.front(); E; E = E->next()) {
+ PropertyInfo pi(E->value().get_type(), (String("Constants/") + E->key()));
+ properties.push_back(PropertyDesc(pi, E->value()));
+ }
+ }
+ }
+ if (Node *node = Object::cast_to<Node>(obj)) {
+ PropertyInfo pi(Variant::NODE_PATH, String("Node/path"));
+ properties.push_front(PropertyDesc(pi, node->get_path()));
+ } else if (Resource *res = Object::cast_to<Resource>(obj)) {
+ if (Script *s = Object::cast_to<Script>(res)) {
+ Map<StringName, Variant> constants;
+ s->get_constants(&constants);
+ for (Map<StringName, Variant>::Element *E = constants.front(); E; E = E->next()) {
+ PropertyInfo pi(E->value().get_type(), String("Constants/") + E->key());
+ properties.push_front(PropertyDesc(pi, E->value()));
+ }
+ }
+ }
+ List<PropertyInfo> pinfo;
+ obj->get_property_list(&pinfo, true);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
-
if (E->get().usage & (PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_CATEGORY)) {
+ properties.push_back(PropertyDesc(E->get(), obj->get(E->get().name)));
+ }
+ }
- if (E->get().usage & PROPERTY_USAGE_CATEGORY) {
- packet_peer_stream->put_var("*" + E->get().name);
- } else {
- packet_peer_stream->put_var(E->get().name);
- }
-
- Variant var = obj->get(E->get().name);
- packet_peer_stream->put_var(E->get().type);
- //only send information that can be sent..
-
- int len = 0; //test how big is this to encode
- encode_variant(var, NULL, len);
-
- 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().hint);
- packet_peer_stream->put_var(E->get().hint_string);
- packet_peer_stream->put_var(var);
- }
+ Array send_props;
+ for (int i = 0; i < properties.size(); i++) {
+ const PropertyInfo &pi = properties[i].first;
+ const Variant &var = properties[i].second;
+ RES res = var;
+
+ Array prop;
+ prop.push_back(pi.name);
+ prop.push_back(pi.type);
+
+ //only send information that can be sent..
+ int len = 0; //test how big is this to encode
+ encode_variant(var, NULL, len);
+ if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size
+ prop.push_back(PROPERTY_HINT_OBJECT_TOO_BIG);
+ prop.push_back("");
+ prop.push_back(pi.usage);
+ prop.push_back(Variant());
+ } else {
+ prop.push_back(pi.hint);
+ if (res.is_null())
+ prop.push_back(pi.hint_string);
+ else
+ prop.push_back(String("RES:") + res->get_path());
+ prop.push_back(pi.usage);
+ prop.push_back(var);
}
+ send_props.push_back(prop);
}
+
+ packet_peer_stream->put_var("message:inspect_object");
+ packet_peer_stream->put_var(3);
+ packet_peer_stream->put_var(p_id);
+ packet_peer_stream->put_var(obj->get_class());
+ packet_peer_stream->put_var(send_props);
}
void ScriptDebuggerRemote::_set_object_property(ObjectID p_id, const String &p_property, const Variant &p_value) {
@@ -589,7 +643,11 @@ void ScriptDebuggerRemote::_set_object_property(ObjectID p_id, const String &p_p
if (!obj)
return;
- obj->set(p_property, p_value);
+ String prop_name = p_property;
+ if (p_property.begins_with("Members/"))
+ prop_name = p_property.substr(8, p_property.length());
+
+ obj->set(prop_name, p_value);
}
void ScriptDebuggerRemote::_poll_events() {
@@ -831,7 +889,7 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_
mutex->unlock();
}
-void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string) {
+void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string, bool p_error) {
ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)p_this;
@@ -855,15 +913,19 @@ void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string)
}
sdr->char_count += allowed_chars;
-
- if (sdr->char_count >= sdr->max_cps) {
- s += "\n[output overflow, print less text!]\n";
- }
+ bool overflowed = sdr->char_count >= sdr->max_cps;
sdr->mutex->lock();
if (!sdr->locking && sdr->tcp_client->is_connected_to_host()) {
+ if (overflowed)
+ s += "[...]";
+
sdr->output_strings.push_back(s);
+
+ if (overflowed) {
+ sdr->output_strings.push_back("[output overflow, print less text!]");
+ }
}
sdr->mutex->unlock();
}
@@ -935,7 +997,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote()
tcp_client(StreamPeerTCP::create_ref()),
packet_peer_stream(Ref<PacketPeerStream>(memnew(PacketPeerStream))),
last_perf_time(0),
- performance(ProjectSettings::get_singleton()->get_singleton_object("Performance")),
+ performance(Engine::get_singleton()->get_singleton_object("Performance")),
requested_quit(false),
mutex(Mutex::create()),
max_cps(GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second")),
diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h
index 22137d1350..90d2daf1f8 100644
--- a/core/script_debugger_remote.h
+++ b/core/script_debugger_remote.h
@@ -94,7 +94,7 @@ class ScriptDebuggerRemote : public ScriptDebugger {
uint64_t msec_count;
bool locking; //hack to avoid a deadloop
- static void _print_handler(void *p_this, const String &p_string);
+ static void _print_handler(void *p_this, const String &p_string, bool p_error);
PrintHandlerList phl;
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 5ead91f26e..384e41e4bd 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -58,7 +58,6 @@ void Script::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_script_signal", "signal_name"), &Script::has_script_signal);
ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool);
- ClassDB::bind_method(D_METHOD("get_node_type"), &Script::get_node_type);
}
void ScriptServer::set_scripting_enabled(bool p_enabled) {
diff --git a/core/script_language.h b/core/script_language.h
index 25767a2f7a..3d01381f3b 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -107,8 +107,6 @@ public:
virtual bool is_tool() const = 0;
- virtual String get_node_type() const = 0;
-
virtual ScriptLanguage *get_language() const = 0;
virtual bool has_script_signal(const StringName &p_signal) const = 0;
@@ -122,6 +120,9 @@ public:
virtual int get_member_line(const StringName &p_member) const { return -1; }
+ virtual void get_constants(Map<StringName, Variant> *p_constants) {}
+ virtual void get_members(Set<StringName> *p_constants) {}
+
Script() {}
};
@@ -132,6 +133,7 @@ public:
virtual void get_property_list(List<PropertyInfo> *p_properties) const = 0;
virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const = 0;
+ virtual Object *get_owner() { return NULL; }
virtual void get_property_state(List<Pair<StringName, Variant> > &state);
virtual void get_method_list(List<MethodInfo> *p_list) const = 0;
@@ -202,6 +204,7 @@ public:
virtual bool validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path = "", List<String> *r_functions = NULL) const = 0;
virtual Script *create_script() const = 0;
virtual bool has_named_classes() const = 0;
+ virtual bool supports_builtin_mode() const = 0;
virtual bool can_inherit_from_file() { return false; }
virtual int find_function(const String &p_function, const String &p_code) const = 0;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const = 0;
@@ -245,7 +248,8 @@ public:
virtual String debug_get_stack_level_source(int p_level) const = 0;
virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) = 0;
virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) = 0;
- virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) = 0;
+ virtual ScriptInstance *debug_get_stack_level_instance(int p_level) { return NULL; }
+ virtual void debug_get_globals(List<String> *p_globals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1) = 0;
virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1) = 0;
struct StackInfo {
diff --git a/core/set.h b/core/set.h
index 0f48e07520..331979d4e3 100644
--- a/core/set.h
+++ b/core/set.h
@@ -424,7 +424,6 @@ private:
Element *rp = ((p_node->left == _data._nil) || (p_node->right == _data._nil)) ? p_node : p_node->_next;
Element *node = (rp->left == _data._nil) ? rp->right : rp->left;
- node->parent = rp->parent;
Element *sibling;
if (rp == rp->parent->left) {
diff --git a/core/string_db.h b/core/string_db.h
index 2bef29fab8..de91e2abd8 100644
--- a/core/string_db.h
+++ b/core/string_db.h
@@ -113,6 +113,9 @@ public:
else
return 0;
}
+ _FORCE_INLINE_ const void *data_unique_pointer() const {
+ return (void *)_data;
+ }
bool operator!=(const StringName &p_name) const;
_FORCE_INLINE_ operator String() const {
diff --git a/core/translation.cpp b/core/translation.cpp
index 27e3b202d0..7e4d4feb89 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -753,65 +753,17 @@ static const char *locale_names[] = {
0
};
-bool TranslationServer::is_locale_valid(const String &p_locale) {
-
- const char **ptr = locale_list;
-
- while (*ptr) {
-
- if (*ptr == p_locale)
- return true;
- ptr++;
- }
-
- return false;
-}
-
-Vector<String> TranslationServer::get_all_locales() {
-
- Vector<String> locales;
-
- const char **ptr = locale_list;
-
- while (*ptr) {
- locales.push_back(*ptr);
- ptr++;
- }
-
- return locales;
-}
-
-Vector<String> TranslationServer::get_all_locale_names() {
-
- Vector<String> locales;
-
- const char **ptr = locale_names;
-
- while (*ptr) {
- locales.push_back(*ptr);
- ptr++;
- }
-
- return locales;
-}
+static const char *locale_renames[][2] = {
+ { "no", "nb" },
+ { NULL, NULL }
+};
static String get_trimmed_locale(const String &p_locale) {
return p_locale.substr(0, 2);
}
-static bool is_valid_locale(const String &p_locale) {
-
- const char **ptr = locale_list;
-
- while (*ptr) {
- if (p_locale == *ptr)
- return true;
- ptr++;
- }
-
- return false;
-}
+///////////////////////////////////////////////
PoolVector<String> Translation::_get_messages() const {
@@ -857,14 +809,13 @@ void Translation::_set_messages(const PoolVector<String> &p_messages) {
void Translation::set_locale(const String &p_locale) {
- // replaces '-' with '_' for macOS Sierra-style locales
- String univ_locale = p_locale.replace("-", "_");
+ String univ_locale = TranslationServer::standardize_locale(p_locale);
- if (!is_valid_locale(univ_locale)) {
+ if (!TranslationServer::is_locale_valid(univ_locale)) {
String trimmed_locale = get_trimmed_locale(univ_locale);
- ERR_EXPLAIN("Invalid Locale: " + trimmed_locale);
- ERR_FAIL_COND(!is_valid_locale(trimmed_locale));
+ ERR_EXPLAIN("Invalid locale: " + trimmed_locale);
+ ERR_FAIL_COND(!TranslationServer::is_locale_valid(trimmed_locale));
locale = trimmed_locale;
} else {
@@ -929,16 +880,47 @@ Translation::Translation()
///////////////////////////////////////////////
-void TranslationServer::set_locale(const String &p_locale) {
+bool TranslationServer::is_locale_valid(const String &p_locale) {
- // replaces '-' with '_' for macOS Sierra-style locales
+ const char **ptr = locale_list;
+
+ while (*ptr) {
+
+ if (*ptr == p_locale)
+ return true;
+ ptr++;
+ }
+
+ return false;
+}
+
+String TranslationServer::standardize_locale(const String &p_locale) {
+
+ // Replaces '-' with '_' for macOS Sierra-style locales
String univ_locale = p_locale.replace("-", "_");
- if (!is_valid_locale(univ_locale)) {
+ // Handles known non-ISO locale names used e.g. on Windows
+ int idx = 0;
+ while (locale_renames[idx][0] != NULL) {
+ if (locale_renames[idx][0] == univ_locale) {
+ univ_locale = locale_renames[idx][1];
+ break;
+ }
+ idx++;
+ }
+
+ return univ_locale;
+}
+
+void TranslationServer::set_locale(const String &p_locale) {
+
+ String univ_locale = standardize_locale(p_locale);
+
+ if (!is_locale_valid(univ_locale)) {
String trimmed_locale = get_trimmed_locale(univ_locale);
- ERR_EXPLAIN("Invalid Locale: " + trimmed_locale);
- ERR_FAIL_COND(!is_valid_locale(trimmed_locale));
+ ERR_EXPLAIN("Invalid locale: " + trimmed_locale);
+ ERR_FAIL_COND(!is_locale_valid(trimmed_locale));
locale = trimmed_locale;
} else {
@@ -957,6 +939,40 @@ String TranslationServer::get_locale() const {
return locale;
}
+String TranslationServer::get_locale_name(const String &p_locale) const {
+
+ if (!locale_name_map.has(p_locale)) return String();
+ return locale_name_map[p_locale];
+}
+
+Vector<String> TranslationServer::get_all_locales() {
+
+ Vector<String> locales;
+
+ const char **ptr = locale_list;
+
+ while (*ptr) {
+ locales.push_back(*ptr);
+ ptr++;
+ }
+
+ return locales;
+}
+
+Vector<String> TranslationServer::get_all_locale_names() {
+
+ Vector<String> locales;
+
+ const char **ptr = locale_names;
+
+ while (*ptr) {
+ locales.push_back(String::utf8(*ptr));
+ ptr++;
+ }
+
+ return locales;
+}
+
void TranslationServer::add_translation(const Ref<Translation> &p_translation) {
translations.insert(p_translation);
@@ -1122,6 +1138,8 @@ void TranslationServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_locale", "locale"), &TranslationServer::set_locale);
ClassDB::bind_method(D_METHOD("get_locale"), &TranslationServer::get_locale);
+ ClassDB::bind_method(D_METHOD("get_locale_name", "locale"), &TranslationServer::get_locale_name);
+
ClassDB::bind_method(D_METHOD("translate", "message"), &TranslationServer::translate);
ClassDB::bind_method(D_METHOD("add_translation", "translation"), &TranslationServer::add_translation);
@@ -1147,4 +1165,9 @@ TranslationServer::TranslationServer()
: locale("en"),
enabled(true) {
singleton = this;
+
+ for (int i = 0; locale_list[i]; ++i) {
+
+ locale_name_map.insert(locale_list[i], String::utf8(locale_names[i]));
+ }
}
diff --git a/core/translation.h b/core/translation.h
index cf59583ad6..0cdab3b0bc 100644
--- a/core/translation.h
+++ b/core/translation.h
@@ -73,6 +73,8 @@ class TranslationServer : public Object {
Set<Ref<Translation> > translations;
Ref<Translation> tool_translation;
+ Map<String, String> locale_name_map;
+
bool enabled;
static TranslationServer *singleton;
@@ -83,14 +85,14 @@ class TranslationServer : public Object {
public:
_FORCE_INLINE_ static TranslationServer *get_singleton() { return singleton; }
- //yes, portuguese is supported!
-
void set_enabled(bool p_enabled) { enabled = p_enabled; }
_FORCE_INLINE_ bool is_enabled() const { return enabled; }
void set_locale(const String &p_locale);
String get_locale() const;
+ String get_locale_name(const String &p_locale) const;
+
void add_translation(const Ref<Translation> &p_translation);
void remove_translation(const Ref<Translation> &p_translation);
@@ -99,6 +101,7 @@ public:
static Vector<String> get_all_locales();
static Vector<String> get_all_locale_names();
static bool is_locale_valid(const String &p_locale);
+ static String standardize_locale(const String &p_locale);
void set_tool_translation(const Ref<Translation> &p_translation);
StringName tool_translate(const StringName &p_message) const;
diff --git a/core/type_info.h b/core/type_info.h
index 9fb80af0eb..24d96c51e8 100644
--- a/core/type_info.h
+++ b/core/type_info.h
@@ -82,7 +82,7 @@ MAKE_TYPE_INFO(Vector3, Variant::VECTOR3)
MAKE_TYPE_INFO(Transform2D, Variant::TRANSFORM2D)
MAKE_TYPE_INFO(Plane, Variant::PLANE)
MAKE_TYPE_INFO(Quat, Variant::QUAT)
-MAKE_TYPE_INFO(Rect3, Variant::RECT3)
+MAKE_TYPE_INFO(AABB, Variant::AABB)
MAKE_TYPE_INFO(Basis, Variant::BASIS)
MAKE_TYPE_INFO(Transform, Variant::TRANSFORM)
MAKE_TYPE_INFO(Color, Variant::COLOR)
diff --git a/core/typedefs.h b/core/typedefs.h
index bf5c8b0f75..c509edf9fe 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -98,11 +98,11 @@ T *_nullptr() {
#undef OK
#endif
+#include "int_types.h"
+
#include "error_list.h"
#include "error_macros.h"
-#include "int_types.h"
-
/** Generic ABS function, for math uses please use Math::abs */
#ifndef ABS
diff --git a/core/ustring.cpp b/core/ustring.cpp
index b85996e3d1..8d40f56386 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -564,7 +564,7 @@ void String::erase(int p_pos, int p_chars) {
String String::capitalize() const {
- String aux = this->replace("_", " ").to_lower();
+ String aux = this->camelcase_to_underscore(true).replace("_", " ").strip_edges();
String cap;
for (int i = 0; i < aux.get_slice_count(" "); i++) {
@@ -862,6 +862,17 @@ Vector<int> String::split_ints_mk(const Vector<String> &p_splitters, bool p_allo
return ret;
}
+String String::join(Vector<String> parts) {
+ String ret;
+ for (int i = 0; i < parts.size(); ++i) {
+ if (i > 0) {
+ ret += *this;
+ }
+ ret += parts[i];
+ }
+ return ret;
+}
+
CharType String::char_uppercase(CharType p_char) {
return _find_upper(p_char);
@@ -2476,6 +2487,11 @@ bool String::begins_with(const char *p_string) const {
return *p_string == 0;
}
+bool String::is_enclosed_in(const String &p_string) const {
+
+ return begins_with(p_string) && ends_with(p_string);
+}
+
bool String::is_subsequence_of(const String &p_string) const {
return _base_is_subsequence_of(p_string, false);
@@ -2486,6 +2502,11 @@ bool String::is_subsequence_ofi(const String &p_string) const {
return _base_is_subsequence_of(p_string, true);
}
+bool String::is_quoted() const {
+
+ return is_enclosed_in("\"") || is_enclosed_in("'");
+}
+
bool String::_base_is_subsequence_of(const String &p_string, bool case_insensitive) const {
int len = length();
@@ -2747,6 +2768,48 @@ CharType String::ord_at(int p_idx) const {
return operator[](p_idx);
}
+String String::dedent() const {
+
+ String new_string;
+ String indent;
+ bool has_indent = false;
+ bool has_text = false;
+ int line_start = 0;
+ int indent_stop = -1;
+
+ for (int i = 0; i < length(); i++) {
+
+ CharType c = operator[](i);
+ if (c == '\n') {
+ if (has_text)
+ new_string += substr(indent_stop, i - indent_stop);
+ new_string += "\n";
+ has_text = false;
+ line_start = i + 1;
+ indent_stop = -1;
+ } else if (!has_text) {
+ if (c > 32) {
+ has_text = true;
+ if (!has_indent) {
+ has_indent = true;
+ indent = substr(line_start, i - line_start);
+ indent_stop = i;
+ }
+ }
+ if (has_indent && indent_stop < 0) {
+ int j = i - line_start;
+ if (j >= indent.length() || c != indent[j])
+ indent_stop = i;
+ }
+ }
+ }
+
+ if (has_text)
+ new_string += substr(indent_stop, length() - indent_stop);
+
+ return new_string;
+}
+
String String::strip_edges(bool left, bool right) const {
int len = length();
@@ -3906,6 +3969,18 @@ String String::sprintf(const Array &values, bool *error) const {
return formatted;
}
+String String::quote(String quotechar) const {
+ return quotechar + *this + quotechar;
+}
+
+String String::unquote() const {
+ if (!is_quoted()) {
+ return *this;
+ }
+
+ return substr(1, length() - 2);
+}
+
#include "translation.h"
#ifdef TOOLS_ENABLED
diff --git a/core/ustring.h b/core/ustring.h
index ab4e325f2c..9c24133b55 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -118,8 +118,10 @@ public:
bool begins_with(const String &p_string) const;
bool begins_with(const char *p_string) const;
bool ends_with(const String &p_string) const;
+ bool is_enclosed_in(const String &p_string) const;
bool is_subsequence_of(const String &p_string) const;
bool is_subsequence_ofi(const String &p_string) const;
+ bool is_quoted() const;
Vector<String> bigrams() const;
float similarity(const String &p_string) const;
String format(const Variant &values, String placeholder = "{_}") const;
@@ -132,6 +134,8 @@ public:
String lpad(int min_length, const String &character = " ") const;
String rpad(int min_length, const String &character = " ") const;
String sprintf(const Array &values, bool *error) const;
+ String quote(String quotechar = "\"") const;
+ String unquote() const;
static String num(double p_num, int p_decimals = -1);
static String num_scientific(double p_num);
static String num_real(double p_num);
@@ -165,6 +169,8 @@ public:
Vector<int> split_ints(const String &p_splitter, bool p_allow_empty = true) const;
Vector<int> split_ints_mk(const Vector<String> &p_splitters, bool p_allow_empty = true) const;
+ String join(Vector<String> parts);
+
static CharType char_uppercase(CharType p_char);
static CharType char_lowercase(CharType p_char);
String to_upper() const;
@@ -172,6 +178,7 @@ public:
String left(int p_pos) const;
String right(int p_pos) const;
+ String dedent() const;
String strip_edges(bool left = true, bool right = true) const;
String strip_escapes() const;
String get_extension() const;
diff --git a/core/variant.cpp b/core/variant.cpp
index f70e4a5218..d4143b8d84 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -66,7 +66,7 @@ String Variant::get_type_name(Variant::Type p_type) {
return "String";
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -94,9 +94,9 @@ String Variant::get_type_name(Variant::Type p_type) {
} break;*/
- case RECT3: {
+ case AABB: {
- return "Rect3";
+ return "AABB";
} break;
case QUAT: {
@@ -267,6 +267,7 @@ bool Variant::can_convert(Variant::Type p_type_from, Variant::Type p_type_to) {
static const Type valid[] = {
QUAT,
+ VECTOR3,
NIL
};
@@ -722,7 +723,7 @@ bool Variant::is_zero() const {
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -754,9 +755,9 @@ bool Variant::is_zero() const {
} break;*/
- case RECT3: {
+ case AABB: {
- return *_data._rect3 == Rect3();
+ return *_data._aabb == ::AABB();
} break;
case QUAT: {
@@ -931,7 +932,7 @@ void Variant::reference(const Variant &p_variant) {
memnew_placement(_data._mem, String(*reinterpret_cast<const String *>(p_variant._data._mem)));
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -954,9 +955,9 @@ void Variant::reference(const Variant &p_variant) {
memnew_placement(_data._mem, Plane(*reinterpret_cast<const Plane *>(p_variant._data._mem)));
} break;
- case RECT3: {
+ case AABB: {
- _data._rect3 = memnew(Rect3(*p_variant._data._rect3));
+ _data._aabb = memnew(::AABB(*p_variant._data._aabb));
} break;
case QUAT: {
@@ -1079,9 +1080,9 @@ void Variant::clear() {
memdelete(_data._transform2d);
} break;
- case RECT3: {
+ case AABB: {
- memdelete(_data._rect3);
+ memdelete(_data._aabb);
} break;
case BASIS: {
@@ -1426,7 +1427,7 @@ Variant::operator String() const {
case PLANE:
return operator Plane();
//case QUAT:
- case RECT3: return operator Rect3();
+ case AABB: return operator ::AABB();
case QUAT: return "(" + operator Quat() + ")";
case BASIS: {
@@ -1617,12 +1618,12 @@ Variant::operator Plane() const {
else
return Plane();
}
-Variant::operator Rect3() const {
+Variant::operator ::AABB() const {
- if (type == RECT3)
- return *_data._rect3;
+ if (type == AABB)
+ return *_data._aabb;
else
- return Rect3();
+ return ::AABB();
}
Variant::operator Basis() const {
@@ -2188,10 +2189,10 @@ Variant::Variant(const Plane &p_plane) {
type = PLANE;
memnew_placement(_data._mem, Plane(p_plane));
}
-Variant::Variant(const Rect3 &p_aabb) {
+Variant::Variant(const ::AABB &p_aabb) {
- type = RECT3;
- _data._rect3 = memnew(Rect3(p_aabb));
+ type = AABB;
+ _data._aabb = memnew(::AABB(p_aabb));
}
Variant::Variant(const Basis &p_matrix) {
@@ -2501,7 +2502,7 @@ void Variant::operator=(const Variant &p_variant) {
*reinterpret_cast<String *>(_data._mem) = *reinterpret_cast<const String *>(p_variant._data._mem);
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -2524,9 +2525,9 @@ void Variant::operator=(const Variant &p_variant) {
*reinterpret_cast<Plane *>(_data._mem) = *reinterpret_cast<const Plane *>(p_variant._data._mem);
} break;
- case RECT3: {
+ case AABB: {
- *_data._rect3 = *(p_variant._data._rect3);
+ *_data._aabb = *(p_variant._data._aabb);
} break;
case QUAT: {
@@ -2641,7 +2642,7 @@ uint32_t Variant::hash() const {
return reinterpret_cast<const String *>(_data._mem)->hash();
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -2686,13 +2687,13 @@ uint32_t Variant::hash() const {
} break;*/
- case RECT3: {
+ case AABB: {
uint32_t hash = 5831;
for (int i = 0; i < 3; i++) {
- hash = hash_djb2_one_float(_data._rect3->position[i], hash);
- hash = hash_djb2_one_float(_data._rect3->size[i], hash);
+ hash = hash_djb2_one_float(_data._aabb->position[i], hash);
+ hash = hash_djb2_one_float(_data._aabb->size[i], hash);
}
return hash;
@@ -2952,9 +2953,9 @@ bool Variant::hash_compare(const Variant &p_variant) const {
(hash_compare_scalar(l->d, r->d));
} break;
- case RECT3: {
- const Rect3 *l = _data._rect3;
- const Rect3 *r = p_variant._data._rect3;
+ case AABB: {
+ const ::AABB *l = _data._aabb;
+ const ::AABB *r = p_variant._data._aabb;
return (hash_compare_vector3(l->position, r->position) &&
(hash_compare_vector3(l->size, r->size)));
diff --git a/core/variant.h b/core/variant.h
index e0d0bf05c8..8ba4d576cf 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -34,6 +34,7 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
+#include "aabb.h"
#include "array.h"
#include "color.h"
#include "dictionary.h"
@@ -45,7 +46,6 @@
#include "node_path.h"
#include "plane.h"
#include "quat.h"
-#include "rect3.h"
#include "ref_ptr.h"
#include "rid.h"
#include "transform.h"
@@ -89,7 +89,7 @@ public:
TRANSFORM2D,
PLANE,
QUAT, // 10
- RECT3,
+ AABB,
BASIS,
TRANSFORM,
@@ -99,15 +99,15 @@ public:
_RID,
OBJECT,
DICTIONARY,
- ARRAY, // 20
+ ARRAY,
// arrays
- POOL_BYTE_ARRAY,
+ POOL_BYTE_ARRAY, // 20
POOL_INT_ARRAY,
POOL_REAL_ARRAY,
POOL_STRING_ARRAY,
- POOL_VECTOR2_ARRAY, // 25
- POOL_VECTOR3_ARRAY,
+ POOL_VECTOR2_ARRAY,
+ POOL_VECTOR3_ARRAY, // 25
POOL_COLOR_ARRAY,
VARIANT_MAX
@@ -136,7 +136,7 @@ private:
int64_t _int;
double _real;
Transform2D *_transform2d;
- Rect3 *_rect3;
+ ::AABB *_aabb;
Basis *_basis;
Transform *_transform;
RefPtr *_resource;
@@ -184,7 +184,7 @@ public:
operator Rect2() const;
operator Vector3() const;
operator Plane() const;
- operator Rect3() const;
+ operator ::AABB() const;
operator Quat() const;
operator Basis() const;
operator Transform() const;
@@ -253,7 +253,7 @@ public:
Variant(const Rect2 &p_rect2);
Variant(const Vector3 &p_vector3);
Variant(const Plane &p_plane);
- Variant(const Rect3 &p_aabb);
+ Variant(const ::AABB &p_aabb);
Variant(const Quat &p_quat);
Variant(const Basis &p_transform);
Variant(const Transform2D &p_transform);
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index d141621fbb..da6e602ccb 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -54,9 +54,8 @@ struct _VariantCall {
Variant::Type return_type;
bool _const;
-#ifdef DEBUG_ENABLED
bool returns;
-#endif
+
VariantFunc func;
_FORCE_INLINE_ bool verify_arguments(const Variant **p_args, Variant::CallError &r_error) {
@@ -146,7 +145,7 @@ struct _VariantCall {
#endif
}
- static void addfunc(bool p_const, Variant::Type p_type, Variant::Type p_return, const StringName &p_name, VariantFunc p_func, const Vector<Variant> &p_defaultarg, const Arg &p_argtype1 = Arg(), const Arg &p_argtype2 = Arg(), const Arg &p_argtype3 = Arg(), const Arg &p_argtype4 = Arg(), const Arg &p_argtype5 = Arg()) {
+ static void addfunc(bool p_const, Variant::Type p_type, Variant::Type p_return, bool p_has_return, const StringName &p_name, VariantFunc p_func, const Vector<Variant> &p_defaultarg, const Arg &p_argtype1 = Arg(), const Arg &p_argtype2 = Arg(), const Arg &p_argtype3 = Arg(), const Arg &p_argtype4 = Arg(), const Arg &p_argtype5 = Arg()) {
FuncData funcdata;
funcdata.func = p_func;
@@ -154,7 +153,7 @@ struct _VariantCall {
funcdata._const = p_const;
#ifdef DEBUG_ENABLED
funcdata.return_type = p_return;
- funcdata.returns = p_return != Variant::NIL;
+ funcdata.returns = p_has_return;
#endif
if (p_argtype1.name) {
@@ -261,6 +260,7 @@ struct _VariantCall {
VCALL_LOCALMEM0R(String, to_lower);
VCALL_LOCALMEM1R(String, left);
VCALL_LOCALMEM1R(String, right);
+ VCALL_LOCALMEM0R(String, dedent);
VCALL_LOCALMEM2R(String, strip_edges);
VCALL_LOCALMEM0R(String, get_extension);
VCALL_LOCALMEM0R(String, get_basename);
@@ -483,6 +483,8 @@ struct _VariantCall {
VCALL_LOCALMEM1(Array, erase);
VCALL_LOCALMEM0(Array, sort);
VCALL_LOCALMEM2(Array, sort_custom);
+ VCALL_LOCALMEM2R(Array, bsearch);
+ VCALL_LOCALMEM4R(Array, bsearch_custom);
VCALL_LOCALMEM0R(Array, duplicate);
VCALL_LOCALMEM0(Array, invert);
@@ -655,26 +657,26 @@ struct _VariantCall {
#define VCALL_PTR5R(m_type, m_method) \
static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); }
- VCALL_PTR0R(Rect3, get_area);
- VCALL_PTR0R(Rect3, has_no_area);
- VCALL_PTR0R(Rect3, has_no_surface);
- VCALL_PTR1R(Rect3, intersects);
- VCALL_PTR1R(Rect3, encloses);
- VCALL_PTR1R(Rect3, merge);
- VCALL_PTR1R(Rect3, intersection);
- VCALL_PTR1R(Rect3, intersects_plane);
- VCALL_PTR2R(Rect3, intersects_segment);
- VCALL_PTR1R(Rect3, has_point);
- VCALL_PTR1R(Rect3, get_support);
- VCALL_PTR0R(Rect3, get_longest_axis);
- VCALL_PTR0R(Rect3, get_longest_axis_index);
- VCALL_PTR0R(Rect3, get_longest_axis_size);
- VCALL_PTR0R(Rect3, get_shortest_axis);
- VCALL_PTR0R(Rect3, get_shortest_axis_index);
- VCALL_PTR0R(Rect3, get_shortest_axis_size);
- VCALL_PTR1R(Rect3, expand);
- VCALL_PTR1R(Rect3, grow);
- VCALL_PTR1R(Rect3, get_endpoint);
+ VCALL_PTR0R(AABB, get_area);
+ VCALL_PTR0R(AABB, has_no_area);
+ VCALL_PTR0R(AABB, has_no_surface);
+ VCALL_PTR1R(AABB, intersects);
+ VCALL_PTR1R(AABB, encloses);
+ VCALL_PTR1R(AABB, merge);
+ VCALL_PTR1R(AABB, intersection);
+ VCALL_PTR1R(AABB, intersects_plane);
+ VCALL_PTR2R(AABB, intersects_segment);
+ VCALL_PTR1R(AABB, has_point);
+ VCALL_PTR1R(AABB, get_support);
+ VCALL_PTR0R(AABB, get_longest_axis);
+ VCALL_PTR0R(AABB, get_longest_axis_index);
+ VCALL_PTR0R(AABB, get_longest_axis_size);
+ VCALL_PTR0R(AABB, get_shortest_axis);
+ VCALL_PTR0R(AABB, get_shortest_axis_index);
+ VCALL_PTR0R(AABB, get_shortest_axis_size);
+ VCALL_PTR1R(AABB, expand);
+ VCALL_PTR1R(AABB, grow);
+ VCALL_PTR1R(AABB, get_endpoint);
VCALL_PTR0R(Transform2D, inverse);
VCALL_PTR0R(Transform2D, affine_inverse);
@@ -755,7 +757,7 @@ struct _VariantCall {
case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Vector3()); return;
case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Plane()); return;
- case Variant::RECT3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Rect3()); return;
+ case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::AABB()); return;
default: r_ret = Variant();
}
}
@@ -766,7 +768,7 @@ struct _VariantCall {
case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector3()); return;
case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Plane()); return;
- case Variant::RECT3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Rect3()); return;
+ case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::AABB()); return;
default: r_ret = Variant();
}
}
@@ -878,9 +880,9 @@ struct _VariantCall {
r_ret = Color::hex(*p_args[0]);
}
- static void Rect3_init1(Variant &r_ret, const Variant **p_args) {
+ static void AABB_init1(Variant &r_ret, const Variant **p_args) {
- r_ret = Rect3(*p_args[0], *p_args[1]);
+ r_ret = ::AABB(*p_args[0], *p_args[1]);
}
static void Basis_init1(Variant &r_ret, const Variant **p_args) {
@@ -1051,7 +1053,6 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
return String();
// math types
-
case VECTOR2:
return Vector2(); // 5
case RECT2: return Rect2();
@@ -1059,8 +1060,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case TRANSFORM2D: return Transform2D();
case PLANE: return Plane();
case QUAT: return Quat();
- case RECT3:
- return Rect3(); // 10
+ case AABB:
+ return ::AABB(); // 10
case BASIS: return Basis();
case TRANSFORM:
return Transform();
@@ -1139,8 +1140,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case VECTOR3: return (Vector3(*p_args[0]));
case PLANE: return (Plane(*p_args[0]));
case QUAT: return (Quat(*p_args[0]));
- case RECT3:
- return (Rect3(*p_args[0])); // 10
+ case AABB:
+ return (::AABB(*p_args[0])); // 10
case BASIS: return (Basis(p_args[0]->operator Basis()));
case TRANSFORM:
return (Transform(p_args[0]->operator Transform()));
@@ -1234,7 +1235,7 @@ Variant::Type Variant::get_method_return_type(Variant::Type p_type, const String
return Variant::NIL;
if (r_has_return)
- *r_has_return = E->get().return_type;
+ *r_has_return = E->get().returns;
return E->get().return_type;
}
@@ -1376,215 +1377,238 @@ void register_variant_methods() {
_VariantCall::construct_funcs = memnew_arr(_VariantCall::ConstructFunc, Variant::VARIANT_MAX);
_VariantCall::constant_data = memnew_arr(_VariantCall::ConstantData, Variant::VARIANT_MAX);
+#define ADDFUNC0R(m_vtype, m_ret, m_class, m_method, m_defarg) \
+ _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg);
+#define ADDFUNC1R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \
+ _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)));
+#define ADDFUNC2R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \
+ _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)));
+#define ADDFUNC3R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \
+ _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)));
+#define ADDFUNC4R(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \
+ _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4)));
+
+#define ADDFUNC0RNC(m_vtype, m_ret, m_class, m_method, m_defarg) \
+ _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg);
+#define ADDFUNC1RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \
+ _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)));
+#define ADDFUNC2RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \
+ _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)));
+#define ADDFUNC3RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \
+ _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)));
+#define ADDFUNC4RNC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \
+ _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, true, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4)));
+
#define ADDFUNC0(m_vtype, m_ret, m_class, m_method, m_defarg) \
- _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg);
+ _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg);
#define ADDFUNC1(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \
- _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)));
+ _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)));
#define ADDFUNC2(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \
- _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)));
+ _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)));
#define ADDFUNC3(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \
- _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)));
+ _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)));
#define ADDFUNC4(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \
- _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4)));
+ _VariantCall::addfunc(true, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4)));
#define ADDFUNC0NC(m_vtype, m_ret, m_class, m_method, m_defarg) \
- _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg);
+ _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg);
#define ADDFUNC1NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_defarg) \
- _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)));
+ _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)));
#define ADDFUNC2NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_defarg) \
- _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)));
+ _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)));
#define ADDFUNC3NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_defarg) \
- _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)));
+ _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)));
#define ADDFUNC4NC(m_vtype, m_ret, m_class, m_method, m_arg1, m_argname1, m_arg2, m_argname2, m_arg3, m_argname3, m_arg4, m_argname4, m_defarg) \
- _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4)));
+ _VariantCall::addfunc(false, Variant::m_vtype, Variant::m_ret, false, _scs_create(#m_method), VCALL(m_class, m_method), m_defarg, _VariantCall::Arg(Variant::m_arg1, _scs_create(m_argname1)), _VariantCall::Arg(Variant::m_arg2, _scs_create(m_argname2)), _VariantCall::Arg(Variant::m_arg3, _scs_create(m_argname3)), _VariantCall::Arg(Variant::m_arg4, _scs_create(m_argname4)));
/* STRING */
- ADDFUNC1(STRING, INT, String, casecmp_to, STRING, "to", varray());
- ADDFUNC1(STRING, INT, String, nocasecmp_to, STRING, "to", varray());
- ADDFUNC0(STRING, INT, String, length, varray());
- ADDFUNC2(STRING, STRING, String, substr, INT, "from", INT, "len", varray());
-
- ADDFUNC2(STRING, INT, String, find, STRING, "what", INT, "from", varray(0));
-
- ADDFUNC1(STRING, INT, String, find_last, STRING, "what", varray());
- ADDFUNC2(STRING, INT, String, findn, STRING, "what", INT, "from", varray(0));
- ADDFUNC2(STRING, INT, String, rfind, STRING, "what", INT, "from", varray(-1));
- ADDFUNC2(STRING, INT, String, rfindn, STRING, "what", INT, "from", varray(-1));
- ADDFUNC1(STRING, BOOL, String, match, STRING, "expr", varray());
- ADDFUNC1(STRING, BOOL, String, matchn, STRING, "expr", varray());
- ADDFUNC1(STRING, BOOL, String, begins_with, STRING, "text", varray());
- ADDFUNC1(STRING, BOOL, String, ends_with, STRING, "text", varray());
- ADDFUNC1(STRING, BOOL, String, is_subsequence_of, STRING, "text", varray());
- ADDFUNC1(STRING, BOOL, String, is_subsequence_ofi, STRING, "text", varray());
- ADDFUNC0(STRING, POOL_STRING_ARRAY, String, bigrams, varray());
- ADDFUNC1(STRING, REAL, String, similarity, STRING, "text", varray());
-
- ADDFUNC2(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}"));
- ADDFUNC2(STRING, STRING, String, replace, STRING, "what", STRING, "forwhat", varray());
- ADDFUNC2(STRING, STRING, String, replacen, STRING, "what", STRING, "forwhat", varray());
- ADDFUNC2(STRING, STRING, String, insert, INT, "position", STRING, "what", varray());
- ADDFUNC0(STRING, STRING, String, capitalize, varray());
- ADDFUNC2(STRING, POOL_STRING_ARRAY, String, split, STRING, "divisor", BOOL, "allow_empty", varray(true));
- ADDFUNC2(STRING, POOL_REAL_ARRAY, String, split_floats, STRING, "divisor", BOOL, "allow_empty", varray(true));
-
- ADDFUNC0(STRING, STRING, String, to_upper, varray());
- ADDFUNC0(STRING, STRING, String, to_lower, varray());
-
- ADDFUNC1(STRING, STRING, String, left, INT, "position", varray());
- ADDFUNC1(STRING, STRING, String, right, INT, "position", varray());
- ADDFUNC2(STRING, STRING, String, strip_edges, BOOL, "left", BOOL, "right", varray(true, true));
- ADDFUNC0(STRING, STRING, String, get_extension, varray());
- ADDFUNC0(STRING, STRING, String, get_basename, varray());
- ADDFUNC1(STRING, STRING, String, plus_file, STRING, "file", varray());
- ADDFUNC1(STRING, INT, String, ord_at, INT, "at", varray());
+ ADDFUNC1R(STRING, INT, String, casecmp_to, STRING, "to", varray());
+ ADDFUNC1R(STRING, INT, String, nocasecmp_to, STRING, "to", varray());
+ ADDFUNC0R(STRING, INT, String, length, varray());
+ ADDFUNC2R(STRING, STRING, String, substr, INT, "from", INT, "len", varray());
+
+ ADDFUNC2R(STRING, INT, String, find, STRING, "what", INT, "from", varray(0));
+
+ ADDFUNC1R(STRING, INT, String, find_last, STRING, "what", varray());
+ ADDFUNC2R(STRING, INT, String, findn, STRING, "what", INT, "from", varray(0));
+ ADDFUNC2R(STRING, INT, String, rfind, STRING, "what", INT, "from", varray(-1));
+ ADDFUNC2R(STRING, INT, String, rfindn, STRING, "what", INT, "from", varray(-1));
+ ADDFUNC1R(STRING, BOOL, String, match, STRING, "expr", varray());
+ ADDFUNC1R(STRING, BOOL, String, matchn, STRING, "expr", varray());
+ ADDFUNC1R(STRING, BOOL, String, begins_with, STRING, "text", varray());
+ ADDFUNC1R(STRING, BOOL, String, ends_with, STRING, "text", varray());
+ ADDFUNC1R(STRING, BOOL, String, is_subsequence_of, STRING, "text", varray());
+ ADDFUNC1R(STRING, BOOL, String, is_subsequence_ofi, STRING, "text", varray());
+ ADDFUNC0R(STRING, POOL_STRING_ARRAY, String, bigrams, varray());
+ ADDFUNC1R(STRING, REAL, String, similarity, STRING, "text", varray());
+
+ ADDFUNC2R(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}"));
+ ADDFUNC2R(STRING, STRING, String, replace, STRING, "what", STRING, "forwhat", varray());
+ ADDFUNC2R(STRING, STRING, String, replacen, STRING, "what", STRING, "forwhat", varray());
+ ADDFUNC2R(STRING, STRING, String, insert, INT, "position", STRING, "what", varray());
+ ADDFUNC0R(STRING, STRING, String, capitalize, varray());
+ ADDFUNC2R(STRING, POOL_STRING_ARRAY, String, split, STRING, "divisor", BOOL, "allow_empty", varray(true));
+ ADDFUNC2R(STRING, POOL_REAL_ARRAY, String, split_floats, STRING, "divisor", BOOL, "allow_empty", varray(true));
+
+ ADDFUNC0R(STRING, STRING, String, to_upper, varray());
+ ADDFUNC0R(STRING, STRING, String, to_lower, varray());
+
+ ADDFUNC1R(STRING, STRING, String, left, INT, "position", varray());
+ ADDFUNC1R(STRING, STRING, String, right, INT, "position", varray());
+ ADDFUNC2R(STRING, STRING, String, strip_edges, BOOL, "left", BOOL, "right", varray(true, true));
+ ADDFUNC0R(STRING, STRING, String, get_extension, varray());
+ ADDFUNC0R(STRING, STRING, String, get_basename, varray());
+ ADDFUNC1R(STRING, STRING, String, plus_file, STRING, "file", varray());
+ ADDFUNC1R(STRING, INT, String, ord_at, INT, "at", varray());
+ ADDFUNC0R(STRING, STRING, String, dedent, varray());
ADDFUNC2(STRING, NIL, String, erase, INT, "position", INT, "chars", varray());
- ADDFUNC0(STRING, INT, String, hash, varray());
- ADDFUNC0(STRING, STRING, String, md5_text, varray());
- ADDFUNC0(STRING, STRING, String, sha256_text, varray());
- ADDFUNC0(STRING, POOL_BYTE_ARRAY, String, md5_buffer, varray());
- ADDFUNC0(STRING, POOL_BYTE_ARRAY, String, sha256_buffer, varray());
- ADDFUNC0(STRING, BOOL, String, empty, varray());
- ADDFUNC0(STRING, BOOL, String, is_abs_path, varray());
- ADDFUNC0(STRING, BOOL, String, is_rel_path, varray());
- ADDFUNC0(STRING, STRING, String, get_base_dir, varray());
- ADDFUNC0(STRING, STRING, String, get_file, varray());
- ADDFUNC0(STRING, STRING, String, xml_escape, varray());
- ADDFUNC0(STRING, STRING, String, xml_unescape, varray());
- ADDFUNC0(STRING, STRING, String, c_escape, varray());
- ADDFUNC0(STRING, STRING, String, c_unescape, varray());
- ADDFUNC0(STRING, STRING, String, json_escape, varray());
- ADDFUNC0(STRING, STRING, String, percent_encode, varray());
- ADDFUNC0(STRING, STRING, String, percent_decode, varray());
- ADDFUNC0(STRING, BOOL, String, is_valid_identifier, varray());
- ADDFUNC0(STRING, BOOL, String, is_valid_integer, varray());
- ADDFUNC0(STRING, BOOL, String, is_valid_float, varray());
- ADDFUNC0(STRING, BOOL, String, is_valid_html_color, varray());
- ADDFUNC0(STRING, BOOL, String, is_valid_ip_address, varray());
- ADDFUNC0(STRING, INT, String, to_int, varray());
- ADDFUNC0(STRING, REAL, String, to_float, varray());
- ADDFUNC0(STRING, INT, String, hex_to_int, varray());
- ADDFUNC1(STRING, STRING, String, pad_decimals, INT, "digits", varray());
- ADDFUNC1(STRING, STRING, String, pad_zeros, INT, "digits", varray());
-
- ADDFUNC0(STRING, POOL_BYTE_ARRAY, String, to_ascii, varray());
- ADDFUNC0(STRING, POOL_BYTE_ARRAY, String, to_utf8, varray());
-
- ADDFUNC0(VECTOR2, VECTOR2, Vector2, normalized, varray());
- ADDFUNC0(VECTOR2, REAL, Vector2, length, varray());
- ADDFUNC0(VECTOR2, REAL, Vector2, angle, varray());
- ADDFUNC0(VECTOR2, REAL, Vector2, length_squared, varray());
- ADDFUNC0(VECTOR2, BOOL, Vector2, is_normalized, varray());
- ADDFUNC1(VECTOR2, REAL, Vector2, distance_to, VECTOR2, "to", varray());
- ADDFUNC1(VECTOR2, REAL, Vector2, distance_squared_to, VECTOR2, "to", varray());
- ADDFUNC1(VECTOR2, REAL, Vector2, angle_to, VECTOR2, "to", varray());
- ADDFUNC1(VECTOR2, REAL, Vector2, angle_to_point, VECTOR2, "to", varray());
- ADDFUNC2(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", REAL, "t", varray());
- ADDFUNC4(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", REAL, "t", varray());
- ADDFUNC1(VECTOR2, VECTOR2, Vector2, rotated, REAL, "phi", varray());
- ADDFUNC0(VECTOR2, VECTOR2, Vector2, tangent, varray());
- ADDFUNC0(VECTOR2, VECTOR2, Vector2, floor, varray());
- ADDFUNC1(VECTOR2, VECTOR2, Vector2, snapped, VECTOR2, "by", varray());
- ADDFUNC0(VECTOR2, REAL, Vector2, aspect, varray());
- ADDFUNC1(VECTOR2, REAL, Vector2, dot, VECTOR2, "with", varray());
- ADDFUNC1(VECTOR2, VECTOR2, Vector2, slide, VECTOR2, "n", varray());
- ADDFUNC1(VECTOR2, VECTOR2, Vector2, bounce, VECTOR2, "n", varray());
- ADDFUNC1(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "n", varray());
- //ADDFUNC1(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray());
- ADDFUNC0(VECTOR2, VECTOR2, Vector2, abs, varray());
- ADDFUNC1(VECTOR2, VECTOR2, Vector2, clamped, REAL, "length", varray());
-
- ADDFUNC0(RECT2, REAL, Rect2, get_area, varray());
- ADDFUNC1(RECT2, BOOL, Rect2, intersects, RECT2, "b", varray());
- ADDFUNC1(RECT2, BOOL, Rect2, encloses, RECT2, "b", varray());
- ADDFUNC0(RECT2, BOOL, Rect2, has_no_area, varray());
- ADDFUNC1(RECT2, RECT2, Rect2, clip, RECT2, "b", varray());
- ADDFUNC1(RECT2, RECT2, Rect2, merge, RECT2, "b", varray());
- ADDFUNC1(RECT2, BOOL, Rect2, has_point, VECTOR2, "point", varray());
- ADDFUNC1(RECT2, RECT2, Rect2, grow, REAL, "by", varray());
- ADDFUNC2(RECT2, RECT2, Rect2, grow_margin, INT, "margin", REAL, "by", varray());
- ADDFUNC4(RECT2, RECT2, Rect2, grow_individual, REAL, "left", REAL, "top", REAL, "right", REAL, " bottom", varray());
- ADDFUNC1(RECT2, RECT2, Rect2, expand, VECTOR2, "to", varray());
-
- ADDFUNC0(VECTOR3, INT, Vector3, min_axis, varray());
- ADDFUNC0(VECTOR3, INT, Vector3, max_axis, varray());
- ADDFUNC0(VECTOR3, REAL, Vector3, length, varray());
- ADDFUNC0(VECTOR3, REAL, Vector3, length_squared, varray());
- ADDFUNC0(VECTOR3, BOOL, Vector3, is_normalized, varray());
- ADDFUNC0(VECTOR3, VECTOR3, Vector3, normalized, varray());
- ADDFUNC0(VECTOR3, VECTOR3, Vector3, inverse, varray());
- ADDFUNC1(VECTOR3, VECTOR3, Vector3, snapped, REAL, "by", varray());
- ADDFUNC2(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "phi", varray());
- ADDFUNC2(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", REAL, "t", varray());
- ADDFUNC4(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", REAL, "t", varray());
- ADDFUNC1(VECTOR3, REAL, Vector3, dot, VECTOR3, "b", varray());
- ADDFUNC1(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray());
- ADDFUNC1(VECTOR3, BASIS, Vector3, outer, VECTOR3, "b", varray());
- ADDFUNC0(VECTOR3, BASIS, Vector3, to_diagonal_matrix, varray());
- ADDFUNC0(VECTOR3, VECTOR3, Vector3, abs, varray());
- ADDFUNC0(VECTOR3, VECTOR3, Vector3, floor, varray());
- ADDFUNC0(VECTOR3, VECTOR3, Vector3, ceil, varray());
- ADDFUNC1(VECTOR3, REAL, Vector3, distance_to, VECTOR3, "b", varray());
- ADDFUNC1(VECTOR3, REAL, Vector3, distance_squared_to, VECTOR3, "b", varray());
- ADDFUNC1(VECTOR3, REAL, Vector3, angle_to, VECTOR3, "to", varray());
- ADDFUNC1(VECTOR3, VECTOR3, Vector3, slide, VECTOR3, "n", varray());
- ADDFUNC1(VECTOR3, VECTOR3, Vector3, bounce, VECTOR3, "n", varray());
- ADDFUNC1(VECTOR3, VECTOR3, Vector3, reflect, VECTOR3, "n", varray());
-
- ADDFUNC0(PLANE, PLANE, Plane, normalized, varray());
- ADDFUNC0(PLANE, VECTOR3, Plane, center, varray());
- ADDFUNC0(PLANE, VECTOR3, Plane, get_any_point, varray());
- ADDFUNC1(PLANE, BOOL, Plane, is_point_over, VECTOR3, "point", varray());
- ADDFUNC1(PLANE, REAL, Plane, distance_to, VECTOR3, "point", varray());
- ADDFUNC2(PLANE, BOOL, Plane, has_point, VECTOR3, "point", REAL, "epsilon", varray(CMP_EPSILON));
- ADDFUNC1(PLANE, VECTOR3, Plane, project, VECTOR3, "point", varray());
- ADDFUNC2(PLANE, VECTOR3, Plane, intersect_3, PLANE, "b", PLANE, "c", varray());
- ADDFUNC2(PLANE, VECTOR3, Plane, intersects_ray, VECTOR3, "from", VECTOR3, "dir", varray());
- ADDFUNC2(PLANE, VECTOR3, Plane, intersects_segment, VECTOR3, "begin", VECTOR3, "end", varray());
-
- ADDFUNC0(QUAT, REAL, Quat, length, varray());
- ADDFUNC0(QUAT, REAL, Quat, length_squared, varray());
- ADDFUNC0(QUAT, QUAT, Quat, normalized, varray());
- ADDFUNC0(QUAT, BOOL, Quat, is_normalized, varray());
- ADDFUNC0(QUAT, QUAT, Quat, inverse, varray());
- ADDFUNC1(QUAT, REAL, Quat, dot, QUAT, "b", varray());
- ADDFUNC1(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray());
- ADDFUNC2(QUAT, QUAT, Quat, slerp, QUAT, "b", REAL, "t", varray());
- ADDFUNC2(QUAT, QUAT, Quat, slerpni, QUAT, "b", REAL, "t", varray());
- ADDFUNC4(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", REAL, "t", varray());
-
- ADDFUNC0(COLOR, INT, Color, to_rgba32, varray());
- ADDFUNC0(COLOR, INT, Color, to_argb32, varray());
- ADDFUNC0(COLOR, REAL, Color, gray, varray());
- ADDFUNC0(COLOR, COLOR, Color, inverted, varray());
- ADDFUNC0(COLOR, COLOR, Color, contrasted, varray());
- ADDFUNC2(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", REAL, "t", varray());
- ADDFUNC1(COLOR, COLOR, Color, blend, COLOR, "over", varray());
- ADDFUNC1(COLOR, STRING, Color, to_html, BOOL, "with_alpha", varray(true));
-
- ADDFUNC0(_RID, INT, RID, get_id, varray());
-
- ADDFUNC0(NODE_PATH, BOOL, NodePath, is_absolute, varray());
- ADDFUNC0(NODE_PATH, INT, NodePath, get_name_count, varray());
- ADDFUNC1(NODE_PATH, STRING, NodePath, get_name, INT, "idx", varray());
- ADDFUNC0(NODE_PATH, INT, NodePath, get_subname_count, varray());
- ADDFUNC1(NODE_PATH, STRING, NodePath, get_subname, INT, "idx", varray());
- ADDFUNC0(NODE_PATH, STRING, NodePath, get_property, varray());
- ADDFUNC0(NODE_PATH, BOOL, NodePath, is_empty, varray());
-
- ADDFUNC0(DICTIONARY, INT, Dictionary, size, varray());
- ADDFUNC0(DICTIONARY, BOOL, Dictionary, empty, varray());
+ ADDFUNC0R(STRING, INT, String, hash, varray());
+ ADDFUNC0R(STRING, STRING, String, md5_text, varray());
+ ADDFUNC0R(STRING, STRING, String, sha256_text, varray());
+ ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, md5_buffer, varray());
+ ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, sha256_buffer, varray());
+ ADDFUNC0R(STRING, BOOL, String, empty, varray());
+ ADDFUNC0R(STRING, BOOL, String, is_abs_path, varray());
+ ADDFUNC0R(STRING, BOOL, String, is_rel_path, varray());
+ ADDFUNC0R(STRING, STRING, String, get_base_dir, varray());
+ ADDFUNC0R(STRING, STRING, String, get_file, varray());
+ ADDFUNC0R(STRING, STRING, String, xml_escape, varray());
+ ADDFUNC0R(STRING, STRING, String, xml_unescape, varray());
+ ADDFUNC0R(STRING, STRING, String, c_escape, varray());
+ ADDFUNC0R(STRING, STRING, String, c_unescape, varray());
+ ADDFUNC0R(STRING, STRING, String, json_escape, varray());
+ ADDFUNC0R(STRING, STRING, String, percent_encode, varray());
+ ADDFUNC0R(STRING, STRING, String, percent_decode, varray());
+ ADDFUNC0R(STRING, BOOL, String, is_valid_identifier, varray());
+ ADDFUNC0R(STRING, BOOL, String, is_valid_integer, varray());
+ ADDFUNC0R(STRING, BOOL, String, is_valid_float, varray());
+ ADDFUNC0R(STRING, BOOL, String, is_valid_html_color, varray());
+ ADDFUNC0R(STRING, BOOL, String, is_valid_ip_address, varray());
+ ADDFUNC0R(STRING, INT, String, to_int, varray());
+ ADDFUNC0R(STRING, REAL, String, to_float, varray());
+ ADDFUNC0R(STRING, INT, String, hex_to_int, varray());
+ ADDFUNC1R(STRING, STRING, String, pad_decimals, INT, "digits", varray());
+ ADDFUNC1R(STRING, STRING, String, pad_zeros, INT, "digits", varray());
+
+ ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, to_ascii, varray());
+ ADDFUNC0R(STRING, POOL_BYTE_ARRAY, String, to_utf8, varray());
+
+ ADDFUNC0R(VECTOR2, VECTOR2, Vector2, normalized, varray());
+ ADDFUNC0R(VECTOR2, REAL, Vector2, length, varray());
+ ADDFUNC0R(VECTOR2, REAL, Vector2, angle, varray());
+ ADDFUNC0R(VECTOR2, REAL, Vector2, length_squared, varray());
+ ADDFUNC0R(VECTOR2, BOOL, Vector2, is_normalized, varray());
+ ADDFUNC1R(VECTOR2, REAL, Vector2, distance_to, VECTOR2, "to", varray());
+ ADDFUNC1R(VECTOR2, REAL, Vector2, distance_squared_to, VECTOR2, "to", varray());
+ ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to, VECTOR2, "to", varray());
+ ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to_point, VECTOR2, "to", varray());
+ ADDFUNC2R(VECTOR2, VECTOR2, Vector2, linear_interpolate, VECTOR2, "b", REAL, "t", varray());
+ ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", REAL, "t", varray());
+ ADDFUNC1R(VECTOR2, VECTOR2, Vector2, rotated, REAL, "phi", varray());
+ ADDFUNC0R(VECTOR2, VECTOR2, Vector2, tangent, varray());
+ ADDFUNC0R(VECTOR2, VECTOR2, Vector2, floor, varray());
+ ADDFUNC1R(VECTOR2, VECTOR2, Vector2, snapped, VECTOR2, "by", varray());
+ ADDFUNC0R(VECTOR2, REAL, Vector2, aspect, varray());
+ ADDFUNC1R(VECTOR2, REAL, Vector2, dot, VECTOR2, "with", varray());
+ ADDFUNC1R(VECTOR2, VECTOR2, Vector2, slide, VECTOR2, "n", varray());
+ ADDFUNC1R(VECTOR2, VECTOR2, Vector2, bounce, VECTOR2, "n", varray());
+ ADDFUNC1R(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "n", varray());
+ //ADDFUNC1R(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray());
+ ADDFUNC0R(VECTOR2, VECTOR2, Vector2, abs, varray());
+ ADDFUNC1R(VECTOR2, VECTOR2, Vector2, clamped, REAL, "length", varray());
+
+ ADDFUNC0R(RECT2, REAL, Rect2, get_area, varray());
+ ADDFUNC1R(RECT2, BOOL, Rect2, intersects, RECT2, "b", varray());
+ ADDFUNC1R(RECT2, BOOL, Rect2, encloses, RECT2, "b", varray());
+ ADDFUNC0R(RECT2, BOOL, Rect2, has_no_area, varray());
+ ADDFUNC1R(RECT2, RECT2, Rect2, clip, RECT2, "b", varray());
+ ADDFUNC1R(RECT2, RECT2, Rect2, merge, RECT2, "b", varray());
+ ADDFUNC1R(RECT2, BOOL, Rect2, has_point, VECTOR2, "point", varray());
+ ADDFUNC1R(RECT2, RECT2, Rect2, grow, REAL, "by", varray());
+ ADDFUNC2R(RECT2, RECT2, Rect2, grow_margin, INT, "margin", REAL, "by", varray());
+ ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, REAL, "left", REAL, "top", REAL, "right", REAL, " bottom", varray());
+ ADDFUNC1R(RECT2, RECT2, Rect2, expand, VECTOR2, "to", varray());
+
+ ADDFUNC0R(VECTOR3, INT, Vector3, min_axis, varray());
+ ADDFUNC0R(VECTOR3, INT, Vector3, max_axis, varray());
+ ADDFUNC0R(VECTOR3, REAL, Vector3, length, varray());
+ ADDFUNC0R(VECTOR3, REAL, Vector3, length_squared, varray());
+ ADDFUNC0R(VECTOR3, BOOL, Vector3, is_normalized, varray());
+ ADDFUNC0R(VECTOR3, VECTOR3, Vector3, normalized, varray());
+ ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray());
+ ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, REAL, "by", varray());
+ ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "phi", varray());
+ ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", REAL, "t", varray());
+ ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", REAL, "t", varray());
+ ADDFUNC1R(VECTOR3, REAL, Vector3, dot, VECTOR3, "b", varray());
+ ADDFUNC1R(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray());
+ ADDFUNC1R(VECTOR3, BASIS, Vector3, outer, VECTOR3, "b", varray());
+ ADDFUNC0R(VECTOR3, BASIS, Vector3, to_diagonal_matrix, varray());
+ ADDFUNC0R(VECTOR3, VECTOR3, Vector3, abs, varray());
+ ADDFUNC0R(VECTOR3, VECTOR3, Vector3, floor, varray());
+ ADDFUNC0R(VECTOR3, VECTOR3, Vector3, ceil, varray());
+ ADDFUNC1R(VECTOR3, REAL, Vector3, distance_to, VECTOR3, "b", varray());
+ ADDFUNC1R(VECTOR3, REAL, Vector3, distance_squared_to, VECTOR3, "b", varray());
+ ADDFUNC1R(VECTOR3, REAL, Vector3, angle_to, VECTOR3, "to", varray());
+ ADDFUNC1R(VECTOR3, VECTOR3, Vector3, slide, VECTOR3, "n", varray());
+ ADDFUNC1R(VECTOR3, VECTOR3, Vector3, bounce, VECTOR3, "n", varray());
+ ADDFUNC1R(VECTOR3, VECTOR3, Vector3, reflect, VECTOR3, "n", varray());
+
+ ADDFUNC0R(PLANE, PLANE, Plane, normalized, varray());
+ ADDFUNC0R(PLANE, VECTOR3, Plane, center, varray());
+ ADDFUNC0R(PLANE, VECTOR3, Plane, get_any_point, varray());
+ ADDFUNC1R(PLANE, BOOL, Plane, is_point_over, VECTOR3, "point", varray());
+ ADDFUNC1R(PLANE, REAL, Plane, distance_to, VECTOR3, "point", varray());
+ ADDFUNC2R(PLANE, BOOL, Plane, has_point, VECTOR3, "point", REAL, "epsilon", varray(CMP_EPSILON));
+ ADDFUNC1R(PLANE, VECTOR3, Plane, project, VECTOR3, "point", varray());
+ ADDFUNC2R(PLANE, VECTOR3, Plane, intersect_3, PLANE, "b", PLANE, "c", varray());
+ ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_ray, VECTOR3, "from", VECTOR3, "dir", varray());
+ ADDFUNC2R(PLANE, VECTOR3, Plane, intersects_segment, VECTOR3, "begin", VECTOR3, "end", varray());
+
+ ADDFUNC0R(QUAT, REAL, Quat, length, varray());
+ ADDFUNC0R(QUAT, REAL, Quat, length_squared, varray());
+ ADDFUNC0R(QUAT, QUAT, Quat, normalized, varray());
+ ADDFUNC0R(QUAT, BOOL, Quat, is_normalized, varray());
+ ADDFUNC0R(QUAT, QUAT, Quat, inverse, varray());
+ ADDFUNC1R(QUAT, REAL, Quat, dot, QUAT, "b", varray());
+ ADDFUNC1R(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray());
+ ADDFUNC2R(QUAT, QUAT, Quat, slerp, QUAT, "b", REAL, "t", varray());
+ ADDFUNC2R(QUAT, QUAT, Quat, slerpni, QUAT, "b", REAL, "t", varray());
+ ADDFUNC4R(QUAT, QUAT, Quat, cubic_slerp, QUAT, "b", QUAT, "pre_a", QUAT, "post_b", REAL, "t", varray());
+
+ ADDFUNC0R(COLOR, INT, Color, to_rgba32, varray());
+ ADDFUNC0R(COLOR, INT, Color, to_argb32, varray());
+ ADDFUNC0R(COLOR, REAL, Color, gray, varray());
+ ADDFUNC0R(COLOR, COLOR, Color, inverted, varray());
+ ADDFUNC0R(COLOR, COLOR, Color, contrasted, varray());
+ ADDFUNC2R(COLOR, COLOR, Color, linear_interpolate, COLOR, "b", REAL, "t", varray());
+ ADDFUNC1R(COLOR, COLOR, Color, blend, COLOR, "over", varray());
+ ADDFUNC1R(COLOR, STRING, Color, to_html, BOOL, "with_alpha", varray(true));
+
+ ADDFUNC0R(_RID, INT, RID, get_id, varray());
+
+ ADDFUNC0R(NODE_PATH, BOOL, NodePath, is_absolute, varray());
+ ADDFUNC0R(NODE_PATH, INT, NodePath, get_name_count, varray());
+ ADDFUNC1R(NODE_PATH, STRING, NodePath, get_name, INT, "idx", varray());
+ ADDFUNC0R(NODE_PATH, INT, NodePath, get_subname_count, varray());
+ ADDFUNC1R(NODE_PATH, STRING, NodePath, get_subname, INT, "idx", varray());
+ ADDFUNC0R(NODE_PATH, STRING, NodePath, get_property, varray());
+ ADDFUNC0R(NODE_PATH, BOOL, NodePath, is_empty, varray());
+
+ ADDFUNC0R(DICTIONARY, INT, Dictionary, size, varray());
+ ADDFUNC0R(DICTIONARY, BOOL, Dictionary, empty, varray());
ADDFUNC0NC(DICTIONARY, NIL, Dictionary, clear, varray());
- ADDFUNC1(DICTIONARY, BOOL, Dictionary, has, NIL, "key", varray());
- ADDFUNC1(DICTIONARY, BOOL, Dictionary, has_all, ARRAY, "keys", varray());
+ ADDFUNC1R(DICTIONARY, BOOL, Dictionary, has, NIL, "key", varray());
+ ADDFUNC1R(DICTIONARY, BOOL, Dictionary, has_all, ARRAY, "keys", varray());
ADDFUNC1(DICTIONARY, NIL, Dictionary, erase, NIL, "key", varray());
- ADDFUNC0(DICTIONARY, INT, Dictionary, hash, varray());
- ADDFUNC0(DICTIONARY, ARRAY, Dictionary, keys, varray());
- ADDFUNC0(DICTIONARY, ARRAY, Dictionary, values, varray());
+ ADDFUNC0R(DICTIONARY, INT, Dictionary, hash, varray());
+ ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, keys, varray());
+ ADDFUNC0R(DICTIONARY, ARRAY, Dictionary, values, varray());
- ADDFUNC0(ARRAY, INT, Array, size, varray());
- ADDFUNC0(ARRAY, BOOL, Array, empty, varray());
+ ADDFUNC0R(ARRAY, INT, Array, size, varray());
+ ADDFUNC0R(ARRAY, BOOL, Array, empty, varray());
ADDFUNC0NC(ARRAY, NIL, Array, clear, varray());
- ADDFUNC0(ARRAY, INT, Array, hash, varray());
+ ADDFUNC0R(ARRAY, INT, Array, hash, varray());
ADDFUNC1NC(ARRAY, NIL, Array, push_back, NIL, "value", varray());
ADDFUNC1NC(ARRAY, NIL, Array, push_front, NIL, "value", varray());
ADDFUNC1NC(ARRAY, NIL, Array, append, NIL, "value", varray());
@@ -1592,165 +1616,162 @@ void register_variant_methods() {
ADDFUNC2NC(ARRAY, NIL, Array, insert, INT, "position", NIL, "value", varray());
ADDFUNC1NC(ARRAY, NIL, Array, remove, INT, "position", varray());
ADDFUNC1NC(ARRAY, NIL, Array, erase, NIL, "value", varray());
- ADDFUNC0(ARRAY, NIL, Array, front, varray());
- ADDFUNC0(ARRAY, NIL, Array, back, varray());
- ADDFUNC2(ARRAY, INT, Array, find, NIL, "what", INT, "from", varray(0));
- ADDFUNC2(ARRAY, INT, Array, rfind, NIL, "what", INT, "from", varray(-1));
- ADDFUNC1(ARRAY, INT, Array, find_last, NIL, "value", varray());
- ADDFUNC1(ARRAY, INT, Array, count, NIL, "value", varray());
- ADDFUNC1(ARRAY, BOOL, Array, has, NIL, "value", varray());
- ADDFUNC0NC(ARRAY, NIL, Array, pop_back, varray());
- ADDFUNC0NC(ARRAY, NIL, Array, pop_front, varray());
+ ADDFUNC0R(ARRAY, NIL, Array, front, varray());
+ ADDFUNC0R(ARRAY, NIL, Array, back, varray());
+ ADDFUNC2R(ARRAY, INT, Array, find, NIL, "what", INT, "from", varray(0));
+ ADDFUNC2R(ARRAY, INT, Array, rfind, NIL, "what", INT, "from", varray(-1));
+ ADDFUNC1R(ARRAY, INT, Array, find_last, NIL, "value", varray());
+ ADDFUNC1R(ARRAY, INT, Array, count, NIL, "value", varray());
+ ADDFUNC1R(ARRAY, BOOL, Array, has, NIL, "value", varray());
+ ADDFUNC0RNC(ARRAY, NIL, Array, pop_back, varray());
+ ADDFUNC0RNC(ARRAY, NIL, Array, pop_front, varray());
ADDFUNC0NC(ARRAY, NIL, Array, sort, varray());
ADDFUNC2NC(ARRAY, NIL, Array, sort_custom, OBJECT, "obj", STRING, "func", varray());
+ ADDFUNC2R(ARRAY, INT, Array, bsearch, NIL, "value", BOOL, "before", varray(true));
+ ADDFUNC4R(ARRAY, INT, Array, bsearch_custom, NIL, "value", OBJECT, "obj", STRING, "func", BOOL, "before", varray(true));
ADDFUNC0NC(ARRAY, NIL, Array, invert, varray());
- ADDFUNC0NC(ARRAY, ARRAY, Array, duplicate, varray());
+ ADDFUNC0RNC(ARRAY, ARRAY, Array, duplicate, varray());
- ADDFUNC0(POOL_BYTE_ARRAY, INT, PoolByteArray, size, varray());
+ ADDFUNC0R(POOL_BYTE_ARRAY, INT, PoolByteArray, size, varray());
ADDFUNC2(POOL_BYTE_ARRAY, NIL, PoolByteArray, set, INT, "idx", INT, "byte", varray());
ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, push_back, INT, "byte", varray());
ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, append, INT, "byte", varray());
ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, append_array, POOL_BYTE_ARRAY, "array", varray());
ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, remove, INT, "idx", varray());
- ADDFUNC2(POOL_BYTE_ARRAY, INT, PoolByteArray, insert, INT, "idx", INT, "byte", varray());
+ ADDFUNC2R(POOL_BYTE_ARRAY, INT, PoolByteArray, insert, INT, "idx", INT, "byte", varray());
ADDFUNC1(POOL_BYTE_ARRAY, NIL, PoolByteArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_BYTE_ARRAY, NIL, PoolByteArray, invert, varray());
- ADDFUNC2(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, subarray, INT, "from", INT, "to", varray());
+ ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, subarray, INT, "from", INT, "to", varray());
- 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));
+ ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_ascii, varray());
+ ADDFUNC0R(POOL_BYTE_ARRAY, STRING, PoolByteArray, get_string_from_utf8, varray());
+ ADDFUNC1R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, compress, INT, "compression_mode", varray(0));
+ ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0));
- ADDFUNC0(POOL_INT_ARRAY, INT, PoolIntArray, size, varray());
+ ADDFUNC0R(POOL_INT_ARRAY, INT, PoolIntArray, size, varray());
ADDFUNC2(POOL_INT_ARRAY, NIL, PoolIntArray, set, INT, "idx", INT, "integer", varray());
ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, push_back, INT, "integer", varray());
ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, append, INT, "integer", varray());
ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, append_array, POOL_INT_ARRAY, "array", varray());
ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, remove, INT, "idx", varray());
- ADDFUNC2(POOL_INT_ARRAY, INT, PoolIntArray, insert, INT, "idx", INT, "integer", varray());
+ ADDFUNC2R(POOL_INT_ARRAY, INT, PoolIntArray, insert, INT, "idx", INT, "integer", varray());
ADDFUNC1(POOL_INT_ARRAY, NIL, PoolIntArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_INT_ARRAY, NIL, PoolIntArray, invert, varray());
- ADDFUNC0(POOL_REAL_ARRAY, INT, PoolRealArray, size, varray());
+ ADDFUNC0R(POOL_REAL_ARRAY, INT, PoolRealArray, size, varray());
ADDFUNC2(POOL_REAL_ARRAY, NIL, PoolRealArray, set, INT, "idx", REAL, "value", varray());
ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, push_back, REAL, "value", varray());
ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, append, REAL, "value", varray());
ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, append_array, POOL_REAL_ARRAY, "array", varray());
ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, remove, INT, "idx", varray());
- ADDFUNC2(POOL_REAL_ARRAY, INT, PoolRealArray, insert, INT, "idx", REAL, "value", varray());
+ ADDFUNC2R(POOL_REAL_ARRAY, INT, PoolRealArray, insert, INT, "idx", REAL, "value", varray());
ADDFUNC1(POOL_REAL_ARRAY, NIL, PoolRealArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_REAL_ARRAY, NIL, PoolRealArray, invert, varray());
- ADDFUNC0(POOL_STRING_ARRAY, INT, PoolStringArray, size, varray());
+ ADDFUNC0R(POOL_STRING_ARRAY, INT, PoolStringArray, size, varray());
ADDFUNC2(POOL_STRING_ARRAY, NIL, PoolStringArray, set, INT, "idx", STRING, "string", varray());
ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, push_back, STRING, "string", varray());
ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, append, STRING, "string", varray());
ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, append_array, POOL_STRING_ARRAY, "array", varray());
ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, remove, INT, "idx", varray());
- ADDFUNC2(POOL_STRING_ARRAY, INT, PoolStringArray, insert, INT, "idx", STRING, "string", varray());
+ ADDFUNC2R(POOL_STRING_ARRAY, INT, PoolStringArray, insert, INT, "idx", STRING, "string", varray());
ADDFUNC1(POOL_STRING_ARRAY, NIL, PoolStringArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_STRING_ARRAY, NIL, PoolStringArray, invert, varray());
ADDFUNC1(POOL_STRING_ARRAY, STRING, PoolStringArray, join, STRING, "delimiter", varray());
- ADDFUNC0(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, size, varray());
+ ADDFUNC0R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, size, varray());
ADDFUNC2(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, set, INT, "idx", VECTOR2, "vector2", varray());
ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, push_back, VECTOR2, "vector2", varray());
ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, append, VECTOR2, "vector2", varray());
ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, append_array, POOL_VECTOR2_ARRAY, "array", varray());
ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, remove, INT, "idx", varray());
- ADDFUNC2(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, insert, INT, "idx", VECTOR2, "vector2", varray());
+ ADDFUNC2R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, insert, INT, "idx", VECTOR2, "vector2", varray());
ADDFUNC1(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, resize, INT, "idx", varray());
ADDFUNC0(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, invert, varray());
- ADDFUNC0(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, size, varray());
+ ADDFUNC0R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, size, varray());
ADDFUNC2(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, set, INT, "idx", VECTOR3, "vector3", varray());
ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, push_back, VECTOR3, "vector3", varray());
ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, append, VECTOR3, "vector3", varray());
ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, append_array, POOL_VECTOR3_ARRAY, "array", varray());
ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, remove, INT, "idx", varray());
- ADDFUNC2(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, insert, INT, "idx", VECTOR3, "vector3", varray());
+ ADDFUNC2R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, insert, INT, "idx", VECTOR3, "vector3", varray());
ADDFUNC1(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, resize, INT, "idx", varray());
ADDFUNC0(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, invert, varray());
- ADDFUNC0(POOL_COLOR_ARRAY, INT, PoolColorArray, size, varray());
+ ADDFUNC0R(POOL_COLOR_ARRAY, INT, PoolColorArray, size, varray());
ADDFUNC2(POOL_COLOR_ARRAY, NIL, PoolColorArray, set, INT, "idx", COLOR, "color", varray());
ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, push_back, COLOR, "color", varray());
ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, append, COLOR, "color", varray());
ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, append_array, POOL_COLOR_ARRAY, "array", varray());
ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, remove, INT, "idx", varray());
- ADDFUNC2(POOL_COLOR_ARRAY, INT, PoolColorArray, insert, INT, "idx", COLOR, "color", varray());
+ ADDFUNC2R(POOL_COLOR_ARRAY, INT, PoolColorArray, insert, INT, "idx", COLOR, "color", varray());
ADDFUNC1(POOL_COLOR_ARRAY, NIL, PoolColorArray, resize, INT, "idx", varray());
ADDFUNC0(POOL_COLOR_ARRAY, NIL, PoolColorArray, invert, varray());
//pointerbased
- ADDFUNC0(RECT3, REAL, Rect3, get_area, varray());
- ADDFUNC0(RECT3, BOOL, Rect3, has_no_area, varray());
- ADDFUNC0(RECT3, BOOL, Rect3, has_no_surface, varray());
- ADDFUNC1(RECT3, BOOL, Rect3, intersects, RECT3, "with", varray());
- ADDFUNC1(RECT3, BOOL, Rect3, encloses, RECT3, "with", varray());
- ADDFUNC1(RECT3, RECT3, Rect3, merge, RECT3, "with", varray());
- ADDFUNC1(RECT3, RECT3, Rect3, intersection, RECT3, "with", varray());
- ADDFUNC1(RECT3, BOOL, Rect3, intersects_plane, PLANE, "plane", varray());
- ADDFUNC2(RECT3, BOOL, Rect3, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray());
- ADDFUNC1(RECT3, BOOL, Rect3, has_point, VECTOR3, "point", varray());
- ADDFUNC1(RECT3, VECTOR3, Rect3, get_support, VECTOR3, "dir", varray());
- ADDFUNC0(RECT3, VECTOR3, Rect3, get_longest_axis, varray());
- ADDFUNC0(RECT3, INT, Rect3, get_longest_axis_index, varray());
- ADDFUNC0(RECT3, REAL, Rect3, get_longest_axis_size, varray());
- ADDFUNC0(RECT3, VECTOR3, Rect3, get_shortest_axis, varray());
- ADDFUNC0(RECT3, INT, Rect3, get_shortest_axis_index, varray());
- ADDFUNC0(RECT3, REAL, Rect3, get_shortest_axis_size, varray());
- ADDFUNC1(RECT3, RECT3, Rect3, expand, VECTOR3, "to_point", varray());
- ADDFUNC1(RECT3, RECT3, Rect3, grow, REAL, "by", varray());
- ADDFUNC1(RECT3, VECTOR3, Rect3, get_endpoint, INT, "idx", varray());
-
- ADDFUNC0(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray());
- ADDFUNC0(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray());
- ADDFUNC0(TRANSFORM2D, REAL, Transform2D, get_rotation, varray());
- ADDFUNC0(TRANSFORM2D, VECTOR2, Transform2D, get_origin, varray());
- ADDFUNC0(TRANSFORM2D, VECTOR2, Transform2D, get_scale, varray());
- ADDFUNC0(TRANSFORM2D, TRANSFORM2D, Transform2D, orthonormalized, varray());
- ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, rotated, REAL, "phi", varray());
- ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, scaled, VECTOR2, "scale", varray());
- ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, translated, VECTOR2, "offset", varray());
- ADDFUNC1(TRANSFORM2D, TRANSFORM2D, Transform2D, xform, NIL, "v", varray());
- 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, "transform", REAL, "weight", varray());
-
- ADDFUNC0(BASIS, BASIS, Basis, inverse, varray());
- ADDFUNC0(BASIS, BASIS, Basis, transposed, varray());
- ADDFUNC0(BASIS, BASIS, Basis, orthonormalized, varray());
- ADDFUNC0(BASIS, REAL, Basis, determinant, varray());
- ADDFUNC2(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray());
- ADDFUNC1(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray());
- ADDFUNC0(BASIS, VECTOR3, Basis, get_scale, varray());
- ADDFUNC0(BASIS, VECTOR3, Basis, get_euler, varray());
- ADDFUNC1(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray());
- ADDFUNC1(BASIS, REAL, Basis, tdoty, VECTOR3, "with", varray());
- ADDFUNC1(BASIS, REAL, Basis, tdotz, VECTOR3, "with", varray());
- ADDFUNC1(BASIS, VECTOR3, Basis, xform, VECTOR3, "v", varray());
- ADDFUNC1(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray());
- ADDFUNC0(BASIS, INT, Basis, get_orthogonal_index, varray());
-
- ADDFUNC0(TRANSFORM, TRANSFORM, Transform, inverse, varray());
- ADDFUNC0(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray());
- ADDFUNC0(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray());
- ADDFUNC2(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", REAL, "phi", varray());
- 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());
-
-#ifdef DEBUG_ENABLED
- _VariantCall::type_funcs[Variant::TRANSFORM].functions["xform"].returns = true;
- _VariantCall::type_funcs[Variant::TRANSFORM].functions["xform_inv"].returns = true;
-#endif
+ ADDFUNC0R(AABB, REAL, AABB, get_area, varray());
+ ADDFUNC0R(AABB, BOOL, AABB, has_no_area, varray());
+ ADDFUNC0R(AABB, BOOL, AABB, has_no_surface, varray());
+ ADDFUNC1R(AABB, BOOL, AABB, intersects, AABB, "with", varray());
+ ADDFUNC1R(AABB, BOOL, AABB, encloses, AABB, "with", varray());
+ ADDFUNC1R(AABB, AABB, AABB, merge, AABB, "with", varray());
+ ADDFUNC1R(AABB, AABB, AABB, intersection, AABB, "with", varray());
+ ADDFUNC1R(AABB, BOOL, AABB, intersects_plane, PLANE, "plane", varray());
+ ADDFUNC2R(AABB, BOOL, AABB, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray());
+ ADDFUNC1R(AABB, BOOL, AABB, has_point, VECTOR3, "point", varray());
+ ADDFUNC1R(AABB, VECTOR3, AABB, get_support, VECTOR3, "dir", varray());
+ ADDFUNC0R(AABB, VECTOR3, AABB, get_longest_axis, varray());
+ ADDFUNC0R(AABB, INT, AABB, get_longest_axis_index, varray());
+ ADDFUNC0R(AABB, REAL, AABB, get_longest_axis_size, varray());
+ ADDFUNC0R(AABB, VECTOR3, AABB, get_shortest_axis, varray());
+ ADDFUNC0R(AABB, INT, AABB, get_shortest_axis_index, varray());
+ ADDFUNC0R(AABB, REAL, AABB, get_shortest_axis_size, varray());
+ ADDFUNC1R(AABB, AABB, AABB, expand, VECTOR3, "to_point", varray());
+ ADDFUNC1R(AABB, AABB, AABB, grow, REAL, "by", varray());
+ ADDFUNC1R(AABB, VECTOR3, AABB, get_endpoint, INT, "idx", varray());
+
+ ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray());
+ ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray());
+ ADDFUNC0R(TRANSFORM2D, REAL, Transform2D, get_rotation, varray());
+ ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_origin, varray());
+ ADDFUNC0R(TRANSFORM2D, VECTOR2, Transform2D, get_scale, varray());
+ ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, orthonormalized, varray());
+ ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, rotated, REAL, "phi", varray());
+ ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, scaled, VECTOR2, "scale", varray());
+ ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, translated, VECTOR2, "offset", varray());
+ ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, xform, NIL, "v", varray());
+ ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, xform_inv, NIL, "v", varray());
+ ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, basis_xform, NIL, "v", varray());
+ ADDFUNC1R(TRANSFORM2D, TRANSFORM2D, Transform2D, basis_xform_inv, NIL, "v", varray());
+ ADDFUNC2R(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", REAL, "weight", varray());
+
+ ADDFUNC0R(BASIS, BASIS, Basis, inverse, varray());
+ ADDFUNC0R(BASIS, BASIS, Basis, transposed, varray());
+ ADDFUNC0R(BASIS, BASIS, Basis, orthonormalized, varray());
+ ADDFUNC0R(BASIS, REAL, Basis, determinant, varray());
+ ADDFUNC2R(BASIS, BASIS, Basis, rotated, VECTOR3, "axis", REAL, "phi", varray());
+ ADDFUNC1R(BASIS, BASIS, Basis, scaled, VECTOR3, "scale", varray());
+ ADDFUNC0R(BASIS, VECTOR3, Basis, get_scale, varray());
+ ADDFUNC0R(BASIS, VECTOR3, Basis, get_euler, varray());
+ ADDFUNC1R(BASIS, REAL, Basis, tdotx, VECTOR3, "with", varray());
+ ADDFUNC1R(BASIS, REAL, Basis, tdoty, VECTOR3, "with", varray());
+ ADDFUNC1R(BASIS, REAL, Basis, tdotz, VECTOR3, "with", varray());
+ ADDFUNC1R(BASIS, VECTOR3, Basis, xform, VECTOR3, "v", varray());
+ ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray());
+ ADDFUNC0R(BASIS, INT, Basis, get_orthogonal_index, varray());
+
+ ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, inverse, varray());
+ ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, affine_inverse, varray());
+ ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, orthonormalized, varray());
+ ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, rotated, VECTOR3, "axis", REAL, "phi", varray());
+ ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, scaled, VECTOR3, "scale", varray());
+ ADDFUNC1R(TRANSFORM, TRANSFORM, Transform, translated, VECTOR3, "ofs", varray());
+ ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, looking_at, VECTOR3, "target", VECTOR3, "up", varray());
+ ADDFUNC2R(TRANSFORM, TRANSFORM, Transform, interpolate_with, TRANSFORM, "transform", REAL, "weight", varray());
+ ADDFUNC1R(TRANSFORM, NIL, Transform, xform, NIL, "v", varray());
+ ADDFUNC1R(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray());
/* REGISTER CONSTRUCTORS */
@@ -1774,7 +1795,7 @@ void register_variant_methods() {
_VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL, "a", Variant::REAL);
_VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL);
- _VariantCall::add_constructor(_VariantCall::Rect3_init1, Variant::RECT3, "position", Variant::VECTOR3, "size", Variant::VECTOR3);
+ _VariantCall::add_constructor(_VariantCall::AABB_init1, Variant::AABB, "position", Variant::VECTOR3, "size", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Basis_init1, Variant::BASIS, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::REAL);
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 03ec336291..c793d70ed8 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -48,7 +48,7 @@
CASE_TYPE(PREFIX, OP, TRANSFORM2D) \
CASE_TYPE(PREFIX, OP, PLANE) \
CASE_TYPE(PREFIX, OP, QUAT) \
- CASE_TYPE(PREFIX, OP, RECT3) \
+ CASE_TYPE(PREFIX, OP, AABB) \
CASE_TYPE(PREFIX, OP, BASIS) \
CASE_TYPE(PREFIX, OP, TRANSFORM) \
CASE_TYPE(PREFIX, OP, COLOR) \
@@ -81,7 +81,7 @@
TYPE(PREFIX, OP, TRANSFORM2D), \
TYPE(PREFIX, OP, PLANE), \
TYPE(PREFIX, OP, QUAT), \
- TYPE(PREFIX, OP, RECT3), \
+ TYPE(PREFIX, OP, AABB), \
TYPE(PREFIX, OP, BASIS), \
TYPE(PREFIX, OP, TRANSFORM), \
TYPE(PREFIX, OP, COLOR), \
@@ -465,7 +465,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR3, ==, Vector3);
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, PLANE, ==, Plane);
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, QUAT, ==, Quat);
- DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, RECT3, ==, _rect3);
+ DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, AABB, ==, _aabb);
DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, BASIS, ==, _basis);
DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, TRANSFORM, ==, _transform);
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, COLOR, ==, Color);
@@ -555,7 +555,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR3, !=, Vector3);
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, PLANE, !=, Plane);
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, QUAT, !=, Quat);
- DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, RECT3, !=, _rect3);
+ DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, AABB, !=, _aabb);
DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, BASIS, !=, _basis);
DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, TRANSFORM, !=, _transform);
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, COLOR, !=, Color);
@@ -629,7 +629,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_LESS, TRANSFORM2D)
CASE_TYPE(math, OP_LESS, PLANE)
CASE_TYPE(math, OP_LESS, QUAT)
- CASE_TYPE(math, OP_LESS, RECT3)
+ CASE_TYPE(math, OP_LESS, AABB)
CASE_TYPE(math, OP_LESS, BASIS)
CASE_TYPE(math, OP_LESS, TRANSFORM)
CASE_TYPE(math, OP_LESS, COLOR)
@@ -658,7 +658,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM2D)
CASE_TYPE(math, OP_LESS_EQUAL, PLANE)
CASE_TYPE(math, OP_LESS_EQUAL, QUAT)
- CASE_TYPE(math, OP_LESS_EQUAL, RECT3)
+ CASE_TYPE(math, OP_LESS_EQUAL, AABB)
CASE_TYPE(math, OP_LESS_EQUAL, BASIS)
CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM)
CASE_TYPE(math, OP_LESS_EQUAL, COLOR)
@@ -733,7 +733,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_GREATER, TRANSFORM2D)
CASE_TYPE(math, OP_GREATER, PLANE)
CASE_TYPE(math, OP_GREATER, QUAT)
- CASE_TYPE(math, OP_GREATER, RECT3)
+ CASE_TYPE(math, OP_GREATER, AABB)
CASE_TYPE(math, OP_GREATER, BASIS)
CASE_TYPE(math, OP_GREATER, TRANSFORM)
CASE_TYPE(math, OP_GREATER, COLOR)
@@ -762,7 +762,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM2D)
CASE_TYPE(math, OP_GREATER_EQUAL, PLANE)
CASE_TYPE(math, OP_GREATER_EQUAL, QUAT)
- CASE_TYPE(math, OP_GREATER_EQUAL, RECT3)
+ CASE_TYPE(math, OP_GREATER_EQUAL, AABB)
CASE_TYPE(math, OP_GREATER_EQUAL, BASIS)
CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM)
CASE_TYPE(math, OP_GREATER_EQUAL, COLOR)
@@ -818,7 +818,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_ADD, RECT2)
CASE_TYPE(math, OP_ADD, TRANSFORM2D)
CASE_TYPE(math, OP_ADD, PLANE)
- CASE_TYPE(math, OP_ADD, RECT3)
+ CASE_TYPE(math, OP_ADD, AABB)
CASE_TYPE(math, OP_ADD, BASIS)
CASE_TYPE(math, OP_ADD, TRANSFORM)
CASE_TYPE(math, OP_ADD, NODE_PATH)
@@ -842,7 +842,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_SUBTRACT, RECT2)
CASE_TYPE(math, OP_SUBTRACT, TRANSFORM2D)
CASE_TYPE(math, OP_SUBTRACT, PLANE)
- CASE_TYPE(math, OP_SUBTRACT, RECT3)
+ CASE_TYPE(math, OP_SUBTRACT, AABB)
CASE_TYPE(math, OP_SUBTRACT, BASIS)
CASE_TYPE(math, OP_SUBTRACT, TRANSFORM)
CASE_TYPE(math, OP_SUBTRACT, NODE_PATH)
@@ -923,7 +923,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_MULTIPLY, STRING)
CASE_TYPE(math, OP_MULTIPLY, RECT2)
CASE_TYPE(math, OP_MULTIPLY, PLANE)
- CASE_TYPE(math, OP_MULTIPLY, RECT3)
+ CASE_TYPE(math, OP_MULTIPLY, AABB)
CASE_TYPE(math, OP_MULTIPLY, NODE_PATH)
CASE_TYPE(math, OP_MULTIPLY, _RID)
CASE_TYPE(math, OP_MULTIPLY, OBJECT)
@@ -964,7 +964,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_DIVIDE, RECT2)
CASE_TYPE(math, OP_DIVIDE, TRANSFORM2D)
CASE_TYPE(math, OP_DIVIDE, PLANE)
- CASE_TYPE(math, OP_DIVIDE, RECT3)
+ CASE_TYPE(math, OP_DIVIDE, AABB)
CASE_TYPE(math, OP_DIVIDE, BASIS)
CASE_TYPE(math, OP_DIVIDE, TRANSFORM)
CASE_TYPE(math, OP_DIVIDE, NODE_PATH)
@@ -995,7 +995,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_POSITIVE, STRING)
CASE_TYPE(math, OP_POSITIVE, RECT2)
CASE_TYPE(math, OP_POSITIVE, TRANSFORM2D)
- CASE_TYPE(math, OP_POSITIVE, RECT3)
+ CASE_TYPE(math, OP_POSITIVE, AABB)
CASE_TYPE(math, OP_POSITIVE, BASIS)
CASE_TYPE(math, OP_POSITIVE, TRANSFORM)
CASE_TYPE(math, OP_POSITIVE, COLOR)
@@ -1029,7 +1029,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_NEGATE, STRING)
CASE_TYPE(math, OP_NEGATE, RECT2)
CASE_TYPE(math, OP_NEGATE, TRANSFORM2D)
- CASE_TYPE(math, OP_NEGATE, RECT3)
+ CASE_TYPE(math, OP_NEGATE, AABB)
CASE_TYPE(math, OP_NEGATE, BASIS)
CASE_TYPE(math, OP_NEGATE, TRANSFORM)
CASE_TYPE(math, OP_NEGATE, NODE_PATH)
@@ -1088,7 +1088,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_MODULE, TRANSFORM2D)
CASE_TYPE(math, OP_MODULE, PLANE)
CASE_TYPE(math, OP_MODULE, QUAT)
- CASE_TYPE(math, OP_MODULE, RECT3)
+ CASE_TYPE(math, OP_MODULE, AABB)
CASE_TYPE(math, OP_MODULE, BASIS)
CASE_TYPE(math, OP_MODULE, TRANSFORM)
CASE_TYPE(math, OP_MODULE, COLOR)
@@ -1384,10 +1384,10 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
}
} break; // 10
- case RECT3: {
+ case AABB: {
if (p_value.type == Variant::VECTOR3) {
- Rect3 *v = _data._rect3;
+ ::AABB *v = _data._aabb;
//scalar name
if (p_index == CoreStringNames::singleton->position) {
v->position = *reinterpret_cast<const Vector3 *>(p_value._data._mem);
@@ -1609,9 +1609,9 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
}
} break; // 10
- case RECT3: {
+ case AABB: {
- const Rect3 *v = _data._rect3;
+ const ::AABB *v = _data._aabb;
//scalar name
if (p_index == CoreStringNames::singleton->position) {
return v->position;
@@ -1655,13 +1655,13 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
} else if (p_index == CoreStringNames::singleton->a) {
return v->a;
} else if (p_index == CoreStringNames::singleton->r8) {
- return v->r * 255.0;
+ return int(v->r * 255.0);
} else if (p_index == CoreStringNames::singleton->g8) {
- return v->g * 255.0;
+ return int(v->g * 255.0);
} else if (p_index == CoreStringNames::singleton->b8) {
- return v->b * 255.0;
+ return int(v->b * 255.0);
} else if (p_index == CoreStringNames::singleton->a8) {
- return v->a * 255.0;
+ return int(v->a * 255.0);
} else if (p_index == CoreStringNames::singleton->h) {
return v->get_h();
} else if (p_index == CoreStringNames::singleton->s) {
@@ -1982,7 +1982,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
} break; // 10
- case RECT3: {
+ case AABB: {
if (p_value.type != Variant::VECTOR3)
return;
@@ -1991,7 +1991,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
- Rect3 *v = _data._rect3;
+ ::AABB *v = _data._aabb;
if (*str == "position") {
valid = true;
v->position = p_value;
@@ -2400,13 +2400,13 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
} break; // 10
- case RECT3: {
+ case AABB: {
if (p_index.get_type() == Variant::STRING) {
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
- const Rect3 *v = _data._rect3;
+ const ::AABB *v = _data._aabb;
if (*str == "position") {
valid = true;
return v->position;
@@ -2835,7 +2835,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::REAL, "w"));
} break; // 10
- case RECT3: {
+ case AABB: {
p_list->push_back(PropertyInfo(Variant::VECTOR3, "position"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "size"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "end"));
@@ -3457,10 +3457,10 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst)
r_dst = *reinterpret_cast<const Vector3 *>(a._data._mem) + *reinterpret_cast<const Vector3 *>(b._data._mem) * c;
}
return;
- case RECT3: {
- const Rect3 *ra = reinterpret_cast<const Rect3 *>(a._data._mem);
- const Rect3 *rb = reinterpret_cast<const Rect3 *>(b._data._mem);
- r_dst = Rect3(ra->position + rb->position * c, ra->size + rb->size * c);
+ case AABB: {
+ const ::AABB *ra = reinterpret_cast<const ::AABB *>(a._data._mem);
+ const ::AABB *rb = reinterpret_cast<const ::AABB *>(b._data._mem);
+ r_dst = ::AABB(ra->position + rb->position * c, ra->size + rb->size * c);
}
return;
case QUAT: {
@@ -3591,8 +3591,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
r_dst = reinterpret_cast<const Quat *>(a._data._mem)->slerp(*reinterpret_cast<const Quat *>(b._data._mem), c);
}
return;
- case RECT3: {
- r_dst = Rect3(a._data._rect3->position.linear_interpolate(b._data._rect3->position, c), a._data._rect3->size.linear_interpolate(b._data._rect3->size, c));
+ case AABB: {
+ r_dst = ::AABB(a._data._aabb->position.linear_interpolate(b._data._aabb->position, c), a._data._aabb->size.linear_interpolate(b._data._aabb->size, c));
}
return;
case BASIS: {
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index d60d10cd3a..1c02c627b5 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -595,7 +595,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = Quat(args[0], args[1], args[2], args[3]);
return OK;
- } else if (id == "Rect3" || id == "AABB") {
+ } else if (id == "AABB" || id == "Rect3") {
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
@@ -606,7 +606,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
r_err_str = "Expected 6 arguments for constructor";
}
- value = Rect3(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5]));
+ value = AABB(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5]));
return OK;
} else if (id == "Basis" || id == "Matrix3") { //compatibility
@@ -1634,10 +1634,10 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, "Plane( " + rtosfix(p.normal.x) + ", " + rtosfix(p.normal.y) + ", " + rtosfix(p.normal.z) + ", " + rtosfix(p.d) + " )");
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
- Rect3 aabb = p_variant;
- p_store_string_func(p_store_string_ud, "Rect3( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )");
+ AABB aabb = p_variant;
+ p_store_string_func(p_store_string_ud, "AABB( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )");
} break;
case Variant::QUAT: {
diff --git a/core/version.h b/core/version.h
index 436f30ef01..b217d82c5d 100644
--- a/core/version.h
+++ b/core/version.h
@@ -30,8 +30,8 @@
#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)
+#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) "." VERSION_STATUS "." VERSION_BUILD VERSION_MODULE_CONFIG
#else
-#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION)
+#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." VERSION_STATUS "." VERSION_BUILD VERSION_MODULE_CONFIG
#endif // VERSION_PATCH
-#define VERSION_FULL_NAME "" _MKSTR(VERSION_NAME) " v" VERSION_MKSTRING
+#define VERSION_FULL_NAME "" VERSION_NAME " v" VERSION_MKSTRING