diff options
26 files changed, 230 insertions, 73 deletions
@@ -35,7 +35,7 @@ Official binaries for the Godot editor and the export templates can be found #### Compiling from source -[See the official docs](http://docs.godotengine.org/en/latest/reference/_compiling.html) +[See the official docs](http://docs.godotengine.org/en/latest/development/compiling/) for compilation instructions for every supported platform. ### Community @@ -52,7 +52,7 @@ on Freenode. The official documentation is hosted on [ReadTheDocs](http://docs.godotengine.org). It is maintained by the Godot community in its own [GitHub repository](https://github.com/godotengine/godot-docs). -The [class reference](http://docs.godotengine.org/en/latest/classes/_classes.html) +The [class reference](http://docs.godotengine.org/en/latest/classes/) is also accessible from within the engine. The official demos are maintained in their own [GitHub repository](https://github.com/godotengine/godot-demo-projects) diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index 8f942c423f..77cff6a052 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -61,6 +61,10 @@ Vector2 Vector2::normalized() const { return v; } +bool Vector2::is_normalized() const { + return Math::isequal_approx(length(), (real_t)1.0); +} + real_t Vector2::distance_to(const Vector2 &p_vector2) const { return Math::sqrt((x - p_vector2.x) * (x - p_vector2.x) + (y - p_vector2.y) * (y - p_vector2.y)); @@ -274,13 +278,23 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c */ } -Vector2 Vector2::slide(const Vector2 &p_vec) const { +// slide returns the component of the vector along the given plane, specified by its normal vector. +Vector2 Vector2::slide(const Vector2 &p_n) const { +#ifdef DEBUG_ENABLED + ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector2()); +#endif + return *this - p_n * this->dot(p_n); +} - return p_vec - *this * this->dot(p_vec); +Vector2 Vector2::bounce(const Vector2 &p_n) const { + return -reflect(p_n); } -Vector2 Vector2::reflect(const Vector2 &p_vec) const { - return p_vec - *this * this->dot(p_vec) * 2.0; +Vector2 Vector2::reflect(const Vector2 &p_n) const { +#ifdef DEBUG_ENABLED + ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector2()); +#endif + return 2.0 * p_n * this->dot(p_n) - *this; } bool Rect2::intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_pos, Point2 *r_normal) const { diff --git a/core/math/math_2d.h b/core/math/math_2d.h index af6437d7f1..50ebcb845f 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -82,6 +82,7 @@ struct Vector2 { void normalize(); Vector2 normalized() const; + bool is_normalized() const; real_t length() const; real_t length_squared() const; @@ -106,6 +107,7 @@ struct Vector2 { Vector2 cubic_interpolate_soft(const Vector2 &p_b, const Vector2 &p_pre_a, const Vector2 &p_post_b, real_t p_t) const; Vector2 slide(const Vector2 &p_vec) const; + Vector2 bounce(const Vector2 &p_vec) const; Vector2 reflect(const Vector2 &p_vec) const; Vector2 operator+(const Vector2 &p_v) const; diff --git a/core/math/vector3.h b/core/math/vector3.h index 951380e898..8550ae7009 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -107,6 +107,7 @@ struct Vector3 { _FORCE_INLINE_ real_t angle_to(const Vector3 &p_b) const; _FORCE_INLINE_ Vector3 slide(const Vector3 &p_vec) const; + _FORCE_INLINE_ Vector3 bounce(const Vector3 &p_vec) const; _FORCE_INLINE_ Vector3 reflect(const Vector3 &p_vec) const; /* Operators */ @@ -400,14 +401,23 @@ void Vector3::zero() { x = y = z = 0; } -Vector3 Vector3::slide(const Vector3 &p_vec) const { - - return p_vec - *this * this->dot(p_vec); +// slide returns the component of the vector along the given plane, specified by its normal vector. +Vector3 Vector3::slide(const Vector3 &p_n) const { +#ifdef DEBUG_ENABLED + ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector3()); +#endif + return *this - p_n * this->dot(p_n); } -Vector3 Vector3::reflect(const Vector3 &p_vec) const { +Vector3 Vector3::bounce(const Vector3 &p_n) const { + return -reflect(p_n); +} - return p_vec - *this * this->dot(p_vec) * 2.0; +Vector3 Vector3::reflect(const Vector3 &p_n) const { +#ifdef DEBUG_ENABLED + ERR_FAIL_COND_V(p_n.is_normalized() == false, Vector3()); +#endif + return 2.0 * p_n * this->dot(p_n) - *this; } #endif diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 758500a873..9c435ea0e5 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -340,6 +340,7 @@ struct _VariantCall { VCALL_LOCALMEM0R(Vector2, aspect); VCALL_LOCALMEM1R(Vector2, dot); VCALL_LOCALMEM1R(Vector2, slide); + VCALL_LOCALMEM1R(Vector2, bounce); VCALL_LOCALMEM1R(Vector2, reflect); VCALL_LOCALMEM0R(Vector2, angle); //VCALL_LOCALMEM1R(Vector2,cross); @@ -377,6 +378,7 @@ struct _VariantCall { VCALL_LOCALMEM1R(Vector3, distance_squared_to); VCALL_LOCALMEM1R(Vector3, angle_to); VCALL_LOCALMEM1R(Vector3, slide); + VCALL_LOCALMEM1R(Vector3, bounce); VCALL_LOCALMEM1R(Vector3, reflect); VCALL_LOCALMEM0R(Plane, normalized); @@ -1438,8 +1440,9 @@ void register_variant_methods() { ADDFUNC1(VECTOR2, VECTOR2, Vector2, snapped, VECTOR2, "by", varray()); ADDFUNC0(VECTOR2, REAL, Vector2, aspect, varray()); ADDFUNC1(VECTOR2, REAL, Vector2, dot, VECTOR2, "with", varray()); - ADDFUNC1(VECTOR2, VECTOR2, Vector2, slide, VECTOR2, "vec", varray()); - ADDFUNC1(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "vec", varray()); + ADDFUNC1(VECTOR2, VECTOR2, Vector2, slide, VECTOR2, "n", varray()); + ADDFUNC1(VECTOR2, VECTOR2, Vector2, bounce, VECTOR2, "n", varray()); + ADDFUNC1(VECTOR2, VECTOR2, Vector2, reflect, VECTOR2, "n", varray()); //ADDFUNC1(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray()); ADDFUNC0(VECTOR2, VECTOR2, Vector2, abs, varray()); ADDFUNC1(VECTOR2, VECTOR2, Vector2, clamped, REAL, "length", varray()); @@ -1475,8 +1478,9 @@ void register_variant_methods() { ADDFUNC1(VECTOR3, REAL, Vector3, distance_to, VECTOR3, "b", varray()); ADDFUNC1(VECTOR3, REAL, Vector3, distance_squared_to, VECTOR3, "b", varray()); ADDFUNC1(VECTOR3, REAL, Vector3, angle_to, VECTOR3, "to", varray()); - ADDFUNC1(VECTOR3, VECTOR3, Vector3, slide, VECTOR3, "by", varray()); - ADDFUNC1(VECTOR3, VECTOR3, Vector3, reflect, VECTOR3, "by", varray()); + ADDFUNC1(VECTOR3, VECTOR3, Vector3, slide, VECTOR3, "n", varray()); + ADDFUNC1(VECTOR3, VECTOR3, Vector3, bounce, VECTOR3, "n", varray()); + ADDFUNC1(VECTOR3, VECTOR3, Vector3, reflect, VECTOR3, "n", varray()); ADDFUNC0(PLANE, PLANE, Plane, normalized, varray()); ADDFUNC0(PLANE, VECTOR3, Plane, center, varray()); diff --git a/doc/base/classes.xml b/doc/base/classes.xml index f3d73deaf0..5bb85aedc1 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -21836,6 +21836,8 @@ </argument> <argument index="3" name="max_bounces" type="int" default="4"> </argument> + <argument index="4" name="floor_max_angle" type="float" default="0.785398"> + </argument> <description> </description> </method> @@ -21846,6 +21848,7 @@ </argument> <description> Move the body to the given position. This is not a teleport, and the body will stop if there is an obstacle. The returned vector is how much movement was remaining before being stopped. + [code]floor_max_angle[/code] is in radians (default is pi/4), and filters which obstacles should be considered as floors/cellings instead of walls. </description> </method> <method name="revert_motion"> @@ -46992,6 +46995,15 @@ do_property]. Returns the ratio of X to Y. </description> </method> + <method name="bounce"> + <return type="Vector2"> + </return> + <argument index="0" name="n" type="Vector2"> + </argument> + <description> + Bounce returns the vector "bounced off" from the given plane, specified by its normal vector. + </description> + </method> <method name="clamped"> <return type="Vector2"> </return> @@ -47084,10 +47096,10 @@ do_property]. <method name="reflect"> <return type="Vector2"> </return> - <argument index="0" name="vec" type="Vector2"> + <argument index="0" name="n" type="Vector2"> </argument> <description> - Like "slide", but reflects the Vector instead of continuing along the wall. + Reflects the vector along the given plane, specified by its normal vector. </description> </method> <method name="rotated"> @@ -47102,10 +47114,10 @@ do_property]. <method name="slide"> <return type="Vector2"> </return> - <argument index="0" name="vec" type="Vector2"> + <argument index="0" name="n" type="Vector2"> </argument> <description> - Slides the vector by the other vector. + Slide returns the component of the vector along the given plane, specified by its normal vector. </description> </method> <method name="snapped"> @@ -47178,6 +47190,15 @@ do_property]. <description> </description> </method> + <method name="bounce"> + <return type="Vector3"> + </return> + <argument index="0" name="n" type="Vector3"> + </argument> + <description> + Bounce returns the vector "bounced off" from the given plane, specified by its normal vector. + </description> + </method> <method name="ceil"> <return type="Vector3"> </return> @@ -47308,10 +47329,10 @@ do_property]. <method name="reflect"> <return type="Vector3"> </return> - <argument index="0" name="by" type="Vector3"> + <argument index="0" name="n" type="Vector3"> </argument> <description> - Like "slide", but reflects the Vector instead of continuing along the wall. + Reflects the vector along the given plane, specified by its normal vector. </description> </method> <method name="rotated"> @@ -47328,10 +47349,10 @@ do_property]. <method name="slide"> <return type="Vector3"> </return> - <argument index="0" name="by" type="Vector3"> + <argument index="0" name="n" type="Vector3"> </argument> <description> - Slides the vector along a wall. + Slide returns the component of the vector along the given plane, specified by its normal vector. </description> </method> <method name="snapped"> diff --git a/doc/tools/doc_status.py b/doc/tools/doc_status.py index 78f39fc7ec..1386e91ce1 100755 --- a/doc/tools/doc_status.py +++ b/doc/tools/doc_status.py @@ -206,7 +206,7 @@ class ClassStatus: output['overall'] = (description_progress + items_progress).to_colored_string('{percent}%', '{pad_percent}{s}') if self.name.startswith('Total'): - output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/_classes.html') + output['url'] = color('url', 'http://docs.godotengine.org/en/latest/classes/') if flags['s']: output['comment'] = color('part_good', 'ALL OK') else: diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 6e0674d060..ea765e8f8a 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -453,7 +453,7 @@ Error OS_Unix::close_dynamic_library(void *p_library_handle) { } Error OS_Unix::get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle) { - char *error; + const char *error; dlerror(); // Clear existing errors p_symbol_handle = dlsym(p_library_handle, p_name.utf8().get_data()); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index fe1f984f39..3e0a2c712a 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1101,7 +1101,7 @@ void FileSystemDock::_dir_rmb_pressed(const Vector2 &p_pos) { folder_options->add_item(TTR("Expand all"), FOLDER_EXPAND_ALL); folder_options->add_item(TTR("Collapse all"), FOLDER_COLLAPSE_ALL); - folder_options->set_pos(files->get_global_pos() + p_pos); + folder_options->set_pos(tree->get_global_pos() + p_pos); folder_options->popup(); } diff --git a/modules/dlscript/api_generator.cpp b/modules/dlscript/api_generator.cpp index 2c2497b5b1..c8e38ca9a3 100644 --- a/modules/dlscript/api_generator.cpp +++ b/modules/dlscript/api_generator.cpp @@ -1,5 +1,7 @@ #include "api_generator.h" +#ifdef TOOLS_ENABLED + #include "class_db.h" #include "core/global_config.h" #include "os/file_access.h" @@ -228,8 +230,8 @@ List<ClassAPI> generate_c_api_classes() { method_api.has_varargs = method_bind && method_bind->is_vararg(); // Method flags - if (method_bind && method_bind->get_hint_flags()) { - const uint32_t flags = method_bind->get_hint_flags(); + if (method_info.flags) { + const uint32_t flags = method_info.flags; method_api.is_editor = flags & METHOD_FLAG_EDITOR; method_api.is_noscript = flags & METHOD_FLAG_NOSCRIPT; method_api.is_const = flags & METHOD_FLAG_CONST; @@ -238,6 +240,8 @@ List<ClassAPI> generate_c_api_classes() { method_api.is_from_script = flags & METHOD_FLAG_FROM_SCRIPT; } + method_api.is_virtual = method_api.is_virtual || method_api.method_name[0] == '_'; + // method argument name and type for (int i = 0; i < method_api.argument_count; i++) { @@ -344,6 +348,7 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { source.push_back(String("\t\t\t\t\"is_const\": ") + (e->get().is_const ? "true" : "false") + ",\n"); source.push_back(String("\t\t\t\t\"is_reverse\": ") + (e->get().is_reverse ? "true" : "false") + ",\n"); source.push_back(String("\t\t\t\t\"is_virtual\": ") + (e->get().is_virtual ? "true" : "false") + ",\n"); + source.push_back(String("\t\t\t\t\"has_varargs\": ") + (e->get().has_varargs ? "true" : "false") + ",\n"); source.push_back(String("\t\t\t\t\"is_from_script\": ") + (e->get().is_from_script ? "true" : "false") + ",\n"); source.push_back("\t\t\t\t\"arguments\": [\n"); for (int i = 0; i < e->get().argument_names.size(); i++) { @@ -368,15 +373,22 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { // +#endif + /* * Saves the whole Godot API to a JSON file located at * p_path */ Error generate_c_api(const String &p_path) { +#ifndef TOOLS_ENABLED + return ERR_BUG; +#else + List<ClassAPI> api = generate_c_api_classes(); List<String> json_source = generate_c_api_json(api); return save_file(p_path, json_source); +#endif } diff --git a/modules/dlscript/dl_script.cpp b/modules/dlscript/dl_script.cpp index 9917018891..449d7b4b17 100644 --- a/modules/dlscript/dl_script.cpp +++ b/modules/dlscript/dl_script.cpp @@ -176,36 +176,84 @@ Error DLScript::reload(bool p_keep_state) { bool DLScript::has_method(const StringName &p_method) const { if (!script_data) return false; - return script_data->methods.has(p_method); + DLScriptData *data = script_data; + + while (data) { + if (data->methods.has(p_method)) + return true; + + data = data->base_data; + } + + return false; } MethodInfo DLScript::get_method_info(const StringName &p_method) const { if (!script_data) return MethodInfo(); + DLScriptData *data = script_data; + + while (data) { + if (data->methods.has(p_method)) + return data->methods[p_method].info; + + data = data->base_data; + } + ERR_FAIL_COND_V(!script_data->methods.has(p_method), MethodInfo()); - return script_data->methods[p_method].info; + return MethodInfo(); } void DLScript::get_script_method_list(List<MethodInfo> *p_list) const { if (!script_data) return; - for (Map<StringName, DLScriptData::Method>::Element *E = script_data->methods.front(); E; E = E->next()) { - p_list->push_back(E->get().info); + + Set<MethodInfo> methods; + DLScriptData *data = script_data; + + while (data) { + for (Map<StringName, DLScriptData::Method>::Element *E = data->methods.front(); E; E = E->next()) { + methods.insert(E->get().info); + } + data = data->base_data; + } + + for (Set<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { + p_list->push_back(E->get()); } } void DLScript::get_script_property_list(List<PropertyInfo> *p_list) const { if (!script_data) return; - for (Map<StringName, DLScriptData::Property>::Element *E = script_data->properties.front(); E; E = E->next()) { - p_list->push_back(E->get().info); + + Set<PropertyInfo> properties; + DLScriptData *data = script_data; + + while (data) { + for (Map<StringName, DLScriptData::Property>::Element *E = data->properties.front(); E; E = E->next()) { + properties.insert(E->get().info); + } + data = data->base_data; + } + + for (Set<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + p_list->push_back(E->get()); } } bool DLScript::get_property_default_value(const StringName &p_property, Variant &r_value) const { if (!script_data) return false; - if (script_data->properties.has(p_property)) { - r_value = script_data->properties[p_property].default_value; - return true; + + DLScriptData *data = script_data; + + while (data) { + if (data->properties.has(p_property)) { + r_value = data->properties[p_property].default_value; + return true; + } + + data = data->base_data; } + return false; } @@ -225,14 +273,38 @@ ScriptLanguage *DLScript::get_language() const { bool DLScript::has_script_signal(const StringName &p_signal) const { if (!script_data) return false; - return script_data->signals_.has(p_signal); + + DLScriptData *data = script_data; + + while (data) { + if (data->signals_.has(p_signal)) { + return true; + } + + data = data->base_data; + } + + return false; } void DLScript::get_script_signal_list(List<MethodInfo> *r_signals) const { if (!script_data) return; - for (Map<StringName, DLScriptData::Signal>::Element *S = script_data->signals_.front(); S; S = S->next()) { - r_signals->push_back(S->get().signal); + + Set<MethodInfo> signals_; + DLScriptData *data = script_data; + + while (data) { + + for (Map<StringName, DLScriptData::Signal>::Element *S = data->signals_.front(); S; S = S->next()) { + signals_.insert(S->get().signal); + } + + data = data->base_data; + } + + for (Set<MethodInfo>::Element *E = signals_.front(); E; E = E->next()) { + r_signals->push_back(E->get()); } } diff --git a/modules/dlscript/dl_script.h b/modules/dlscript/dl_script.h index 18af85382a..497208c832 100644 --- a/modules/dlscript/dl_script.h +++ b/modules/dlscript/dl_script.h @@ -241,6 +241,8 @@ class DLInstance : public ScriptInstance { public: _FORCE_INLINE_ Object *get_owner() { return owner; } + _FORCE_INLINE_ void *get_userdata() { return userdata; } + virtual bool set(const StringName &p_name, const Variant &p_value); virtual bool get(const StringName &p_name, Variant &r_ret) const; virtual void get_property_list(List<PropertyInfo> *p_properties) const; diff --git a/modules/dlscript/godot.cpp b/modules/dlscript/godot.cpp index e987e8cf18..9a488ad612 100644 --- a/modules/dlscript/godot.cpp +++ b/modules/dlscript/godot.cpp @@ -28,16 +28,11 @@ /*************************************************************************/ #include "godot.h" -#include <cassert> -#include <cstdlib> - #include "class_db.h" #include "dl_script.h" #include "global_config.h" #include "variant.h" -#include <memory.h> - #ifdef __cplusplus extern "C" { #endif @@ -175,6 +170,16 @@ void GDAPI godot_script_register_signal(const char *p_name, const godot_signal * library->_register_script_signal(p_name, p_signal); } +void GDAPI *godot_dlinstance_get_userdata(godot_object *p_instance) { + Object *instance = (Object *)p_instance; + if (!instance) + return NULL; + if (instance->get_script_instance() && instance->get_script_instance()->get_language() == DLScriptLanguage::get_singleton()) { + return ((DLInstance *)instance->get_script_instance())->get_userdata(); + } + return NULL; +} + // System functions void GDAPI *godot_alloc(int p_bytes) { return memalloc(p_bytes); diff --git a/modules/dlscript/godot.h b/modules/dlscript/godot.h index 0c28c1fd2c..75f1f47ed1 100644 --- a/modules/dlscript/godot.h +++ b/modules/dlscript/godot.h @@ -121,8 +121,6 @@ typedef int godot_int; typedef float godot_real; -typedef double godot_real64; // for Variant in 3.0 - /////// Object (forward declared) typedef void godot_object; @@ -375,6 +373,8 @@ typedef struct godot_signal { void GDAPI godot_script_register_signal(const char *p_name, const godot_signal *p_signal); +void GDAPI *godot_dlinstance_get_userdata(godot_object *p_instance); + ////// System Functions //using these will help Godot track how much memory is in use in debug mode diff --git a/modules/dlscript/godot/godot_node_path.cpp b/modules/dlscript/godot/godot_node_path.cpp index cc0652c75b..8b79175e44 100644 --- a/modules/dlscript/godot/godot_node_path.cpp +++ b/modules/dlscript/godot/godot_node_path.cpp @@ -2,8 +2,6 @@ #include "path_db.h" -#include <memory.h> // why is there no <cmemory> btw? - #ifdef __cplusplus extern "C" { #endif @@ -22,6 +20,12 @@ void GDAPI godot_node_path_new(godot_node_path *p_np, const godot_string *p_from memnew_placement_custom(np, NodePath, NodePath(*from)); } +void GDAPI godot_node_path_copy(godot_node_path *p_np, const godot_node_path *p_from) { + NodePath *np = (NodePath *)p_np; + NodePath *from = (NodePath *)p_from; + *np = *from; +} + godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_np, const godot_int p_idx) { const NodePath *np = (const NodePath *)p_np; godot_string str; diff --git a/modules/dlscript/godot/godot_node_path.h b/modules/dlscript/godot/godot_node_path.h index b322e55d83..04f1e70c1d 100644 --- a/modules/dlscript/godot/godot_node_path.h +++ b/modules/dlscript/godot/godot_node_path.h @@ -16,6 +16,7 @@ typedef struct godot_node_path { #include "../godot.h" void GDAPI godot_node_path_new(godot_node_path *p_np, const godot_string *p_from); +void GDAPI godot_node_path_copy(godot_node_path *p_np, const godot_node_path *p_from); godot_string GDAPI godot_node_path_get_name(const godot_node_path *p_np, const godot_int p_idx); godot_int GDAPI godot_node_path_get_name_count(const godot_node_path *p_np); diff --git a/modules/dlscript/godot/godot_quat.cpp b/modules/dlscript/godot/godot_quat.cpp index 5571614e07..9bd2eb0639 100644 --- a/modules/dlscript/godot/godot_quat.cpp +++ b/modules/dlscript/godot/godot_quat.cpp @@ -2,8 +2,6 @@ #include "math/quat.h" -#include <memory.h> // why is there no <cmemory> btw? - #ifdef __cplusplus extern "C" { #endif diff --git a/modules/dlscript/godot/godot_string.cpp b/modules/dlscript/godot/godot_string.cpp index 1501743e02..97d0985a50 100644 --- a/modules/dlscript/godot/godot_string.cpp +++ b/modules/dlscript/godot/godot_string.cpp @@ -3,7 +3,7 @@ #include "string_db.h" #include "ustring.h" -#include <memory.h> // why is there no <cmemory> btw? +#include <string.h> #ifdef __cplusplus extern "C" { diff --git a/modules/dlscript/godot/godot_transform.cpp b/modules/dlscript/godot/godot_transform.cpp index 18d218e6c4..c8da519f6b 100644 --- a/modules/dlscript/godot/godot_transform.cpp +++ b/modules/dlscript/godot/godot_transform.cpp @@ -2,8 +2,6 @@ #include "math/transform.h" -#include <memory.h> // why is there no <cmemory> btw? - #ifdef __cplusplus extern "C" { #endif diff --git a/modules/dlscript/godot/godot_variant.cpp b/modules/dlscript/godot/godot_variant.cpp index e7c47ff9ff..3681f89753 100644 --- a/modules/dlscript/godot/godot_variant.cpp +++ b/modules/dlscript/godot/godot_variant.cpp @@ -34,7 +34,12 @@ void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b) { memnew_placement_custom(v, Variant, Variant(p_b)); } -void GDAPI godot_variant_new_int(godot_variant *p_v, const uint64_t p_i) { +void GDAPI godot_variant_new_uint(godot_variant *p_v, const uint64_t p_i) { + Variant *v = (Variant *)p_v; + memnew_placement_custom(v, Variant, Variant(p_i)); +} + +void GDAPI godot_variant_new_int(godot_variant *p_v, const int64_t p_i) { Variant *v = (Variant *)p_v; memnew_placement_custom(v, Variant, Variant(p_i)); } @@ -199,14 +204,19 @@ godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_v) { return v->operator bool(); } -uint64_t GDAPI godot_variant_as_int(const godot_variant *p_v) { +uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_v) { + const Variant *v = (const Variant *)p_v; + return v->operator uint64_t(); +} + +int64_t GDAPI godot_variant_as_int(const godot_variant *p_v) { const Variant *v = (const Variant *)p_v; - return v->operator godot_int(); + return v->operator int64_t(); } -godot_real GDAPI godot_variant_as_real(const godot_variant *p_v) { +double GDAPI godot_variant_as_real(const godot_variant *p_v) { const Variant *v = (const Variant *)p_v; - return v->operator godot_real(); + return v->operator double(); } godot_string GDAPI godot_variant_as_string(const godot_variant *p_v) { diff --git a/modules/dlscript/godot/godot_variant.h b/modules/dlscript/godot/godot_variant.h index 0b91af863d..1ff5ba4a57 100644 --- a/modules/dlscript/godot/godot_variant.h +++ b/modules/dlscript/godot/godot_variant.h @@ -71,7 +71,8 @@ void GDAPI godot_variant_copy(godot_variant *p_dest, const godot_variant *p_src) void GDAPI godot_variant_new_nil(godot_variant *p_v); void GDAPI godot_variant_new_bool(godot_variant *p_v, const godot_bool p_b); -void GDAPI godot_variant_new_int(godot_variant *p_v, const uint64_t p_i); +void GDAPI godot_variant_new_uint(godot_variant *p_v, const uint64_t p_i); +void GDAPI godot_variant_new_int(godot_variant *p_v, const int64_t p_i); void GDAPI godot_variant_new_real(godot_variant *p_v, const double p_r); void GDAPI godot_variant_new_string(godot_variant *p_v, const godot_string *p_s); void GDAPI godot_variant_new_vector2(godot_variant *p_v, const godot_vector2 *p_v2); @@ -100,8 +101,9 @@ void GDAPI godot_variant_new_pool_vector3_array(godot_variant *p_v, const godot_ void GDAPI godot_variant_new_pool_color_array(godot_variant *p_v, const godot_pool_color_array *p_pca); godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_v); -uint64_t GDAPI godot_variant_as_int(const godot_variant *p_v); -godot_real GDAPI godot_variant_as_real(const godot_variant *p_v); +uint64_t GDAPI godot_variant_as_uint(const godot_variant *p_v); +int64_t GDAPI godot_variant_as_int(const godot_variant *p_v); +double GDAPI godot_variant_as_real(const godot_variant *p_v); godot_string GDAPI godot_variant_as_string(const godot_variant *p_v); godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_v); godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_v); diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 1540bb51f8..4c2965c8ec 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -2420,7 +2420,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { p_block->sub_blocks.push_back(cf_if->body); if (!_enter_indent_block(cf_if->body)) { - _set_error("Expected intended block after 'if'"); + _set_error("Expected indented block after 'if'"); p_block->end_line = tokenizer->get_token_line(); return; } diff --git a/platform/android/detect.py b/platform/android/detect.py index 0e78a4618d..8d2ed59f17 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -175,6 +175,8 @@ def configure(env): if env['android_arch'] == 'x86': can_vectorize = True target_opts = ['-target', 'i686-none-linux-android'] + # The NDK adds this if targeting API < 21, so we can drop it when Godot targets it at least + env.Append(CPPFLAGS=['-mstackrealign']) elif env["android_arch"] == "armv6": can_vectorize = False target_opts = ['-target', 'armv6-none-linux-androideabi'] diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 88845a7290..00187f28bc 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -1168,7 +1168,7 @@ Vector2 KinematicBody2D::move(const Vector2 &p_motion) { #endif } -Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_floor_direction, float p_slope_stop_min_velocity, int p_max_bounces) { +Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_floor_direction, float p_slope_stop_min_velocity, int p_max_bounces, float p_floor_max_angle) { Vector2 motion = (move_and_slide_floor_velocity + p_linear_velocity) * get_fixed_process_delta_time(); Vector2 lv = p_linear_velocity; @@ -1189,7 +1189,7 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const //all is a wall move_and_slide_on_wall = true; } else { - if (get_collision_normal().dot(p_floor_direction) > Math::cos(Math::deg2rad((float)45))) { //floor + if (get_collision_normal().dot(p_floor_direction) >= Math::cos(p_floor_max_angle)) { //floor move_and_slide_on_floor = true; move_and_slide_floor_velocity = get_collider_velocity(); @@ -1198,15 +1198,16 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const revert_motion(); return Vector2(); } - } else if (get_collision_normal().dot(p_floor_direction) < Math::cos(Math::deg2rad((float)45))) { //ceiling + } else if (get_collision_normal().dot(-p_floor_direction) <= Math::cos(p_floor_max_angle)) { //ceiling move_and_slide_on_ceiling = true; } else { move_and_slide_on_wall = true; } } - motion = get_collision_normal().slide(motion); - lv = get_collision_normal().slide(lv); + Vector2 n = get_collision_normal(); + motion = motion.slide(n); + lv = lv.slide(n); Variant collider = _get_collider(); if (collider.get_type() != Variant::NIL) { move_and_slide_colliders.push_back(collider); @@ -1307,7 +1308,7 @@ void KinematicBody2D::_bind_methods() { ClassDB::bind_method(D_METHOD("move", "rel_vec"), &KinematicBody2D::move); ClassDB::bind_method(D_METHOD("move_to", "position"), &KinematicBody2D::move_to); - ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "slope_stop_min_velocity", "max_bounces"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(5), DEFVAL(4)); + ClassDB::bind_method(D_METHOD("move_and_slide", "linear_velocity", "floor_normal", "slope_stop_min_velocity", "max_bounces", "floor_max_angle"), &KinematicBody2D::move_and_slide, DEFVAL(Vector2(0, 0)), DEFVAL(5), DEFVAL(4), DEFVAL(Math::deg2rad((float)45))); ClassDB::bind_method(D_METHOD("test_move", "from", "rel_vec"), &KinematicBody2D::test_move); ClassDB::bind_method(D_METHOD("get_travel"), &KinematicBody2D::get_travel); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index e51b512302..6ce6f14d36 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -314,7 +314,7 @@ public: void set_collision_margin(float p_margin); float get_collision_margin() const; - Vector2 move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_floor_direction = Vector2(0, 0), float p_slope_stop_min_velocity = 5, int p_max_bounces = 4); + Vector2 move_and_slide(const Vector2 &p_linear_velocity, const Vector2 &p_floor_direction = Vector2(0, 0), float p_slope_stop_min_velocity = 5, int p_max_bounces = 4, float p_floor_max_angle = Math::deg2rad((float)45)); bool is_move_and_slide_on_floor() const; bool is_move_and_slide_on_wall() const; bool is_move_and_slide_on_ceiling() const; diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 7e3c5db5bc..aeb72a6d1e 100755 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -50,8 +50,7 @@ void Timer::_notification(int p_what) { if (time_left < 0) { if (!one_shot) - //time_left=wait_time+time_left; - time_left = wait_time; + time_left += wait_time; else stop(); @@ -66,7 +65,7 @@ void Timer::_notification(int p_what) { if (time_left < 0) { if (!one_shot) - time_left = wait_time + time_left; + time_left += wait_time; else stop(); emit_signal("timeout"); |