caseih wrote:Of course one could dynamically allocate memory and fill it with the table values at run time, but maybe that is too costly. I dunno.
It is 100% too costly. You're trying to run a game at 30 - 60 FPS that has buffers and caches for a ton of different things. You might have thousands upon thousands of entities going in and out of memory at once.
Much easier to just allocate a fixed-sized buffer for all of these things and take up slots or remove slots from that pre-allocated memory as available. Also, the same similar data is processed, it is often a huge optimization for them to be in the same linear memory sequence. Reduced lookups and allocations.
And you do something like clear this bank at the end of every engine loop cycle. That has a cost, but it's apparently way less than the cost of dynamic allocation in the middle of processing critical execution frames.