Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update compatibility to 4.0-stable #304

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2fd59b7
Update compatibility for 4.0 beta3 (35cfaafda8073f700c9d2fe42a43d3d81…
Beliar83 Oct 31, 2022
c5bba89
Update compatibility to 889868cbbc8beac74d5f49f9b7ef41efc4ae7d5a
Beliar83 Nov 3, 2022
b99963a
Ignore script name when checking properties
Beliar83 Nov 3, 2022
f8db5b6
Temporarily disable registering scripts when running a project to fix…
Beliar83 Nov 3, 2022
f8bf505
Fix loading of components from C#
Beliar83 Nov 5, 2022
1a200e4
Update compatibility
Beliar83 Jan 6, 2023
6d2a012
Update compatibility
Beliar83 Jan 31, 2023
f3a5fd2
Move register_runtime_scripts to NOTIFICATION_POSTINITIALIZE
Beliar83 Feb 11, 2023
1412b3c
Call register_runtime_scripts in NOTIFICATION_READY as well.
Beliar83 Feb 12, 2023
5291ad1
Fix formatting
Beliar83 Feb 14, 2023
9ab9ed5
Compatibility changes
Beliar83 Feb 21, 2023
0069914
Change godot version to check out
Beliar83 Feb 13, 2023
27d873b
Adjust target
Beliar83 Feb 13, 2023
9c282c2
Update patch
Beliar83 Feb 13, 2023
abb7ed4
Fix g++ warnings
Beliar83 Feb 13, 2023
dc228d8
Fixing builds
Beliar83 Feb 13, 2023
3b7098e
Fix formatting
Beliar83 Feb 14, 2023
b8514f0
Fix godot tests
Beliar83 Feb 15, 2023
e0c8e08
Fix tests
Beliar83 Feb 22, 2023
eac4c95
Preload scripts for registering system and component names
Beliar83 Feb 22, 2023
d62c5f2
Wait for static checks
Beliar83 Feb 22, 2023
d19166a
Update ref
Beliar83 Feb 22, 2023
ccba0ee
Run tests with headless
Beliar83 Feb 22, 2023
7d87207
Print message when preloading scripts
Beliar83 Feb 22, 2023
57117e8
Don't preload scripts for tests in debug mode
Beliar83 Feb 22, 2023
92513e7
Update commit to 4.0 RC3
Beliar83 Feb 22, 2023
4439dd9
Don't run tests with headless on windows.
Beliar83 Feb 22, 2023
d2f0ecc
Remove left over debug statement
Beliar83 Feb 22, 2023
27b6469
Move resetting of default values to fix crash with mono builds.
Beliar83 Feb 22, 2023
816bf03
Fix building with clang
Beliar83 Feb 23, 2023
76b6755
Use newer black version
Beliar83 Feb 23, 2023
f676895
Updated godot version to 92bee43adba8d2401ef40e2480e53087bcb1eaf1 (4.…
Beliar83 Mar 1, 2023
43f6c34
Merge branch 'GodotECS:main' into main
Beliar83 Apr 12, 2023
9c4b85b
Updated version to 7a0977ce2c558fe6219f0a14f8bd4d05aea8f019 (4.0.2-st…
Beliar83 Apr 11, 2023
369a473
Update compatibility to ab7cb2a95d060a6533e6ff5111c11f71972ab43f
Beliar83 Apr 12, 2023
f919dff
Fix builds for PRs
Beliar83 Apr 12, 2023
d329668
Fix shadow warnigs
Beliar83 May 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ on:

# Global Settings
env:
GODOT_BASE_BRANCH: master
SCONSFLAGS: platform=linuxbsd verbose=yes warnings=extra werror=yes debug_symbols=no --jobs=2 module_text_server_fb_enabled=yes
GODOT_REF: 92bee43adba8d2401ef40e2480e53087bcb1eaf1
SCONSFLAGS: platform=linuxbsd verbose=yes warnings=extra werror=yes debug_symbols=no module_text_server_fb_enabled=yes
SCONS_CACHE_LIMIT: 4096

jobs:
linux-editor:
runs-on: "ubuntu-20.04"
name: Editor (target=release_debug, tools=yes, tests=yes)
name: Editor (target=editor, tools=yes, tests=yes)

steps:
- name: Wait for static checks
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
check-name: 'Static Checks (clang-format, black format, file format, documentation checks)'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Make godot dir
run: |
mkdir godot
Expand All @@ -33,10 +40,15 @@ jobs:
- name: Clone godot for godex
uses: actions/checkout@v2
with:
repository: GodotECS/godot
ref: refs/heads/godex_version
repository: godotengine/godot
ref: ${{ env.GODOT_REF }}
path: godot

- name: Apply patch
run: |
cd godot
git apply ../modules/godex/patches/add_custom_iterator.patch --reject --ignore-space-change --ignore-whitespace

# Azure repositories are not reliable, we need to prevent azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
run: |
Expand All @@ -56,11 +68,11 @@ jobs:
uses: actions/cache@v2
with:
path: ${{github.workspace}}/.scons_cache/
key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-{{env.GODOT_REF}}-${{github.ref}}-${{github.sha}}
restore-keys: |
${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
${{github.job}}-${{env.GODOT_BASE_BRANCH}}
${{github.job}}-{{env.GODOT_REF}}-${{github.ref}}-${{github.sha}}
${{github.job}}-{{env.GODOT_REF}}-${{github.ref}}
${{github.job}}-{{env.GODOT_REF}}

# Use python 3.x release (works cross platform; best to keep self contained in it's own step)
- name: Set up Python 3.x
Expand All @@ -84,14 +96,14 @@ jobs:
SCONS_CACHE: ${{github.workspace}}/.scons_cache/
run: |
cd godot
scons tools=yes tests=yes target=release_debug custom_modules="../modules" -j2
scons tools=yes tests=yes target=editor custom_modules="../modules"
ls -l bin/

# Execute unit tests for the editor
- name: Unit Tests
run: |
cd ./godot
./bin/godot.linuxbsd.opt.tools.64 --test
./bin/godot.linuxbsd.editor.x86_64 --test --headless
cd ../

- uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
sudo apt-get install -qq dos2unix recode clang-format-11
sudo update-alternatives --remove-all clang-format
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 100
sudo pip3 install black==20.8b1 pygments
sudo pip3 install black==22.3.0 pygments
- name: File formatting checks (file_format.sh)
run: |
bash ./misc/scripts/file_format.sh
Expand Down
32 changes: 22 additions & 10 deletions .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,25 @@ on:
# Global Settings
# SCONS_CACHE for windows must be set in the build environment
env:
GODOT_BASE_BRANCH: master
SCONSFLAGS: platform=windows verbose=yes warnings=all werror=yes debug_symbols=no --jobs=2 module_text_server_fb_enabled=yes
GODOT_REF: 92bee43adba8d2401ef40e2480e53087bcb1eaf1
SCONSFLAGS: platform=windows verbose=yes warnings=all werror=yes debug_symbols=no module_text_server_fb_enabled=yes
SCONS_CACHE_MSVC_CONFIG: true
SCONS_CACHE_LIMIT: 3072

jobs:
windows-editor:
# Windows 10 with latest image
runs-on: "windows-latest"
name: Editor (target=release_debug, tools=yes, tests=yes)
name: Editor (target=editor, tools=yes, tests=yes)

steps:
- name: Wait for static checks
uses: lewagon/[email protected]
with:
ref: ${{ github.ref }}
check-name: 'Static Checks (clang-format, black format, file format, documentation checks)'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
- name: Make dir
run: |
mkdir godot
Expand All @@ -36,10 +43,15 @@ jobs:
- name: Clone godot for godex
uses: actions/checkout@v2
with:
repository: GodotECS/godot
ref: refs/heads/godex_version
repository: godotengine/godot
ref: ${{ env.GODOT_REF }}
path: godot

- name: Apply patch
run: |
cd godot
git apply ../modules/godex/patches/add_custom_iterator.patch --reject --ignore-space-change --ignore-whitespace

# Upload cache on completion and check it out now
# Editing this is pretty dangerous for Windows since it can break and needs to be properly tested with a fresh cache.
- name: Load .scons_cache directory
Expand All @@ -49,9 +61,9 @@ jobs:
path: ${{github.workspace}}/.scons_cache/
key: ${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
restore-keys: |
${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
${{github.job}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}
${{github.job}}-${{env.GODOT_BASE_BRANCH}}
${{github.job}}-${{env.GODOT_REF}}-${{github.ref}}-${{github.sha}}
${{github.job}}-${{env.GODOT_REF}}-${{github.ref}}
${{github.job}}-${{env.GODOT_REF}}

# Use python 3.x release (works cross platform; best to keep self contained in it's own step)
- name: Set up Python 3.x
Expand All @@ -76,14 +88,14 @@ jobs:
SCONS_CACHE: ${{github.workspace}}/.scons_cache/
run: |
cd godot
scons tools=yes tests=yes target=release_debug custom_modules="../modules"
scons tools=yes tests=yes target=editor custom_modules="../modules"
ls -l bin/

# Execute unit tests for the editor
- name: Unit Tests
run: |
cd ./godot
./bin/godot.windows.opt.tools.64.exe --test
./bin/godot.windows.editor.x86_64.exe --test
cd ../

- uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Godex is a Godot Engine ecs library.
**Disclaimer:** this module is still in development, open an [issues](https://github.com/GodotECS/godex/issues) to report any problem or a new [discussion](https://github.com/GodotECS/godex/discussions) if you need any help. Any form of contribution is welcome.

### The tested Godot version
Is `master` `35cfaafda8073f700c9d2fe42a43d3d81eaaea67`, please open an issue if the current master is not working or doesn't compile.
Is `master` `92bee43adba8d2401ef40e2480e53087bcb1eaf1`, please open an issue if the current master is not working or doesn't compile.

### What is ECS
Shortened as ECS, the Entity Component System is an architectural design pattern that allow to organize the data in a way so that the workload can be split into small and easy programs.
Expand Down
2 changes: 1 addition & 1 deletion SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Import("env")
Import("env_modules")

env_ecs = env_modules.Clone()
if env_ecs["float"] == "64":
if env_ecs["precision"] == "double":
env_ecs.Append(CPPDEFINES=["BT_USE_DOUBLE_PRECISION=1"])

methods_ecs.generate_system_structs()
Expand Down
80 changes: 66 additions & 14 deletions ecs.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

#include "ecs.h"
#include <core/config/project_settings.h>
#include <core/io/dir_access.h>
#include <modules/gdscript/gdscript_parser.h>

#include "components/dynamic_component.h"
#include "core/object/message_queue.h"
Expand Down Expand Up @@ -159,6 +162,43 @@ ECS::ECS() :
}
}

void get_script_files(const String &p_path, Vector<String> &scripts) {
for (const auto &directory : DirAccess::get_directories_at(p_path)) {
get_script_files(p_path.path_join(directory), scripts);
}
for (const auto &file : DirAccess::get_files_at(p_path)) {
auto file_path = p_path.path_join(file);
if (ResourceLoader::get_resource_type(file_path) == "GDScript") {
scripts.push_back(file_path);
}
}
}

void ECS::preload_scripts() {
if (Engine::get_singleton()->is_project_manager_hint()) {
return;
}

Vector<String> scripts;
print_line("Preloading component and system scripts");
get_script_files("res://", scripts);

for (const auto &script : scripts) {
auto code = FileAccess::get_file_as_string(script);
GDScriptParser parser;
if (parser.parse(code, script, false) == OK) {
auto tree = parser.get_tree();
if (tree->extends.has("System")) {
register_dynamic_system(script.get_file());
}

if (tree->extends.has("Component")) {
register_or_get_id_for_component_name(script.get_file());
}
}
}
}

ECS::~ECS() {
}

Expand Down Expand Up @@ -1041,11 +1081,7 @@ const LocalVector<godex::component_id> &ECS::get_spawnable_components(godex::spa
return spawners_info[p_spawner].components;
}

uint32_t ECS::register_or_update_script_component(
const StringName &p_name,
const LocalVector<ScriptProperty> &p_properties,
StorageType p_storage_type,
Vector<StringName> p_spawners) {
uint32_t ECS::register_or_get_id_for_component_name(const StringName &p_name) {
godex::component_id id = get_component_id(p_name);
DynamicComponentInfo *info;

Expand All @@ -1058,18 +1094,38 @@ uint32_t ECS::register_or_update_script_component(
components.push_back(p_name);
components_info.push_back(ComponentInfo());
components_info[id].dynamic_component_info = info;
} else {
// This is an old component, verify is a script component.
ERR_FAIL_COND_V_MSG(components_info[id].dynamic_component_info == nullptr, godex::COMPONENT_NONE, "This component " + p_name + " is not a script component and can't be updated. Your component must be an unique name.");
info = components_info[id].dynamic_component_info;

// Add a new scripting constant, for fast and easy `component` access.
ClassDB::bind_integer_constant(get_class_static(), StringName(), String(p_name).replace(".", "_"), id);
print_line("ComponentScript: " + p_name + " registered with ID: " + itos(id));
}

return id;
}

uint32_t ECS::register_or_update_script_component(
const StringName &p_name,
const LocalVector<ScriptProperty> &p_properties,
StorageType p_storage_type,
Vector<StringName> p_spawners) {
godex::component_id id = register_or_get_id_for_component_name(p_name);
DynamicComponentInfo *info;
ERR_FAIL_COND_V_MSG(components_info[id].dynamic_component_info == nullptr, godex::COMPONENT_NONE, "This component " + p_name + " is not a script component and can't be updated. Your component must be an unique name.");
info = components_info[id].dynamic_component_info;

info->property_map.resize(p_properties.size());
info->properties.resize(p_properties.size());
info->defaults.resize(p_properties.size());

// Validate and initialize the parameters.
for (uint32_t i = 0; i < p_properties.size(); i += 1) {
if (

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra whitespace

// Filter GDScript file name
p_properties[i].property.name == p_name
// Filter C# file name. It uses only the class name
|| p_properties[i].property.name + ".cs" == p_name) {
continue;
}
// Is type supported?
switch (p_properties[i].property.type) {
case Variant::NIL:
Expand All @@ -1078,7 +1134,7 @@ uint32_t ECS::register_or_update_script_component(
case Variant::SIGNAL:
case Variant::CALLABLE:
// TODO what about dictionary and arrays?
ERR_PRINT("The script component " + p_name + " is using a pointer variable. This is unsafe, so not supported. Please use a databag.");
ERR_PRINT("The property " + p_properties[i].property.name + " of script component " + p_name + " is using a pointer variable. This is unsafe, so not supported. Please use a databag.");
return UINT32_MAX;
default:
// Valid!
Expand Down Expand Up @@ -1108,10 +1164,6 @@ uint32_t ECS::register_or_update_script_component(
spawners_info[spawner].components.push_back(info->component_id);
}

// Add a new scripting constant, for fast and easy `component` access.
ClassDB::bind_integer_constant(get_class_static(), StringName(), String(p_name).replace(".", "_"), id);
print_line("ComponentScript: " + p_name + " registered with ID: " + itos(id));

return id;
}

Expand Down
3 changes: 3 additions & 0 deletions ecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ class ECS : public Object {
template <class C>
static void register_component(StorageBase *(*create_storage)());

static uint32_t register_or_get_id_for_component_name(const StringName &p_name);
static uint32_t register_or_update_script_component(const StringName &p_name, const LocalVector<ScriptProperty> &p_properties, StorageType p_storage_type, Vector<StringName> p_spawners);

static uint32_t get_components_count();
Expand Down Expand Up @@ -488,6 +489,8 @@ class ECS : public Object {
/// time, making the pipeline switch immediate.
static void system_set_active_system(godex::system_id p_id, uint8_t *p_mem, bool p_active);

static void preload_scripts();

private:
static void clear_emitters_for_system(godex::system_id p_id);

Expand Down
2 changes: 1 addition & 1 deletion iterators/dynamic_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void DynamicQuery::_bind_methods() {
ClassDB::bind_method(D_METHOD("not_component", "component_id"), &DynamicQuery::not_component);

ClassDB::bind_method(D_METHOD("is_valid"), &DynamicQuery::is_valid);
ClassDB::bind_method(D_METHOD("prepare_world"), &DynamicQuery::prepare_world_script);
ClassDB::bind_method(D_METHOD("prepare_world", "world"), &DynamicQuery::prepare_world_script);
ClassDB::bind_method(D_METHOD("reset"), &DynamicQuery::reset);
ClassDB::bind_method(D_METHOD("get_component", "index"), &DynamicQuery::get_access_by_index_gd);

Expand Down
5 changes: 4 additions & 1 deletion modules/bullet_physics/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

Import("env")
Import("env_modules")
import methods

env_bullet = env_modules.Clone()

thirdparty_obj = []

env.Append(builtin_bullet=True)
if methods.using_clang(env_bullet) or methods.using_emcc(env_bullet):
env_bullet.Append(CXXFLAGS=["-frelaxed-template-template-args"])

# Add bullet header, no need to compile Bullet third party, because it's
# already done by the godot bullet module.
Expand Down Expand Up @@ -208,7 +211,7 @@ if env["builtin_bullet"]:
if env["target"] == "debug" or env["target"] == "release_debug":
env_bullet.Append(CPPDEFINES=["DEBUG"])

if env["float"] == "64":
if env["precision"] == "double":
env_bullet.Append(CPPDEFINES=["BT_USE_DOUBLE_PRECISION"])

env_bullet.Append(CPPDEFINES=["BT_USE_OLD_DAMPING_METHOD"])
Expand Down
Loading