[Bf-committers] 2.47 showstopper bug in the BGE.

Benoit Bolsee benoit.bolsee at online.be
Sat Aug 16 00:43:28 CEST 2008


Hi,

The bug fix in revision 16022 for bug #17450 was wrong: the formula used
to extract scaling and rotation from the parent inverse transform was
giving incorrect results for some type of matrix, leading to wrong
position and orientation for parented objects with no scale applied:

	MT_Matrix3x3 inverseOrientation(parinvtrans.getRotation());
	parentinversenode->SetLocalOrientation(inverseOrientation);

getRotation() only works correctly if there is no scaling in the
transformation. The correct formula that follows Blender's internal math
is as follow:

	MT_Matrix3x3 ori(parinvtrans.getBasis());
	MT_Vector3 x(ori.getColumn(0));
	MT_Vector3 y(ori.getColumn(1));
	MT_Vector3 z(ori.getColumn(2));
	MT_Vector3 scale(x.length(), y.length(), z.length());
	if (!MT_fuzzyZero(scale[0]))
		x /= scale[0];
	if (!MT_fuzzyZero(scale[1]))
		y /= scale[1];
	if (!MT_fuzzyZero(scale[2]))
		z /= scale[2];
	ori.setColumn(0, x);

	ori.setColumn(1, y);

	ori.setColumn(2, z);

	parentinversenode->SetLocalOrientation(ori);

This bug affects 2.47 as revision 16022 was included in 2.47. It
potentially affects all games with parented objects with no scale
applied on the parent: in this situation the parent inverse node has
scaling and the formula doesn't work correctly.

I've fixed the bug in revision 16127 and I recommend to include it in
2.47. 

The game designer can get away with the bug by applying the scale on the
parent objects, which is often recommended in the tutorials so the
impact of this bug may be limited.
Note that 2.47 contains a number of advanced improvements in the game
engine that are not sufficiently tested. I expect more problems of that
kind but this one is particularly visible.

/Benoit



More information about the Bf-committers mailing list