DucktapeEngine / Ducktape

Ducktape - An open source 3d C++ game engine.
MIT License
127 stars 25 forks source link

Parent-Child Relationship System #173

Closed aryanbaburajan closed 1 year ago

aryanbaburajan commented 1 year ago

Is your feature request related to a problem? Please describe. As of now, there does not exist a way to "group" multiple Entities together, such as Meshes of a single Model.

Describe the solution you'd like Implement Parent-child Relationship system using Components. The whole system would run on a component:

class Relationship
{
public:
    Entity parent;
    std::vector<Entity> children;

    SetParent(Entity parent);
    AddChild(Entity child);
    RemoveChild(Entity child);
};

Here's a sample usage:


Entity parent = scene.CreateEntity();
Entity child = scene.CreateEntity();

scene.Assign<Relationship>(parent).AddChild(child);
// OR Alternative method:
scene.Assign<Relationship>(child).SetParent(parent);```
ege-del commented 1 year ago

afaik using vectors would be bad for performance here is a cache friendly approach provided by creator of entt https://skypjack.github.io/2019-06-25-ecs-baf-part-4/

aryanbaburajan commented 1 year ago

Ah, that indeed seems like the better approach of solving this. The Unconstrained model should fit our needs pretty well.

I was finished implementing the before-mentioned hierarchy system using vectors, guess it's time to rewrite before I push haha. Ducktape's been pretty stale in terms of development lately due to my exams so it'll take a month or two before I get back.

Anyway, thanks for pointing it out!