[BUG] Matrix4f.translate() is inconsistent

Started by waucka, March 29, 2014, 03:35:59

Previous topic - Next topic

waucka

Example Code:
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector3f;

public class WeirdMatrix {
    public static void runTest() {
	Matrix4f idmat1 = new Matrix4f();
	Matrix4f scalemat1 = Matrix4f.scale(new Vector3f(5, 5, 5), idmat1, null);
	Matrix4f mat1 = Matrix4f.translate(new Vector3f(1, 2, 3), scalemat1, null);
	System.out.println(mat1);

	Matrix4f mat2 = new Matrix4f();
	mat2.scale(new Vector3f(5, 5, 5));
	mat2.translate(new Vector3f(1, 2, 3));
	System.out.println(mat2);
    }
}


Output:
1.0 0.0 0.0 5.0
0.0 1.0 0.0 10.0
0.0 0.0 1.0 15.0
0.0 0.0 0.0 1.0

5.0 0.0 0.0 5.0
0.0 5.0 0.0 10.0
0.0 0.0 5.0 15.0
0.0 0.0 0.0 1.0


Is that really the way it's supposed to work?  That's definitely not what I expected.  From reading the Matrix4f.translate() code, I see that it only writes to the fourth column of the dest matrix, which is only valid if source == dest.  It seems to me that, dest should be set to the value of source at the beginning of the method.  I see somebody already reported a bug about this back in 2011, but that post seems to have been ignored.