Spellcaster Studios

Make it happen…

Refactoring done!

Finally, after almost 57 hours of work, I’ve finished the refactoring of the resource system and adaptation of the SurgePlayer to use those changes!

It’s a bit frustrating to be honest, to put in so many hours in a single task and the end result is everything looking exactly the same, but internally the system now runs much better…

What I did was to change the whole way resources/assets are handled by Spellbook… Instead of having a pointer to the resource (like a mesh has pointers to materials, and materials have pointers to textures, etc), now I use resource references (a mesh has references to materials, and materials references to textures)… What this means in practical terms is that I know exactly how many objects reference a specific asset, besides having a level of indirection that will allow me in the near future to replace a resource without searching the whole system for pointers to the resource.

This allows for live updates, and in the long run will allow more complicated systems like caching and streaming worlds; a cool side effect is that it’s less likely to have crashes, since a resource only gets deleted from the system if no one is using it, which is great!

Finding who is using what is a bit more tricky, but it can probably be done in a simpler fashion as well (although very memory intensive, but might be good for debug purposes).

This change to the system entailed me changing about 700 source files of code, and a lot of debugging, specially in the “cleanup” tasks of the engine (which sapped about 10 hours of work by itself, I found a ton of places where in some circumstances the engine could crash because of missing resources).

Anyway, next week I’ll be away on work in Germany, and because of that there won’t be any updates to the blog (and probably no work done on the game as well, besides some design work), but afterwards I hope I find enough time to get the live update done, and finally sort out the “icy skeleton” effect using that same system, which will be pretty cool I guess!

Then, one more huge task I have absolutely no motivation to do, but has to be done: adapting these changes to the SurgeEd… Not looking forward for that one! Surprised smile