dimanche 18 avril 2021

Is there a design pattern for iterating over all the arrays of a same type in a collection of SoA?

I have N structs of arrays:

PlayerTable: ids, velocities, positions, animations, healths ...
EnemyTable: ids, velocities, positions, animations, AIs ...
BulletTables: ids, velocities, positions, animations, ranges ...
... other N-3 soas

I have M procedures for updating those structs of arrays:

applyVelocities: [read] velocities, [write] positions
updateAnimations: [write] animations
drawEntities: [read] animations, [read] positions
... other M-3 procedures

Is there a design pattern for iterating over all the arrays of a same type in a collection of SoA?

I can only think of writing a template function and calling it for each struct of array with those atributes. Is that it? Does that usually scale well?

Aucun commentaire:

Enregistrer un commentaire