summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/image.cpp24
-rw-r--r--core/image.h1
-rw-r--r--core/math/geometry.cpp11
-rw-r--r--core/math/geometry.h3
-rw-r--r--core/math/matrix3.cpp17
-rw-r--r--core/math/matrix3.h3
-rw-r--r--core/os/input.cpp20
-rw-r--r--core/os/input.h25
-rw-r--r--core/os/os.h1
-rw-r--r--core/script_debugger_remote.cpp21
-rw-r--r--core/variant_call.cpp5
11 files changed, 119 insertions, 12 deletions
diff --git a/core/image.cpp b/core/image.cpp
index 11429b8782..2f2d7efd7c 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -47,6 +47,7 @@ const char *Image::format_names[Image::FORMAT_MAX] = {
"RGBA8",
"RGBA4444",
"RGBA5551",
+ "RGB10A2",
"RFloat", //float
"RGFloat",
"RGBFloat",
@@ -112,6 +113,7 @@ int Image::get_format_pixel_size(Format p_format) {
case FORMAT_RGBA8: return 4;
case FORMAT_RGBA4444: return 2;
case FORMAT_RGBA5551: return 2;
+ case FORMAT_RGB10A2: return 4;
case FORMAT_RF:
return 4; //float
case FORMAT_RGF: return 8;
@@ -1978,6 +1980,15 @@ Color Image::get_pixel(int p_x, int p_y) const {
float a = ((u >> 15) & 0x1) / 1.0;
return Color(r, g, b, a);
} break;
+ case FORMAT_RGB10A2: {
+
+ uint32_t u = ((uint32_t *)ptr)[ofs];
+ float r = (u & 0x3FF) / 1023.0;
+ float g = ((u >> 10) & 0x3FF) / 1023.0;
+ float b = ((u >> 20) & 0x3FF) / 1023.0;
+ float a = ((u >> 30) & 0x3) / 3.0;
+ return Color(r, g, b, a);
+ } break;
case FORMAT_RF: {
float r = ((float *)ptr)[ofs];
@@ -2123,6 +2134,18 @@ void Image::set_pixel(int p_x, int p_y, const Color &p_color) {
((uint16_t *)ptr)[ofs] = rgba;
} break;
+ case FORMAT_RGB10A2: {
+
+ uint32_t rgba = 0;
+
+ rgba = uint32_t(CLAMP(p_color.r * 1023.0, 0, 1023));
+ rgba |= uint32_t(CLAMP(p_color.g * 1023.0, 0, 1023)) << 10;
+ rgba |= uint32_t(CLAMP(p_color.b * 1023.0, 0, 1023)) << 20;
+ rgba |= uint32_t(CLAMP(p_color.a * 3.0, 0, 3)) << 30;
+
+ ((uint32_t *)ptr)[ofs] = rgba;
+
+ } break;
case FORMAT_RF: {
((float *)ptr)[ofs] = p_color.r;
@@ -2300,6 +2323,7 @@ void Image::_bind_methods() {
BIND_ENUM_CONSTANT(FORMAT_RGBA8);
BIND_ENUM_CONSTANT(FORMAT_RGBA4444);
BIND_ENUM_CONSTANT(FORMAT_RGBA5551);
+ BIND_ENUM_CONSTANT(FORMAT_RGB10A2);
BIND_ENUM_CONSTANT(FORMAT_RF); //float
BIND_ENUM_CONSTANT(FORMAT_RGF);
BIND_ENUM_CONSTANT(FORMAT_RGBF);
diff --git a/core/image.h b/core/image.h
index 767f3c6ac5..efb62a6a29 100644
--- a/core/image.h
+++ b/core/image.h
@@ -68,6 +68,7 @@ public:
FORMAT_RGBA8,
FORMAT_RGBA4444,
FORMAT_RGBA5551,
+ FORMAT_RGB10A2,
FORMAT_RF, //float
FORMAT_RGF,
FORMAT_RGBF,
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index b2145eca85..a3b48320b1 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -30,6 +30,17 @@
#include "geometry.h"
#include "print_string.h"
+bool Geometry::is_point_in_polygon(const Vector2 &p_point, const Vector<Vector2> &p_polygon) {
+
+ Vector<int> indices = Geometry::triangulate_polygon(p_polygon);
+ for (int j = 0; j + 3 <= indices.size(); j += 3) {
+ int i1 = indices[j], i2 = indices[j + 1], i3 = indices[j + 2];
+ if (Geometry::is_point_in_triangle(p_point, p_polygon[i1], p_polygon[i2], p_polygon[i3]))
+ return true;
+ }
+ return false;
+}
+
void Geometry::MeshData::optimize_vertices() {
Map<int, int> vtx_remap;
diff --git a/core/math/geometry.h b/core/math/geometry.h
index ac1a22289c..fefdd88794 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -512,6 +512,9 @@ public:
return true;
}
+
+ static bool is_point_in_polygon(const Vector2 &p_point, const Vector<Vector2> &p_polygon);
+
static Vector2 get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 *p_segment) {
Vector2 p = p_point - p_segment[0];
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index e1708a44b0..ceaff04ae8 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -228,12 +228,24 @@ void Basis::scale(const Vector3 &p_scale) {
}
Basis Basis::scaled(const Vector3 &p_scale) const {
-
Basis m = *this;
m.scale(p_scale);
return m;
}
+void Basis::scale_local(const Vector3 &p_scale) {
+ // performs a scaling in object-local coordinate system:
+ // M -> (M.S.Minv).M = M.S.
+ *this = scaled_local(p_scale);
+}
+
+Basis Basis::scaled_local(const Vector3 &p_scale) const {
+ Basis b;
+ b.set_scale(p_scale);
+
+ return (*this) * b;
+}
+
void Basis::set_scale(const Vector3 &p_scale) {
set_axis(0, get_axis(0).normalized() * p_scale.x);
@@ -312,7 +324,8 @@ void Basis::rotate(const Vector3 &p_axis, real_t p_phi) {
}
void Basis::rotate_local(const Vector3 &p_axis, real_t p_phi) {
-
+ // performs a rotation in object-local coordinate system:
+ // M -> (M.R.Minv).M = M.R.
*this = rotated_local(p_axis, p_phi);
}
Basis Basis::rotated_local(const Vector3 &p_axis, real_t p_phi) const {
diff --git a/core/math/matrix3.h b/core/math/matrix3.h
index 71971bdea8..c426435729 100644
--- a/core/math/matrix3.h
+++ b/core/math/matrix3.h
@@ -103,6 +103,9 @@ public:
void scale(const Vector3 &p_scale);
Basis scaled(const Vector3 &p_scale) const;
+ void scale_local(const Vector3 &p_scale);
+ Basis scaled_local(const Vector3 &p_scale) const;
+
void set_scale(const Vector3 &p_scale);
Vector3 get_scale() const;
Vector3 get_signed_scale() const;
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 2795b11243..a44adde425 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -84,7 +84,7 @@ void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("warp_mouse_position", "to"), &Input::warp_mouse_position);
ClassDB::bind_method(D_METHOD("action_press", "action"), &Input::action_press);
ClassDB::bind_method(D_METHOD("action_release", "action"), &Input::action_release);
- ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(Vector2()));
+ ClassDB::bind_method(D_METHOD("set_custom_mouse_cursor", "image", "shape", "hotspot"), &Input::set_custom_mouse_cursor, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2()));
ClassDB::bind_method(D_METHOD("parse_input_event", "event"), &Input::parse_input_event);
BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
@@ -92,6 +92,24 @@ void Input::_bind_methods() {
BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
+ BIND_ENUM_CONSTANT(CURSOR_ARROW);
+ BIND_ENUM_CONSTANT(CURSOR_IBEAM);
+ BIND_ENUM_CONSTANT(CURSOR_POINTING_HAND);
+ BIND_ENUM_CONSTANT(CURSOR_CROSS);
+ BIND_ENUM_CONSTANT(CURSOR_WAIT);
+ BIND_ENUM_CONSTANT(CURSOR_BUSY);
+ BIND_ENUM_CONSTANT(CURSOR_DRAG);
+ BIND_ENUM_CONSTANT(CURSOR_CAN_DROP);
+ BIND_ENUM_CONSTANT(CURSOR_FORBIDDEN);
+ BIND_ENUM_CONSTANT(CURSOR_VSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_HSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_BDIAGSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_FDIAGSIZE);
+ BIND_ENUM_CONSTANT(CURSOR_MOVE);
+ BIND_ENUM_CONSTANT(CURSOR_VSPLIT);
+ BIND_ENUM_CONSTANT(CURSOR_HSPLIT);
+ BIND_ENUM_CONSTANT(CURSOR_HELP);
+
ADD_SIGNAL(MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "connected")));
}
diff --git a/core/os/input.h b/core/os/input.h
index 608484ccd0..140d11de4d 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -51,6 +51,28 @@ public:
MOUSE_MODE_CONFINED
};
+#undef CursorShape
+ enum CursorShape {
+ CURSOR_ARROW,
+ CURSOR_IBEAM,
+ CURSOR_POINTING_HAND,
+ CURSOR_CROSS,
+ CURSOR_WAIT,
+ CURSOR_BUSY,
+ CURSOR_DRAG,
+ CURSOR_CAN_DROP,
+ CURSOR_FORBIDDEN,
+ CURSOR_VSIZE,
+ CURSOR_HSIZE,
+ CURSOR_BDIAGSIZE,
+ CURSOR_FDIAGSIZE,
+ CURSOR_MOVE,
+ CURSOR_VSPLIT,
+ CURSOR_HSPLIT,
+ CURSOR_HELP,
+ CURSOR_MAX
+ };
+
void set_mouse_mode(MouseMode p_mode);
MouseMode get_mouse_mode() const;
@@ -96,7 +118,7 @@ public:
virtual bool is_emulating_touchscreen() const = 0;
- virtual void set_custom_mouse_cursor(const RES &p_cursor, const Vector2 &p_hotspot = Vector2()) = 0;
+ virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape = CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) = 0;
virtual void set_mouse_in_window(bool p_in_window) = 0;
virtual String get_joy_button_string(int p_button) = 0;
@@ -110,5 +132,6 @@ public:
};
VARIANT_ENUM_CAST(Input::MouseMode);
+VARIANT_ENUM_CAST(Input::CursorShape);
#endif // INPUT_H
diff --git a/core/os/os.h b/core/os/os.h
index 5dc39b52d6..c9c228cfaf 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -325,6 +325,7 @@ public:
virtual int get_virtual_keyboard_height() const;
virtual void set_cursor_shape(CursorShape p_shape) = 0;
+ virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) = 0;
virtual bool get_swap_ok_cancel() { return false; }
virtual void dump_memory_to_file(const char *p_file);
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 27633ec553..a0a55ce86e 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -67,17 +67,20 @@ Error ScriptDebuggerRemote::connect_to_host(const String &p_host, uint16_t p_por
int port = p_port;
- int tries = 3;
+ const int tries = 6;
+ int waits[tries] = { 1, 10, 100, 1000, 1000, 1000 };
+
tcp_client->connect_to_host(ip, port);
- while (tries--) {
+ for (int i = 0; i < tries; i++) {
if (tcp_client->get_status() == StreamPeerTCP::STATUS_CONNECTED) {
break;
} else {
- OS::get_singleton()->delay_usec(1000000);
- print_line("Remote Debugger: Connection failed with status: '" + String::num(tcp_client->get_status()) + "', retrying in 1 sec.");
+ const int ms = waits[i];
+ OS::get_singleton()->delay_usec(ms * 1000);
+ print_line("Remote Debugger: Connection failed with status: '" + String::num(tcp_client->get_status()) + "', retrying in " + String::num(ms) + " msec.");
};
};
@@ -126,15 +129,21 @@ static ObjectID safe_get_instance_id(const Variant &p_v) {
void ScriptDebuggerRemote::_put_variable(const String &p_name, const Variant &p_variable) {
packet_peer_stream->put_var(p_name);
+
+ Variant var = p_variable;
+ if (p_variable.get_type() == Variant::OBJECT && !ObjectDB::instance_validate(p_variable)) {
+ var = Variant();
+ }
+
int len = 0;
- Error err = encode_variant(p_variable, NULL, len);
+ Error err = encode_variant(var, NULL, len);
if (err != OK)
ERR_PRINT("Failed to encode variant");
if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size
packet_peer_stream->put_var(Variant());
} else {
- packet_peer_stream->put_var(p_variable);
+ packet_peer_stream->put_var(var);
}
}
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index a2794e7052..81e823b5db 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -101,9 +101,10 @@ struct _VariantCall {
const Variant *newargs[VARIANT_ARG_MAX];
for (int i = 0; i < p_argcount; i++)
newargs[i] = p_args[i];
- int defargcount = def_argcount;
+ // fill in any remaining parameters with defaults
+ int first_default_arg = arg_count - def_argcount;
for (int i = p_argcount; i < arg_count; i++)
- newargs[i] = &default_args[defargcount - (i - p_argcount) - 1]; //default arguments
+ newargs[i] = &default_args[i - first_default_arg];
#ifdef DEBUG_ENABLED
if (!verify_arguments(newargs, r_error))
return;