Skip to content

Commit

Permalink
Merge pull request godotengine#45892 from akien-mga/3.2-cherrypicks
Browse files Browse the repository at this point in the history
Cherry-picks for the 3.2 branch (future 3.2.4) - 22nd batch
  • Loading branch information
akien-mga authored Feb 11, 2021
2 parents f55c23d + 5abe08f commit 9a89782
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 46 deletions.
6 changes: 5 additions & 1 deletion .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Anish Bhobe <anishbhobe@hotmail.com>
Anutrix <numaanzaheerahmed@yahoo.com>
Aren Villanueva <arenvillanueva@yomogi-soft.com> <aren@displaysweet.com>
Ariel Manzur <ariel@godotengine.org>
Ariel Manzur <ariel@godotengine.org> <puntob@gmail.com>
Ariel Manzur <ariel@godotengine.org> <punto@godotengine.org>
Ariel Manzur <ariel@godotengine.org> <ariel@okamstudio.com>
Ariel Manzur <ariel@godotengine.org> <punto@Ariels-Mac-mini.local>
Expand All @@ -25,6 +26,7 @@ Daniel J. Ramirez <djrmuv@gmail.com>
Dominik 'dreamsComeTrue' Jasiński <dominikjasinski@o2.pl>
Emmanuel Barroga <emmanuelbarroga@gmail.com>
Eric M <itsjusteza@gmail.com>
Eric Rybicki <info@ericrybicki.com> <stratos695@googlemail.com>
Erik Selecký <35656626+rxlecky@users.noreply.github.com>
Erik Selecký <35656626+rxlecky@users.noreply.github.com> <35656626+SeleckyErik@users.noreply.github.com>
Fabian <supagu@gmail.com>
Expand Down Expand Up @@ -84,6 +86,7 @@ Mateo Kuruk Miccino <mateomiccino@gmail.com>
Max Hilbrunner <m.hilbrunner@gmail.com>
Max Hilbrunner <m.hilbrunner@gmail.com> <mhilbrunner@users.noreply.github.com>
Michael Alexsander <michaelalexsander@protonmail.com>
Nathan Franke <natfra@pm.me> <nathanwfranke@gmail.com>
Nathan Lovato <nathan@gdquest.com>
Nathan Warden <nathan@nathanwarden.com> <nathanwardenlee@icloud.com>
Nils ANDRÉ-CHANG <nils@nilsand.re>
Expand All @@ -97,7 +100,7 @@ Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
Pieter-Jan Briers <pieterjan.briers+git@gmail.com> <pieterjan.briers@gmail.com>
Poommetee Ketson <poommetee@protonmail.com>
Przemysław Gołąb (n-pigeon) <golab.przemyslaw@gmail.com>
Rafał Mikrut <mikrutrafal54@gmail.com>
Rafał Mikrut <mikrutrafal@protonmail.com> <mikrutrafal54@gmail.com>
Ralf Hölzemer <r.hoelzemer@posteo.de> <rollenrolm@posteo.de>
Ralf Hölzemer <r.hoelzemer@posteo.de> <rollenrolm@users.noreply.github.com>
Ramesh Ravone <ramesh.maran443@gmail.com>
Expand All @@ -123,5 +126,6 @@ Wilhem Barbier <nounoursheureux@openmailbox.org> <wilhem.b@free.fr>
Wilhem Barbier <nounoursheureux@openmailbox.org> <schtroumps31@gmail.com>
Will Nations <willnationsdev@gmail.com>
yg2f <yoann@terminajones.com>
Yuri Sizov <yuris@humnom.net> <pycbouh@users.noreply.github.com>
Zak Stam <zakscomputers@hotmail.com>
Zher Huei Lee <lee.zh.92@gmail.com>
3 changes: 3 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ name is available.
Leon Krause (leonkrause)
Liz Haas (27thLiz)
Lucien Menassol (Kanabenki)
Lyuma
m4nu3lf
Maganty Rushyendra (mrushyendra)
Marcel Admiraal (madmiraal)
Expand All @@ -138,6 +139,7 @@ name is available.
MichiRecRoom (LikeLakers2)
mrezai
muiroc
Nathan Franke (nathanfranke)
Nathan Lovato (NathanLovato)
Nathan Warden (NathanWarden)
Nils André-Chang (NilsIrl)
Expand Down Expand Up @@ -191,6 +193,7 @@ name is available.
Xavier Cho (mysticfall)
yg2f (SuperUserNameMan)
Yuri Roubinsky (Chaosus)
Yuri Sizov (pycbouh)
Zak Stam (zaksnet)
Zher Huei Lee (leezh)
ZuBsPaCe
20 changes: 12 additions & 8 deletions core/math/math_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,19 @@ class Math {
static _ALWAYS_INLINE_ double range_lerp(double p_value, double p_istart, double p_istop, double p_ostart, double p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); }
static _ALWAYS_INLINE_ float range_lerp(float p_value, float p_istart, float p_istop, float p_ostart, float p_ostop) { return Math::lerp(p_ostart, p_ostop, Math::inverse_lerp(p_istart, p_istop, p_value)); }

