struct mat4x4
{
float m[4][4] = {0};
};
Basically, I have function to multiply a 4x4 matrix.
mat4x4 matrix_matrix(mat4x4 m1, mat4x4 m2)
{
mat4x4 product.m[someValue][someValue] = do_calculations_and_get_product();
return product;
}
So what I was thinking is to take a third mat4x4 as argument by reference, save the product in that new matrix and return that matrix. But that means a third argument must be passed while calling it. I want to be able to call it by passing only 2 matrices and expect a product matrix as an output AND if third matrix is given, I want it to save the results to that third matrix and also return that matrix.
From reading some of the other posts I came up with this
mat4x4 matrix_matrix(mat4x4 m1, mat4x4 m2, const mat4x4 & m3 = mat4x4{})
{
m3.m[somevalue][somevalue] = do_calculations_and_get_product();
return m3;
}
but I am getting an error: expression must be a modifiable lvalue, with a red wiggly line under m3. I don't really know what I am doing and need someone to help me. Thanks
Removing const gives the following error:
initial value of reference to non-const must be an lvalue
with a red wiggly line under mat4x4{} in function defination.