summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp9
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/global_constants.cpp29
-rw-r--r--core/globals.cpp2
-rw-r--r--core/io/file_access_pack.cpp9
-rw-r--r--core/io/file_access_pack.h34
-rw-r--r--core/io/http_client.cpp28
-rw-r--r--core/math/camera_matrix.cpp7
-rw-r--r--core/math/camera_matrix.h2
-rw-r--r--core/math/face3.cpp96
-rw-r--r--core/math/face3.h1
-rw-r--r--core/math/math_2d.cpp5
-rw-r--r--core/math/math_2d.h3
-rw-r--r--core/math/quat.h39
-rw-r--r--core/math/vector3.h16
-rw-r--r--core/object.cpp10
-rw-r--r--core/object.h2
-rw-r--r--core/os/input.cpp16
-rw-r--r--core/os/input.h9
-rw-r--r--core/print_string.cpp5
-rw-r--r--core/print_string.h2
-rw-r--r--core/script_language.h2
-rw-r--r--core/translation.cpp14
-rw-r--r--core/translation.h3
-rw-r--r--core/ustring.cpp18
-rw-r--r--core/ustring.h3
-rw-r--r--core/variant_call.cpp19
-rw-r--r--core/variant_op.cpp34
28 files changed, 376 insertions, 42 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 64b31d6fdd..ba27c2cdd6 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -176,6 +176,11 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const {
}
+void _OS::set_use_file_access_save_and_swap(bool p_enable) {
+
+ FileAccess::set_backup_save(p_enable);
+}
+
bool _OS::is_video_mode_resizable(int p_screen) const {
OS::VideoMode vm;
@@ -675,6 +680,10 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("native_video_pause"),&_OS::native_video_pause);
+ ObjectTypeDB::bind_method(_MD("set_use_file_access_save_and_swap","enabled"),&_OS::set_use_file_access_save_and_swap);
+
+
+
BIND_CONSTANT( DAY_SUNDAY );
BIND_CONSTANT( DAY_MONDAY );
BIND_CONSTANT( DAY_TUESDAY );
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 20a33fa013..cac2de314d 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -174,6 +174,7 @@ public:
};
*/
+ void set_use_file_access_save_and_swap(bool p_enable);
void set_icon(const Image& p_icon);
Dictionary get_date() const;
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index efa72b6547..ae4abc627d 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -445,15 +445,26 @@ static _GlobalConstant _global_constants[]={
BIND_GLOBAL_CONSTANT( ERR_BUG ), ///< a bug in the software certainly happened ), due to a double check failing or unexpected behavior.
BIND_GLOBAL_CONSTANT( ERR_WTF ),
- BIND_GLOBAL_CONSTANT( PROPERTY_HINT_NONE ),
- BIND_GLOBAL_CONSTANT( PROPERTY_HINT_RANGE ),
- BIND_GLOBAL_CONSTANT( PROPERTY_HINT_EXP_RANGE ),
- BIND_GLOBAL_CONSTANT( PROPERTY_HINT_ENUM ),
- BIND_GLOBAL_CONSTANT( PROPERTY_HINT_LENGTH ),
- BIND_GLOBAL_CONSTANT( PROPERTY_HINT_FLAGS ),
- BIND_GLOBAL_CONSTANT( PROPERTY_HINT_FILE ),
- BIND_GLOBAL_CONSTANT( PROPERTY_HINT_DIR ),
- BIND_GLOBAL_CONSTANT( PROPERTY_HINT_RESOURCE_TYPE ),
+
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_NONE ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_RANGE ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_EXP_RANGE ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_ENUM ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_EXP_EASING ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_LENGTH ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_KEY_ACCEL ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_FLAGS ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_ALL_FLAGS ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_FILE ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_DIR ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_GLOBAL_FILE ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_GLOBAL_DIR ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_RESOURCE_TYPE ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_MULTILINE_TEXT ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_COLOR_NO_ALPHA ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_IMAGE_COMPRESS_LOSSY ),
+ BIND_GLOBAL_CONSTANT( PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS ),
+
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORAGE ),
BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORAGE ),
diff --git a/core/globals.cpp b/core/globals.cpp
index 3a04becef4..ccda457f46 100644
--- a/core/globals.cpp
+++ b/core/globals.cpp
@@ -1358,6 +1358,7 @@ void Globals::_bind_methods() {
ObjectTypeDB::bind_method(_MD("save"),&Globals::save);
ObjectTypeDB::bind_method(_MD("has_singleton"),&Globals::has_singleton);
ObjectTypeDB::bind_method(_MD("get_singleton"),&Globals::get_singleton_object);
+ ObjectTypeDB::bind_method(_MD("load_resource_pack"),&Globals::_load_resource_pack);
}
Globals::Globals() {
@@ -1379,6 +1380,7 @@ Globals::Globals() {
set("application/name","" );
set("application/main_scene","");
custom_prop_info["application/main_scene"]=PropertyInfo(Variant::STRING,"application/main_scene",PROPERTY_HINT_FILE,"xml,res,scn,xscn");
+ set("application/disable_stdout",false);
key.key.scancode=KEY_RETURN;
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index e2cb300ebc..6e03819aac 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -48,7 +48,10 @@ Error PackedData::add_pack(const String& p_path) {
void PackedData::add_path(const String& pkg_path, const String& path, uint64_t ofs, uint64_t size,const uint8_t* p_md5, PackSource* p_src) {
- bool exists = files.has(path);
+ PathMD5 pmd5(path.md5_buffer());
+ //printf("adding path %ls, %lli, %lli\n", path.c_str(), pmd5.a, pmd5.b);
+
+ bool exists = files.has(pmd5);
PackedFile pf;
pf.pack=pkg_path;
@@ -58,7 +61,7 @@ void PackedData::add_path(const String& pkg_path, const String& path, uint64_t o
pf.md5[i]=p_md5[i];
pf.src = p_src;
- files[path]=pf;
+ files[pmd5]=pf;
if (!exists) {
//search for dir
@@ -113,6 +116,8 @@ bool PackedSourcePCK::try_open_pack(const String& p_path) {
if (!f)
return false;
+ //printf("try open %ls!\n", p_path.c_str());
+
uint32_t magic= f->get_32();
if (magic != 0x43504447) {
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index a4c750bf3c..5fcc79aaf4 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -60,8 +60,34 @@ private:
Set<String> files;
};
+ struct PathMD5 {
+ uint64_t a;
+ uint64_t b;
+ bool operator < (const PathMD5& p_md5) const {
+
+ if (p_md5.a == a) {
+ return b < p_md5.b;
+ } else {
+ return a < p_md5.a;
+ }
+ }
+
+ bool operator == (const PathMD5& p_md5) const {
+ return a == p_md5.a && b == p_md5.b;
+ };
+
+ PathMD5() {
+ a = b = 0;
+ };
+
+ PathMD5(const Vector<uint8_t> p_buf) {
+ a = *((uint64_t*)&p_buf[0]);
+ b = *((uint64_t*)&p_buf[8]);
+ };
+ };
+
+ Map<PathMD5,PackedFile> files;
- Map<String,PackedFile> files;
Vector<PackSource*> sources;
PackedDir *root;
@@ -151,7 +177,9 @@ public:
FileAccess *PackedData::try_open_path(const String& p_path) {
- Map<String,PackedFile>::Element *E=files.find(p_path);
+ //print_line("try open path " + p_path);
+ PathMD5 pmd5(p_path.md5_buffer());
+ Map<PathMD5,PackedFile>::Element *E=files.find(pmd5);
if (!E)
return NULL; //not found
if (E->get().offset==0)
@@ -162,7 +190,7 @@ FileAccess *PackedData::try_open_path(const String& p_path) {
bool PackedData::has_path(const String& p_path) {
- return files.has(p_path);
+ return files.has(PathMD5(p_path.md5_buffer()));
}
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 27e202f47f..60a200af12 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -500,20 +500,24 @@ ByteArray HTTPClient::read_response_body_chunk() {
}
} else {
- ByteArray::Write r = tmp_read.write();
- int rec=0;
- err = connection->get_partial_data(r.ptr(),MIN(body_left,tmp_read.size()),rec);
- if (rec>0) {
- ByteArray ret;
- ret.resize(rec);
- ByteArray::Write w = ret.write();
- copymem(w.ptr(),r.ptr(),rec);
- body_left-=rec;
- if (body_left==0) {
- status=STATUS_CONNECTED;
+ ByteArray ret;
+ ret.resize(MAX(body_left,tmp_read.size()));
+ ByteArray::Write w = ret.write();
+ int _offset = 0;
+ while (body_left > 0) {
+ ByteArray::Write r = tmp_read.write();
+ int rec=0;
+ err = connection->get_partial_data(r.ptr(),MIN(body_left,tmp_read.size()),rec);
+ if (rec>0) {
+ copymem(w.ptr()+_offset,r.ptr(),rec);
+ body_left-=rec;
+ _offset += rec;
}
- return ret;
}
+ if (body_left==0) {
+ status=STATUS_CONNECTED;
+ }
+ return ret;
}
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 52d77b6ebc..a60dea7379 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -67,9 +67,10 @@ Plane CameraMatrix::xform4(const Plane& p_vec4) {
void CameraMatrix::set_perspective(float p_fovy_degrees, float p_aspect, float p_z_near, float p_z_far,bool p_flip_fov) {
- if (p_flip_fov)
- p_fovy_degrees=get_fovy(p_fovy_degrees,p_aspect);
+ if (p_flip_fov) {
+ p_fovy_degrees=get_fovy(p_fovy_degrees,1.0/p_aspect);
+ }
float sine, cotangent, deltaZ;
float radians = p_fovy_degrees / 2.0 * Math_PI / 180.0;
@@ -110,7 +111,7 @@ void CameraMatrix::set_orthogonal(float p_left, float p_right, float p_bottom, f
void CameraMatrix::set_orthogonal(float p_size, float p_aspect, float p_znear, float p_zfar,bool p_flip_fov) {
- if (p_flip_fov) {
+ if (!p_flip_fov) {
p_size*=p_aspect;
}
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index 6ffcb0ed0b..767236ea04 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -60,7 +60,7 @@ struct CameraMatrix {
static float get_fovy(float p_fovx,float p_aspect) {
- return Math::atan(p_aspect * Math::tan(p_fovx * 0.5))*2.0;
+ return Math::rad2deg(Math::atan(p_aspect * Math::tan(Math::deg2rad(p_fovx) * 0.5))*2.0);
}
float get_z_far() const;
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index 814f2d675d..1adc95e4e9 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -356,4 +356,100 @@ void Face3::get_support(const Vector3& p_normal,const Transform& p_transform,Vec
}
+Vector3 Face3::get_closest_point_to(const Vector3& p_point) const {
+
+ Vector3 edge0 = vertex[1] - vertex[0];
+ Vector3 edge1 = vertex[2] - vertex[0];
+ Vector3 v0 = vertex[0] - p_point;
+
+ float a = edge0.dot( edge0 );
+ float b = edge0.dot( edge1 );
+ float c = edge1.dot( edge1 );
+ float d = edge0.dot( v0 );
+ float e = edge1.dot( v0 );
+
+ float det = a*c - b*b;
+ float s = b*e - c*d;
+ float t = b*d - a*e;
+
+ if ( s + t < det )
+ {
+ if ( s < 0.f )
+ {
+ if ( t < 0.f )
+ {
+ if ( d < 0.f )
+ {
+ s = CLAMP( -d/a, 0.f, 1.f );
+ t = 0.f;
+ }
+ else
+ {
+ s = 0.f;
+ t = CLAMP( -e/c, 0.f, 1.f );
+ }
+ }
+ else
+ {
+ s = 0.f;
+ t = CLAMP( -e/c, 0.f, 1.f );
+ }
+ }
+ else if ( t < 0.f )
+ {
+ s = CLAMP( -d/a, 0.f, 1.f );
+ t = 0.f;
+ }
+ else
+ {
+ float invDet = 1.f / det;
+ s *= invDet;
+ t *= invDet;
+ }
+ }
+ else
+ {
+ if ( s < 0.f )
+ {
+ float tmp0 = b+d;
+ float tmp1 = c+e;
+ if ( tmp1 > tmp0 )
+ {
+ float numer = tmp1 - tmp0;
+ float denom = a-2*b+c;
+ s = CLAMP( numer/denom, 0.f, 1.f );
+ t = 1-s;
+ }
+ else
+ {
+ t = CLAMP( -e/c, 0.f, 1.f );
+ s = 0.f;
+ }
+ }
+ else if ( t < 0.f )
+ {
+ if ( a+d > b+e )
+ {
+ float numer = c+e-b-d;
+ float denom = a-2*b+c;
+ s = CLAMP( numer/denom, 0.f, 1.f );
+ t = 1-s;
+ }
+ else
+ {
+ s = CLAMP( -e/c, 0.f, 1.f );
+ t = 0.f;
+ }
+ }
+ else
+ {
+ float numer = c+e-b-d;
+ float denom = a-2*b+c;
+ s = CLAMP( numer/denom, 0.f, 1.f );
+ t = 1.f - s;
+ }
+ }
+
+ return vertex[0] + s * edge0 + t * edge1;
+}
diff --git a/core/math/face3.h b/core/math/face3.h
index 630c408de3..5a509299a2 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -68,6 +68,7 @@ public:
real_t get_area() const;
Vector3 get_median_point() const;
+ Vector3 get_closest_point_to(const Vector3& p_point) const;
bool intersects_ray(const Vector3& p_from,const Vector3& p_dir,Vector3 * p_intersection=0) const;
bool intersects_segment(const Vector3& p_from,const Vector3& p_dir,Vector3 * p_intersection=0) const;
diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp
index 6c160abaca..3aaa539fbb 100644
--- a/core/math/math_2d.cpp
+++ b/core/math/math_2d.cpp
@@ -77,6 +77,11 @@ float Vector2::angle_to(const Vector2& p_vector2) const {
return Math::atan2( tangent().dot(p_vector2), dot(p_vector2) );
}
+float Vector2::angle_to_point(const Vector2& p_vector2) const {
+
+ return Math::atan2( x-p_vector2.x, y - p_vector2.y );
+}
+
float Vector2::dot(const Vector2& p_other) const {
return x*p_other.x + y*p_other.y;
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index 3cc5bdc843..fa40d305f5 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -90,7 +90,8 @@ struct Vector2 {
float distance_to(const Vector2& p_vector2) const;
float distance_squared_to(const Vector2& p_vector2) const;
float angle_to(const Vector2& p_vector2) const;
-
+ float angle_to_point(const Vector2& p_vector2) const;
+
float dot(const Vector2& p_other) const;
float cross(const Vector2& p_other) const;
Vector2 cross(real_t p_other) const;
diff --git a/core/math/quat.h b/core/math/quat.h
index d326073033..04901116b8 100644
--- a/core/math/quat.h
+++ b/core/math/quat.h
@@ -64,6 +64,22 @@ public:
Quat operator*(const Quat& q) const;
+
+ Quat operator*(const Vector3& v) const
+ {
+ return Quat( w * v.x + y * v.z - z * v.y,
+ w * v.y + z * v.x - x * v.z,
+ w * v.z + x * v.y - y * v.x,
+ -x * v.x - y * v.y - z * v.z);
+ }
+
+ _FORCE_INLINE_ Vector3 xform(const Vector3& v) {
+
+ Quat q = *this * v;
+ q *= this->inverse();
+ return Vector3(q.x,q.y,q.z);
+ }
+
_FORCE_INLINE_ void operator+=(const Quat& q);
_FORCE_INLINE_ void operator-=(const Quat& q);
_FORCE_INLINE_ void operator*=(const real_t& s);
@@ -87,6 +103,29 @@ public:
x=p_x; y=p_y; z=p_z; w=p_w;
}
Quat(const Vector3& axis, const real_t& angle);
+
+ Quat(const Vector3& v0, const Vector3& v1) // shortest arc
+ {
+ Vector3 c = v0.cross(v1);
+ real_t d = v0.dot(v1);
+
+ if (d < -1.0 + CMP_EPSILON) {
+ x=0;
+ y=1;
+ z=0;
+ w=0;
+ } else {
+
+ real_t s = Math::sqrt((1.0f + d) * 2.0f);
+ real_t rs = 1.0f / s;
+
+ x=c.x*rs;
+ y=c.y*rs;
+ z=c.z*rs;
+ w=s * 0.5;
+ }
+ }
+
inline Quat() {x=y=z=0; w=1; }
diff --git a/core/math/vector3.h b/core/math/vector3.h
index 959f7cd0a8..d2f2408829 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -111,6 +111,12 @@ struct Vector3 {
_FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const;
_FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const;
+
+
+ _FORCE_INLINE_ Vector3 slide(const Vector3& p_vec) const;
+ _FORCE_INLINE_ Vector3 reflect(const Vector3& p_vec) const;
+
+
/* Operators */
_FORCE_INLINE_ Vector3& operator+=(const Vector3& p_v);
@@ -368,6 +374,16 @@ void Vector3::zero() {
x=y=z=0;
}
+Vector3 Vector3::slide(const Vector3& p_vec) const {
+
+ return p_vec - *this * this->dot(p_vec);
+}
+Vector3 Vector3::reflect(const Vector3& p_vec) const {
+
+ return p_vec - *this * this->dot(p_vec) * 2.0;
+
+}
+
#endif
#endif // VECTOR3_H
diff --git a/core/object.cpp b/core/object.cpp
index b40f4ec151..8a844577a8 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1286,16 +1286,16 @@ void Object::get_signal_connection_list(const StringName& p_signal,List<Connecti
}
-void Object::connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector<Variant>& p_binds,uint32_t p_flags) {
+Error Object::connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector<Variant>& p_binds,uint32_t p_flags) {
- ERR_FAIL_NULL(p_to_object);
+ ERR_FAIL_NULL_V(p_to_object,ERR_INVALID_PARAMETER);
Signal *s = signal_map.getptr(p_signal);
if (!s) {
bool signal_is_valid = ObjectTypeDB::has_signal(get_type_name(),p_signal);
if (!signal_is_valid) {
ERR_EXPLAIN("Attempt to connect to unexisting signal: "+p_signal);
- ERR_FAIL_COND(!signal_is_valid);
+ ERR_FAIL_COND_V(!signal_is_valid,ERR_INVALID_PARAMETER);
}
signal_map[p_signal]=Signal();
s=&signal_map[p_signal];
@@ -1304,7 +1304,7 @@ void Object::connect(const StringName& p_signal, Object *p_to_object, const Stri
Signal::Target target(p_to_object->get_instance_ID(),p_to_method);
if (s->slot_map.has(target)) {
ERR_EXPLAIN("Signal '"+p_signal+"'' already connected to given method '"+p_to_method+"' in that object.");
- ERR_FAIL_COND(s->slot_map.has(target));
+ ERR_FAIL_COND_V(s->slot_map.has(target),ERR_INVALID_PARAMETER);
}
Signal::Slot slot;
@@ -1319,6 +1319,8 @@ void Object::connect(const StringName& p_signal, Object *p_to_object, const Stri
slot.conn=conn;
slot.cE=p_to_object->connections.push_back(conn);
s->slot_map[target]=slot;
+
+ return OK;
}
bool Object::is_connected(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method) const {
diff --git a/core/object.h b/core/object.h
index 6290f9d64b..8e0164b13b 100644
--- a/core/object.h
+++ b/core/object.h
@@ -571,7 +571,7 @@ public:
void get_signal_list(List<MethodInfo> *p_signals ) const;
void get_signal_connection_list(const StringName& p_signal,List<Connection> *p_connections) const;
- void connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector<Variant>& p_binds=Vector<Variant>(),uint32_t p_flags=0);
+ Error connect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method,const Vector<Variant>& p_binds=Vector<Variant>(),uint32_t p_flags=0);
void disconnect(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method);
bool is_connected(const StringName& p_signal, Object *p_to_object, const StringName& p_to_method) const;
diff --git a/core/os/input.cpp b/core/os/input.cpp
index 70733aadec..3712690cc1 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -53,6 +53,7 @@ void Input::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_joy_button_pressed","device","button"),&Input::is_joy_button_pressed);
ObjectTypeDB::bind_method(_MD("is_action_pressed","action"),&Input::is_action_pressed);
ObjectTypeDB::bind_method(_MD("get_joy_axis","device","axis"),&Input::get_joy_axis);
+ ObjectTypeDB::bind_method(_MD("get_joy_name","device"),&Input::get_joy_name);
ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer);
ObjectTypeDB::bind_method(_MD("get_mouse_pos"),&Input::get_mouse_pos);
ObjectTypeDB::bind_method(_MD("get_mouse_speed"),&Input::get_mouse_speed);
@@ -64,6 +65,7 @@ void Input::_bind_methods() {
BIND_CONSTANT( MOUSE_MODE_HIDDEN );
BIND_CONSTANT( MOUSE_MODE_CAPTURED );
+ ADD_SIGNAL( MethodInfo("joy_connection_changed", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "connected")) );
}
Input::Input() {
@@ -193,6 +195,20 @@ float InputDefault::get_joy_axis(int p_device,int p_axis) {
}
}
+String InputDefault::get_joy_name(int p_idx) {
+
+ _THREAD_SAFE_METHOD_
+ return joy_names[p_idx];
+};
+
+void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_name) {
+
+ _THREAD_SAFE_METHOD_
+ joy_names[p_idx] = p_connected ? p_name : "";
+
+ emit_signal("joy_connection_changed", p_idx, p_connected);
+};
+
Vector3 InputDefault::get_accelerometer() {
_THREAD_SAFE_METHOD_
diff --git a/core/os/input.h b/core/os/input.h
index cc51dbf42f..b837a1f68f 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -61,6 +61,9 @@ public:
virtual bool is_action_pressed(const StringName& p_action)=0;
virtual float get_joy_axis(int p_device,int p_axis)=0;
+ virtual String get_joy_name(int p_idx)=0;
+ virtual void joy_connection_changed(int p_idx, bool p_connected, String p_name)=0;
+
virtual Point2 get_mouse_pos() const=0;
virtual Point2 get_mouse_speed() const=0;
@@ -71,6 +74,7 @@ public:
virtual void action_press(const StringName& p_action)=0;
virtual void action_release(const StringName& p_action)=0;
+
Input();
};
@@ -86,6 +90,7 @@ class InputDefault : public Input {
Set<int> joy_buttons_pressed;
Map<int,float> joy_axis;
Map<StringName,int> custom_action_press;
+ Map<int, String> joy_names;
Vector3 accelerometer;
Vector2 mouse_pos;
MainLoop *main_loop;
@@ -108,14 +113,14 @@ class InputDefault : public Input {
public:
-
-
virtual bool is_key_pressed(int p_scancode);
virtual bool is_mouse_button_pressed(int p_button);
virtual bool is_joy_button_pressed(int p_device, int p_button);
virtual bool is_action_pressed(const StringName& p_action);
virtual float get_joy_axis(int p_device,int p_axis);
+ String get_joy_name(int p_idx);
+ void joy_connection_changed(int p_idx, bool p_connected, String p_name);
virtual Vector3 get_accelerometer();
diff --git a/core/print_string.cpp b/core/print_string.cpp
index 85700fe650..ae15d05a35 100644
--- a/core/print_string.cpp
+++ b/core/print_string.cpp
@@ -31,7 +31,7 @@
#include <stdio.h>
static PrintHandlerList *print_handler_list=NULL;
-
+bool _print_line_enabled=true;
void add_print_handler(PrintHandlerList *p_handler) {
@@ -75,6 +75,9 @@ void remove_print_handler(PrintHandlerList *p_handler) {
void print_line(String p_string) {
+ if (!_print_line_enabled)
+ return;
+
OS::get_singleton()->print("%s\n",p_string.utf8().get_data());
_global_lock();
diff --git a/core/print_string.h b/core/print_string.h
index 49960b7ed7..c3e91f32fa 100644
--- a/core/print_string.h
+++ b/core/print_string.h
@@ -47,9 +47,11 @@ struct PrintHandlerList {
};
+
void add_print_handler(PrintHandlerList *p_handler);
void remove_print_handler(PrintHandlerList *p_handler);
+extern bool _print_line_enabled;
extern void print_line(String p_string);
#endif
diff --git a/core/script_language.h b/core/script_language.h
index 8c59a9e6b8..f4956accd3 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -246,7 +246,7 @@ public:
virtual void set_request_scene_tree_message_func(RequestSceneTreeMessageFunc p_func, void *p_udata) {}
ScriptDebugger();
- virtual ~ScriptDebugger() {}
+ virtual ~ScriptDebugger() {singleton=NULL;}
};
diff --git a/core/translation.cpp b/core/translation.cpp
index 045771f7c7..81f2c36075 100644
--- a/core/translation.cpp
+++ b/core/translation.cpp
@@ -470,6 +470,11 @@ void Translation::get_message_list(List<StringName> *r_messages) const {
}
+int Translation::get_message_count() const {
+
+ return translation_map.size();
+};
+
void Translation::_bind_methods() {
@@ -479,6 +484,7 @@ void Translation::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_message","src_message"),&Translation::get_message);
ObjectTypeDB::bind_method(_MD("erase_message","src_message"),&Translation::erase_message);
ObjectTypeDB::bind_method(_MD("get_message_list"),&Translation::_get_message_list);
+ ObjectTypeDB::bind_method(_MD("get_message_count"),&Translation::get_message_count);
ObjectTypeDB::bind_method(_MD("_set_messages"),&Translation::_set_messages);
ObjectTypeDB::bind_method(_MD("_get_messages"),&Translation::_get_messages);
@@ -519,6 +525,11 @@ void TranslationServer::remove_translation(const Ref<Translation> &p_translation
translations.erase(p_translation);
}
+void TranslationServer::clear() {
+
+ translations.clear();
+};
+
StringName TranslationServer::translate(const StringName& p_message) const {
//translate using locale
@@ -609,6 +620,9 @@ void TranslationServer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_translation"),&TranslationServer::add_translation);
ObjectTypeDB::bind_method(_MD("remove_translation"),&TranslationServer::remove_translation);
+
+ ObjectTypeDB::bind_method(_MD("clear"),&TranslationServer::clear);
+
}
void TranslationServer::load_translations() {
diff --git a/core/translation.h b/core/translation.h
index 1286f48a0b..d690320cd0 100644
--- a/core/translation.h
+++ b/core/translation.h
@@ -60,6 +60,7 @@ public:
void erase_message(const StringName& p_src_text);
void get_message_list(List<StringName> *r_messages) const;
+ int get_message_count() const;
Translation();
};
@@ -103,6 +104,8 @@ public:
void setup();
+ void clear();
+
void load_translations();
TranslationServer();
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 00477e7570..cb0540dbb0 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -2276,6 +2276,24 @@ String String::md5_text() const {
return String::md5(ctx.digest);
}
+Vector<uint8_t> String::md5_buffer() const {
+
+ CharString cs=utf8();
+ MD5_CTX ctx;
+ MD5Init(&ctx);
+ MD5Update(&ctx,(unsigned char*)cs.ptr(),cs.length());
+ MD5Final(&ctx);
+
+ Vector<uint8_t> ret;
+ ret.resize(16);
+ for (int i=0; i<16; i++) {
+ ret[i] = ctx.digest[i];
+ };
+
+ return ret;
+};
+
+
String String::insert(int p_at_pos,String p_string) const {
if (p_at_pos<0)
diff --git a/core/ustring.h b/core/ustring.h
index 13db00f07f..4831341866 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -183,7 +183,8 @@ public:
uint32_t hash() const; /* hash the string */
uint64_t hash64() const; /* hash the string */
String md5_text() const;
-
+ Vector<uint8_t> md5_buffer() const;
+
inline bool empty() const { return length() == 0; }
// path functions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 8cdfce1b0a..8fbccc87ae 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -263,6 +263,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1R(String,ord_at);
//VCALL_LOCALMEM2R(String,erase);
VCALL_LOCALMEM0R(String,hash);
+ VCALL_LOCALMEM0R(String,md5_text);
+ VCALL_LOCALMEM0R(String,md5_buffer);
VCALL_LOCALMEM0R(String,empty);
VCALL_LOCALMEM0R(String,is_abs_path);
VCALL_LOCALMEM0R(String,is_rel_path);
@@ -290,6 +292,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1R(Vector2,distance_to);
VCALL_LOCALMEM1R(Vector2,distance_squared_to);
VCALL_LOCALMEM1R(Vector2,angle_to);
+ VCALL_LOCALMEM1R(Vector2,angle_to_point);
VCALL_LOCALMEM2R(Vector2,linear_interpolate);
VCALL_LOCALMEM4R(Vector2,cubic_interpolate);
VCALL_LOCALMEM1R(Vector2,rotated);
@@ -300,6 +303,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM1R(Vector2,dot);
VCALL_LOCALMEM1R(Vector2,slide);
VCALL_LOCALMEM1R(Vector2,reflect);
+ VCALL_LOCALMEM0R(Vector2,atan2);
// VCALL_LOCALMEM1R(Vector2,cross);
VCALL_LOCALMEM0R(Rect2,get_area);
@@ -327,6 +331,9 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0R(Vector3, abs);
VCALL_LOCALMEM1R(Vector3, distance_to);
VCALL_LOCALMEM1R(Vector3, distance_squared_to);
+ VCALL_LOCALMEM1R(Vector3, slide);
+ VCALL_LOCALMEM1R(Vector3, reflect);
+
VCALL_LOCALMEM0R(Plane,normalized);
VCALL_LOCALMEM0R(Plane,center);
@@ -520,7 +527,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
#define VCALL_PTR3R(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]); }
#define VCALL_PTR4(m_type,m_method)\
-static void _call_##m_type##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); }
+static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Variant** p_args) { reinterpret_cast<m_type*>(p_self._data._ptr)->m_method(*p_args[0],*p_args[1],*p_args[2],*p_args[3]); }
#define VCALL_PTR4R(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]); }
#define VCALL_PTR5(m_type,m_method)\
@@ -533,6 +540,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_PTR0R(Image,get_height);
VCALL_PTR0R(Image,empty);
VCALL_PTR3R(Image,get_pixel);
+ VCALL_PTR4(Image, put_pixel);
VCALL_PTR0R(Image,get_used_rect);
VCALL_PTR3R(Image,brushed);
VCALL_PTR1R(Image,load);
@@ -552,6 +560,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
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 );
@@ -1162,6 +1171,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(STRING,STRING,String,ord_at,INT,"at",varray());
// ADDFUNC2(STRING,String,erase,INT,INT,varray());
ADDFUNC0(STRING,INT,String,hash,varray());
+ ADDFUNC0(STRING,STRING,String,md5_text,varray());
+ ADDFUNC0(STRING,RAW_ARRAY,String,md5_buffer,varray());
ADDFUNC0(STRING,BOOL,String,empty,varray());
ADDFUNC0(STRING,BOOL,String,is_abs_path,varray());
ADDFUNC0(STRING,BOOL,String,is_rel_path,varray());
@@ -1184,10 +1195,12 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(VECTOR2,VECTOR2,Vector2,normalized,varray());
ADDFUNC0(VECTOR2,REAL,Vector2,length,varray());
+ ADDFUNC0(VECTOR2,REAL,Vector2,atan2,varray());
ADDFUNC0(VECTOR2,REAL,Vector2,length_squared,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());
@@ -1226,6 +1239,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(VECTOR3,VECTOR3,Vector3,abs,varray());
ADDFUNC1(VECTOR3,REAL,Vector3,distance_to,VECTOR3,"b",varray());
ADDFUNC1(VECTOR3,REAL,Vector3,distance_squared_to,VECTOR3,"b",varray());
+ ADDFUNC1(VECTOR3,VECTOR3,Vector3,slide,VECTOR3,"by",varray());
+ ADDFUNC1(VECTOR3,VECTOR3,Vector3,reflect,VECTOR3,"by",varray());
ADDFUNC0(PLANE,PLANE,Plane,normalized,varray());
ADDFUNC0(PLANE,VECTOR3,Plane,center,varray());
@@ -1261,6 +1276,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(IMAGE, INT, Image, get_height, varray());
ADDFUNC0(IMAGE, BOOL, Image, empty, varray());
ADDFUNC3(IMAGE, COLOR, Image, get_pixel, INT, "x", INT, "y", INT, "mipmap_level", varray(0));
+ ADDFUNC4(IMAGE, NIL, Image, put_pixel, INT, "x", INT, "y", COLOR, "color", INT, "mipmap_level", varray(0));
ADDFUNC3(IMAGE, IMAGE, Image, brushed, IMAGE, "src", IMAGE, "brush", VECTOR2, "pos", varray(0));
ADDFUNC1(IMAGE, INT, Image, load, STRING, "path", varray(0));
ADDFUNC3(IMAGE, NIL, Image, brush_transfer, IMAGE, "src", IMAGE, "brush", VECTOR2, "pos", varray(0));
@@ -1364,6 +1380,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC1(_AABB,_AABB,AABB,merge,_AABB,"with",varray());
ADDFUNC1(_AABB,_AABB,AABB,intersection,_AABB,"with",varray());
ADDFUNC1(_AABB,BOOL,AABB,intersects_plane,PLANE,"plane",varray());
+ ADDFUNC2(_AABB,BOOL,AABB,intersects_segment,VECTOR3,"from",VECTOR3,"to",varray());
ADDFUNC1(_AABB,BOOL,AABB,has_point,VECTOR3,"point",varray());
ADDFUNC1(_AABB,VECTOR3,AABB,get_support,VECTOR3,"dir",varray());
ADDFUNC0(_AABB,VECTOR3,AABB,get_longest_axis,varray());
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 6c2667c7e9..9c489c5ef2 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -1145,6 +1145,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
if (p_value.type!=Variant::VECTOR3)
return;
+
if (p_index.get_type()==Variant::STRING) {
//scalar name
@@ -1181,6 +1182,24 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid)
v->set_axis(index,p_value);
return;
}
+ } else if (p_index.get_type()==Variant::STRING) {
+
+ const String *str=reinterpret_cast<const String*>(p_index._data._mem);
+ Matrix3 *v=_data._matrix3;
+
+ if (*str=="x") {
+ valid=true;
+ v->set_axis(0,p_value);
+ return;
+ } else if (*str=="y" ) {
+ valid=true;
+ v->set_axis(1,p_value);
+ return;
+ } else if (*str=="z" ) {
+ valid=true;
+ v->set_axis(2,p_value);
+ return;
+ }
}
} break;
@@ -2021,6 +2040,21 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const {
valid=true;
return v->get_axis(index);
}
+ } else if (p_index.get_type()==Variant::STRING) {
+
+ const String *str=reinterpret_cast<const String*>(p_index._data._mem);
+ const Matrix3 *v=_data._matrix3;
+
+ if (*str=="x") {
+ valid=true;
+ return v->get_axis(0);
+ } else if (*str=="y" ) {
+ valid=true;
+ return v->get_axis(1);
+ } else if (*str=="z" ) {
+ valid=true;
+ return v->get_axis(2);
+ }
}
} break;