I'm trying to write a rendering function for a game. I have an array of object transforms (position, rotation, scale), which should be sorted by material as to not waste time binding the same material multiple times.
The problem is that I would rather not store a reference to a material in each transform. It's such a basic type that I don't want it to get cluttered with references to every part of the game that depends on it. The transform should only store the position, rotation and scale, and the relationship to the material should be stored elsewhere.
I could instead store references to the transforms inside each material, but then sorting the array of transforms would be a lot less straightforward.
Does anyone have any suggestions on how to store this data relationship? Is there a particular data structure which is good at representing this kind of relationship?