forked from bartvdbraak/blender
BGE bug fix: the fix in revision 16022 for bug #17450 was wrong: the formula used to extract scaling and rotation was giving incorrect results for some type of rotation, leading to wrong position and orientation for parented objects with no scale applied. The new formula follows Blender's internal math.
This commit is contained in:
parent
c965ef7824
commit
528722f472
@ -1946,10 +1946,22 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
//parentinversenode->SetLocalOrientation(parinvtrans.getBasis());
|
||||
|
||||
// Extract the rotation and the scaling from the basis
|
||||
MT_Matrix3x3 inverseOrientation(parinvtrans.getRotation());
|
||||
parentinversenode->SetLocalOrientation(inverseOrientation);
|
||||
MT_Matrix3x3 scale(inverseOrientation.transposed()*parinvtrans.getBasis());
|
||||
parentinversenode->SetLocalScale(MT_Vector3(scale[0][0], scale[1][1], scale[2][2]));
|
||||
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);
|
||||
parentinversenode->SetLocalScale(scale);
|
||||
|
||||
parentinversenode->AddChild(gameobj->GetSGNode());
|
||||
}
|
||||
@ -2129,7 +2141,24 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
float* fl = (float*) blenderobject->parentinv;
|
||||
MT_Transform parinvtrans(fl);
|
||||
parentinversenode->SetLocalPosition(parinvtrans.getOrigin());
|
||||
parentinversenode->SetLocalOrientation(parinvtrans.getBasis());
|
||||
|
||||
// Extract the rotation and the scaling from the basis
|
||||
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);
|
||||
parentinversenode->SetLocalScale(scale);
|
||||
|
||||
parentinversenode->AddChild(gameobj->GetSGNode());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user