TheCherno / Sparky

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

Bug in Mat4::Rotate #125

Closed Crisspl closed 7 years ago

Crisspl commented 7 years ago

I think you have bug here: https://github.com/TheCherno/Sparky/blob/master/Sparky-core/src/sp/maths/mat4.cpp#L311

It should be: result.elements[0 + 0 * 4] = x * x * omc + c; // x^2 result.elements[1 + 1 * 4] = y * y * omc + c; // y^2 result.elements[2 + 2 * 4] = z * z * omc + c; // z^2

Probably you didn't see it beacuse you always rotated on one axis (i mean {1, 0, 0}, {0, 1, 0} or {0, 0, 1}) and 1^2 is still 1 so it was working or not squaring just didn't have so much impact on the values to be noticeable.