Overview
This is an alternative and more conventional solution for D7902
Basically each component of the old TransData is now separated
into more specific structs.
Motivation
This patch was originally developed as a step to fix T70873 more
appropriately (reusing the struct TransData for mirror elements in
order to deduplicate code and simplify use).
(I was impatient and committed another solution for it).
Even though that bug has been solved, this patch still points out a
problem in the transform code, which is memory usage.
TransData is a struct allocated for each element affected in the
transformation.
When proportional edit is enabled, all elements visible in the scene
have a respective TransData allocated.
This indicates that there is a TransData for each vertex, object,
particle or whatever.
However, TransData (in conjunction with TransDataExtension) has a
total of 41 members and a size of 608 bytes!
But for most transformations, we only need 24 bytes (int flag, float *loc, float iloc[3])
So we only need about 4% of the total size of the TransData struct for most of the transform modes.
That struct is oversized, and is an unnecessary waste of memory.
Results
At the moment some arrays of unused structs are being allocated together.
They will be removed later if the idea of this solution is accepted.
A benefit of this patch at the moment is the performance, which even
though it does not save memory still presents some difference (~20%):
| Translate: | Single Struct: | Splitted Struct: |
|---|---|---|
| TIME CONVERT | 0.092606 | 0.058717 |
| TIME MODE | 0.044919 | 0.039117 |
| TIME END | 0.063259 | 0.050652 |
| Rotate: | Single Struct: | Splitted Struct: |
|---|---|---|
| TIME CONVERT | 0.093524 | 0.058600 |
| TIME MODE | 0.060536 | 0.048597 |
| TIME END | 0.057728 | 0.059498 |
| Scale: | Single Struct: | Splitted Struct: |
|---|---|---|
| TIME CONVERT | 0.090281 | 0.059215 |
| TIME MODE | 0.065083 | 0.062000 |
| TIME END | 0.062925 | 0.048495 |