sdslabs / Rootex

An advanced C++ 3D game engine powering an in-production game yet to be announced
https://rootex.readthedocs.io/
Other
215 stars 36 forks source link

WIP: Refactoring scene tree to make unordered set of unique pointers #605

Open aaryaag03 opened 1 year ago

r41k0u commented 1 year ago

Please give a better PR name like WIP: Refactoring scene tree to use unordered_set of unique_ptr or something like that

sin3point14 commented 1 year ago

I talked about a probably approach with archit which would need minimal changes and should remove those pesky edge cases. Only allow saving the root scene’s children and don’t allow 2 scenes of the same path to be attached to the root. Ofc if you must attach 2 scenes of the same path, you still can 2 make 2 empty scene children of the root and add those 2 scenes as their children. Since we serialise(afaik) all the children into the file of the direct root children, saved scenes should only be treated as “templates” ie you can instantiate them as child of some scene and then change the properties. Saving the root child parent node(the node in the parent hierarchy which is also a root child) will result in the scene of that root child to contain all the data of this instantiated child scene. Another way to think about this is that changing the contents of that child scene file would have no effect on this attached instance, it lost all connections to its source file and the moment it was attached as a non root child.

tldr: only allow saving of direct root child scenes ie root child scenes are the only scenes who know their original file path and disallow multiple root children from same path. This goes well with rootex philosophy of everything can be uniquely identified with its file path.

On Thu, 16 Feb 2023 at 8:48 PM, Twarit Waikar @.***> wrote:

@.**** commented on this pull request.

In rootex/framework/scene.h https://github.com/sdslabs/Rootex/pull/605#discussion_r1108623891:

@@ -51,7 +51,7 @@ class Scene Entity m_Entity;

Scene* m_ParentScene = nullptr;

  • Vector<Ptr> m_ChildrenScenes;
  • Unordered_set<Ptr> m_ChildrenScenes;

One way the order is important is when you need to iterate over the children to display them on the editor. Seeing the order of the children change as you make any changes in the scene hierarchy can get confusing.

— Reply to this email directly, view it on GitHub https://github.com/sdslabs/Rootex/pull/605#discussion_r1108623891, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKMII7OCZBWVPYSGHQWAFA3WXZALPANCNFSM6AAAAAAUM3ALIE . You are receiving this because you were mentioned.Message ID: @.***>