The current code is fairly inefficient for multiple reasons.
This commit addresses two of them:
- The getter functions were directly accessing the RNA arrays, which causes a lot of overhead since they are called many times per vertex/face. By iterating over the RNA arrays once and caching the data in temporary storage, this overhead is avoided.
- The step that merges duplicate vertices only performed binning in one spatial dimension and then looped over all vertices in each bin. By hashing all nine components, binning these hashes and then checking inside each bin the code is simplified a lot while also saving a huge amount of time.
There are many more optimization opportunities, but these two already halve
render times for my test file (suzanne with default unwrapping and subdivided
to level 6).