summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bind/core_bind.cpp14
-rw-r--r--core/error_macros.h10
-rw-r--r--core/input_map.cpp67
-rw-r--r--core/input_map.h7
-rw-r--r--core/math/matrix3.cpp63
-rw-r--r--core/math/matrix3.h15
-rw-r--r--core/math/transform.cpp4
-rw-r--r--core/os/input.cpp3
-rw-r--r--core/os/input.h1
-rw-r--r--core/os/input_event.cpp83
-rw-r--r--core/os/input_event.h22
-rw-r--r--core/project_settings.cpp21
-rw-r--r--core/project_settings.h2
-rw-r--r--core/string_db.cpp13
-rw-r--r--core/string_db.h1
-rw-r--r--core/ustring.cpp28
-rw-r--r--doc/classes/Dictionary.xml1
-rw-r--r--doc/classes/GraphEdit.xml1
-rw-r--r--doc/classes/Object.xml1
-rw-r--r--doc/classes/SceneTree.xml4
-rw-r--r--doc/classes/Script.xml1
-rw-r--r--doc/classes/ScrollBar.xml1
-rw-r--r--doc/classes/ScrollContainer.xml2
-rw-r--r--doc/classes/SplitContainer.xml1
-rw-r--r--doc/classes/TileMap.xml2
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp3
-rw-r--r--drivers/gles3/shaders/canvas.glsl59
-rw-r--r--drivers/windows/file_access_windows.cpp23
-rw-r--r--editor/plugins/skeleton_2d_editor_plugin.cpp5
-rw-r--r--editor/plugins/sprite_editor_plugin.cpp5
-rw-r--r--editor/project_export.cpp4
-rw-r--r--editor/project_settings_editor.cpp169
-rw-r--r--editor/project_settings_editor.h2
-rw-r--r--main/input_default.cpp18
-rw-r--r--main/input_default.h2
-rw-r--r--main/main.cpp4
-rw-r--r--modules/bullet/collision_object_bullet.cpp4
-rw-r--r--modules/bullet/godot_result_callbacks.cpp10
-rw-r--r--modules/bullet/space_bullet.cpp6
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp7
-rw-r--r--modules/mono/glue/cs_files/AABB.cs102
-rw-r--r--modules/mono/glue/cs_files/Basis.cs129
-rw-r--r--modules/mono/glue/cs_files/Color.cs96
-rw-r--r--modules/mono/glue/cs_files/DebuggingUtils.cs4
-rw-r--r--modules/mono/glue/cs_files/GD.cs12
-rw-r--r--modules/mono/glue/cs_files/GodotMethodAttribute.cs2
-rw-r--r--modules/mono/glue/cs_files/GodotSynchronizationContext.cs1
-rw-r--r--modules/mono/glue/cs_files/GodotTaskScheduler.cs2
-rw-r--r--modules/mono/glue/cs_files/IAwaiter.cs1
-rw-r--r--modules/mono/glue/cs_files/MarshalUtils.cs6
-rw-r--r--modules/mono/glue/cs_files/Mathf.cs31
-rw-r--r--modules/mono/glue/cs_files/Plane.cs17
-rw-r--r--modules/mono/glue/cs_files/Quat.cs49
-rw-r--r--modules/mono/glue/cs_files/Rect2.cs53
-rw-r--r--modules/mono/glue/cs_files/SignalAttribute.cs3
-rw-r--r--modules/mono/glue/cs_files/SignalAwaiter.cs12
-rw-r--r--modules/mono/glue/cs_files/StringExtensions.cs76
-rw-r--r--modules/mono/glue/cs_files/Transform.cs21
-rw-r--r--modules/mono/glue/cs_files/Transform2D.cs51
-rw-r--r--modules/mono/glue/cs_files/Vector2.cs68
-rw-r--r--modules/mono/glue/cs_files/Vector3.cs68
-rw-r--r--platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java12
-rw-r--r--platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java14
-rw-r--r--platform/iphone/in_app_store.mm1
-rw-r--r--scene/2d/canvas_item.cpp3
-rw-r--r--scene/2d/path_2d.cpp3
-rw-r--r--scene/2d/sprite.cpp24
-rw-r--r--scene/3d/spatial.cpp4
-rw-r--r--scene/animation/animation_player.cpp4
-rw-r--r--scene/animation/animation_tree_player.cpp3
-rw-r--r--scene/gui/color_picker.cpp9
-rw-r--r--scene/gui/color_picker.h2
-rw-r--r--scene/gui/line_edit.cpp14
-rw-r--r--scene/gui/text_edit.cpp12
-rw-r--r--servers/visual/shader_types.cpp2
75 files changed, 909 insertions, 691 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 85793f127d..34d48b2b09 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -639,8 +639,8 @@ uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
unsigned int second = ((datetime.has(SECOND_KEY)) ? static_cast<unsigned int>(datetime[SECOND_KEY]) : 0);
unsigned int minute = ((datetime.has(MINUTE_KEY)) ? static_cast<unsigned int>(datetime[MINUTE_KEY]) : 0);
unsigned int hour = ((datetime.has(HOUR_KEY)) ? static_cast<unsigned int>(datetime[HOUR_KEY]) : 0);
- unsigned int day = ((datetime.has(DAY_KEY)) ? static_cast<unsigned int>(datetime[DAY_KEY]) : 0);
- unsigned int month = ((datetime.has(MONTH_KEY)) ? static_cast<unsigned int>(datetime[MONTH_KEY]) - 1 : 0);
+ unsigned int day = ((datetime.has(DAY_KEY)) ? static_cast<unsigned int>(datetime[DAY_KEY]) : 1);
+ unsigned int month = ((datetime.has(MONTH_KEY)) ? static_cast<unsigned int>(datetime[MONTH_KEY]) : 1);
unsigned int year = ((datetime.has(YEAR_KEY)) ? static_cast<unsigned int>(datetime[YEAR_KEY]) : 0);
/// How many days come before each month (0-12)
@@ -660,15 +660,15 @@ uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
ERR_EXPLAIN("Invalid hour value of: " + itos(hour));
ERR_FAIL_COND_V(hour > 23, 0);
- ERR_EXPLAIN("Invalid month value of: " + itos(month + 1));
- ERR_FAIL_COND_V(month + 1 > 12, 0);
+ ERR_EXPLAIN("Invalid month value of: " + itos(month));
+ ERR_FAIL_COND_V(month > 12 || month == 0, 0);
// Do this check after month is tested as valid
- ERR_EXPLAIN("Invalid day value of: " + itos(day) + " which is larger than " + itos(MONTH_DAYS_TABLE[LEAPYEAR(year)][month]));
- ERR_FAIL_COND_V(day > MONTH_DAYS_TABLE[LEAPYEAR(year)][month], 0);
+ ERR_EXPLAIN("Invalid day value of: " + itos(day) + " which is larger than " + itos(MONTH_DAYS_TABLE[LEAPYEAR(year)][month - 1]) + " or 0");
+ ERR_FAIL_COND_V(day > MONTH_DAYS_TABLE[LEAPYEAR(year)][month - 1] || day == 0, 0);
// Calculate all the seconds from months past in this year
- uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR = DAYS_PAST_THIS_YEAR_TABLE[LEAPYEAR(year)][month] * SECONDS_PER_DAY;
+ uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR = DAYS_PAST_THIS_YEAR_TABLE[LEAPYEAR(year)][month - 1] * SECONDS_PER_DAY;
uint64_t SECONDS_FROM_YEARS_PAST = 0;
for (unsigned int iyear = EPOCH_YR; iyear < year; iyear++) {
diff --git a/core/error_macros.h b/core/error_macros.h
index b8d0c7e0c3..168b2e06fe 100644
--- a/core/error_macros.h
+++ b/core/error_macros.h
@@ -311,4 +311,14 @@ extern bool _err_error_exists;
_err_error_exists = false; \
}
+#define WARN_DEPRECATED \
+ { \
+ static bool warning_shown=false;\
+ if (!warning_shown) {\
+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__,"This method has been deprecated and will be removed in the future", ERR_HANDLER_WARNING); \
+ _err_error_exists = false; \
+ warning_shown=true;\
+ }\
+ }
+
#endif
diff --git a/core/input_map.cpp b/core/input_map.cpp
index ea724d2595..973edcb5b5 100644
--- a/core/input_map.cpp
+++ b/core/input_map.cpp
@@ -41,9 +41,10 @@ void InputMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("has_action", "action"), &InputMap::has_action);
ClassDB::bind_method(D_METHOD("get_actions"), &InputMap::_get_actions);
- ClassDB::bind_method(D_METHOD("add_action", "action"), &InputMap::add_action);
+ ClassDB::bind_method(D_METHOD("add_action", "action", "deadzone"), &InputMap::add_action, DEFVAL(0.5f));
ClassDB::bind_method(D_METHOD("erase_action", "action"), &InputMap::erase_action);
+ ClassDB::bind_method(D_METHOD("action_set_deadzone", "deadzone"), &InputMap::action_set_deadzone);
ClassDB::bind_method(D_METHOD("action_add_event", "action", "event"), &InputMap::action_add_event);
ClassDB::bind_method(D_METHOD("action_has_event", "action", "event"), &InputMap::action_has_event);
ClassDB::bind_method(D_METHOD("action_erase_event", "action", "event"), &InputMap::action_erase_event);
@@ -52,12 +53,13 @@ void InputMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("load_from_globals"), &InputMap::load_from_globals);
}
-void InputMap::add_action(const StringName &p_action) {
+void InputMap::add_action(const StringName &p_action, float p_deadzone) {
ERR_FAIL_COND(input_map.has(p_action));
input_map[p_action] = Action();
static int last_id = 1;
input_map[p_action].id = last_id;
+ input_map[p_action].deadzone = p_deadzone;
last_id++;
}
@@ -96,9 +98,9 @@ List<StringName> InputMap::get_actions() const {
return actions;
}
-List<Ref<InputEvent> >::Element *InputMap::_find_event(List<Ref<InputEvent> > &p_list, const Ref<InputEvent> &p_event, bool p_action_test) const {
+List<Ref<InputEvent> >::Element *InputMap::_find_event(Action p_action, const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength) const {
- for (List<Ref<InputEvent> >::Element *E = p_list.front(); E; E = E->next()) {
+ for (List<Ref<InputEvent> >::Element *E = p_action.inputs.front(); E; E = E->next()) {
const Ref<InputEvent> e = E->get();
@@ -106,9 +108,11 @@ List<Ref<InputEvent> >::Element *InputMap::_find_event(List<Ref<InputEvent> > &p
// continue;
int device = e->get_device();
- if (device == ALL_DEVICES || device == p_event->get_device())
- if (e->action_match(p_event))
+ if (device == ALL_DEVICES || device == p_event->get_device()) {
+ if (e->action_match(p_event, p_pressed, p_strength, p_action.deadzone)) {
return E;
+ }
+ }
}
return NULL;
@@ -119,11 +123,18 @@ bool InputMap::has_action(const StringName &p_action) const {
return input_map.has(p_action);
}
+void InputMap::action_set_deadzone(const StringName &p_action, float p_deadzone) {
+
+ ERR_FAIL_COND(!input_map.has(p_action));
+
+ input_map[p_action].deadzone = p_deadzone;
+}
+
void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
ERR_FAIL_COND(!input_map.has(p_action));
- if (_find_event(input_map[p_action].inputs, p_event))
+ if (_find_event(input_map[p_action], p_event))
return; //already gots
input_map[p_action].inputs.push_back(p_event);
@@ -132,14 +143,14 @@ void InputMap::action_add_event(const StringName &p_action, const Ref<InputEvent
bool InputMap::action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND_V(!input_map.has(p_action), false);
- return (_find_event(input_map[p_action].inputs, p_event) != NULL);
+ return (_find_event(input_map[p_action], p_event) != NULL);
}
void InputMap::action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(!input_map.has(p_action));
- List<Ref<InputEvent> >::Element *E = _find_event(input_map[p_action].inputs, p_event);
+ List<Ref<InputEvent> >::Element *E = _find_event(input_map[p_action], p_event);
if (E)
input_map[p_action].inputs.erase(E);
}
@@ -168,19 +179,33 @@ const List<Ref<InputEvent> > *InputMap::get_action_list(const StringName &p_acti
}
bool InputMap::event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action) const {
+ return event_get_action_status(p_event, p_action);
+}
+bool InputMap::event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool *p_pressed, float *p_strength) const {
Map<StringName, Action>::Element *E = input_map.find(p_action);
if (!E) {
ERR_EXPLAIN("Request for nonexistent InputMap action: " + String(p_action));
ERR_FAIL_COND_V(!E, false);
}
- Ref<InputEventAction> iea = p_event;
- if (iea.is_valid()) {
- return iea->get_action() == p_action;
+ Ref<InputEventAction> input_event_action = p_event;
+ if (input_event_action.is_valid()) {
+ return input_event_action->get_action() == p_action;
}
- return _find_event(E->get().inputs, p_event, true) != NULL;
+ bool pressed;
+ float strength;
+ List<Ref<InputEvent> >::Element *event = _find_event(E->get(), p_event, &pressed, &strength);
+ if (event != NULL) {
+ if (p_pressed != NULL)
+ *p_pressed = pressed;
+ if (p_strength != NULL)
+ *p_strength = strength;
+ return true;
+ } else {
+ return false;
+ }
}
const Map<StringName, InputMap::Action> &InputMap::get_action_map() const {
@@ -202,16 +227,16 @@ void InputMap::load_from_globals() {
String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length());
- add_action(name);
-
- Array va = ProjectSettings::get_singleton()->get(pi.name);
-
- for (int i = 0; i < va.size(); i++) {
+ Dictionary action = ProjectSettings::get_singleton()->get(pi.name);
+ float deadzone = action.has("deadzone") ? (float)action["deadzone"] : 0.5f;
+ Array events = action["events"];
- Ref<InputEvent> ie = va[i];
- if (ie.is_null())
+ add_action(name, deadzone);
+ for (int i = 0; i < events.size(); i++) {
+ Ref<InputEvent> event = events[i];
+ if (event.is_null())
continue;
- action_add_event(name, ie);
+ action_add_event(name, event);
}
}
}
diff --git a/core/input_map.h b/core/input_map.h
index 9f3c13c2cf..a00be8c859 100644
--- a/core/input_map.h
+++ b/core/input_map.h
@@ -46,6 +46,7 @@ public:
struct Action {
int id;
+ float deadzone;
List<Ref<InputEvent> > inputs;
};
@@ -54,7 +55,7 @@ private:
mutable Map<StringName, Action> input_map;
- List<Ref<InputEvent> >::Element *_find_event(List<Ref<InputEvent> > &p_list, const Ref<InputEvent> &p_event, bool p_action_test = false) const;
+ List<Ref<InputEvent> >::Element *_find_event(Action p_action, const Ref<InputEvent> &p_event, bool *p_pressed = NULL, float *p_strength = NULL) const;
Array _get_action_list(const StringName &p_action);
Array _get_actions();
@@ -67,15 +68,17 @@ public:
bool has_action(const StringName &p_action) const;
List<StringName> get_actions() const;
- void add_action(const StringName &p_action);
+ void add_action(const StringName &p_action, float p_deadzone = 0.5);
void erase_action(const StringName &p_action);
+ void action_set_deadzone(const StringName &p_action, float p_deadzone);
void action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event);
bool action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event);
void action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event);
const List<Ref<InputEvent> > *get_action_list(const StringName &p_action);
bool event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action) const;
+ bool event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool *p_pressed = NULL, float *p_strength = NULL) const;
const Map<StringName, Action> &get_action_map() const;
void load_from_globals();
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp
index 189b1ef9b3..b0b05d1ec8 100644
--- a/core/math/matrix3.cpp
+++ b/core/math/matrix3.cpp
@@ -254,7 +254,7 @@ void Basis::set_scale(const Vector3 &p_scale) {
set_axis(2, get_axis(2).normalized() * p_scale.z);
}
-Vector3 Basis::get_scale() const {
+Vector3 Basis::get_scale_abs() const {
return Vector3(
Vector3(elements[0][0], elements[1][0], elements[2][0]).length(),
@@ -262,7 +262,13 @@ Vector3 Basis::get_scale() const {
Vector3(elements[0][2], elements[1][2], elements[2][2]).length());
}
-Vector3 Basis::get_signed_scale() const {
+Vector3 Basis::get_scale_local() const {
+ real_t det_sign = determinant() > 0 ? 1 : -1;
+ return det_sign * Vector3(elements[0].length(), elements[1].length(), elements[2].length());
+}
+
+// get_scale works with get_rotation, use get_scale_abs if you need to enforce positive signature.
+Vector3 Basis::get_scale() const {
// FIXME: We are assuming M = R.S (R is rotation and S is scaling), and use polar decomposition to extract R and S.
// A polar decomposition is M = O.P, where O is an orthogonal matrix (meaning rotation and reflection) and
// P is a positive semi-definite matrix (meaning it contains absolute values of scaling along its diagonal).
@@ -342,6 +348,14 @@ void Basis::rotate(const Vector3 &p_euler) {
*this = rotated(p_euler);
}
+Basis Basis::rotated(const Quat &p_quat) const {
+ return Basis(p_quat) * (*this);
+}
+
+void Basis::rotate(const Quat &p_quat) {
+ *this = rotated(p_quat);
+}
+
// TODO: rename this to get_rotation_euler
Vector3 Basis::get_rotation() const {
// Assumes that the matrix can be decomposed into a proper rotation and scaling matrix as M = R.S,
@@ -371,6 +385,22 @@ void Basis::get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const {
m.get_axis_angle(p_axis, p_angle);
}
+void Basis::get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) const {
+ // Assumes that the matrix can be decomposed into a proper rotation and scaling matrix as M = R.S,
+ // and returns the Euler angles corresponding to the rotation part, complementing get_scale().
+ // See the comment in get_scale() for further information.
+ Basis m = transposed();
+ m.orthonormalize();
+ real_t det = m.determinant();
+ if (det < 0) {
+ // Ensure that the determinant is 1, such that result is a proper rotation matrix which can be represented by Euler angles.
+ m.scale(Vector3(-1, -1, -1));
+ }
+
+ m.get_axis_angle(p_axis, p_angle);
+ p_angle = -p_angle;
+}
+
// get_euler_xyz returns a vector containing the Euler angles in the format
// (a1,a2,a3), where a3 is the angle of the first rotation, and a1 is the last
// (following the convention they are commonly defined in the literature).
@@ -767,3 +797,32 @@ void Basis::set_axis_angle(const Vector3 &p_axis, real_t p_phi) {
elements[2][1] = p_axis.y * p_axis.z * (1.0 - cosine) + p_axis.x * sine;
elements[2][2] = axis_sq.z + cosine * (1.0 - axis_sq.z);
}
+
+void Basis::set_axis_angle_scale(const Vector3 &p_axis, real_t p_phi, const Vector3 &p_scale) {
+ set_diagonal(p_scale);
+ rotate(p_axis, p_phi);
+}
+
+void Basis::set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale) {
+ set_diagonal(p_scale);
+ rotate(p_euler);
+}
+
+void Basis::set_quat_scale(const Quat &p_quat, const Vector3 &p_scale) {
+ set_diagonal(p_scale);
+ rotate(p_quat);
+}
+
+void Basis::set_diagonal(const Vector3 p_diag) {
+ elements[0][0] = p_diag.x;
+ elements[0][1] = 0;
+ elements[0][2] = 0;
+
+ elements[1][0] = 0;
+ elements[1][1] = p_diag.y;
+ elements[1][2] = 0;
+
+ elements[2][0] = 0;
+ elements[2][1] = 0;
+ elements[2][2] = p_diag.z;
+}
diff --git a/core/math/matrix3.h b/core/math/matrix3.h
index c426435729..fd383fc673 100644
--- a/core/math/matrix3.h
+++ b/core/math/matrix3.h
@@ -81,8 +81,12 @@ public:
void rotate(const Vector3 &p_euler);
Basis rotated(const Vector3 &p_euler) const;
+ void rotate(const Quat &p_quat);
+ Basis rotated(const Quat &p_quat) const;
+
Vector3 get_rotation() const;
void get_rotation_axis_angle(Vector3 &p_axis, real_t &p_angle) const;
+ void get_rotation_axis_angle_local(Vector3 &p_axis, real_t &p_angle) const;
Vector3 rotref_posscale_decomposition(Basis &rotref) const;
@@ -108,7 +112,12 @@ public:
void set_scale(const Vector3 &p_scale);
Vector3 get_scale() const;
- Vector3 get_signed_scale() const;
+ Vector3 get_scale_abs() const;
+ Vector3 get_scale_local() const;
+
+ void set_axis_angle_scale(const Vector3 &p_axis, real_t p_phi, const Vector3 &p_scale);
+ void set_euler_scale(const Vector3 &p_euler, const Vector3 &p_scale);
+ void set_quat_scale(const Quat &p_quat, const Vector3 &p_scale);
// transposed dot products
_FORCE_INLINE_ real_t tdotx(const Vector3 &v) const {
@@ -140,6 +149,8 @@ public:
int get_orthogonal_index() const;
void set_orthogonal_index(int p_index);
+ void set_diagonal(const Vector3 p_diag);
+
bool is_orthogonal() const;
bool is_diagonal() const;
bool is_rotation() const;
@@ -219,6 +230,8 @@ public:
Basis(const Quat &p_quat) { set_quat(p_quat); };
Basis(const Vector3 &p_euler) { set_euler(p_euler); }
Basis(const Vector3 &p_axis, real_t p_phi) { set_axis_angle(p_axis, p_phi); }
+ Basis(const Vector3 &p_axis, real_t p_phi, const Vector3 &p_scale) { set_axis_angle_scale(p_axis, p_phi, p_scale); }
+ Basis(const Quat &p_quat, const Vector3 &p_scale) { set_quat_scale(p_quat, p_scale); }
_FORCE_INLINE_ Basis(const Vector3 &row0, const Vector3 &row1, const Vector3 &row2) {
elements[0] = row0;
diff --git a/core/math/transform.cpp b/core/math/transform.cpp
index f727d00e30..7cd186ca60 100644
--- a/core/math/transform.cpp
+++ b/core/math/transform.cpp
@@ -119,11 +119,11 @@ Transform Transform::interpolate_with(const Transform &p_transform, real_t p_c)
/* not sure if very "efficient" but good enough? */
- Vector3 src_scale = basis.get_signed_scale();
+ Vector3 src_scale = basis.get_scale();
Quat src_rot = basis.orthonormalized();
Vector3 src_loc = origin;
- Vector3 dst_scale = p_transform.basis.get_signed_scale();
+ Vector3 dst_scale = p_transform.basis.get_scale();
Quat dst_rot = p_transform.basis;
Vector3 dst_loc = p_transform.origin;
diff --git a/core/os/input.cpp b/core/os/input.cpp
index e8a635e1b5..a5b0f91e63 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -57,6 +57,7 @@ void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &Input::is_action_pressed);
ClassDB::bind_method(D_METHOD("is_action_just_pressed", "action"), &Input::is_action_just_pressed);
ClassDB::bind_method(D_METHOD("is_action_just_released", "action"), &Input::is_action_just_released);
+ ClassDB::bind_method(D_METHOD("get_action_strength", "action"), &Input::get_action_strength);
ClassDB::bind_method(D_METHOD("add_joy_mapping", "mapping", "update_existing"), &Input::add_joy_mapping, DEFVAL(false));
ClassDB::bind_method(D_METHOD("remove_joy_mapping", "guid"), &Input::remove_joy_mapping);
ClassDB::bind_method(D_METHOD("joy_connection_changed", "device", "connected", "name", "guid"), &Input::joy_connection_changed);
@@ -119,7 +120,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S
#ifdef TOOLS_ENABLED
String pf = p_function;
- if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released")) {
+ if (p_idx == 0 && (pf == "is_action_pressed" || pf == "action_press" || pf == "action_release" || pf == "is_action_just_pressed" || pf == "is_action_just_released" || pf == "get_action_strength")) {
List<PropertyInfo> pinfo;
ProjectSettings::get_singleton()->get_property_list(&pinfo);
diff --git a/core/os/input.h b/core/os/input.h
index fca68f27b7..027147b987 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -85,6 +85,7 @@ public:
virtual bool is_action_pressed(const StringName &p_action) const = 0;
virtual bool is_action_just_pressed(const StringName &p_action) const = 0;
virtual bool is_action_just_released(const StringName &p_action) const = 0;
+ virtual float get_action_strength(const StringName &p_action) const = 0;
virtual float get_joy_axis(int p_device, int p_axis) const = 0;
virtual String get_joy_name(int p_idx) = 0;
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index b9607632f7..5003be77ab 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -41,11 +41,6 @@ int InputEvent::get_device() const {
return device;
}
-bool InputEvent::is_pressed() const {
-
- return false;
-}
-
bool InputEvent::is_action(const StringName &p_action) const {
return InputMap::get_singleton()->event_is_action(Ref<InputEvent>((InputEvent *)this), p_action);
@@ -53,11 +48,29 @@ bool InputEvent::is_action(const StringName &p_action) const {
bool InputEvent::is_action_pressed(const StringName &p_action) const {
- return (is_pressed() && !is_echo() && is_action(p_action));
+ bool pressed;
+ bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed);
+ return valid && pressed && !is_echo();
}
+
bool InputEvent::is_action_released(const StringName &p_action) const {
- return (!is_pressed() && is_action(p_action));
+ bool pressed;
+ bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed);
+ return valid && !pressed;
+}
+
+float InputEvent::get_action_strength(const StringName &p_action) const {
+
+ bool pressed;
+ float strength;
+ bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed, &strength);
+ return valid ? strength : 0.0f;
+}
+
+bool InputEvent::is_pressed() const {
+
+ return false;
}
bool InputEvent::is_echo() const {
@@ -75,7 +88,7 @@ String InputEvent::as_text() const {
return String();
}
-bool InputEvent::action_match(const Ref<InputEvent> &p_event) const {
+bool InputEvent::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
return false;
}
@@ -95,15 +108,16 @@ void InputEvent::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_device", "device"), &InputEvent::set_device);
ClassDB::bind_method(D_METHOD("get_device"), &InputEvent::get_device);
- ClassDB::bind_method(D_METHOD("is_pressed"), &InputEvent::is_pressed);
ClassDB::bind_method(D_METHOD("is_action", "action"), &InputEvent::is_action);
ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &InputEvent::is_action_pressed);
ClassDB::bind_method(D_METHOD("is_action_released", "action"), &InputEvent::is_action_released);
+ ClassDB::bind_method(D_METHOD("get_action_strength", "action"), &InputEvent::get_action_strength);
+
+ ClassDB::bind_method(D_METHOD("is_pressed"), &InputEvent::is_pressed);
ClassDB::bind_method(D_METHOD("is_echo"), &InputEvent::is_echo);
ClassDB::bind_method(D_METHOD("as_text"), &InputEvent::as_text);
- ClassDB::bind_method(D_METHOD("action_match", "event"), &InputEvent::action_match);
ClassDB::bind_method(D_METHOD("shortcut_match", "event"), &InputEvent::shortcut_match);
ClassDB::bind_method(D_METHOD("is_action_type"), &InputEvent::is_action_type);
@@ -281,7 +295,7 @@ String InputEventKey::as_text() const {
return kc;
}
-bool InputEventKey::action_match(const Ref<InputEvent> &p_event) const {
+bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
Ref<InputEventKey> key = p_event;
if (key.is_null())
@@ -290,7 +304,14 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event) const {
uint32_t code = get_scancode_with_modifiers();
uint32_t event_code = key->get_scancode_with_modifiers();
- return get_scancode() == key->get_scancode() && (!key->is_pressed() || (code & event_code) == code);
+ bool match = get_scancode() == key->get_scancode() && (!key->is_pressed() || (code & event_code) == code);
+ if (match) {
+ if (p_pressed != NULL)
+ *p_pressed = key->is_pressed();
+ if (p_strength != NULL)
+ *p_strength = (*p_pressed) ? 1.0f : 0.0f;
+ }
+ return match;
}
bool InputEventKey::shortcut_match(const Ref<InputEvent> &p_event) const {
@@ -446,13 +467,21 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co
return mb;
}
-bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event) const {
+bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_null())
return false;
- return mb->button_index == button_index;
+ bool match = mb->button_index == button_index;
+ if (match) {
+ if (p_pressed != NULL)
+ *p_pressed = mb->is_pressed();
+ if (p_strength != NULL)
+ *p_strength = (*p_pressed) ? 1.0f : 0.0f;
+ }
+
+ return match;
}
String InputEventMouseButton::as_text() const {
@@ -610,6 +639,7 @@ void InputEventJoypadMotion::set_axis_value(float p_value) {
axis_value = p_value;
}
+
float InputEventJoypadMotion::get_axis_value() const {
return axis_value;
@@ -617,16 +647,23 @@ float InputEventJoypadMotion::get_axis_value() const {
bool InputEventJoypadMotion::is_pressed() const {
- return Math::abs(axis_value) > 0.5f;
+ return Math::abs(axis_value) >= 0.5f;
}
-bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event) const {
+bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
Ref<InputEventJoypadMotion> jm = p_event;
if (jm.is_null())
return false;
- return (axis == jm->axis && ((axis_value < 0) == (jm->axis_value < 0) || jm->axis_value == 0));
+ bool match = (axis == jm->axis && (((axis_value < 0) == (jm->axis_value < 0)) || jm->axis_value == 0));
+ if (match) {
+ if (p_pressed != NULL)
+ *p_pressed = Math::abs(jm->get_axis_value()) >= p_deadzone;
+ if (p_strength != NULL)
+ *p_strength = (*p_pressed) ? Math::inverse_lerp(p_deadzone, 1.0f, Math::abs(jm->get_axis_value())) : 0.0f;
+ }
+ return match;
}
String InputEventJoypadMotion::as_text() const {
@@ -681,13 +718,21 @@ float InputEventJoypadButton::get_pressure() const {
return pressure;
}
-bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event) const {
+bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
Ref<InputEventJoypadButton> jb = p_event;
if (jb.is_null())
return false;
- return button_index == jb->button_index;
+ bool match = button_index == jb->button_index;
+ if (match) {
+ if (p_pressed != NULL)
+ *p_pressed = jb->is_pressed();
+ if (p_strength != NULL)
+ *p_strength = (*p_pressed) ? 1.0f : 0.0f;
+ }
+
+ return match;
}
String InputEventJoypadButton::as_text() const {
diff --git a/core/os/input_event.h b/core/os/input_event.h
index 0a33ab18a7..037649ed60 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -154,16 +154,21 @@ public:
void set_device(int p_device);
int get_device() const;
+ bool is_action(const StringName &p_action) const;
+ bool is_action_pressed(const StringName &p_action) const;
+ bool is_action_released(const StringName &p_action) const;
+ float get_action_strength(const StringName &p_action) const;
+
+ // To be removed someday, since they do not make sense for all events
virtual bool is_pressed() const;
- virtual bool is_action(const StringName &p_action) const;
- virtual bool is_action_pressed(const StringName &p_action) const;
- virtual bool is_action_released(const StringName &p_action) const;
virtual bool is_echo() const;
+ // ...-.
+
virtual String as_text() const;
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
- virtual bool action_match(const Ref<InputEvent> &p_event) const;
+ virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
virtual bool is_action_type() const;
@@ -244,7 +249,7 @@ public:
uint32_t get_scancode_with_modifiers() const;
- virtual bool action_match(const Ref<InputEvent> &p_event) const;
+ virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
virtual bool is_action_type() const { return true; }
@@ -305,7 +310,7 @@ public:
bool is_doubleclick() const;
virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const;
- virtual bool action_match(const Ref<InputEvent> &p_event) const;
+ virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
virtual bool is_action_type() const { return true; }
virtual String as_text() const;
@@ -352,7 +357,8 @@ public:
float get_axis_value() const;
virtual bool is_pressed() const;
- virtual bool action_match(const Ref<InputEvent> &p_event) const;
+
+ virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
virtual bool is_action_type() const { return true; }
virtual String as_text() const;
@@ -379,7 +385,7 @@ public:
void set_pressure(float p_pressure);
float get_pressure() const;
- virtual bool action_match(const Ref<InputEvent> &p_event) const;
+ virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
virtual bool is_action_type() const { return true; }
virtual String as_text() const;
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index 20d91e7940..d3a62263ac 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -42,7 +42,7 @@
#include "variant_parser.h"
#include <zlib.h>
-#define FORMAT_VERSION 3
+#define FORMAT_VERSION 4
ProjectSettings *ProjectSettings::singleton = NULL;
@@ -262,6 +262,23 @@ bool ProjectSettings::_load_resource_pack(const String &p_pack) {
return true;
}
+void ProjectSettings::_convert_to_last_version() {
+ if (!has_setting("config_version") || (int)get_setting("config_version") <= 3) {
+
+ // Converts the actions from array to dictionary (array of events to dictionary with deadzone + events)
+ for (Map<StringName, ProjectSettings::VariantContainer>::Element *E = props.front(); E; E = E->next()) {
+ Variant value = E->get().variant;
+ if (String(E->key()).begins_with("input/") && value.get_type() == Variant::ARRAY) {
+ Array array = value;
+ Dictionary action;
+ action["deadzone"] = Variant(0.5f);
+ action["events"] = array;
+ E->get().variant = action;
+ }
+ }
+ }
+}
+
Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bool p_upwards) {
//If looking for files in network, just use network!
@@ -390,6 +407,8 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo
if (resource_path.length() && resource_path[resource_path.length() - 1] == '/')
resource_path = resource_path.substr(0, resource_path.length() - 1); // chop end
+ _convert_to_last_version();
+
return OK;
}
diff --git a/core/project_settings.h b/core/project_settings.h
index 9b51bc3ac3..b01e7855aa 100644
--- a/core/project_settings.h
+++ b/core/project_settings.h
@@ -102,6 +102,8 @@ protected:
Error _save_custom_bnd(const String &p_file);
+ void _convert_to_last_version();
+
bool _load_resource_pack(const String &p_pack);
void _add_property_info_bind(const Dictionary &p_info);
diff --git a/core/string_db.cpp b/core/string_db.cpp
index 6e1f887754..2475cbe3e8 100644
--- a/core/string_db.cpp
+++ b/core/string_db.cpp
@@ -164,21 +164,14 @@ void StringName::operator=(const StringName &p_name) {
_data = p_name._data;
}
}
-/* was inlined
-StringName::operator String() const {
- if (_data)
- return _data->get_name();
-
- return "";
-}
-*/
StringName::StringName(const StringName &p_name) {
- ERR_FAIL_COND(!configured);
_data = NULL;
- if (p_name._data && p_name._data->refcount.ref()) {
+ ERR_FAIL_COND(!configured);
+
+ if (p_name._data && p_name._data->refcount.ref()) {
_data = p_name._data;
}
}
diff --git a/core/string_db.h b/core/string_db.h
index 28ca812a45..01d1ca4033 100644
--- a/core/string_db.h
+++ b/core/string_db.h
@@ -67,6 +67,7 @@ class StringName {
_Data() {
cname = NULL;
next = prev = NULL;
+ idx = 0;
hash = 0;
}
};
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 954f590218..0eb6cc1be4 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -1151,7 +1151,7 @@ String String::num_uint64(uint64_t p_num, int base, bool capitalize_hex) {
c[chars] = 0;
n = p_num;
do {
- int mod = ABS(n % base);
+ int mod = n % base;
if (mod >= 10) {
char a = (capitalize_hex ? 'A' : 'a');
c[--chars] = a + (mod - 10);
@@ -1550,8 +1550,7 @@ String::String(const StrRange &p_range) {
int String::hex_to_int(bool p_with_prefix) const {
- int l = length();
- if (p_with_prefix && l < 3)
+ if (p_with_prefix && length() < 3)
return 0;
const CharType *s = ptr();
@@ -1560,17 +1559,13 @@ int String::hex_to_int(bool p_with_prefix) const {
if (sign < 0) {
s++;
- l--;
- if (p_with_prefix && l < 2)
- return 0;
}
if (p_with_prefix) {
if (s[0] != '0' || s[1] != 'x')
return 0;
s += 2;
- l -= 2;
- };
+ }
int hex = 0;
@@ -1596,8 +1591,7 @@ int String::hex_to_int(bool p_with_prefix) const {
int64_t String::hex_to_int64(bool p_with_prefix) const {
- int l = length();
- if (p_with_prefix && l < 3)
+ if (p_with_prefix && length() < 3)
return 0;
const CharType *s = ptr();
@@ -1606,17 +1600,13 @@ int64_t String::hex_to_int64(bool p_with_prefix) const {
if (sign < 0) {
s++;
- l--;
- if (p_with_prefix && l < 2)
- return 0;
}
if (p_with_prefix) {
if (s[0] != '0' || s[1] != 'x')
return 0;
s += 2;
- l -= 2;
- };
+ }
int64_t hex = 0;
@@ -3478,13 +3468,13 @@ bool String::is_valid_hex_number(bool p_with_prefix) const {
if (p_with_prefix) {
- if (len < 2)
+ if (len < 3)
return false;
if (operator[](from) != '0' || operator[](from + 1) != 'x') {
return false;
- };
+ }
from += 2;
- };
+ }
for (int i = from; i < len; i++) {
@@ -3492,7 +3482,7 @@ bool String::is_valid_hex_number(bool p_with_prefix) const {
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
continue;
return false;
- };
+ }
return true;
};
diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml
index 3c1413b028..9fa1e3ea6c 100644
--- a/doc/classes/Dictionary.xml
+++ b/doc/classes/Dictionary.xml
@@ -22,6 +22,7 @@
<argument index="0" name="deep" type="bool" default="False">
</argument>
<description>
+ Creates a copy of the dictionary, and returns it.
</description>
</method>
<method name="empty">
diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml
index 5fb12612ab..605efd9114 100644
--- a/doc/classes/GraphEdit.xml
+++ b/doc/classes/GraphEdit.xml
@@ -228,6 +228,7 @@
<argument index="0" name="node" type="Object">
</argument>
<description>
+ Emitted when a GraphNode is selected.
</description>
</signal>
<signal name="popup_request">
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index b5986ec0f5..0717836366 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -398,6 +398,7 @@
<signals>
<signal name="script_changed">
<description>
+ Emitted whenever the script of the Object is changed.
</description>
</signal>
</signals>
diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml
index 8846616851..dec0cbbcc3 100644
--- a/doc/classes/SceneTree.xml
+++ b/doc/classes/SceneTree.xml
@@ -367,12 +367,16 @@
</signals>
<constants>
<constant name="GROUP_CALL_DEFAULT" value="0" enum="GroupCallFlags">
+ Call a group with no flags (default).
</constant>
<constant name="GROUP_CALL_REVERSE" value="1" enum="GroupCallFlags">
+ Call a group in reverse scene order.
</constant>
<constant name="GROUP_CALL_REALTIME" value="2" enum="GroupCallFlags">
+ Call a group immediately (calls are normally made on idle).
</constant>
<constant name="GROUP_CALL_UNIQUE" value="4" enum="GroupCallFlags">
+ Call a group only once even if the call is executed many times.
</constant>
<constant name="STRETCH_MODE_DISABLED" value="0" enum="StretchMode">
</constant>
diff --git a/doc/classes/Script.xml b/doc/classes/Script.xml
index 4257991e0d..97f6a60f01 100644
--- a/doc/classes/Script.xml
+++ b/doc/classes/Script.xml
@@ -24,6 +24,7 @@
<return type="Script">
</return>
<description>
+ Returns the script directly inherited by this script.
</description>
</method>
<method name="get_instance_base_type" qualifiers="const">
diff --git a/doc/classes/ScrollBar.xml b/doc/classes/ScrollBar.xml
index d3e6c62e49..736b780218 100644
--- a/doc/classes/ScrollBar.xml
+++ b/doc/classes/ScrollBar.xml
@@ -19,6 +19,7 @@
<signals>
<signal name="scrolling">
<description>
+ Emitted whenever the scrollbar is being scrolled.
</description>
</signal>
</signals>
diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml
index 28fbdea58d..64b0fcfd83 100644
--- a/doc/classes/ScrollContainer.xml
+++ b/doc/classes/ScrollContainer.xml
@@ -31,10 +31,12 @@
<signals>
<signal name="scroll_ended">
<description>
+ Emitted whenever scrolling stops.
</description>
</signal>
<signal name="scroll_started">
<description>
+ Emitted whenever scrolling is started.
</description>
</signal>
</signals>
diff --git a/doc/classes/SplitContainer.xml b/doc/classes/SplitContainer.xml
index 692598f382..d56da68448 100644
--- a/doc/classes/SplitContainer.xml
+++ b/doc/classes/SplitContainer.xml
@@ -16,6 +16,7 @@
<member name="collapsed" type="bool" setter="set_collapsed" getter="is_collapsed">
</member>
<member name="dragger_visibility" type="int" setter="set_dragger_visibility" getter="get_dragger_visibility" enum="SplitContainer.DraggerVisibility">
+ Determines whether the dragger is visible.
</member>
<member name="split_offset" type="int" setter="set_split_offset" getter="get_split_offset">
</member>
diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml
index 6ee9489995..ec67370c79 100644
--- a/doc/classes/TileMap.xml
+++ b/doc/classes/TileMap.xml
@@ -178,6 +178,7 @@
<argument index="1" name="value" type="bool">
</argument>
<description>
+ Set any collision layer to be [code]true[/code] or [code]false[/code].
</description>
</method>
<method name="set_collision_mask_bit">
@@ -303,6 +304,7 @@
Tile origin at its center.
</constant>
<constant name="TILE_ORIGIN_BOTTOM_LEFT" value="2" enum="TileOrigin">
+ Tile origin at its bottom-left corner.
</constant>
</constants>
</class>
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index 070c661c8a..1f3b76f5cd 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -795,7 +795,6 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_HEIGHT"] = "light_height";
actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_COLOR"] = "light_color";
actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_UV"] = "light_uv";
- //actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT_SHADOW_COLOR"]="light_shadow_color";
actions[VS::SHADER_CANVAS_ITEM].renames["LIGHT"] = "light";
actions[VS::SHADER_CANVAS_ITEM].renames["SHADOW_COLOR"] = "shadow_color";
@@ -805,9 +804,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_CANVAS_ITEM].usage_defines["SCREEN_PIXEL_SIZE"] = "@SCREEN_UV";
actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n";
actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
- actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_COLOR"] = "#define SHADOW_COLOR_USED\n";
actions[VS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
-
actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
/** SPATIAL SHADER **/
diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl
index f436ef06f7..3bbeb1149d 100644
--- a/drivers/gles3/shaders/canvas.glsl
+++ b/drivers/gles3/shaders/canvas.glsl
@@ -285,7 +285,19 @@ MATERIAL_UNIFORMS
FRAGMENT_SHADER_GLOBALS
-void light_compute(inout vec4 light,vec2 light_vec,float light_height,vec4 light_color,vec2 light_uv,vec4 shadow,vec3 normal,vec2 uv,vec2 screen_uv,vec4 color) {
+void light_compute(
+ inout vec4 light,
+ inout vec2 light_vec,
+ inout float light_height,
+ inout vec4 light_color,
+ vec2 light_uv,
+ inout vec4 shadow_color,
+ vec3 normal,
+ vec2 uv,
+#if defined(SCREEN_UV_USED)
+ vec2 screen_uv,
+#endif
+ vec4 color) {
#if defined(USE_LIGHT_SHADER_CODE)
@@ -462,39 +474,41 @@ FRAGMENT_SHADER_CODE
float att=1.0;
vec2 light_uv = light_uv_interp.xy;
- vec4 light = texture(light_texture,light_uv) * light_color;
-#if defined(SHADOW_COLOR_USED)
- vec4 shadow_color=vec4(0.0,0.0,0.0,0.0);
-#endif
+ vec4 light = texture(light_texture,light_uv);
if (any(lessThan(light_uv_interp.xy,vec2(0.0,0.0))) || any(greaterThanEqual(light_uv_interp.xy,vec2(1.0,1.0)))) {
color.a*=light_outside_alpha; //invisible
} else {
+ float real_light_height = light_height;
+ vec4 real_light_color = light_color;
+ vec4 real_light_shadow_color = light_shadow_color;
#if defined(USE_LIGHT_SHADER_CODE)
//light is written by the light shader
- light_compute(light,light_vec,light_height,light_color,light_uv,shadow,normal,uv,screen_uv,color);
+ light_compute(
+ light,
+ light_vec,
+ real_light_height,
+ real_light_color,
+ light_uv,
+ real_light_shadow_color,
+ normal,
+ uv,
+#if defined(SCREEN_UV_USED)
+ screen_uv,
+#endif
+ color);
+#endif
-#else
+ light *= real_light_color;
if (normal_used) {
-
- vec3 light_normal = normalize(vec3(light_vec,-light_height));
+ vec3 light_normal = normalize(vec3(light_vec,-real_light_height));
light*=max(dot(-light_normal,normal),0.0);
}
color*=light;
-/*
-#ifdef USE_NORMAL
- color.xy=local_rot.xy;//normal.xy;
- color.zw=vec2(0.0,1.0);
-#endif
-*/
-
-//light shader code
-#endif
-
#ifdef USE_SHADOWS
@@ -634,13 +648,8 @@ FRAGMENT_SHADER_CODE
#endif
-
-#if defined(SHADOW_COLOR_USED)
- color=mix(shadow_color,color,shadow_attenuation);
-#else
//color*=shadow_attenuation;
- color=mix(light_shadow_color,color,shadow_attenuation);
-#endif
+ color=mix(real_light_shadow_color,color,shadow_attenuation);
//use shadows
#endif
}
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 23c8ea2ec7..8b09d76bef 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -85,10 +85,31 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
return ERR_FILE_CANT_OPEN;
};
+#ifdef TOOLS_ENABLED
+ // Windows is case insensitive, but all other platforms are sensitive to it
+ // To ease cross-platform development, we issue a warning if users try to access
+ // a file using the wrong case (which *works* on Windows, but won't on other
+ // platforms).
+ if (p_mode_flags == READ) {
+ WIN32_FIND_DATAW d = { 0 };
+ HANDLE f = FindFirstFileW(path.c_str(), &d);
+ if (f) {
+ String fname = d.cFileName;
+ if (fname != String()) {
+
+ String base_file = path.get_file();
+ if (base_file != fname && base_file.findn(fname) == 0) {
+ WARN_PRINTS("Case mismatch opening requested file '" + base_file + "', stored as '" + fname + "' in the filesystem. This file will not open when exported to other case-sensitive platforms.");
+ }
+ }
+ FindClose(f);
+ }
+ }
+#endif
+
if (is_backup_save_enabled() && p_mode_flags & WRITE && !(p_mode_flags & READ)) {
save_path = path;
path = path + ".tmp";
- //print_line("saving instead to "+path);
}
f = _wfopen(path.c_str(), mode_string);
diff --git a/editor/plugins/skeleton_2d_editor_plugin.cpp b/editor/plugins/skeleton_2d_editor_plugin.cpp
index 6bf94b95eb..e372f792d6 100644
--- a/editor/plugins/skeleton_2d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_2d_editor_plugin.cpp
@@ -20,6 +20,10 @@ void Skeleton2DEditor::edit(Skeleton2D *p_sprite) {
void Skeleton2DEditor::_menu_option(int p_option) {
+ if (!node) {
+ return;
+ }
+
switch (p_option) {
case MENU_OPTION_MAKE_REST: {
@@ -107,6 +111,7 @@ Skeleton2DEditorPlugin::Skeleton2DEditorPlugin(EditorNode *p_node) {
editor = p_node;
sprite_editor = memnew(Skeleton2DEditor);
editor->get_viewport()->add_child(sprite_editor);
+ make_visible(false);
//sprite_editor->options->hide();
}
diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_editor_plugin.cpp
index 99aabcb3eb..49816fe2ae 100644
--- a/editor/plugins/sprite_editor_plugin.cpp
+++ b/editor/plugins/sprite_editor_plugin.cpp
@@ -80,6 +80,10 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float
void SpriteEditor::_menu_option(int p_option) {
+ if (!node) {
+ return;
+ }
+
switch (p_option) {
case MENU_OPTION_CREATE_MESH_2D: {
@@ -389,6 +393,7 @@ SpriteEditorPlugin::SpriteEditorPlugin(EditorNode *p_node) {
editor = p_node;
sprite_editor = memnew(SpriteEditor);
editor->get_viewport()->add_child(sprite_editor);
+ make_visible(false);
//sprite_editor->options->hide();
}
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 4dbd9d500e..bdbb79df6d 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -986,6 +986,10 @@ ProjectExportDialog::ProjectExportDialog() {
editor_icons = "EditorIcons";
default_filename = EditorSettings::get_singleton()->get_project_metadata("export_options", "default_filename", String());
+
+ if (default_filename == "") {
+ default_filename = ProjectSettings::get_singleton()->get("application/config/name");
+ }
}
ProjectExportDialog::~ProjectExportDialog() {
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 6e3be343ba..3127644a81 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -178,15 +178,15 @@ void ProjectSettingsEditor::_action_edited() {
}
int order = ProjectSettings::get_singleton()->get_order(add_at);
- Array va = ProjectSettings::get_singleton()->get(add_at);
+ Dictionary action = ProjectSettings::get_singleton()->get(add_at);
setting = true;
undo_redo->create_action(TTR("Rename Input Action Event"));
undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", add_at);
- undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", action_prop, va);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", action_prop, action);
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", action_prop, order);
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", action_prop);
- undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", add_at, va);
+ undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", add_at, action);
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", add_at, order);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
@@ -203,8 +203,9 @@ void ProjectSettingsEditor::_device_input_add() {
Ref<InputEvent> ie;
String name = add_at;
int idx = edit_idx;
- Array old_val = ProjectSettings::get_singleton()->get(name);
- Array arr = old_val.duplicate();
+ Dictionary old_val = ProjectSettings::get_singleton()->get(name);
+ Dictionary action = old_val.duplicate();
+ Array events = action["events"];
switch (add_type) {
@@ -215,9 +216,9 @@ void ProjectSettingsEditor::_device_input_add() {
mb->set_button_index(device_index->get_selected() + 1);
mb->set_device(_get_current_device());
- for (int i = 0; i < arr.size(); i++) {
+ for (int i = 0; i < events.size(); i++) {
- Ref<InputEventMouseButton> aie = arr[i];
+ Ref<InputEventMouseButton> aie = events[i];
if (aie.is_null())
continue;
if (aie->get_device() == mb->get_device() && aie->get_button_index() == mb->get_button_index()) {
@@ -236,17 +237,24 @@ void ProjectSettingsEditor::_device_input_add() {
jm->set_axis_value(device_index->get_selected() & 1 ? 1 : -1);
jm->set_device(_get_current_device());
- for (int i = 0; i < arr.size(); i++) {
+ bool should_update_event = true;
+ Variant deadzone = device_special_value->get_value();
+ for (int i = 0; i < events.size(); i++) {
- Ref<InputEventJoypadMotion> aie = arr[i];
+ Ref<InputEventJoypadMotion> aie = events[i];
if (aie.is_null())
continue;
if (aie->get_device() == jm->get_device() && aie->get_axis() == jm->get_axis() && aie->get_axis_value() == jm->get_axis_value()) {
- return;
+ should_update_event = false;
+ break;
}
}
+ if (!should_update_event && deadzone == action["deadzone"])
+ return;
+
ie = jm;
+ action["deadzone"] = deadzone;
} break;
case INPUT_JOY_BUTTON: {
@@ -257,9 +265,9 @@ void ProjectSettingsEditor::_device_input_add() {
jb->set_button_index(device_index->get_selected());
jb->set_device(_get_current_device());
- for (int i = 0; i < arr.size(); i++) {
+ for (int i = 0; i < events.size(); i++) {
- Ref<InputEventJoypadButton> aie = arr[i];
+ Ref<InputEventJoypadButton> aie = events[i];
if (aie.is_null())
continue;
if (aie->get_device() == jb->get_device() && aie->get_button_index() == jb->get_button_index()) {
@@ -272,14 +280,15 @@ void ProjectSettingsEditor::_device_input_add() {
default: {}
}
- if (idx < 0 || idx >= arr.size()) {
- arr.push_back(ie);
+ if (idx < 0 || idx >= events.size()) {
+ events.push_back(ie);
} else {
- arr[idx] = ie;
+ events[idx] = ie;
}
+ action["events"] = events;
undo_redo->create_action(TTR("Add Input Action Event"));
- undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, arr);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, action);
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
@@ -320,12 +329,13 @@ void ProjectSettingsEditor::_press_a_key_confirm() {
String name = add_at;
int idx = edit_idx;
- Array old_val = ProjectSettings::get_singleton()->get(name);
- Array arr = old_val.duplicate();
+ Dictionary old_val = ProjectSettings::get_singleton()->get(name);
+ Dictionary action = old_val.duplicate();
+ Array events = action["events"];
- for (int i = 0; i < arr.size(); i++) {
+ for (int i = 0; i < events.size(); i++) {
- Ref<InputEventKey> aie = arr[i];
+ Ref<InputEventKey> aie = events[i];
if (aie.is_null())
continue;
if (aie->get_scancode_with_modifiers() == ie->get_scancode_with_modifiers()) {
@@ -333,14 +343,15 @@ void ProjectSettingsEditor::_press_a_key_confirm() {
}
}
- if (idx < 0 || idx >= arr.size()) {
- arr.push_back(ie);
+ if (idx < 0 || idx >= events.size()) {
+ events.push_back(ie);
} else {
- arr[idx] = ie;
+ events[idx] = ie;
}
+ action["events"] = events;
undo_redo->create_action(TTR("Add Input Action Event"));
- undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, arr);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, action);
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
@@ -418,6 +429,9 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
last_wait_for_key = Ref<InputEvent>();
press_a_key->popup_centered(Size2(250, 80) * EDSCALE);
press_a_key->grab_focus();
+
+ device_special_value_label->hide();
+ device_special_value->hide();
} break;
case INPUT_MOUSE_BUTTON: {
@@ -443,6 +457,9 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
_set_current_device(0);
device_input->get_ok()->set_text(TTR("Add"));
}
+
+ device_special_value_label->hide();
+ device_special_value->hide();
} break;
case INPUT_JOY_MOTION: {
@@ -464,6 +481,15 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
_set_current_device(0);
device_input->get_ok()->set_text(TTR("Add"));
}
+
+ device_special_value_label->set_text(TTR("Deadzone (global to the action):"));
+ device_special_value_label->show();
+ device_special_value->set_min(0.0f);
+ device_special_value->set_max(1.0f);
+ device_special_value->set_step(0.01f);
+ Dictionary action = ProjectSettings::get_singleton()->get(add_at);
+ device_special_value->set_value(action.has("deadzone") ? action["deadzone"] : Variant(0.5f));
+ device_special_value->show();
} break;
case INPUT_JOY_BUTTON: {
@@ -486,6 +512,8 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
device_input->get_ok()->set_text(TTR("Add"));
}
+ device_special_value_label->hide();
+ device_special_value->hide();
} break;
default: {}
}
@@ -522,18 +550,17 @@ void ProjectSettingsEditor::_action_activated() {
String name = "input/" + ti->get_parent()->get_text(0);
int idx = ti->get_metadata(0);
- Array va = ProjectSettings::get_singleton()->get(name);
-
- ERR_FAIL_INDEX(idx, va.size());
-
- Ref<InputEvent> ie = va[idx];
+ Dictionary action = ProjectSettings::get_singleton()->get(name);
+ Array events = action["events"];
- if (ie.is_null())
+ ERR_FAIL_INDEX(idx, events.size());
+ Ref<InputEvent> event = events[idx];
+ if (event.is_null())
return;
add_at = name;
edit_idx = idx;
- _edit_item(ie);
+ _edit_item(event);
}
void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column, int p_id) {
@@ -543,6 +570,7 @@ void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column,
ERR_FAIL_COND(!ti);
if (p_id == 1) {
+ // Add action event
Point2 ofs = input_editor->get_global_position();
Rect2 ir = input_editor->get_item_rect(ti);
ir.position.y -= input_editor->get_scroll().y;
@@ -554,14 +582,12 @@ void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column,
edit_idx = -1;
} else if (p_id == 2) {
- //remove
+ // Remove
if (ti->get_parent() == input_editor->get_root()) {
-
- //remove main thing
-
+ // Remove action
String name = "input/" + ti->get_text(0);
- Variant old_val = ProjectSettings::get_singleton()->get(name);
+ Dictionary old_val = ProjectSettings::get_singleton()->get(name);
int order = ProjectSettings::get_singleton()->get_order(name);
undo_redo->create_action(TTR("Erase Input Action"));
@@ -575,24 +601,19 @@ void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column,
undo_redo->commit_action();
} else {
- //remove action
+ // Remove action event
String name = "input/" + ti->get_parent()->get_text(0);
- Variant old_val = ProjectSettings::get_singleton()->get(name);
+ Dictionary old_val = ProjectSettings::get_singleton()->get(name);
+ Dictionary action = old_val.duplicate();
int idx = ti->get_metadata(0);
- Array va = old_val;
-
- ERR_FAIL_INDEX(idx, va.size());
-
- for (int i = idx; i < va.size() - 1; i++) {
-
- va[i] = va[i + 1];
- }
-
- va.resize(va.size() - 1);
+ Array events = action["events"];
+ ERR_FAIL_INDEX(idx, events.size());
+ events.remove(idx);
+ action["events"] = events;
undo_redo->create_action(TTR("Erase Input Action Event"));
- undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, va);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, action);
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", name, old_val);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
@@ -601,30 +622,31 @@ void ProjectSettingsEditor::_action_button_pressed(Object *p_obj, int p_column,
undo_redo->commit_action();
}
} else if (p_id == 3) {
- //edit
+ // Edit
if (ti->get_parent() == input_editor->get_root()) {
-
+ // Edit action name
ti->set_as_cursor(0);
input_editor->edit_selected();
} else {
- //edit action
+ // Edit action event
String name = "input/" + ti->get_parent()->get_text(0);
int idx = ti->get_metadata(0);
- Array va = ProjectSettings::get_singleton()->get(name);
+ Dictionary action = ProjectSettings::get_singleton()->get(name);
- ERR_FAIL_INDEX(idx, va.size());
+ Array events = action["events"];
+ ERR_FAIL_INDEX(idx, events.size());
- Ref<InputEvent> ie = va[idx];
+ Ref<InputEvent> event = events[idx];
- if (ie.is_null())
+ if (event.is_null())
return;
ti->set_as_cursor(0);
add_at = name;
edit_idx = idx;
- _edit_item(ie);
+ _edit_item(event);
}
}
}
@@ -660,17 +682,18 @@ void ProjectSettingsEditor::_update_actions() {
}
item->set_custom_bg_color(0, get_color("prop_subsection", "Editor"));
- Array actions = ProjectSettings::get_singleton()->get(pi.name);
+ Dictionary action = ProjectSettings::get_singleton()->get(pi.name);
+ Array events = action["events"];
- for (int i = 0; i < actions.size(); i++) {
+ for (int i = 0; i < events.size(); i++) {
- Ref<InputEvent> ie = actions[i];
- if (ie.is_null())
+ Ref<InputEvent> event = events[i];
+ if (event.is_null())
continue;
TreeItem *action = input_editor->create_item(item);
- Ref<InputEventKey> k = ie;
+ Ref<InputEventKey> k = event;
if (k.is_valid()) {
String str = keycode_get_string(k->get_scancode()).capitalize();
@@ -687,7 +710,7 @@ void ProjectSettingsEditor::_update_actions() {
action->set_icon(0, get_icon("Keyboard", "EditorIcons"));
}
- Ref<InputEventJoypadButton> jb = ie;
+ Ref<InputEventJoypadButton> jb = event;
if (jb.is_valid()) {
@@ -701,7 +724,7 @@ void ProjectSettingsEditor::_update_actions() {
action->set_icon(0, get_icon("JoyButton", "EditorIcons"));
}
- Ref<InputEventMouseButton> mb = ie;
+ Ref<InputEventMouseButton> mb = event;
if (mb.is_valid()) {
String str = _get_device_string(mb->get_device()) + ", ";
@@ -718,7 +741,7 @@ void ProjectSettingsEditor::_update_actions() {
action->set_icon(0, get_icon("Mouse", "EditorIcons"));
}
- Ref<InputEventJoypadMotion> jm = ie;
+ Ref<InputEventJoypadMotion> jm = event;
if (jm.is_valid()) {
@@ -732,7 +755,7 @@ void ProjectSettingsEditor::_update_actions() {
action->add_button(0, get_icon("Edit", "EditorIcons"), 3, false, TTR("Edit"));
action->add_button(0, get_icon("Remove", "EditorIcons"), 2, false, TTR("Remove"));
action->set_metadata(0, i);
- action->set_meta("__input", ie);
+ action->set_meta("__input", event);
}
}
@@ -892,10 +915,12 @@ void ProjectSettingsEditor::_action_adds(String) {
void ProjectSettingsEditor::_action_add() {
- Array va;
+ Dictionary action;
+ action["events"] = Array();
+ action["deadzone"] = 0.5f;
String name = "input/" + action_name->get_text();
undo_redo->create_action(TTR("Add Input Action"));
- undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, va);
+ undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", name, action);
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "clear", name);
undo_redo->add_do_method(this, "_update_actions");
undo_redo->add_undo_method(this, "_update_actions");
@@ -1814,6 +1839,14 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
device_index = memnew(OptionButton);
vbc_right->add_child(device_index);
+ l = memnew(Label);
+ l->set_text(TTR("Special value:"));
+ vbc_right->add_child(l);
+ device_special_value_label = l;
+
+ device_special_value = memnew(SpinBox);
+ vbc_right->add_child(device_special_value);
+
setting = false;
//translations
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index 0ced88d7f6..b8bfdcd876 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -83,6 +83,8 @@ class ProjectSettingsEditor : public AcceptDialog {
OptionButton *device_id;
OptionButton *device_index;
Label *device_index_label;
+ SpinBox *device_special_value;
+ Label *device_special_value_label;
MenuButton *popup_copy_to_feature;
LineEdit *action_name;
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 1c73ecf2d2..3c40be5082 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -127,6 +127,14 @@ bool InputDefault::is_action_just_released(const StringName &p_action) const {
}
}
+float InputDefault::get_action_strength(const StringName &p_action) const {
+ const Map<StringName, Action>::Element *E = action_state.find(p_action);
+ if (!E)
+ return 0.0f;
+
+ return E->get().strength;
+}
+
float InputDefault::get_joy_axis(int p_device, int p_axis) const {
_THREAD_SAFE_METHOD_
@@ -330,16 +338,18 @@ void InputDefault::parse_input_event(const Ref<InputEvent> &p_event) {
}
}
- if (!p_event->is_echo()) {
- for (const Map<StringName, InputMap::Action>::Element *E = InputMap::get_singleton()->get_action_map().front(); E; E = E->next()) {
+ for (const Map<StringName, InputMap::Action>::Element *E = InputMap::get_singleton()->get_action_map().front(); E; E = E->next()) {
+ if (InputMap::get_singleton()->event_is_action(p_event, E->key())) {
- if (InputMap::get_singleton()->event_is_action(p_event, E->key()) && is_action_pressed(E->key()) != p_event->is_pressed()) {
+ // Save the action's state
+ if (!p_event->is_echo() && is_action_pressed(E->key()) != p_event->is_action_pressed(E->key())) {
Action action;
action.physics_frame = Engine::get_singleton()->get_physics_frames();
action.idle_frame = Engine::get_singleton()->get_idle_frames();
- action.pressed = p_event->is_pressed();
+ action.pressed = p_event->is_action_pressed(E->key());
action_state[E->key()] = action;
}
+ action_state[E->key()].strength = p_event->get_action_strength(E->key());
}
}
diff --git a/main/input_default.h b/main/input_default.h
index 384b04cf41..6dd88cd31e 100644
--- a/main/input_default.h
+++ b/main/input_default.h
@@ -55,6 +55,7 @@ class InputDefault : public Input {
uint64_t physics_frame;
uint64_t idle_frame;
bool pressed;
+ float strength;
};
Map<StringName, Action> action_state;
@@ -182,6 +183,7 @@ public:
virtual bool is_action_pressed(const StringName &p_action) const;
virtual bool is_action_just_pressed(const StringName &p_action) const;
virtual bool is_action_just_released(const StringName &p_action) const;
+ virtual float get_action_strength(const StringName &p_action) const;
virtual float get_joy_axis(int p_device, int p_axis) const;
String get_joy_name(int p_idx);
diff --git a/main/main.cpp b/main/main.cpp
index a59ca3da3b..29da47fe8f 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1512,7 +1512,7 @@ bool Main::start() {
bool snap_controls = GLOBAL_DEF("gui/common/snap_controls_to_pixels", true);
sml->get_root()->set_snap_controls_to_pixels(snap_controls);
- bool font_oversampling = GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", false);
+ bool font_oversampling = GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", true);
sml->set_use_font_oversampling(font_oversampling);
} else {
@@ -1525,7 +1525,7 @@ bool Main::start() {
sml->set_auto_accept_quit(GLOBAL_DEF("application/config/auto_accept_quit", true));
sml->set_quit_on_go_back(GLOBAL_DEF("application/config/quit_on_go_back", true));
GLOBAL_DEF("gui/common/snap_controls_to_pixels", true);
- GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", false);
+ GLOBAL_DEF("rendering/quality/dynamic_fonts/use_oversampling", true);
}
String local_game_path;
diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp
index 05c0e653df..57e4db708e 100644
--- a/modules/bullet/collision_object_bullet.cpp
+++ b/modules/bullet/collision_object_bullet.cpp
@@ -49,7 +49,7 @@
CollisionObjectBullet::ShapeWrapper::~ShapeWrapper() {}
void CollisionObjectBullet::ShapeWrapper::set_transform(const Transform &p_transform) {
- G_TO_B(p_transform.get_basis().get_scale(), scale);
+ G_TO_B(p_transform.get_basis().get_scale_abs(), scale);
G_TO_B(p_transform, transform);
UNSCALE_BT_BASIS(transform);
}
@@ -158,7 +158,7 @@ int CollisionObjectBullet::get_godot_object_flags() const {
void CollisionObjectBullet::set_transform(const Transform &p_global_transform) {
- set_body_scale(p_global_transform.basis.get_scale());
+ set_body_scale(p_global_transform.basis.get_scale_abs());
btTransform bt_transform;
G_TO_B(p_global_transform, bt_transform);
diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp
index caa3d677dd..1bf259da84 100644
--- a/modules/bullet/godot_result_callbacks.cpp
+++ b/modules/bullet/godot_result_callbacks.cpp
@@ -172,10 +172,7 @@ btScalar GodotAllContactResultCallback::addSingleResult(btManifoldPoint &cp, con
result.shape = cp.m_index0;
}
- if (colObj)
- result.collider_id = colObj->get_instance_id();
- else
- result.collider_id = 0;
+ result.collider_id = colObj->get_instance_id();
result.collider = 0 == result.collider_id ? NULL : ObjectDB::get_instance(result.collider_id);
result.rid = colObj->get_self();
++m_count;
@@ -250,10 +247,7 @@ btScalar GodotRestInfoContactResultCallback::addSingleResult(btManifoldPoint &cp
m_rest_info_collision_object = colObj0Wrap->getCollisionObject();
}
- if (colObj)
- m_result->collider_id = colObj->get_instance_id();
- else
- m_result->collider_id = 0;
+ m_result->collider_id = colObj->get_instance_id();
m_result->rid = colObj->get_self();
m_collided = true;
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index 8450a66f65..3a1f5d78dd 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -122,7 +122,7 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra
ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
- btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale(), p_margin);
+ btCollisionShape *btShape = shape->create_bt_shape(p_xform.basis.get_scale_abs(), p_margin);
if (!btShape->isConvex()) {
bulletdelete(btShape);
ERR_PRINTS("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type()));
@@ -202,7 +202,7 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform &
ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
- btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale(), p_margin);
+ btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin);
if (!btShape->isConvex()) {
bulletdelete(btShape);
ERR_PRINTS("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type()));
@@ -234,7 +234,7 @@ bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_sh
ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape);
- btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale(), p_margin);
+ btCollisionShape *btShape = shape->create_bt_shape(p_shape_xform.basis.get_scale_abs(), p_margin);
if (!btShape->isConvex()) {
bulletdelete(btShape);
ERR_PRINTS("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type()));
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index d255148e0f..cf8977f3ea 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -357,14 +357,13 @@ void NativeScript::get_script_property_list(List<PropertyInfo> *p_list) const {
NativeScriptDesc *script_data = get_script_desc();
Set<StringName> existing_properties;
+ List<PropertyInfo>::Element *original_back = p_list->back();
while (script_data) {
- List<PropertyInfo>::Element *insert_position = p_list->front();
- bool insert_before = true;
+ List<PropertyInfo>::Element *insert_position = original_back;
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element E = script_data->properties.front(); E; E = E.next()) {
if (!existing_properties.has(E.key())) {
- insert_position = insert_before ? p_list->insert_before(insert_position, E.get().info) : p_list->insert_after(insert_position, E.get().info);
- insert_before = false;
+ insert_position = p_list->insert_after(insert_position, E.get().info);
existing_properties.insert(E.key());
}
}
diff --git a/modules/mono/glue/cs_files/AABB.cs b/modules/mono/glue/cs_files/AABB.cs
index 25458c93e1..39f2d2ed51 100644
--- a/modules/mono/glue/cs_files/AABB.cs
+++ b/modules/mono/glue/cs_files/AABB.cs
@@ -1,12 +1,10 @@
-using System;
-
// file: core/math/aabb.h
// commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451
// file: core/math/aabb.cpp
// commit: bd282ff43f23fe845f29a3e25c8efc01bd65ffb0
// file: core/variant_call.cpp
// commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685
-
+using System;
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -51,12 +49,12 @@ namespace Godot
Vector3 dst_min = with.position;
Vector3 dst_max = with.position + with.size;
- return ((src_min.x <= dst_min.x) &&
- (src_max.x > dst_max.x) &&
- (src_min.y <= dst_min.y) &&
- (src_max.y > dst_max.y) &&
- (src_min.z <= dst_min.z) &&
- (src_max.z > dst_max.z));
+ return src_min.x <= dst_min.x &&
+ src_max.x > dst_max.x &&
+ src_min.y <= dst_min.y &&
+ src_max.y > dst_max.y &&
+ src_min.z <= dst_min.z &&
+ src_max.z > dst_max.z;
}
public AABB Expand(Vector3 to_point)
@@ -113,7 +111,7 @@ namespace Godot
public Vector3 GetLongestAxis()
{
- Vector3 axis = new Vector3(1f, 0f, 0f);
+ var axis = new Vector3(1f, 0f, 0f);
real_t max_size = size.x;
if (size.y > max_size)
@@ -125,7 +123,6 @@ namespace Godot
if (size.z > max_size)
{
axis = new Vector3(0f, 0f, 1f);
- max_size = size.z;
}
return axis;
@@ -133,7 +130,7 @@ namespace Godot
public Vector3.Axis GetLongestAxisIndex()
{
- Vector3.Axis axis = Vector3.Axis.X;
+ var axis = Vector3.Axis.X;
real_t max_size = size.x;
if (size.y > max_size)
@@ -145,7 +142,6 @@ namespace Godot
if (size.z > max_size)
{
axis = Vector3.Axis.Z;
- max_size = size.z;
}
return axis;
@@ -166,7 +162,7 @@ namespace Godot
public Vector3 GetShortestAxis()
{
- Vector3 axis = new Vector3(1f, 0f, 0f);
+ var axis = new Vector3(1f, 0f, 0f);
real_t max_size = size.x;
if (size.y < max_size)
@@ -178,7 +174,6 @@ namespace Godot
if (size.z < max_size)
{
axis = new Vector3(0f, 0f, 1f);
- max_size = size.z;
}
return axis;
@@ -186,7 +181,7 @@ namespace Godot
public Vector3.Axis GetShortestAxisIndex()
{
- Vector3.Axis axis = Vector3.Axis.X;
+ var axis = Vector3.Axis.X;
real_t max_size = size.x;
if (size.y < max_size)
@@ -198,7 +193,6 @@ namespace Godot
if (size.z < max_size)
{
axis = Vector3.Axis.Z;
- max_size = size.z;
}
return axis;
@@ -223,14 +217,14 @@ namespace Godot
Vector3 ofs = position + half_extents;
return ofs + new Vector3(
- (dir.x > 0f) ? -half_extents.x : half_extents.x,
- (dir.y > 0f) ? -half_extents.y : half_extents.y,
- (dir.z > 0f) ? -half_extents.z : half_extents.z);
+ dir.x > 0f ? -half_extents.x : half_extents.x,
+ dir.y > 0f ? -half_extents.y : half_extents.y,
+ dir.z > 0f ? -half_extents.z : half_extents.z);
}
public AABB Grow(real_t by)
{
- AABB res = this;
+ var res = this;
res.position.x -= by;
res.position.y -= by;
@@ -283,48 +277,42 @@ namespace Godot
{
return new AABB();
}
- else
- {
- min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x;
- max.x = (src_max.x < dst_max.x) ? src_max.x : dst_max.x;
- }
+
+ min.x = src_min.x > dst_min.x ? src_min.x : dst_min.x;
+ max.x = src_max.x < dst_max.x ? src_max.x : dst_max.x;
if (src_min.y > dst_max.y || src_max.y < dst_min.y)
{
return new AABB();
}
- else
- {
- min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y;
- max.y = (src_max.y < dst_max.y) ? src_max.y : dst_max.y;
- }
+
+ min.y = src_min.y > dst_min.y ? src_min.y : dst_min.y;
+ max.y = src_max.y < dst_max.y ? src_max.y : dst_max.y;
if (src_min.z > dst_max.z || src_max.z < dst_min.z)
{
return new AABB();
}
- else
- {
- min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z;
- max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z;
- }
+
+ min.z = src_min.z > dst_min.z ? src_min.z : dst_min.z;
+ max.z = src_max.z < dst_max.z ? src_max.z : dst_max.z;
return new AABB(min, max - min);
}
public bool Intersects(AABB with)
{
- if (position.x >= (with.position.x + with.size.x))
+ if (position.x >= with.position.x + with.size.x)
return false;
- if ((position.x + size.x) <= with.position.x)
+ if (position.x + size.x <= with.position.x)
return false;
- if (position.y >= (with.position.y + with.size.y))
+ if (position.y >= with.position.y + with.size.y)
return false;
- if ((position.y + size.y) <= with.position.y)
+ if (position.y + size.y <= with.position.y)
return false;
- if (position.z >= (with.position.z + with.size.z))
+ if (position.z >= with.position.z + with.size.z)
return false;
- if ((position.z + size.z) <= with.position.z)
+ if (position.z + size.z <= with.position.z)
return false;
return true;
@@ -341,7 +329,7 @@ namespace Godot
new Vector3(position.x + size.x, position.y, position.z),
new Vector3(position.x + size.x, position.y, position.z + size.z),
new Vector3(position.x + size.x, position.y + size.y, position.z),
- new Vector3(position.x + size.x, position.y + size.y, position.z + size.z),
+ new Vector3(position.x + size.x, position.y + size.y, position.z + size.z)
};
bool over = false;
@@ -408,19 +396,19 @@ namespace Godot
{
Vector3 beg_1 = position;
Vector3 beg_2 = with.position;
- Vector3 end_1 = new Vector3(size.x, size.y, size.z) + beg_1;
- Vector3 end_2 = new Vector3(with.size.x, with.size.y, with.size.z) + beg_2;
+ var end_1 = new Vector3(size.x, size.y, size.z) + beg_1;
+ var end_2 = new Vector3(with.size.x, with.size.y, with.size.z) + beg_2;
- Vector3 min = new Vector3(
- (beg_1.x < beg_2.x) ? beg_1.x : beg_2.x,
- (beg_1.y < beg_2.y) ? beg_1.y : beg_2.y,
- (beg_1.z < beg_2.z) ? beg_1.z : beg_2.z
+ var min = new Vector3(
+ beg_1.x < beg_2.x ? beg_1.x : beg_2.x,
+ beg_1.y < beg_2.y ? beg_1.y : beg_2.y,
+ beg_1.z < beg_2.z ? beg_1.z : beg_2.z
);
- Vector3 max = new Vector3(
- (end_1.x > end_2.x) ? end_1.x : end_2.x,
- (end_1.y > end_2.y) ? end_1.y : end_2.y,
- (end_1.z > end_2.z) ? end_1.z : end_2.z
+ var max = new Vector3(
+ end_1.x > end_2.x ? end_1.x : end_2.x,
+ end_1.y > end_2.y ? end_1.y : end_2.y,
+ end_1.z > end_2.z ? end_1.z : end_2.z
);
return new AABB(min, max - min);
@@ -467,8 +455,8 @@ namespace Godot
{
return String.Format("{0} - {1}", new object[]
{
- this.position.ToString(),
- this.size.ToString()
+ position.ToString(),
+ size.ToString()
});
}
@@ -476,8 +464,8 @@ namespace Godot
{
return String.Format("{0} - {1}", new object[]
{
- this.position.ToString(format),
- this.size.ToString(format)
+ position.ToString(format),
+ size.ToString(format)
});
}
}
diff --git a/modules/mono/glue/cs_files/Basis.cs b/modules/mono/glue/cs_files/Basis.cs
index aa07cf3999..929b13d70c 100644
--- a/modules/mono/glue/cs_files/Basis.cs
+++ b/modules/mono/glue/cs_files/Basis.cs
@@ -1,6 +1,5 @@
using System;
using System.Runtime.InteropServices;
-
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -19,8 +18,7 @@ namespace Godot
new Vector3(0f, 0f, 1f)
);
- private static readonly Basis[] orthoBases = new Basis[24]
- {
+ private static readonly Basis[] orthoBases = {
new Basis(1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f),
new Basis(0f, -1f, 0f, 1f, 0f, 0f, 0f, 0f, 1f),
new Basis(-1f, 0f, 0f, 0f, -1f, 0f, 0f, 0f, 1f),
@@ -188,7 +186,7 @@ namespace Godot
public Vector3 GetEuler()
{
- Basis m = this.Orthonormalized();
+ Basis m = Orthonormalized();
Vector3 euler;
euler.z = 0.0f;
@@ -221,7 +219,7 @@ namespace Godot
public int GetOrthogonalIndex()
{
- Basis orth = this;
+ var orth = this;
for (int i = 0; i < 3; i++)
{
@@ -251,10 +249,9 @@ namespace Godot
public Basis Inverse()
{
- Basis inv = this;
+ var inv = this;
- real_t[] co = new real_t[3]
- {
+ real_t[] co = {
inv[1, 1] * inv[2, 2] - inv[1, 2] * inv[2, 1],
inv[1, 2] * inv[2, 0] - inv[1, 0] * inv[2, 2],
inv[1, 0] * inv[2, 1] - inv[1, 1] * inv[2, 0]
@@ -297,12 +294,12 @@ namespace Godot
Vector3 zAxis = GetAxis(2);
xAxis.Normalize();
- yAxis = (yAxis - xAxis * (xAxis.Dot(yAxis)));
+ yAxis = yAxis - xAxis * xAxis.Dot(yAxis);
yAxis.Normalize();
- zAxis = (zAxis - xAxis * (xAxis.Dot(zAxis)) - yAxis * (yAxis.Dot(zAxis)));
+ zAxis = zAxis - xAxis * xAxis.Dot(zAxis) - yAxis * yAxis.Dot(zAxis);
zAxis.Normalize();
- return Basis.CreateFromAxes(xAxis, yAxis, zAxis);
+ return CreateFromAxes(xAxis, yAxis, zAxis);
}
public Basis Rotated(Vector3 axis, real_t phi)
@@ -312,7 +309,7 @@ namespace Godot
public Basis Scaled(Vector3 scale)
{
- Basis m = this;
+ var m = this;
m[0, 0] *= scale.x;
m[0, 1] *= scale.x;
@@ -344,7 +341,7 @@ namespace Godot
public Basis Transposed()
{
- Basis tr = this;
+ var tr = this;
real_t temp = this[0, 1];
this[0, 1] = this[1, 0];
@@ -375,9 +372,9 @@ namespace Godot
{
return new Vector3
(
- (this[0, 0] * v.x) + (this[1, 0] * v.y) + (this[2, 0] * v.z),
- (this[0, 1] * v.x) + (this[1, 1] * v.y) + (this[2, 1] * v.z),
- (this[0, 2] * v.x) + (this[1, 2] * v.y) + (this[2, 2] * v.z)
+ this[0, 0] * v.x + this[1, 0] * v.y + this[2, 0] * v.z,
+ this[0, 1] * v.x + this[1, 1] * v.y + this[2, 1] * v.z,
+ this[0, 2] * v.x + this[1, 2] * v.y + this[2, 2] * v.z
);
}
@@ -393,34 +390,38 @@ namespace Godot
(_y[0] - _x[1]) * inv_s,
s * 0.25f
);
- } else if (_x[0] > _y[1] && _x[0] > _z[2]) {
- real_t s = Mathf.Sqrt(_x[0] - _y[1] - _z[2] + 1.0f) * 2f;
- real_t inv_s = 1f / s;
- return new Quat(
- s * 0.25f,
- (_x[1] + _y[0]) * inv_s,
- (_x[2] + _z[0]) * inv_s,
- (_z[1] - _y[2]) * inv_s
- );
- } else if (_y[1] > _z[2]) {
- real_t s = Mathf.Sqrt(-_x[0] + _y[1] - _z[2] + 1.0f) * 2f;
- real_t inv_s = 1f / s;
- return new Quat(
- (_x[1] + _y[0]) * inv_s,
- s * 0.25f,
- (_y[2] + _z[1]) * inv_s,
- (_x[2] - _z[0]) * inv_s
- );
- } else {
- real_t s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f;
- real_t inv_s = 1f / s;
- return new Quat(
- (_x[2] + _z[0]) * inv_s,
- (_y[2] + _z[1]) * inv_s,
- s * 0.25f,
- (_y[0] - _x[1]) * inv_s
- );
}
+
+ if (_x[0] > _y[1] && _x[0] > _z[2]) {
+ real_t s = Mathf.Sqrt(_x[0] - _y[1] - _z[2] + 1.0f) * 2f;
+ real_t inv_s = 1f / s;
+ return new Quat(
+ s * 0.25f,
+ (_x[1] + _y[0]) * inv_s,
+ (_x[2] + _z[0]) * inv_s,
+ (_z[1] - _y[2]) * inv_s
+ );
+ }
+
+ if (_y[1] > _z[2]) {
+ real_t s = Mathf.Sqrt(-_x[0] + _y[1] - _z[2] + 1.0f) * 2f;
+ real_t inv_s = 1f / s;
+ return new Quat(
+ (_x[1] + _y[0]) * inv_s,
+ s * 0.25f,
+ (_y[2] + _z[1]) * inv_s,
+ (_x[2] - _z[0]) * inv_s
+ );
+ } else {
+ real_t s = Mathf.Sqrt(-_x[0] - _y[1] + _z[2] + 1.0f) * 2f;
+ real_t inv_s = 1f / s;
+ return new Quat(
+ (_x[2] + _z[0]) * inv_s,
+ (_y[2] + _z[1]) * inv_s,
+ s * 0.25f,
+ (_y[0] - _x[1]) * inv_s
+ );
+ }
}
public Basis(Quat quat)
@@ -440,33 +441,33 @@ namespace Godot
real_t yz = quat.y * zs;
real_t zz = quat.z * zs;
- this._x = new Vector3(1.0f - (yy + zz), xy - wz, xz + wy);
- this._y = new Vector3(xy + wz, 1.0f - (xx + zz), yz - wx);
- this._z = new Vector3(xz - wy, yz + wx, 1.0f - (xx + yy));
+ _x = new Vector3(1.0f - (yy + zz), xy - wz, xz + wy);
+ _y = new Vector3(xy + wz, 1.0f - (xx + zz), yz - wx);
+ _z = new Vector3(xz - wy, yz + wx, 1.0f - (xx + yy));
}
public Basis(Vector3 axis, real_t phi)
{
- Vector3 axis_sq = new Vector3(axis.x * axis.x, axis.y * axis.y, axis.z * axis.z);
+ var axis_sq = new Vector3(axis.x * axis.x, axis.y * axis.y, axis.z * axis.z);
- real_t cosine = Mathf.Cos( (real_t)phi);
- real_t sine = Mathf.Sin( (real_t)phi);
+ real_t cosine = Mathf.Cos( phi);
+ real_t sine = Mathf.Sin( phi);
- this._x = new Vector3
+ _x = new Vector3
(
axis_sq.x + cosine * (1.0f - axis_sq.x),
axis.x * axis.y * (1.0f - cosine) - axis.z * sine,
axis.z * axis.x * (1.0f - cosine) + axis.y * sine
);
- this._y = new Vector3
+ _y = new Vector3
(
axis.x * axis.y * (1.0f - cosine) + axis.z * sine,
axis_sq.y + cosine * (1.0f - axis_sq.y),
axis.y * axis.z * (1.0f - cosine) - axis.x * sine
);
- this._z = new Vector3
+ _z = new Vector3
(
axis.z * axis.x * (1.0f - cosine) - axis.y * sine,
axis.y * axis.z * (1.0f - cosine) + axis.x * sine,
@@ -476,16 +477,16 @@ namespace Godot
public Basis(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis)
{
- this._x = xAxis;
- this._y = yAxis;
- this._z = zAxis;
+ _x = xAxis;
+ _y = yAxis;
+ _z = zAxis;
}
public Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz)
{
- this._x = new Vector3(xx, xy, xz);
- this._y = new Vector3(yx, yy, yz);
- this._z = new Vector3(zx, zy, zz);
+ _x = new Vector3(xx, xy, xz);
+ _y = new Vector3(yx, yy, yz);
+ _z = new Vector3(zx, zy, zz);
}
public static Basis operator *(Basis left, Basis right)
@@ -532,9 +533,9 @@ namespace Godot
{
return String.Format("({0}, {1}, {2})", new object[]
{
- this._x.ToString(),
- this._y.ToString(),
- this._z.ToString()
+ _x.ToString(),
+ _y.ToString(),
+ _z.ToString()
});
}
@@ -542,9 +543,9 @@ namespace Godot
{
return String.Format("({0}, {1}, {2})", new object[]
{
- this._x.ToString(format),
- this._y.ToString(format),
- this._z.ToString(format)
+ _x.ToString(format),
+ _y.ToString(format),
+ _z.ToString(format)
});
}
}
diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs
index aa42c487c8..af94bb616e 100644
--- a/modules/mono/glue/cs_files/Color.cs
+++ b/modules/mono/glue/cs_files/Color.cs
@@ -45,8 +45,8 @@ namespace Godot
{
get
{
- float max = (float) Mathf.Max(r, (float) Mathf.Max(g, b));
- float min = (float) Mathf.Min(r, (float) Mathf.Min(g, b));
+ float max = Math.Max(r, Math.Max(g, b));
+ float min = Math.Min(r, Math.Min(g, b));
float delta = max - min;
@@ -79,8 +79,8 @@ namespace Godot
{
get
{
- float max = (float) Mathf.Max(r, (float) Mathf.Max(g, b));
- float min = (float) Mathf.Min(r, (float) Mathf.Min(g, b));
+ float max = Math.Max(r, Math.Max(g, b));
+ float min = Math.Min(r, Math.Min(g, b));
float delta = max - min;
@@ -96,7 +96,7 @@ namespace Godot
{
get
{
- return (float) Mathf.Max(r, (float) Mathf.Max(g, b));
+ return Math.Max(r, Math.Max(g, b));
}
set
{
@@ -104,7 +104,7 @@ namespace Godot
}
}
- private static readonly Color black = new Color(0f, 0f, 0f, 1.0f);
+ private static readonly Color black = new Color(0f, 0f, 0f);
public Color Black
{
@@ -180,7 +180,7 @@ namespace Godot
hue += 1.0f;
}
- saturation = (max == 0) ? 0 : 1f - (1f * min / max);
+ saturation = max == 0 ? 0 : 1f - 1f * min / max;
value = max / 255f;
}
@@ -232,12 +232,10 @@ namespace Godot
{
return new Color(0, 0, 0, 0);
}
- else
- {
- res.r = (r * a * sa + over.r * over.a) / res.a;
- res.g = (g * a * sa + over.g * over.a) / res.a;
- res.b = (b * a * sa + over.b * over.a) / res.a;
- }
+
+ res.r = (r * a * sa + over.r * over.a) / res.a;
+ res.g = (g * a * sa + over.g * over.a) / res.a;
+ res.b = (b * a * sa + over.b * over.a) / res.a;
return res;
}
@@ -265,14 +263,14 @@ namespace Godot
);
}
- public Color LinearInterpolate(Color b, float t)
+ public Color LinearInterpolate(Color c, float t)
{
- Color res = this;
+ var res = this;
- res.r += (t * (b.r - this.r));
- res.g += (t * (b.g - this.g));
- res.b += (t * (b.b - this.b));
- res.a += (t * (b.a - this.a));
+ res.r += t * (c.r - r);
+ res.g += t * (c.g - g);
+ res.b += t * (c.b - b);
+ res.a += t * (c.a - a);
return res;
}
@@ -305,7 +303,7 @@ namespace Godot
public string ToHtml(bool include_alpha = true)
{
- String txt = string.Empty;
+ var txt = string.Empty;
txt += _to_hex(r);
txt += _to_hex(g);
@@ -328,13 +326,13 @@ namespace Godot
public Color(int rgba)
{
- this.a = (rgba & 0xFF) / 255.0f;
+ a = (rgba & 0xFF) / 255.0f;
rgba >>= 8;
- this.b = (rgba & 0xFF) / 255.0f;
+ b = (rgba & 0xFF) / 255.0f;
rgba >>= 8;
- this.g = (rgba & 0xFF) / 255.0f;
+ g = (rgba & 0xFF) / 255.0f;
rgba >>= 8;
- this.r = (rgba & 0xFF) / 255.0f;
+ r = (rgba & 0xFF) / 255.0f;
}
private static int _parse_col(string str, int ofs)
@@ -344,7 +342,7 @@ namespace Godot
for (int i = 0; i < 2; i++)
{
int c = str[i + ofs];
- int v = 0;
+ int v;
if (c >= '0' && c <= '9')
{
@@ -376,9 +374,9 @@ namespace Godot
private String _to_hex(float val)
{
- int v = (int) Mathf.Clamp(val * 255.0f, 0, 255);
+ var v = (int) Mathf.Clamp(val * 255.0f, 0, 255);
- string ret = string.Empty;
+ var ret = string.Empty;
for (int i = 0; i < 2; i++)
{
@@ -405,7 +403,7 @@ namespace Godot
if (color[0] == '#')
color = color.Substring(1, color.Length - 1);
- bool alpha = false;
+ bool alpha;
if (color.Length == 8)
alpha = true;
@@ -434,7 +432,7 @@ namespace Godot
public static Color Color8(byte r8, byte g8, byte b8, byte a8)
{
- return new Color((float)r8 / 255f, (float)g8 / 255f, (float)b8 / 255f, (float)a8 / 255f);
+ return new Color(r8 / 255f, g8 / 255f, b8 / 255f, a8 / 255f);
}
public Color(string rgba)
@@ -451,7 +449,7 @@ namespace Godot
if (rgba[0] == '#')
rgba = rgba.Substring(1);
- bool alpha = false;
+ bool alpha;
if (rgba.Length == 8)
{
@@ -513,14 +511,11 @@ namespace Godot
if (left.g == right.g)
{
if (left.b == right.b)
- return (left.a < right.a);
- else
- return (left.b < right.b);
- }
- else
- {
- return left.g < right.g;
+ return left.a < right.a;
+ return left.b < right.b;
}
+
+ return left.g < right.g;
}
return left.r < right.r;
@@ -533,14 +528,11 @@ namespace Godot
if (left.g == right.g)
{
if (left.b == right.b)
- return (left.a > right.a);
- else
- return (left.b > right.b);
- }
- else
- {
- return left.g > right.g;
+ return left.a > right.a;
+ return left.b > right.b;
}
+
+ return left.g > right.g;
}
return left.r > right.r;
@@ -568,24 +560,12 @@ namespace Godot
public override string ToString()
{
- return String.Format("{0},{1},{2},{3}", new object[]
- {
- this.r.ToString(),
- this.g.ToString(),
- this.b.ToString(),
- this.a.ToString()
- });
+ return String.Format("{0},{1},{2},{3}", r.ToString(), g.ToString(), b.ToString(), a.ToString());
}
public string ToString(string format)
{
- return String.Format("{0},{1},{2},{3}", new object[]
- {
- this.r.ToString(format),
- this.g.ToString(format),
- this.b.ToString(format),
- this.a.ToString(format)
- });
+ return String.Format("{0},{1},{2},{3}", r.ToString(format), g.ToString(format), b.ToString(format), a.ToString(format));
}
}
}
diff --git a/modules/mono/glue/cs_files/DebuggingUtils.cs b/modules/mono/glue/cs_files/DebuggingUtils.cs
index ffaaf00837..b27816084e 100644
--- a/modules/mono/glue/cs_files/DebuggingUtils.cs
+++ b/modules/mono/glue/cs_files/DebuggingUtils.cs
@@ -14,7 +14,7 @@ namespace Godot
else if (type == typeof(void))
sb.Append("void");
else
- sb.Append(type.ToString());
+ sb.Append(type);
sb.Append(" ");
}
@@ -32,7 +32,7 @@ namespace Godot
return;
}
- StringBuilder sb = new StringBuilder();
+ var sb = new StringBuilder();
if (methodBase is MethodInfo)
sb.AppendTypeName(((MethodInfo)methodBase).ReturnType);
diff --git a/modules/mono/glue/cs_files/GD.cs b/modules/mono/glue/cs_files/GD.cs
index 1ee7e7d21c..ec1534cb9a 100644
--- a/modules/mono/glue/cs_files/GD.cs
+++ b/modules/mono/glue/cs_files/GD.cs
@@ -91,7 +91,7 @@ namespace Godot
public static int[] Range(int length)
{
- int[] ret = new int[length];
+ var ret = new int[length];
for (int i = 0; i < length; i++)
{
@@ -106,7 +106,7 @@ namespace Godot
if (to < from)
return new int[0];
- int[] ret = new int[to - from];
+ var ret = new int[to - from];
for (int i = from; i < to; i++)
{
@@ -124,14 +124,14 @@ namespace Godot
return new int[0];
// Calculate count
- int count = 0;
+ int count;
if (increment > 0)
- count = ((to - from - 1) / increment) + 1;
+ count = (to - from - 1) / increment + 1;
else
- count = ((from - to - 1) / -increment) + 1;
+ count = (from - to - 1) / -increment + 1;
- int[] ret = new int[count];
+ var ret = new int[count];
if (increment > 0)
{
diff --git a/modules/mono/glue/cs_files/GodotMethodAttribute.cs b/modules/mono/glue/cs_files/GodotMethodAttribute.cs
index 21333c8dab..55848769d5 100644
--- a/modules/mono/glue/cs_files/GodotMethodAttribute.cs
+++ b/modules/mono/glue/cs_files/GodotMethodAttribute.cs
@@ -2,7 +2,7 @@ using System;
namespace Godot
{
- [AttributeUsage(AttributeTargets.Method, Inherited = true)]
+ [AttributeUsage(AttributeTargets.Method)]
internal class GodotMethodAttribute : Attribute
{
private string methodName;
diff --git a/modules/mono/glue/cs_files/GodotSynchronizationContext.cs b/modules/mono/glue/cs_files/GodotSynchronizationContext.cs
index eb4d0bed1c..da3c7bac83 100644
--- a/modules/mono/glue/cs_files/GodotSynchronizationContext.cs
+++ b/modules/mono/glue/cs_files/GodotSynchronizationContext.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
diff --git a/modules/mono/glue/cs_files/GodotTaskScheduler.cs b/modules/mono/glue/cs_files/GodotTaskScheduler.cs
index f587645a49..6bf25a89d2 100644
--- a/modules/mono/glue/cs_files/GodotTaskScheduler.cs
+++ b/modules/mono/glue/cs_files/GodotTaskScheduler.cs
@@ -36,7 +36,7 @@ namespace Godot
TryDequeue(task);
}
- return base.TryExecuteTask(task);
+ return TryExecuteTask(task);
}
protected sealed override bool TryDequeue(Task task)
diff --git a/modules/mono/glue/cs_files/IAwaiter.cs b/modules/mono/glue/cs_files/IAwaiter.cs
index 73c71b5634..b5aa1a5389 100644
--- a/modules/mono/glue/cs_files/IAwaiter.cs
+++ b/modules/mono/glue/cs_files/IAwaiter.cs
@@ -1,4 +1,3 @@
-using System;
using System.Runtime.CompilerServices;
namespace Godot
diff --git a/modules/mono/glue/cs_files/MarshalUtils.cs b/modules/mono/glue/cs_files/MarshalUtils.cs
index 2bdfb95c51..ff4477cc6c 100644
--- a/modules/mono/glue/cs_files/MarshalUtils.cs
+++ b/modules/mono/glue/cs_files/MarshalUtils.cs
@@ -7,7 +7,7 @@ namespace Godot
{
private static Dictionary<object, object> ArraysToDictionary(object[] keys, object[] values)
{
- Dictionary<object, object> ret = new Dictionary<object, object>();
+ var ret = new Dictionary<object, object>();
for (int i = 0; i < keys.Length; i++)
{
@@ -19,11 +19,11 @@ namespace Godot
private static void DictionaryToArrays(Dictionary<object, object> from, out object[] keysTo, out object[] valuesTo)
{
- Dictionary<object, object>.KeyCollection keys = from.Keys;
+ var keys = from.Keys;
keysTo = new object[keys.Count];
keys.CopyTo(keysTo, 0);
- Dictionary<object, object>.ValueCollection values = from.Values;
+ var values = from.Values;
valuesTo = new object[values.Count];
values.CopyTo(valuesTo, 0);
}
diff --git a/modules/mono/glue/cs_files/Mathf.cs b/modules/mono/glue/cs_files/Mathf.cs
index bbee106018..0d20a12563 100644
--- a/modules/mono/glue/cs_files/Mathf.cs
+++ b/modules/mono/glue/cs_files/Mathf.cs
@@ -1,5 +1,4 @@
using System;
-
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -115,7 +114,8 @@ namespace Godot
return Pow(s, curve);
}
- else if (curve < 0f)
+
+ if (curve < 0f)
{
if (s < 0.5f)
{
@@ -144,10 +144,8 @@ namespace Godot
{
return x % y;
}
- else
- {
- return y - (-x % y);
- }
+
+ return y - -x % y;
}
public static real_t InverseLerp(real_t from, real_t to, real_t weight)
@@ -177,22 +175,22 @@ namespace Godot
public static int Max(int a, int b)
{
- return (a > b) ? a : b;
+ return a > b ? a : b;
}
public static real_t Max(real_t a, real_t b)
{
- return (a > b) ? a : b;
+ return a > b ? a : b;
}
public static int Min(int a, int b)
{
- return (a < b) ? a : b;
+ return a < b ? a : b;
}
public static real_t Min(real_t a, real_t b)
{
- return (a < b) ? a : b;
+ return a < b ? a : b;
}
public static int NearestPo2(int value)
@@ -227,19 +225,14 @@ namespace Godot
return (real_t)Math.Round(s);
}
- public static int RoundToInt(real_t s)
- {
- return (int)Math.Round(s);
- }
-
public static int Sign(int s)
{
- return (s < 0) ? -1 : 1;
+ return s < 0 ? -1 : 1;
}
public static real_t Sign(real_t s)
{
- return (s < 0f) ? -1f : 1f;
+ return s < 0f ? -1f : 1f;
}
public static real_t Sin(real_t s)
@@ -280,13 +273,13 @@ namespace Godot
public static int Wrap(int value, int min, int max)
{
int rng = max - min;
- return min + ((((value - min) % rng) + rng) % rng);
+ return min + ((value - min) % rng + rng) % rng;
}
public static real_t Wrap(real_t value, real_t min, real_t max)
{
real_t rng = max - min;
- return min + ((((value - min) % rng) + rng) % rng);
+ return min + ((value - min) % rng + rng) % rng;
}
}
}
diff --git a/modules/mono/glue/cs_files/Plane.cs b/modules/mono/glue/cs_files/Plane.cs
index 0f74f3b66a..8b92522029 100644
--- a/modules/mono/glue/cs_files/Plane.cs
+++ b/modules/mono/glue/cs_files/Plane.cs
@@ -1,5 +1,4 @@
using System;
-
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -81,9 +80,9 @@ namespace Godot
if (Mathf.Abs(denom) <= Mathf.Epsilon)
return new Vector3();
- Vector3 result = (b.normal.Cross(c.normal) * this.d) +
- (c.normal.Cross(normal) * b.d) +
- (normal.Cross(b.normal) * c.d);
+ Vector3 result = b.normal.Cross(c.normal) * d +
+ c.normal.Cross(normal) * b.d +
+ normal.Cross(b.normal) * c.d;
return result / denom;
}
@@ -114,7 +113,7 @@ namespace Godot
real_t dist = (normal.Dot(begin) - d) / den;
- if (dist < -Mathf.Epsilon || dist > (1.0f + Mathf.Epsilon))
+ if (dist < -Mathf.Epsilon || dist > 1.0f + Mathf.Epsilon)
return new Vector3();
return begin + segment * -dist;
@@ -198,8 +197,8 @@ namespace Godot
{
return String.Format("({0}, {1})", new object[]
{
- this.normal.ToString(),
- this.d.ToString()
+ normal.ToString(),
+ d.ToString()
});
}
@@ -207,8 +206,8 @@ namespace Godot
{
return String.Format("({0}, {1})", new object[]
{
- this.normal.ToString(format),
- this.d.ToString(format)
+ normal.ToString(format),
+ d.ToString(format)
});
}
}
diff --git a/modules/mono/glue/cs_files/Quat.cs b/modules/mono/glue/cs_files/Quat.cs
index 0cf3e00ddb..c69c55d997 100644
--- a/modules/mono/glue/cs_files/Quat.cs
+++ b/modules/mono/glue/cs_files/Quat.cs
@@ -1,6 +1,5 @@
using System;
using System.Runtime.InteropServices;
-
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -106,10 +105,10 @@ namespace Godot
}
public void Set(Quat q)
{
- this.x = q.x;
- this.y = q.y;
- this.z = q.z;
- this.w = q.w;
+ x = q.x;
+ y = q.y;
+ z = q.z;
+ w = q.w;
}
public Quat Slerp(Quat b, real_t t)
@@ -117,7 +116,7 @@ namespace Godot
// Calculate cosine
real_t cosom = x * b.x + y * b.y + z * b.z + w * b.w;
- real_t[] to1 = new real_t[4];
+ var to1 = new real_t[4];
// Adjust signs if necessary
if (cosom < 0.0)
@@ -138,7 +137,7 @@ namespace Godot
real_t sinom, scale0, scale1;
// Calculate coefficients
- if ((1.0 - cosom) > Mathf.Epsilon)
+ if (1.0 - cosom > Mathf.Epsilon)
{
// Standard case (Slerp)
real_t omega = Mathf.Acos(cosom);
@@ -165,7 +164,7 @@ namespace Godot
public Quat Slerpni(Quat b, real_t t)
{
- real_t dot = this.Dot(b);
+ real_t dot = Dot(b);
if (Mathf.Abs(dot) > 0.9999f)
{
@@ -179,17 +178,17 @@ namespace Godot
return new Quat
(
- invFactor * this.x + newFactor * b.x,
- invFactor * this.y + newFactor * b.y,
- invFactor * this.z + newFactor * b.z,
- invFactor * this.w + newFactor * b.w
+ invFactor * x + newFactor * b.x,
+ invFactor * y + newFactor * b.y,
+ invFactor * z + newFactor * b.z,
+ invFactor * w + newFactor * b.w
);
}
public Vector3 Xform(Vector3 v)
{
Quat q = this * v;
- q *= this.Inverse();
+ q *= Inverse();
return new Vector3(q.x, q.y, q.z);
}
@@ -203,10 +202,10 @@ namespace Godot
}
public Quat(Quat q)
{
- this.x = q.x;
- this.y = q.y;
- this.z = q.z;
- this.w = q.w;
+ x = q.x;
+ y = q.y;
+ z = q.z;
+ w = q.w;
}
public Quat(Vector3 axis, real_t angle)
@@ -327,24 +326,12 @@ namespace Godot
public override string ToString()
{
- return String.Format("({0}, {1}, {2}, {3})", new object[]
- {
- this.x.ToString(),
- this.y.ToString(),
- this.z.ToString(),
- this.w.ToString()
- });
+ return String.Format("({0}, {1}, {2}, {3})", x.ToString(), y.ToString(), z.ToString(), w.ToString());
}
public string ToString(string format)
{
- return String.Format("({0}, {1}, {2}, {3})", new object[]
- {
- this.x.ToString(format),
- this.y.ToString(format),
- this.z.ToString(format),
- this.w.ToString(format)
- });
+ return String.Format("({0}, {1}, {2}, {3})", x.ToString(format), y.ToString(format), z.ToString(format), w.ToString(format));
}
}
}
diff --git a/modules/mono/glue/cs_files/Rect2.cs b/modules/mono/glue/cs_files/Rect2.cs
index decee35f8c..6f16656573 100644
--- a/modules/mono/glue/cs_files/Rect2.cs
+++ b/modules/mono/glue/cs_files/Rect2.cs
@@ -1,6 +1,5 @@
using System;
using System.Runtime.InteropServices;
-
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -39,7 +38,7 @@ namespace Godot
public Rect2 Clip(Rect2 b)
{
- Rect2 newRect = b;
+ var newRect = b;
if (!Intersects(newRect))
return new Rect2();
@@ -58,14 +57,14 @@ namespace Godot
public bool Encloses(Rect2 b)
{
- return (b.position.x >= position.x) && (b.position.y >= position.y) &&
- ((b.position.x + b.size.x) < (position.x + size.x)) &&
- ((b.position.y + b.size.y) < (position.y + size.y));
+ return b.position.x >= position.x && b.position.y >= position.y &&
+ b.position.x + b.size.x < position.x + size.x &&
+ b.position.y + b.size.y < position.y + size.y;
}
public Rect2 Expand(Vector2 to)
{
- Rect2 expanded = this;
+ var expanded = this;
Vector2 begin = expanded.position;
Vector2 end = expanded.position + expanded.size;
@@ -93,7 +92,7 @@ namespace Godot
public Rect2 Grow(real_t by)
{
- Rect2 g = this;
+ var g = this;
g.position.x -= by;
g.position.y -= by;
@@ -105,7 +104,7 @@ namespace Godot
public Rect2 GrowIndividual(real_t left, real_t top, real_t right, real_t bottom)
{
- Rect2 g = this;
+ var g = this;
g.position.x -= left;
g.position.y -= top;
@@ -117,12 +116,12 @@ namespace Godot
public Rect2 GrowMargin(Margin margin, real_t by)
{
- Rect2 g = this;
+ var g = this;
- g.GrowIndividual((Margin.Left == margin) ? by : 0,
- (Margin.Top == margin) ? by : 0,
- (Margin.Right == margin) ? by : 0,
- (Margin.Bottom == margin) ? by : 0);
+ g.GrowIndividual(Margin.Left == margin ? by : 0,
+ Margin.Top == margin ? by : 0,
+ Margin.Right == margin ? by : 0,
+ Margin.Bottom == margin ? by : 0);
return g;
}
@@ -139,9 +138,9 @@ namespace Godot
if (point.y < position.y)
return false;
- if (point.x >= (position.x + size.x))
+ if (point.x >= position.x + size.x)
return false;
- if (point.y >= (position.y + size.y))
+ if (point.y >= position.y + size.y)
return false;
return true;
@@ -149,13 +148,13 @@ namespace Godot
public bool Intersects(Rect2 b)
{
- if (position.x > (b.position.x + b.size.x))
+ if (position.x > b.position.x + b.size.x)
return false;
- if ((position.x + size.x) < b.position.x)
+ if (position.x + size.x < b.position.x)
return false;
- if (position.y > (b.position.y + b.size.y))
+ if (position.y > b.position.y + b.size.y)
return false;
- if ((position.y + size.y) < b.position.y)
+ if (position.y + size.y < b.position.y)
return false;
return true;
@@ -185,17 +184,17 @@ namespace Godot
public Rect2(Vector2 position, real_t width, real_t height)
{
this.position = position;
- this.size = new Vector2(width, height);
+ size = new Vector2(width, height);
}
public Rect2(real_t x, real_t y, Vector2 size)
{
- this.position = new Vector2(x, y);
+ position = new Vector2(x, y);
this.size = size;
}
public Rect2(real_t x, real_t y, real_t width, real_t height)
{
- this.position = new Vector2(x, y);
- this.size = new Vector2(width, height);
+ position = new Vector2(x, y);
+ size = new Vector2(width, height);
}
public static bool operator ==(Rect2 left, Rect2 right)
@@ -232,8 +231,8 @@ namespace Godot
{
return String.Format("({0}, {1})", new object[]
{
- this.position.ToString(),
- this.size.ToString()
+ position.ToString(),
+ size.ToString()
});
}
@@ -241,8 +240,8 @@ namespace Godot
{
return String.Format("({0}, {1})", new object[]
{
- this.position.ToString(format),
- this.size.ToString(format)
+ position.ToString(format),
+ size.ToString(format)
});
}
}
diff --git a/modules/mono/glue/cs_files/SignalAttribute.cs b/modules/mono/glue/cs_files/SignalAttribute.cs
index d8a6cabb83..3957387be9 100644
--- a/modules/mono/glue/cs_files/SignalAttribute.cs
+++ b/modules/mono/glue/cs_files/SignalAttribute.cs
@@ -5,8 +5,5 @@ namespace Godot
[AttributeUsage(AttributeTargets.Delegate)]
public class SignalAttribute : Attribute
{
- public SignalAttribute()
- {
- }
}
}
diff --git a/modules/mono/glue/cs_files/SignalAwaiter.cs b/modules/mono/glue/cs_files/SignalAwaiter.cs
index 19ccc26e79..c06f6b05c9 100644
--- a/modules/mono/glue/cs_files/SignalAwaiter.cs
+++ b/modules/mono/glue/cs_files/SignalAwaiter.cs
@@ -4,15 +4,15 @@ namespace Godot
{
public class SignalAwaiter : IAwaiter<object[]>, IAwaitable<object[]>
{
- private bool completed = false;
- private object[] result = null;
- private Action action = null;
+ private bool completed;
+ private object[] result;
+ private Action action;
- public SignalAwaiter(Godot.Object source, string signal, Godot.Object target)
+ public SignalAwaiter(Object source, string signal, Object target)
{
NativeCalls.godot_icall_Object_connect_signal_awaiter(
- Godot.Object.GetPtr(source),
- signal, Godot.Object.GetPtr(target), this
+ Object.GetPtr(source),
+ signal, Object.GetPtr(target), this
);
}
diff --git a/modules/mono/glue/cs_files/StringExtensions.cs b/modules/mono/glue/cs_files/StringExtensions.cs
index cbc337ab19..21090fb68d 100644
--- a/modules/mono/glue/cs_files/StringExtensions.cs
+++ b/modules/mono/glue/cs_files/StringExtensions.cs
@@ -1,4 +1,5 @@
//using System;
+
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -43,11 +44,9 @@ namespace Godot
{
return instance.Substring(prev, i - prev);
}
- else
- {
- count++;
- prev = i + 1;
- }
+
+ count++;
+ prev = i + 1;
}
i++;
@@ -83,7 +82,7 @@ namespace Godot
// </summary>
public static string[] Bigrams(this string instance)
{
- string[] b = new string[instance.Length - 1];
+ var b = new string[instance.Length - 1];
for (int i = 0; i < b.Length; i++)
{
@@ -98,7 +97,7 @@ namespace Godot
// </summary>
public static string CEscape(this string instance)
{
- StringBuilder sb = new StringBuilder(string.Copy(instance));
+ var sb = new StringBuilder(string.Copy(instance));
sb.Replace("\\", "\\\\");
sb.Replace("\a", "\\a");
@@ -120,7 +119,7 @@ namespace Godot
// </summary>
public static string CUnescape(this string instance)
{
- StringBuilder sb = new StringBuilder(string.Copy(instance));
+ var sb = new StringBuilder(string.Copy(instance));
sb.Replace("\\a", "\a");
sb.Replace("\\b", "\b");
@@ -143,7 +142,7 @@ namespace Godot
public static string Capitalize(this string instance)
{
string aux = instance.Replace("_", " ").ToLower();
- string cap = string.Empty;
+ var cap = string.Empty;
for (int i = 0; i < aux.GetSliceCount(" "); i++)
{
@@ -178,13 +177,13 @@ namespace Godot
{
if (to[to_idx] == 0 && instance[instance_idx] == 0)
return 0; // We're equal
- else if (instance[instance_idx] == 0)
+ if (instance[instance_idx] == 0)
return -1; // If this is empty, and the other one is not, then we're less... I think?
- else if (to[to_idx] == 0)
+ if (to[to_idx] == 0)
return 1; // Otherwise the other one is smaller...
- else if (instance[instance_idx] < to[to_idx]) // More than
+ if (instance[instance_idx] < to[to_idx]) // More than
return -1;
- else if (instance[instance_idx] > to[to_idx]) // Less than
+ if (instance[instance_idx] > to[to_idx]) // Less than
return 1;
instance_idx++;
@@ -260,12 +259,12 @@ namespace Godot
{
int basepos = instance.Find("://");
- string rs = string.Empty;
- string @base = string.Empty;
+ string rs;
+ var @base = string.Empty;
if (basepos != -1)
{
- int end = basepos + 3;
+ var end = basepos + 3;
rs = instance.Substring(end, instance.Length);
@base = instance.Substring(0, end);
}
@@ -312,8 +311,8 @@ namespace Godot
int hashv = 5381;
int c;
- while ((c = (int)instance[index++]) != 0)
- hashv = ((hashv << 5) + hashv) + c; // hash * 33 + c
+ while ((c = instance[index++]) != 0)
+ hashv = (hashv << 5) + hashv + c; // hash * 33 + c
return hashv;
}
@@ -379,7 +378,7 @@ namespace Godot
while (instance[src] != 0 && text[tgt] != 0)
{
- bool match = false;
+ bool match;
if (case_insensitive)
{
@@ -455,7 +454,10 @@ namespace Godot
return false; // Don't start with number plz
}
- bool valid_char = (instance[i] >= '0' && instance[i] <= '9') || (instance[i] >= 'a' && instance[i] <= 'z') || (instance[i] >= 'A' && instance[i] <= 'Z') || instance[i] == '_';
+ bool valid_char = instance[i] >= '0' &&
+ instance[i] <= '9' || instance[i] >= 'a' &&
+ instance[i] <= 'z' || instance[i] >= 'A' &&
+ instance[i] <= 'Z' || instance[i] == '_';
if (!valid_char)
return false;
@@ -502,7 +504,7 @@ namespace Godot
// </summary>
public static string JsonEscape(this string instance)
{
- StringBuilder sb = new StringBuilder(string.Copy(instance));
+ var sb = new StringBuilder(string.Copy(instance));
sb.Replace("\\", "\\\\");
sb.Replace("\b", "\\b");
@@ -551,7 +553,7 @@ namespace Godot
case '\0':
return instance[0] == 0;
case '*':
- return ExprMatch(expr + 1, instance, caseSensitive) || (instance[0] != 0 && ExprMatch(expr, instance + 1, caseSensitive));
+ return ExprMatch(expr + 1, instance, caseSensitive) || instance[0] != 0 && ExprMatch(expr, instance + 1, caseSensitive);
case '?':
return instance[0] != 0 && instance[0] != '.' && ExprMatch(expr + 1, instance + 1, caseSensitive);
default:
@@ -610,13 +612,13 @@ namespace Godot
{
if (to[to_idx] == 0 && instance[instance_idx] == 0)
return 0; // We're equal
- else if (instance[instance_idx] == 0)
+ if (instance[instance_idx] == 0)
return -1; // If this is empty, and the other one is not, then we're less... I think?
- else if (to[to_idx] == 0)
+ if (to[to_idx] == 0)
return 1; // Otherwise the other one is smaller..
- else if (char.ToUpper(instance[instance_idx]) < char.ToUpper(to[to_idx])) // More than
+ if (char.ToUpper(instance[instance_idx]) < char.ToUpper(to[to_idx])) // More than
return -1;
- else if (char.ToUpper(instance[instance_idx]) > char.ToUpper(to[to_idx])) // Less than
+ if (char.ToUpper(instance[instance_idx]) > char.ToUpper(to[to_idx])) // Less than
return 1;
instance_idx++;
@@ -724,8 +726,7 @@ namespace Godot
{
if (instance.Length > 0 && instance[instance.Length - 1] == '/')
return instance + file;
- else
- return instance + "/" + file;
+ return instance + "/" + file;
}
// <summary>
@@ -771,7 +772,7 @@ namespace Godot
if (pos < 0)
return string.Empty;
- return instance.Substring(pos, (instance.Length - pos));
+ return instance.Substring(pos, instance.Length - pos);
}
public static byte[] Sha256Buffer(this string instance)
@@ -824,7 +825,7 @@ namespace Godot
}
}
- return (2.0f * inter) / sum;
+ return 2.0f * inter / sum;
}
// <summary>
@@ -832,7 +833,7 @@ namespace Godot
// </summary>
public static string[] Split(this string instance, string divisor, bool allow_empty = true)
{
- return instance.Split(new string[] { divisor }, StringSplitOptions.RemoveEmptyEntries);
+ return instance.Split(new[] { divisor }, StringSplitOptions.RemoveEmptyEntries);
}
// <summary>
@@ -840,7 +841,7 @@ namespace Godot
// </summary>
public static float[] SplitFloats(this string instance, string divisor, bool allow_empty = true)
{
- List<float> ret = new List<float>();
+ var ret = new List<float>();
int from = 0;
int len = instance.Length;
@@ -849,7 +850,7 @@ namespace Godot
int end = instance.Find(divisor, from);
if (end < 0)
end = len;
- if (allow_empty || (end > from))
+ if (allow_empty || end > from)
ret.Add(float.Parse(instance.Substring(from)));
if (end == len)
break;
@@ -878,13 +879,10 @@ namespace Godot
{
if (right)
return instance.Trim(non_printable);
- else
- return instance.TrimStart(non_printable);
- }
- else
- {
- return instance.TrimEnd(non_printable);
+ return instance.TrimStart(non_printable);
}
+
+ return instance.TrimEnd(non_printable);
}
// <summary>
diff --git a/modules/mono/glue/cs_files/Transform.cs b/modules/mono/glue/cs_files/Transform.cs
index ce26c60706..d1b247a552 100644
--- a/modules/mono/glue/cs_files/Transform.cs
+++ b/modules/mono/glue/cs_files/Transform.cs
@@ -1,6 +1,5 @@
using System;
using System.Runtime.InteropServices;
-
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -29,7 +28,7 @@ namespace Godot
public Transform LookingAt(Vector3 target, Vector3 up)
{
- Transform t = this;
+ var t = this;
t.SetLookAt(origin, target, up);
return t;
}
@@ -98,22 +97,22 @@ namespace Godot
return new Vector3
(
- (basis[0, 0] * vInv.x) + (basis[1, 0] * vInv.y) + (basis[2, 0] * vInv.z),
- (basis[0, 1] * vInv.x) + (basis[1, 1] * vInv.y) + (basis[2, 1] * vInv.z),
- (basis[0, 2] * vInv.x) + (basis[1, 2] * vInv.y) + (basis[2, 2] * vInv.z)
+ basis[0, 0] * vInv.x + basis[1, 0] * vInv.y + basis[2, 0] * vInv.z,
+ basis[0, 1] * vInv.x + basis[1, 1] * vInv.y + basis[2, 1] * vInv.z,
+ basis[0, 2] * vInv.x + basis[1, 2] * vInv.y + basis[2, 2] * vInv.z
);
}
// Constructors
public Transform(Vector3 xAxis, Vector3 yAxis, Vector3 zAxis, Vector3 origin)
{
- this.basis = Basis.CreateFromAxes(xAxis, yAxis, zAxis);
+ basis = Basis.CreateFromAxes(xAxis, yAxis, zAxis);
this.origin = origin;
}
public Transform(Quat quat, Vector3 origin)
{
- this.basis = new Basis(quat);
+ basis = new Basis(quat);
this.origin = origin;
}
@@ -164,8 +163,8 @@ namespace Godot
{
return String.Format("{0} - {1}", new object[]
{
- this.basis.ToString(),
- this.origin.ToString()
+ basis.ToString(),
+ origin.ToString()
});
}
@@ -173,8 +172,8 @@ namespace Godot
{
return String.Format("{0} - {1}", new object[]
{
- this.basis.ToString(format),
- this.origin.ToString(format)
+ basis.ToString(format),
+ origin.ToString(format)
});
}
}
diff --git a/modules/mono/glue/cs_files/Transform2D.cs b/modules/mono/glue/cs_files/Transform2D.cs
index 836cca129e..ff5259178b 100644
--- a/modules/mono/glue/cs_files/Transform2D.cs
+++ b/modules/mono/glue/cs_files/Transform2D.cs
@@ -1,6 +1,5 @@
using System;
using System.Runtime.InteropServices;
-
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -111,7 +110,7 @@ namespace Godot
public Transform2D AffineInverse()
{
- Transform2D inv = this;
+ var inv = this;
real_t det = this[0, 0] * this[1, 1] - this[1, 0] * this[0, 1];
@@ -158,15 +157,15 @@ namespace Godot
Vector2 s2 = m.Scale;
// Slerp rotation
- Vector2 v1 = new Vector2(Mathf.Cos(r1), Mathf.Sin(r1));
- Vector2 v2 = new Vector2(Mathf.Cos(r2), Mathf.Sin(r2));
+ var v1 = new Vector2(Mathf.Cos(r1), Mathf.Sin(r1));
+ var v2 = new Vector2(Mathf.Cos(r2), Mathf.Sin(r2));
real_t dot = v1.Dot(v2);
// Clamp dot to [-1, 1]
- dot = (dot < -1.0f) ? -1.0f : ((dot > 1.0f) ? 1.0f : dot);
+ dot = dot < -1.0f ? -1.0f : (dot > 1.0f ? 1.0f : dot);
- Vector2 v = new Vector2();
+ Vector2 v;
if (dot > 0.9995f)
{
@@ -185,7 +184,7 @@ namespace Godot
Vector2 p2 = m.Origin;
// Construct matrix
- Transform2D res = new Transform2D(Mathf.Atan2(v.y, v.x), p1.LinearInterpolate(p2, c));
+ var res = new Transform2D(Mathf.Atan2(v.y, v.x), p1.LinearInterpolate(p2, c));
Vector2 scale = s1.LinearInterpolate(s2, c);
res.x *= scale;
res.y *= scale;
@@ -195,7 +194,7 @@ namespace Godot
public Transform2D Inverse()
{
- Transform2D inv = this;
+ var inv = this;
// Swap
real_t temp = inv.x.y;
@@ -209,13 +208,13 @@ namespace Godot
public Transform2D Orthonormalized()
{
- Transform2D on = this;
+ var on = this;
Vector2 onX = on.x;
Vector2 onY = on.y;
onX.Normalize();
- onY = onY - onX * (onX.Dot(onY));
+ onY = onY - onX * onX.Dot(onY);
onY.Normalize();
on.x = onX;
@@ -231,7 +230,7 @@ namespace Godot
public Transform2D Scaled(Vector2 scale)
{
- Transform2D copy = this;
+ var copy = this;
copy.x *= scale;
copy.y *= scale;
copy.o *= scale;
@@ -250,7 +249,7 @@ namespace Godot
public Transform2D Translated(Vector2 offset)
{
- Transform2D copy = this;
+ var copy = this;
copy.o += copy.BasisXform(offset);
return copy;
}
@@ -269,22 +268,22 @@ namespace Godot
// Constructors
public Transform2D(Vector2 xAxis, Vector2 yAxis, Vector2 origin)
{
- this.x = xAxis;
- this.y = yAxis;
- this.o = origin;
+ x = xAxis;
+ y = yAxis;
+ o = origin;
}
public Transform2D(real_t xx, real_t xy, real_t yx, real_t yy, real_t ox, real_t oy)
{
- this.x = new Vector2(xx, xy);
- this.y = new Vector2(yx, yy);
- this.o = new Vector2(ox, oy);
+ x = new Vector2(xx, xy);
+ y = new Vector2(yx, yy);
+ o = new Vector2(ox, oy);
}
public Transform2D(real_t rot, Vector2 pos)
{
- real_t cr = Mathf.Cos( (real_t)rot);
- real_t sr = Mathf.Sin( (real_t)rot);
+ real_t cr = Mathf.Cos(rot);
+ real_t sr = Mathf.Sin(rot);
x.x = cr;
y.y = cr;
x.y = -sr;
@@ -345,9 +344,9 @@ namespace Godot
{
return String.Format("({0}, {1}, {2})", new object[]
{
- this.x.ToString(),
- this.y.ToString(),
- this.o.ToString()
+ x.ToString(),
+ y.ToString(),
+ o.ToString()
});
}
@@ -355,9 +354,9 @@ namespace Godot
{
return String.Format("({0}, {1}, {2})", new object[]
{
- this.x.ToString(format),
- this.y.ToString(format),
- this.o.ToString(format)
+ x.ToString(format),
+ y.ToString(format),
+ o.ToString(format)
});
}
}
diff --git a/modules/mono/glue/cs_files/Vector2.cs b/modules/mono/glue/cs_files/Vector2.cs
index 6fbe374611..cc2cda82fb 100644
--- a/modules/mono/glue/cs_files/Vector2.cs
+++ b/modules/mono/glue/cs_files/Vector2.cs
@@ -1,13 +1,11 @@
-using System;
-using System.Runtime.InteropServices;
-
// file: core/math/math_2d.h
// commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451
// file: core/math/math_2d.cpp
// commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451
// file: core/variant_call.cpp
// commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685
-
+using System;
+using System.Runtime.InteropServices;
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -101,8 +99,8 @@ namespace Godot
public Vector2 Clamped(real_t length)
{
- Vector2 v = this;
- real_t l = this.Length();
+ var v = this;
+ real_t l = Length();
if (l > 0 && length < l)
{
@@ -115,15 +113,15 @@ namespace Godot
public Vector2 CubicInterpolate(Vector2 b, Vector2 preA, Vector2 postB, real_t t)
{
- Vector2 p0 = preA;
- Vector2 p1 = this;
- Vector2 p2 = b;
- Vector2 p3 = postB;
+ var p0 = preA;
+ var p1 = this;
+ var p2 = b;
+ var p3 = postB;
real_t t2 = t * t;
real_t t3 = t2 * t;
- return 0.5f * ((p1 * 2.0f) +
+ return 0.5f * (p1 * 2.0f +
(-p0 + p2) * t +
(2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 +
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3);
@@ -166,17 +164,17 @@ namespace Godot
public Vector2 LinearInterpolate(Vector2 b, real_t t)
{
- Vector2 res = this;
+ var res = this;
- res.x += (t * (b.x - x));
- res.y += (t * (b.y - y));
+ res.x += t * (b.x - x);
+ res.y += t * (b.y - y);
return res;
}
public Vector2 Normalized()
{
- Vector2 result = this;
+ var result = this;
result.Normalize();
return result;
}
@@ -199,8 +197,8 @@ namespace Godot
}
public void Set(Vector2 v)
{
- this.x = v.x;
- this.y = v.y;
+ x = v.x;
+ y = v.y;
}
public Vector2 Slide(Vector2 n)
@@ -244,8 +242,8 @@ namespace Godot
}
public Vector2(Vector2 v)
{
- this.x = v.x;
- this.y = v.y;
+ x = v.x;
+ y = v.y;
}
public static Vector2 operator +(Vector2 left, Vector2 right)
@@ -320,10 +318,8 @@ namespace Godot
{
return left.y < right.y;
}
- else
- {
- return left.x < right.x;
- }
+
+ return left.x < right.x;
}
public static bool operator >(Vector2 left, Vector2 right)
@@ -332,10 +328,8 @@ namespace Godot
{
return left.y > right.y;
}
- else
- {
- return left.x > right.x;
- }
+
+ return left.x > right.x;
}
public static bool operator <=(Vector2 left, Vector2 right)
@@ -344,10 +338,8 @@ namespace Godot
{
return left.y <= right.y;
}
- else
- {
- return left.x <= right.x;
- }
+
+ return left.x <= right.x;
}
public static bool operator >=(Vector2 left, Vector2 right)
@@ -356,10 +348,8 @@ namespace Godot
{
return left.y >= right.y;
}
- else
- {
- return left.x >= right.x;
- }
+
+ return left.x >= right.x;
}
public override bool Equals(object obj)
@@ -386,8 +376,8 @@ namespace Godot
{
return String.Format("({0}, {1})", new object[]
{
- this.x.ToString(),
- this.y.ToString()
+ x.ToString(),
+ y.ToString()
});
}
@@ -395,8 +385,8 @@ namespace Godot
{
return String.Format("({0}, {1})", new object[]
{
- this.x.ToString(format),
- this.y.ToString(format)
+ x.ToString(format),
+ y.ToString(format)
});
}
}
diff --git a/modules/mono/glue/cs_files/Vector3.cs b/modules/mono/glue/cs_files/Vector3.cs
index 285736d7b8..0a71f3fa4d 100644
--- a/modules/mono/glue/cs_files/Vector3.cs
+++ b/modules/mono/glue/cs_files/Vector3.cs
@@ -1,13 +1,11 @@
-using System;
-using System.Runtime.InteropServices;
-
// file: core/math/vector3.h
// commit: bd282ff43f23fe845f29a3e25c8efc01bd65ffb0
// file: core/math/vector3.cpp
// commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451
// file: core/variant_call.cpp
// commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685
-
+using System;
+using System.Runtime.InteropServices;
#if REAL_T_IS_DOUBLE
using real_t = System.Double;
#else
@@ -67,7 +65,7 @@ namespace Godot
internal void Normalize()
{
- real_t length = this.Length();
+ real_t length = Length();
if (length == 0f)
{
@@ -105,24 +103,24 @@ namespace Godot
{
return new Vector3
(
- (y * b.z) - (z * b.y),
- (z * b.x) - (x * b.z),
- (x * b.y) - (y * b.x)
+ y * b.z - z * b.y,
+ z * b.x - x * b.z,
+ x * b.y - y * b.x
);
}
public Vector3 CubicInterpolate(Vector3 b, Vector3 preA, Vector3 postB, real_t t)
{
- Vector3 p0 = preA;
- Vector3 p1 = this;
- Vector3 p2 = b;
- Vector3 p3 = postB;
+ var p0 = preA;
+ var p1 = this;
+ var p2 = b;
+ var p3 = postB;
real_t t2 = t * t;
real_t t3 = t2 * t;
return 0.5f * (
- (p1 * 2.0f) + (-p0 + p2) * t +
+ p1 * 2.0f + (-p0 + p2) * t +
(2.0f * p0 - 5.0f * p1 + 4f * p2 - p3) * t2 +
(-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3
);
@@ -180,9 +178,9 @@ namespace Godot
{
return new Vector3
(
- x + (t * (b.x - x)),
- y + (t * (b.y - y)),
- z + (t * (b.z - z))
+ x + t * (b.x - x),
+ y + t * (b.y - y),
+ z + t * (b.z - z)
);
}
@@ -198,7 +196,7 @@ namespace Godot
public Vector3 Normalized()
{
- Vector3 v = this;
+ var v = this;
v.Normalize();
return v;
}
@@ -234,9 +232,9 @@ namespace Godot
}
public void Set(Vector3 v)
{
- this.x = v.x;
- this.y = v.y;
- this.z = v.z;
+ x = v.x;
+ y = v.y;
+ z = v.z;
}
public Vector3 Slide(Vector3 n)
@@ -294,9 +292,9 @@ namespace Godot
}
public Vector3(Vector3 v)
{
- this.x = v.x;
- this.y = v.y;
- this.z = v.z;
+ x = v.x;
+ y = v.y;
+ z = v.z;
}
public static Vector3 operator +(Vector3 left, Vector3 right)
@@ -379,8 +377,7 @@ namespace Godot
{
if (left.y == right.y)
return left.z < right.z;
- else
- return left.y < right.y;
+ return left.y < right.y;
}
return left.x < right.x;
@@ -392,8 +389,7 @@ namespace Godot
{
if (left.y == right.y)
return left.z > right.z;
- else
- return left.y > right.y;
+ return left.y > right.y;
}
return left.x > right.x;
@@ -405,8 +401,7 @@ namespace Godot
{
if (left.y == right.y)
return left.z <= right.z;
- else
- return left.y < right.y;
+ return left.y < right.y;
}
return left.x < right.x;
@@ -418,8 +413,7 @@ namespace Godot
{
if (left.y == right.y)
return left.z >= right.z;
- else
- return left.y > right.y;
+ return left.y > right.y;
}
return left.x > right.x;
@@ -449,9 +443,9 @@ namespace Godot
{
return String.Format("({0}, {1}, {2})", new object[]
{
- this.x.ToString(),
- this.y.ToString(),
- this.z.ToString()
+ x.ToString(),
+ y.ToString(),
+ z.ToString()
});
}
@@ -459,9 +453,9 @@ namespace Godot
{
return String.Format("({0}, {1}, {2})", new object[]
{
- this.x.ToString(format),
- this.y.ToString(format),
- this.z.ToString(format)
+ x.ToString(format),
+ y.ToString(format),
+ z.ToString(format)
});
}
}
diff --git a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
index d72c590378..bde4221644 100644
--- a/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
+++ b/platform/android/java/src/org/godotengine/godot/GodotPaymentV3.java
@@ -101,12 +101,12 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
GodotLib.calldeferred(purchaseCallbackId, "consume_not_required", new Object[] {});
}
- public void callbackFailConsume() {
- GodotLib.calldeferred(purchaseCallbackId, "consume_fail", new Object[] {});
+ public void callbackFailConsume(String message) {
+ GodotLib.calldeferred(purchaseCallbackId, "consume_fail", new Object[] { message });
}
- public void callbackFail() {
- GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[] {});
+ public void callbackFail(String message) {
+ GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[] { message });
}
public void callbackCancel() {
@@ -165,11 +165,11 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
}
public void callbackDisconnected() {
- GodotLib.calldeferred(purchaseCallbackId, "iap_disconnected", new Object[]{});
+ GodotLib.calldeferred(purchaseCallbackId, "iap_disconnected", new Object[] {});
}
public void callbackConnected() {
- GodotLib.calldeferred(purchaseCallbackId, "iap_connected", new Object[]{});
+ GodotLib.calldeferred(purchaseCallbackId, "iap_connected", new Object[] {});
}
// true if connected, false otherwise
diff --git a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
index 441a311358..b7bf2362cc 100644
--- a/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
+++ b/platform/android/java/src/org/godotengine/godot/payments/PaymentsManager.java
@@ -116,7 +116,7 @@ public class PaymentsManager {
@Override
protected void error(String message) {
- godotPaymentV3.callbackFail();
+ godotPaymentV3.callbackFail(message);
}
@Override
@@ -148,7 +148,7 @@ public class PaymentsManager {
@Override
protected void error(String message) {
Log.d("godot", "consumeUnconsumedPurchases :" + message);
- godotPaymentV3.callbackFailConsume();
+ godotPaymentV3.callbackFailConsume(message);
}
@Override
@@ -222,7 +222,7 @@ public class PaymentsManager {
@Override
protected void error(String message) {
- godotPaymentV3.callbackFail();
+ godotPaymentV3.callbackFail(message);
}
}
.consume(sku);
@@ -231,7 +231,7 @@ public class PaymentsManager {
@Override
protected void error(String message) {
- godotPaymentV3.callbackFail();
+ godotPaymentV3.callbackFail(message);
}
@Override
@@ -258,7 +258,7 @@ public class PaymentsManager {
@Override
protected void error(String message) {
- godotPaymentV3.callbackFail();
+ godotPaymentV3.callbackFail(message);
}
}
.consume(sku);
@@ -266,7 +266,7 @@ public class PaymentsManager {
@Override
protected void error(String message) {
- godotPaymentV3.callbackFail();
+ godotPaymentV3.callbackFail(message);
}
@Override
@@ -291,7 +291,7 @@ public class PaymentsManager {
@Override
protected void error(String message) {
- godotPaymentV3.callbackFailConsume();
+ godotPaymentV3.callbackFailConsume(message);
}
}
.consume(sku);
diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm
index 6fa189e917..2cdd477ed1 100644
--- a/platform/iphone/in_app_store.mm
+++ b/platform/iphone/in_app_store.mm
@@ -238,6 +238,7 @@ Error InAppStore::restore_purchases() {
ret["type"] = "purchase";
ret["result"] = "error";
ret["product_id"] = pid;
+ ret["error"] = String::utf8([transaction.error.localizedDescription UTF8String]);
InAppStore::get_singleton()->_post_event(ret);
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
} break;
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 60368816a9..a2637f816e 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -271,7 +271,8 @@ bool CanvasItem::is_visible_in_tree() const {
void CanvasItem::_propagate_visibility_changed(bool p_visible) {
- notification(NOTIFICATION_VISIBILITY_CHANGED);
+ if (!first_draw)
+ notification(NOTIFICATION_VISIBILITY_CHANGED);
if (p_visible)
update(); //todo optimize
diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp
index 7b77b34b26..7377591f7d 100644
--- a/scene/2d/path_2d.cpp
+++ b/scene/2d/path_2d.cpp
@@ -96,7 +96,7 @@ void Path2D::_notification(int p_what) {
#else
const float line_width = 2;
#endif
- const Color color = Color(0.5, 0.6, 1.0, 0.7);
+ const Color color = Color(1.0, 1.0, 1.0, 1.0);
for (int i = 0; i < curve->get_point_count(); i++) {
@@ -151,6 +151,7 @@ void Path2D::_bind_methods() {
Path2D::Path2D() {
set_curve(Ref<Curve2D>(memnew(Curve2D))); //create one by default
+ set_self_modulate(Color(0.5, 0.6, 1.0, 0.7));
}
/////////////////////////////////////////////////////////////////////////////////
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index ca1ac2cd7f..bc39368c88 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -331,7 +331,31 @@ bool Sprite::_edit_is_selected_on_click(const Point2 &p_point, double p_toleranc
}
ERR_FAIL_COND_V(image.is_null(), false);
+ if (image->is_compressed()) {
+ return dst_rect.has_point(p_point);
+ }
+ bool is_repeat = texture->get_flags() & Texture::FLAG_REPEAT;
+ bool is_mirrored_repeat = texture->get_flags() & Texture::FLAG_MIRRORED_REPEAT;
+ if (is_repeat) {
+ int mirror_x = 0;
+ int mirror_y = 0;
+ if (is_mirrored_repeat) {
+ mirror_x = (int)(q.x / texture->get_size().width);
+ mirror_y = (int)(q.y / texture->get_size().height);
+ }
+ q.x = Math::fmod(q.x, texture->get_size().width);
+ q.y = Math::fmod(q.y, texture->get_size().height);
+ if (mirror_x % 2 == 1) {
+ q.x = texture->get_size().width - q.x - 1;
+ }
+ if (mirror_y % 2 == 1) {
+ q.y = texture->get_size().height - q.y - 1;
+ }
+ } else {
+ q.x = MIN(q.x, texture->get_size().width - 1);
+ q.y = MIN(q.y, texture->get_size().height - 1);
+ }
image->lock();
const Color c = image->get_pixel((int)q.x, (int)q.y);
image->unlock();
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index f8a5c7f400..dab0e573d7 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -85,9 +85,7 @@ void Spatial::_notify_dirty() {
}
void Spatial::_update_local_transform() const {
- data.local_transform.basis = Basis();
- data.local_transform.basis.scale(data.scale);
- data.local_transform.basis.rotate(data.rotation);
+ data.local_transform.basis.set_euler_scale(data.rotation, data.scale);
data.dirty &= ~DIRTY_LOCAL;
}
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 63580bcae6..eca7caeaf0 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -590,9 +590,7 @@ void AnimationPlayer::_animation_update_transforms() {
Transform t;
t.origin = nc->loc_accum;
- t.basis.scale(nc->scale_accum);
- t.basis.rotate(nc->rot_accum.get_euler());
-
+ t.basis.set_quat_scale(nc->rot_accum, nc->scale_accum);
if (nc->skeleton && nc->bone_idx >= 0) {
nc->skeleton->set_bone_pose(nc->bone_idx, t);
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index e811b7a7b3..42fa20068b 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -900,8 +900,7 @@ void AnimationTreePlayer::_process_animation(float p_delta) {
t.scale.x += 1.0;
t.scale.y += 1.0;
t.scale.z += 1.0;
- xform.basis.scale(t.scale);
- xform.basis.rotate(t.rot.get_euler());
+ xform.basis.set_quat_scale(t.rot, t.scale);
if (t.bone_idx >= 0) {
if (t.skeleton)
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 31be18612f..6f34f3e49f 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -660,6 +660,11 @@ void ColorPickerButton::_color_changed(const Color &p_color) {
emit_signal("color_changed", p_color);
}
+void ColorPickerButton::_modal_closed() {
+
+ emit_signal("popup_closed");
+}
+
void ColorPickerButton::pressed() {
popup->set_position(get_global_position() - picker->get_combined_minimum_size());
@@ -722,8 +727,10 @@ void ColorPickerButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_edit_alpha", "show"), &ColorPickerButton::set_edit_alpha);
ClassDB::bind_method(D_METHOD("is_editing_alpha"), &ColorPickerButton::is_editing_alpha);
ClassDB::bind_method(D_METHOD("_color_changed"), &ColorPickerButton::_color_changed);
+ ClassDB::bind_method(D_METHOD("_modal_closed"), &ColorPickerButton::_modal_closed);
ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color")));
+ ADD_SIGNAL(MethodInfo("popup_closed"));
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_pick_color", "get_pick_color");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "edit_alpha"), "set_edit_alpha", "is_editing_alpha");
}
@@ -735,5 +742,7 @@ ColorPickerButton::ColorPickerButton() {
popup->add_child(picker);
picker->connect("color_changed", this, "_color_changed");
+ popup->connect("modal_closed", this, "_modal_closed");
+
add_child(popup);
}
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 40ded4fff5..7d1a554ada 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -120,6 +120,8 @@ class ColorPickerButton : public Button {
ColorPicker *picker;
void _color_changed(const Color &p_color);
+ void _modal_closed();
+
virtual void pressed();
protected:
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 09c6a3b32c..fe5f3b769c 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1505,15 +1505,15 @@ LineEdit::LineEdit() {
context_menu_enabled = true;
menu = memnew(PopupMenu);
add_child(menu);
- menu->add_item(TTR("Cut"), MENU_CUT, KEY_MASK_CMD | KEY_X);
- menu->add_item(TTR("Copy"), MENU_COPY, KEY_MASK_CMD | KEY_C);
- menu->add_item(TTR("Paste"), MENU_PASTE, KEY_MASK_CMD | KEY_V);
+ menu->add_item(RTR("Cut"), MENU_CUT, KEY_MASK_CMD | KEY_X);
+ menu->add_item(RTR("Copy"), MENU_COPY, KEY_MASK_CMD | KEY_C);
+ menu->add_item(RTR("Paste"), MENU_PASTE, KEY_MASK_CMD | KEY_V);
menu->add_separator();
- menu->add_item(TTR("Select All"), MENU_SELECT_ALL, KEY_MASK_CMD | KEY_A);
- menu->add_item(TTR("Clear"), MENU_CLEAR);
+ menu->add_item(RTR("Select All"), MENU_SELECT_ALL, KEY_MASK_CMD | KEY_A);
+ menu->add_item(RTR("Clear"), MENU_CLEAR);
menu->add_separator();
- menu->add_item(TTR("Undo"), MENU_UNDO, KEY_MASK_CMD | KEY_Z);
- menu->add_item(TTR("Redo"), MENU_REDO, KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_Z);
+ menu->add_item(RTR("Undo"), MENU_UNDO, KEY_MASK_CMD | KEY_Z);
+ menu->add_item(RTR("Redo"), MENU_REDO, KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_Z);
menu->connect("id_pressed", this, "menu_option");
expand_to_text_length = false;
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 068ea9d4f5..ff3cbbd591 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -5779,14 +5779,14 @@ TextEdit::TextEdit() {
context_menu_enabled = true;
menu = memnew(PopupMenu);
add_child(menu);
- menu->add_item(TTR("Cut"), MENU_CUT, KEY_MASK_CMD | KEY_X);
- menu->add_item(TTR("Copy"), MENU_COPY, KEY_MASK_CMD | KEY_C);
- menu->add_item(TTR("Paste"), MENU_PASTE, KEY_MASK_CMD | KEY_V);
+ menu->add_item(RTR("Cut"), MENU_CUT, KEY_MASK_CMD | KEY_X);
+ menu->add_item(RTR("Copy"), MENU_COPY, KEY_MASK_CMD | KEY_C);
+ menu->add_item(RTR("Paste"), MENU_PASTE, KEY_MASK_CMD | KEY_V);
menu->add_separator();
- menu->add_item(TTR("Select All"), MENU_SELECT_ALL, KEY_MASK_CMD | KEY_A);
- menu->add_item(TTR("Clear"), MENU_CLEAR);
+ menu->add_item(RTR("Select All"), MENU_SELECT_ALL, KEY_MASK_CMD | KEY_A);
+ menu->add_item(RTR("Clear"), MENU_CLEAR);
menu->add_separator();
- menu->add_item(TTR("Undo"), MENU_UNDO, KEY_MASK_CMD | KEY_Z);
+ menu->add_item(RTR("Undo"), MENU_UNDO, KEY_MASK_CMD | KEY_Z);
menu->connect("id_pressed", this, "menu_option");
}
diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp
index 2ab52d13b8..a4053ad415 100644
--- a/servers/visual/shader_types.cpp
+++ b/servers/visual/shader_types.cpp
@@ -207,7 +207,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].built_ins["SCREEN_TEXTURE"] = constt(ShaderLanguage::TYPE_SAMPLER2D);
shader_modes[VS::SHADER_CANVAS_ITEM].functions["fragment"].can_discard = true;
- shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["POSITION"] = constt(ShaderLanguage::TYPE_VEC2);
+ shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["FRAGCOORD"] = constt(ShaderLanguage::TYPE_VEC4);
shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["NORMAL"] = constt(ShaderLanguage::TYPE_VEC3);
shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["UV"] = constt(ShaderLanguage::TYPE_VEC2);
shader_modes[VS::SHADER_CANVAS_ITEM].functions["light"].built_ins["COLOR"] = constt(ShaderLanguage::TYPE_VEC4);