Coder Social home page Coder Social logo

godotecs / godex Goto Github PK

View Code? Open in Web Editor NEW
1.1K 1.1K 67.0 3.42 MB

Godex is a Godot Engine ECS library.

License: MIT License

Python 2.27% C++ 93.24% C 2.12% Shell 2.13% PowerShell 0.23%
ecs entity-component-system game-development game-engine gamedev

godex's People

Contributors

andreacatania avatar beliar83 avatar blackxsnow avatar carlos-ramos-73 avatar fire avatar florianvazelle avatar jbrod22 avatar lewiji avatar pspritechologist avatar ricardrc avatar tdcranila avatar tpltnt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godex's Issues

Import a Godot Packed Scene into ECS

Context and Problem Statement

Not able to use the standard Godot import tooling to import entities. We want to import the packed scene into entity and entity3d format.

Decision Drivers

  • We lack content in the ECS ecosystem
  • It's mindless to convert
  • Converting should be not noticeably slow
  • Blocks ECS skeletons
  • Blocks ECS physics engine

Considered Options

  • Convert manually
  • Write a plugin in C++
  • Write a plugin in gdscript

Decision Outcome

Chosen option "Write a plugin in C++" because it was the fastest and does not require a separate addon.

Positive Consequences

  • Fastest
  • Can be in the single Godot executable

Negative Consequences

  • Hard to bug fix

Pros and Cons of the Options

Option convert manually

We go over the packed scene and convert them to a packed scene using Godex components. Godex components are added based on the type and the properties.

  • Node3D (base class and only the base class)
    • Hierarchy of nodes, and the transform.
  • MeshInstance3D (without skeleton)
    • Hierarchy of nodes, the mesh and the transform.
  • MeshInstance3D (with skeleton)
    • passthrough
  • BoneAttachment3D
    • passthrough
  • Skeleton3D
    • passthrough
  • MultiMeshInstance3D
    • passthrough
  • CSGShape3D
    • passthrough
  • GridMap
    • passthrough
  • Camera3D
    • passthrough
  • Light3D
    • passthrough
  • AnimationPlayer
    • passthrough

For Node2D we passthrough.

Everything else stays the same until we have a conversion for it.

  • Good, Know exactly what we want
  • Bad, because there are ways to do the conversion wrong by human error

Option GDScript

Automate manual option in GDscript.

  • Good, it's easy to iterate
  • Bad, because it's not embedded

Option C++

Automate manual option in C++.

In scene importer add a checkbox for conversion and it is enabled by default.

  • Good, it's embedded
  • Good, it's fast
  • Bad, because of C++ programming friction

Links

In-editor UX enhancements for systems and resources

