Skip to content

Commit

Permalink
Merge branch '4.x' of github.com:roalyr/godot-for-3d-open-worlds into…
Browse files Browse the repository at this point in the history
… 4.x
  • Loading branch information
roalyr committed Jan 30, 2024
2 parents c1ba04f + bed5e9f commit a4e76f2
Show file tree
Hide file tree
Showing 423 changed files with 9,204 additions and 2,760 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ doc_classes/* @godotengine/documentation
/drivers/xaudio2/ @godotengine/audio

## Rendering
/drivers/d3d12/ @godotengine/rendering
/drivers/dummy/ @godotengine/rendering
/drivers/gles3/ @godotengine/rendering
/drivers/spirv-reflect/ @godotengine/rendering
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ body:
- Write a descriptive issue title above.
- The golden rule is to **always open *one* issue for *one* bug**. If you notice several bugs and want to report them, make sure to create one new issue for each of them.
- Search [open](https://github.com/godotengine/godot/issues) and [closed](https://github.com/godotengine/godot/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported. If you don't find a relevant match or if you're unsure, don't hesitate to **open a new issue**. The bugsquad will handle it from there if it's a duplicate.
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html). Please always check if your issue is reproducible in the latest version – it may already have been fixed!
- Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/latest/about/release_policy.html). Please always check if your issue is reproducible in the latest version – it may already have been fixed!
- If you use a custom build, please test if your issue is reproducible in official builds too. Likewise if you use any C++ modules, GDExtensions, or editor plugins, you should check if the bug is reproducible in a project without these.
- type: textarea
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/web_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Emscripten latest
uses: mymindstorm/setup-emsdk@v12
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
cache-key: emsdk-${{ matrix.cache-name }}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}

- name: Verify Emscripten setup
run: |
Expand Down
25 changes: 3 additions & 22 deletions .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes d3d12=yes "dxc_path=${{github.workspace}}/dxc" "mesa_libs=${{github.workspace}}/godot-nir-static"
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes d3d12=yes
SCONS_CACHE_MSVC_CONFIG: true

concurrency:
Expand Down Expand Up @@ -49,27 +49,8 @@ jobs:
- name: Setup python and scons
uses: ./.github/actions/godot-deps

- name: Download pre-built DirectX Shader Compiler
uses: dsaltares/[email protected]
with:
repo: Microsoft/DirectXShaderCompiler
version: tags/v1.7.2308
file: dxc_2023_08_14.zip
target: dxc.zip

- name: Extract pre-built DirectX Shader Compiler
run: 7z x dxc.zip -o${{github.workspace}}/dxc

- name: Download pre-built Mesa-NIR
uses: dsaltares/[email protected]
with:
repo: godotengine/godot-nir-static
version: tags/23.1.0-devel
file: godot-nir-23.1.0-1-devel.zip
target: godot-nir-static.zip

- name: Extract pre-built Mesa-NIR
run: 7z x godot-nir-static.zip -o${{github.workspace}}/godot-nir-static
- name: Download Direct3D 12 SDK components
run: python ./misc/scripts/install_d3d12_sdk_windows.py

- name: Setup MSVC problem matcher
uses: ammaraskar/msvc-problem-matcher@master
Expand Down
7 changes: 0 additions & 7 deletions .lgtm.yml

This file was deleted.

2 changes: 1 addition & 1 deletion COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ License: Expat

Files: ./thirdparty/zlib/
Comment: zlib
Copyright: 1995-2023, Jean-loup Gailly and Mark Adler
Copyright: 1995-2024, Jean-loup Gailly and Mark Adler
License: Zlib

Files: ./thirdparty/zstd/
Expand Down
1 change: 0 additions & 1 deletion core/config/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ Dictionary Engine::get_version_info() const {
dict["hex"] = VERSION_HEX;
dict["status"] = VERSION_STATUS;
dict["build"] = VERSION_BUILD;
dict["year"] = VERSION_YEAR;

String hash = String(VERSION_HASH);
dict["hash"] = hash.is_empty() ? String("unknown") : hash;
Expand Down
4 changes: 4 additions & 0 deletions core/core_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,10 @@ void register_global_constants() {
BIND_CORE_BITFIELD_CLASS_FLAG(KeyModifierMask, KEY_MASK, KPAD);
BIND_CORE_BITFIELD_CLASS_FLAG(KeyModifierMask, KEY_MASK, GROUP_SWITCH);

BIND_CORE_ENUM_CLASS_CONSTANT(KeyLocation, KEY_LOCATION, UNSPECIFIED);
BIND_CORE_ENUM_CLASS_CONSTANT(KeyLocation, KEY_LOCATION, LEFT);
BIND_CORE_ENUM_CLASS_CONSTANT(KeyLocation, KEY_LOCATION, RIGHT);

BIND_CORE_ENUM_CLASS_CONSTANT(MouseButton, MOUSE_BUTTON, NONE);
BIND_CORE_ENUM_CLASS_CONSTANT(MouseButton, MOUSE_BUTTON, LEFT);
BIND_CORE_ENUM_CLASS_CONSTANT(MouseButton, MOUSE_BUTTON, RIGHT);
Expand Down
15 changes: 15 additions & 0 deletions core/extension/gdextension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ void GDExtension::_unregister_extension_class(GDExtensionClassLibraryPtr p_libra
if (!ext->is_reloading) {
self->extension_classes.erase(class_name);
}

GDExtensionEditorHelp::remove_class(class_name);
#else
self->extension_classes.erase(class_name);
#endif
Expand Down Expand Up @@ -1196,4 +1198,17 @@ void GDExtensionEditorPlugins::remove_extension_class(const StringName &p_class_
extension_classes.erase(p_class_name);
}
}

GDExtensionEditorHelp::EditorHelpLoadXmlBufferFunc GDExtensionEditorHelp::editor_help_load_xml_buffer = nullptr;
GDExtensionEditorHelp::EditorHelpRemoveClassFunc GDExtensionEditorHelp::editor_help_remove_class = nullptr;

void GDExtensionEditorHelp::load_xml_buffer(const uint8_t *p_buffer, int p_size) {
ERR_FAIL_NULL(editor_help_load_xml_buffer);
editor_help_load_xml_buffer(p_buffer, p_size);
}

void GDExtensionEditorHelp::remove_class(const String &p_class) {
ERR_FAIL_NULL(editor_help_remove_class);
editor_help_remove_class(p_class);
}
#endif // TOOLS_ENABLED
20 changes: 20 additions & 0 deletions core/extension/gdextension.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,26 @@ class GDExtensionEditorPlugins {
return extension_classes;
}
};

class GDExtensionEditorHelp {
protected:
friend class EditorHelp;

// Similarly to EditorNode above, we need to be able to ask EditorHelp to parse
// new documentation data. Note though that, differently from EditorHelp, this
// is initialized even _before_ it gets instantiated, as we need to rely on
// this method while initializing the engine.
typedef void (*EditorHelpLoadXmlBufferFunc)(const uint8_t *p_buffer, int p_size);
static EditorHelpLoadXmlBufferFunc editor_help_load_xml_buffer;

typedef void (*EditorHelpRemoveClassFunc)(const String &p_class);
static EditorHelpRemoveClassFunc editor_help_remove_class;

public:
static void load_xml_buffer(const uint8_t *p_buffer, int p_size);
static void remove_class(const String &p_class);
};

#endif // TOOLS_ENABLED

#endif // GDEXTENSION_H
17 changes: 17 additions & 0 deletions core/extension/gdextension_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include "core/variant/variant.h"
#include "core/version.h"

#include <string.h>

class CallableCustomExtension : public CallableCustom {
void *userdata;
void *token;
Expand Down Expand Up @@ -1373,6 +1375,19 @@ static void gdextension_editor_remove_plugin(GDExtensionConstStringNamePtr p_cla
#endif
}

static void gdextension_editor_help_load_xml_from_utf8_chars_and_len(const char *p_data, GDExtensionInt p_size) {
#ifdef TOOLS_ENABLED
GDExtensionEditorHelp::load_xml_buffer((const uint8_t *)p_data, p_size);
#endif
}

static void gdextension_editor_help_load_xml_from_utf8_chars(const char *p_data) {
#ifdef TOOLS_ENABLED
size_t len = strlen(p_data);
gdextension_editor_help_load_xml_from_utf8_chars_and_len(p_data, len);
#endif
}

#define REGISTER_INTERFACE_FUNC(m_name) GDExtension::register_interface_function(#m_name, (GDExtensionInterfaceFunctionPtr)&gdextension_##m_name)

void gdextension_setup_interface() {
Expand Down Expand Up @@ -1516,6 +1531,8 @@ void gdextension_setup_interface() {
REGISTER_INTERFACE_FUNC(classdb_get_class_tag);
REGISTER_INTERFACE_FUNC(editor_add_plugin);
REGISTER_INTERFACE_FUNC(editor_remove_plugin);
REGISTER_INTERFACE_FUNC(editor_help_load_xml_from_utf8_chars);
REGISTER_INTERFACE_FUNC(editor_help_load_xml_from_utf8_chars_and_len);
}

#undef REGISTER_INTERFACE_FUNCTION
25 changes: 25 additions & 0 deletions core/extension/gdextension_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -2617,6 +2617,31 @@ typedef void (*GDExtensionInterfaceEditorAddPlugin)(GDExtensionConstStringNamePt
*/
typedef void (*GDExtensionInterfaceEditorRemovePlugin)(GDExtensionConstStringNamePtr p_class_name);

