The usage of LINQ slowed down the conversion from matrices to arrays by a lot. I got massive performance improvements by simply getting rid of them (I had several thousand calls of to_array per frame in my render engine). The code I replaced LINQ with is really not complicated and I see absolutely no reason to use LINQ here.
Some vector operations were allocating new vector object while the operations can be performed without them as well so I removed them.
I also replaced a few index accesses on vectors with direct variable access which should be quite a bit faster as well since it avoids all the branches. The index operator really only is useful for iterating over the values.
The usage of LINQ slowed down the conversion from matrices to arrays by a lot. I got massive performance improvements by simply getting rid of them (I had several thousand calls of to_array per frame in my render engine). The code I replaced LINQ with is really not complicated and I see absolutely no reason to use LINQ here.
Some vector operations were allocating new vector object while the operations can be performed without them as well so I removed them.
I also replaced a few index accesses on vectors with direct variable access which should be quite a bit faster as well since it avoids all the branches. The index operator really only is useful for iterating over the values.