Skip to content

Commit

Permalink
Merge pull request #81078 from akien-mga/3.x-cherrypicks
Browse files Browse the repository at this point in the history
Cherry-picks for the 3.x branch (future 3.6) - 13th batch
  • Loading branch information
akien-mga authored Aug 29, 2023
2 parents 47e6467 + b92b391 commit 3c7114e
Show file tree
Hide file tree
Showing 274 changed files with 38,388 additions and 37,014 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ tests/data/*.translation
# Binutils tmp linker output of the form "stXXXXXX" where "X" is alphanumeric
st[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]

# Python development
.venv
venv

# Python generated
__pycache__/
*.pyc
Expand Down
4 changes: 2 additions & 2 deletions core/io/file_access_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ uint64_t FileAccessMemory::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
}

memcpy(p_dst, &data[pos], read);
pos += p_length;
pos += read;

return read;
}
Expand Down Expand Up @@ -176,7 +176,7 @@ void FileAccessMemory::store_buffer(const uint8_t *p_src, uint64_t p_length) {
}

memcpy(&data[pos], p_src, write);
pos += p_length;
pos += write;
}

FileAccessMemory::FileAccessMemory() {
Expand Down
12 changes: 6 additions & 6 deletions core/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
// Defines the main "branch" version. Patch versions in this branch should be
// forward-compatible.
// Example: "3.1"
#define VERSION_BRANCH "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR)
#define VERSION_BRANCH _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR)
#if VERSION_PATCH
// Example: "3.1.4"
#define VERSION_NUMBER "" VERSION_BRANCH "." _MKSTR(VERSION_PATCH)
#define VERSION_NUMBER VERSION_BRANCH "." _MKSTR(VERSION_PATCH)
#else // patch is 0, we don't include it in the "pretty" version number.
// Example: "3.1" instead of "3.1.0"
#define VERSION_NUMBER "" VERSION_BRANCH
#define VERSION_NUMBER VERSION_BRANCH
#endif // VERSION_PATCH

// Version number encoded as hexadecimal int with one byte for each number,
Expand All @@ -57,16 +57,16 @@
// Describes the full configuration of that Godot version, including the version number,
// the status (beta, stable, etc.) and potential module-specific features (e.g. mono).
// Example: "3.1.4.stable.mono"
#define VERSION_FULL_CONFIG "" VERSION_NUMBER "." VERSION_STATUS VERSION_MODULE_CONFIG
#define VERSION_FULL_CONFIG VERSION_NUMBER "." VERSION_STATUS VERSION_MODULE_CONFIG

// Similar to VERSION_FULL_CONFIG, but also includes the (potentially custom) VERSION_BUILD
// description (e.g. official, custom_build, etc.).
// Example: "3.1.4.stable.mono.official"
#define VERSION_FULL_BUILD "" VERSION_FULL_CONFIG "." VERSION_BUILD
#define VERSION_FULL_BUILD VERSION_FULL_CONFIG "." VERSION_BUILD

// Same as above, but prepended with Godot's name and a cosmetic "v" for "version".
// Example: "Godot v3.1.4.stable.official.mono"
#define VERSION_FULL_NAME "" VERSION_NAME " v" VERSION_FULL_BUILD
#define VERSION_FULL_NAME VERSION_NAME " v" VERSION_FULL_BUILD

// Git commit hash, generated at build time in `core/version_hash.gen.cpp`.
extern const char *const VERSION_HASH;
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/Engine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
The desired frames per second. If the hardware cannot keep up, this setting may not be respected. A value of 0 means no limit.
</member>
<member name="time_scale" type="float" setter="set_time_scale" getter="get_time_scale" default="1.0">
Controls how fast or slow the in-game clock ticks versus the real life one. It defaults to 1.0. A value of 2.0 means the game moves twice as fast as real life, whilst a value of 0.5 means the game moves at half the regular speed.
Controls how fast or slow the in-game clock ticks versus the real life one. It defaults to 1.0. A value of 2.0 means the game moves twice as fast as real life, whilst a value of 0.5 means the game moves at half the regular speed. This also affects [Timer] and [SceneTreeTimer] (see [method SceneTree.create_timer] for how to control this).
</member>
</members>
<constants>
Expand Down
6 changes: 3 additions & 3 deletions doc/classes/Input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@
<return type="String" />
<argument index="0" name="device" type="int" />
<description>
Returns a SDL2-compatible device GUID on platforms that use gamepad remapping. Returns [code]"Default Gamepad"[/code] otherwise.
Returns a SDL2-compatible device GUID on platforms that use gamepad remapping, e.g. [code]030000004c050000c405000000010000[/code]. Returns [code]"Default Gamepad"[/code] otherwise. Godot uses the [url=https://github.com/gabomdq/SDL_GameControllerDB]SDL2 game controller database[/url] to determine gamepad names and mappings based on this GUID.
</description>
</method>
<method name="get_joy_name">
<return type="String" />
<argument index="0" name="device" type="int" />
<description>
Returns the name of the joypad at the specified device index.
Returns the name of the joypad at the specified device index, e.g. [code]PS4 Controller[/code]. Godot uses the [url=https://github.com/gabomdq/SDL_GameControllerDB]SDL2 game controller database[/url] to determine gamepad names.
</description>
</method>
<method name="get_joy_vibration_duration">
Expand Down Expand Up @@ -320,7 +320,7 @@
<argument index="2" name="hotspot" type="Vector2" default="Vector2( 0, 0 )" />
<description>
Sets a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. Passing [code]null[/code] to the image parameter resets to the system cursor. See [enum CursorShape] for the list of shapes.
[code]image[/code]'s size must be lower than 256×256.
[code]image[/code]'s size must be lower than or equal to 256×256. To avoid rendering issues, sizes lower than or equal to 128×128 are recommended.
[code]hotspot[/code] must be within [code]image[/code]'s size.
[b]Note:[/b] [AnimatedTexture]s aren't supported as custom mouse cursors. If using an [AnimatedTexture], only the first frame will be displayed.
[b]Note:[/b] Only images imported with the [b]Lossless[/b], [b]Lossy[/b] or [b]Uncompressed[/b] compression modes are supported. The [b]Video RAM[/b] compression mode can't be used for custom cursors.
Expand Down
10 changes: 10 additions & 0 deletions doc/classes/ScrollContainer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,22 @@
</member>
<member name="scroll_horizontal" type="int" setter="set_h_scroll" getter="get_h_scroll" default="0">
The current horizontal scroll value.
[b]Note:[/b] If you are setting this value in the [method Node._ready] function or earlier, it needs to be wrapped with [method Object.set_deferred], since scroll bar's [member Range.max_value] is not initialized yet.
[codeblock]
func _ready():
set_deferred("scroll_horizontal", 600)
[/codeblock]
</member>
<member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" default="true">
If [code]true[/code], enables horizontal scrolling.
</member>
<member name="scroll_vertical" type="int" setter="set_v_scroll" getter="get_v_scroll" default="0">
The current vertical scroll value.
[b]Note:[/b] Setting it early needs to be deferred, just like in [member scroll_horizontal].
[codeblock]
func _ready():
set_deferred("scroll_vertical", 600)
[/codeblock]
</member>
<member name="scroll_vertical_enabled" type="bool" setter="set_enable_v_scroll" getter="is_v_scroll_enabled" default="true">
If [code]true[/code], enables vertical scrolling.
Expand Down
3 changes: 2 additions & 1 deletion doc/classes/Timer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</brief_description>
<description>
Counts down a specified interval and emits a signal on reaching 0. Can be set to repeat or "one-shot" mode.
[b]Note:[/b] Timers are affected by [member Engine.time_scale], a higher scale means quicker timeouts, and vice versa.
[b]Note:[/b] To create a one-shot timer without instantiating a node, use [method SceneTree.create_timer].
</description>
<tutorials>
Expand Down Expand Up @@ -52,7 +53,7 @@
</member>
<member name="wait_time" type="float" setter="set_wait_time" getter="get_wait_time" default="1.0">
The wait time in seconds.
[b]Note:[/b] Timers can only emit once per rendered frame at most (or once per physics frame if [member process_mode] is [constant TIMER_PROCESS_PHYSICS]). This means very low wait times (lower than 0.05 seconds) will behave in significantly different ways depending on the rendered framerate. For very low wait times, it is recommended to use a process loop in a script instead of using a Timer node.
[b]Note:[/b] Timers can only emit once per rendered frame at most (or once per physics frame if [member process_mode] is [constant TIMER_PROCESS_PHYSICS]). This means very low wait times (lower than 0.05 seconds) will behave in significantly different ways depending on the rendered framerate. For very low wait times, it is recommended to use a process loop in a script instead of using a Timer node. Timers are affected by [member Engine.time_scale], a higher scale means quicker timeouts, and vice versa.
</member>
</members>
<signals>
Expand Down
23 changes: 22 additions & 1 deletion drivers/wasapi/audio_driver_wasapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@ Error AudioDriverWASAPI::init_render_device(bool reinit) {
return err;

switch (audio_output.channels) {
case 1: // Mono
case 3: // Surround 2.1
case 5: // Surround 5.0
case 7: // Surround 7.0
// We will downmix as required.
channels = audio_output.channels + 1;
break;

case 2: // Stereo
case 4: // Surround 3.1
case 6: // Surround 5.1
Expand All @@ -343,7 +351,7 @@ Error AudioDriverWASAPI::init_render_device(bool reinit) {
input_position = 0;
input_size = 0;

print_verbose("WASAPI: detected " + itos(channels) + " channels");
print_verbose("WASAPI: detected " + itos(audio_output.channels) + " channels");
print_verbose("WASAPI: audio buffer frames: " + itos(buffer_frames) + " calculated latency: " + itos(buffer_frames * 1000 / mix_rate) + "ms");

return OK;
Expand Down Expand Up @@ -584,6 +592,19 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
for (unsigned int i = 0; i < write_frames * ad->channels; i++) {
ad->write_sample(ad->audio_output.format_tag, ad->audio_output.bits_per_sample, buffer, i, ad->samples_in.write[write_ofs++]);
}
} else if (ad->channels == ad->audio_output.channels + 1) {
// Pass all channels except the last two as-is, and then mix the last two
// together as one channel. E.g. stereo -> mono, or 3.1 -> 2.1.
unsigned int last_chan = ad->audio_output.channels - 1;
for (unsigned int i = 0; i < write_frames; i++) {
for (unsigned int j = 0; j < last_chan; j++) {
ad->write_sample(ad->audio_output.format_tag, ad->audio_output.bits_per_sample, buffer, i * ad->audio_output.channels + j, ad->samples_in.write[write_ofs++]);
}
int32_t l = ad->samples_in.write[write_ofs++];
int32_t r = ad->samples_in.write[write_ofs++];
int32_t c = (int32_t)(((int64_t)l + (int64_t)r) / 2);
ad->write_sample(ad->audio_output.format_tag, ad->audio_output.bits_per_sample, buffer, i * ad->audio_output.channels + last_chan, c);
}
} else {
for (unsigned int i = 0; i < write_frames; i++) {
for (unsigned int j = 0; j < MIN(ad->channels, ad->audio_output.channels); j++) {
Expand Down
Loading

0 comments on commit 3c7114e

Please sign in to comment.