Actually my main problem with my own code is my "MatrixDataArray" property in the Matrix4x4 class.
Reasons:
Every time "MatrixDataArray" is accessed, column major form of the array has to be restructured element by element. I wish I knew a better way to do this.
Also, because of the way in which I construct the array form of the 4x4 matrix, if I were to use the "indexer" and do this:
Code:
Matrix4x4 myMatrix = new Matrix4x4();
myMatrix[5] = 3;
This change would not be reflected in the matrix itself....because the indexer accesses "MatrixDataArray", and "MatrixDataArray" is a separately constructed array not using the same memory as the real matrix data....and in this case as far as I know it will only be using the "getter"...the "setter" would never be called in that code snippet. So it would be cool if I had a way to do that last code snippet. In C++ I could do something like the following in my getter for "MatrixDataArray":
Code:
float **retArray = new (float*)[16];
for (int x = 0, i = 0; x < 4; x++)
{
for (int y = 0; y < 4; y++, i++)
{
retArray[i] = &_mat[y][x];
}
}
return retArray;
And that would provide me access to the actual data instead of a copy of the data...but that is C++ and not C#. I should research how to do something similar in C#