TheCherno / Sparky

Cross-Platform High Performance 2D/3D game engine for people like me who like to write code.
Apache License 2.0
1.1k stars 222 forks source link

Mat4 columns #33

Open mahlerni opened 9 years ago

mahlerni commented 9 years ago

Shouldn't this

vec4 getColumn(int index)
        {
            index *= 4;
            return vec4(elements[index], elements[index + 1], elements[index + 2], elements[index + 3]);
        }

be this instead?

vec4 getColumn(int index)
        {
            return columns[index];
        }

(mat4.h)

Maxchii commented 9 years ago

What you are suggesting would return an element not a column.

Actually you may be right! I forgot about Vector4 columns[4]; in Mat4.h

TheCherno commented 9 years ago

@mahlerni It totally should, I wrote that code to demonstrate how not to do it. Really the method shouldn't even exist, since columns is public. It could be kept the way you rewrote it, but returning a reference.