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

improvements to EntityManagers and Filament APIs #7302

Merged
merged 3 commits into from
Oct 26, 2023
Merged

Conversation

pixelflinger
Copy link
Collaborator

@pixelflinger pixelflinger commented Oct 25, 2023

  • we used to to this by deleting operator delete, but this prevented
    the internal "F" classes from being virtual; which can be useful
    when using EntityManger::Listener.
    now we just make the destructor protected in each class.

  • EntityManger::Listener now has a virtual destructor so that
    objects could be correctly destroyed from Listener*

  • all component managers now have the same "base" API

    • getComponentCount()
    • empty()
    • getEntity()
    • getEntities()
  • Scene now has getEntityCount()

  • EntityManager now has getEntityCount()

  • all component manager implement gc() the same way, by calling destroy()

  • SingleInstanceComponentManager::gc() that calls removeComponent() has
    been removed because it's dangerous. removeComponent() is often
    not enough, some additional cleanup might be needed.

- we used to to this by deleting operator delete, but this prevented
  the internal "F" classes from being virtual; which can be useful
  when using EntityManger::Listener.
  now we just make the destructor protected in each class.

- EntityManger::Listener now has a virtual destructor so that
  objects could be correctly destroyed from Listener*
- all component managers now have the same "base" API
    - getComponentCount()
	- empty()
    - getEntity()
    - getEntities()

- Scene now has getEntityCount()

- EntityManager now has getEntityCount()

- all component manager implement gc() the same way, by calling destroy()

- SingleInstanceComponentManager::gc() that calls removeComponent() has
  been removed because it's dangerous. removeComponent() is often
  not enough, some additional cleanup might be needed.
@pixelflinger pixelflinger added the internal Issue/PR does not affect clients label Oct 25, 2023
Comment on lines +147 to +148
// prevent heap allocation
~DebugRegistry() = default;
Copy link
Member

Choose a reason for hiding this comment

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

Could we make FilamentAPI's destructor protected instead of individually on all the subclasses?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, that doesn't help, because the destructor is still public: https://godbolt.org/z/7P19eWsP5

@pixelflinger pixelflinger merged commit e674420 into main Oct 26, 2023
10 checks passed
@pixelflinger pixelflinger deleted the ma/entities branch October 26, 2023 20:10
poweifeng pushed a commit that referenced this pull request Oct 30, 2023
* prevent public classes from being created on the stack

- we used to to this by deleting operator delete, but this prevented
  the internal "F" classes from being virtual; which can be useful
  when using EntityManger::Listener.
  now we just make the destructor protected in each class.

- EntityManger::Listener now has a virtual destructor so that
  objects could be correctly destroyed from Listener*

* improve EntityManger and Component managers

- all component managers now have the same "base" API
    - getComponentCount()
	- empty()
    - getEntity()
    - getEntities()

- Scene now has getEntityCount()

- EntityManager now has getEntityCount()

- all component manager implement gc() the same way, by calling destroy()

- SingleInstanceComponentManager::gc() that calls removeComponent() has
  been removed because it's dangerous. removeComponent() is often
  not enough, some additional cleanup might be needed.
poweifeng pushed a commit that referenced this pull request Oct 31, 2023
* prevent public classes from being created on the stack

- we used to to this by deleting operator delete, but this prevented
  the internal "F" classes from being virtual; which can be useful
  when using EntityManger::Listener.
  now we just make the destructor protected in each class.

- EntityManger::Listener now has a virtual destructor so that
  objects could be correctly destroyed from Listener*

* improve EntityManger and Component managers

- all component managers now have the same "base" API
    - getComponentCount()
	- empty()
    - getEntity()
    - getEntities()

- Scene now has getEntityCount()

- EntityManager now has getEntityCount()

- all component manager implement gc() the same way, by calling destroy()

- SingleInstanceComponentManager::gc() that calls removeComponent() has
  been removed because it's dangerous. removeComponent() is often
  not enough, some additional cleanup might be needed.
plepers pushed a commit to plepers/filament that referenced this pull request Dec 9, 2023
* prevent public classes from being created on the stack

- we used to to this by deleting operator delete, but this prevented
  the internal "F" classes from being virtual; which can be useful
  when using EntityManger::Listener.
  now we just make the destructor protected in each class.

- EntityManger::Listener now has a virtual destructor so that
  objects could be correctly destroyed from Listener*

* improve EntityManger and Component managers

- all component managers now have the same "base" API
    - getComponentCount()
	- empty()
    - getEntity()
    - getEntities()

- Scene now has getEntityCount()

- EntityManager now has getEntityCount()

- all component manager implement gc() the same way, by calling destroy()

- SingleInstanceComponentManager::gc() that calls removeComponent() has
  been removed because it's dangerous. removeComponent() is often
  not enough, some additional cleanup might be needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Issue/PR does not affect clients
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants