domenica 13 dicembre 2015

Day 98: Mallocator

Today I did quite a lot of stuff.

I created a Mallocator, which is a custom allocator which works exacly like malloc, but hides the implementation details. I refactored the whole engine to instantiate objects with it, and this required a lot of tweaks to make the interface looks nice. Before I had:

go = new GameObject();

now i have

go.create(mallocator);

Now everything is working, copyconstructors and destructors included.

While doing this I noticed a few things that were not good in the engine, like a bad management of the emitter components inside the gameobject, and the fact that the game has one camera for all the scenes. I modified them both, so noew the emitter behaves like any other component, and each scene has its own camera.

Finally I changed the TextureManager to keep track of which textures are lifetime objects and which are not, and it's reset method is now working correctly.

I didn't profile it yet, but now I'm quite confident that everything works like it should, and even if I'll find leaks they should be easy to fix.

The system now allows me to create other allocators pretty easily, like a stack allocator, which is what i'll do next.
The only downside is that it uses lots of template classes and functions, which leads to very bad error messages.

Nessun commento:

Posta un commento