summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/SCsub4
-rw-r--r--core/bind/core_bind.cpp3
-rw-r--r--core/color.cpp5
-rw-r--r--core/color.h2
-rw-r--r--core/crypto/hashing_context.cpp1
-rw-r--r--core/dictionary.cpp23
-rw-r--r--core/error_macros.cpp10
-rw-r--r--core/error_macros.h27
-rw-r--r--core/image.cpp15
-rw-r--r--core/io/multiplayer_api.cpp11
-rw-r--r--core/math/a_star.cpp76
-rw-r--r--core/math/a_star.h35
-rw-r--r--core/math/aabb.cpp5
-rw-r--r--core/math/aabb.h1
-rw-r--r--core/math/basis.cpp21
-rw-r--r--core/math/basis.h4
-rw-r--r--core/math/bsp_tree.cpp4
-rw-r--r--core/math/delaunay.h4
-rw-r--r--core/math/math_funcs.h2
-rw-r--r--core/math/plane.cpp7
-rw-r--r--core/math/plane.h6
-rw-r--r--core/math/quat.cpp5
-rw-r--r--core/math/quat.h1
-rw-r--r--core/math/quick_hull.cpp2
-rw-r--r--core/math/rect2.cpp5
-rw-r--r--core/math/rect2.h1
-rw-r--r--core/math/transform.cpp5
-rw-r--r--core/math/transform.h1
-rw-r--r--core/math/transform_2d.cpp6
-rw-r--r--core/math/transform_2d.h1
-rw-r--r--core/math/vector2.cpp4
-rw-r--r--core/math/vector2.h6
-rw-r--r--core/math/vector3.cpp5
-rw-r--r--core/math/vector3.h7
-rw-r--r--core/object.cpp2
-rw-r--r--core/os/input_event.cpp34
-rw-r--r--core/os/input_event.h9
-rw-r--r--core/packed_data_container.cpp1
-rw-r--r--core/pool_vector.h7
-rw-r--r--core/project_settings.cpp2
-rw-r--r--core/ref_ptr.cpp8
-rw-r--r--core/ref_ptr.h1
-rw-r--r--core/script_language.cpp1
-rw-r--r--core/translation.cpp3
-rw-r--r--core/ustring.cpp15
-rw-r--r--core/ustring.h1
-rw-r--r--core/variant_call.cpp102
47 files changed, 364 insertions, 137 deletions
diff --git a/core/SCsub b/core/SCsub
index ed9a0a231d..755c5c65c6 100644
--- a/core/SCsub
+++ b/core/SCsub
@@ -80,6 +80,8 @@ if env['builtin_zlib']:
env_thirdparty.Prepend(CPPPATH=[thirdparty_zlib_dir])
# Needs to be available in main env too
env.Prepend(CPPPATH=[thirdparty_zlib_dir])
+ if (env['target'] == 'debug'):
+ env_thirdparty.Append(CPPDEFINES=['ZLIB_DEBUG'])
env_thirdparty.add_source_files(env.core_sources, thirdparty_zlib_sources)
@@ -118,6 +120,8 @@ if env['builtin_zstd']:
"compress/zstd_ldm.c",
"compress/zstd_opt.c",
"compress/zstdmt_compress.c",
+ "compress/zstd_compress_literals.c",
+ "compress/zstd_compress_sequences.c",
"decompress/huf_decompress.c",
"decompress/zstd_ddict.c",
"decompress/zstd_decompress_block.c",
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 1d451b2982..c539f912aa 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -3165,6 +3165,9 @@ Ref<JSONParseResult> _JSON::parse(const String &p_json) {
result->error = JSON::parse(p_json, result->result, result->error_string, result->error_line);
+ if (result->error != OK) {
+ ERR_PRINTS(vformat("Error parsing JSON at line %s: %s", result->error_line, result->error_string));
+ }
return result;
}
diff --git a/core/color.cpp b/core/color.cpp
index a54a3115cc..a6ad50b745 100644
--- a/core/color.cpp
+++ b/core/color.cpp
@@ -214,6 +214,11 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) {
}
}
+bool Color::is_equal_approx(const Color &p_color) const {
+
+ return Math::is_equal_approx(r, p_color.r) && Math::is_equal_approx(g, p_color.g) && Math::is_equal_approx(b, p_color.b) && Math::is_equal_approx(a, p_color.a);
+}
+
void Color::invert() {
r = 1.0 - r;
diff --git a/core/color.h b/core/color.h
index 8fb78d1ced..b34a82ef19 100644
--- a/core/color.h
+++ b/core/color.h
@@ -86,6 +86,8 @@ struct Color {
void operator/=(const Color &p_color);
void operator/=(const real_t &rvalue);
+ bool is_equal_approx(const Color &p_color) const;
+
void invert();
void contrast();
Color inverted() const;
diff --git a/core/crypto/hashing_context.cpp b/core/crypto/hashing_context.cpp
index bd863f546b..b5aa0ddc18 100644
--- a/core/crypto/hashing_context.cpp
+++ b/core/crypto/hashing_context.cpp
@@ -50,6 +50,7 @@ Error HashingContext::start(HashType p_type) {
Error HashingContext::update(PoolByteArray p_chunk) {
ERR_FAIL_COND_V(ctx == NULL, ERR_UNCONFIGURED);
size_t len = p_chunk.size();
+ ERR_FAIL_COND_V(len == 0, FAILED);
PoolByteArray::Read r = p_chunk.read();
switch (type) {
case HASH_MD5:
diff --git a/core/dictionary.cpp b/core/dictionary.cpp
index 5e4dfb9a5a..0d9945991e 100644
--- a/core/dictionary.cpp
+++ b/core/dictionary.cpp
@@ -192,13 +192,9 @@ uint32_t Dictionary::hash() const {
uint32_t h = hash_djb2_one_32(Variant::DICTIONARY);
- List<Variant> keys;
- get_key_list(&keys);
-
- for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
-
- h = hash_djb2_one_32(E->get().hash(), h);
- h = hash_djb2_one_32(operator[](E->get()).hash(), h);
+ for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
+ h = hash_djb2_one_32(E.key().hash(), h);
+ h = hash_djb2_one_32(E.value().hash(), h);
}
return h;
@@ -207,10 +203,11 @@ uint32_t Dictionary::hash() const {
Array Dictionary::keys() const {
Array varr;
- varr.resize(size());
if (_p->variant_map.empty())
return varr;
+ varr.resize(size());
+
int i = 0;
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
varr[i] = E.key();
@@ -223,10 +220,11 @@ Array Dictionary::keys() const {
Array Dictionary::values() const {
Array varr;
- varr.resize(size());
if (_p->variant_map.empty())
return varr;
+ varr.resize(size());
+
int i = 0;
for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
varr[i] = E.get();
@@ -255,11 +253,8 @@ Dictionary Dictionary::duplicate(bool p_deep) const {
Dictionary n;
- List<Variant> keys;
- get_key_list(&keys);
-
- for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
- n[E->get()] = p_deep ? operator[](E->get()).duplicate(p_deep) : operator[](E->get());
+ for (OrderedHashMap<Variant, Variant, VariantHasher, VariantComparator>::Element E = _p->variant_map.front(); E; E = E.next()) {
+ n[E.key()] = p_deep ? E.value().duplicate(true) : E.value();
}
return n;
diff --git a/core/error_macros.cpp b/core/error_macros.cpp
index 0e8e4a9bb4..eda6b9cbbb 100644
--- a/core/error_macros.cpp
+++ b/core/error_macros.cpp
@@ -31,6 +31,7 @@
#include "error_macros.h"
#include "core/io/logger.h"
+#include "core/ustring.h"
#include "os/os.h"
bool _err_error_exists = false;
@@ -42,6 +43,11 @@ void _err_set_last_error(const char *p_err) {
OS::get_singleton()->set_last_error(p_err);
}
+void _err_set_last_error(const String &p_err) {
+
+ _err_set_last_error(p_err.utf8().get_data());
+}
+
void _err_clear_last_error() {
OS::get_singleton()->clear_last_error();
@@ -99,6 +105,10 @@ void _err_print_error(const char *p_function, const char *p_file, int p_line, co
}
}
+void _err_print_error(const char *p_function, const char *p_file, int p_line, const String &p_error, ErrorHandlerType p_type) {
+ _err_print_error(p_function, p_file, p_line, p_error.utf8().get_data(), p_type);
+}
+
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: " : "");
diff --git a/core/error_macros.h b/core/error_macros.h
index 65802de9d2..d4b69ff40d 100644
--- a/core/error_macros.h
+++ b/core/error_macros.h
@@ -55,8 +55,10 @@ enum ErrorHandlerType {
ERR_HANDLER_SHADER,
};
+class String;
typedef void (*ErrorHandlerFunc)(void *, const char *, const char *, int p_line, const char *, const char *, ErrorHandlerType p_type);
void _err_set_last_error(const char *p_err);
+void _err_set_last_error(const String &p_err);
void _err_clear_last_error();
struct ErrorHandlerList {
@@ -77,6 +79,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_error(const char *p_function, const char *p_file, int p_line, const String &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
@@ -98,10 +101,10 @@ extern bool _err_error_exists;
_err_set_last_error(m_reason); \
_err_error_exists = true; \
}
-#define ERR_EXPLAIN(m_string) \
- { \
- _err_set_last_error(String(m_string).utf8().get_data()); \
- _err_error_exists = true; \
+#define ERR_EXPLAIN(m_string) \
+ { \
+ _err_set_last_error(m_string); \
+ _err_error_exists = true; \
}
#else
@@ -430,10 +433,10 @@ extern bool _err_error_exists;
_err_error_exists = false; \
}
-#define ERR_PRINTS(m_string) \
- { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, String(m_string).utf8().get_data()); \
- _err_error_exists = false; \
+#define ERR_PRINTS(m_string) \
+ { \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string); \
+ _err_error_exists = false; \
}
#define ERR_PRINT_ONCE(m_string) \
@@ -455,10 +458,10 @@ extern bool _err_error_exists;
_err_error_exists = false; \
}
-#define WARN_PRINTS(m_string) \
- { \
- _err_print_error(FUNCTION_STR, __FILE__, __LINE__, String(m_string).utf8().get_data(), ERR_HANDLER_WARNING); \
- _err_error_exists = false; \
+#define WARN_PRINTS(m_string) \
+ { \
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, m_string, ERR_HANDLER_WARNING); \
+ _err_error_exists = false; \
}
#define WARN_PRINT_ONCE(m_string) \
diff --git a/core/image.cpp b/core/image.cpp
index e0b0a1f8be..74706535b3 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -885,8 +885,8 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
bool mipmap_aware = p_interpolation == INTERPOLATE_TRILINEAR /* || p_interpolation == INTERPOLATE_TRICUBIC */;
- ERR_FAIL_COND_MSG(p_width <= 0, "Image width cannot be greater than 0.");
- ERR_FAIL_COND_MSG(p_height <= 0, "Image height cannot be greater than 0.");
+ ERR_FAIL_COND_MSG(p_width <= 0, "Image width must be greater than 0.");
+ ERR_FAIL_COND_MSG(p_height <= 0, "Image height must be greater than 0.");
ERR_FAIL_COND_MSG(p_width > MAX_WIDTH, "Image width cannot be greater than " + itos(MAX_WIDTH) + ".");
ERR_FAIL_COND_MSG(p_height > MAX_HEIGHT, "Image height cannot be greater than " + itos(MAX_HEIGHT) + ".");
@@ -1284,8 +1284,8 @@ static void _generate_po2_mipmap(const Component *p_src, Component *p_dst, uint3
Component *dst_ptr = &p_dst[i * dst_w * CC];
uint32_t count = dst_w;
- while (count--) {
-
+ while (count) {
+ count--;
for (int j = 0; j < CC; j++) {
average_func(dst_ptr[j], rup_ptr[j], rup_ptr[j + right_step], rdown_ptr[j], rdown_ptr[j + right_step]);
}
@@ -1322,6 +1322,8 @@ void Image::expand_x2_hq2x() {
PoolVector<uint8_t>::Read r = data.read();
PoolVector<uint8_t>::Write w = dest.write();
+ ERR_FAIL_COND(!r.ptr());
+
hq2x_resize((const uint32_t *)r.ptr(), width, height, (uint32_t *)w.ptr());
}
@@ -1373,6 +1375,7 @@ void Image::shrink_x2() {
int ps = get_format_pixel_size(format);
new_img.resize((width / 2) * (height / 2) * ps);
ERR_FAIL_COND(new_img.size() == 0);
+ ERR_FAIL_COND(data.size() == 0);
{
PoolVector<uint8_t>::Write w = new_img.write();
@@ -2895,6 +2898,8 @@ void Image::bumpmap_to_normalmap(float bump_scale) {
PoolVector<uint8_t>::Read rp = data.read();
PoolVector<uint8_t>::Write wp = result_image.write();
+ ERR_FAIL_COND(!rp.ptr());
+
unsigned char *write_ptr = wp.ptr();
float *read_ptr = (float *)rp.ptr();
@@ -2930,7 +2935,7 @@ void Image::srgb_to_linear() {
if (data.size() == 0)
return;
- static const uint8_t srgb2lin[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 26, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109, 110, 112, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132, 134, 135, 137, 139, 140, 142, 144, 145, 147, 148, 150, 152, 153, 155, 157, 159, 160, 162, 164, 166, 167, 169, 171, 173, 175, 176, 178, 180, 182, 184, 186, 188, 190, 192, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 218, 220, 222, 224, 226, 228, 230, 232, 235, 237, 239, 241, 243, 245, 248, 250, 252 };
+ static const uint8_t srgb2lin[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 22, 22, 23, 23, 24, 24, 25, 26, 26, 27, 27, 28, 29, 29, 30, 31, 31, 32, 33, 33, 34, 35, 36, 36, 37, 38, 38, 39, 40, 41, 42, 42, 43, 44, 45, 46, 47, 47, 48, 49, 50, 51, 52, 53, 54, 55, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 87, 88, 89, 90, 92, 93, 94, 95, 97, 98, 99, 101, 102, 103, 105, 106, 107, 109, 110, 112, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132, 134, 135, 137, 139, 140, 142, 144, 145, 147, 148, 150, 152, 153, 155, 157, 159, 160, 162, 164, 166, 167, 169, 171, 173, 175, 176, 178, 180, 182, 184, 186, 188, 190, 192, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 218, 220, 222, 224, 226, 228, 230, 232, 235, 237, 239, 241, 243, 245, 248, 250, 252, 255 };
ERR_FAIL_COND(format != FORMAT_RGB8 && format != FORMAT_RGBA8);
diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp
index 0ba84d0c8f..1426dbbd4d 100644
--- a/core/io/multiplayer_api.cpp
+++ b/core/io/multiplayer_api.cpp
@@ -602,7 +602,16 @@ void MultiplayerAPI::_add_peer(int p_id) {
void MultiplayerAPI::_del_peer(int p_id) {
connected_peers.erase(p_id);
- path_get_cache.erase(p_id); // I no longer need your cache, sorry.
+ // Cleanup get cache.
+ path_get_cache.erase(p_id);
+ // Cleanup sent cache.
+ // Some refactoring is needed to make this faster and do paths GC.
+ List<NodePath> keys;
+ path_send_cache.get_key_list(&keys);
+ for (List<NodePath>::Element *E = keys.front(); E; E = E->next()) {
+ PathSentCache *psc = path_send_cache.getptr(E->get());
+ psc->confirmed_peers.erase(p_id);
+ }
emit_signal("network_peer_disconnected", p_id);
}
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index ae2b56e7b7..810e290922 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -164,23 +164,23 @@ void AStar::connect_points(int p_id, int p_with_id, bool bidirectional) {
}
Segment s(p_id, p_with_id);
- if (s.from == p_id) {
- s.from_point = a;
- s.to_point = b;
- } else {
- s.from_point = b;
- s.to_point = a;
+ if (bidirectional) s.direction = Segment::BIDIRECTIONAL;
+
+ Set<Segment>::Element *element = segments.find(s);
+ if (element != NULL) {
+ s.direction |= element->get().direction;
+ if (s.direction == Segment::BIDIRECTIONAL) {
+ // Both are neighbours of each other now
+ a->unlinked_neighbours.remove(b->id);
+ b->unlinked_neighbours.remove(a->id);
+ }
+ segments.erase(element);
}
segments.insert(s);
}
-void AStar::disconnect_points(int p_id, int p_with_id) {
-
- Segment s(p_id, p_with_id);
- ERR_FAIL_COND(!segments.has(s));
-
- segments.erase(s);
+void AStar::disconnect_points(int p_id, int p_with_id, bool bidirectional) {
Point *a;
bool a_exists = points.lookup(p_id, a);
@@ -190,10 +190,33 @@ void AStar::disconnect_points(int p_id, int p_with_id) {
bool b_exists = points.lookup(p_with_id, b);
CRASH_COND(!b_exists);
- a->neighbours.remove(b->id);
- a->unlinked_neighbours.remove(b->id);
- b->neighbours.remove(a->id);
- b->unlinked_neighbours.remove(a->id);
+ Segment s(p_id, p_with_id);
+ int remove_direction = bidirectional ? (int)Segment::BIDIRECTIONAL : s.direction;
+
+ Set<Segment>::Element *element = segments.find(s);
+ if (element != NULL) {
+ // s is the new segment
+ // Erase the directions to be removed
+ s.direction = (element->get().direction & ~remove_direction);
+
+ a->neighbours.remove(b->id);
+ if (bidirectional) {
+ b->neighbours.remove(a->id);
+ if (element->get().direction != Segment::BIDIRECTIONAL) {
+ a->unlinked_neighbours.remove(b->id);
+ b->unlinked_neighbours.remove(a->id);
+ }
+ } else {
+ if (s.direction == Segment::NONE)
+ b->unlinked_neighbours.remove(a->id);
+ else
+ a->unlinked_neighbours.set(b->id, b);
+ }
+
+ segments.erase(element);
+ if (s.direction != Segment::NONE)
+ segments.insert(s);
+ }
}
bool AStar::has_point(int p_id) const {
@@ -227,10 +250,13 @@ PoolVector<int> AStar::get_point_connections(int p_id) {
return point_list;
}
-bool AStar::are_points_connected(int p_id, int p_with_id) const {
+bool AStar::are_points_connected(int p_id, int p_with_id, bool bidirectional) const {
Segment s(p_id, p_with_id);
- return segments.has(s);
+ const Set<Segment>::Element *element = segments.find(s);
+
+ return element != NULL &&
+ (bidirectional || (element->get().direction & s.direction) == s.direction);
}
void AStar::clear() {
@@ -284,13 +310,17 @@ Vector3 AStar::get_closest_position_in_segment(const Vector3 &p_point) const {
for (const Set<Segment>::Element *E = segments.front(); E; E = E->next()) {
- if (!(E->get().from_point->enabled && E->get().to_point->enabled)) {
+ Point *from_point = nullptr, *to_point = nullptr;
+ points.lookup(E->get().u, from_point);
+ points.lookup(E->get().v, to_point);
+
+ if (!(from_point->enabled && to_point->enabled)) {
continue;
}
Vector3 segment[2] = {
- E->get().from_point->pos,
- E->get().to_point->pos,
+ from_point->pos,
+ to_point->pos,
};
Vector3 p = Geometry::get_closest_point_to_segment(p_point, segment);
@@ -532,8 +562,8 @@ void AStar::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_point_disabled", "id"), &AStar::is_point_disabled);
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);
+ ClassDB::bind_method(D_METHOD("disconnect_points", "id", "to_id", "bidirectional"), &AStar::disconnect_points, DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("are_points_connected", "id", "to_id", "bidirectional"), &AStar::are_points_connected, DEFVAL(true));
ClassDB::bind_method(D_METHOD("get_point_count"), &AStar::get_point_count);
ClassDB::bind_method(D_METHOD("get_point_capacity"), &AStar::get_point_capacity);
diff --git a/core/math/a_star.h b/core/math/a_star.h
index 0a5d3e992c..8ff62e646b 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -81,24 +81,35 @@ class AStar : public Reference {
struct Segment {
union {
struct {
- int32_t from;
- int32_t to;
+ int32_t u;
+ int32_t v;
};
uint64_t key;
};
- Point *from_point;
- Point *to_point;
+ enum {
+ NONE = 0,
+ FORWARD = 1,
+ BACKWARD = 2,
+ BIDIRECTIONAL = FORWARD | BACKWARD
+ };
+ unsigned char direction;
bool operator<(const Segment &p_s) const { return key < p_s.key; }
- Segment() { key = 0; }
+ Segment() {
+ key = 0;
+ direction = NONE;
+ }
Segment(int p_from, int p_to) {
- if (p_from > p_to) {
- SWAP(p_from, p_to);
+ if (p_from < p_to) {
+ u = p_from;
+ v = p_to;
+ direction = FORWARD;
+ } else {
+ u = p_to;
+ v = p_from;
+ direction = BACKWARD;
}
-
- from = p_from;
- to = p_to;
}
};
@@ -133,8 +144,8 @@ public:
bool is_point_disabled(int p_id) const;
void connect_points(int p_id, int p_with_id, bool bidirectional = true);
- void disconnect_points(int p_id, int p_with_id);
- bool are_points_connected(int p_id, int p_with_id) const;
+ void disconnect_points(int p_id, int p_with_id, bool bidirectional = true);
+ bool are_points_connected(int p_id, int p_with_id, bool bidirectional = true) const;
int get_point_count() const;
int get_point_capacity() const;
diff --git a/core/math/aabb.cpp b/core/math/aabb.cpp
index a4eb1fe2a5..27da061274 100644
--- a/core/math/aabb.cpp
+++ b/core/math/aabb.cpp
@@ -69,6 +69,11 @@ void AABB::merge_with(const AABB &p_aabb) {
size = max - min;
}
+bool AABB::is_equal_approx(const AABB &p_aabb) const {
+
+ return position.is_equal_approx(p_aabb.position) && size.is_equal_approx(p_aabb.size);
+}
+
AABB AABB::intersection(const AABB &p_aabb) const {
Vector3 src_min = position;
diff --git a/core/math/aabb.h b/core/math/aabb.h
index 52e5ed3626..c3ce33c6f4 100644
--- a/core/math/aabb.h
+++ b/core/math/aabb.h
@@ -64,6 +64,7 @@ public:
bool operator==(const AABB &p_rval) const;
bool operator!=(const AABB &p_rval) const;
+ bool is_equal_approx(const AABB &p_aabb) const;
_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
diff --git a/core/math/basis.cpp b/core/math/basis.cpp
index 0a491010e2..d77501c0f6 100644
--- a/core/math/basis.cpp
+++ b/core/math/basis.cpp
@@ -106,17 +106,17 @@ Basis Basis::orthonormalized() const {
}
bool Basis::is_orthogonal() const {
- Basis id;
+ Basis identity;
Basis m = (*this) * transposed();
- return is_equal_approx(id, m);
+ return m.is_equal_approx(identity);
}
bool Basis::is_diagonal() const {
return (
- Math::is_equal_approx(elements[0][1], 0) && Math::is_equal_approx(elements[0][2], 0) &&
- Math::is_equal_approx(elements[1][0], 0) && Math::is_equal_approx(elements[1][2], 0) &&
- Math::is_equal_approx(elements[2][0], 0) && Math::is_equal_approx(elements[2][1], 0));
+ Math::is_zero_approx(elements[0][1]) && Math::is_zero_approx(elements[0][2]) &&
+ Math::is_zero_approx(elements[1][0]) && Math::is_zero_approx(elements[1][2]) &&
+ Math::is_zero_approx(elements[2][0]) && Math::is_zero_approx(elements[2][1]));
}
bool Basis::is_rotation() const {
@@ -557,16 +557,9 @@ void Basis::set_euler_yxz(const Vector3 &p_euler) {
*this = ymat * xmat * zmat;
}
-bool Basis::is_equal_approx(const Basis &a, const Basis &b, real_t p_epsilon) const {
+bool Basis::is_equal_approx(const Basis &p_basis) const {
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- if (!Math::is_equal_approx(a.elements[i][j], b.elements[i][j], p_epsilon))
- return false;
- }
- }
-
- return true;
+ return elements[0].is_equal_approx(p_basis.elements[0]) && elements[1].is_equal_approx(p_basis.elements[1]) && elements[2].is_equal_approx(p_basis.elements[2]);
}
bool Basis::is_equal_approx_ratio(const Basis &a, const Basis &b, real_t p_epsilon) const {
diff --git a/core/math/basis.h b/core/math/basis.h
index 4be4ea4cd3..9b2e38b3d3 100644
--- a/core/math/basis.h
+++ b/core/math/basis.h
@@ -127,7 +127,9 @@ public:
return elements[0][2] * v[0] + elements[1][2] * v[1] + elements[2][2] * v[2];
}
- bool is_equal_approx(const Basis &a, const Basis &b, real_t p_epsilon = CMP_EPSILON) const;
+ bool is_equal_approx(const Basis &p_basis) const;
+ // TODO: Break compatibility in 4.0 by getting rid of this so that it's only an instance method. See also TODO in variant_call.cpp
+ bool is_equal_approx(const Basis &a, const Basis &b) const { return a.is_equal_approx(b); }
bool is_equal_approx_ratio(const Basis &a, const Basis &b, real_t p_epsilon = UNIT_EPSILON) const;
bool operator==(const Basis &p_matrix) const;
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index cfa698282e..ece293d036 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -364,7 +364,7 @@ static int _bsp_create_node(const Face3 *p_faces, const Vector<int> &p_indices,
const Face3 &f = p_faces[indices[i]];
/*
- if (f.get_plane().is_almost_like(divisor_plane))
+ if (f.get_plane().is_equal_approx(divisor_plane))
continue;
*/
@@ -412,7 +412,7 @@ static int _bsp_create_node(const Face3 *p_faces, const Vector<int> &p_indices,
for (int i = 0; i < p_planes.size(); i++) {
- if (p_planes[i].is_almost_like(divisor_plane)) {
+ if (p_planes[i].is_equal_approx(divisor_plane)) {
divisor_plane_idx = i;
break;
}
diff --git a/core/math/delaunay.h b/core/math/delaunay.h
index 3f8013a3e6..89a34de082 100644
--- a/core/math/delaunay.h
+++ b/core/math/delaunay.h
@@ -80,11 +80,11 @@ public:
}
static bool edge_compare(const Vector<Vector2> &p_vertices, const Edge &p_a, const Edge &p_b) {
- if (p_vertices[p_a.edge[0]] == p_vertices[p_b.edge[0]] && p_vertices[p_a.edge[1]] == p_vertices[p_b.edge[1]]) {
+ if (p_vertices[p_a.edge[0]].is_equal_approx(p_vertices[p_b.edge[0]]) && p_vertices[p_a.edge[1]].is_equal_approx(p_vertices[p_b.edge[1]])) {
return true;
}
- if (p_vertices[p_a.edge[0]] == p_vertices[p_b.edge[1]] && p_vertices[p_a.edge[1]] == p_vertices[p_b.edge[0]]) {
+ if (p_vertices[p_a.edge[0]].is_equal_approx(p_vertices[p_b.edge[1]]) && p_vertices[p_a.edge[1]].is_equal_approx(p_vertices[p_b.edge[0]])) {
return true;
}
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 9078abea68..a94b27fcc5 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -472,7 +472,7 @@ public:
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) {
+ static _ALWAYS_INLINE_ float snap_scalar_separation(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;
diff --git a/core/math/plane.cpp b/core/math/plane.cpp
index b6bcac4b27..d55957cd0a 100644
--- a/core/math/plane.cpp
+++ b/core/math/plane.cpp
@@ -32,9 +32,6 @@
#include "core/math/math_funcs.h"
-#define _PLANE_EQ_DOT_EPSILON 0.999
-#define _PLANE_EQ_D_EPSILON 0.0001
-
void Plane::set_normal(const Vector3 &p_normal) {
normal = p_normal;
@@ -156,9 +153,9 @@ bool Plane::intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vec
/* misc */
-bool Plane::is_almost_like(const Plane &p_plane) const {
+bool Plane::is_equal_approx(const Plane &p_plane) const {
- return (normal.dot(p_plane.normal) > _PLANE_EQ_DOT_EPSILON && Math::absd(d - p_plane.d) < _PLANE_EQ_D_EPSILON);
+ return normal.is_equal_approx(p_plane.normal) && Math::is_equal_approx(d, p_plane.d);
}
Plane::operator String() const {
diff --git a/core/math/plane.h b/core/math/plane.h
index ec817edd2c..9abf24fbba 100644
--- a/core/math/plane.h
+++ b/core/math/plane.h
@@ -68,7 +68,7 @@ public:
/* misc */
Plane operator-() const { return Plane(-normal, -d); }
- bool is_almost_like(const Plane &p_plane) const;
+ bool is_equal_approx(const Plane &p_plane) const;
_FORCE_INLINE_ bool operator==(const Plane &p_plane) const;
_FORCE_INLINE_ bool operator!=(const Plane &p_plane) const;
@@ -125,12 +125,12 @@ Plane::Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_
bool Plane::operator==(const Plane &p_plane) const {
- return normal == p_plane.normal && Math::is_equal_approx(d, p_plane.d);
+ return normal == p_plane.normal && d == p_plane.d;
}
bool Plane::operator!=(const Plane &p_plane) const {
- return normal != p_plane.normal || !Math::is_equal_approx(d, p_plane.d);
+ return normal != p_plane.normal || d != p_plane.d;
}
#endif // PLANE_H
diff --git a/core/math/quat.cpp b/core/math/quat.cpp
index 1a67be7384..a4f91844b9 100644
--- a/core/math/quat.cpp
+++ b/core/math/quat.cpp
@@ -121,6 +121,11 @@ Quat Quat::operator*(const Quat &q) const {
return r;
}
+bool Quat::is_equal_approx(const Quat &p_quat) const {
+
+ return Math::is_equal_approx(x, p_quat.x) && Math::is_equal_approx(y, p_quat.y) && Math::is_equal_approx(z, p_quat.z) && Math::is_equal_approx(w, p_quat.w);
+}
+
real_t Quat::length() const {
return Math::sqrt(length_squared());
diff --git a/core/math/quat.h b/core/math/quat.h
index 3d6602e466..27885f4152 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -43,6 +43,7 @@ public:
real_t x, y, z, w;
_FORCE_INLINE_ real_t length_squared() const;
+ bool is_equal_approx(const Quat &p_quat) const;
real_t length() const;
void normalize();
Quat normalized() const;
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index fc2eb1454d..f71f00afd6 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -401,7 +401,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
ERR_CONTINUE(O == E);
ERR_CONTINUE(O == NULL);
- if (O->get().plane.is_almost_like(f.plane)) {
+ if (O->get().plane.is_equal_approx(f.plane)) {
//merge and delete edge and contiguous face, while repointing edges (uuugh!)
int ois = O->get().indices.size();
int merged = 0;
diff --git a/core/math/rect2.cpp b/core/math/rect2.cpp
index fea128afbd..e31776672e 100644
--- a/core/math/rect2.cpp
+++ b/core/math/rect2.cpp
@@ -30,6 +30,11 @@
#include "core/math/transform_2d.h" // Includes rect2.h but Rect2 needs Transform2D
+bool Rect2::is_equal_approx(const Rect2 &p_rect) const {
+
+ return position.is_equal_approx(p_rect.position) && size.is_equal_approx(p_rect.size);
+}
+
bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_pos, Point2 *r_normal) const {
real_t min = 0, max = 1;
diff --git a/core/math/rect2.h b/core/math/rect2.h
index f58756ee40..71221ffb1b 100644
--- a/core/math/rect2.h
+++ b/core/math/rect2.h
@@ -153,6 +153,7 @@ struct Rect2 {
return true;
}
+ bool is_equal_approx(const Rect2 &p_rect) const;
bool operator==(const Rect2 &p_rect) const { return position == p_rect.position && size == p_rect.size; }
bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; }
diff --git a/core/math/transform.cpp b/core/math/transform.cpp
index 4056975da8..5dcc6ab9f0 100644
--- a/core/math/transform.cpp
+++ b/core/math/transform.cpp
@@ -182,6 +182,11 @@ Transform Transform::orthonormalized() const {
return _copy;
}
+bool Transform::is_equal_approx(const Transform &p_transform) const {
+
+ return basis.is_equal_approx(p_transform.basis) && origin.is_equal_approx(p_transform.origin);
+}
+
bool Transform::operator==(const Transform &p_transform) const {
return (basis == p_transform.basis && origin == p_transform.origin);
diff --git a/core/math/transform.h b/core/math/transform.h
index 90e2b07583..da65a183cf 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -70,6 +70,7 @@ public:
void orthonormalize();
Transform orthonormalized() const;
+ bool is_equal_approx(const Transform &p_transform) const;
bool operator==(const Transform &p_transform) const;
bool operator!=(const Transform &p_transform) const;
diff --git a/core/math/transform_2d.cpp b/core/math/transform_2d.cpp
index 1d0387bd45..a1c0814637 100644
--- a/core/math/transform_2d.cpp
+++ b/core/math/transform_2d.cpp
@@ -147,6 +147,7 @@ void Transform2D::orthonormalize() {
elements[0] = x;
elements[1] = y;
}
+
Transform2D Transform2D::orthonormalized() const {
Transform2D on = *this;
@@ -154,6 +155,11 @@ Transform2D Transform2D::orthonormalized() const {
return on;
}
+bool Transform2D::is_equal_approx(const Transform2D &p_transform) const {
+
+ return elements[0].is_equal_approx(p_transform.elements[0]) && elements[1].is_equal_approx(p_transform.elements[1]) && elements[2].is_equal_approx(p_transform.elements[2]);
+}
+
bool Transform2D::operator==(const Transform2D &p_transform) const {
for (int i = 0; i < 3; i++) {
diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h
index e8b44ab197..0ec39a1765 100644
--- a/core/math/transform_2d.h
+++ b/core/math/transform_2d.h
@@ -96,6 +96,7 @@ struct Transform2D {
void orthonormalize();
Transform2D orthonormalized() const;
+ bool is_equal_approx(const Transform2D &p_transform) const;
bool operator==(const Transform2D &p_transform) const;
bool operator!=(const Transform2D &p_transform) const;
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp
index 972bccc0ac..fbedeb8eb2 100644
--- a/core/math/vector2.cpp
+++ b/core/math/vector2.cpp
@@ -203,6 +203,10 @@ Vector2 Vector2::reflect(const Vector2 &p_normal) const {
return 2.0 * p_normal * this->dot(p_normal) - *this;
}
+bool Vector2::is_equal_approx(const Vector2 &p_v) const {
+ return Math::is_equal_approx(x, p_v.x) && Math::is_equal_approx(y, p_v.y);
+}
+
/* Vector2i */
Vector2i Vector2i::operator+(const Vector2i &p_v) const {
diff --git a/core/math/vector2.h b/core/math/vector2.h
index 1a73831891..7fcaadab00 100644
--- a/core/math/vector2.h
+++ b/core/math/vector2.h
@@ -92,6 +92,8 @@ struct Vector2 {
Vector2 bounce(const Vector2 &p_normal) const;
Vector2 reflect(const Vector2 &p_normal) const;
+ bool is_equal_approx(const Vector2 &p_v) const;
+
Vector2 operator+(const Vector2 &p_v) const;
void operator+=(const Vector2 &p_v);
Vector2 operator-(const Vector2 &p_v) const;
@@ -221,11 +223,11 @@ _FORCE_INLINE_ Vector2 Vector2::operator-() const {
_FORCE_INLINE_ bool Vector2::operator==(const Vector2 &p_vec2) const {
- return Math::is_equal_approx(x, p_vec2.x) && Math::is_equal_approx(y, p_vec2.y);
+ return x == p_vec2.x && y == p_vec2.y;
}
_FORCE_INLINE_ bool Vector2::operator!=(const Vector2 &p_vec2) const {
- return !Math::is_equal_approx(x, p_vec2.x) || !Math::is_equal_approx(y, p_vec2.y);
+ return x != p_vec2.x || y != p_vec2.y;
}
Vector2 Vector2::linear_interpolate(const Vector2 &p_b, real_t p_t) const {
diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp
index ebc1599820..e3211c8fb1 100644
--- a/core/math/vector3.cpp
+++ b/core/math/vector3.cpp
@@ -149,6 +149,11 @@ Basis Vector3::to_diagonal_matrix() const {
0, 0, z);
}
+bool Vector3::is_equal_approx(const Vector3 &p_v) const {
+
+ return Math::is_equal_approx(x, p_v.x) && Math::is_equal_approx(y, p_v.y) && Math::is_equal_approx(z, p_v.z);
+}
+
Vector3::operator String() const {
return (rtos(x) + ", " + rtos(y) + ", " + rtos(z));
diff --git a/core/math/vector3.h b/core/math/vector3.h
index de1743d88f..43fa09ffac 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -119,6 +119,8 @@ struct Vector3 {
_FORCE_INLINE_ Vector3 bounce(const Vector3 &p_normal) const;
_FORCE_INLINE_ Vector3 reflect(const Vector3 &p_normal) const;
+ bool is_equal_approx(const Vector3 &p_v) const;
+
/* Operators */
_FORCE_INLINE_ Vector3 &operator+=(const Vector3 &p_v);
@@ -330,11 +332,12 @@ Vector3 Vector3::operator-() const {
bool Vector3::operator==(const Vector3 &p_v) const {
- return (Math::is_equal_approx(x, p_v.x) && Math::is_equal_approx(y, p_v.y) && Math::is_equal_approx(z, p_v.z));
+ return x == p_v.x && y == p_v.y && z == p_v.z;
}
bool Vector3::operator!=(const Vector3 &p_v) const {
- return (!Math::is_equal_approx(x, p_v.x) || !Math::is_equal_approx(y, p_v.y) || !Math::is_equal_approx(z, p_v.z));
+
+ return x != p_v.x || y != p_v.y || z != p_v.z;
}
bool Vector3::operator<(const Vector3 &p_v) const {
diff --git a/core/object.cpp b/core/object.cpp
index 6facf38733..ed3ae4f25d 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -436,7 +436,7 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
} else if (p_name == CoreStringNames::get_singleton()->_meta) {
//set_meta(p_name,p_value);
- metadata = p_value;
+ metadata = p_value.duplicate();
if (r_valid)
*r_valid = true;
return;
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 831aa60d66..8f1eb93fe6 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -557,10 +557,31 @@ InputEventMouseButton::InputEventMouseButton() {
////////////////////////////////////////////
+void InputEventMouseMotion::set_tilt(const Vector2 &p_tilt) {
+
+ tilt = p_tilt;
+}
+
+Vector2 InputEventMouseMotion::get_tilt() const {
+
+ return tilt;
+}
+
+void InputEventMouseMotion::set_pressure(float p_pressure) {
+
+ pressure = p_pressure;
+}
+
+float InputEventMouseMotion::get_pressure() const {
+
+ return pressure;
+}
+
void InputEventMouseMotion::set_relative(const Vector2 &p_relative) {
relative = p_relative;
}
+
Vector2 InputEventMouseMotion::get_relative() const {
return relative;
@@ -570,6 +591,7 @@ void InputEventMouseMotion::set_speed(const Vector2 &p_speed) {
speed = p_speed;
}
+
Vector2 InputEventMouseMotion::get_speed() const {
return speed;
@@ -590,6 +612,8 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co
mm->set_modifiers_from_event(this);
mm->set_position(l);
+ mm->set_pressure(get_pressure());
+ mm->set_tilt(get_tilt());
mm->set_global_position(g);
mm->set_button_mask(get_button_mask());
@@ -665,17 +689,27 @@ bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) {
void InputEventMouseMotion::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_tilt", "tilt"), &InputEventMouseMotion::set_tilt);
+ ClassDB::bind_method(D_METHOD("get_tilt"), &InputEventMouseMotion::get_tilt);
+
+ ClassDB::bind_method(D_METHOD("set_pressure", "pressure"), &InputEventMouseMotion::set_pressure);
+ ClassDB::bind_method(D_METHOD("get_pressure"), &InputEventMouseMotion::get_pressure);
+
ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventMouseMotion::set_relative);
ClassDB::bind_method(D_METHOD("get_relative"), &InputEventMouseMotion::get_relative);
ClassDB::bind_method(D_METHOD("set_speed", "speed"), &InputEventMouseMotion::set_speed);
ClassDB::bind_method(D_METHOD("get_speed"), &InputEventMouseMotion::get_speed);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "tilt"), "set_tilt", "get_tilt");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "pressure"), "set_pressure", "get_pressure");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed");
}
InputEventMouseMotion::InputEventMouseMotion() {
+
+ pressure = 0;
}
////////////////////////////////////////
diff --git a/core/os/input_event.h b/core/os/input_event.h
index 6b49d1fa20..a4db618bfe 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -351,6 +351,9 @@ public:
class InputEventMouseMotion : public InputEventMouse {
GDCLASS(InputEventMouseMotion, InputEventMouse);
+
+ Vector2 tilt;
+ float pressure;
Vector2 relative;
Vector2 speed;
@@ -358,6 +361,12 @@ protected:
static void _bind_methods();
public:
+ void set_tilt(const Vector2 &p_tilt);
+ Vector2 get_tilt() const;
+
+ void set_pressure(float p_pressure);
+ float get_pressure() const;
+
void set_relative(const Vector2 &p_relative);
Vector2 get_relative() const;
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index 003e7e7428..7afaf7f0f1 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -137,6 +137,7 @@ uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const {
int PackedDataContainer::_size(uint32_t p_ofs) const {
PoolVector<uint8_t>::Read rd = data.read();
+ ERR_FAIL_COND_V(!rd.ptr(), 0);
const uint8_t *r = &rd[p_ofs];
uint32_t type = decode_uint32(r);
diff --git a/core/pool_vector.h b/core/pool_vector.h
index fbd4d630be..a698e72e18 100644
--- a/core/pool_vector.h
+++ b/core/pool_vector.h
@@ -385,6 +385,7 @@ public:
}
inline int size() const;
+ inline bool empty() const;
T get(int p_index) const;
void set(int p_index, const T &p_val);
void push_back(const T &p_val);
@@ -475,6 +476,12 @@ int PoolVector<T>::size() const {
}
template <class T>
+bool PoolVector<T>::empty() const {
+
+ return alloc ? alloc->size == 0 : true;
+}
+
+template <class T>
T PoolVector<T>::get(int p_index) const {
return operator[](p_index);
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index c2241ed926..7704c7b377 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -107,7 +107,7 @@ String ProjectSettings::localize_path(const String &p_path) const {
if (plocal == "") {
return "";
};
- return plocal + path.substr(sep, path.size() - sep);
+ return plocal + path.substr((sep + 1), path.size() - (sep + 1));
};
}
diff --git a/core/ref_ptr.cpp b/core/ref_ptr.cpp
index 961f143e5c..6da73ca41a 100644
--- a/core/ref_ptr.cpp
+++ b/core/ref_ptr.cpp
@@ -49,6 +49,14 @@ bool RefPtr::operator==(const RefPtr &p_other) const {
return *ref == *ref_other;
}
+bool RefPtr::operator!=(const RefPtr &p_other) const {
+
+ Ref<Reference> *ref = reinterpret_cast<Ref<Reference> *>(&data[0]);
+ Ref<Reference> *ref_other = reinterpret_cast<Ref<Reference> *>(const_cast<char *>(&p_other.data[0]));
+
+ return *ref != *ref_other;
+}
+
RefPtr::RefPtr(const RefPtr &p_other) {
memnew_placement(&data[0], Ref<Reference>);
diff --git a/core/ref_ptr.h b/core/ref_ptr.h
index f745ababa1..320cf35609 100644
--- a/core/ref_ptr.h
+++ b/core/ref_ptr.h
@@ -50,6 +50,7 @@ public:
bool is_null() const;
void operator=(const RefPtr &p_other);
bool operator==(const RefPtr &p_other) const;
+ bool operator!=(const RefPtr &p_other) const;
RID get_rid() const;
void unref();
_FORCE_INLINE_ void *get_data() const { return data; }
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 7201773ea5..cbe4681eca 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -218,6 +218,7 @@ void ScriptServer::global_classes_clear() {
}
void ScriptServer::add_global_class(const StringName &p_class, const StringName &p_base, const StringName &p_language, const String &p_path) {
+ ERR_FAIL_COND_MSG(p_class == p_base || (global_classes.has(p_base) && get_global_class_native_base(p_base) == p_class), "Cyclic inheritance in script class.");
GlobalScriptClass g;
g.language = p_language;
g.path = p_path;
diff --git a/core/translation.cpp b/core/translation.cpp
index a0902d71fc..4a1ac26433 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -986,6 +986,7 @@ Array TranslationServer::get_loaded_locales() const {
for (const Set<Ref<Translation> >::Element *E = translations.front(); E; E = E->next()) {
const Ref<Translation> &t = E->get();
+ ERR_FAIL_COND_V(t.is_null(), Array());
String l = t->get_locale();
locales.push_back(l);
@@ -1057,6 +1058,7 @@ StringName TranslationServer::translate(const StringName &p_message) const {
for (const Set<Ref<Translation> >::Element *E = translations.front(); E; E = E->next()) {
const Ref<Translation> &t = E->get();
+ ERR_FAIL_COND_V(t.is_null(), StringName(""));
String l = t->get_locale();
if (lptr[0] != l[0] || lptr[1] != l[1])
continue; // Language code does not match.
@@ -1085,6 +1087,7 @@ StringName TranslationServer::translate(const StringName &p_message) const {
for (const Set<Ref<Translation> >::Element *E = translations.front(); E; E = E->next()) {
const Ref<Translation> &t = E->get();
+ ERR_FAIL_COND_V(t.is_null(), StringName(""));
String l = t->get_locale();
if (fptr[0] != l[0] || fptr[1] != l[1])
continue; // Language code does not match.
diff --git a/core/ustring.cpp b/core/ustring.cpp
index f029ae4200..7850c6774c 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -1337,7 +1337,17 @@ String String::num_scientific(double p_num) {
char buf[256];
#if defined(__GNUC__) || defined(_MSC_VER)
+
+#if (defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900)) && defined(_TWO_DIGIT_EXPONENT)
+ // MinGW and old MSC require _set_output_format() to conform to C99 output for printf
+ unsigned int old_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT);
+#endif
snprintf(buf, 256, "%lg", p_num);
+
+#if (defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900)) && defined(_TWO_DIGIT_EXPONENT)
+ _set_output_format(old_exponent_format);
+#endif
+
#else
sprintf(buf, "%.16lg", p_num);
#endif
@@ -4058,6 +4068,11 @@ String itos(int64_t p_val) {
return String::num_int64(p_val);
}
+String uitos(uint64_t p_val) {
+
+ return String::num_uint64(p_val);
+}
+
String rtos(double p_val) {
return String::num(p_val);
diff --git a/core/ustring.h b/core/ustring.h
index 15e2c07d9f..dfc5044942 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -369,6 +369,7 @@ String operator+(const char *p_chr, const String &p_str);
String operator+(CharType p_chr, const String &p_str);
String itos(int64_t p_val);
+String uitos(uint64_t p_val);
String rtos(double p_val);
String rtoss(double p_val); //scientific version
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 40b944744b..6e593a308d 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -351,12 +351,13 @@ struct _VariantCall {
r_ret = retval;
}
- VCALL_LOCALMEM0R(Vector2, normalized);
+ VCALL_LOCALMEM1R(Vector2, distance_to);
+ VCALL_LOCALMEM1R(Vector2, distance_squared_to);
VCALL_LOCALMEM0R(Vector2, length);
VCALL_LOCALMEM0R(Vector2, length_squared);
+ VCALL_LOCALMEM0R(Vector2, normalized);
VCALL_LOCALMEM0R(Vector2, is_normalized);
- VCALL_LOCALMEM1R(Vector2, distance_to);
- VCALL_LOCALMEM1R(Vector2, distance_squared_to);
+ VCALL_LOCALMEM1R(Vector2, is_equal_approx);
VCALL_LOCALMEM1R(Vector2, posmod);
VCALL_LOCALMEM1R(Vector2, posmodv);
VCALL_LOCALMEM1R(Vector2, project);
@@ -385,24 +386,28 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Vector2, sign);
VCALL_LOCALMEM0R(Rect2, get_area);
+ VCALL_LOCALMEM0R(Rect2, has_no_area);
+ VCALL_LOCALMEM1R(Rect2, has_point);
+ VCALL_LOCALMEM1R(Rect2, is_equal_approx);
VCALL_LOCALMEM1R(Rect2, intersects);
VCALL_LOCALMEM1R(Rect2, encloses);
- VCALL_LOCALMEM0R(Rect2, has_no_area);
VCALL_LOCALMEM1R(Rect2, clip);
VCALL_LOCALMEM1R(Rect2, merge);
- VCALL_LOCALMEM1R(Rect2, has_point);
+ VCALL_LOCALMEM1R(Rect2, expand);
VCALL_LOCALMEM1R(Rect2, grow);
VCALL_LOCALMEM2R(Rect2, grow_margin);
VCALL_LOCALMEM4R(Rect2, grow_individual);
- VCALL_LOCALMEM1R(Rect2, expand);
VCALL_LOCALMEM0R(Rect2, abs);
VCALL_LOCALMEM0R(Vector3, min_axis);
VCALL_LOCALMEM0R(Vector3, max_axis);
+ VCALL_LOCALMEM1R(Vector3, distance_to);
+ VCALL_LOCALMEM1R(Vector3, distance_squared_to);
VCALL_LOCALMEM0R(Vector3, length);
VCALL_LOCALMEM0R(Vector3, length_squared);
- VCALL_LOCALMEM0R(Vector3, is_normalized);
VCALL_LOCALMEM0R(Vector3, normalized);
+ VCALL_LOCALMEM0R(Vector3, is_normalized);
+ VCALL_LOCALMEM1R(Vector3, is_equal_approx);
VCALL_LOCALMEM0R(Vector3, inverse);
VCALL_LOCALMEM1R(Vector3, snapped);
VCALL_LOCALMEM2R(Vector3, rotated);
@@ -418,8 +423,6 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Vector3, floor);
VCALL_LOCALMEM0R(Vector3, ceil);
VCALL_LOCALMEM0R(Vector3, round);
- VCALL_LOCALMEM1R(Vector3, distance_to);
- VCALL_LOCALMEM1R(Vector3, distance_squared_to);
VCALL_LOCALMEM1R(Vector3, posmod);
VCALL_LOCALMEM1R(Vector3, posmodv);
VCALL_LOCALMEM1R(Vector3, project);
@@ -433,6 +436,7 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Plane, normalized);
VCALL_LOCALMEM0R(Plane, center);
VCALL_LOCALMEM0R(Plane, get_any_point);
+ VCALL_LOCALMEM1R(Plane, is_equal_approx);
VCALL_LOCALMEM1R(Plane, is_point_over);
VCALL_LOCALMEM1R(Plane, distance_to);
VCALL_LOCALMEM2R(Plane, has_point);
@@ -467,6 +471,7 @@ struct _VariantCall {
VCALL_LOCALMEM0R(Quat, length_squared);
VCALL_LOCALMEM0R(Quat, normalized);
VCALL_LOCALMEM0R(Quat, is_normalized);
+ VCALL_LOCALMEM1R(Quat, is_equal_approx);
VCALL_LOCALMEM0R(Quat, inverse);
VCALL_LOCALMEM1R(Quat, dot);
VCALL_LOCALMEM1R(Quat, xform);
@@ -492,6 +497,7 @@ struct _VariantCall {
VCALL_LOCALMEM1R(Color, darkened);
VCALL_LOCALMEM1R(Color, to_html);
VCALL_LOCALMEM4R(Color, from_hsv);
+ VCALL_LOCALMEM1R(Color, is_equal_approx);
VCALL_LOCALMEM0R(RID, get_id);
@@ -626,6 +632,7 @@ struct _VariantCall {
}
VCALL_LOCALMEM0R(PoolByteArray, size);
+ VCALL_LOCALMEM0R(PoolByteArray, empty);
VCALL_LOCALMEM2(PoolByteArray, set);
VCALL_LOCALMEM1R(PoolByteArray, get);
VCALL_LOCALMEM1(PoolByteArray, push_back);
@@ -638,6 +645,7 @@ struct _VariantCall {
VCALL_LOCALMEM2R(PoolByteArray, subarray);
VCALL_LOCALMEM0R(PoolIntArray, size);
+ VCALL_LOCALMEM0R(PoolIntArray, empty);
VCALL_LOCALMEM2(PoolIntArray, set);
VCALL_LOCALMEM1R(PoolIntArray, get);
VCALL_LOCALMEM1(PoolIntArray, push_back);
@@ -649,6 +657,7 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolIntArray, invert);
VCALL_LOCALMEM0R(PoolRealArray, size);
+ VCALL_LOCALMEM0R(PoolRealArray, empty);
VCALL_LOCALMEM2(PoolRealArray, set);
VCALL_LOCALMEM1R(PoolRealArray, get);
VCALL_LOCALMEM1(PoolRealArray, push_back);
@@ -660,6 +669,7 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolRealArray, invert);
VCALL_LOCALMEM0R(PoolStringArray, size);
+ VCALL_LOCALMEM0R(PoolStringArray, empty);
VCALL_LOCALMEM2(PoolStringArray, set);
VCALL_LOCALMEM1R(PoolStringArray, get);
VCALL_LOCALMEM1(PoolStringArray, push_back);
@@ -672,6 +682,7 @@ struct _VariantCall {
VCALL_LOCALMEM1R(PoolStringArray, join);
VCALL_LOCALMEM0R(PoolVector2Array, size);
+ VCALL_LOCALMEM0R(PoolVector2Array, empty);
VCALL_LOCALMEM2(PoolVector2Array, set);
VCALL_LOCALMEM1R(PoolVector2Array, get);
VCALL_LOCALMEM1(PoolVector2Array, push_back);
@@ -683,6 +694,7 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolVector2Array, invert);
VCALL_LOCALMEM0R(PoolVector3Array, size);
+ VCALL_LOCALMEM0R(PoolVector3Array, empty);
VCALL_LOCALMEM2(PoolVector3Array, set);
VCALL_LOCALMEM1R(PoolVector3Array, get);
VCALL_LOCALMEM1(PoolVector3Array, push_back);
@@ -694,6 +706,7 @@ struct _VariantCall {
VCALL_LOCALMEM0(PoolVector3Array, invert);
VCALL_LOCALMEM0R(PoolColorArray, size);
+ VCALL_LOCALMEM0R(PoolColorArray, empty);
VCALL_LOCALMEM2(PoolColorArray, set);
VCALL_LOCALMEM1R(PoolColorArray, get);
VCALL_LOCALMEM1(PoolColorArray, push_back);
@@ -732,13 +745,16 @@ struct _VariantCall {
VCALL_PTR0R(AABB, get_area);
VCALL_PTR0R(AABB, has_no_area);
VCALL_PTR0R(AABB, has_no_surface);
+ VCALL_PTR1R(AABB, has_point);
+ VCALL_PTR1R(AABB, is_equal_approx);
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, intersection);
+ VCALL_PTR1R(AABB, merge);
+ VCALL_PTR1R(AABB, expand);
+ VCALL_PTR1R(AABB, grow);
VCALL_PTR1R(AABB, get_support);
VCALL_PTR0R(AABB, get_longest_axis);
VCALL_PTR0R(AABB, get_longest_axis_index);
@@ -746,8 +762,6 @@ struct _VariantCall {
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);
@@ -760,6 +774,7 @@ struct _VariantCall {
VCALL_PTR1R(Transform2D, scaled);
VCALL_PTR1R(Transform2D, translated);
VCALL_PTR2R(Transform2D, interpolate_with);
+ VCALL_PTR1R(Transform2D, is_equal_approx);
static void _call_Transform2D_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) {
@@ -816,7 +831,7 @@ struct _VariantCall {
VCALL_PTR0R(Basis, get_orthogonal_index);
VCALL_PTR0R(Basis, orthonormalized);
VCALL_PTR2R(Basis, slerp);
- VCALL_PTR2R(Basis, is_equal_approx);
+ VCALL_PTR2R(Basis, is_equal_approx); // TODO: Break compatibility in 4.0 to change this to an instance method (a.is_equal_approx(b) as VCALL_PTR1R) for consistency.
VCALL_PTR0R(Basis, get_rotation_quat);
VCALL_PTR0R(Transform, inverse);
@@ -827,6 +842,7 @@ struct _VariantCall {
VCALL_PTR0R(Transform, orthonormalized);
VCALL_PTR2R(Transform, looking_at);
VCALL_PTR2R(Transform, interpolate_with);
+ VCALL_PTR1R(Transform, is_equal_approx);
static void _call_Transform_xform(Variant &r_ret, Variant &p_self, const Variant **p_args) {
@@ -1607,19 +1623,20 @@ void register_variant_methods() {
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, angle_to, VECTOR2, "to", varray());
+ ADDFUNC1R(VECTOR2, REAL, Vector2, angle_to_point, VECTOR2, "to", varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, direction_to, VECTOR2, "b", varray());
ADDFUNC1R(VECTOR2, REAL, Vector2, distance_to, VECTOR2, "to", varray());
ADDFUNC1R(VECTOR2, REAL, Vector2, distance_squared_to, VECTOR2, "to", varray());
+ ADDFUNC0R(VECTOR2, REAL, Vector2, length, varray());
+ ADDFUNC0R(VECTOR2, REAL, Vector2, length_squared, varray());
+ ADDFUNC0R(VECTOR2, VECTOR2, Vector2, normalized, varray());
+ ADDFUNC0R(VECTOR2, BOOL, Vector2, is_normalized, varray());
+ ADDFUNC1R(VECTOR2, BOOL, Vector2, is_equal_approx, VECTOR2, "v", varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmod, REAL, "mod", varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, posmodv, VECTOR2, "modv", varray());
ADDFUNC1R(VECTOR2, VECTOR2, Vector2, project, VECTOR2, "b", 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());
ADDFUNC2R(VECTOR2, VECTOR2, Vector2, slerp, VECTOR2, "b", REAL, "t", varray());
ADDFUNC4R(VECTOR2, VECTOR2, Vector2, cubic_interpolate, VECTOR2, "b", VECTOR2, "pre_a", VECTOR2, "post_b", REAL, "t", varray());
@@ -1641,31 +1658,36 @@ void register_variant_methods() {
ADDFUNC0R(VECTOR2, VECTOR2, Vector2, sign, varray());
ADDFUNC0R(RECT2, REAL, Rect2, get_area, varray());
+ ADDFUNC0R(RECT2, BOOL, Rect2, has_no_area, varray());
+ ADDFUNC1R(RECT2, BOOL, Rect2, has_point, VECTOR2, "point", varray());
+ ADDFUNC1R(RECT2, BOOL, Rect2, is_equal_approx, RECT2, "rect", 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, expand, VECTOR2, "to", 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(RECT2, RECT2, Rect2, abs, varray());
ADDFUNC0R(VECTOR3, INT, Vector3, min_axis, varray());
ADDFUNC0R(VECTOR3, INT, Vector3, max_axis, varray());
+ ADDFUNC1R(VECTOR3, REAL, Vector3, angle_to, VECTOR3, "to", varray());
+ ADDFUNC1R(VECTOR3, VECTOR3, Vector3, direction_to, VECTOR3, "b", varray());
+ ADDFUNC1R(VECTOR3, REAL, Vector3, distance_to, VECTOR3, "b", varray());
+ ADDFUNC1R(VECTOR3, REAL, Vector3, distance_squared_to, VECTOR3, "b", 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, BOOL, Vector3, is_normalized, varray());
+ ADDFUNC1R(VECTOR3, BOOL, Vector3, is_equal_approx, VECTOR3, "v", varray());
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, inverse, varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, snapped, VECTOR3, "by", varray());
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, rotated, VECTOR3, "axis", REAL, "phi", varray());
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, linear_interpolate, VECTOR3, "b", REAL, "t", varray());
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, slerp, VECTOR3, "b", REAL, "t", varray());
ADDFUNC4R(VECTOR3, VECTOR3, Vector3, cubic_interpolate, VECTOR3, "b", VECTOR3, "pre_a", VECTOR3, "post_b", REAL, "t", varray());
- ADDFUNC1R(VECTOR3, VECTOR3, Vector3, direction_to, VECTOR3, "b", varray());
ADDFUNC2R(VECTOR3, VECTOR3, Vector3, move_toward, VECTOR3, "to", REAL, "delta", varray());
ADDFUNC1R(VECTOR3, REAL, Vector3, dot, VECTOR3, "b", varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, cross, VECTOR3, "b", varray());
@@ -1675,12 +1697,9 @@ void register_variant_methods() {
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, floor, varray());
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, ceil, varray());
ADDFUNC0R(VECTOR3, VECTOR3, Vector3, round, varray());
- ADDFUNC1R(VECTOR3, REAL, Vector3, distance_to, VECTOR3, "b", varray());
- ADDFUNC1R(VECTOR3, REAL, Vector3, distance_squared_to, VECTOR3, "b", varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, posmod, REAL, "mod", varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, posmodv, VECTOR3, "modv", varray());
ADDFUNC1R(VECTOR3, VECTOR3, Vector3, project, 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());
@@ -1689,6 +1708,7 @@ void register_variant_methods() {
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_equal_approx, PLANE, "plane", 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));
@@ -1701,6 +1721,7 @@ void register_variant_methods() {
ADDFUNC0R(QUAT, REAL, Quat, length_squared, varray());
ADDFUNC0R(QUAT, QUAT, Quat, normalized, varray());
ADDFUNC0R(QUAT, BOOL, Quat, is_normalized, varray());
+ ADDFUNC1R(QUAT, BOOL, Quat, is_equal_approx, QUAT, "quat", varray());
ADDFUNC0R(QUAT, QUAT, Quat, inverse, varray());
ADDFUNC1R(QUAT, REAL, Quat, dot, QUAT, "b", varray());
ADDFUNC1R(QUAT, VECTOR3, Quat, xform, VECTOR3, "v", varray());
@@ -1726,6 +1747,7 @@ void register_variant_methods() {
ADDFUNC1R(COLOR, COLOR, Color, darkened, REAL, "amount", varray());
ADDFUNC1R(COLOR, STRING, Color, to_html, BOOL, "with_alpha", varray(true));
ADDFUNC4R(COLOR, COLOR, Color, from_hsv, REAL, "h", REAL, "s", REAL, "v", REAL, "a", varray(1.0));
+ ADDFUNC1R(COLOR, BOOL, Color, is_equal_approx, COLOR, "color", varray());
ADDFUNC0R(_RID, INT, RID, get_id, varray());
@@ -1782,6 +1804,7 @@ void register_variant_methods() {
ADDFUNC0R(ARRAY, NIL, Array, min, varray());
ADDFUNC0R(POOL_BYTE_ARRAY, INT, PoolByteArray, size, varray());
+ ADDFUNC0R(POOL_BYTE_ARRAY, BOOL, PoolByteArray, empty, 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());
@@ -1799,6 +1822,7 @@ void register_variant_methods() {
ADDFUNC2R(POOL_BYTE_ARRAY, POOL_BYTE_ARRAY, PoolByteArray, decompress, INT, "buffer_size", INT, "compression_mode", varray(0));
ADDFUNC0R(POOL_INT_ARRAY, INT, PoolIntArray, size, varray());
+ ADDFUNC0R(POOL_INT_ARRAY, BOOL, PoolIntArray, empty, 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());
@@ -1809,6 +1833,7 @@ void register_variant_methods() {
ADDFUNC0(POOL_INT_ARRAY, NIL, PoolIntArray, invert, varray());
ADDFUNC0R(POOL_REAL_ARRAY, INT, PoolRealArray, size, varray());
+ ADDFUNC0R(POOL_REAL_ARRAY, BOOL, PoolRealArray, empty, 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());
@@ -1819,6 +1844,7 @@ void register_variant_methods() {
ADDFUNC0(POOL_REAL_ARRAY, NIL, PoolRealArray, invert, varray());
ADDFUNC0R(POOL_STRING_ARRAY, INT, PoolStringArray, size, varray());
+ ADDFUNC0R(POOL_STRING_ARRAY, BOOL, PoolStringArray, empty, 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());
@@ -1830,6 +1856,7 @@ void register_variant_methods() {
ADDFUNC1(POOL_STRING_ARRAY, STRING, PoolStringArray, join, STRING, "delimiter", varray());
ADDFUNC0R(POOL_VECTOR2_ARRAY, INT, PoolVector2Array, size, varray());
+ ADDFUNC0R(POOL_VECTOR2_ARRAY, BOOL, PoolVector2Array, empty, 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());
@@ -1840,6 +1867,7 @@ void register_variant_methods() {
ADDFUNC0(POOL_VECTOR2_ARRAY, NIL, PoolVector2Array, invert, varray());
ADDFUNC0R(POOL_VECTOR3_ARRAY, INT, PoolVector3Array, size, varray());
+ ADDFUNC0R(POOL_VECTOR3_ARRAY, BOOL, PoolVector3Array, empty, 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());
@@ -1850,6 +1878,7 @@ void register_variant_methods() {
ADDFUNC0(POOL_VECTOR3_ARRAY, NIL, PoolVector3Array, invert, varray());
ADDFUNC0R(POOL_COLOR_ARRAY, INT, PoolColorArray, size, varray());
+ ADDFUNC0R(POOL_COLOR_ARRAY, BOOL, PoolColorArray, empty, 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());
@@ -1864,13 +1893,16 @@ void register_variant_methods() {
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, has_point, VECTOR3, "point", varray());
+ ADDFUNC1R(AABB, BOOL, AABB, is_equal_approx, AABB, "aabb", 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, AABB, AABB, intersection, AABB, "with", varray());
+ ADDFUNC1R(AABB, AABB, AABB, merge, AABB, "with", varray());
+ ADDFUNC1R(AABB, AABB, AABB, expand, VECTOR3, "to_point", varray());
+ ADDFUNC1R(AABB, AABB, AABB, grow, REAL, "by", 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());
@@ -1878,8 +1910,6 @@ void register_variant_methods() {
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());
@@ -1896,6 +1926,7 @@ void register_variant_methods() {
ADDFUNC1R(TRANSFORM2D, VECTOR2, Transform2D, basis_xform, VECTOR2, "v", varray());
ADDFUNC1R(TRANSFORM2D, VECTOR2, Transform2D, basis_xform_inv, VECTOR2, "v", varray());
ADDFUNC2R(TRANSFORM2D, TRANSFORM2D, Transform2D, interpolate_with, TRANSFORM2D, "transform", REAL, "weight", varray());
+ ADDFUNC1R(TRANSFORM2D, BOOL, Transform2D, is_equal_approx, TRANSFORM2D, "transform", varray());
ADDFUNC0R(BASIS, BASIS, Basis, inverse, varray());
ADDFUNC0R(BASIS, BASIS, Basis, transposed, varray());
@@ -1912,7 +1943,7 @@ void register_variant_methods() {
ADDFUNC1R(BASIS, VECTOR3, Basis, xform_inv, VECTOR3, "v", varray());
ADDFUNC0R(BASIS, INT, Basis, get_orthogonal_index, varray());
ADDFUNC2R(BASIS, BASIS, Basis, slerp, BASIS, "b", REAL, "t", varray());
- ADDFUNC2R(BASIS, BOOL, Basis, is_equal_approx, BASIS, "b", REAL, "epsilon", varray(CMP_EPSILON));
+ ADDFUNC2R(BASIS, BOOL, Basis, is_equal_approx, BASIS, "b", REAL, "epsilon", varray(CMP_EPSILON)); // TODO: Replace in 4.0, see other TODO.
ADDFUNC0R(BASIS, QUAT, Basis, get_rotation_quat, varray());
ADDFUNC0R(TRANSFORM, TRANSFORM, Transform, inverse, varray());
@@ -1923,6 +1954,7 @@ void register_variant_methods() {
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, BOOL, Transform, is_equal_approx, TRANSFORM, "transform", varray());
ADDFUNC1R(TRANSFORM, NIL, Transform, xform, NIL, "v", varray());
ADDFUNC1R(TRANSFORM, NIL, Transform, xform_inv, NIL, "v", varray());