static _ALWAYS_INLINE_ double smoothstep(double p_from, double p_to, double p_weight) {
if (is_equal_approx(p_from, p_to)) return p_from;
double x = CLAMP((p_weight - p_from) / (p_to - p_from), 0.0, 1.0);
return x * x * (3.0 - 2.0 * x);
static _ALWAYS_INLINE_ double smoothstep(double p_from, double p_to, double p_s) {
if (is_equal_approx(p_from, p_to)) {
return p_from;
}
double s = CLAMP((p_s - p_from) / (p_to - p_from), 0.0, 1.0);
return s * s * (3.0 - 2.0 * s);
}
static _ALWAYS_INLINE_ float smoothstep(float p_from, float p_to, float p_weight) {
if (is_equal_approx(p_from, p_to)) return p_from;
float x = CLAMP((p_weight - p_from) / (p_to - p_from), 0.0f, 1.0f);
return x * x * (3.0f - 2.0f * x);
static _ALWAYS_INLINE_ float smoothstep(float p_from, float p_to, float p_s) {
if (is_equal_approx(p_from, p_to)) {
return p_from;
}
float s = CLAMP((p_s - p_from) / (p_to - p_from), 0.0f, 1.0f);
return s * s * (3.0f - 2.0f * s);
}
static _ALWAYS_INLINE_ double move_toward(double p_from, double p_to, double p_delta) { return abs(p_to - p_from) <= p_delta ? p_to : p_from + SGN(p_to - p_from) * p_delta; }
static _ALWAYS_INLINE_ float move_toward(float p_from, float p_to, float p_delta) { return abs(p_to - p_from) <= p_delta ? p_to : p_from + SGN(p_to - p_from) * p_delta; }
Expand Down
43 changes: 26 additions & 17 deletions core/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2710,40 +2710,49 @@ int String::rfindn(const String &p_str, int p_from) const {
}

bool String::ends_with(const String &p_string) const {

int l = p_string.length();
if (l > length()) {
return false;
}

if (l == 0) {
return true;
}

int pos = find_last(p_string);
if (pos == -1)
return false;
return pos + l == length();
const CharType *p = &p_string[0];
const CharType *s = &operator[](length() - l);

for (int i = 0; i < l; i++) {
if (p[i] != s[i]) {
return false;
}
}

return true;
}

bool String::begins_with(const String &p_string) const {

if (p_string.length() > length())
int l = p_string.length();
if (l > length()) {
return false;
}

int l = p_string.length();
if (l == 0)
if (l == 0) {
return true;
}

const CharType *src = &p_string[0];
const CharType *str = &operator[](0);

int i = 0;
for (; i < l; i++) {
const CharType *p = &p_string[0];
const CharType *s = &operator[](0);

if (src[i] != str[i])
for (int i = 0; i < l; i++) {
if (p[i] != s[i]) {
return false;
}
}

// only if i == l the p_string matches the beginning
return i == l;
return true;
}

bool String::begins_with(const char *p_string) const {

int l = length();
Expand Down
7 changes: 3 additions & 4 deletions doc/classes/EditorImportPlugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
return "my.special.plugin"

func get_visible_name():
return "Special Mesh Importer"
return "Special Mesh"

func get_recognized_extensions():
return ["special", "spec"]
Expand Down Expand Up @@ -44,8 +44,7 @@
# Fill the Mesh with data read in "file", left as an exercise to the reader

var filename = save_path + "." + get_save_extension()
ResourceSaver.save(filename, mesh)
return OK
return ResourceSaver.save(filename, mesh)
[/codeblock]
</description>
<tutorials>
Expand Down Expand Up @@ -143,7 +142,7 @@
<return type="String">
</return>
<description>
Gets the name to display in the import window.
Gets the name to display in the import window. You should choose this name as a continuation to "Import as", e.g. "Import as Special Mesh".
</description>
</method>
<method name="import" qualifiers="virtual">
Expand Down
7 changes: 7 additions & 0 deletions doc/classes/GraphNode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@
Emitted when the GraphNode is moved.
</description>
</signal>
<signal name="slot_updated">
<argument index="0" name="idx" type="int">
</argument>
<description>
Emitted when any GraphNode's slot is updated.
</description>
</signal>
<signal name="raise_request">
<description>
Emitted when the GraphNode is requested to be displayed over other ones. Happens on focusing (clicking into) the GraphNode.
Expand Down
18 changes: 15 additions & 3 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1294,14 +1294,26 @@ void FileSystemDock::_make_scene_confirm() {
void FileSystemDock::_file_removed(String p_file) {
emit_signal("file_removed", p_file);

path = "res://";
// Find the closest parent directory available, in case multiple items were deleted along the same path.
path = p_file.get_base_dir();
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
while (!da->dir_exists(path)) {
path = path.get_base_dir();
}

current_path->set_text(path);
}

void FileSystemDock::_folder_removed(String p_folder) {
emit_signal("folder_removed", p_folder);

path = "res://";
// Find the closest parent directory available, in case multiple items were deleted along the same path.
path = p_folder.get_base_dir();
DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
while (!da->dir_exists(path)) {
path = path.get_base_dir();
}

current_path->set_text(path);
}

Expand Down Expand Up @@ -1469,7 +1481,7 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool overw
print_verbose("FileSystem: saving moved scenes.");
_save_scenes_after_move(file_renames);

path = "res://";
path = p_to_path;
current_path->set_text(path);
}
}
Expand Down
10 changes: 6 additions & 4 deletions misc/dist/html/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,7 @@
return;
}
Promise.all([
deleteDB("/home/web_user/projects"),
deleteDB("/home/web_user/.config"),
deleteDB("/home/web_user/.cache"),
deleteDB("/home/web_user"),
]).then(function(results) {
alert("Done.");
}).catch(function (err) {
Expand All @@ -286,6 +284,10 @@
tabs.forEach(function (elem) {
if (elem.id == 'tab-' + name) {
elem.style.display = 'block';
if (name == 'editor' || name == 'game') {
const canvas = document.getElementById(name + '-canvas');
canvas.focus();
}
} else {
elem.style.display = 'none';
}
Expand Down Expand Up @@ -327,7 +329,7 @@
function startEditor(zip) {

const INDETERMINATE_STATUS_STEP_MS = 100;
const persistentPaths = ['/home/web_user/'];
const persistentPaths = ['/home/web_user'];

var editorCanvas = document.getElementById('editor-canvas');
var gameCanvas = document.getElementById('game-canvas');
Expand Down
28 changes: 20 additions & 8 deletions modules/gdscript/doc_classes/@GDScript.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
</argument>
<description>
The natural exponential function. It raises the mathematical constant [b]e[/b] to the power of [code]s[/code] and returns it.
[b]e[/b] has an approximate value of 2.71828.
[b]e[/b] has an approximate value of 2.71828, and can be obtained with [code]exp(1)[/code].
For exponents to other bases use the method [method pow].
[codeblock]
a = exp(2) # Approximately 7.39
Expand Down Expand Up @@ -501,6 +501,8 @@
</argument>
<description>
Returns [code]true[/code] if [code]a[/code] and [code]b[/code] are approximately equal to each other.
Here, approximately equal means that [code]a[/code] and [code]b[/code] are within a small internal epsilon of each other, which scales with the magnitude of the numbers.
Infinity values of the same sign are considered equal.
</description>
</method>
<method name="is_inf">
Expand Down Expand Up @@ -638,6 +640,7 @@
[codeblock]
log(10) # Returns 2.302585
[/codeblock]
[b]Note:[/b] The logarithm of [code]0[/code] returns [code]-inf[/code], while negative values return [code]-nan[/code].
</description>
</method>
<method name="max">
Expand Down Expand Up @@ -683,7 +686,9 @@
Moves [code]from[/code] toward [code]to[/code] by the [code]delta[/code] value.
Use a negative [code]delta[/code] value to move away.
[codeblock]
move_toward(5, 10, 4) # Returns 9
move_toward(10, 5, 4) # Returns 6
move_toward(10, 5, -1.5) # Returns 11.5
[/codeblock]
</description>
</method>
Expand All @@ -693,12 +698,17 @@
<argument index="0" name="value" type="int">
</argument>
<description>
Returns the nearest larger power of 2 for integer [code]value[/code].
Returns the nearest equal or larger power of 2 for integer [code]value[/code].
In other words, returns the smallest value [code]a[/code] where [code]a = pow(2, n)[/code] such that [code]value &lt;= a[/code] for some non-negative integer [code]n[/code].
[codeblock]
nearest_po2(3) # Returns 4
nearest_po2(4) # Returns 4
nearest_po2(5) # Returns 8

nearest_po2(0) # Returns 0 (this may not be what you expect)
nearest_po2(-1) # Returns 0 (this may not be what you expect)
[/codeblock]
[b]WARNING:[/b] Due to the way it is implemented, this function returns [code]0[/code] rather than [code]1[/code] for non-positive values of [code]value[/code] (in reality, 1 is the smallest integer power of 2).
</description>
</method>
<method name="ord">
Expand Down Expand Up @@ -1078,15 +1088,17 @@
</argument>
<argument index="1" name="to" type="float">
</argument>
<argument index="2" name="weight" type="float">
<argument index="2" name="s" type="float">
</argument>
<description>
Returns a number smoothly interpolated between the [code]from[/code] and [code]to[/code], based on the [code]weight[/code]. Similar to [method lerp], but interpolates faster at the beginning and slower at the end.
Returns the result of smoothly interpolating the value of [code]s[/code] between [code]0[/code] and [code]1[/code], based on the where [code]s[/code] lies with respect to the edges [code]from[/code] and [code]to[/code].
The return value is [code]0[/code] if [code]s &lt;= from[/code], and [code]1[/code] if [code]s &gt;= to[/code]. If [code]s[/code] lies between [code]from[/code] and [code]to[/code], the returned value follows an S-shaped curve that maps [code]s[/code] between [code]0[/code] and [code]1[/code].
This S-shaped curve is the cubic Hermite interpolator, given by [code]f(s) = 3*s^2 - 2*s^3[/code].
[codeblock]
smoothstep(0, 2, -5.0) # Returns 0.0
smoothstep(0, 2, 0.5) # Returns 0.15625
smoothstep(0, 2, 1.0) # Returns 0.5
smoothstep(0, 2, 2.0) # Returns 1.0
smoothstep(0, 2, 0.5) # Returns 0.15625
smoothstep(0, 2, 1.0) # Returns 0.5
smoothstep(0, 2, 2.0) # Returns 1.0
[/codeblock]
</description>
</method>
Expand All @@ -1100,7 +1112,7 @@
[codeblock]
sqrt(9) # Returns 3
[/codeblock]
If you need negative inputs, use [code]System.Numerics.Complex[/code] in C#.
[b]Note:[/b]Negative values of [code]s[/code] return NaN. If you need negative inputs, use [code]System.Numerics.Complex[/code] in C#.
</description>
</method>
<method name="step_decimals">
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/gdscript_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
return mi;
} break;
case MATH_SMOOTHSTEP: {
MethodInfo mi("smoothstep", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "weight"));
MethodInfo mi("smoothstep", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "s"));
mi.return_val.type = Variant::REAL;
return mi;
} break;
Expand Down
Loading

0 comments on commit 9a89782

Please sign in to comment.