diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 25 | ||||
-rw-r--r-- | core/bind/core_bind.h | 4 | ||||
-rw-r--r-- | core/io/marshalls.cpp | 2 | ||||
-rw-r--r-- | core/math/geometry.h | 21 | ||||
-rw-r--r-- | core/os/input.cpp | 2 | ||||
-rw-r--r-- | core/os/input.h | 2 | ||||
-rw-r--r-- | core/os/os.h | 2 |
7 files changed, 40 insertions, 18 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 8c57f49069..bd41e48a30 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -163,9 +163,9 @@ _ResourceSaver::_ResourceSaver() { /////////////////OS -Point2 _OS::get_mouse_pos() const { +Point2 _OS::get_mouse_position() const { - return OS::get_singleton()->get_mouse_pos(); + return OS::get_singleton()->get_mouse_position(); } void _OS::set_window_title(const String &p_title) { @@ -954,7 +954,7 @@ _OS *_OS::singleton = NULL; void _OS::_bind_methods() { - //ClassDB::bind_method(D_METHOD("get_mouse_pos"),&_OS::get_mouse_pos); + //ClassDB::bind_method(D_METHOD("get_mouse_position"),&_OS::get_mouse_position); //ClassDB::bind_method(D_METHOD("is_mouse_grab_enabled"),&_OS::is_mouse_grab_enabled); ClassDB::bind_method(D_METHOD("set_clipboard", "clipboard"), &_OS::set_clipboard); @@ -2367,6 +2367,23 @@ Array _ClassDB::get_property_list(StringName p_class, bool p_no_inheritance) con return ret; } +Variant _ClassDB::get_property(Object *p_object, const StringName &p_property) const { + Variant ret; + ClassDB::get_property(p_object, p_property, ret); + return ret; +} + +Error _ClassDB::set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const { + Variant ret; + bool valid; + if (!ClassDB::set_property(p_object, p_property, p_value, &valid)) { + return ERR_UNAVAILABLE; + } else if (!valid) { + return ERR_INVALID_DATA; + } + return OK; +} + bool _ClassDB::has_method(StringName p_class, StringName p_method, bool p_no_inheritance) const { return ClassDB::has_method(p_class, p_method, p_no_inheritance); @@ -2439,6 +2456,8 @@ void _ClassDB::_bind_methods() { ClassDB::bind_method(D_METHOD("class_get_signal_list", "class", "no_inheritance"), &_ClassDB::get_signal_list, DEFVAL(false)); ClassDB::bind_method(D_METHOD("class_get_property_list", "class", "no_inheritance"), &_ClassDB::get_property_list, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("class_get_property:Variant", "object", "property"), &_ClassDB::get_property); + ClassDB::bind_method(D_METHOD("class_set_property:Error", "object", "property", "value"), &_ClassDB::set_property); ClassDB::bind_method(D_METHOD("class_has_method", "class", "method", "no_inheritance"), &_ClassDB::has_method, DEFVAL(false)); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 13956c3373..222339bce1 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -120,7 +120,7 @@ public: MONTH_DECEMBER }; - Point2 get_mouse_pos() const; + Point2 get_mouse_position() const; void set_window_title(const String &p_title); int get_mouse_button_state() const; @@ -587,6 +587,8 @@ public: Array get_signal_list(StringName p_class, bool p_no_inheritance = false) const; Array get_property_list(StringName p_class, bool p_no_inheritance = false) const; + Variant get_property(Object *p_object, const StringName &p_property) const; + Error set_property(Object *p_object, const StringName &p_property, const Variant &p_value) const; bool has_method(StringName p_class, StringName p_method, bool p_no_inheritance = false) const; diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 3889c8f3ae..5e66b7f7f5 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -862,7 +862,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) { } else { if (buf) { - encode_double(p_variant.operator float(), buf); + encode_float(p_variant.operator float(), buf); } r_len += 4; diff --git a/core/math/geometry.h b/core/math/geometry.h index 2469e799a0..909d8164c3 100644 --- a/core/math/geometry.h +++ b/core/math/geometry.h @@ -105,23 +105,23 @@ public: } static void get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2, Vector3 &c1, Vector3 &c2) { -#if 0 - //do the function 'd' as defined by pb. I think is is dot product of some sort +#if 1 +//do the function 'd' as defined by pb. I think is is dot product of some sort #define d_of(m, n, o, p) ((m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z)) //calculate the parametric position on the 2 curves, mua and mub - real_t mua = ( d_of(p1,q1,q2,q1) * d_of(q2,q1,p2,p1) - d_of(p1,q1,p2,p1) * d_of(q2,q1,q2,q1) ) / ( d_of(p2,p1,p2,p1) * d_of(q2,q1,q2,q1) - d_of(q2,q1,p2,p1) * d_of(q2,q1,p2,p1) ); - real_t mub = ( d_of(p1,q1,q2,q1) + mua * d_of(q2,q1,p2,p1) ) / d_of(q2,q1,q2,q1); + real_t mua = (d_of(p1, q1, q2, q1) * d_of(q2, q1, p2, p1) - d_of(p1, q1, p2, p1) * d_of(q2, q1, q2, q1)) / (d_of(p2, p1, p2, p1) * d_of(q2, q1, q2, q1) - d_of(q2, q1, p2, p1) * d_of(q2, q1, p2, p1)); + real_t mub = (d_of(p1, q1, q2, q1) + mua * d_of(q2, q1, p2, p1)) / d_of(q2, q1, q2, q1); //clip the value between [0..1] constraining the solution to lie on the original curves if (mua < 0) mua = 0; if (mub < 0) mub = 0; if (mua > 1) mua = 1; if (mub > 1) mub = 1; - c1 = p1.linear_interpolate(p2,mua); - c2 = q1.linear_interpolate(q2,mub); -#endif - + c1 = p1.linear_interpolate(p2, mua); + c2 = q1.linear_interpolate(q2, mub); +#else + //this is broken do not use Vector3 u = p2 - p1; Vector3 v = q2 - q1; Vector3 w = p1 - q1; @@ -144,8 +144,9 @@ public: c1 = w + sc * u; c2 = w + tc * v; - // get the difference of the two closest points - //Vector dP = w + (sc * u) - (tc * v); // = L1(sc) - L2(tc) +// get the difference of the two closest points +//Vector dP = w + (sc * u) - (tc * v); // = L1(sc) - L2(tc) +#endif } static real_t get_closest_distance_between_segments(const Vector3 &p_from_a, const Vector3 &p_to_a, const Vector3 &p_from_b, const Vector3 &p_to_b) { diff --git a/core/os/input.cpp b/core/os/input.cpp index 6215ad3732..bc388d0bca 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -75,7 +75,7 @@ void Input::_bind_methods() { ClassDB::bind_method(D_METHOD("get_accelerometer"), &Input::get_accelerometer); ClassDB::bind_method(D_METHOD("get_magnetometer"), &Input::get_magnetometer); ClassDB::bind_method(D_METHOD("get_gyroscope"), &Input::get_gyroscope); - //ClassDB::bind_method(D_METHOD("get_mouse_pos"),&Input::get_mouse_pos); - this is not the function you want + //ClassDB::bind_method(D_METHOD("get_mouse_position"),&Input::get_mouse_position); - this is not the function you want ClassDB::bind_method(D_METHOD("get_last_mouse_speed"), &Input::get_last_mouse_speed); ClassDB::bind_method(D_METHOD("get_mouse_button_mask"), &Input::get_mouse_button_mask); ClassDB::bind_method(D_METHOD("set_mouse_mode", "mode"), &Input::set_mouse_mode); diff --git a/core/os/input.h b/core/os/input.h index 4b297a7eef..4f26f097c2 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -77,7 +77,7 @@ public: virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0) = 0; virtual void stop_joy_vibration(int p_device) = 0; - virtual Point2 get_mouse_pos() const = 0; + virtual Point2 get_mouse_position() const = 0; virtual Point2 get_last_mouse_speed() const = 0; virtual int get_mouse_button_mask() const = 0; diff --git a/core/os/os.h b/core/os/os.h index 0abc91e35e..ff2a24f40d 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -144,7 +144,7 @@ public: virtual MouseMode get_mouse_mode() const; virtual void warp_mouse_pos(const Point2 &p_to) {} - virtual Point2 get_mouse_pos() const = 0; + virtual Point2 get_mouse_position() const = 0; virtual int get_mouse_button_state() const = 0; virtual void set_window_title(const String &p_title) = 0; |