This patch moves `Mesh` polygon material indices out of thefrom the mesh `MPoly` struct to a
a generic attribute, with the goal of simplifying code,integer attribute. and eventually reducingThe builtin material index was already
memory usageexposed in geometry nodes, but this makes it a "proper" attribute
accessible with Python and improving performancevisible in the "Attributes" panel.
Until 4.0, meshes are written to and read with the existing format,The goals of the refactor are code simplification and backwardsmemory and
compatibility in DNA means we can't actually removperformance improvements, mainly because the field from the struct yet,attribute doesn't have
but there may be ways around that in the future.
Ref T95967to be stored and processed if there are no materials. However, until
4.0, material indices will still be read and written in the old
format, meaning there may be a temporary increase in memory usage.
TODO:Further notes:
* Completely removing the `MPoly.mat_nr` after 4.0 may require
changes to DNA or introducing a new `MPoly` type.
- Fix multires* Access to material evaluation: `ccgDM_copyFinalPolyArray`indices from the RNA `MeshPolygon` type is slower
- Run tests, with this patch. The `material_index` attribute can be used instead.
* Cycles is changed to read from the attribute instead.
* BMesh isn't changed in this patch. fix as neededTheoretically it could be though,
to save 2 bytes per face when no materials are used.
* Eventually we could use a 16 bit integer attribute type instead.
Ref T95967
Branch: `refactor-mesh-material-index-generic`