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

Refactor AssetManager #32

Open
5 tasks
numpad opened this issue Nov 7, 2020 · 0 comments
Open
5 tasks

Refactor AssetManager #32

numpad opened this issue Nov 7, 2020 · 0 comments
Labels
code-quality Purely backend related, the player won't notice anything but it makes developing easier. engine engine improvements, nothing the player will really notice.

Comments

@numpad
Copy link
Owner

numpad commented Nov 7, 2020

The current AssetManager implementation is very basic; it has subpar code quality, bad error handling/feedback and is not extremely performant.

Ideas:

  • Should be mod friendly: Open an assetmanager for a specific dir structure (like base/{images,sounds,...} and modXY/{images,...})
  • Every scene should use its own AssetManager, this way clean up is easy. Once a scene is closed the AssetManager destroys all assets used.
  • But: Engine specific stuff (like UI etc.) shouldn't need to be reloaded every time. Solution: An AssetManager can reference a parent AssetManager, if ChildAssedManager doesn't find a resource, the parent is checked.

Examine a better way to handle Assets, topics that need a rework:

  • Replace all raw with smart pointers.
  • Reimplement all assets/filetypes as generic classes.
  • Think about error handling, are nullptrs OK? Maybe default Assets are easier to handle (like Source engine). Black/Pink texture, 1s no-sound audio, Cube as default model, ...
  • Performance improvements. Dedicated functionality for preloading, store files that are already confirmed to not exist as empty instead of trying to load them everytime.
  • Memory handling. When to clean up resources?

Performance:
Currently very flexible system, f.ex. AM::getAudio() tries to return a already loaded audio, if that is not yet loaded, call ::loadAudio() and return this instead. Does this make sense performance wise or is there a better system which is still flexible enough? Switch from path to ID keys for Asset key/value pairs.

Memory handling:
Should resources be freed after not being used for a specific amount of time and no more references to it? Or on a per-scene/level basis?

@numpad numpad added code-quality Purely backend related, the player won't notice anything but it makes developing easier. engine engine improvements, nothing the player will really notice. labels Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality Purely backend related, the player won't notice anything but it makes developing easier. engine engine improvements, nothing the player will really notice.
Projects
None yet
Development

No branches or pull requests

1 participant