|
|
|
|
|
by shermanyo
3680 days ago
|
|
> The reason that raw pointer management works in gamedev is because gamedev is closer to crafting than traditional programming.
> No one will die if a game crashes, and the iteration loop is a tight feedback cycle of code-compile-run code-compile-run. The more time I've spent understanding and building game engines, the more I see it as an organised network of state-machines managing and working with collections of data. More often than not, shared state has clear ownership and lifecycle management built into the relevant state-machines.
By isolating creation and destruction of resources in the transitional states (load and start a level, open a menu, change to Game Over screen), most of the code can safely reference data from other subsystems without reference counting, under the assumption that references are only valid until a global, shared transition in state. Imagine a player entity that stores a reference to a model, texture, sound effect, input state, etc... If that data is loaded at the start of the level, and destroyed when the level ends, is there really a need to inc/dec a reference count if an enemy entity shares a sound effect reference? |
|