/**
* @name editor_help_load_xml_from_utf8_chars
* @since 4.3
*
* Loads new XML-formatted documentation data in the editor.
*
* The provided pointer can be immediately freed once the function returns.
*
* @param p_data A pointer to an UTF-8 encoded C string (null terminated).
*/
typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8Chars)(const char *p_data);

/**
* @name editor_help_load_xml_from_utf8_chars_and_len
* @since 4.3
*
* Loads new XML-formatted documentation data in the editor.
*
* The provided pointer can be immediately freed once the function returns.
*
* @param p_data A pointer to an UTF-8 encoded C string.
* @param p_size The number of bytes (not code units).
*/
typedef void (*GDExtensionsInterfaceEditorHelpLoadXmlFromUtf8CharsAndLen)(const char *p_data, GDExtensionInt p_size);

#ifdef __cplusplus
}
#endif
Expand Down
44 changes: 43 additions & 1 deletion core/input/input_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ char32_t InputEventKey::get_unicode() const {
return unicode;
}

void InputEventKey::set_location(KeyLocation p_key_location) {
location = p_key_location;
emit_changed();
}

KeyLocation InputEventKey::get_location() const {
return location;
}

void InputEventKey::set_echo(bool p_enable) {
echo = p_enable;
emit_changed();
Expand Down Expand Up @@ -436,6 +445,23 @@ String InputEventKey::as_text_key_label() const {
return mods_text.is_empty() ? kc : mods_text + "+" + kc;
}

String InputEventKey::as_text_location() const {
String loc;

switch (location) {
case KeyLocation::LEFT:
loc = "left";
break;
case KeyLocation::RIGHT:
loc = "right";
break;
default:
break;
}

return loc;
}

String InputEventKey::as_text() const {
String kc;

Expand Down Expand Up @@ -464,6 +490,11 @@ String InputEventKey::to_string() {
String kc = "";
String physical = "false";

String loc = as_text_location();
if (loc.is_empty()) {
loc = "unspecified";
}

if (keycode == Key::NONE && physical_keycode == Key::NONE && unicode != 0) {
kc = "U+" + String::num_uint64(unicode, 16) + " (" + String::chr(unicode) + ")";
} else if (keycode != Key::NONE) {
Expand All @@ -478,7 +509,7 @@ String InputEventKey::to_string() {
String mods = InputEventWithModifiers::as_text();
mods = mods.is_empty() ? "none" : mods;

return vformat("InputEventKey: keycode=%s, mods=%s, physical=%s, pressed=%s, echo=%s", kc, mods, physical, p, e);
return vformat("InputEventKey: keycode=%s, mods=%s, physical=%s, location=%s, pressed=%s, echo=%s", kc, mods, physical, loc, p, e);
}

Ref<InputEventKey> InputEventKey::create_reference(Key p_keycode, bool p_physical) {
Expand Down Expand Up @@ -531,6 +562,9 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool p_exact_ma
match = keycode == key->keycode;
} else if (physical_keycode != Key::NONE) {
match = physical_keycode == key->physical_keycode;
if (location != KeyLocation::UNSPECIFIED) {
match &= location == key->location;
}
} else {
match = false;
}
Expand Down Expand Up @@ -572,6 +606,9 @@ bool InputEventKey::is_match(const Ref<InputEvent> &p_event, bool p_exact_match)
return (keycode == key->keycode) &&
(!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask());
} else if (physical_keycode != Key::NONE) {
if (location != KeyLocation::UNSPECIFIED && location != key->location) {
return false;
}
return (physical_keycode == key->physical_keycode) &&
(!p_exact_match || get_modifiers_mask() == key->get_modifiers_mask());
} else {
Expand All @@ -594,6 +631,9 @@ void InputEventKey::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_unicode", "unicode"), &InputEventKey::set_unicode);
ClassDB::bind_method(D_METHOD("get_unicode"), &InputEventKey::get_unicode);

ClassDB::bind_method(D_METHOD("set_location", "location"), &InputEventKey::set_location);
ClassDB::bind_method(D_METHOD("get_location"), &InputEventKey::get_location);

ClassDB::bind_method(D_METHOD("set_echo", "echo"), &InputEventKey::set_echo);

ClassDB::bind_method(D_METHOD("get_keycode_with_modifiers"), &InputEventKey::get_keycode_with_modifiers);
Expand All @@ -603,12 +643,14 @@ void InputEventKey::_bind_methods() {
ClassDB::bind_method(D_METHOD("as_text_keycode"), &InputEventKey::as_text_keycode);
ClassDB::bind_method(D_METHOD("as_text_physical_keycode"), &InputEventKey::as_text_physical_keycode);
ClassDB::bind_method(D_METHOD("as_text_key_label"), &InputEventKey::as_text_key_label);
ClassDB::bind_method(D_METHOD("as_text_location"), &InputEventKey::as_text_location);

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
ADD_PROPERTY(PropertyInfo(Variant::INT, "keycode"), "set_keycode", "get_keycode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "physical_keycode"), "set_physical_keycode", "get_physical_keycode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "key_label"), "set_key_label", "get_key_label");
ADD_PROPERTY(PropertyInfo(Variant::INT, "unicode"), "set_unicode", "get_unicode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "location", PROPERTY_HINT_ENUM, "Unspecified,Left,Right"), "set_location", "get_location");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "echo"), "set_echo", "is_echo");
}

Expand Down
5 changes: 5 additions & 0 deletions core/input/input_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class InputEventKey : public InputEventWithModifiers {
Key physical_keycode = Key::NONE;
Key key_label = Key::NONE;
uint32_t unicode = 0; ///unicode
KeyLocation location = KeyLocation::UNSPECIFIED;

bool echo = false; /// true if this is an echo key

Expand All @@ -178,6 +179,9 @@ class InputEventKey : public InputEventWithModifiers {
void set_unicode(char32_t p_unicode);
char32_t get_unicode() const;

void set_location(KeyLocation p_key_location);
KeyLocation get_location() const;

void set_echo(bool p_enable);
virtual bool is_echo() const override;

Expand All @@ -193,6 +197,7 @@ class InputEventKey : public InputEventWithModifiers {
virtual String as_text_physical_keycode() const;
virtual String as_text_keycode() const;
virtual String as_text_key_label() const;
virtual String as_text_location() const;
virtual String as_text() const override;
virtual String to_string() override;

Expand Down
2 changes: 1 addition & 1 deletion core/io/file_access_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ uint64_t FileAccessMemory::get_length() const {
}

bool FileAccessMemory::eof_reached() const {
return pos > length;
return pos >= length;
}

uint8_t FileAccessMemory::get_8() const {
Expand Down
16 changes: 8 additions & 8 deletions core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,20 +509,20 @@ Ref<ResourceLoader::LoadToken> ResourceLoader::_load_start(const String &p_path,
float ResourceLoader::_dependency_get_progress(const String &p_path) {
if (thread_load_tasks.has(p_path)) {
ThreadLoadTask &load_task = thread_load_tasks[p_path];
float current_progress = 0.0;
int dep_count = load_task.sub_tasks.size();
if (dep_count > 0) {
float dep_progress = 0;
for (const String &E : load_task.sub_tasks) {
dep_progress += _dependency_get_progress(E);
current_progress += _dependency_get_progress(E);
}
dep_progress /= float(dep_count);
dep_progress *= 0.5;
dep_progress += load_task.progress * 0.5;
return dep_progress;
current_progress /= float(dep_count);
current_progress *= 0.5;
current_progress += load_task.progress * 0.5;
} else {
return load_task.progress;
current_progress = load_task.progress;
}

load_task.max_reported_progress = MAX(load_task.max_reported_progress, current_progress);
return load_task.max_reported_progress;
} else {
return 1.0; //assume finished loading it so it no longer exists
}
Expand Down
Loading

0 comments on commit a4e76f2

Please sign in to comment.