This patch goes away form using C++ RNA during tangent space calculation which
avoids quite a bit of overhead. This is similar to what D2702 is doing, but
there are some differences: calculation uses ccl::Mesh entirely, without any
preprocessing.
Cons:
- Tangent is now calculated from triangles. Didn't see any difference comparing results on adult Scales model, but some more (including regression) testing is required.
- There is some trickery to make Cycles to store UV layers if they are not used by shader directly but required to calculate tangent space.
Pros:
- Same speed as D2702 (assuming, mikkspace.c is patched as well, see below).
- Memory footprint is same or lower than with D2702:
- We got rig of temporary tangent array in MikkUserData.
- We don't need extra arrays for normals, vertices and vert-indices.
- We still might create extra arrays for UV coordinates if shader doesn't use them itself.
- The code is generic enough, not dependent on anything from Blender and could be moved to render/. This way other render engines will be able to calculate Blender-compatible tangents. Additionally, this will allow Cycles standalone to have support of tangents. Note: there is one dependency to Blender is to map orco back to original undeformed vertex location, but that's simple to solve.
- The code allows threaded evaluation of tangent layers: both evaluation of multiple tangent layers of the same object in separate threads and calculating tangents of multiple objects at the same time.
Note that this path does not include miskapce.c changes from D2702, those are to
be applied separately.
There are still some TODOs here and there, but don't think it's something fully
important. If this approach is considered fine will solve those TODOs (maybe as
separate commit right after main changes, since those are more like a refactor).