diff options
136 files changed, 1026 insertions, 660 deletions
diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 0173657e80..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,55 +0,0 @@ -image: Visual Studio 2019 - -platform: x64 - -environment: - HOME: "%HOMEDRIVE%%HOMEPATH%" - PYTHON: C:\Python38 - SCONS_CACHE_ROOT: "%HOME%\\scons_cache" - SCONS_CACHE_LIMIT: 1024 - OPTIONS: "debug_symbols=no verbose=yes progress=no" - EXTRA_ARGS: "warnings=all werror=yes" - matrix: - - GD_PLATFORM: windows - TARGET: release_debug - TOOLS: yes -# Disabled for performance reasons until master is more stable. -# - GD_PLATFORM: windows -# TARGET: release -# TOOLS: no - -matrix: - fast_finish: true - -init: - - ps: if ($env:APPVEYOR_REPO_BRANCH -ne "master") { $env:APPVEYOR_CACHE_SKIP_SAVE = "true" } - -cache: - - "%SCONS_CACHE_ROOT%" - -install: - - SET "PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - - pip install -U wheel # needed for pip install scons to work, otherwise a flag is missing - - pip install scons # use stable scons - - if defined VS call "%VS%" %ARCH% # if defined - so we can also use mingw - -before_build: - - echo %GD_PLATFORM% - - python --version - - scons --version - - set "SCONS_CACHE=%SCONS_CACHE_ROOT%\%APPVEYOR_REPO_BRANCH%" - -build_script: - - scons platform=%GD_PLATFORM% target=%TARGET% tools=%TOOLS% %OPTIONS% %EXTRA_ARGS% - -after_build: - - git rev-parse --short=9 HEAD > VERSION_HASH.txt - - set /P VERSION_HASH= < VERSION_HASH.txt - - cd bin - - mv godot.windows.opt.tools.64.exe godot_%APPVEYOR_REPO_BRANCH%-%VERSION_HASH%_win64.exe - - 7z a -mx9 godot_%APPVEYOR_REPO_BRANCH%-%VERSION_HASH%_win64.zip *.exe - -artifacts: - - path: bin/godot_${APPVEYOR_REPO_BRANCH}-${VERSION_HASH}_win64.zip - name: Win64 release_debug editor build - type: zip diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index da597a9706..77554ea0ef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -87,7 +87,7 @@ jobs: ${{runner.os}}-template ${{runner.os}} - # Use python 3.x release (works cross platform) + # Use python 3.x release (works cross platform) - name: Set up Python 3.x uses: actions/setup-python@v2 with: @@ -216,7 +216,13 @@ jobs: steps: - uses: actions/checkout@v2 - # install all packages (except scons) + # Azure repositories are not reliable, we need to prevent azure giving us packages. + - name: Make apt sources.list use the default Ubuntu repositories + run: | + sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo apt-get update + + # Install all packages (except scons) - name: Configure dependencies run: | sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \ @@ -267,7 +273,13 @@ jobs: steps: - uses: actions/checkout@v2 - # install all packages (except scons) + # Azure repositories are not reliable, we need to prevent azure giving us packages. + - name: Make apt sources.list use the default Ubuntu repositories + run: | + sudo cp -f misc/ci/sources.list /etc/apt/sources.list + sudo apt-get update + + # Install all packages (except scons) - name: Configure dependencies run: | sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \ @@ -287,7 +299,7 @@ jobs: ${{runner.os}}-template ${{runner.os}} - # Use python 3.x release (works cross platform) + # Use python 3.x release (works cross platform) - name: Set up Python 3.x uses: actions/setup-python@v2 with: diff --git a/.travis.yml b/.travis.yml index 9c085d4ce0..cb576efee7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,6 @@ env: - SCONS_CACHE=$HOME/.scons_cache/$TRAVIS_BRANCH - SCONS_CACHE_LIMIT=1024 - OPTIONS="debug_symbols=no verbose=yes progress=no" - - secure: "uch9QszCgsl1qVbuzY41P7S2hWL2IiNFV4SbAYRCdi0oJ9MIu+pVyrQdpf3+jG4rH6j4Rffl+sN17Zz4dIDDioFL1JwqyCqyCyswR8uACC0Rr8gr4Mi3+HIRbv+2s2P4cIQq41JM8FJe84k9jLEMGCGh69w+ibCWoWs74CokYVA=" cache: directories: @@ -19,32 +18,6 @@ cache: matrix: include: - - name: Linux editor (debug, GCC 9, with Mono) - stage: build - env: PLATFORM=linuxbsd TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc-9 MATRIX_EVAL="CC=gcc-9 && CXX=g++-9" EXTRA_ARGS="module_mono_enabled=yes mono_glue=no warnings=extra werror=yes" - os: linux - compiler: gcc-9 - addons: - apt: - sources: - - sourceline: "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" - key_url: "https://raw.githubusercontent.com/travis-ci/apt-source-safelist/master/keys/mono.asc" - - sourceline: "ppa:ubuntu-toolchain-r/test" - packages: - - &gcc9_deps [gcc-9, g++-9] - - &linux_deps [libasound2-dev, libgl1-mesa-dev, libglu1-mesa-dev, libx11-dev, libxcursor-dev, libxi-dev, libxinerama-dev, libxrandr-dev] - - &linux_mono_deps [mono-devel, msbuild, nuget] - - - name: Linux export template (release, Clang 7) - stage: build - env: PLATFORM=linuxbsd TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="warnings=extra werror=yes" - os: linux - compiler: clang - addons: - apt: - packages: - - *linux_deps - - name: Android export template (release_debug, Clang) stage: build env: PLATFORM=android TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-clang EXTRA_ARGS="warnings=extra werror=yes" @@ -55,18 +28,6 @@ matrix: packages: - openjdk-8-jdk - - name: macOS editor (debug, Clang) - stage: build - env: PLATFORM=osx TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-clang EXTRA_ARGS="warnings=extra werror=yes" - os: osx - osx_image: xcode11.5 - compiler: clang - addons: - homebrew: - packages: - - scons - update: true - # TODO: iOS MoltenVK support # - name: iOS export template (debug, Clang) @@ -80,16 +41,6 @@ matrix: # packages: # - scons - - name: Linux export template (release_debug, GCC 7, without 3D support) - stage: build - env: PLATFORM=linuxbsd TOOLS=no TARGET=release_debug CACHE_NAME=${PLATFORM}-gcc-7 EXTRA_ARGS="disable_3d=yes" - os: linux - compiler: gcc - addons: - apt: - packages: - - *linux_deps - - name: JavaScript export template (release, emscripten latest) stage: build env: PLATFORM=javascript TOOLS=no TARGET=release CACHE_NAME=${PLATFORM}-emcc-latest EXTRA_ARGS="use_closure_compiler=yes" @@ -113,12 +64,13 @@ install: export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64; export PATH=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin:${PATH}; java -version; - misc/travis/android-tools-linux.sh; + misc/ci/android-tools-linux.sh; fi - if [ "$PLATFORM" = "javascript" ]; then - git clone --depth 1 "https://github.com/emscripten-core/emsdk.git"; + git clone --depth 1 https://github.com/emscripten-core/emsdk; ./emsdk/emsdk install latest; - ./emsdk/emsdk activate --no-embedded latest; + ./emsdk/emsdk activate latest; + source ./emsdk/emsdk_env.sh; fi before_script: @@ -128,9 +80,4 @@ before_script: fi script: - - scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS && - if [ "$TEST_PROJECT" = "yes" ]; then - git clone --depth 1 "https://github.com/godotengine/godot-tests.git"; - sed -i "s:custom_template/release=\"\":custom_template/release=\"$(readlink -e bin/godot_server.linuxbsd.opt.tools.64)\":" godot-tests/tests/project_export/export_presets.cfg; - godot-tests/tests/project_export/test_project.sh "bin/godot_server.linuxbsd.opt.tools.64"; - fi + - scons -j2 CC=$CC CXX=$CXX platform=$PLATFORM tools=$TOOLS target=$TARGET $OPTIONS $EXTRA_ARGS @@ -67,6 +67,7 @@ such as text and video tutorials, demos, etc. Consult the [community channels](h for more info. [![Travis Build Status](https://travis-ci.org/godotengine/godot.svg?branch=master)](https://travis-ci.org/godotengine/godot) +[![Actions Build Status](https://github.com/godotengine/godot/workflows/Godot/badge.svg?branch=master)](https://github.com/godotengine/godot/actions) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/bfiihqq6byxsjxxh/branch/master?svg=true)](https://ci.appveyor.com/project/akien-mga/godot) [![Code Triagers Badge](https://www.codetriage.com/godotengine/godot/badges/users.svg)](https://www.codetriage.com/godotengine/godot) [![Translate on Weblate](https://hosted.weblate.org/widgets/godot-engine/-/godot/svg-badge.svg)](https://hosted.weblate.org/engage/godot-engine/?utm_source=widget) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 94da74cbda..2f8b11652b 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1690,7 +1690,7 @@ String _Directory::get_current_dir() { } Error _Directory::make_dir(String p_dir) { - ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use."); + ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory is not configured properly."); if (!p_dir.is_rel_path()) { DirAccess *d = DirAccess::create_for_path(p_dir); Error err = d->make_dir(p_dir); @@ -1701,7 +1701,7 @@ Error _Directory::make_dir(String p_dir) { } Error _Directory::make_dir_recursive(String p_dir) { - ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use."); + ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory is not configured properly."); if (!p_dir.is_rel_path()) { DirAccess *d = DirAccess::create_for_path(p_dir); Error err = d->make_dir_recursive(p_dir); diff --git a/core/class_db.cpp b/core/class_db.cpp index 05c9850c39..88f1df3457 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -548,6 +548,29 @@ void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherit } } +#ifdef DEBUG_METHODS_ENABLED +static MethodInfo info_from_bind(MethodBind *p_method) { + MethodInfo minfo; + minfo.name = p_method->get_name(); + minfo.id = p_method->get_method_id(); + + for (int i = 0; i < p_method->get_argument_count(); i++) { + minfo.arguments.push_back(p_method->get_argument_info(i)); + } + + minfo.return_val = p_method->get_return_info(); + minfo.flags = p_method->get_hint_flags(); + + for (int i = 0; i < p_method->get_argument_count(); i++) { + if (p_method->has_default_argument(i)) { + minfo.default_arguments.push_back(p_method->get_default_argument(i)); + } + } + + return minfo; +} +#endif + void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance, bool p_exclude_from_properties) { OBJTYPE_RLOCK; @@ -570,29 +593,12 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b } for (List<StringName>::Element *E = type->method_order.front(); E; E = E->next()) { - MethodBind *method = type->method_map.get(E->get()); - MethodInfo minfo; - minfo.name = E->get(); - minfo.id = method->get_method_id(); - - if (p_exclude_from_properties && type->methods_in_properties.has(minfo.name)) { + if (p_exclude_from_properties && type->methods_in_properties.has(E->get())) { continue; } - for (int i = 0; i < method->get_argument_count(); i++) { - //Variant::Type t=method->get_argument_type(i); - - minfo.arguments.push_back(method->get_argument_info(i)); - } - - minfo.return_val = method->get_return_info(); - minfo.flags = method->get_hint_flags(); - - for (int i = 0; i < method->get_argument_count(); i++) { - if (method->has_default_argument(i)) { - minfo.default_arguments.push_back(method->get_default_argument(i)); - } - } + MethodBind *method = type->method_map.get(E->get()); + MethodInfo minfo = info_from_bind(method); p_methods->push_back(minfo); } @@ -618,6 +624,57 @@ void ClassDB::get_method_list(StringName p_class, List<MethodInfo> *p_methods, b } } +bool ClassDB::get_method_info(StringName p_class, StringName p_method, MethodInfo *r_info, bool p_no_inheritance, bool p_exclude_from_properties) { + OBJTYPE_RLOCK; + + ClassInfo *type = classes.getptr(p_class); + + while (type) { + if (type->disabled) { + if (p_no_inheritance) { + break; + } + + type = type->inherits_ptr; + continue; + } + +#ifdef DEBUG_METHODS_ENABLED + MethodBind **method = type->method_map.getptr(p_method); + if (method && *method) { + if (r_info != nullptr) { + MethodInfo minfo = info_from_bind(*method); + *r_info = minfo; + } + return true; + } else if (type->virtual_methods_map.has(p_method)) { + if (r_info) { + *r_info = type->virtual_methods_map[p_method]; + } + return true; + } +#else + if (type->method_map.has(p_method)) { + if (r_info) { + MethodBind *m = type->method_map[p_method]; + MethodInfo mi; + mi.name = m->get_name(); + *r_info = mi; + } + return true; + } +#endif + + if (p_no_inheritance) { + break; + } + + type = type->inherits_ptr; + } + + return false; +} + MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) { OBJTYPE_RLOCK; @@ -718,6 +775,25 @@ int ClassDB::get_integer_constant(const StringName &p_class, const StringName &p return 0; } +bool ClassDB::has_integer_constant(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) { + OBJTYPE_RLOCK; + + ClassInfo *type = classes.getptr(p_class); + + while (type) { + if (type->constant_map.has(p_name)) { + return true; + } + if (p_no_inheritance) { + return false; + } + + type = type->inherits_ptr; + } + + return false; +} + StringName ClassDB::get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) { OBJTYPE_RLOCK; @@ -784,6 +860,25 @@ void ClassDB::get_enum_constants(const StringName &p_class, const StringName &p_ } } +bool ClassDB::has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance) { + OBJTYPE_RLOCK; + + ClassInfo *type = classes.getptr(p_class); + + while (type) { + if (type->enum_map.has(p_name)) { + return true; + } + if (p_no_inheritance) { + return false; + } + + type = type->inherits_ptr; + } + + return false; +} + void ClassDB::add_signal(StringName p_class, const MethodInfo &p_signal) { OBJTYPE_WLOCK; @@ -825,7 +920,7 @@ void ClassDB::get_signal_list(StringName p_class, List<MethodInfo> *p_signals, b } } -bool ClassDB::has_signal(StringName p_class, StringName p_signal) { +bool ClassDB::has_signal(StringName p_class, StringName p_signal, bool p_no_inheritance) { OBJTYPE_RLOCK; ClassInfo *type = classes.getptr(p_class); ClassInfo *check = type; @@ -833,6 +928,9 @@ bool ClassDB::has_signal(StringName p_class, StringName p_signal) { if (check->signal_map.has(p_signal)) { return true; } + if (p_no_inheritance) { + return false; + } check = check->inherits_ptr; } @@ -910,6 +1008,7 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons OBJTYPE_WLOCK type->property_list.push_back(p_pinfo); + type->property_map[p_pinfo.name] = p_pinfo; #ifdef DEBUG_METHODS_ENABLED if (mb_get) { type->methods_in_properties.insert(p_getter); @@ -959,6 +1058,30 @@ void ClassDB::get_property_list(StringName p_class, List<PropertyInfo> *p_list, } } +bool ClassDB::get_property_info(StringName p_class, StringName p_property, PropertyInfo *r_info, bool p_no_inheritance, const Object *p_validator) { + OBJTYPE_RLOCK; + + ClassInfo *check = classes.getptr(p_class); + while (check) { + if (check->property_map.has(p_property)) { + PropertyInfo pinfo = check->property_map[p_property]; + if (p_validator) { + p_validator->_validate_property(pinfo); + } + if (r_info) { + *r_info = pinfo; + } + return true; + } + if (p_no_inheritance) { + break; + } + check = check->inherits_ptr; + } + + return false; +} + bool ClassDB::set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid) { ClassInfo *type = classes.getptr(p_object->get_class_name()); ClassInfo *check = type; @@ -1239,6 +1362,7 @@ void ClassDB::add_virtual_method(const StringName &p_class, const MethodInfo &p_ mi.flags |= METHOD_FLAG_VIRTUAL; } classes[p_class].virtual_methods.push_back(mi); + classes[p_class].virtual_methods_map[p_method.name] = mi; #endif } diff --git a/core/class_db.h b/core/class_db.h index eae2a9afd4..86ac2aa001 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -120,11 +120,13 @@ public: HashMap<StringName, List<StringName>> enum_map; HashMap<StringName, MethodInfo> signal_map; List<PropertyInfo> property_list; + HashMap<StringName, PropertyInfo> property_map; #ifdef DEBUG_METHODS_ENABLED List<StringName> constant_order; List<StringName> method_order; Set<StringName> methods_in_properties; List<MethodInfo> virtual_methods; + Map<StringName, MethodInfo> virtual_methods_map; StringName category; #endif HashMap<StringName, PropertySetGet> property_setget; @@ -328,7 +330,7 @@ public: } static void add_signal(StringName p_class, const MethodInfo &p_signal); - static bool has_signal(StringName p_class, StringName p_signal); + static bool has_signal(StringName p_class, StringName p_signal, bool p_no_inheritance = false); static bool get_signal(StringName p_class, StringName p_signal, MethodInfo *r_signal); static void get_signal_list(StringName p_class, List<MethodInfo> *p_signals, bool p_no_inheritance = false); @@ -337,6 +339,7 @@ public: static void add_property(StringName p_class, const PropertyInfo &p_pinfo, const StringName &p_setter, const StringName &p_getter, int p_index = -1); static void set_property_default_value(StringName p_class, const StringName &p_name, const Variant &p_default); static void get_property_list(StringName p_class, List<PropertyInfo> *p_list, bool p_no_inheritance = false, const Object *p_validator = nullptr); + static bool get_property_info(StringName p_class, StringName p_property, PropertyInfo *r_info, bool p_no_inheritance = false, const Object *p_validator = nullptr); static bool set_property(Object *p_object, const StringName &p_property, const Variant &p_value, bool *r_valid = nullptr); static bool get_property(Object *p_object, const StringName &p_property, Variant &r_value); static bool has_property(const StringName &p_class, const StringName &p_property, bool p_no_inheritance = false); @@ -349,6 +352,7 @@ public: static void set_method_flags(StringName p_class, StringName p_method, int p_flags); static void get_method_list(StringName p_class, List<MethodInfo> *p_methods, bool p_no_inheritance = false, bool p_exclude_from_properties = false); + static bool get_method_info(StringName p_class, StringName p_method, MethodInfo *r_info, bool p_no_inheritance = false, bool p_exclude_from_properties = false); static MethodBind *get_method(StringName p_class, StringName p_name); static void add_virtual_method(const StringName &p_class, const MethodInfo &p_method, bool p_virtual = true); @@ -357,10 +361,12 @@ public: static void bind_integer_constant(const StringName &p_class, const StringName &p_enum, const StringName &p_name, int p_constant); static void get_integer_constant_list(const StringName &p_class, List<String> *p_constants, bool p_no_inheritance = false); static int get_integer_constant(const StringName &p_class, const StringName &p_name, bool *p_success = nullptr); + static bool has_integer_constant(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false); static StringName get_integer_constant_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false); static void get_enum_list(const StringName &p_class, List<StringName> *p_enums, bool p_no_inheritance = false); static void get_enum_constants(const StringName &p_class, const StringName &p_enum, List<StringName> *p_constants, bool p_no_inheritance = false); + static bool has_enum(const StringName &p_class, const StringName &p_name, bool p_no_inheritance = false); static Variant class_get_default_property_value(const StringName &p_class, const StringName &p_property, bool *r_valid = nullptr); diff --git a/core/container_type_validate.h b/core/container_type_validate.h index f2724e884d..8a361aa0ef 100644 --- a/core/container_type_validate.h +++ b/core/container_type_validate.h @@ -38,7 +38,7 @@ struct ContainerTypeValidate { Variant::Type type = Variant::NIL; StringName class_name; Ref<Script> script; - const char *where = "conatiner"; + const char *where = "container"; _FORCE_INLINE_ bool can_reference(const ContainerTypeValidate &p_type) const { if (type == p_type.type) { diff --git a/core/math/aabb.h b/core/math/aabb.h index 4106fbb93c..bd1f3a1a36 100644 --- a/core/math/aabb.h +++ b/core/math/aabb.h @@ -99,6 +99,10 @@ public: _FORCE_INLINE_ void project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const; _FORCE_INLINE_ void expand_to(const Vector3 &p_vector); /** expand to contain a point if necessary */ + _FORCE_INLINE_ AABB abs() const { + return AABB(Vector3(position.x + MIN(size.x, 0), position.y + MIN(size.y, 0), position.z + MIN(size.z, 0)), size.abs()); + } + operator String() const; _FORCE_INLINE_ AABB() {} diff --git a/core/math/geometry_3d.cpp b/core/math/geometry_3d.cpp index 7807ab19a7..2c19fe2085 100644 --- a/core/math/geometry_3d.cpp +++ b/core/math/geometry_3d.cpp @@ -648,7 +648,7 @@ Geometry3D::MeshData Geometry3D::build_convex_mesh(const Vector<Plane> &p_planes Vector<Vector3> vertices; - Vector3 center = p.get_any_point(); + Vector3 center = p.center(); // make a quad clockwise vertices.push_back(center - up * subplane_size + right * subplane_size); vertices.push_back(center - up * subplane_size - right * subplane_size); diff --git a/core/math/plane.cpp b/core/math/plane.cpp index df37ceb0e5..4200484c59 100644 --- a/core/math/plane.cpp +++ b/core/math/plane.cpp @@ -52,10 +52,6 @@ Plane Plane::normalized() const { return p; } -Vector3 Plane::get_any_point() const { - return get_normal() * d; -} - Vector3 Plane::get_any_perpendicular_normal() const { static const Vector3 p1 = Vector3(1, 0, 0); static const Vector3 p2 = Vector3(0, 1, 0); diff --git a/core/math/plane.h b/core/math/plane.h index 9a3e5a485f..70a6111edd 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -47,7 +47,6 @@ public: /* Plane-Point operations */ _FORCE_INLINE_ Vector3 center() const { return normal * d; } - Vector3 get_any_point() const; Vector3 get_any_perpendicular_normal() const; _FORCE_INLINE_ bool is_point_over(const Vector3 &p_point) const; ///< Point is over plane diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 0aa1339401..8afa24e63d 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -455,7 +455,6 @@ struct _VariantCall { VCALL_LOCALMEM0R(Plane, normalized); VCALL_LOCALMEM0R(Plane, center); - VCALL_LOCALMEM0R(Plane, get_any_point); VCALL_LOCALMEM1R(Plane, is_equal_approx); VCALL_LOCALMEM1R(Plane, is_point_over); VCALL_LOCALMEM1R(Plane, distance_to); @@ -843,6 +842,7 @@ struct _VariantCall { #define VCALL_PTR5R(m_type, m_method) \ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); } + VCALL_PTR0R(AABB, abs); VCALL_PTR0R(AABB, get_area); VCALL_PTR0R(AABB, has_no_area); VCALL_PTR0R(AABB, has_no_surface); @@ -1980,7 +1980,6 @@ void register_variant_methods() { ADDFUNC0R(PLANE, PLANE, Plane, normalized, varray()); ADDFUNC0R(PLANE, VECTOR3, Plane, center, varray()); - ADDFUNC0R(PLANE, VECTOR3, Plane, get_any_point, varray()); ADDFUNC1R(PLANE, BOOL, Plane, is_equal_approx, PLANE, "plane", varray()); ADDFUNC1R(PLANE, BOOL, Plane, is_point_over, VECTOR3, "point", varray()); ADDFUNC1R(PLANE, FLOAT, Plane, distance_to, VECTOR3, "point", varray()); @@ -2220,6 +2219,7 @@ void register_variant_methods() { //pointerbased + ADDFUNC0R(AABB, AABB, AABB, abs, varray()); ADDFUNC0R(AABB, FLOAT, AABB, get_area, varray()); ADDFUNC0R(AABB, BOOL, AABB, has_no_area, varray()); ADDFUNC0R(AABB, BOOL, AABB, has_no_surface, varray()); diff --git a/doc/classes/AABB.xml b/doc/classes/AABB.xml index 3f2f27d121..ae80abc5d2 100644 --- a/doc/classes/AABB.xml +++ b/doc/classes/AABB.xml @@ -18,7 +18,14 @@ <argument index="1" name="size" type="Vector3"> </argument> <description> - Optional constructor, accepts position and size. + Constructs an [AABB] from a position and size. + </description> + </method> + <method name="abs"> + <return type="AABB"> + </return> + <description> + Returns an AABB with equivalent position and size, modified so that the most-negative corner is the origin and the size is positive. </description> </method> <method name="encloses"> @@ -197,13 +204,14 @@ </methods> <members> <member name="end" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )"> - Ending corner. This is calculated as [code]position + size[/code]. Changing this property changes [member size] accordingly. + Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size. </member> <member name="position" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )"> - Beginning corner. + Beginning corner. Typically has values lower than [member end]. </member> <member name="size" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )"> - Size from position to end. + Size from [member position] to [member end]. Typically all components are positive. + If the size is negative, you can use [method abs] to fix it. </member> </members> <constants> diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml index 5e908b0e53..3812b45b13 100644 --- a/doc/classes/BaseButton.xml +++ b/doc/classes/BaseButton.xml @@ -13,7 +13,7 @@ <return type="void"> </return> <description> - Called when the button is pressed. + Called when the button is pressed. If you need to know the button's pressed state (and [member toggle_mode] is active), use [method _toggled] instead. </description> </method> <method name="_toggled" qualifiers="virtual"> @@ -89,6 +89,7 @@ <signal name="pressed"> <description> Emitted when the button is toggled or pressed. This is on [signal button_down] if [member action_mode] is [constant ACTION_MODE_BUTTON_PRESS] and on [signal button_up] otherwise. + If you need to know the button's pressed state (and [member toggle_mode] is active), use [signal toggled] instead. </description> </signal> <signal name="toggled"> diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml index 3952ea2d27..47433d7adc 100644 --- a/doc/classes/Basis.xml +++ b/doc/classes/Basis.xml @@ -4,10 +4,13 @@ 3×3 matrix datatype. </brief_description> <description> - 3×3 matrix used for 3D rotation and scale. Contains 3 vector fields X, Y and Z as its columns, which can be interpreted as the local basis vectors of a transformation. Can also be accessed as array of 3D vectors. These vectors are orthogonal to each other, but are not necessarily normalized (due to scaling). Almost always used as an orthogonal basis for a [Transform]. - For such use, it is composed of a scaling and a rotation matrix, in that order (M = R.S). + 3×3 matrix used for 3D rotation and scale. Almost always used as an orthogonal basis for a Transform. + Contains 3 vector fields X, Y and Z as its columns, which are typically interpreted as the local basis vectors of a transformation. For such use, it is composed of a scaling and a rotation matrix, in that order (M = R.S). + Can also be accessed as array of 3D vectors. These vectors are normally orthogonal to each other, but are not necessarily normalized (due to scaling). + For more information, read the "Matrices and transforms" documentation article. </description> <tutorials> + <link>https://docs.godotengine.org/en/latest/tutorials/math/matrices_and_transforms.html</link> <link>https://docs.godotengine.org/en/latest/tutorials/3d/using_transforms.html</link> </tutorials> <methods> @@ -17,7 +20,7 @@ <argument index="0" name="from" type="Quat"> </argument> <description> - Create a rotation matrix from the given quaternion. + Constructs a pure rotation basis matrix from the given quaternion. </description> </method> <method name="Basis"> @@ -26,7 +29,8 @@ <argument index="0" name="from" type="Vector3"> </argument> <description> - Create a rotation matrix (in the YXZ convention: first Z, then X, and Y last) from the specified Euler angles, given in the vector format as (X angle, Y angle, Z angle). + Constructs a pure rotation basis matrix from the given Euler angles (in the YXZ convention: when *composing*, first Y, then X, and Z last), given in the vector format as (X angle, Y angle, Z angle). + Consider using the [Quat] constructor instead, which uses a quaternion instead of Euler angles. </description> </method> <method name="Basis"> @@ -37,7 +41,7 @@ <argument index="1" name="phi" type="float"> </argument> <description> - Create a rotation matrix which rotates around the given axis by the specified angle, in radians. The axis must be a normalized vector. + Constructs a pure rotation basis matrix, rotated around the given [code]axis[/code] by [code]phi[/code], in radians. The axis must be a normalized vector. </description> </method> <method name="Basis"> @@ -50,28 +54,30 @@ <argument index="2" name="z_axis" type="Vector3"> </argument> <description> - Create a matrix from 3 axis vectors. + Constructs a basis matrix from 3 axis vectors (matrix columns). </description> </method> <method name="determinant"> <return type="float"> </return> <description> - Returns the determinant of the matrix. + Returns the determinant of the basis matrix. If the basis is uniformly scaled, its determinant is the square of the scale. + A negative determinant means the basis has a negative scale. A zero determinant means the basis isn't invertible, and is usually considered invalid. </description> </method> <method name="get_euler"> <return type="Vector3"> </return> <description> - Returns the basis's rotation in the form of Euler angles (in the YXZ convention: first Z, then X, and Y last). The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle). See [method get_rotation_quat] if you need a quaternion instead. + Returns the basis's rotation in the form of Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last). The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle). + Consider using the [method get_rotation_quat] method instead, which returns a [Quat] quaternion instead of Euler angles. </description> </method> <method name="get_orthogonal_index"> <return type="int"> </return> <description> - This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1, 0, or 1, and returns the index of the point best representing the orientation of the object. It is mainly used by the grid map editor. For further details, refer to the Godot source code. + This function considers a discretization of rotations into 24 points on unit sphere, lying along the vectors (x,y,z) with each component being either -1, 0, or 1, and returns the index of the point best representing the orientation of the object. It is mainly used by the [GridMap] editor. For further details, refer to the Godot source code. </description> </method> <method name="get_rotation_quat"> @@ -193,25 +199,26 @@ <argument index="0" name="v" type="Vector3"> </argument> <description> - Returns a vector transformed (multiplied) by the transposed matrix. + Returns a vector transformed (multiplied) by the transposed basis matrix. [b]Note:[/b] This results in a multiplication by the inverse of the matrix only if it represents a rotation-reflection. </description> </method> </methods> <members> <member name="x" type="Vector3" setter="" getter="" default="Vector3( 1, 0, 0 )"> - The basis matrix's X vector. + The basis matrix's X vector (column 0). Equivalent to array index [code]0[/code]. </member> <member name="y" type="Vector3" setter="" getter="" default="Vector3( 0, 1, 0 )"> - The basis matrix's Y vector. + The basis matrix's Y vector (column 1). Equivalent to array index [code]1[/code]. </member> <member name="z" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 1 )"> - The basis matrix's Z vector. + The basis matrix's Z vector (column 2). Equivalent to array index [code]2[/code]. </member> </members> <constants> <constant name="IDENTITY" value="Basis( 1, 0, 0, 0, 1, 0, 0, 0, 1 )"> - The identity basis. This is identical to calling [code]Basis()[/code] without any parameters. This constant can be used to make your code clearer. + The identity basis, with no rotation or scaling applied. + This is identical to calling [code]Basis()[/code] without any parameters. This constant can be used to make your code clearer, and for consistency with C#. </constant> <constant name="FLIP_X" value="Basis( -1, 0, 0, 0, 1, 0, 0, 0, 1 )"> The basis that will flip something along the X axis when used in a transformation. diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index 17b474531e..240e70db9f 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="Color" version="4.0"> <brief_description> - Color in RGBA format with some support for ARGB format. + Color in RGBA format using floats on the range of 0 to 1. </brief_description> <description> - A color is represented by red, green, and blue [code](r, g, b)[/code] components. Additionally, [code]a[/code] represents the alpha component, often used for transparency. Values are in floating-point and usually range from 0 to 1. Some properties (such as [member CanvasItem.modulate]) may accept values greater than 1. + A color represented by red, green, blue, and alpha (RGBA) components. The alpha component is often used for transparency. Values are in floating-point and usually range from 0 to 1. Some properties (such as CanvasItem.modulate) may accept values greater than 1 (overbright or HDR colors). You can also create a color from standardized color names by using [method @GDScript.ColorN] or directly using the color constants defined here. The standardized color set is based on the [url=https://en.wikipedia.org/wiki/X11_color_names]X11 color names[/url]. If you want to supply values in a range of 0 to 255, you should use [method @GDScript.Color8]. [b]Note:[/b] In a boolean context, a Color will evaluate to [code]false[/code] if it's equal to [code]Color(0, 0, 0, 1)[/code] (opaque black). Otherwise, a Color will always evaluate to [code]true[/code]. @@ -277,37 +277,37 @@ </methods> <members> <member name="a" type="float" setter="" getter="" default="1.0"> - Alpha value (range 0 to 1). + The color's alpha (transparency) component, typically on the range of 0 to 1. </member> <member name="a8" type="int" setter="" getter="" default="255"> - Alpha value (range 0 to 255). + Wrapper for [member a] that uses the range 0 to 255 instead of 0 to 1. </member> <member name="b" type="float" setter="" getter="" default="0.0"> - Blue value (range 0 to 1). + The color's blue component, typically on the range of 0 to 1. </member> <member name="b8" type="int" setter="" getter="" default="0"> - Blue value (range 0 to 255). + Wrapper for [member b] that uses the range 0 to 255 instead of 0 to 1. </member> <member name="g" type="float" setter="" getter="" default="0.0"> - Green value (range 0 to 1). + The color's green component, typically on the range of 0 to 1. </member> <member name="g8" type="int" setter="" getter="" default="0"> - Green value (range 0 to 255). + Wrapper for [member g] that uses the range 0 to 255 instead of 0 to 1. </member> <member name="h" type="float" setter="" getter="" default="0.0"> - HSV hue value (range 0 to 1). + The HSV hue of this color, on the range 0 to 1. </member> <member name="r" type="float" setter="" getter="" default="0.0"> - Red value (range 0 to 1). + The color's red component, typically on the range of 0 to 1. </member> <member name="r8" type="int" setter="" getter="" default="0"> - Red value (range 0 to 255). + Wrapper for [member r] that uses the range 0 to 255 instead of 0 to 1. </member> <member name="s" type="float" setter="" getter="" default="0.0"> - HSV saturation value (range 0 to 1). + The HSV saturation of this color, on the range 0 to 1. </member> <member name="v" type="float" setter="" getter="" default="0.0"> - HSV value (range 0 to 1). + The HSV value (brightness) of this color, on the range 0 to 1. </member> </members> <constants> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index 9dbb843902..1f495bf91a 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -856,7 +856,9 @@ The node's rotation around its pivot, in degrees. See [member rect_pivot_offset] to change the pivot's position. </member> <member name="rect_scale" type="Vector2" setter="set_scale" getter="get_scale" default="Vector2( 1, 1 )"> - The node's scale, relative to its [member rect_size]. Change this property to scale the node around its [member rect_pivot_offset]. + The node's scale, relative to its [member rect_size]. Change this property to scale the node around its [member rect_pivot_offset]. The Control's [member hint_tooltip] will also scale according to this value. + [b]Note:[/b] This property is mainly intended to be used for animation purposes. Text inside the Control will look pixelated or blurry when the Control is scaled. To support multiple resolutions in your project, use an appropriate viewport stretch mode as described in the [url=https://docs.godotengine.org/en/latest/tutorials/viewports/multiple_resolutions.html]documentation[/url] instead of scaling Controls individually. + [b]Note:[/b] If the Control node is a child of a [Container] node, the scale will be reset to [code]Vector2(1, 1)[/code] when the scene is instanced. To set the Control's scale when it's instanced, wait for one frame using [code]yield(get_tree(), "idle_frame")[/code] then set its [member rect_scale] property. </member> <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" default="Vector2( 0, 0 )"> The size of the node's bounding rectangle, in pixels. [Container] nodes update this property automatically. diff --git a/doc/classes/DynamicFont.xml b/doc/classes/DynamicFont.xml index 0864c3ba36..24df056c6b 100644 --- a/doc/classes/DynamicFont.xml +++ b/doc/classes/DynamicFont.xml @@ -26,6 +26,14 @@ Adds a fallback font. </description> </method> + <method name="get_available_chars" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns a string containing all the characters available in the main and all the fallback fonts. + If a given character is included in more than one font, it appears only once in the returned string. + </description> + </method> <method name="get_fallback" qualifiers="const"> <return type="DynamicFontData"> </return> diff --git a/doc/classes/EditorFileSystem.xml b/doc/classes/EditorFileSystem.xml index 9bb51af2d0..5461dccd27 100644 --- a/doc/classes/EditorFileSystem.xml +++ b/doc/classes/EditorFileSystem.xml @@ -97,6 +97,7 @@ <argument index="0" name="resources" type="PackedStringArray"> </argument> <description> + Emitted if at least one resource is reloaded when the filesystem is scanned. </description> </signal> <signal name="sources_changed"> diff --git a/doc/classes/EditorFileSystemDirectory.xml b/doc/classes/EditorFileSystemDirectory.xml index 096fe5df8f..b852ae1063 100644 --- a/doc/classes/EditorFileSystemDirectory.xml +++ b/doc/classes/EditorFileSystemDirectory.xml @@ -67,6 +67,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the base class of the script class defined in the file at index [code]idx[/code]. If the file doesn't define a script class using the [code]class_name[/code] syntax, this will return an empty string. </description> </method> <method name="get_file_script_class_name" qualifiers="const"> @@ -75,6 +76,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the name of the script class defined in the file at index [code]idx[/code]. If the file doesn't define a script class using the [code]class_name[/code] syntax, this will return an empty string. </description> </method> <method name="get_file_type" qualifiers="const"> diff --git a/doc/classes/EditorImportPlugin.xml b/doc/classes/EditorImportPlugin.xml index 0aac59c727..ea2dfae9a5 100644 --- a/doc/classes/EditorImportPlugin.xml +++ b/doc/classes/EditorImportPlugin.xml @@ -83,6 +83,16 @@ <argument index="1" name="options" type="Dictionary"> </argument> <description> + This method can be overridden to hide specific import options if conditions are met. This is mainly useful for hiding options that depend on others if one of them is disabled. For example: + [codeblock] + func get_option_visibility(option, options): + # Only show the lossy quality setting if the compression mode is set to "Lossy". + if option == "compress/lossy_quality" and options.has("compress/mode"): + return int(options["compress/mode"]) == COMPRESS_LOSSY + + return true + [/codeblock] + Return [code]true[/code] to make all options always visible. </description> </method> <method name="get_preset_count" qualifiers="virtual"> @@ -150,6 +160,8 @@ <argument index="4" name="gen_files" type="Array"> </argument> <description> + Imports [code]source_file[/code] into [code]save_path[/code] with the import [code]options[/code] specified. The [code]platform_variants[/code] and [code]gen_files[/code] arrays will be modified by this function. + This method must be overridden to do the actual importing work. See this class' description for an example of overriding this method. </description> </method> </methods> diff --git a/doc/classes/EditorInspector.xml b/doc/classes/EditorInspector.xml index 2f62fe9e40..5fbe427f67 100644 --- a/doc/classes/EditorInspector.xml +++ b/doc/classes/EditorInspector.xml @@ -14,41 +14,50 @@ <return type="void"> </return> <description> + Refreshes the inspector. + [b]Note:[/b] To save on CPU resources, calling this method will do nothing if the time specified in [code]docks/property_editor/auto_refresh_interval[/code] editor setting hasn't passed yet since this method was last called. (By default, this interval is set to 0.3 seconds.) </description> </method> </methods> <members> - <member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" override="true" default="false" /> + <member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" override="true" default="false"> + If [code]true[/code], horizontal scrolling is enabled. An horizontal scroll bar will display at the bottom of the inspector. + </member> </members> <signals> <signal name="object_id_selected"> <argument index="0" name="id" type="int"> </argument> <description> + Emitted when the Edit button of an [Object] has been pressed in the inspector. This is mainly used in the remote scene tree inspector. </description> </signal> <signal name="property_deleted"> <argument index="0" name="property" type="String"> </argument> <description> + Emitted when a property is removed from the inspector. </description> </signal> <signal name="property_edited"> <argument index="0" name="property" type="String"> </argument> <description> + Emitted when a property is edited in the inspector. </description> </signal> <signal name="property_keyed"> <argument index="0" name="property" type="String"> </argument> <description> + Emitted when a property is keyed in the inspector. Properties can be keyed by clicking the "key" icon next to a property when the Animation panel is toggled. </description> </signal> <signal name="property_selected"> <argument index="0" name="property" type="String"> </argument> <description> + Emitted when a property is selected in the inspector. </description> </signal> <signal name="property_toggled"> @@ -57,6 +66,8 @@ <argument index="1" name="checked" type="bool"> </argument> <description> + Emitted when a boolean property is toggled in the inspector. + [b]Note:[/b] This signal is never emitted if the internal [code]autoclear[/code] property enabled. Since this property is always enabled in the editor inspector, this signal is never emitted by the editor itself. </description> </signal> <signal name="resource_selected"> @@ -65,10 +76,12 @@ <argument index="1" name="prop" type="String"> </argument> <description> + Emitted when a resource is selected in the inspector. </description> </signal> <signal name="restart_requested"> <description> + Emitted when a property that requires a restart to be applied is edited in the inspector. This is only used in the Project Settings and Editor Settings. </description> </signal> </signals> diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index 1d877e632e..8b2b9c9350 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -23,13 +23,14 @@ <return type="Control"> </return> <description> - Returns the main container of Godot editor's window. You can use it, for example, to retrieve the size of the container and place your controls accordingly. + Returns the main container of Godot editor's window. For example, you can use it to retrieve the size of the container and place your controls accordingly. </description> </method> <method name="get_current_path" qualifiers="const"> <return type="String"> </return> <description> + Returns the current path being viewed in the [FileSystemDock]. </description> </method> <method name="get_edited_scene_root"> @@ -43,26 +44,29 @@ <return type="EditorSettings"> </return> <description> - Returns the [EditorSettings]. + Returns the editor's [EditorSettings] instance. </description> </method> <method name="get_editor_viewport"> <return type="Control"> </return> <description> - Returns the editor [Viewport]. + Returns the editor's [Viewport] instance. + [b]Note:[/b] This returns the main editor viewport containing the whole editor, not the 2D or 3D viewports specifically. </description> </method> <method name="get_file_system_dock"> <return type="FileSystemDock"> </return> <description> + Returns the editor's [FileSystemDock] instance. </description> </method> <method name="get_inspector" qualifiers="const"> <return type="EditorInspector"> </return> <description> + Returns the editor's [EditorInspector] instance. </description> </method> <method name="get_open_scenes" qualifiers="const"> @@ -83,34 +87,35 @@ <return type="EditorFileSystem"> </return> <description> - Returns the [EditorFileSystem]. + Returns the editor's [EditorFileSystem] instance. </description> </method> <method name="get_resource_previewer"> <return type="EditorResourcePreview"> </return> <description> - Returns the [EditorResourcePreview]. + Returns the editor's [EditorResourcePreview] instance. </description> </method> <method name="get_script_editor"> <return type="ScriptEditor"> </return> <description> - Returns the [ScriptEditor]. + Returns the editor's [ScriptEditor] instance. </description> </method> <method name="get_selected_path" qualifiers="const"> <return type="String"> </return> <description> + Returns the path of the directory currently selected in the [FileSystemDock]. If a file is selected, its base directory will be returned using [method String.get_base_dir] instead. </description> </method> <method name="get_selection"> <return type="EditorSelection"> </return> <description> - Returns the [EditorSelection]. + Returns the editor's [EditorSelection] instance. </description> </method> <method name="inspect_object"> @@ -121,14 +126,14 @@ <argument index="1" name="for_property" type="String" default=""""> </argument> <description> - Shows the given property on the given [code]object[/code] in the Editor's Inspector dock. + Shows the given property on the given [code]object[/code] in the editor's Inspector dock. </description> </method> <method name="is_playing_scene" qualifiers="const"> <return type="bool"> </return> <description> - Returns [code]true[/code], if a scene is currently being played; [code]false[/code] otherwise. Paused scenes are considered as being played. + Returns [code]true[/code] if a scene is currently being played, [code]false[/code] otherwise. Paused scenes are considered as being played. </description> </method> <method name="is_plugin_enabled" qualifiers="const"> @@ -137,7 +142,7 @@ <argument index="0" name="plugin" type="String"> </argument> <description> - Returns the enabled status of a plugin. The plugin name is the same as its directory name. + Returns [code]true[/code] if the specified [code]plugin[/code] is enabled. The plugin name is the same as its directory name. </description> </method> <method name="make_mesh_previews"> @@ -225,6 +230,7 @@ <argument index="0" name="name" type="String"> </argument> <description> + Sets the editor's current main screen to the one specified in [code]name[/code]. [code]name[/code] must match the text of the tab in question exactly ([code]2D[/code], [code]3D[/code], [code]Script[/code], [code]AssetLib[/code]). </description> </method> <method name="set_plugin_enabled"> diff --git a/doc/classes/EditorNode3DGizmo.xml b/doc/classes/EditorNode3DGizmo.xml index 6d695ddeea..45541b9263 100644 --- a/doc/classes/EditorNode3DGizmo.xml +++ b/doc/classes/EditorNode3DGizmo.xml @@ -15,6 +15,7 @@ <argument index="0" name="segments" type="PackedVector3Array"> </argument> <description> + Adds the specified [code]segments[/code] to the gizmo's collision shape for picking. Call this function during [method redraw]. </description> </method> <method name="add_collision_triangles"> @@ -69,6 +70,7 @@ <argument index="3" name="material" type="Material" default="null"> </argument> <description> + Adds a mesh to the gizmo with the specified [code]billboard[/code] state, [code]skeleton[/code] and [code]material[/code]. If [code]billboard[/code] is [code]true[/code], the mesh will rotate to always face the camera. Call this function during [method redraw]. </description> </method> <method name="add_unscaled_billboard"> @@ -88,6 +90,7 @@ <return type="void"> </return> <description> + Removes everything in the gizmo including meshes, collisions and handles. </description> </method> <method name="commit_handle" qualifiers="virtual"> @@ -143,14 +146,14 @@ <argument index="0" name="index" type="int"> </argument> <description> - Gets whether a handle is highlighted or not. + Returns [code]true[/code] if the handle at index [code]index[/code] is highlighted by being hovered with the mouse. </description> </method> <method name="redraw" qualifiers="virtual"> <return type="void"> </return> <description> - This function is called when the Node3D this gizmo refers to changes (the [method Node3D.update_gizmo] is called). + This function is called when the [Node3D] this gizmo refers to changes (the [method Node3D.update_gizmo] is called). </description> </method> <method name="set_handle" qualifiers="virtual"> @@ -173,6 +176,7 @@ <argument index="0" name="hidden" type="bool"> </argument> <description> + Sets the gizmo's hidden state. If [code]true[/code], the gizmo will be hidden. If [code]false[/code], it will be shown. </description> </method> <method name="set_spatial_node"> @@ -181,6 +185,7 @@ <argument index="0" name="node" type="Node"> </argument> <description> + Sets the reference [Node3D] node for the gizmo. [code]node[/code] must inherit from [Node3D]. </description> </method> </methods> diff --git a/doc/classes/EditorNode3DGizmoPlugin.xml b/doc/classes/EditorNode3DGizmoPlugin.xml index ca75b47fbf..b81281b5b6 100644 --- a/doc/classes/EditorNode3DGizmoPlugin.xml +++ b/doc/classes/EditorNode3DGizmoPlugin.xml @@ -139,6 +139,8 @@ <return type="String"> </return> <description> + Override this method to set the gizmo's priority. Higher values correspond to higher priority. If a gizmo with higher priority conflicts with another gizmo, only the gizmo with higher priority will be used. + All built-in editor gizmos return a priority of [code]-1[/code]. If not overridden, this method will return [code]0[/code], which means custom gizmos will automatically override built-in gizmos. </description> </method> <method name="has_gizmo" qualifiers="virtual"> diff --git a/doc/classes/EditorProperty.xml b/doc/classes/EditorProperty.xml index 4da3b58b94..f568263ff8 100644 --- a/doc/classes/EditorProperty.xml +++ b/doc/classes/EditorProperty.xml @@ -73,24 +73,25 @@ </methods> <members> <member name="checkable" type="bool" setter="set_checkable" getter="is_checkable" default="false"> - Used by the inspector, set when property is checkable. + Used by the inspector, set to [code]true[/code] when the property is checkable. </member> <member name="checked" type="bool" setter="set_checked" getter="is_checked" default="false"> - Used by the inspector, when the property is checked. + Used by the inspector, set to [code]true[/code] when the property is checked. </member> <member name="deletable" type="bool" setter="set_deletable" getter="is_deletable" default="false"> + Used by the inspector, set to [code]true[/code] when the property can be deleted by the user. </member> <member name="draw_red" type="bool" setter="set_draw_red" getter="is_draw_red" default="false"> - Used by the inspector, when the property must draw with error color. + Used by the inspector, set to [code]true[/code] when the property must draw with error color. This is used for editable children's properties. </member> <member name="keying" type="bool" setter="set_keying" getter="is_keying" default="false"> - Used by the inspector, when the property can add keys for animation. + Used by the inspector, set to [code]true[/code] when the property can add keys for animation. </member> <member name="label" type="String" setter="set_label" getter="get_label" default=""""> - Sets this property to change the label (if you want to show one). + Set this property to change the label (if you want to show one). </member> <member name="read_only" type="bool" setter="set_read_only" getter="is_read_only" default="false"> - Used by the inspector, when the property is read-only. + Used by the inspector, set to [code]true[/code] when the property is read-only. </member> </members> <signals> @@ -134,6 +135,7 @@ <argument index="0" name="property" type="StringName"> </argument> <description> + Emitted when a property was deleted. Used internally. </description> </signal> <signal name="property_keyed"> diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 19921ff5c8..0c6a2d61cd 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -5,11 +5,16 @@ </brief_description> <description> Object that holds the project-independent editor settings. These settings are generally visible in the [b]Editor > Editor Settings[/b] menu. - Accessing the settings is done by using the regular [Object] API, such as: + Property names use slash delimiters to distinguish sections. Setting values can be of any [Variant] type. It's recommended to use [code]snake_case[/code] for editor settings to be consistent with the Godot editor itself. + Accessing the settings can be done using the following methods, such as: [codeblock] - settings.set(prop,value) - settings.get(prop) - list_of_settings = settings.get_property_list() + # `settings.set("some/property", value)` also works as this class overrides `_set()` internally. + settings.set_setting("some/property",value) + + # `settings.get("some/property", value)` also works as this class overrides `_get()` internally. + settings.get_setting("some/property") + + var list_of_settings = settings.get_property_list() [/codeblock] [b]Note:[/b] This class shouldn't be instantiated directly. Instead, access the singleton using [method EditorInterface.get_editor_settings]. </description> @@ -47,14 +52,14 @@ <argument index="0" name="property" type="String"> </argument> <description> - Erase a given setting (pass full property path). + Erases the setting whose name is specified by [code]property[/code]. </description> </method> <method name="get_favorites" qualifiers="const"> <return type="PackedStringArray"> </return> <description> - Gets the list of favorite files and directories for this project. + Returns the list of favorite files and directories for this project. </description> </method> <method name="get_project_metadata" qualifiers="const"> @@ -67,20 +72,21 @@ <argument index="2" name="default" type="Variant" default="null"> </argument> <description> + Returns project-specific metadata for the [code]section[/code] and [code]key[/code] specified. If the metadata doesn't exist, [code]default[/code] will be returned instead. See also [method set_project_metadata]. </description> </method> <method name="get_project_settings_dir" qualifiers="const"> <return type="String"> </return> <description> - Gets the specific project settings path. Projects all have a unique sub-directory inside the settings path where project specific settings are saved. + Returns the project-specific settings path. Projects all have a unique subdirectory inside the settings path where project-specific settings are saved. </description> </method> <method name="get_recent_dirs" qualifiers="const"> <return type="PackedStringArray"> </return> <description> - Gets the list of recently visited folders in the file dialog for this project. + Returns the list of recently visited folders in the file dialog for this project. </description> </method> <method name="get_setting" qualifiers="const"> @@ -89,6 +95,7 @@ <argument index="0" name="name" type="String"> </argument> <description> + Returns the value of the setting specified by [code]name[/code]. This is equivalent to using [method Object.get] on the EditorSettings instance. </description> </method> <method name="get_settings_dir" qualifiers="const"> @@ -106,6 +113,7 @@ <argument index="0" name="name" type="String"> </argument> <description> + Returns [code]true[/code] if the setting specified by [code]name[/code] exists, [code]false[/code] otherwise. </description> </method> <method name="property_can_revert"> @@ -114,6 +122,7 @@ <argument index="0" name="name" type="String"> </argument> <description> + Returns [code]true[/code] if the setting specified by [code]name[/code] can have its value reverted to the default value, [code]false[/code] otherwise. When this method returns [code]true[/code], a Revert button will display next to the setting in the Editor Settings. </description> </method> <method name="property_get_revert"> @@ -122,6 +131,7 @@ <argument index="0" name="name" type="String"> </argument> <description> + Returns the default value of the setting specified by [code]name[/code]. This is the value that would be applied when clicking the Revert button in the Editor Settings. </description> </method> <method name="set_favorites"> @@ -143,6 +153,7 @@ <argument index="2" name="update_current" type="bool"> </argument> <description> + Sets the initial value of the setting specified by [code]name[/code] to [code]value[/code]. This is used to provide a value for the Revert button in the Editor Settings. If [code]update_current[/code] is true, the current value of the setting will be set to [code]value[/code] as well. </description> </method> <method name="set_project_metadata"> @@ -155,6 +166,7 @@ <argument index="2" name="data" type="Variant"> </argument> <description> + Sets project-specific metadata with the [code]section[/code], [code]key[/code] and [code]data[/code] specified. This metadata is stored outside the project folder and therefore won't be checked into version control. See also [method get_project_metadata]. </description> </method> <method name="set_recent_dirs"> @@ -174,19 +186,20 @@ <argument index="1" name="value" type="Variant"> </argument> <description> + Sets the [code]value[/code] of the setting specified by [code]name[/code]. This is equivalent to using [method Object.set] on the EditorSettings instance. </description> </method> </methods> <signals> <signal name="settings_changed"> <description> - Emitted when editor settings change. + Emitted after any editor setting has changed. </description> </signal> </signals> <constants> <constant name="NOTIFICATION_EDITOR_SETTINGS_CHANGED" value="10000"> - Emitted when editor settings change. It used by various editor plugins to update their visuals on theme changes or logic on configuration changes. + Emitted after any editor setting has changed. It's used by various editor plugins to update their visuals on theme changes or logic on configuration changes. </constant> </constants> </class> diff --git a/doc/classes/HTTPClient.xml b/doc/classes/HTTPClient.xml index 76153ae041..7e8f0807ac 100644 --- a/doc/classes/HTTPClient.xml +++ b/doc/classes/HTTPClient.xml @@ -8,6 +8,7 @@ [b]Note:[/b] This client only needs to connect to a host once (see [method connect_to_host]) to send multiple requests. Because of this, methods that take URLs usually take just the part after the host instead of the full URL, as the client is already connected to a host. See [method request] for a full example and to get started. A [HTTPClient] should be reused between multiple requests or to connect to different hosts instead of creating one client per request. Supports SSL and SSL server certificate verification. HTTP status codes in the 2xx range indicate success, 3xx redirection (i.e. "try again, but over here"), 4xx something was wrong with the request, and 5xx something went wrong on the server's side. For more information on HTTP, see https://developer.mozilla.org/en-US/docs/Web/HTTP (or read RFC 2616 to get it straight from the source: https://tools.ietf.org/html/rfc2616). + [b]Note:[/b] When performing HTTP requests from a project exported to HTML5, keep in mind the remote server may not allow requests from foreign origins due to [url=https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS]CORS[/url]. If you host the server in question, you should modify its backend to allow requests from foreign origins by adding the [code]Access-Control-Allow-Origin: *[/code] HTTP header. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/networking/http_client_class.html</link> diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml index 0b0d71fccf..61e0d2e2b9 100644 --- a/doc/classes/HTTPRequest.xml +++ b/doc/classes/HTTPRequest.xml @@ -64,6 +64,7 @@ add_child(texture_rect) texture_rect.texture = texture [/codeblock] + [b]Note:[/b] When performing HTTP requests from a project exported to HTML5, keep in mind the remote server may not allow requests from foreign origins due to [url=https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS]CORS[/url]. If you host the server in question, you should modify its backend to allow requests from foreign origins by adding the [code]Access-Control-Allow-Origin: *[/code] HTTP header. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/networking/http_request_class.html</link> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 32645c9205..5b4b5d02fb 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -112,7 +112,18 @@ <return type="PackedStringArray"> </return> <description> - Returns the command line arguments passed to the engine. + Returns the command-line arguments passed to the engine. + Command-line arguments can be written in any form, including both [code]--key value[/code] and [code]--key=value[/code] forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments. + You can also incorporate environment variables using the [method get_environment] method. + You can set [code]editor/main_run_args[/code] in the Project Settings to define command-line arguments to be passed by the editor when running the project. + Here's a minimal example on how to parse command-line arguments into a dictionary using the [code]--key=value[/code] form for arguments: + [codeblock] + var arguments = {} + for argument in OS.get_cmdline_args(): + if argument.find("=") > -1: + var key_value = argument.split("=") + arguments[key_value[0].lstrip("--")] = key_value[1] + [/codeblock] </description> </method> <method name="get_connected_midi_inputs"> diff --git a/doc/classes/Plane.xml b/doc/classes/Plane.xml index 292acd8b5d..ce0680523c 100644 --- a/doc/classes/Plane.xml +++ b/doc/classes/Plane.xml @@ -65,13 +65,6 @@ Returns the shortest distance from the plane to the position [code]point[/code]. </description> </method> - <method name="get_any_point"> - <return type="Vector3"> - </return> - <description> - Returns a point on the plane. - </description> - </method> <method name="has_point"> <return type="bool"> </return> @@ -80,7 +73,7 @@ <argument index="1" name="epsilon" type="float" default="1e-05"> </argument> <description> - Returns [code]true[/code] if [code]point[/code] is inside the plane (by a very minimum [code]epsilon[/code] threshold). + Returns [code]true[/code] if [code]point[/code] is inside the plane. Comparison uses a custom minimum [code]epsilon[/code] threshold. </description> </method> <method name="intersect_3"> @@ -147,36 +140,38 @@ <argument index="0" name="point" type="Vector3"> </argument> <description> - Returns the orthogonal projection of point [code]p[/code] into a point in the plane. + Returns the orthogonal projection of [code]point[/code] into a point in the plane. </description> </method> </methods> <members> <member name="d" type="float" setter="" getter="" default="0.0"> - Distance from the origin to the plane, in the direction of [member normal]. + The distance from the origin to the plane, in the direction of [member normal]. This value is typically non-negative. + In the scalar equation of the plane [code]ax + by + cz = d[/code], this is [code]d[/code], while the [code](a, b, c)[/code] coordinates are represented by the [member normal] property. </member> <member name="normal" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )"> - The normal of the plane. "Over" or "Above" the plane is considered the side of the plane towards where the normal is pointing. + The normal of the plane, which must be normalized. + In the scalar equation of the plane [code]ax + by + cz = d[/code], this is the vector [code](a, b, c)[/code], where [code]d[/code] is the [member d] property. </member> <member name="x" type="float" setter="" getter="" default="0.0"> - The [member normal]'s X component. + The X component of the plane's [member normal] vector. </member> <member name="y" type="float" setter="" getter="" default="0.0"> - The [member normal]'s Y component. + The Y component of the plane's [member normal] vector. </member> <member name="z" type="float" setter="" getter="" default="0.0"> - The [member normal]'s Z component. + The Z component of the plane's [member normal] vector. </member> </members> <constants> <constant name="PLANE_YZ" value="Plane( 1, 0, 0, 0 )"> - A plane that extends in the Y and Z axes. + A plane that extends in the Y and Z axes (normal vector points +X). </constant> <constant name="PLANE_XZ" value="Plane( 0, 1, 0, 0 )"> - A plane that extends in the X and Z axes. + A plane that extends in the X and Z axes (normal vector points +Y). </constant> <constant name="PLANE_XY" value="Plane( 0, 0, 1, 0 )"> - A plane that extends in the X and Y axes. + A plane that extends in the X and Y axes (normal vector points +Z). </constant> </constants> </class> diff --git a/doc/classes/Quat.xml b/doc/classes/Quat.xml index 327fa882e5..730edb00d9 100644 --- a/doc/classes/Quat.xml +++ b/doc/classes/Quat.xml @@ -4,9 +4,9 @@ Quaternion. </brief_description> <description> - A unit quaternion used for representing 3D rotations. - It is similar to [Basis], which implements matrix representation of rotations, and can be parametrized using both an axis-angle pair or Euler angles. But due to its compactness and the way it is stored in memory, certain operations (obtaining axis-angle and performing SLERP, in particular) are more efficient and robust against floating-point errors. - Quaternions need to be (re)normalized. + A unit quaternion used for representing 3D rotations. Quaternions need to be normalized to be used for rotation. + It is similar to Basis, which implements matrix representation of rotations, and can be parametrized using both an axis-angle pair or Euler angles. Basis stores rotation, scale, and shearing, while Quat only stores rotation. + Due to its compactness and the way it is stored in memory, certain operations (obtaining axis-angle and performing SLERP, in particular) are more efficient and robust against floating-point errors. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/3d/using_transforms.html#interpolating-with-quaternions</link> @@ -18,7 +18,7 @@ <argument index="0" name="from" type="Basis"> </argument> <description> - Returns the rotation matrix corresponding to the given quaternion. + Constructs a quaternion from the given [Basis]. </description> </method> <method name="Quat"> @@ -27,7 +27,7 @@ <argument index="0" name="euler" type="Vector3"> </argument> <description> - Returns a quaternion that will perform a rotation specified by Euler angles (in the YXZ convention: first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle). + Constructs a quaternion that will perform a rotation specified by Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle). </description> </method> <method name="Quat"> @@ -38,7 +38,7 @@ <argument index="1" name="angle" type="float"> </argument> <description> - Returns a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector. + Constructs a quaternion that will rotate around the given axis by the specified angle. The axis must be a normalized vector. </description> </method> <method name="Quat"> @@ -53,7 +53,7 @@ <argument index="3" name="w" type="float"> </argument> <description> - Returns a quaternion defined by these values. + Constructs a quaternion defined by the given values. </description> </method> <method name="cubic_slerp"> @@ -68,7 +68,7 @@ <argument index="3" name="t" type="float"> </argument> <description> - Performs a cubic spherical-linear interpolation with another quaternion. + Performs a cubic spherical interpolation between quaternions [code]preA[/code], this vector, [code]b[/code], and [code]postB[/code], by the given amount [code]t[/code]. </description> </method> <method name="dot"> @@ -84,7 +84,7 @@ <return type="Vector3"> </return> <description> - Returns Euler angles (in the YXZ convention: first Z, then X, and Y last) corresponding to the rotation represented by the unit quaternion. Returned vector contains the rotation angles in the format (X angle, Y angle, Z angle). + Returns Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last) corresponding to the rotation represented by the unit quaternion. Returned vector contains the rotation angles in the format (X angle, Y angle, Z angle). </description> </method> <method name="inverse"> @@ -148,7 +148,7 @@ <argument index="0" name="euler" type="Vector3"> </argument> <description> - Sets the quaternion to a rotation specified by Euler angles (in the YXZ convention: first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle). + Sets the quaternion to a rotation specified by Euler angles (in the YXZ convention: when decomposing, first Z, then X, and Y last), given in the vector format as (X angle, Y angle, Z angle). </description> </method> <method name="slerp"> @@ -159,7 +159,8 @@ <argument index="1" name="t" type="float"> </argument> <description> - Performs a spherical-linear interpolation with another quaternion. + Returns the result of the spherical linear interpolation between this quaternion and [code]to[/code] by amount [code]weight[/code]. + [b]Note:[/b] Both quaternions must be normalized. </description> </method> <method name="slerpni"> @@ -170,7 +171,7 @@ <argument index="1" name="t" type="float"> </argument> <description> - Performs a spherical-linear interpolation with another quaterion without checking if the rotation path is not bigger than 90°. + Returns the result of the spherical linear interpolation between this quaternion and [code]to[/code] by amount [code]weight[/code], but without checking if the rotation path is not bigger than 90 degrees. </description> </method> <method name="xform"> @@ -179,27 +180,31 @@ <argument index="0" name="v" type="Vector3"> </argument> <description> - Transforms the vector [code]v[/code] by this quaternion. + Returns a vector transformed (multiplied) by this quaternion. </description> </method> </methods> <members> <member name="w" type="float" setter="" getter="" default="1.0"> - W component of the quaternion. + W component of the quaternion (real part). + Quaternion components should usually not be manipulated directly. </member> <member name="x" type="float" setter="" getter="" default="0.0"> - X component of the quaternion. + X component of the quaternion (imaginary [code]i[/code] axis part). + Quaternion components should usually not be manipulated directly. </member> <member name="y" type="float" setter="" getter="" default="0.0"> - Y component of the quaternion. + Y component of the quaternion (imaginary [code]j[/code] axis part). + Quaternion components should usually not be manipulated directly. </member> <member name="z" type="float" setter="" getter="" default="0.0"> - Z component of the quaternion. + Z component of the quaternion (imaginary [code]k[/code] axis part). + Quaternion components should usually not be manipulated directly. </member> </members> <constants> <constant name="IDENTITY" value="Quat( 0, 0, 0, 1 )"> - The identity rotation. Equivalent to an identity matrix. If a vector is transformed by an identity quaternion, it will not change. + The identity quaternion, representing no rotation. Equivalent to an identity [Basis] matrix. If a vector is transformed by an identity quaternion, it will not change. </constant> </constants> </class> diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml index dbf461cdf1..8599aad95e 100644 --- a/doc/classes/Rect2.xml +++ b/doc/classes/Rect2.xml @@ -171,13 +171,14 @@ </methods> <members> <member name="end" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )"> - Ending corner. + Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size. </member> <member name="position" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )"> - Position (starting corner). + Beginning corner. Typically has values lower than [member end]. </member> <member name="size" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )"> - Size from position to end. + Size from [member position] to [member end]. Typically all components are positive. + If the size is negative, you can use [method abs] to fix it. </member> </members> <constants> diff --git a/doc/classes/Rect2i.xml b/doc/classes/Rect2i.xml index f3a7ba0476..7362580c02 100644 --- a/doc/classes/Rect2i.xml +++ b/doc/classes/Rect2i.xml @@ -160,13 +160,14 @@ </methods> <members> <member name="end" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )"> - Ending corner. + Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size. </member> <member name="position" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )"> - Position (starting corner). + Beginning corner. Typically has values lower than [member end]. </member> <member name="size" type="Vector2i" setter="" getter="" default="Vector2i( 0, 0 )"> - Size from position to end. + Size from [member position] to [member end]. Typically all components are positive. + If the size is negative, you can use [method abs] to fix it. </member> </members> <constants> diff --git a/doc/classes/RigidBody3D.xml b/doc/classes/RigidBody3D.xml index efd55f5566..370e6bd19c 100644 --- a/doc/classes/RigidBody3D.xml +++ b/doc/classes/RigidBody3D.xml @@ -100,6 +100,13 @@ [b]Note:[/b] The result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead. </description> </method> + <method name="get_inverse_inertia_tensor"> + <return type="Basis"> + </return> + <description> + Returns the inverse inertia tensor basis. This is used to calculate the angular acceleration resulting from a torque applied to the [RigidBody3D]. + </description> + </method> <method name="set_axis_lock"> <return type="void"> </return> diff --git a/doc/classes/Transform.xml b/doc/classes/Transform.xml index 4175f01eb4..26c190bfa9 100644 --- a/doc/classes/Transform.xml +++ b/doc/classes/Transform.xml @@ -4,10 +4,12 @@ 3D transformation (3×4 matrix). </brief_description> <description> - Represents one or many transformations in 3D space such as translation, rotation, or scaling. It consists of a [member basis] and an [member origin]. It is similar to a 3×4 matrix. + 3×4 matrix (3 rows, 4 columns) used for 3D linear transformations. It can represent transformations such as translation, rotation, or scaling. It consists of a [member basis] (first 3 columns) and a [Vector3] for the [member origin] (last column). + For more information, read the "Matrices and transforms" documentation article. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/math/index.html</link> + <link>https://docs.godotengine.org/en/latest/tutorials/math/matrices_and_transforms.html</link> <link>https://docs.godotengine.org/en/latest/tutorials/3d/using_transforms.html</link> </tutorials> <methods> @@ -23,7 +25,7 @@ <argument index="3" name="origin" type="Vector3"> </argument> <description> - Constructs the Transform from four [Vector3]. Each axis corresponds to local basis vectors (some of which may be scaled). + Constructs a Transform from four [Vector3] values (matrix columns). Each axis corresponds to local basis vectors (some of which may be scaled). </description> </method> <method name="Transform"> @@ -34,7 +36,7 @@ <argument index="1" name="origin" type="Vector3"> </argument> <description> - Constructs the Transform from a [Basis] and [Vector3]. + Constructs a Transform from a [Basis] and [Vector3]. </description> </method> <method name="Transform"> @@ -43,7 +45,7 @@ <argument index="0" name="from" type="Transform2D"> </argument> <description> - Constructs the Transform from a [Transform2D]. + Constructs a Transform from a [Transform2D]. </description> </method> <method name="Transform"> @@ -52,7 +54,7 @@ <argument index="0" name="from" type="Quat"> </argument> <description> - Constructs the Transform from a [Quat]. The origin will be Vector3(0, 0, 0). + Constructs a Transform from a [Quat]. The origin will be [code]Vector3(0, 0, 0)[/code]. </description> </method> <method name="Transform"> @@ -79,7 +81,7 @@ <argument index="1" name="weight" type="float"> </argument> <description> - Interpolates the transform to other Transform by weight amount (0-1). + Interpolates the transform to other Transform by weight amount (on the range of 0.0 to 1.0). </description> </method> <method name="inverse"> @@ -172,7 +174,7 @@ The basis is a matrix containing 3 [Vector3] as its columns: X axis, Y axis, and Z axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object. </member> <member name="origin" type="Vector3" setter="" getter="" default="Vector3( 0, 0, 0 )"> - The translation offset of the transform. + The translation offset of the transform (column 3, the fourth column). Equivalent to array index [code]3[/code]. </member> </members> <constants> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index af93d4c654..f630df7afe 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -1,12 +1,14 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="Transform2D" version="4.0"> <brief_description> - 2D transformation (3×2 matrix). + 2D transformation (2×3 matrix). </brief_description> <description> - Represents one or many transformations in 2D space such as translation, rotation, or scaling. It consists of two [member x] and [member y] [Vector2]s and an [member origin]. It is similar to a 3×2 matrix. + 2×3 matrix (2 rows, 3 columns) used for 2D linear transformations. It can represent transformations such as translation, rotation, or scaling. It consists of a three [Vector2] values: [member x], [member y], and the [member origin]. + For more information, read the "Matrices and transforms" documentation article. </description> <tutorials> + <link>https://docs.godotengine.org/en/latest/tutorials/math/matrices_and_transforms.html</link> </tutorials> <methods> <method name="Transform2D"> @@ -28,7 +30,7 @@ <argument index="2" name="origin" type="Vector2"> </argument> <description> - Constructs the transform from 3 [Vector2]s representing x, y, and origin. + Constructs the transform from 3 [Vector2] values representing [member x], [member y], and the [member origin] (the three column vectors). </description> </method> <method name="Transform2D"> @@ -46,7 +48,7 @@ <return type="Transform2D"> </return> <description> - Returns the inverse of the matrix. + Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation. </description> </method> <method name="basis_xform"> @@ -55,7 +57,8 @@ <argument index="0" name="v" type="Vector2"> </argument> <description> - Transforms the given vector by this transform's basis (no translation). + Returns a vector transformed (multiplied) by the basis matrix. + This method does not account for translation (the origin vector). </description> </method> <method name="basis_xform_inv"> @@ -64,7 +67,8 @@ <argument index="0" name="v" type="Vector2"> </argument> <description> - Inverse-transforms the given vector by this transform's basis (no translation). + Returns a vector transformed (multiplied) by the inverse basis matrix. + This method does not account for translation (the origin vector). </description> </method> <method name="get_origin"> @@ -96,14 +100,14 @@ <argument index="1" name="weight" type="float"> </argument> <description> - Returns a transform interpolated between this transform and another by a given weight (0-1). + Returns a transform interpolated between this transform and another by a given weight (on the range of 0.0 to 1.0). </description> </method> <method name="inverse"> <return type="Transform2D"> </return> <description> - Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling). + Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use [method affine_inverse] for transforms with scaling). </description> </method> <method name="is_equal_approx"> @@ -119,7 +123,7 @@ <return type="Transform2D"> </return> <description> - Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors. + Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1). </description> </method> <method name="rotated"> @@ -171,24 +175,24 @@ </methods> <members> <member name="origin" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )"> - The transform's translation offset. + The origin vector (column 2, the third column). Equivalent to array index [code]2[/code]. The origin vector represents translation. </member> <member name="x" type="Vector2" setter="" getter="" default="Vector2( 1, 0 )"> - The X axis of 2×2 basis matrix containing 2 [Vector2]s as its columns: X axis and Y axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object. + The basis matrix's X vector (column 0). Equivalent to array index [code]0[/code]. </member> <member name="y" type="Vector2" setter="" getter="" default="Vector2( 0, 1 )"> - The Y axis of 2×2 basis matrix containing 2 [Vector2]s as its columns: X axis and Y axis. These vectors can be interpreted as the basis vectors of local coordinate system traveling with the object. + The basis matrix's Y vector (column 1). Equivalent to array index [code]1[/code]. </member> </members> <constants> <constant name="IDENTITY" value="Transform2D( 1, 0, 0, 1, 0, 0 )"> - [Transform2D] with no translation, rotation or scaling applied. When applied to other data structures, [constant IDENTITY] performs no transformation. + The identity [Transform2D] with no translation, rotation or scaling applied. When applied to other data structures, [constant IDENTITY] performs no transformation. </constant> <constant name="FLIP_X" value="Transform2D( -1, 0, 0, 1, 0, 0 )"> - [Transform2D] with mirroring applied parallel to the X axis. + The [Transform2D] that will flip something along the X axis. </constant> <constant name="FLIP_Y" value="Transform2D( 1, 0, 0, -1, 0, 0 )"> - [Transform2D] with mirroring applied parallel to the Y axis. + The [Transform2D] that will flip something along the Y axis. </constant> </constants> </class> diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 32895310d1..c0d8628d88 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -43,7 +43,7 @@ <return type="float"> </return> <description> - Returns the vector's angle in radians with respect to the X axis, or [code](1, 0)[/code] vector. + Returns this vector's angle with respect to the X axis, or [code](1, 0)[/code] vector, in radians. Equivalent to the result of [method @GDScript.atan2] when called with the vector's [member y] and [member x] as parameters: [code]atan2(y, x)[/code]. </description> </method> @@ -53,7 +53,7 @@ <argument index="0" name="to" type="Vector2"> </argument> <description> - Returns the angle in radians between the two vectors. + Returns the angle to the given vector, in radians. </description> </method> <method name="angle_to_point"> @@ -62,14 +62,14 @@ <argument index="0" name="to" type="Vector2"> </argument> <description> - Returns the angle in radians between the line connecting the two points and the X coordinate. + Returns the angle between the line connecting the two points and the X axis, in radians. </description> </method> <method name="aspect"> <return type="float"> </return> <description> - Returns the ratio of [member x] to [member y]. + Returns the aspect ratio of this vector, the ratio of [member x] to [member y]. </description> </method> <method name="bounce"> @@ -85,7 +85,7 @@ <return type="Vector2"> </return> <description> - Returns the vector with all components rounded up. + Returns the vector with all components rounded up (towards positive infinity). </description> </method> <method name="clamped"> @@ -94,7 +94,7 @@ <argument index="0" name="length" type="float"> </argument> <description> - Returns the vector with a maximum length. + Returns the vector with a maximum length by limiting its length to [code]length[/code]. </description> </method> <method name="cross"> @@ -103,7 +103,7 @@ <argument index="0" name="with" type="Vector2"> </argument> <description> - Returns the 2-dimensional analog of the cross product with the given vector. + Returns the cross product of this vector and [code]with[/code]. </description> </method> <method name="cubic_interpolate"> @@ -118,7 +118,7 @@ <argument index="3" name="t" type="float"> </argument> <description> - Cubically interpolates between this vector and [code]b[/code] using [code]pre_a[/code] and [code]post_b[/code] as handles, and returns the result at position [code]t[/code]. [code]t[/code] is in the range of [code]0.0 - 1.0[/code], representing the amount of interpolation. + Cubically interpolates between this vector and [code]b[/code] using [code]pre_a[/code] and [code]post_b[/code] as handles, and returns the result at position [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="direction_to"> @@ -136,7 +136,8 @@ <argument index="0" name="to" type="Vector2"> </argument> <description> - Returns the squared distance to vector [code]b[/code]. Prefer this function over [method distance_to] if you need to sort vectors or need the squared distance for some formula. + Returns the squared distance between this vector and [code]b[/code]. + This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> <method name="distance_to"> @@ -145,7 +146,7 @@ <argument index="0" name="to" type="Vector2"> </argument> <description> - Returns the distance to vector [code]b[/code]. + Returns the distance between this vector and [code]to[/code]. </description> </method> <method name="dot"> @@ -154,14 +155,17 @@ <argument index="0" name="with" type="Vector2"> </argument> <description> - Returns the dot product with vector [code]b[/code]. + Returns the dot product of this vector and [code]with[/code]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. + The dot product will be [code]0[/code] for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees. + When using unit (normalized) vectors, the result will always be between [code]-1.0[/code] (180 degree angle) when the vectors are facing opposite directions, and [code]1.0[/code] (0 degree angle) when the vectors are aligned. + [b]Note:[/b] [code]a.dot(b)[/code] is equivalent to [code]b.dot(a)[/code]. </description> </method> <method name="floor"> <return type="Vector2"> </return> <description> - Returns the vector with all components rounded down. + Returns the vector with all components rounded down (towards negative infinity). </description> </method> <method name="is_equal_approx"> @@ -177,21 +181,22 @@ <return type="bool"> </return> <description> - Returns [code]true[/code] if the vector is normalized. + Returns [code]true[/code] if the vector is normalized, and false otherwise. </description> </method> <method name="length"> <return type="float"> </return> <description> - Returns the vector's length. + Returns the length (magnitude) of this vector. </description> </method> <method name="length_squared"> <return type="float"> </return> <description> - Returns the vector's length squared. Prefer this method over [method length] if you need to sort vectors or need the squared length for some formula. + Returns the squared length (squared magnitude) of this vector. + This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> <method name="lerp"> @@ -202,7 +207,7 @@ <argument index="1" name="t" type="float"> </argument> <description> - Returns the result of the linear interpolation between this vector and [code]b[/code] by amount [code]t[/code]. [code]t[/code] is in the range of [code]0.0 - 1.0[/code], representing the amount of interpolation. + Returns the result of the linear interpolation between this vector and [code]b[/code] by amount [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="move_toward"> @@ -229,7 +234,7 @@ <argument index="0" name="mod" type="float"> </argument> <description> - Returns a vector composed of the [code]fposmod[/code] of this vector's components and [code]mod[/code]. + Returns a vector composed of the [method @GDScript.fposmod] of this vector's components and [code]mod[/code]. </description> </method> <method name="posmodv"> @@ -238,7 +243,7 @@ <argument index="0" name="modv" type="Vector2"> </argument> <description> - Returns a vector composed of the [code]fposmod[/code] of this vector's components and [code]modv[/code]'s components. + Returns a vector composed of the [method @GDScript.fposmod] of this vector's components and [code]modv[/code]'s components. </description> </method> <method name="project"> @@ -279,7 +284,7 @@ <return type="Vector2"> </return> <description> - Returns the vector with each component set to one or negative one, depending on the signs of the components. + Returns the vector with each component set to one or negative one, depending on the signs of the components, or zero if the component is zero, by calling [method @GDScript.sign] on each component. </description> </method> <method name="slerp"> @@ -290,7 +295,7 @@ <argument index="1" name="t" type="float"> </argument> <description> - Returns the result of spherical linear interpolation between this vector and [code]b[/code], by amount [code]t[/code]. [code]t[/code] is in the range of [code]0.0 - 1.0[/code], representing the amount of interpolation. + Returns the result of spherical linear interpolation between this vector and [code]b[/code], by amount [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. [b]Note:[/b] Both vectors must be normalized. </description> </method> @@ -300,7 +305,7 @@ <argument index="0" name="n" type="Vector2"> </argument> <description> - Returns the component of the vector along a plane defined by the given normal. + Returns this vector slid along a plane defined by the given normal. </description> </method> <method name="snapped"> @@ -309,14 +314,14 @@ <argument index="0" name="by" type="Vector2"> </argument> <description> - Returns the vector snapped to a grid with the given size. + Returns this vector with each component snapped to the nearest multiple of [code]step[/code]. This can also be used to round to an arbitrary number of decimals. </description> </method> <method name="tangent"> <return type="Vector2"> </return> <description> - Returns a perpendicular vector. + Returns a perpendicular vector rotated 90 degrees counter-clockwise compared to the original, with the same length. </description> </method> </methods> @@ -336,25 +341,25 @@ Enumerated value for the Y axis. </constant> <constant name="ZERO" value="Vector2( 0, 0 )"> - Zero vector. + Zero vector, a vector with all components set to [code]0[/code]. </constant> <constant name="ONE" value="Vector2( 1, 1 )"> - One vector. + One vector, a vector with all components set to [code]1[/code]. </constant> <constant name="INF" value="Vector2( inf, inf )"> - Infinity vector. + Infinity vector, a vector with all components set to [constant @GDScript.INF]. </constant> <constant name="LEFT" value="Vector2( -1, 0 )"> - Left unit vector. + Left unit vector. Represents the direction of left. </constant> <constant name="RIGHT" value="Vector2( 1, 0 )"> - Right unit vector. + Right unit vector. Represents the direction of right. </constant> <constant name="UP" value="Vector2( 0, -1 )"> - Up unit vector. + Up unit vector. Y is down in 2D, so this vector points -Y. </constant> <constant name="DOWN" value="Vector2( 0, 1 )"> - Down unit vector. + Down unit vector. Y is down in 2D, so this vector points +Y. </constant> </constants> </class> diff --git a/doc/classes/Vector2i.xml b/doc/classes/Vector2i.xml index 2f7ca985b2..d03db712fc 100644 --- a/doc/classes/Vector2i.xml +++ b/doc/classes/Vector2i.xml @@ -70,22 +70,22 @@ Enumerated value for the Y axis. </constant> <constant name="ZERO" value="Vector2i( 0, 0 )"> - Zero vector. + Zero vector, a vector with all components set to [code]0[/code]. </constant> <constant name="ONE" value="Vector2i( 1, 1 )"> - One vector. + One vector, a vector with all components set to [code]1[/code]. </constant> <constant name="LEFT" value="Vector2i( -1, 0 )"> - Left unit vector. + Left unit vector. Represents the direction of left. </constant> <constant name="RIGHT" value="Vector2i( 1, 0 )"> - Right unit vector. + Right unit vector. Represents the direction of right. </constant> <constant name="UP" value="Vector2i( 0, -1 )"> - Up unit vector. + Up unit vector. Y is down in 2D, so this vector points -Y. </constant> <constant name="DOWN" value="Vector2i( 0, 1 )"> - Down unit vector. + Down unit vector. Y is down in 2D, so this vector points +Y. </constant> </constants> </class> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index 0c861e5ee2..776dfd929e 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -47,7 +47,7 @@ <argument index="0" name="to" type="Vector3"> </argument> <description> - Returns the minimum angle to the given vector. + Returns the minimum angle to the given vector, in radians. </description> </method> <method name="bounce"> @@ -63,7 +63,7 @@ <return type="Vector3"> </return> <description> - Returns a new vector with all components rounded up. + Returns a new vector with all components rounded up (towards positive infinity). </description> </method> <method name="cross"> @@ -72,7 +72,7 @@ <argument index="0" name="b" type="Vector3"> </argument> <description> - Returns the cross product with [code]b[/code]. + Returns the cross product of this vector and [code]b[/code]. </description> </method> <method name="cubic_interpolate"> @@ -87,7 +87,7 @@ <argument index="3" name="t" type="float"> </argument> <description> - Performs a cubic interpolation between vectors [code]pre_a[/code], [code]a[/code], [code]b[/code], [code]post_b[/code] ([code]a[/code] is current), by the given amount [code]t[/code]. [code]t[/code] is in the range of [code]0.0 - 1.0[/code], representing the amount of interpolation. + Performs a cubic interpolation between vectors [code]pre_a[/code], [code]a[/code], [code]b[/code], [code]post_b[/code] ([code]a[/code] is current), by the given amount [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="direction_to"> @@ -105,7 +105,8 @@ <argument index="0" name="b" type="Vector3"> </argument> <description> - Returns the squared distance to [code]b[/code]. Prefer this function over [method distance_to] if you need to sort vectors or need the squared distance for some formula. + Returns the squared distance between this vector and [code]b[/code]. + This method runs faster than [method distance_to], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> <method name="distance_to"> @@ -114,7 +115,7 @@ <argument index="0" name="b" type="Vector3"> </argument> <description> - Returns the distance to [code]b[/code]. + Returns the distance between this vector and [code]b[/code]. </description> </method> <method name="dot"> @@ -123,14 +124,17 @@ <argument index="0" name="b" type="Vector3"> </argument> <description> - Returns the dot product with [code]b[/code]. + Returns the dot product of this vector and [code]b[/code]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player. + The dot product will be [code]0[/code] for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees. + When using unit (normalized) vectors, the result will always be between [code]-1.0[/code] (180 degree angle) when the vectors are facing opposite directions, and [code]1.0[/code] (0 degree angle) when the vectors are aligned. + [b]Note:[/b] [code]a.dot(b)[/code] is equivalent to [code]b.dot(a)[/code]. </description> </method> <method name="floor"> <return type="Vector3"> </return> <description> - Returns a new vector with all components rounded down. + Returns a new vector with all components rounded down (towards negative infinity). </description> </method> <method name="inverse"> @@ -153,21 +157,22 @@ <return type="bool"> </return> <description> - Returns [code]true[/code] if the vector is normalized. + Returns [code]true[/code] if the vector is normalized, and false otherwise. </description> </method> <method name="length"> <return type="float"> </return> <description> - Returns the vector's length. + Returns the length (magnitude) of this vector. </description> </method> <method name="length_squared"> <return type="float"> </return> <description> - Returns the vector's length squared. Prefer this function over [method length] if you need to sort vectors or need the squared length for some formula. + Returns the squared length (squared magnitude) of this vector. + This method runs faster than [method length], so prefer it if you need to compare vectors or need the squared distance for some formula. </description> </method> <method name="lerp"> @@ -178,21 +183,21 @@ <argument index="1" name="t" type="float"> </argument> <description> - Returns the result of the linear interpolation between this vector and [code]b[/code] by amount [code]t[/code]. [code]t[/code] is in the range of [code]0.0 - 1.0[/code], representing the amount of interpolation.. + Returns the result of the linear interpolation between this vector and [code]b[/code] by amount [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. </description> </method> <method name="max_axis"> <return type="int"> </return> <description> - Returns the axis of the vector's largest value. See [code]AXIS_*[/code] constants. + Returns the axis of the vector's largest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X]. </description> </method> <method name="min_axis"> <return type="int"> </return> <description> - Returns the axis of the vector's smallest value. See [code]AXIS_*[/code] constants. + Returns the axis of the vector's smallest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Z]. </description> </method> <method name="move_toward"> @@ -203,7 +208,7 @@ <argument index="1" name="delta" type="float"> </argument> <description> - Moves the vector toward [code]to[/code] by the fixed [code]delta[/code] amount. + Moves this vector toward [code]to[/code] by the fixed [code]delta[/code] amount. </description> </method> <method name="normalized"> @@ -228,7 +233,7 @@ <argument index="0" name="mod" type="float"> </argument> <description> - Returns a vector composed of the [code]fposmod[/code] of this vector's components and [code]mod[/code]. + Returns a vector composed of the [method @GDScript.fposmod] of this vector's components and [code]mod[/code]. </description> </method> <method name="posmodv"> @@ -237,7 +242,7 @@ <argument index="0" name="modv" type="Vector3"> </argument> <description> - Returns a vector composed of the [code]fposmod[/code] of this vector's components and [code]modv[/code]'s components. + Returns a vector composed of the [method @GDScript.fposmod] of this vector's components and [code]modv[/code]'s components. </description> </method> <method name="project"> @@ -246,7 +251,7 @@ <argument index="0" name="b" type="Vector3"> </argument> <description> - Returns the vector projected onto the vector [code]b[/code]. + Returns this vector projected onto another vector [code]b[/code]. </description> </method> <method name="reflect"> @@ -255,7 +260,7 @@ <argument index="0" name="n" type="Vector3"> </argument> <description> - Returns the vector reflected from a plane defined by the given normal. + Returns this vector reflected from a plane defined by the given normal. </description> </method> <method name="rotated"> @@ -266,21 +271,21 @@ <argument index="1" name="phi" type="float"> </argument> <description> - Rotates the vector around a given axis by [code]phi[/code] radians. The axis must be a normalized vector. + Rotates this vector around a given axis by [code]phi[/code] radians. The axis must be a normalized vector. </description> </method> <method name="round"> <return type="Vector3"> </return> <description> - Returns the vector with all components rounded to the nearest integer, with halfway cases rounded away from zero. + Returns this vector with all components rounded to the nearest integer, with halfway cases rounded away from zero. </description> </method> <method name="sign"> <return type="Vector3"> </return> <description> - Returns the vector with each component set to one or negative one, depending on the signs of the components. + Returns a vector with each component set to one or negative one, depending on the signs of this vector's components, or zero if the component is zero, by calling [method @GDScript.sign] on each component. </description> </method> <method name="slerp"> @@ -291,7 +296,7 @@ <argument index="1" name="t" type="float"> </argument> <description> - Returns the result of spherical linear interpolation between this vector and [code]b[/code], by amount [code]t[/code]. [code]t[/code] is in the range of [code]0.0 - 1.0[/code], representing the amount of interpolation. + Returns the result of spherical linear interpolation between this vector and [code]b[/code], by amount [code]t[/code]. [code]t[/code] is on the range of 0.0 to 1.0, representing the amount of interpolation. [b]Note:[/b] Both vectors must be normalized. </description> </method> @@ -301,7 +306,7 @@ <argument index="0" name="n" type="Vector3"> </argument> <description> - Returns the component of the vector along a plane defined by the given normal. + Returns this vector slid along a plane defined by the given normal. </description> </method> <method name="snapped"> @@ -310,7 +315,7 @@ <argument index="0" name="by" type="Vector3"> </argument> <description> - Returns the vector snapped to a grid with the given size. + Returns this vector with each component snapped to the nearest multiple of [code]step[/code]. This can also be used to round to an arbitrary number of decimals. </description> </method> <method name="to_diagonal_matrix"> @@ -318,6 +323,7 @@ </return> <description> Returns a diagonal matrix with the vector as main diagonal. + This is equivalent to a Basis with no rotation or shearing and this vector's components set as the scale. </description> </method> </methods> @@ -343,19 +349,19 @@ Enumerated value for the Z axis. Returned by [method max_axis] and [method min_axis]. </constant> <constant name="ZERO" value="Vector3( 0, 0, 0 )"> - Zero vector. + Zero vector, a vector with all components set to [code]0[/code]. </constant> <constant name="ONE" value="Vector3( 1, 1, 1 )"> - One vector. + One vector, a vector with all components set to [code]1[/code]. </constant> <constant name="INF" value="Vector3( inf, inf, inf )"> - Infinity vector. + Infinity vector, a vector with all components set to [constant @GDScript.INF]. </constant> <constant name="LEFT" value="Vector3( -1, 0, 0 )"> - Left unit vector. + Left unit vector. Represents the local direction of left, and the global direction of west. </constant> <constant name="RIGHT" value="Vector3( 1, 0, 0 )"> - Right unit vector. + Right unit vector. Represents the local direction of right, and the global direction of east. </constant> <constant name="UP" value="Vector3( 0, 1, 0 )"> Up unit vector. @@ -364,10 +370,10 @@ Down unit vector. </constant> <constant name="FORWARD" value="Vector3( 0, 0, -1 )"> - Forward unit vector. + Forward unit vector. Represents the local direction of forward, and the global direction of north. </constant> <constant name="BACK" value="Vector3( 0, 0, 1 )"> - Back unit vector. + Back unit vector. Represents the local direction of back, and the global direction of south. </constant> </constants> </class> diff --git a/doc/classes/Vector3i.xml b/doc/classes/Vector3i.xml index 91d64ea609..94551e1c2f 100644 --- a/doc/classes/Vector3i.xml +++ b/doc/classes/Vector3i.xml @@ -38,14 +38,14 @@ <return type="int"> </return> <description> - Returns the axis of the vector's largest value. See [code]AXIS_*[/code] constants. + Returns the axis of the vector's largest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_X]. </description> </method> <method name="min_axis"> <return type="int"> </return> <description> - Returns the axis of the vector's smallest value. See [code]AXIS_*[/code] constants. + Returns the axis of the vector's smallest value. See [code]AXIS_*[/code] constants. If all components are equal, this method returns [constant AXIS_Z]. </description> </method> <method name="sign"> @@ -78,16 +78,16 @@ Enumerated value for the Z axis. </constant> <constant name="ZERO" value="Vector3i( 0, 0, 0 )"> - Zero vector. + Zero vector, a vector with all components set to [code]0[/code]. </constant> <constant name="ONE" value="Vector3i( 1, 1, 1 )"> - One vector. + One vector, a vector with all components set to [code]1[/code]. </constant> <constant name="LEFT" value="Vector3i( -1, 0, 0 )"> - Left unit vector. + Left unit vector. Represents the local direction of left, and the global direction of west. </constant> <constant name="RIGHT" value="Vector3i( 1, 0, 0 )"> - Right unit vector. + Right unit vector. Represents the local direction of right, and the global direction of east. </constant> <constant name="UP" value="Vector3i( 0, 1, 0 )"> Up unit vector. @@ -96,10 +96,10 @@ Down unit vector. </constant> <constant name="FORWARD" value="Vector3i( 0, 0, -1 )"> - Forward unit vector. + Forward unit vector. Represents the local direction of forward, and the global direction of north. </constant> <constant name="BACK" value="Vector3i( 0, 0, 1 )"> - Back unit vector. + Back unit vector. Represents the local direction of back, and the global direction of south. </constant> </constants> </class> diff --git a/doc/classes/VisibilityEnabler2D.xml b/doc/classes/VisibilityEnabler2D.xml index a5abf16a8d..02fe7a7cd0 100644 --- a/doc/classes/VisibilityEnabler2D.xml +++ b/doc/classes/VisibilityEnabler2D.xml @@ -5,7 +5,8 @@ </brief_description> <description> The VisibilityEnabler2D will disable [RigidBody2D], [AnimationPlayer], and other nodes when they are not visible. It will only affect nodes with the same root node as the VisibilityEnabler2D, and the root node itself. - [b]Note:[/b] For performance reasons, VisibilityEnabler2D uses an approximate heuristic with precision determined by [member ProjectSettings.world/2d/cell_size]. If you need exact visibility checking, use another method such as adding an [Area2D] node as a child of a [Camera2D] node. + If you just want to receive notifications, use [VisibilityNotifier2D] instead. + [b]Note:[/b] For performance reasons, VisibilityEnabler2D uses an approximate heuristic with precision determined by [member ProjectSettings.world/2d/cell_size]. If you need precise visibility checking, use another method such as adding an [Area2D] node as a child of a [Camera2D] node. [b]Note:[/b] VisibilityEnabler2D will not affect nodes added after scene initialization. </description> <tutorials> diff --git a/doc/classes/VisibilityEnabler3D.xml b/doc/classes/VisibilityEnabler3D.xml index 342a37e7a4..d78ebb55f2 100644 --- a/doc/classes/VisibilityEnabler3D.xml +++ b/doc/classes/VisibilityEnabler3D.xml @@ -5,7 +5,8 @@ </brief_description> <description> The VisibilityEnabler3D will disable [RigidBody3D] and [AnimationPlayer] nodes when they are not visible. It will only affect other nodes within the same scene as the VisibilityEnabler3D itself. - [b]Note:[/b] VisibilityEnabler3D uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account. If you need exact visibility checking, use another method such as adding an [Area3D] node as a child of a [Camera3D] node. + If you just want to receive notifications, use [VisibilityNotifier3D] instead. + [b]Note:[/b] VisibilityEnabler3D uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account. The heuristic is an implementation detail and may change in future versions. If you need precise visibility checking, use another method such as adding an [Area3D] node as a child of a [Camera3D] node and/or [method Vector3.dot]. [b]Note:[/b] VisibilityEnabler3D will not affect nodes added after scene initialization. </description> <tutorials> diff --git a/doc/classes/VisibilityNotifier2D.xml b/doc/classes/VisibilityNotifier2D.xml index 391163ef94..314a100989 100644 --- a/doc/classes/VisibilityNotifier2D.xml +++ b/doc/classes/VisibilityNotifier2D.xml @@ -5,7 +5,8 @@ </brief_description> <description> The VisibilityNotifier2D detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a viewport. - [b]Note:[/b] For performance reasons, VisibilityNotifier2D uses an approximate heuristic with precision determined by [member ProjectSettings.world/2d/cell_size]. If you need exact visibility checking, use another method such as adding an [Area2D] node as a child of a [Camera2D] node. + If you want nodes to be disabled automatically when they exit the screen, use [VisibilityEnabler2D] instead. + [b]Note:[/b] For performance reasons, VisibilityNotifier2D uses an approximate heuristic with precision determined by [member ProjectSettings.world/2d/cell_size]. If you need precise visibility checking, use another method such as adding an [Area2D] node as a child of a [Camera2D] node. </description> <tutorials> </tutorials> diff --git a/doc/classes/VisibilityNotifier3D.xml b/doc/classes/VisibilityNotifier3D.xml index eb7bb91f26..e5d3116612 100644 --- a/doc/classes/VisibilityNotifier3D.xml +++ b/doc/classes/VisibilityNotifier3D.xml @@ -5,7 +5,8 @@ </brief_description> <description> The VisibilityNotifier3D detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a [Camera3D]'s view. - [b]Note:[/b] VisibilityNotifier3D uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account. If you need exact visibility checking, use another method such as adding an [Area3D] node as a child of a [Camera3D] node. + If you want nodes to be disabled automatically when they exit the screen, use [VisibilityEnabler3D] instead. + [b]Note:[/b] VisibilityNotifier3D uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account. The heuristic is an implementation detail and may change in future versions. If you need precise visibility checking, use another method such as adding an [Area3D] node as a child of a [Camera3D] node and/or [method Vector3.dot]. </description> <tutorials> </tutorials> diff --git a/drivers/vulkan/rendering_device_vulkan.cpp b/drivers/vulkan/rendering_device_vulkan.cpp index c5b837decd..794bcee3e6 100644 --- a/drivers/vulkan/rendering_device_vulkan.cpp +++ b/drivers/vulkan/rendering_device_vulkan.cpp @@ -5068,13 +5068,13 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma input_assembly_create_info.topology = topology_list[p_render_primitive]; input_assembly_create_info.primitiveRestartEnable = (p_render_primitive == RENDER_PRIMITIVE_TRIANGLE_STRIPS_WITH_RESTART_INDEX); - //tesselation - VkPipelineTessellationStateCreateInfo tesselation_create_info; - tesselation_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; - tesselation_create_info.pNext = nullptr; - tesselation_create_info.flags = 0; + //tessellation + VkPipelineTessellationStateCreateInfo tessellation_create_info; + tessellation_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; + tessellation_create_info.pNext = nullptr; + tessellation_create_info.flags = 0; ERR_FAIL_COND_V(p_rasterization_state.patch_control_points < 1 || p_rasterization_state.patch_control_points > limits.maxTessellationPatchSize, RID()); - tesselation_create_info.patchControlPoints = p_rasterization_state.patch_control_points; + tessellation_create_info.patchControlPoints = p_rasterization_state.patch_control_points; VkPipelineViewportStateCreateInfo viewport_state_create_info; viewport_state_create_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; @@ -5286,7 +5286,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma graphics_pipeline_create_info.pStages = shader->pipeline_stages.ptr(); graphics_pipeline_create_info.pVertexInputState = &pipeline_vertex_input_state_create_info; graphics_pipeline_create_info.pInputAssemblyState = &input_assembly_create_info; - graphics_pipeline_create_info.pTessellationState = &tesselation_create_info; + graphics_pipeline_create_info.pTessellationState = &tessellation_create_info; graphics_pipeline_create_info.pViewportState = &viewport_state_create_info; graphics_pipeline_create_info.pRasterizationState = &rasterization_state_create_info; graphics_pipeline_create_info.pMultisampleState = &multisample_state_create_info; diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c3f0d1b712..2d50d25ff5 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2980,7 +2980,16 @@ Variant EditorPropertyResource::get_drag_data_fw(const Point2 &p_point, Control } bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const { - String allowed_type = base_type; + Vector<String> allowed_types = base_type.split(","); + int size = allowed_types.size(); + for (int i = 0; i < size; i++) { + String at = allowed_types[i].strip_edges(); + if (at == "StandardMaterial3D") { + allowed_types.append("Texture2D"); + } else if (at == "ShaderMaterial") { + allowed_types.append("Shader"); + } + } Dictionary drag_data = p_drag_data; @@ -2993,9 +3002,9 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const } if (res.is_valid()) { - for (int i = 0; i < allowed_type.get_slice_count(","); i++) { - String at = allowed_type.get_slice(",", i).strip_edges(); - if (res.is_valid() && ClassDB::is_parent_class(res->get_class(), at)) { + for (int i = 0; i < allowed_types.size(); i++) { + String at = allowed_types[i].strip_edges(); + if (ClassDB::is_parent_class(res->get_class(), at)) { return true; } } @@ -3009,8 +3018,8 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const String ftype = EditorFileSystem::get_singleton()->get_file_type(file); if (ftype != "") { - for (int i = 0; i < allowed_type.get_slice_count(","); i++) { - String at = allowed_type.get_slice(",", i).strip_edges(); + for (int i = 0; i < allowed_types.size(); i++) { + String at = allowed_types[i].strip_edges(); if (ClassDB::is_parent_class(ftype, at)) { return true; } @@ -3039,24 +3048,49 @@ void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant & res = drag_data["resource"]; } - if (res.is_valid()) { - emit_changed(get_edited_property(), res); - update_property(); - return; - } - - if (drag_data.has("type") && String(drag_data["type"]) == "files") { + if (!res.is_valid() && drag_data.has("type") && String(drag_data["type"]) == "files") { Vector<String> files = drag_data["files"]; if (files.size() == 1) { String file = files[0]; - RES file_res = ResourceLoader::load(file); - if (file_res.is_valid()) { - emit_changed(get_edited_property(), file_res); - update_property(); - return; + res = ResourceLoader::load(file); + } + } + + if (res.is_valid()) { + bool need_convert = true; + + Vector<String> allowed_types = base_type.split(","); + for (int i = 0; i < allowed_types.size(); i++) { + String at = allowed_types[i].strip_edges(); + if (ClassDB::is_parent_class(res->get_class(), at)) { + need_convert = false; + break; + } + } + + if (need_convert) { + for (int i = 0; i < allowed_types.size(); i++) { + String at = allowed_types[i].strip_edges(); + if (at == "StandardMaterial3D" && ClassDB::is_parent_class(res->get_class(), "Texture2D")) { + Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D); + mat->set_texture(StandardMaterial3D::TextureParam::TEXTURE_ALBEDO, res); + res = mat; + break; + } + + if (at == "ShaderMaterial" && ClassDB::is_parent_class(res->get_class(), "Shader")) { + Ref<ShaderMaterial> mat = memnew(ShaderMaterial); + mat->set_shader(res); + res = mat; + break; + } } } + + emit_changed(get_edited_property(), res); + update_property(); + return; } } diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 683db0e31d..bb144d2ed6 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1229,10 +1229,14 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { } } + mesh.blend_weights.resize(mesh.mesh->get_blend_shape_count()); + for (int32_t weight_i = 0; weight_i < mesh.blend_weights.size(); weight_i++) { + mesh.blend_weights.write[weight_i] = 0.0f; + } + if (d.has("weights")) { const Array &weights = d["weights"]; - ERR_FAIL_COND_V(mesh.mesh->get_blend_shape_count() != weights.size(), ERR_PARSE_ERROR); - mesh.blend_weights.resize(weights.size()); + ERR_FAIL_COND_V(mesh.blend_weights.size() != weights.size(), ERR_PARSE_ERROR); for (int j = 0; j < weights.size(); j++) { mesh.blend_weights.write[j] = weights[j]; } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 44913abe8b..3c6556a310 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -2045,10 +2045,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if ((b->get_alt() && !b->get_control()) || tool == TOOL_MOVE) { List<CanvasItem *> selection = _get_edited_canvas_items(); - // Remove not movable nodes + drag_selection.clear(); for (int i = 0; i < selection.size(); i++) { - if (!_is_node_movable(selection[i], true)) { - selection.erase(selection[i]); + if (_is_node_movable(selection[i], true)) { + drag_selection.push_back(selection[i]); } } @@ -2073,7 +2073,6 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } drag_from = transform.affine_inverse().xform(b->get_position()); - drag_selection = selection; _save_canvas_item_state(drag_selection); } return true; @@ -2395,16 +2394,15 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { // Drag the node(s) if requested List<CanvasItem *> selection2 = _get_edited_canvas_items(); - // Remove not movable nodes + drag_selection.clear(); for (int i = 0; i < selection2.size(); i++) { - if (!_is_node_movable(selection2[i], true)) { - selection2.erase(selection2[i]); + if (_is_node_movable(selection2[i], true)) { + drag_selection.push_back(selection2[i]); } } if (selection2.size() > 0) { drag_type = DRAG_MOVE; - drag_selection = selection2; drag_from = click; _save_canvas_item_state(drag_selection); } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 4f783f4e27..71830d0464 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -701,7 +701,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) { Ref<Script> script = current->get_edited_resource(); if (p_save) { // Do not try to save internal scripts - if (!(script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1)) { + if (!script.is_valid() || !(script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1)) { _menu_option(FILE_SAVE); } } diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index b121a7ae3e..7fb751e3ed 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -1977,7 +1977,7 @@ void TileSetEditor::_set_edited_shape_points(const Vector<Vector2> &points) { if (convex.is_valid()) { undo_redo->add_do_method(convex.ptr(), "set_points", points); undo_redo->add_undo_method(convex.ptr(), "set_points", _get_edited_shape_points()); - } else if (concave.is_valid()) { + } else if (concave.is_valid() && points.size() > 1) { PackedVector2Array segments; for (int i = 0; i < points.size() - 1; i++) { segments.push_back(points[i]); @@ -2669,7 +2669,7 @@ void TileSetEditor::draw_polygon_shapes() { workspace->draw_polygon(polygon, colors); if (coord == edited_shape_coord || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) { - if (!creating_shape) { + if (!creating_shape && polygon.size() > 1) { for (int j = 0; j < polygon.size() - 1; j++) { workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); } @@ -2706,13 +2706,11 @@ void TileSetEditor::draw_polygon_shapes() { } workspace->draw_polygon(polygon, colors); - if (!creating_shape) { - if (polygon.size() > 1) { - for (int j = 0; j < polygon.size() - 1; j++) { - workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); - } - workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1); + if (!creating_shape && polygon.size() > 1) { + for (int j = 0; j < polygon.size() - 1; j++) { + workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); } + workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1); } if (shape == edited_occlusion_shape) { draw_handles = true; @@ -2756,7 +2754,7 @@ void TileSetEditor::draw_polygon_shapes() { workspace->draw_polygon(polygon, colors); if (coord == edited_shape_coord) { - if (!creating_shape) { + if (!creating_shape && polygon.size() > 1) { for (int j = 0; j < polygon.size() - 1; j++) { workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); } @@ -2796,7 +2794,7 @@ void TileSetEditor::draw_polygon_shapes() { } workspace->draw_polygon(polygon, colors); - if (!creating_shape) { + if (!creating_shape && polygon.size() > 1) { for (int j = 0; j < polygon.size() - 1; j++) { workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); } @@ -2845,7 +2843,7 @@ void TileSetEditor::draw_polygon_shapes() { workspace->draw_polygon(polygon, colors); if (coord == edited_shape_coord) { - if (!creating_shape) { + if (!creating_shape && polygon.size() > 1) { for (int j = 0; j < polygon.size() - 1; j++) { workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); } @@ -2863,7 +2861,7 @@ void TileSetEditor::draw_polygon_shapes() { } } - if (creating_shape) { + if (creating_shape && current_shape.size() > 1) { for (int j = 0; j < current_shape.size() - 1; j++) { workspace->draw_line(current_shape[j], current_shape[j + 1], Color(0, 1, 1), 1); } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 90747e45e4..13fb74987c 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1217,7 +1217,6 @@ void SceneTreeDock::_node_selected() { Node *node = scene_tree->get_selected(); if (!node) { - editor->push_item(nullptr); return; } @@ -1902,11 +1901,10 @@ void SceneTreeDock::_selection_changed() { if (selection_size > 1) { //automatically turn on multi-edit _tool_selected(TOOL_MULTI_EDIT); - } else if (selection_size == 1) { - editor->push_item(EditorNode::get_singleton()->get_editor_selection()->get_selected_node_list()[0]); - } else { + } else if (selection_size == 0) { editor->push_item(nullptr); } + _update_script_button(); } diff --git a/misc/travis/android-tools-linux.sh b/misc/ci/android-tools-linux.sh index 6114551861..6114551861 100755 --- a/misc/travis/android-tools-linux.sh +++ b/misc/ci/android-tools-linux.sh diff --git a/misc/ci/sources.list b/misc/ci/sources.list new file mode 100644 index 0000000000..4d8f94f35c --- /dev/null +++ b/misc/ci/sources.list @@ -0,0 +1,4 @@ +deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse +deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse diff --git a/misc/travis/ccache-osx.sh b/misc/travis/ccache-osx.sh deleted file mode 100755 index 5ce7a80cbc..0000000000 --- a/misc/travis/ccache-osx.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -echo -echo "Download and install ccache ..." -echo - -echo "Downloading sources ..." -curl -L -O https://www.samba.org/ftp/ccache/ccache-3.3.4.tar.gz # latest version available here: https://ccache.samba.org/download.html - -echo "Extracting to build directory ..." -tar xzf ccache-3.3.4.tar.gz -cd ccache-3.3.4 - -echo "Compiling sources ..." -./configure --prefix=/usr/local --with-bundled-zlib > /dev/null -make - -echo "Installing ..." - -mkdir /usr/local/opt/ccache - -mkdir /usr/local/opt/ccache/bin -cp ccache /usr/local/opt/ccache/bin -ln -s /usr/local/opt/ccache/bin/ccache /usr/local/bin/ccache - -mkdir /usr/local/opt/ccache/libexec -links=( - clang - clang++ - cc - gcc gcc2 gcc3 gcc-3.3 gcc-4.0 gcc-4.2 gcc-4.3 gcc-4.4 gcc-4.5 gcc-4.6 gcc-4.7 gcc-4.8 gcc-4.9 gcc-5 gcc-6 gcc-7 - c++ c++3 c++-3.3 c++-4.0 c++-4.2 c++-4.3 c++-4.4 c++-4.5 c++-4.6 c++-4.7 c++-4.8 c++-4.9 c++-5 c++-6 c++-7 - g++ g++2 g++3 g++-3.3 g++-4.0 g++-4.2 g++-4.3 g++-4.4 g++-4.5 g++-4.6 g++-4.7 g++-4.8 g++-4.9 g++-5 g++-6 g++-7 -) -for link in "${links[@]}"; do - ln -s ../bin/ccache /usr/local/opt/ccache/libexec/$link -done -#/usr/local/bin/ccache -M 2G -cd $TRAVIS_BUILD_DIR - -echo -echo "Done!" -echo diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 70e137b16d..9dc307c629 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -158,10 +158,6 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf btVector3 bt_motion; G_TO_B(p_motion, bt_motion); - if (bt_motion.fuzzyZero()) { - return false; - } - ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->getornull(p_shape); ERR_FAIL_COND_V(!shape, false); @@ -180,6 +176,10 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf btTransform bt_xform_to(bt_xform_from); bt_xform_to.getOrigin() += bt_motion; + if ((bt_xform_to.getOrigin() - bt_xform_from.getOrigin()).fuzzyZero()) { + return false; + } + GodotClosestConvexResultCallback btResult(bt_xform_from.getOrigin(), bt_xform_to.getOrigin(), &p_exclude, p_collide_with_bodies, p_collide_with_areas); btResult.m_collisionFilterGroup = 0; btResult.m_collisionFilterMask = p_collision_mask; @@ -982,7 +982,7 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f motionVec->end(); #endif - for (int shIndex = 0; shIndex < shape_count && !motion.fuzzyZero(); ++shIndex) { + for (int shIndex = 0; shIndex < shape_count; ++shIndex) { if (p_body->is_shape_disabled(shIndex)) { continue; } @@ -1004,6 +1004,11 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f btTransform shape_world_to(shape_world_from); shape_world_to.getOrigin() += motion; + if ((shape_world_to.getOrigin() - shape_world_from.getOrigin()).fuzzyZero()) { + motion = btVector3(0, 0, 0); + break; + } + GodotKinClosestConvexResultCallback btResult(shape_world_from.getOrigin(), shape_world_to.getOrigin(), p_body, p_infinite_inertia); btResult.m_collisionFilterGroup = p_body->get_collision_layer(); btResult.m_collisionFilterMask = p_body->get_collision_mask(); diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp index 7f22c7dfe3..d5970e8004 100644 --- a/modules/gdnative/gdnative/aabb.cpp +++ b/modules/gdnative/gdnative/aabb.cpp @@ -81,6 +81,13 @@ godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self) { return ret; } +godot_aabb GDAPI godot_aabb_abs(const godot_aabb *p_self) { + godot_aabb dest; + const AABB *self = (const AABB *)p_self; + *((AABB *)&dest) = self->abs(); + return dest; +} + godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self) { const AABB *self = (const AABB *)p_self; return self->get_area(); diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp index 663937f906..d4ed8d00f4 100644 --- a/modules/gdnative/gdnative/plane.cpp +++ b/modules/gdnative/gdnative/plane.cpp @@ -79,13 +79,6 @@ godot_vector3 GDAPI godot_plane_center(const godot_plane *p_self) { return dest; } -godot_vector3 GDAPI godot_plane_get_any_point(const godot_plane *p_self) { - godot_vector3 dest; - const Plane *self = (const Plane *)p_self; - *((Vector3 *)&dest) = self->get_any_point(); - return dest; -} - godot_bool GDAPI godot_plane_is_point_over(const godot_plane *p_self, const godot_vector3 *p_point) { const Plane *self = (const Plane *)p_self; const Vector3 *point = (const Vector3 *)p_point; diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index eb122089b6..9852928d22 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -54,6 +54,13 @@ ] }, { + "name": "godot_aabb_abs", + "return_type": "godot_aabb", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { "name": "godot_aabb_get_area", "return_type": "godot_real", "arguments": [ @@ -2981,13 +2988,6 @@ ] }, { - "name": "godot_plane_get_any_point", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { "name": "godot_plane_is_point_over", "return_type": "godot_bool", "arguments": [ diff --git a/modules/gdnative/include/gdnative/aabb.h b/modules/gdnative/include/gdnative/aabb.h index 9f41e9d4c6..c776297944 100644 --- a/modules/gdnative/include/gdnative/aabb.h +++ b/modules/gdnative/include/gdnative/aabb.h @@ -69,6 +69,8 @@ void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_ godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self); +godot_aabb GDAPI godot_aabb_abs(const godot_aabb *p_self); + godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self); godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self); diff --git a/modules/gdnative/include/gdnative/plane.h b/modules/gdnative/include/gdnative/plane.h index b759a8cc1a..9843056489 100644 --- a/modules/gdnative/include/gdnative/plane.h +++ b/modules/gdnative/include/gdnative/plane.h @@ -68,8 +68,6 @@ godot_plane GDAPI godot_plane_normalized(const godot_plane *p_self); godot_vector3 GDAPI godot_plane_center(const godot_plane *p_self); -godot_vector3 GDAPI godot_plane_get_any_point(const godot_plane *p_self); - godot_bool GDAPI godot_plane_is_point_over(const godot_plane *p_self, const godot_vector3 *p_point); godot_real GDAPI godot_plane_distance_to(const godot_plane *p_self, const godot_vector3 *p_point); diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index f04cb4b4c3..36de66ea52 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -52,7 +52,7 @@ <argument index="0" name="s" type="float"> </argument> <description> - Returns the absolute value of parameter [code]s[/code] (i.e. unsigned value, works for integer and float). + Returns the absolute value of parameter [code]s[/code] (i.e. positive value). [codeblock] # a is 1 a = abs(-1) @@ -112,7 +112,7 @@ </argument> <description> Returns the arc tangent of [code]s[/code] in radians. Use it to get the angle from an angle's tangent in trigonometry: [code]atan(tan(angle)) == angle[/code]. - The method cannot know in which quadrant the angle should fall. See [method atan2] if you always want an exact angle. + The method cannot know in which quadrant the angle should fall. See [method atan2] if you have both [code]y[code] and [code]x[/code]. [codeblock] a = atan(0.5) # a is 0.463648 [/codeblock] @@ -127,6 +127,7 @@ </argument> <description> Returns the arc tangent of [code]y/x[/code] in radians. Use to get the angle of tangent [code]y/x[/code]. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant. + Important note: The Y coordinate comes first, by convention. [codeblock] a = atan2(0, -1) # a is 3.141593 [/codeblock] @@ -161,7 +162,7 @@ <argument index="0" name="s" type="float"> </argument> <description> - Rounds [code]s[/code] upward, returning the smallest integral value that is not less than [code]s[/code]. + Rounds [code]s[/code] upward (towards positive infinity), returning the smallest whole number that is not less than [code]s[/code]. [codeblock] i = ceil(1.45) # i is 2 i = ceil(1.001) # i is 2 @@ -283,7 +284,7 @@ <argument index="0" name="deg" type="float"> </argument> <description> - Returns degrees converted to radians. + Converts an angle expressed in degrees to radians. [codeblock] # r is 3.141593 r = deg2rad(180) @@ -307,7 +308,7 @@ <argument index="1" name="curve" type="float"> </argument> <description> - Easing function, based on exponent. 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in. + Easing function, based on exponent. The curve values are: 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in. </description> </method> <method name="exp"> @@ -330,7 +331,7 @@ <argument index="0" name="s" type="float"> </argument> <description> - Rounds [code]s[/code] to the closest smaller integer and returns it. + Rounds [code]s[/code] downward (towards negative infinity), returning the largest whole number that is not more than [code]s[/code]. [codeblock] # a is 2.0 a = floor(2.99) @@ -530,7 +531,7 @@ <argument index="0" name="s" type="float"> </argument> <description> - Returns whether [code]s[/code] is a NaN (Not-A-Number) value. + Returns whether [code]s[/code] is a NaN ("Not a Number" or invalid) value. </description> </method> <method name="is_zero_approx"> @@ -540,6 +541,7 @@ </argument> <description> Returns [code]true[/code] if [code]s[/code] is zero or almost zero. + This method is faster than using [method is_equal_approx] with one value as zero. </description> </method> <method name="len"> @@ -907,7 +909,7 @@ <argument index="0" name="rad" type="float"> </argument> <description> - Converts from radians to degrees. + Converts an angle expressed in radians to degrees. [codeblock] rad2deg(0.523599) # Returns 30 [/codeblock] @@ -1026,7 +1028,7 @@ <argument index="0" name="s" type="float"> </argument> <description> - Returns the integral value that is nearest to [code]s[/code], with halfway cases rounded away from zero. + Rounds [code]s[/code] to the nearest whole number, with halfway cases rounded away from zero. [codeblock] round(2.6) # Returns 3 [/codeblock] @@ -1108,10 +1110,11 @@ <argument index="0" name="s" type="float"> </argument> <description> - Returns the square root of [code]s[/code]. + Returns the square root of [code]s[/code], where [code]s[/code] is a non-negative number. [codeblock] sqrt(9) # Returns 3 [/codeblock] + If you need negative inputs, use [code]System.Numerics.Complex[/code] in C#. </description> </method> <method name="step_decimals"> @@ -1312,27 +1315,19 @@ Wraps float [code]value[/code] between [code]min[/code] and [code]max[/code]. Usable for creating loop-alike behavior or infinite surfaces. [codeblock] - # a is 0.5 - a = wrapf(10.5, 0.0, 10.0) - [/codeblock] - [codeblock] - # a is 9.5 - a = wrapf(-0.5, 0.0, 10.0) - [/codeblock] - [codeblock] - # Infinite loop between 0.0 and 0.99 - f = wrapf(f + 0.1, 0.0, 1.0) + # Infinite loop between 5.0 and 9.9 + value = wrapf(value + 0.1, 5.0, 10.0) [/codeblock] [codeblock] # Infinite rotation (in radians) angle = wrapf(angle + 0.1, 0.0, TAU) [/codeblock] - [b]Note:[/b] If you just want to wrap between 0.0 and [code]n[/code] (where [code]n[/code] is a positive floating-point value), it is better for performance to use the [method fmod] method like [code]fmod(number, n)[/code]. - [code]wrapf[/code] is more flexible than using the [method fmod] approach by giving the user a simple control over the minimum value. It also fully supports negative numbers, e.g. [codeblock] # Infinite rotation (in radians) angle = wrapf(angle + 0.1, -PI, PI) [/codeblock] + [b]Note:[/b] If [code]min[/code] is [code]0[/code], this is equivalent to [method fposmod], so prefer using that instead. + [code]wrapf[/code] is more flexible than using the [method fposmod] approach by giving the user control over the minimum value. </description> </method> <method name="wrapi"> @@ -1348,23 +1343,15 @@ Wraps integer [code]value[/code] between [code]min[/code] and [code]max[/code]. Usable for creating loop-alike behavior or infinite surfaces. [codeblock] - # a is 0 - a = wrapi(10, 0, 10) - [/codeblock] - [codeblock] - # a is 9 - a = wrapi(-1, 0, 10) - [/codeblock] - [codeblock] - # Infinite loop between 0 and 9 - frame = wrapi(frame + 1, 0, 10) + # Infinite loop between 5 and 9 + frame = wrapi(frame + 1, 5, 10) [/codeblock] - [b]Note:[/b] If you just want to wrap between 0 and [code]n[/code] (where [code]n[/code] is a positive integer value), it is better for performance to use the modulo operator like [code]number % n[/code]. - [code]wrapi[/code] is more flexible than using the modulo approach by giving the user a simple control over the minimum value. It also fully supports negative numbers, e.g. [codeblock] # result is -2 var result = wrapi(-6, -5, -1) [/codeblock] + [b]Note:[/b] If [code]min[/code] is [code]0[/code], this is equivalent to [method posmod], so prefer using that instead. + [code]wrapi[/code] is more flexible than using the [method posmod] approach by giving the user control over the minimum value. </description> </method> <method name="yield"> @@ -1406,17 +1393,16 @@ </methods> <constants> <constant name="PI" value="3.141593"> - Constant that represents how many times the diameter of a circle fits around its perimeter. + Constant that represents how many times the diameter of a circle fits around its perimeter. This is equivalent to [code]TAU / 2[/code]. </constant> <constant name="TAU" value="6.283185"> - The circle constant, the circumference of the unit circle. + The circle constant, the circumference of the unit circle in radians. </constant> <constant name="INF" value="inf"> - A positive infinity. (For negative infinity, use -INF). + Positive infinity. For negative infinity, use -INF. </constant> <constant name="NAN" value="nan"> - Macro constant that expands to an expression of type float that represents a NaN. - The NaN values are used to identify undefined or non-representable values for floating-point elements, such as the square root of negative numbers or the result of 0/0. + "Not a Number", an invalid value. [code]NaN[/code] has special properties, including that it is not equal to itself. It is output by some invalid operations, such as dividing zero by zero. </constant> </constants> </class> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs index 3173a21986..d851abc6d3 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs @@ -486,7 +486,7 @@ namespace Godot } /// <summary> - /// Constructs a color from RGB values on the range of 0 to 1. + /// Constructs a color from RGBA values on the range of 0 to 1. /// </summary> /// <param name="r">The color's red component, typically on the range of 0 to 1.</param> /// <param name="g">The color's green component, typically on the range of 0 to 1.</param> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs index af0d474bae..2748454e48 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Plane.cs @@ -20,8 +20,9 @@ namespace Godot private Vector3 _normal; /// <summary> - /// The normal of the plane (in the plane equation: a, b, and c). - /// The normal vector must be normalized. + /// The normal of the plane, which must be normalized. + /// In the scalar equation of the plane `ax + by + cz = d`, this is + /// the vector `(a, b, c)`, where `d` is the <see cref="D"> property. /// </summary> /// <value>Equivalent to `x`, `y`, and `z`.</value> public Vector3 Normal @@ -81,6 +82,9 @@ namespace Godot /// <summary> /// The distance from the origin to the plane (in the direction of /// <see cref="Normal"/>). This value is typically non-negative. + /// In the scalar equation of the plane `ax + by + cz = d`, + /// this is `d`, while the `(a, b, c)` coordinates are represented + /// by the <see cref="Normal"> property. /// </summary> /// <value>The plane's distance from the origin.</value> public real_t D { get; set; } diff --git a/platform/android/android_keys_utils.h b/platform/android/android_keys_utils.h index fb442f4c54..857bef02d1 100644 --- a/platform/android/android_keys_utils.h +++ b/platform/android/android_keys_utils.h @@ -148,6 +148,8 @@ enum { AKEYCODE_BUTTON_START = 108, AKEYCODE_BUTTON_SELECT = 109, AKEYCODE_BUTTON_MODE = 110, + AKEYCODE_CONTROL_LEFT = 113, + AKEYCODE_CONTROL_RIGHT = 114, // NOTE: If you add a new keycode here you must also add it to several other files. // Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list. @@ -246,6 +248,8 @@ static _WinTranslatePair _ak_to_keycode[] = { { KEY_BACKSLASH, AKEYCODE_BACKSLASH }, { KEY_BRACKETLEFT, AKEYCODE_LEFT_BRACKET }, { KEY_BRACKETRIGHT, AKEYCODE_RIGHT_BRACKET }, + { KEY_CONTROL, AKEYCODE_CONTROL_LEFT }, + { KEY_CONTROL, AKEYCODE_CONTROL_RIGHT }, { KEY_UNKNOWN, 0 } }; /* diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index 3bc9e6d876..7193519a52 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -486,17 +486,40 @@ void DisplayServerAndroid::process_joy_event(DisplayServerAndroid::JoypadEvent p } } +void DisplayServerAndroid::_set_key_modifier_state(Ref<InputEventWithModifiers> ev) { + ev->set_shift(shift_mem); + ev->set_alt(alt_mem); + ev->set_metakey(meta_mem); + ev->set_control(control_mem); +} + void DisplayServerAndroid::process_key_event(int p_keycode, int p_scancode, int p_unicode_char, bool p_pressed) { Ref<InputEventKey> ev; ev.instance(); int val = p_unicode_char; int keycode = android_get_keysym(p_keycode); int phy_keycode = android_get_keysym(p_scancode); + + if (keycode == KEY_SHIFT) { + shift_mem = p_pressed; + } + if (keycode == KEY_ALT) { + alt_mem = p_pressed; + } + if (keycode == KEY_CONTROL) { + control_mem = p_pressed; + } + if (keycode == KEY_META) { + meta_mem = p_pressed; + } + ev->set_keycode(keycode); ev->set_physical_keycode(phy_keycode); ev->set_unicode(val); ev->set_pressed(p_pressed); + _set_key_modifier_state(ev); + if (val == '\n') { ev->set_keycode(KEY_ENTER); } else if (val == 61448) { @@ -629,6 +652,7 @@ void DisplayServerAndroid::process_hover(int p_type, Point2 p_pos) { case 10: { // hover exit Ref<InputEventMouseMotion> ev; ev.instance(); + _set_key_modifier_state(ev); ev->set_position(p_pos); ev->set_global_position(p_pos); ev->set_relative(p_pos - hover_prev_pos); @@ -641,6 +665,7 @@ void DisplayServerAndroid::process_hover(int p_type, Point2 p_pos) { void DisplayServerAndroid::process_double_tap(Point2 p_pos) { Ref<InputEventMouseButton> ev; ev.instance(); + _set_key_modifier_state(ev); ev->set_position(p_pos); ev->set_global_position(p_pos); ev->set_pressed(false); @@ -651,6 +676,7 @@ void DisplayServerAndroid::process_double_tap(Point2 p_pos) { void DisplayServerAndroid::process_scroll(Point2 p_pos) { Ref<InputEventPanGesture> ev; ev.instance(); + _set_key_modifier_state(ev); ev->set_position(p_pos); ev->set_delta(p_pos - scroll_prev_pos); Input::get_singleton()->parse_input_event(ev); diff --git a/platform/android/display_server_android.h b/platform/android/display_server_android.h index d64542df58..4cae52fa76 100644 --- a/platform/android/display_server_android.h +++ b/platform/android/display_server_android.h @@ -63,6 +63,11 @@ public: private: String rendering_driver; + bool alt_mem = false; + bool shift_mem = false; + bool control_mem = false; + bool meta_mem = false; + bool keep_screen_on; Vector<TouchPos> touch; @@ -84,6 +89,8 @@ private: static void _dispatch_input_events(const Ref<InputEvent> &p_event); + void _set_key_modifier_state(Ref<InputEventWithModifiers> ev); + public: static DisplayServerAndroid *get_singleton(); diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 71d05bd732..ed85256695 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -43,6 +43,7 @@ #include "editor/editor_log.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" +#include "platform/android/export/gradle_export_util.h" #include "platform/android/logo.gen.h" #include "platform/android/plugin/godot_plugin_config.h" #include "platform/android/run_icon.gen.h" @@ -2003,9 +2004,10 @@ public: EditorProgress ep("export", "Exporting for Android", 105, true); - if (bool(p_preset->get("custom_template/use_custom_build"))) { //custom build - //re-generate build.gradle and AndroidManifest.xml + bool use_custom_build = bool(p_preset->get("custom_template/use_custom_build")); + if (use_custom_build) { + //re-generate build.gradle and AndroidManifest.xml { //test that installed build version is alright FileAccessRef f = FileAccess::open("res://android/.build_version", FileAccess::READ); if (!f) { @@ -2018,6 +2020,14 @@ public: return ERR_UNCONFIGURED; } } + + // TODO: should we use "package/name" or "application/config/name"? + String project_name = get_project_name(p_preset->get("package/name")); + // instead of calling _fix_resources + Error err = _create_project_name_strings_files(p_preset, project_name); + if (err != OK) { + EditorNode::add_io_error("Unable to overwrite res://android/build/res/*.xml files with project name"); + } //build project if custom build is enabled String sdk_path = EDITOR_GET("export/android/custom_build_sdk_path"); @@ -2202,7 +2212,9 @@ public: } if (file == "resources.arsc") { - _fix_resources(p_preset, data); + if (!use_custom_build) { + _fix_resources(p_preset, data); + } } for (int i = 0; i < icon_densities_count; ++i) { diff --git a/platform/android/export/gradle_export_util.h b/platform/android/export/gradle_export_util.h index f988047483..622860c307 100644 --- a/platform/android/export/gradle_export_util.h +++ b/platform/android/export/gradle_export_util.h @@ -37,6 +37,13 @@ #include "core/os/os.h" #include "editor/editor_export.h" +const String godot_project_name_xml_string = R"(<?xml version="1.0" encoding="utf-8"?> +<!--WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> +<resources> + <string name="godot_project_name_string">%s</string> +</resources> +)"; + // Utility method used to create a directory. Error create_directory(const String &p_dir) { if (!DirAccess::exists(p_dir)) { @@ -94,8 +101,45 @@ Error store_string_at_path(const String &p_path, const String &p_data) { // This method will be called ONLY when custom build is enabled. Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) { String dst_path = p_path.replace_first("res://", "res://android/build/assets/"); - Error err = store_file_at_path(dst_path, p_data, Z_NO_COMPRESSION); + Error err = store_file_at_path(dst_path, p_data); return err; } +// Creates strings.xml files inside the gradle project for different locales. +Error _create_project_name_strings_files(const Ref<EditorExportPreset> &p_preset, const String &project_name) { + // Stores the string into the default values directory. + String processed_default_xml_string = vformat(godot_project_name_xml_string, project_name.xml_escape(true)); + store_string_at_path("res://android/build/res/values/godot_project_name_string.xml", processed_default_xml_string); + + // Searches the Gradle project res/ directory to find all supported locales + DirAccessRef da = DirAccess::open("res://android/build/res"); + if (!da) { + return ERR_CANT_OPEN; + } + da->list_dir_begin(); + while (true) { + String file = da->get_next(); + if (file == "") { + break; + } + if (!file.begins_with("values-")) { + // NOTE: This assumes all directories that start with "values-" are for localization. + continue; + } + String locale = file.replace("values-", "").replace("-r", "_"); + String property_name = "application/config/name_" + locale; + String locale_directory = "res://android/build/res/" + file + "/godot_project_name_string.xml"; + if (ProjectSettings::get_singleton()->has_setting(property_name)) { + String locale_project_name = ProjectSettings::get_singleton()->get(property_name); + String processed_xml_string = vformat(godot_project_name_xml_string, locale_project_name.xml_escape(true)); + store_string_at_path(locale_directory, processed_xml_string); + } else { + // TODO: Once the legacy build system is deprecated we don't need to have xml files for this else branch + store_string_at_path(locale_directory, processed_default_xml_string); + } + } + da->list_dir_end(); + return OK; +} + #endif //GODOT_GRADLE_EXPORT_UTIL_H diff --git a/platform/android/java/lib/res/values-ar/strings.xml b/platform/android/java/app/res/values-ar/godot_project_name_string.xml index 77cd61ea51..23aa5cf3e1 100644 --- a/platform/android/java/lib/res/values-ar/strings.xml +++ b/platform/android/java/app/res/values-ar/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-ar</string> </resources> diff --git a/platform/android/java/lib/res/values-bg/strings.xml b/platform/android/java/app/res/values-bg/godot_project_name_string.xml index 0f42d1f22b..dbb7e04ae5 100644 --- a/platform/android/java/lib/res/values-bg/strings.xml +++ b/platform/android/java/app/res/values-bg/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-bg</string> </resources> diff --git a/platform/android/java/lib/res/values-ca/strings.xml b/platform/android/java/app/res/values-ca/godot_project_name_string.xml index 291a44d5e2..709d0961e6 100644 --- a/platform/android/java/lib/res/values-ca/strings.xml +++ b/platform/android/java/app/res/values-ca/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-ca</string> </resources> diff --git a/platform/android/java/lib/res/values-cs/strings.xml b/platform/android/java/app/res/values-cs/godot_project_name_string.xml index 83ff73e12a..ab248a8032 100644 --- a/platform/android/java/lib/res/values-cs/strings.xml +++ b/platform/android/java/app/res/values-cs/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-cs</string> </resources> diff --git a/platform/android/java/lib/res/values-da/strings.xml b/platform/android/java/app/res/values-da/godot_project_name_string.xml index fd251a7c90..906bf44f57 100644 --- a/platform/android/java/lib/res/values-da/strings.xml +++ b/platform/android/java/app/res/values-da/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-da</string> </resources> diff --git a/platform/android/java/lib/res/values-de/strings.xml b/platform/android/java/app/res/values-de/godot_project_name_string.xml index f6e80b0b1a..0cacb0175f 100644 --- a/platform/android/java/lib/res/values-de/strings.xml +++ b/platform/android/java/app/res/values-de/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-de</string> </resources> diff --git a/platform/android/java/lib/res/values-el/strings.xml b/platform/android/java/app/res/values-el/godot_project_name_string.xml index adcdf13eb1..047de616a5 100644 --- a/platform/android/java/lib/res/values-el/strings.xml +++ b/platform/android/java/app/res/values-el/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-el</string> </resources> diff --git a/platform/android/java/lib/res/values-en/strings.xml b/platform/android/java/app/res/values-en/godot_project_name_string.xml index 1b251c9ab6..bb3a5dbef3 100644 --- a/platform/android/java/lib/res/values-en/strings.xml +++ b/platform/android/java/app/res/values-en/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-en</string> </resources> diff --git a/platform/android/java/lib/res/values-es-rES/strings.xml b/platform/android/java/app/res/values-es-rES/godot_project_name_string.xml index b580a8270b..d4537f3496 100644 --- a/platform/android/java/lib/res/values-es-rES/strings.xml +++ b/platform/android/java/app/res/values-es-rES/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-es_ES</string> </resources> diff --git a/platform/android/java/lib/res/values-es/strings.xml b/platform/android/java/app/res/values-es/godot_project_name_string.xml index 6aedd6870b..d63a16022e 100644 --- a/platform/android/java/lib/res/values-es/strings.xml +++ b/platform/android/java/app/res/values-es/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-es</string> </resources> diff --git a/platform/android/java/app/res/values-fa/godot_project_name_string.xml b/platform/android/java/app/res/values-fa/godot_project_name_string.xml new file mode 100644 index 0000000000..c303f13d5f --- /dev/null +++ b/platform/android/java/app/res/values-fa/godot_project_name_string.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> +<resources> + <string name="godot_project_name_string">godot-project-name-fa</string> +</resources> diff --git a/platform/android/java/lib/res/values-fi/strings.xml b/platform/android/java/app/res/values-fi/godot_project_name_string.xml index bd7ef059ab..bd6005574a 100644 --- a/platform/android/java/lib/res/values-fi/strings.xml +++ b/platform/android/java/app/res/values-fi/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-fi</string> </resources> diff --git a/platform/android/java/lib/res/values-fr/strings.xml b/platform/android/java/app/res/values-fr/godot_project_name_string.xml index 03994099cf..2e94b65a20 100644 --- a/platform/android/java/lib/res/values-fr/strings.xml +++ b/platform/android/java/app/res/values-fr/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-fr</string> </resources> diff --git a/platform/android/java/lib/res/values-hi/strings.xml b/platform/android/java/app/res/values-hi/godot_project_name_string.xml index 60d3b46861..0bf75dcd56 100644 --- a/platform/android/java/lib/res/values-hi/strings.xml +++ b/platform/android/java/app/res/values-hi/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-hi</string> </resources> diff --git a/platform/android/java/lib/res/values-hr/strings.xml b/platform/android/java/app/res/values-hr/godot_project_name_string.xml index e552a6f6ec..d3f75910f9 100644 --- a/platform/android/java/lib/res/values-hr/strings.xml +++ b/platform/android/java/app/res/values-hr/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-hr</string> </resources> diff --git a/platform/android/java/lib/res/values-hu/strings.xml b/platform/android/java/app/res/values-hu/godot_project_name_string.xml index ed21411acb..012b613af3 100644 --- a/platform/android/java/lib/res/values-hu/strings.xml +++ b/platform/android/java/app/res/values-hu/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-hu</string> </resources> diff --git a/platform/android/java/app/res/values-in/godot_project_name_string.xml b/platform/android/java/app/res/values-in/godot_project_name_string.xml new file mode 100644 index 0000000000..eedecff7a1 --- /dev/null +++ b/platform/android/java/app/res/values-in/godot_project_name_string.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> +<resources> + <string name="godot_project_name_string">godot-project-name-in</string> +</resources> diff --git a/platform/android/java/lib/res/values-it/strings.xml b/platform/android/java/app/res/values-it/godot_project_name_string.xml index 880b87e030..7e734047c4 100644 --- a/platform/android/java/lib/res/values-it/strings.xml +++ b/platform/android/java/app/res/values-it/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-it</string> </resources> diff --git a/platform/android/java/app/res/values-iw/godot_project_name_string.xml b/platform/android/java/app/res/values-iw/godot_project_name_string.xml new file mode 100644 index 0000000000..03893f0cbb --- /dev/null +++ b/platform/android/java/app/res/values-iw/godot_project_name_string.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> +<resources> + <string name="godot_project_name_string">godot-project-name-iw</string> +</resources> diff --git a/platform/android/java/lib/res/values-ja/strings.xml b/platform/android/java/app/res/values-ja/godot_project_name_string.xml index 27d3ba521e..f9dd4fab0d 100644 --- a/platform/android/java/lib/res/values-ja/strings.xml +++ b/platform/android/java/app/res/values-ja/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-ja</string> </resources> diff --git a/platform/android/java/app/res/values-ko/godot_project_name_string.xml b/platform/android/java/app/res/values-ko/godot_project_name_string.xml new file mode 100644 index 0000000000..26f5dac176 --- /dev/null +++ b/platform/android/java/app/res/values-ko/godot_project_name_string.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> +<resources> + <string name="godot_project_name_string">godot-project-name-ko</string> +</resources> diff --git a/platform/android/java/lib/res/values-lt/strings.xml b/platform/android/java/app/res/values-lt/godot_project_name_string.xml index 10a93926db..1c2e976cc5 100644 --- a/platform/android/java/lib/res/values-lt/strings.xml +++ b/platform/android/java/app/res/values-lt/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-lt</string> </resources> diff --git a/platform/android/java/lib/res/values-lv/strings.xml b/platform/android/java/app/res/values-lv/godot_project_name_string.xml index 4f230b97f8..b5e638ed73 100644 --- a/platform/android/java/lib/res/values-lv/strings.xml +++ b/platform/android/java/app/res/values-lv/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-lv</string> </resources> diff --git a/platform/android/java/lib/res/values-nb/strings.xml b/platform/android/java/app/res/values-nb/godot_project_name_string.xml index a85a3da39a..e6d89d6a3f 100644 --- a/platform/android/java/lib/res/values-nb/strings.xml +++ b/platform/android/java/app/res/values-nb/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-nb</string> </resources> diff --git a/platform/android/java/lib/res/values-nl/strings.xml b/platform/android/java/app/res/values-nl/godot_project_name_string.xml index c459f64397..93cb3a3878 100644 --- a/platform/android/java/lib/res/values-nl/strings.xml +++ b/platform/android/java/app/res/values-nl/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-nl</string> </resources> diff --git a/platform/android/java/lib/res/values-pl/strings.xml b/platform/android/java/app/res/values-pl/godot_project_name_string.xml index 34a846cc78..e5d6ac74fb 100644 --- a/platform/android/java/lib/res/values-pl/strings.xml +++ b/platform/android/java/app/res/values-pl/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-pl</string> </resources> diff --git a/platform/android/java/lib/res/values-pt/strings.xml b/platform/android/java/app/res/values-pt/godot_project_name_string.xml index 5f7a875eb5..a4624655c5 100644 --- a/platform/android/java/lib/res/values-pt/strings.xml +++ b/platform/android/java/app/res/values-pt/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-pt</string> </resources> diff --git a/platform/android/java/lib/res/values-ro/strings.xml b/platform/android/java/app/res/values-ro/godot_project_name_string.xml index de990e789b..19e026637e 100644 --- a/platform/android/java/lib/res/values-ro/strings.xml +++ b/platform/android/java/app/res/values-ro/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-ro</string> </resources> diff --git a/platform/android/java/lib/res/values-ru/strings.xml b/platform/android/java/app/res/values-ru/godot_project_name_string.xml index 73d8a27443..284845241f 100644 --- a/platform/android/java/lib/res/values-ru/strings.xml +++ b/platform/android/java/app/res/values-ru/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-ru</string> </resources> diff --git a/platform/android/java/lib/res/values-sk/strings.xml b/platform/android/java/app/res/values-sk/godot_project_name_string.xml index 053960efed..f8ab4a5b59 100644 --- a/platform/android/java/lib/res/values-sk/strings.xml +++ b/platform/android/java/app/res/values-sk/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-sk</string> </resources> diff --git a/platform/android/java/lib/res/values-sl/strings.xml b/platform/android/java/app/res/values-sl/godot_project_name_string.xml index d6dff8289a..98bd53e8d2 100644 --- a/platform/android/java/lib/res/values-sl/strings.xml +++ b/platform/android/java/app/res/values-sl/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-sl</string> </resources> diff --git a/platform/android/java/lib/res/values-sr/strings.xml b/platform/android/java/app/res/values-sr/godot_project_name_string.xml index b7e79e89ea..3f400f2a4d 100644 --- a/platform/android/java/lib/res/values-sr/strings.xml +++ b/platform/android/java/app/res/values-sr/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-sr</string> </resources> diff --git a/platform/android/java/lib/res/values-sv/strings.xml b/platform/android/java/app/res/values-sv/godot_project_name_string.xml index 9436c3870a..8670b7c9aa 100644 --- a/platform/android/java/lib/res/values-sv/strings.xml +++ b/platform/android/java/app/res/values-sv/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-sv</string> </resources> diff --git a/platform/android/java/lib/res/values-th/strings.xml b/platform/android/java/app/res/values-th/godot_project_name_string.xml index 629d77b9c2..a1cc1bcd49 100644 --- a/platform/android/java/lib/res/values-th/strings.xml +++ b/platform/android/java/app/res/values-th/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-th</string> </resources> diff --git a/platform/android/java/lib/res/values-tl/strings.xml b/platform/android/java/app/res/values-tl/godot_project_name_string.xml index f8832d6b1f..6d66d114cf 100644 --- a/platform/android/java/lib/res/values-tl/strings.xml +++ b/platform/android/java/app/res/values-tl/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-tl</string> </resources> diff --git a/platform/android/java/lib/res/values-tr/strings.xml b/platform/android/java/app/res/values-tr/godot_project_name_string.xml index f3a8f57de4..ba3bd7de36 100644 --- a/platform/android/java/lib/res/values-tr/strings.xml +++ b/platform/android/java/app/res/values-tr/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-tr</string> </resources> diff --git a/platform/android/java/lib/res/values-uk/strings.xml b/platform/android/java/app/res/values-uk/godot_project_name_string.xml index 8ba2bf86aa..5f14ab25a0 100644 --- a/platform/android/java/lib/res/values-uk/strings.xml +++ b/platform/android/java/app/res/values-uk/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-uk</string> </resources> diff --git a/platform/android/java/lib/res/values-vi/strings.xml b/platform/android/java/app/res/values-vi/godot_project_name_string.xml index 8bf063ed82..295378e111 100644 --- a/platform/android/java/lib/res/values-vi/strings.xml +++ b/platform/android/java/app/res/values-vi/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-vi</string> </resources> diff --git a/platform/android/java/lib/res/values-zh-rHK/strings.xml b/platform/android/java/app/res/values-zh-rHK/godot_project_name_string.xml index 8a6269da0f..40ab0f285a 100644 --- a/platform/android/java/lib/res/values-zh-rHK/strings.xml +++ b/platform/android/java/app/res/values-zh-rHK/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-zh_HK</string> </resources> diff --git a/platform/android/java/lib/res/values-zh-rTW/strings.xml b/platform/android/java/app/res/values-zh-rTW/godot_project_name_string.xml index b1bb39d5d6..095bd564e2 100644 --- a/platform/android/java/lib/res/values-zh-rTW/strings.xml +++ b/platform/android/java/app/res/values-zh-rTW/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-zh_TW</string> </resources> diff --git a/platform/android/java/lib/res/values-zh-rCN/strings.xml b/platform/android/java/app/res/values-zh/godot_project_name_string.xml index 6668c56bd9..31aa8c273a 100644 --- a/platform/android/java/lib/res/values-zh-rCN/strings.xml +++ b/platform/android/java/app/res/values-zh/godot_project_name_string.xml @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> <resources> <string name="godot_project_name_string">godot-project-name-zh</string> </resources> diff --git a/platform/android/java/app/res/values/godot_project_name_string.xml b/platform/android/java/app/res/values/godot_project_name_string.xml new file mode 100644 index 0000000000..7ec2738896 --- /dev/null +++ b/platform/android/java/app/res/values/godot_project_name_string.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- WARNING: THIS FILE WILL BE OVERWRITTEN AT BUILD TIME--> +<resources> + <string name="godot_project_name_string">godot-project-name</string> +</resources> diff --git a/platform/android/java/lib/res/values-fa/strings.xml b/platform/android/java/lib/res/values-fa/strings.xml index f1e29013c4..60b01accf1 100644 --- a/platform/android/java/lib/res/values-fa/strings.xml +++ b/platform/android/java/lib/res/values-fa/strings.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string name="godot_project_name_string">godot-project-name-fa</string> <string name="text_paused_cellular">آیا می خواهید بر روی اتصال داده همراه دانلود را شروع کنید؟ بر اساس نوع سطح داده شما این ممکن است برای شما هزینه مالی داشته باشد.</string> <string name="text_paused_cellular_2">اگر نمی خواهید بر روی اتصال داده همراه دانلود را شروع کنید ، دانلود به صورت خودکار در زمان دسترسی به وای-فای شروع می شود.</string> <string name="text_button_resume_cellular">ادامه دانلود</string> diff --git a/platform/android/java/lib/res/values-in/strings.xml b/platform/android/java/lib/res/values-in/strings.xml deleted file mode 100644 index 169b65decb..0000000000 --- a/platform/android/java/lib/res/values-in/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="godot_project_name_string">godot-project-name-id</string> -</resources> diff --git a/platform/android/java/lib/res/values-iw/strings.xml b/platform/android/java/lib/res/values-iw/strings.xml deleted file mode 100644 index b4826798c7..0000000000 --- a/platform/android/java/lib/res/values-iw/strings.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <string name="godot_project_name_string">godot-project-name-he</string> -</resources> diff --git a/platform/android/java/lib/res/values-ko/strings.xml b/platform/android/java/lib/res/values-ko/strings.xml index efc5c7e015..7b62345977 100644 --- a/platform/android/java/lib/res/values-ko/strings.xml +++ b/platform/android/java/lib/res/values-ko/strings.xml @@ -1,6 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string name="godot_project_name_string">godot-project-name-ko</string> <string name="text_paused_cellular">모바일 네트워크를 사용하여 다운로드 하시겠습니까? 남은 데이터 사용량에 따라, 요금이 부과될 수 있습니다.</string> <string name="text_paused_cellular_2">모바일 네트워크를 사용하여 다운로드 하지 않을 경우, 와이파이 연결이 가능할 때 자동적으로 다운로드가 이루어집니다.</string> <string name="text_button_resume_cellular">다운로드 계속하기</string> diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index 1b55090451..1ae400abb5 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -467,6 +467,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC final Activity activity = getActivity(); Window window = activity.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); + window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); mClipboard = (ClipboardManager)activity.getSystemService(Context.CLIPBOARD_SERVICE); pluginRegistry = GodotPluginRegistry.initializePluginRegistry(this); diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java index 4da2f31250..d169f46599 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotGLRenderView.java @@ -117,6 +117,11 @@ public class GodotGLRenderView extends GLSurfaceView implements GodotRenderView godot.onBackPressed(); } + @Override + public GodotInputHandler getInputHandler() { + return inputHandler; + } + @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouchEvent(MotionEvent event) { diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java index 27e63f3a66..68b8a16641 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java @@ -30,6 +30,8 @@ package org.godotengine.godot; +import org.godotengine.godot.input.GodotInputHandler; + import android.view.SurfaceView; public interface GodotRenderView { @@ -43,4 +45,6 @@ public interface GodotRenderView { abstract public void onActivityResumed(); abstract public void onBackPressed(); + + abstract public GodotInputHandler getInputHandler(); } diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java index aace593bae..65708389c3 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java @@ -90,6 +90,11 @@ public class GodotVulkanRenderView extends VkSurfaceView implements GodotRenderV godot.onBackPressed(); } + @Override + public GodotInputHandler getInputHandler() { + return mInputHandler; + } + @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouchEvent(MotionEvent event) { diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java index 7f596575a8..c0defd008e 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotEditText.java @@ -155,14 +155,35 @@ public class GodotEditText extends EditText { // =========================================================== @Override public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) { - super.onKeyDown(keyCode, keyEvent); - - /* Let GlSurfaceView get focus if back key is input. */ + /* Let SurfaceView get focus if back key is input. */ if (keyCode == KeyEvent.KEYCODE_BACK) { mRenderView.getView().requestFocus(); } - return true; + // pass event to godot in special cases + if (needHandlingInGodot(keyCode, keyEvent) && mRenderView.getInputHandler().onKeyDown(keyCode, keyEvent)) { + return true; + } else { + return super.onKeyDown(keyCode, keyEvent); + } + } + + @Override + public boolean onKeyUp(int keyCode, KeyEvent keyEvent) { + if (needHandlingInGodot(keyCode, keyEvent) && mRenderView.getInputHandler().onKeyUp(keyCode, keyEvent)) { + return true; + } else { + return super.onKeyUp(keyCode, keyEvent); + } + } + + private boolean needHandlingInGodot(int keyCode, KeyEvent keyEvent) { + boolean isArrowKey = keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || + keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT; + boolean isModifiedKey = keyEvent.isAltPressed() || keyEvent.isCtrlPressed() || keyEvent.isSymPressed() || + keyEvent.isFunctionPressed() || keyEvent.isMetaPressed(); + return isArrowKey || keyCode == KeyEvent.KEYCODE_TAB || KeyEvent.isModifierKey(keyCode) || + isModifiedKey; } // =========================================================== diff --git a/platform/osx/detect.py b/platform/osx/detect.py index ff4c024551..ca28e1e70e 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -24,7 +24,7 @@ def get_opts(): from SCons.Variables import BoolVariable, EnumVariable return [ - ("osxcross_sdk", "OSXCross SDK version", "darwin14"), + ("osxcross_sdk", "OSXCross SDK version", "darwin16"), ("MACOS_SDK_PATH", "Path to the macOS SDK", ""), BoolVariable( "use_static_mvk", @@ -86,16 +86,16 @@ def configure(env): if "OSXCROSS_ROOT" in os.environ: env["osxcross"] = True - if not "osxcross" in env: # regular native build - if env["arch"] == "arm64": - print("Building for macOS 10.15+, platform arm64.") - env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15", "-target", "arm64-apple-macos10.15"]) - env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15", "-target", "arm64-apple-macos10.15"]) - else: - print("Building for macOS 10.12+, platform x86-64.") - env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) - env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) + if env["arch"] == "arm64": + print("Building for macOS 10.15+, platform arm64.") + env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15", "-target", "arm64-apple-macos10.15"]) + env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15", "-target", "arm64-apple-macos10.15"]) + else: + print("Building for macOS 10.12+, platform x86-64.") + env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) + env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) + if not "osxcross" in env: # regular native build if env["macports_clang"] != "no": mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpclangver = env["macports_clang"] @@ -116,7 +116,10 @@ def configure(env): else: # osxcross build root = os.environ.get("OSXCROSS_ROOT", 0) - basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" + if env["arch"] == "arm64": + basecmd = root + "/target/bin/arm64-apple-" + env["osxcross_sdk"] + "-" + else: + basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" ccache_path = os.environ.get("CCACHE") if ccache_path is None: diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 9d7615a319..5e209a6e6b 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -3492,9 +3492,7 @@ DisplayServerOSX::WindowID DisplayServerOSX::_create_window(WindowMode p_mode, c wd.window_view = [[GodotContentView alloc] init]; ERR_FAIL_COND_V_MSG(wd.window_view == nil, INVALID_WINDOW_ID, "Can't create a window view"); [wd.window_view setWindowID:window_id_counter]; - if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_14) { - [wd.window_view setWantsLayer:TRUE]; - } + [wd.window_view setWantsLayer:TRUE]; [wd.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; [wd.window_object setContentView:wd.window_view]; diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 0251ffe664..6ee9b6d698 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -170,7 +170,7 @@ void DisplayServerWindows::clipboard_set(const String &p_text) { // Convert LF line endings to CRLF in clipboard content // Otherwise, line endings won't be visible when pasted in other software - String text = p_text.replace("\n", "\r\n"); + String text = p_text.replace("\r\n", "\n").replace("\n", "\r\n"); // avoid \r\r\n if (!OpenClipboard(windows[last_focused_window].hWnd)) { ERR_FAIL_MSG("Unable to open clipboard."); diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 72ae75b236..fc021e5532 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -358,6 +358,7 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { set_global_transform(state->get_transform()); linear_velocity = state->get_linear_velocity(); angular_velocity = state->get_angular_velocity(); + inverse_inertia_tensor = state->get_inverse_inertia_tensor(); if (sleeping != state->is_sleeping()) { sleeping = state->is_sleeping(); emit_signal(SceneStringNames::get_singleton()->sleeping_state_changed); @@ -594,6 +595,10 @@ Vector3 RigidBody3D::get_angular_velocity() const { return angular_velocity; } +Basis RigidBody3D::get_inverse_inertia_tensor() { + return inverse_inertia_tensor; +} + void RigidBody3D::set_use_custom_integrator(bool p_enable) { if (custom_integrator == p_enable) { return; @@ -760,6 +765,8 @@ void RigidBody3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_angular_velocity", "angular_velocity"), &RigidBody3D::set_angular_velocity); ClassDB::bind_method(D_METHOD("get_angular_velocity"), &RigidBody3D::get_angular_velocity); + ClassDB::bind_method(D_METHOD("get_inverse_inertia_tensor"), &RigidBody3D::get_inverse_inertia_tensor); + ClassDB::bind_method(D_METHOD("set_gravity_scale", "gravity_scale"), &RigidBody3D::set_gravity_scale); ClassDB::bind_method(D_METHOD("get_gravity_scale"), &RigidBody3D::get_gravity_scale); diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index 413b587fc4..9830a55183 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -123,6 +123,7 @@ protected: Vector3 linear_velocity; Vector3 angular_velocity; + Basis inverse_inertia_tensor; real_t gravity_scale; real_t linear_damp; real_t angular_damp; @@ -201,6 +202,8 @@ public: void set_angular_velocity(const Vector3 &p_velocity); Vector3 get_angular_velocity() const override; + Basis get_inverse_inertia_tensor(); + void set_gravity_scale(real_t p_gravity_scale); real_t get_gravity_scale() const; diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 854db5fee2..bd4396d680 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -701,21 +701,21 @@ void Tween::_tween_process(float p_delta) { } // Are all of the tweens complete? - bool all_finished = true; + int any_unfinished = 0; // For each tween we wish to interpolate... for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { // Get the data from it InterpolateData &data = E->get(); - // Track if we hit one that isn't finished yet - all_finished = all_finished && data.finish; - // Is the data not active or already finished? No need to go any further if (!data.active || data.finish) { continue; } + // Track if we hit one that isn't finished yet + any_unfinished++; + // Get the target object for this interpolation Object *object = ObjectDB::get_instance(data.id); if (object == nullptr) { @@ -802,17 +802,15 @@ void Tween::_tween_process(float p_delta) { // If we are not repeating the tween, remove it if (!repeat) { call_deferred("_remove_by_uid", data.uid); + any_unfinished--; } - } else if (!repeat) { - // Check whether all tweens are finished - all_finished = all_finished && data.finish; } } // One less update left to go pending_update--; // If all tweens are completed, we no longer need to be active - if (all_finished) { + if (any_unfinished == 0) { set_active(false); emit_signal("tween_all_completed"); } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 47761d724e..eeb7f9430d 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3419,6 +3419,8 @@ void Tree::scroll_to_item(TreeItem *p_item) { TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards) { TreeItem *from = p_at; + TreeItem *loop = nullptr; // Safe-guard against infinite loop. + while (p_at) { for (int i = 0; i < columns.size(); i++) { if (p_at->get_text(i).findn(p_find) == 0 && (!p_selectable || p_at->is_selectable(i))) { @@ -3438,6 +3440,12 @@ TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_c if ((p_at) == from) { break; } + + if (!loop) { + loop = p_at; + } else if (loop == p_at) { + break; + } } return nullptr; diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 3d99556a10..99f87dd6ed 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -290,6 +290,21 @@ Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const V return ret; } +String DynamicFontAtSize::get_available_chars() const { + String chars; + + FT_UInt gindex; + FT_ULong charcode = FT_Get_First_Char(face, &gindex); + while (gindex != 0) { + if (charcode != 0) { + chars += CharType(charcode); + } + charcode = FT_Get_Next_Char(face, charcode, &gindex); + } + + return chars; +} + float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks, bool p_advance_only, bool p_outline) const { if (!valid) { return 0; @@ -849,6 +864,25 @@ Size2 DynamicFont::get_char_size(CharType p_char, CharType p_next) const { return ret; } +String DynamicFont::get_available_chars() const { + if (!data_at_size.is_valid()) { + return ""; + } + + String chars = data_at_size->get_available_chars(); + + for (int i = 0; i < fallback_data_at_size.size(); i++) { + String fallback_chars = fallback_data_at_size[i]->get_available_chars(); + for (int j = 0; j < fallback_chars.length(); j++) { + if (chars.find_char(fallback_chars[j]) == -1) { + chars += fallback_chars[j]; + } + } + } + + return chars; +} + bool DynamicFont::is_distance_field_hint() const { return false; } @@ -964,6 +998,8 @@ void DynamicFont::_bind_methods() { ClassDB::bind_method(D_METHOD("set_font_data", "data"), &DynamicFont::set_font_data); ClassDB::bind_method(D_METHOD("get_font_data"), &DynamicFont::get_font_data); + ClassDB::bind_method(D_METHOD("get_available_chars"), &DynamicFont::get_available_chars); + ClassDB::bind_method(D_METHOD("set_size", "data"), &DynamicFont::set_size); ClassDB::bind_method(D_METHOD("get_size"), &DynamicFont::get_size); diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index 0afad428b3..e8637e7e34 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -189,6 +189,7 @@ public: float get_underline_thickness() const; Size2 get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks) const; + String get_available_chars() const; float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks, bool p_advance_only = false, bool p_outline = false) const; @@ -277,6 +278,7 @@ public: virtual float get_underline_thickness() const override; virtual Size2 get_char_size(CharType p_char, CharType p_next = 0) const override; + String get_available_chars() const; virtual bool is_distance_field_hint() const override; diff --git a/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp index f2a59151f3..3854f4c2a4 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.cpp @@ -238,7 +238,7 @@ void RasterizerSceneRD::_sdfgi_erase(RenderBuffers *rb) { const Vector3i RasterizerSceneRD::SDFGI::Cascade::DIRTY_ALL = Vector3i(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF); void RasterizerSceneRD::sdfgi_update(RID p_render_buffers, RID p_environment, const Vector3 &p_world_position) { - Environent *env = environment_owner.getornull(p_environment); + Environment *env = environment_owner.getornull(p_environment); RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); bool needs_sdfgi = env && env->sdfgi_enabled; @@ -1142,7 +1142,7 @@ void RasterizerSceneRD::sdfgi_update_probes(RID p_render_buffers, RID p_environm if (rb->sdfgi == nullptr) { return; } - Environent *env = environment_owner.getornull(p_environment); + Environment *env = environment_owner.getornull(p_environment); RENDER_TIMESTAMP(">SDFGI Update Probes"); @@ -1380,7 +1380,7 @@ void RasterizerSceneRD::_process_gi(RID p_render_buffers, RID p_normal_roughness RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); ERR_FAIL_COND(rb == nullptr); - Environent *env = environment_owner.getornull(p_environment); + Environment *env = environment_owner.getornull(p_environment); GI::PushConstant push_constant; @@ -2695,53 +2695,53 @@ RasterizerStorageRD::MaterialData *RasterizerSceneRD::_create_sky_material_func( } RID RasterizerSceneRD::environment_create() { - return environment_owner.make_rid(Environent()); + return environment_owner.make_rid(Environment()); } void RasterizerSceneRD::environment_set_background(RID p_env, RS::EnvironmentBG p_bg) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->background = p_bg; } void RasterizerSceneRD::environment_set_sky(RID p_env, RID p_sky) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->sky = p_sky; } void RasterizerSceneRD::environment_set_sky_custom_fov(RID p_env, float p_scale) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->sky_custom_fov = p_scale; } void RasterizerSceneRD::environment_set_sky_orientation(RID p_env, const Basis &p_orientation) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->sky_orientation = p_orientation; } void RasterizerSceneRD::environment_set_bg_color(RID p_env, const Color &p_color) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->bg_color = p_color; } void RasterizerSceneRD::environment_set_bg_energy(RID p_env, float p_energy) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->bg_energy = p_energy; } void RasterizerSceneRD::environment_set_canvas_max_layer(RID p_env, int p_max_layer) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->canvas_max_layer = p_max_layer; } void RasterizerSceneRD::environment_set_ambient_light(RID p_env, const Color &p_color, RS::EnvironmentAmbientSource p_ambient, float p_energy, float p_sky_contribution, RS::EnvironmentReflectionSource p_reflection_source, const Color &p_ao_color) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->ambient_light = p_color; env->ambient_source = p_ambient; @@ -2752,85 +2752,85 @@ void RasterizerSceneRD::environment_set_ambient_light(RID p_env, const Color &p_ } RS::EnvironmentBG RasterizerSceneRD::environment_get_background(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, RS::ENV_BG_MAX); return env->background; } RID RasterizerSceneRD::environment_get_sky(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, RID()); return env->sky; } float RasterizerSceneRD::environment_get_sky_custom_fov(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->sky_custom_fov; } Basis RasterizerSceneRD::environment_get_sky_orientation(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Basis()); return env->sky_orientation; } Color RasterizerSceneRD::environment_get_bg_color(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Color()); return env->bg_color; } float RasterizerSceneRD::environment_get_bg_energy(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->bg_energy; } int RasterizerSceneRD::environment_get_canvas_max_layer(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->canvas_max_layer; } Color RasterizerSceneRD::environment_get_ambient_light_color(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Color()); return env->ambient_light; } RS::EnvironmentAmbientSource RasterizerSceneRD::environment_get_ambient_source(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, RS::ENV_AMBIENT_SOURCE_BG); return env->ambient_source; } float RasterizerSceneRD::environment_get_ambient_light_energy(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->ambient_light_energy; } float RasterizerSceneRD::environment_get_ambient_sky_contribution(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, 0); return env->ambient_sky_contribution; } RS::EnvironmentReflectionSource RasterizerSceneRD::environment_get_reflection_source(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, RS::ENV_REFLECTION_SOURCE_DISABLED); return env->reflection_source; } Color RasterizerSceneRD::environment_get_ao_color(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Color()); return env->ao_color; } void RasterizerSceneRD::environment_set_tonemap(RID p_env, RS::EnvironmentToneMapper p_tone_mapper, float p_exposure, float p_white, bool p_auto_exposure, float p_min_luminance, float p_max_luminance, float p_auto_exp_speed, float p_auto_exp_scale) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->exposure = p_exposure; env->tone_mapper = p_tone_mapper; @@ -2846,7 +2846,7 @@ void RasterizerSceneRD::environment_set_tonemap(RID p_env, RS::EnvironmentToneMa } void RasterizerSceneRD::environment_set_glow(RID p_env, bool p_enable, int p_level_flags, float p_intensity, float p_strength, float p_mix, float p_bloom_threshold, RS::EnvironmentGlowBlendMode p_blend_mode, float p_hdr_bleed_threshold, float p_hdr_bleed_scale, float p_hdr_luminance_cap) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->glow_enabled = p_enable; env->glow_levels = p_level_flags; @@ -2865,7 +2865,7 @@ void RasterizerSceneRD::environment_glow_set_use_bicubic_upscale(bool p_enable) } void RasterizerSceneRD::environment_set_sdfgi(RID p_env, bool p_enable, RS::EnvironmentSDFGICascades p_cascades, float p_min_cell_size, RS::EnvironmentSDFGIYScale p_y_scale, bool p_use_occlusion, bool p_use_multibounce, bool p_read_sky, float p_energy, float p_normal_bias, float p_probe_bias) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->sdfgi_enabled = p_enable; @@ -2889,7 +2889,7 @@ void RasterizerSceneRD::environment_set_sdfgi_frames_to_converge(RS::Environment } void RasterizerSceneRD::environment_set_ssr(RID p_env, bool p_enable, int p_max_steps, float p_fade_int, float p_fade_out, float p_depth_tolerance) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->ssr_enabled = p_enable; @@ -2908,7 +2908,7 @@ RS::EnvironmentSSRRoughnessQuality RasterizerSceneRD::environment_get_ssr_roughn } void RasterizerSceneRD::environment_set_ssao(RID p_env, bool p_enable, float p_radius, float p_intensity, float p_bias, float p_light_affect, float p_ao_channel_affect, RS::EnvironmentSSAOBlur p_blur, float p_bilateral_sharpness) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND(!env); env->ssao_enabled = p_enable; @@ -2926,30 +2926,30 @@ void RasterizerSceneRD::environment_set_ssao_quality(RS::EnvironmentSSAOQuality } bool RasterizerSceneRD::environment_is_ssao_enabled(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, false); return env->ssao_enabled; } float RasterizerSceneRD::environment_get_ssao_ao_affect(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, false); return env->ssao_ao_channel_affect; } float RasterizerSceneRD::environment_get_ssao_light_affect(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, false); return env->ssao_direct_light_affect; } bool RasterizerSceneRD::environment_is_ssr_enabled(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, false); return env->ssr_enabled; } bool RasterizerSceneRD::environment_is_sdfgi_enabled(RID p_env) const { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, false); return env->sdfgi_enabled; } @@ -2959,7 +2959,7 @@ bool RasterizerSceneRD::is_environment(RID p_env) const { } Ref<Image> RasterizerSceneRD::environment_bake_panorama(RID p_env, bool p_bake_irradiance, const Size2i &p_size) { - Environent *env = environment_owner.getornull(p_env); + Environment *env = environment_owner.getornull(p_env); ERR_FAIL_COND_V(!env, Ref<Image>()); if (env->background == RS::ENV_BG_CAMERA_FEED || env->background == RS::ENV_BG_CANVAS || env->background == RS::ENV_BG_KEEP) { @@ -4903,7 +4903,7 @@ void RasterizerSceneRD::_process_ssr(RID p_render_buffers, RID p_dest_framebuffe return; } - Environent *env = environment_owner.getornull(p_environment); + Environment *env = environment_owner.getornull(p_environment); ERR_FAIL_COND(!env); ERR_FAIL_COND(!env->ssr_enabled); @@ -4948,7 +4948,7 @@ void RasterizerSceneRD::_process_ssao(RID p_render_buffers, RID p_environment, R RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); ERR_FAIL_COND(!rb); - Environent *env = environment_owner.getornull(p_environment); + Environment *env = environment_owner.getornull(p_environment); ERR_FAIL_COND(!env); if (rb->ssao.ao[0].is_valid() && rb->ssao.ao_full.is_valid() != ssao_half_size) { @@ -5015,7 +5015,7 @@ void RasterizerSceneRD::_render_buffers_post_process_and_tonemap(RID p_render_bu RenderBuffers *rb = render_buffers_owner.getornull(p_render_buffers); ERR_FAIL_COND(!rb); - Environent *env = environment_owner.getornull(p_environment); + Environment *env = environment_owner.getornull(p_environment); //glow (if enabled) CameraEffects *camfx = camera_effects_owner.getornull(p_camera_effects); diff --git a/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h index f09f9dde65..bbc0f536aa 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h +++ b/servers/rendering/rasterizer_rd/rasterizer_scene_rd.h @@ -623,7 +623,7 @@ private: /* ENVIRONMENT */ - struct Environent { + struct Environment { // BG RS::EnvironmentBG background = RS::ENV_BG_CLEAR_COLOR; RID sky; @@ -703,7 +703,7 @@ private: static uint64_t auto_exposure_counter; - mutable RID_Owner<Environent> environment_owner; + mutable RID_Owner<Environment> environment_owner; /* CAMERA EFFECTS */ diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h index 319c6d9fde..66c6a1c3a9 100644 --- a/servers/rendering/rendering_device_binds.h +++ b/servers/rendering/rendering_device_binds.h @@ -620,7 +620,7 @@ protected: RD_BIND(Variant::INT, RDPipelineColorBlendState, logic_op); RD_BIND(Variant::COLOR, RDPipelineColorBlendState, blend_constant); - ClassDB::bind_method(D_METHOD("set_attachments", "atachments"), &RDPipelineColorBlendState::set_attachments); + ClassDB::bind_method(D_METHOD("set_attachments", "attachments"), &RDPipelineColorBlendState::set_attachments); ClassDB::bind_method(D_METHOD("get_attachments"), &RDPipelineColorBlendState::get_attachments); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "attachments", PROPERTY_HINT_ARRAY_TYPE, "RDPipelineColorBlendStateAttachment"), "set_attachments", "get_attachments"); } diff --git a/thirdparty/README.md b/thirdparty/README.md index 43cd448a00..392abea85e 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -426,9 +426,8 @@ Collection of single-file libraries used in Godot components. * License: zlib - `stb_vorbis.c` * Upstream: https://github.com/nothings/stb - * Version: 1.19 + * Version: 1.20 * License: Public Domain (Unlicense) or MIT - * Modifications: `f->temp_offset += (sz+3)&~3;` changed to `f->temp_offset += (sz+7)&~7;` (needed until fixed upstream) ## nanosvg diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp index 36b5131f80..55b160d752 100644 --- a/thirdparty/enet/godot.cpp +++ b/thirdparty/enet/godot.cpp @@ -44,15 +44,14 @@ /// Abstract ENet interface for UDP/DTLS. class ENetGodotSocket { - public: virtual Error bind(IP_Address p_ip, uint16_t p_port) = 0; virtual Error sendto(const uint8_t *p_buffer, int p_len, int &r_sent, IP_Address p_ip, uint16_t p_port) = 0; virtual Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) = 0; virtual int set_option(ENetSocketOption p_option, int p_value) = 0; virtual void close() = 0; - virtual void set_refuse_new_connections(bool p_refuse) { /* Only used by dtls server */ } - virtual ~ENetGodotSocket(){}; + virtual void set_refuse_new_connections(bool p_enable) {} /* Only used by dtls server */ + virtual ~ENetGodotSocket() {} }; class ENetDTLSClient; @@ -60,21 +59,19 @@ class ENetDTLSServer; /// NetSocket interface class ENetUDP : public ENetGodotSocket { - friend class ENetDTLSClient; friend class ENetDTLSServer; private: Ref<NetSocket> sock; IP_Address address; - uint16_t port; - bool bound; + uint16_t port = 0; + bool bound = false; public: ENetUDP() { sock = Ref<NetSocket>(NetSocket::create()); IP::Type ip_type = IP::TYPE_ANY; - bound = false; sock->open(NetSocket::TYPE_UDP, ip_type); } @@ -95,8 +92,9 @@ public: Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) { Error err = sock->poll(NetSocket::POLL_TYPE_IN, 0); - if (err != OK) + if (err != OK) { return err; + } return sock->recvfrom(p_buffer, p_len, r_read, r_ip, r_port); } @@ -149,11 +147,10 @@ public: /// DTLS Client ENet interface class ENetDTLSClient : public ENetGodotSocket { - - bool connected; + bool connected = false; Ref<PacketPeerUDP> udp; Ref<PacketPeerDTLS> dtls; - bool verify; + bool verify = false; String for_hostname; Ref<X509Certificate> cert; @@ -168,7 +165,6 @@ public: if (p_base->bound) { bind(p_base->address, p_base->port); } - connected = false; } ~ENetDTLSClient() { @@ -186,25 +182,29 @@ public: connected = true; } dtls->poll(); - if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) + if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) { return ERR_BUSY; - else if (dtls->get_status() != PacketPeerDTLS::STATUS_CONNECTED) + } else if (dtls->get_status() != PacketPeerDTLS::STATUS_CONNECTED) { return FAILED; + } r_sent = p_len; return dtls->put_packet(p_buffer, p_len); } Error recvfrom(uint8_t *p_buffer, int p_len, int &r_read, IP_Address &r_ip, uint16_t &r_port) { dtls->poll(); - if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) + if (dtls->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) { return ERR_BUSY; - if (dtls->get_status() != PacketPeerDTLS::STATUS_CONNECTED) + } + if (dtls->get_status() != PacketPeerDTLS::STATUS_CONNECTED) { return FAILED; + } int pc = dtls->get_available_packet_count(); - if (pc == 0) + if (pc == 0) { return ERR_BUSY; - else if (pc < 0) + } else if (pc < 0) { return FAILED; + } const uint8_t *buffer; Error err = dtls->get_packet(&buffer, r_read); @@ -229,15 +229,13 @@ public: /// DTLSServer - ENet interface class ENetDTLSServer : public ENetGodotSocket { - Ref<DTLSServer> server; Ref<UDPServer> udp_server; - Map<String, Ref<PacketPeerDTLS> > peers; - int last_service; + Map<String, Ref<PacketPeerDTLS>> peers; + int last_service = 0; public: ENetDTLSServer(ENetUDP *p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert) { - last_service = 0; udp_server.instance(); p_base->close(); if (p_base->bound) { @@ -264,12 +262,13 @@ public: ERR_FAIL_COND_V(!peers.has(key), ERR_UNAVAILABLE); Ref<PacketPeerDTLS> peer = peers[key]; Error err = peer->put_packet(p_buffer, p_len); - if (err == OK) + if (err == OK) { r_sent = p_len; - else if (err == ERR_BUSY) + } else if (err == ERR_BUSY) { r_sent = 0; - else + } else { r_sent = -1; + } return err; } @@ -291,13 +290,13 @@ public: List<String> remove; Error err = ERR_BUSY; // TODO this needs to be fair! - for (Map<String, Ref<PacketPeerDTLS> >::Element *E = peers.front(); E; E = E->next()) { + for (Map<String, Ref<PacketPeerDTLS>>::Element *E = peers.front(); E; E = E->next()) { Ref<PacketPeerDTLS> peer = E->get(); peer->poll(); - if (peer->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) + if (peer->get_status() == PacketPeerDTLS::STATUS_HANDSHAKING) { continue; - else if (peer->get_status() != PacketPeerDTLS::STATUS_CONNECTED) { + } else if (peer->get_status() != PacketPeerDTLS::STATUS_CONNECTED) { // Peer disconnected, removing it. remove.push_back(E->key()); continue; @@ -336,7 +335,7 @@ public: } void close() { - for (Map<String, Ref<PacketPeerDTLS> >::Element *E = peers.front(); E; E = E->next()) { + for (Map<String, Ref<PacketPeerDTLS>>::Element *E = peers.front(); E; E = E->next()) { E->get()->disconnect_from_peer(); } peers.clear(); @@ -348,7 +347,6 @@ public: static enet_uint32 timeBase = 0; int enet_initialize(void) { - return 0; } @@ -356,22 +354,18 @@ void enet_deinitialize(void) { } enet_uint32 enet_host_random_seed(void) { - return (enet_uint32)OS::get_singleton()->get_unix_time(); } enet_uint32 enet_time_get(void) { - return OS::get_singleton()->get_ticks_msec() - timeBase; } void enet_time_set(enet_uint32 newTimeBase) { - timeBase = OS::get_singleton()->get_ticks_msec() - newTimeBase; } int enet_address_set_host(ENetAddress *address, const char *name) { - IP_Address ip = IP::get_singleton()->resolve_hostname(name); ERR_FAIL_COND_V(!ip.is_valid(), -1); @@ -380,24 +374,20 @@ int enet_address_set_host(ENetAddress *address, const char *name) { } void enet_address_set_ip(ENetAddress *address, const uint8_t *ip, size_t size) { - int len = size > 16 ? 16 : size; memset(address->host, 0, 16); memcpy(address->host, ip, len); } int enet_address_get_host_ip(const ENetAddress *address, char *name, size_t nameLength) { - return -1; } int enet_address_get_host(const ENetAddress *address, char *name, size_t nameLength) { - return -1; } ENetSocket enet_socket_create(ENetSocketType type) { - ENetUDP *socket = memnew(ENetUDP); return socket; @@ -421,7 +411,6 @@ void enet_host_refuse_new_connections(ENetHost *host, int p_refuse) { } int enet_socket_bind(ENetSocket socket, const ENetAddress *address) { - IP_Address ip; if (address->wildcard) { ip = IP_Address("*"); @@ -443,8 +432,7 @@ void enet_socket_destroy(ENetSocket socket) { } int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBuffer *buffers, size_t bufferCount) { - - ERR_FAIL_COND_V(address == NULL, -1); + ERR_FAIL_COND_V(address == nullptr, -1); ENetGodotSocket *sock = (ENetGodotSocket *)socket; IP_Address dest; @@ -455,7 +443,7 @@ int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBu // Create a single packet. Vector<uint8_t> out; - uint8_t* w; + uint8_t *w; int size = 0; int pos = 0; for (i = 0; i < bufferCount; i++) { @@ -472,7 +460,6 @@ int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBu int sent = 0; err = sock->sendto((const uint8_t *)&w[0], size, sent, dest, address->port); if (err != OK) { - if (err == ERR_BUSY) { // Blocking call return 0; } @@ -485,7 +472,6 @@ int enet_socket_send(ENetSocket socket, const ENetAddress *address, const ENetBu } int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buffers, size_t bufferCount) { - ERR_FAIL_COND_V(bufferCount != 1, -1); ENetGodotSocket *sock = (ENetGodotSocket *)socket; @@ -494,11 +480,13 @@ int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buf IP_Address ip; Error err = sock->recvfrom((uint8_t *)buffers[0].data, buffers[0].dataLength, read, ip, address->port); - if (err == ERR_BUSY) + if (err == ERR_BUSY) { return 0; + } - if (err != OK) + if (err != OK) { return -1; + } enet_address_set_ip(address, ip.get_ipv6(), 16); @@ -507,47 +495,38 @@ int enet_socket_receive(ENetSocket socket, ENetAddress *address, ENetBuffer *buf // Not implemented int enet_socket_wait(ENetSocket socket, enet_uint32 *condition, enet_uint32 timeout) { - return 0; // do we need this function? } int enet_socket_get_address(ENetSocket socket, ENetAddress *address) { - return -1; // do we need this function? } int enet_socketset_select(ENetSocket maxSocket, ENetSocketSet *readSet, ENetSocketSet *writeSet, enet_uint32 timeout) { - return -1; } int enet_socket_listen(ENetSocket socket, int backlog) { - return -1; } int enet_socket_set_option(ENetSocket socket, ENetSocketOption option, int value) { - ENetGodotSocket *sock = (ENetGodotSocket *)socket; return sock->set_option(option, value); } int enet_socket_get_option(ENetSocket socket, ENetSocketOption option, int *value) { - return -1; } int enet_socket_connect(ENetSocket socket, const ENetAddress *address) { - return -1; } ENetSocket enet_socket_accept(ENetSocket socket, ENetAddress *address) { - - return NULL; + return nullptr; } int enet_socket_shutdown(ENetSocket socket, ENetSocketShutdown how) { - return -1; } diff --git a/thirdparty/misc/stb_vorbis.c b/thirdparty/misc/stb_vorbis.c index 52c9c666a2..a8cbfa6c23 100644 --- a/thirdparty/misc/stb_vorbis.c +++ b/thirdparty/misc/stb_vorbis.c @@ -1,4 +1,4 @@ -// Ogg Vorbis audio decoder - v1.19 - public domain +// Ogg Vorbis audio decoder - v1.20 - public domain // http://nothings.org/stb_vorbis/ // // Original version written by Sean Barrett in 2007. @@ -31,9 +31,11 @@ // Phillip Bennefall Rohit Thiago Goulart // github:manxorist saga musix github:infatum // Timur Gagiev Maxwell Koo Peter Waller -// github:audinowho Dougall Johnson +// github:audinowho Dougall Johnson David Reid +// github:Clownacy Pedro J. Estebanez Remi Verschelde // // Partial history: +// 1.20 - 2020-07-11 - several small fixes // 1.19 - 2020-02-05 - warnings // 1.18 - 2020-02-02 - fix seek bugs; parse header comments; misc warnings etc. // 1.17 - 2019-07-08 - fix CVE-2019-13217..CVE-2019-13223 (by ForAllSecure) @@ -577,7 +579,7 @@ enum STBVorbisError #if defined(_MSC_VER) || defined(__MINGW32__) #include <malloc.h> #endif - #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) + #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) || defined(__NEWLIB__) #include <alloca.h> #endif #else // STB_VORBIS_NO_CRT @@ -599,7 +601,9 @@ enum STBVorbisError #undef __forceinline #endif #define __forceinline + #ifndef alloca #define alloca __builtin_alloca + #endif #elif !defined(_MSC_VER) #if __GNUC__ #define __forceinline inline @@ -1600,7 +1604,8 @@ static uint32 get_bits(vorb *f, int n) f->valid_bits += 8; } } - if (f->valid_bits < 0) return 0; + + assert(f->valid_bits >= n); z = f->acc & ((1 << n)-1); f->acc >>= n; f->valid_bits -= n; @@ -4256,7 +4261,7 @@ static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z) memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start if (z) { p->alloc = *z; - p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3; + p->alloc.alloc_buffer_length_in_bytes &= ~7; p->temp_offset = p->alloc.alloc_buffer_length_in_bytes; } p->eof = 0; |