I'm proposing three features:

  1. A way to remove specific resources added to a world.
  2. A way to remove specific systems added to a pipeline.
  3. A way to rearrange systems in a pipeline (new to Godex, but I'm assuming the system order is strictly enforced, hence the indexing).

@AndreaCatania, would you prefer a PR, or would you rather implement these yourself? Please let me know if I'm missing something.

Event mechanism proposal

Regarding events, we should have a common base that works. So to be really solid. In the other game engines, I saw until now, I feel like the events mechanism is just an hack and doesn't properly integrate with ECS workflow.

For Godex I been contemplating the idea that the event should be a piece of that can be associated to an entity easily; so a System can perform operations on it like any other system. Check my idea.

The event is a special Component (In a sec you understand what I mean by special) that when emitted it's directly attached to the entity who triggered it.

Let's say you have to build an FPS and you have this bullet that has to deal the damage when hit a Collider. The system that moves such bullet and perform the collision check, when detects a collider append the event component DamageEvent on such entity.

Later on the pipeline you have a system like this:

extends System
## This system computes the damages of your entities. It's here where you want to check eventual shields and so on.

func _prepare():
    with_component("Health", MUTABLE)
    with_component("DamageEvent", IMMUTABLE)

func _for_each(health_component, damage_events):
    for event in damage_events:
        health_component.health -= event.damage

The above system, computes the health loss for all the entities that have an Health component and the event component DamageEvent.

If you, later add a new feature to the game, let's say, an Area Of Effect that deals damage to the characters that goes in: you can emit the event and so attach it to the entity that entered that area. You just need to add the system that emits such event, and anything else because the System that catches and pairs the DamageEvent with the Health event already exists.
Before, I said that this event component is special. It is, because unlikely the other component, it's destroyed at the end of each processing automatically so that you can't catch the same event twice with the same System.

Adding or selecting a WorldECS node eliminates greater Godot window context

godex-window.mp4

This seems to be a new bug. Previously, I recall the WorldECS window being treated as a sub-window, but now it is treated as the whole window and everything else disappears. I'm not sure if there's some button I'm missing that will take me back.

The Godot build in question uses Godex 114646e and the recommended commit of Godot from the README. I'm happy to provide any other information if requested.

Consider use binary search or another storage algorithm for `ChangeList`.

Consider use binary search or another storage algorithm for ChangeList.

The ChangeList is used to mark an Entity Component as changed:

  • When the Entity is already marked as changed nothing should happen.
  • When the Entity is not yet marked as changed, it is stored inside an array.
  • Allows to iterate over all the changed elements.

Note: The data to marked as changed, is not sorted.

Choose query storage at runtime.

Sometimes you may want to process a specific component, depending on some runtime events.

Let's suppose you have a set of rooms, composed by tiles, and you need a query that takes all the obstacle tiles for that specific room.

Each room has it's own tag: Room1, Room2, Room3, RoomN, so you can query those tiles in this way:

void search_near_obstacle(Query<Room1, Tile, TileObstacle> &p_query){
    // Do cool stuff.
}

Depending on some events, you may want to do the same thing for Room2 or Room3 so you are forced to create a System per each room.

A better solution would be expand that system per each room, so that it's possible to fetch just the needed room.

void search_near_obstacle(Query<Runtime<Room1, Room2, Room3>, Tile, TileObstacle> &p_query){
    switch(event){
        case event_a:
            p_query.set_runtime<Room1>(0);
            break;
        case event_b:
            p_query.set_runtime<Room2>(0);
            break;
        case event_c:
            p_query.set_runtime<Room3>(0);
            break;
    };

    // Do cool stuff.
}

Consider improve the syntax.

Patch cannot be applied in a Windows build

When applying the patch in a windows build, the git throws errors that the patch does not apply:
git apply modules/godex/patches/add_custom_iterator.patch
error: patch failed: SConstruct:543
error: SConstruct: patch does not apply
error: patch failed: core/config/engine.h:88
error: core/config/engine.h: patch does not apply
error: patch failed: main/main.cpp:1284
error: main/main.cpp: patch does not apply
error: patch failed: main/main.h:54
error: main/main.h: patch does not apply

I think this might due to linespacing formatting issues between unix and windows systems.
The following command successfully applied the patch with no errors:
git apply --ignore-space-change --ignore-whitespace modules/godex/patches/add_custom_iterator.patch

BUT will not allow it to build successfully:

C:\Users\Carlos\Documents\Godot\godot\modules\godex\iterators\../storage/storage.h(206): error C2663: 'MeshComponent::set': 2 overloads have no legal conversion for 'this' pointer

C:\Users\Carlos\Documents\Godot\godot\modules\godex\iterators\../storage/storage.h(201): note: while compiling class template member function 'void Storage<const C>::insert_dynamic(EntityID,const Dictionary &)' with [ C=MeshComponent ]

C:\Users\Carlos\Documents\Godot\godot\modules\godex\systems\../iterators/query.h(201): note: see reference to class template instantiation 'Storage<const C>' being compiled with [ C=MeshComponent ]

C:\Users\Carlos\Documents\Godot\godot\modules\godex\systems\../iterators/query.h(195): note: while compiling class template member function 'bool QueryStorage<const MeshComponent,const TransformComponent>::has_data(EntityID) const'

C:\Users\Carlos\Documents\Godot\godot\modules\godex\systems\../iterators/query.h(263): note: see reference to function template instantiation 'bool QueryStorage<const MeshComponent,const TransformComponent>::has_data(EntityID) const' being compiled

C:\Users\Carlos\Documents\Godot\godot\modules\godex\systems\../iterators/query.h(230): note: see reference to class template instantiation 'QueryStorage<const MeshComponent,const TransformComponent>' being compiled

C:\Users\Carlos\Documents\Godot\godot\modules\godex\systems/system_builder.h(87): note: see reference to class template instantiation 'Query<const MeshComponent,const TransformComponent>' being compiled

C:\Users\Carlos\Documents\Godot\godot\modules\godex\systems\system_exe_funcs.gen.h(12): note: see reference to class template instantiation 'SystemBuilder::DataFetcher<P1>' being compiled with [ P1=Query<const MeshComponent,const TransformComponent> & ] modules\godex\register_types.cpp(113): note: see reference to function template instantiation 'void SystemBuilder::system_exec_func<RenderingServerDatabag*,Query<const MeshComponent,const TransformComponent>&>(World *,void (__cdecl *)(P0,P1))' being compiled with [ P0=RenderingServerDatabag *, P1=Query<const MeshComponent,const TransformComponent> & ]

scons: *** [modules\godex\register_types.windows.tools.64.obj] Error 2

scons: building terminated because of errors.

Improve ECS singleton syntax

If you need to read the entity Component, or a Databag, from a standard GDScript function, it's possible to use the ECS singleton in this way:

func _ready():
    var component = ECS.get_active_world().get_entity_component(get_entity_id(), ECS.TransformComponent)

The function get_active_world is used to get the currently active world, however, this function is really verbose. Is it possible to make it shorter?

The function get_entity_component is good, but still verbose. Is it possible to make this shorter?

What about this?
Is still understandable?
Worth it?

func _ready():
    var component = ECS.get_world().get_component(get_entity_id(), ECS.TransformComponent)

Add SystemBundle

Bound with #39

The SystemBundle is a collection of Systems that allow to add Systems, to the pipeline, in bulk. This is useful to speed-up and make easier the pipeline composition.

Some example are:

  • RenderingBundle
  • PhysicsBundle
  • ....

Feedbacks

  • I can override or add to a bundle (Bundle MyRigidBody = Godex.RigidBody & SomeComponent)

Notes

  • The SystemBundle just contains actual Systems that can still be added one by one.
  • The SystemBundle is just an Editor concept so it doesn't bloat the actual godex::pipeline core.

Query "changed" filter is missing.

The query changed filter is indispensable to properly detect changed components and perform one time task. Right now, it's missing on the Mesh updated. The transform of each Mesh is updated even if it doesn't change.

Add hierarchy sorting

Add hierarchy sorting at the end of each iteration. The grouping must take care of:

  • Hierarchy structure.
  • Most modified data.
  • Most accessed data.

Godex does not compile with the latest Godot master

I am on this commit of Godot: godotengine/godot@0e77dc6

I am on Windows and this is the command I ran:

scons -j8 p=windows tools=yes target=release_debug

Here are the errors I get:

PS F:\godot> scons -j8 p=windows tools=yes target=release_debug
scons: Reading SConscript files ...
Configuring for Windows: target=release_debug, bits=default
Found MSVC version 14.2, arch amd64, bits=64
YASM is necessary for WebM SIMD optimizations.
WebM SIMD optimizations are disabled. Check if your CPU architecture, CPU bits or platform are supported!
Checking for C header file mntent.h... (cached) no
scons: done reading SConscript files.
scons: Building targets ...
[  2%] Compiling ==> platform\windows\os_windows.cpp
[  3%] os_windows.cpp
[  3%] rc /DDEBUG_ENABLED /DWINDOWS_SUBSYSTEM_CONSOLE /DWINDOWS_ENABLED /DWASAPI_ENABLED /DWINMIDI_ENABLED /DTYPED_METHOD_BIND /DWIN32 /DMSVC /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DNOMINMAX /D_WIN64 /DVULKAN_ENABLED /DCUSTOM_ITERATOR /DCUSTOM_PHYSICS_ITERATOR /DTOOLS_ENABLED /DMINIZIP_ENABLED /DZSTD_STATIC_LINKING_ONLY /Ithirdparty\freetype\include /Ithirdparty\libpng /Ithirdparty\vulkan /Ithirdparty\vulkan\include /Ithirdparty\vulkan\loader /Ithirdparty\zstd /Ithirdparty\zlib /Iplatform\windows /I. /nologo /foplatform\windows\godot_res.windows.opt.tools.64.obj platform\windows\godot_res.rc
[  3%] Generating enabled modules header.
[ 15%] Compiling ==> thirdparty\miniupnpc\miniupnpc\miniwget.c
[ 15%] Compiling ==> thirdparty\miniupnpc\miniupnpc\minisoap.c
[ 15%] miniwget.c
[ 16%] minisoap.c
[ 40%] Compiling ==> modules\godex\register_types.cpp
[ 40%] register_types.cpp
[ 40%] Compiling ==> modules\godex\godot\editor_plugins\components_gizmo_3d.cpp
[ 40%] Compiling ==> modules\godex\godot\editor_plugins\editor_world_ecs.cpp
components_gizmo_3d.cpp
[ 40%] Compiling ==> modules\upnp\upnp_device.cpp
editor_world_ecs.cpp
[ 40%] Compiling ==> modules\upnp\upnp.cpp
[ 40%] Compiling ==> modules\upnp\register_types.cpp
upnp_device.cpp
[ 40%] upnp.cpp
Compiling ==> main\main.cpp
register_types.cpp
main.cpp
[ 40%] Compiling ==> modules\text_server_adv\text_server_adv.cpp
text_server_adv.cpp
[ 40%] Compiling ==> modules\register_module_types.gen.cpp
register_module_types.gen.cpp
[ 40%] Linking Static Library ==> modules\modules.windows.opt.tools.64.lib
[ 40%] Compiling ==> modules\text_server_adv\dynamic_font_adv.cpp
dynamic_font_adv.cpp
[ 40%] Compiling ==> modules\godex\godot\editor_plugins\entity_editor_plugin.cpp
entity_editor_plugin.cpp
[ 40%] Linking Static Library ==> modules\module_upnp.windows.opt.tools.64.lib
[ 40%] Compiling ==> modules\godex\godot\nodes\ecs_world.cpp
F:\godot\modules\godex\godot\editor_plugins\editor_world_ecs.h(169): error C3668: 'EditorWorldECS::_changed_callback': method with override specifier 'override' did not override any base class methods
ecs_world.cpp
modules\godex\godot\editor_plugins\editor_world_ecs.cpp(694): error C2039: 'remove_change_receptor': is not a member of 'WorldECS'
F:\godot\modules\godex\godot\editor_plugins\../nodes/ecs_world.h(79): note: see declaration of 'WorldECS'
modules\godex\godot\editor_plugins\editor_world_ecs.cpp(707): error C2039: 'add_change_receptor': is not a member of 'WorldECS'
F:\godot\modules\godex\godot\editor_plugins\../nodes/ecs_world.h(79): note: see declaration of 'WorldECS'
modules\godex\godot\editor_plugins\editor_world_ecs.cpp(719): error C2039: 'remove_change_receptor': is not a member of 'PipelineECS'
F:\godot\modules\godex\godot\editor_plugins\../nodes/ecs_world.h(18): note: see declaration of 'PipelineECS'
modules\godex\godot\editor_plugins\editor_world_ecs.cpp(725): error C2039: 'add_change_receptor': is not a member of 'PipelineECS'
F:\godot\modules\godex\godot\editor_plugins\../nodes/ecs_world.h(18): note: see declaration of 'PipelineECS'
modules\godex\godot\editor_plugins\editor_world_ecs.cpp(1094): error C2039: '_change_notify': is not a member of 'WorldECS'
F:\godot\modules\godex\godot\editor_plugins\../nodes/ecs_world.h(79): note: see declaration of 'WorldECS'
scons: *** [modules\godex\godot\editor_plugins\editor_world_ecs.windows.opt.tools.64.obj] Error 2
F:\godot\modules\godex\godot/editor_plugins/editor_world_ecs.h(169): error C3668: 'EditorWorldECS::_changed_callback': method with override specifier 'override' did not override any base class methods
F:\godot\modules\godex\godot/editor_plugins/entity_editor_plugin.h(42): error C3668: 'EntityEditor::_changed_callback': method with override specifier 'override' did not override any base class methods
F:\godot\modules\godex\godot\editor_plugins\../nodes/entity.h(745): error C2039: '_change_notify': is not a member of 'Entity3D'
F:\godot\modules\godex\godot\editor_plugins\../nodes/entity.h(94): note: see declaration of 'Entity3D'
F:\godot\modules\godex\godot\editor_plugins\../nodes/entity.h(744): note: while compiling class template member function 'void EntityInternal<Entity3D>::update_components_data(void)'
F:\godot\modules\godex\godot\editor_plugins\../nodes/entity.h(202): note: see reference to function template instantiation 'void EntityInternal<Entity3D>::update_components_data(void)' being compiled
F:\godot\modules\godex\godot\editor_plugins\../nodes/entity.h(98): note: see reference to class template instantiation 'EntityInternal<Entity3D>' being compiled
F:\godot\modules\godex\godot\editor_plugins\../nodes/entity.h(745): error C2039: '_change_notify': is not a member of 'Entity2D'
F:\godot\modules\godex\godot\editor_plugins\../nodes/entity.h(221): note: see declaration of 'Entity2D'
F:\godot\modules\godex\godot\editor_plugins\../nodes/entity.h(744): note: while compiling class template member function 'void EntityInternal<Entity2D>::update_components_data(void)'
F:\godot\modules\godex\godot\editor_plugins\../nodes/entity.h(293): note: see reference to function template instantiation 'void EntityInternal<Entity2D>::update_components_data(void)' being compiled
F:\godot\modules\godex\godot\editor_plugins\../nodes/entity.h(225): note: see reference to class template instantiation 'EntityInternal<Entity2D>' being compiled
scons: *** [modules\godex\register_types.windows.opt.tools.64.obj] Error 2
scons: *** [modules\godex\godot\editor_plugins\components_gizmo_3d.windows.opt.tools.64.obj] Error 2
modules\godex\godot\nodes\ecs_world.cpp(40): error C3861: '_change_notify': identifier not found
modules\godex\godot\nodes\ecs_world.cpp(49): error C3861: '_change_notify': identifier not found
modules\godex\godot\nodes\ecs_world.cpp(69): error C3861: '_change_notify': identifier not found
modules\godex\godot\nodes\ecs_world.cpp(74): error C3861: '_change_notify': identifier not found
modules\godex\godot\nodes\ecs_world.cpp(354): error C3861: '_change_notify': identifier not found
modules\godex\godot\nodes\ecs_world.cpp(359): error C3861: '_change_notify': identifier not found
scons: *** [modules\godex\godot\nodes\ecs_world.windows.opt.tools.64.obj] Error 2
F:\godot\modules\godex\godot\editor_plugins\entity_editor_plugin.h(42): error C3668: 'EntityEditor::_changed_callback': method with override specifier 'override' did not override any base class methods
scons: *** [modules\godex\godot\editor_plugins\entity_editor_plugin.windows.opt.tools.64.obj] Error 2
scons: building terminated because of errors.

Here is a project that you should be able to clone/get submodules (for godex)

https://github.com/sean-clayton/godot

ECS Skeletals

Describe the project you are working on

3D Game

Describe the problem or limitation you are having in your project

Wanted better performance on skeleton animation and IK

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Define skeletons in ecs

  1. skeleton
  2. animation player
  3. skeletal animation input to the compute shaders for skinning and blend shapes
  4. ik

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

???

If this enhancement will not be used often, can it be worked around with a few lines of script?

IK and Skeleton is thousands of lines of code.

Is there a reason why this should be core and not an add-on in the asset library?

GDScript is slow

Proposal: automatic Component and System registration

It would be nice to have a simpler component and systema registration/removal.

I would propose the Component and System registration to be automatic. I mean, the posibility to choose any resource .gd script as a System or Component without the needing of first registering it as one to the ECS world. The registration would take place behind the scenes after the "ok" or double click.

Also, a list of current registered Components and Systems in the editor to remove one if wanted.

Linux build errors

Impressive work, thanks for sharing it. I wanted to try it out before finding out that my card is probably too old, I create this issue only FYI, close it when you want.

I tried to build master first then the branch mentioned in the wiki Setup page, without the godex module and without the patch I can build and run both, if I add the module and apply the patch I have errors with both:

Debian/sid gcc-10

branch master:

[ 33%] Compiling ==> modules/godex/main.cpp
[ 33%] Compiling ==> modules/godex/register_types.cpp
In file included from modules/godex/register_types.cpp:17:
modules/godex/godot/editor_plugins/editor_world_ecs.h:137:7: error: 'void EditorWorldECS::_changed_callback(Object*, const char*)' marked 'override', but does not override
  137 |  void _changed_callback(Object *p_changed, const char *p_prop) override;
      |       ^~~~~~~~~~~~~~~~~
In file included from modules/godex/register_types.cpp:18:
modules/godex/godot/editor_plugins/entity_editor_plugin.h:42:15: error: 'virtual void EntityEditor::_changed_callback(Object*, const char*)' marked 'override', but does not override
   42 |  virtual void _changed_callback(Object *p_changed, const char *p_prop) override;
      |               ^~~~~~~~~~~~~~~~~
In file included from modules/godex/godot/editor_plugins/components_gizmo_3d.h:3,
                 from modules/godex/register_types.cpp:16:
modules/godex/godot/editor_plugins/../nodes/entity.h: In instantiation of 'void EntityInternal<C>::update_components_data() [with C = Entity3D]':
modules/godex/godot/editor_plugins/../nodes/entity.h:202:33:   required from here
modules/godex/godot/editor_plugins/../nodes/entity.h:745:9: error: 'class Entity3D' has no member named '_change_notify'
  745 |  owner->_change_notify("components_data");
      |  ~~~~~~~^~~~~~~~~~~~~~
modules/godex/godot/editor_plugins/../nodes/entity.h: In instantiation of 'void EntityInternal<C>::update_components_data() [with C = Entity2D]':
modules/godex/godot/editor_plugins/../nodes/entity.h:293:33:   required from here
modules/godex/godot/editor_plugins/../nodes/entity.h:745:9: error: 'class Entity2D' has no member named '_change_notify'
scons: *** [modules/godex/register_types.linuxbsd.tools.64.o] Error 1
scons: building terminated because of errors.

detached branch over 36c943260ed40c6e31a6ecff7f6e1674714b4fcb:

[ 30%] Linking Static Library ==> modules/libmodule_gridmap.linuxbsd.tools.64.a
Ranlib Library         ==> modules/libmodule_gridmap.linuxbsd.tools.64.a
[ 30%] Compiling ==> modules/godex/components/child.cpp
In file included from modules/godex/components/../systems/../iterators/query.h:5,
                 from modules/godex/components/../systems/system_builder.h:7,
                 from modules/godex/components/../ecs.h:11,
                 from modules/godex/components/component.h:5,
                 from modules/godex/components/child.h:3,
                 from modules/godex/components/child.cpp:1:
modules/godex/components/../systems/../iterators/../storage/storage.h: In member function 'void ChangeList::notify_updated(EntityID)':
modules/godex/components/../systems/../iterators/../storage/storage.h:50:14: error: 'class LocalVector<EntityID>' has no member named 'remove_unordered'
   50 |      changed.remove_unordered(index);
      |              ^~~~~~~~~~~~~~~~
modules/godex/components/../systems/../iterators/../storage/storage.h:55:13: error: 'class LocalVector<EntityID>' has no member named 'remove_unordered'
   55 |     changed.remove_unordered(index);
      |             ^~~~~~~~~~~~~~~~
scons: *** [modules/godex/components/child.linuxbsd.tools.64.o] Error 1
scons: building terminated because of errors.

Make Component and Databag trivially copyable

  • Make Component and Databag trivial copyable and use static_assert(std::is_trivially_copyable<T>::value); and static_assert(std::is_trivially_copyable<D>::value); to make sure all registered Components and Databags are trivially copyable.
  • Make Batch also trivial

GDScript System execution without a query

Issue

The current GDScript System syntax, doesn't allow to create Systems without a Query. This is an example:

extends System

func _prepare():
    with_component("TransformComponent")
    with_databag("WorldCommands")

func _for_each(transform_comp, world):
    print(transform_comp)

If you want to perform some operations like add or remove Entities that are not coupled with a Query there is no way to do it.

Proposal
If we add a new function _execute that receives the query as an accessor:

extends System

func _prepare():
    with_component("TransformComponent")
    with_databag("WorldCommands")

func _execute(query, world):
    # So `world` is usable regardless the query.
    while query.is_done() == false:
        var accessors = query.get()
        print(accessors.0)

However, the function _for_each would not be removed.

Remove WorldECSCommands

Consider remove WorldECSCommands so the WorldCommands databag can be used to add remove Entities.

Using Godot api in ECS systems

Problem

It is not clear how we can get the Godot api to work in the ECS context. As an example, using Godot physics api to detect collisions or make physics simulation in a ECS system. I can see there is a Shape3dComponent but It is not clear how it can be used to access the Godot physics api which relies on kinematic, static bodies and other classes. The same applies for other classes and features. Maybe it is about documentation.

Proposal

As an idea, I don't know how feasible it is to get Godot scenes registered as components to have the full Godot api available in ECS systems. While adding complex scenes as components is not what ECS is about it could integrate Godot in the ECS paradigm.

LLVM Compilation Error

Description

When compiling with LLVM the compilation fails. When compiling without LLVM it works fine.

Steps to reproduce

  1. Clone godot and checkout commit godotengine/godot@ae6b2d6e
  2. Add godex submodule (master at the time of writing at commit 6146699)
  3. Apply patch
  4. Compile with scons -j8 platform=linuxbsd use_llvm=yes use_lld=yes

Error

In file included from modules/godex/components/dynamic_component.cpp:1:
In file included from modules/godex/components/dynamic_component.h:3:
modules/godex/components/component.h:99:39: error: 'target' is a private member of 'DataAccessor'
                return static_cast<const T *>(comp->target);
                                                    ^
modules/godex/components/../systems/../iterators/../world/../ecs_types.h:388:8: note: declared private here
        void *target = nullptr;
              ^

Gist with the complete log

Versions

OS: Solus x86_64 (Kernel 5.11.6-174.current)
GCC: 10.2.0
LLVM: 10.0.1
scons: v3.1.1

Additional notes

scons -j8 platform=linuxbsd compiles successfully. Compiling with LLVM but without godex compiles successfully.

Patch does not apply

Problem

Following the Compiling wiki page with Godot at this commit and Godex at this commit, I ran git apply modules/godex/patches/add_custom_iterator.patch.

That resulted in this error:

error: patch failed: core/config/engine.h:88
error: core/config/engine.h: patch does not apply
error: patch failed: main/main.cpp:2497
error: main/main.cpp: patch does not apply

Workaround

I can successfully apply the patch after checking out a previous—albeit recent—commit of Godot like so:

git checkout 2e66e5d5992a521fe27dc88fee92c680f4adf98b

Understandably Godot's master branch is hectic, so the patch will inevitably fall out of sync until this PR is merged. It's probably kind of annoying to maintain the patch. If it helps, I'd be happy to update Godex's wiki by mentioning that last-known compatible Godot commit.

Edit: Actually, I had to make a some minor changes to Godex for Godot to compile with it. I'm wondering, which commit of Godot is safest to use with Godex? I want to avoid recompiling a bunch of times.

Cannot add system

Description

When adding a system via UI it will not become available to use.

Steps to reproduce

  1. Create new Project
  2. Create scene with WorldECS node
  3. Create Pipeline
  4. Add gdscript file extending System
  5. Click on "New system / component" in the ECS plugin
  6. Enter script filename and click "Create"

Here is the system script I used:

extends System

func _prepare():
	with_databag(ECS.FrameTime, IMMUTABLE)
	with_component(ECS.TransformComponent, MUTABLE)

func _for_each(frame_time, transform):
	var new_basis = transform.transform.basis.rotated(Vector3.UP, frame_time.delta)
	transform.transform.basis = new_basis

System/Version

OS: Solus x86_64 (Kernel 5.11.6-174.current)
Godot: godotengine/godot@ae6b2d6e
Godex: 59a955b

Additional Information

I tried debugging this a bit but did not find a solution yet (and don't have much time to investigate further). Here is what I found so far:

  • the system seems to validate fine
  • everything works up to the point where EditorEcs::save_script() is called
  • when the setting is read into the array, it will result in an empty array

This is a snippet from my project.godot file after trying to register the system:

[ECS]
System/scripts="MySystem.gd"

To me this looks like it is saved as a string instead of an array. Could this be a hint to the problem?

Add ComponentBundle

The ComponentBundle is a collection of Component; it can be added to an Entity: all the contained Components are added to that Entity.

This is useful to speed-up Entity composition, for standard things like RigidBody, Meshes, etc... .

Setup CI

Setup CI so to be sure the code always compile to all platforms.
Related #26 #80

Parent ECS entities

Describe the project you are working on

3D Game

Describe the problem or limitation you are having in your project

Unable to recreate parent to child transform. So I'm not able to write a scene root to packed scene converter.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Allow the creation of a parent to child relationship spatially.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The component contains the parent entity ID. A system resolve those transforms, before updating the meshes position.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not trivial done by a few lines of script.

Is there a reason why this should be core and not an add-on in the asset library?

Could be a gd script component.

3D editor is not immediatelly updated on Gizmo interaction.

Regression introduced by: #135

When the Entity transform is changed via gizmo (by dragging it around with the mouse), the 3D object doesn't change the position immediately: It seems like the editor lags. I don't think it's a performance issue because the editor is still running at pretty high FPS. Rather, I suppose that in some function is missing the new notify_property_list_changed call.

Improve pipeline creation UI

Bound with #38

issue
When a new pipeline is added, it's created without any Systems in it, so the developer has to populate it before even be able to use it.

proposal
To improve it, a solution would be pre populate the pipeline, so the developer can immediately use it.

In addition to this the WorldECS could come with the pipelines already setup: this would reduce beginners entry cost, and improve usability.

Tracker

  • Add WorldECS warning to better guide the user. #191
  • Make the WorldECS ready to use by default. #191
  • Add editor to show the pipeline composed by the PipelineBuilder. #186
  • The pipeline view must show the pipeline dispatcher #194
  • Show the PipelineBuilder warning messages on the WorldECS node #192
  • Show the PipelineBuilder warning messages on the editor world ecs #192

LLVM Compilation Error

I am getting the following compilation error message:

modules/godex/components/../systems/../iterators/query.h: In member function 'std::tuple<Batch<typename remove_filter::type>...> QueryStorage::get(EntityID, Space) const':
modules/godex/components/../systems/../iterators/query.h:39:103: error: cannot deduce template arguments for 'tuple' from ()
std::tuple<Batch<remove_filter_t>...> get(EntityID p_id, Space p_mode) const { return std::tuple(); }
^
scons: *** [modules/godex/components/child.linuxbsd.tools.64.o] Error 1
scons: building terminated because of errors.

I am using latest stable Godot and Godex versions and compiling as described in the wiki.

Any idea to fix it? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.