Does anyone use hard arrays to store objects?
With a wrapper / manager class, this method is no more unwieldy to work with than normal objects. For my particles, I am running a particle system class which contains a set of arrays for x, y, vx, vy, particle type, etc.
This is rather a mix of the old way of doing things back in the 1980s and the object oriented way. By having it as a class, you can inherit other particle system classes. But by using hard-sized arrays you don't need to worry about the garbage collector, and according to my timing experiments it's somewhat faster than having all of the particles represented as individual first-class objects with internal methods, even if the objects are pre-allocated and reused rather than being destroyed.
It's a very brute-force way of doing things, and sometimes brute force is good. Obviously you're losing some flexibility by doing it this way but with specialization, does it really matter?
|