The code for initializing textures for SOverlayTexturedLines and SOverlayQuads is duplicated four times in the simulation: in CCmpTerritoryManager, CCmpSelectable (done twice), and CCmpRallyPointRenderer, and this list will grow to include another component with D555 when range-overlay rendering is moved out of CCmpSelectable.
This code involves:
- Creating a CTextureProperties object for both the mask and base for the texture.
- Calling SetWrap and SetMaxAnisotropy on the CTextureProperties objects (using the exact same arguments for SetWrap in all mentioned components).
- Invoking the texture manager (through g_Renderer) twice to create the mask and base.
An option would possibly be to move the code to a file/class in the simulation2/helpers directory, but:
- The only current "helper" class that is relevant (in Render.cpp/.h) does not access the renderer directly, as it only deals with calculating f.e. line segments.
- This would still require using the graphics class CTextureProperties directly in the simulation (and adding a bunch of includes from the graphics code).
It is best to try to keep the sim independent of the graphics/rendering code as much as possible (i.e. minimize the need to access the renderer directly in the sim).
All this justifies adding a new method to the graphics code to reduce the duplication, in the part of the code that already deals directly with CTextureProperties and texture creation. These simulation components still need to have access to the renderer in order to check if it is initialized before calculating their lines/quads.