BGE bug #17450 fixed: When we have parented objects with no scale-applyed objects the ray hit system doesn't work properly. Fix by separating rotation and scaling in the parent inverse node to keep scaling correct down to the leaf objects. Only isotropric scaling should be used, as always with the BGE.

This commit is contained in:
Benoit Bolsee
2008-08-08 09:57:17 +00:00
parent fa98def953
commit 62f9ba67c0

View File

@@ -1939,7 +1939,17 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
float* fl = (float*) blenderobject->parentinv;
MT_Transform parinvtrans(fl);
parentinversenode->SetLocalPosition(parinvtrans.getOrigin());
parentinversenode->SetLocalOrientation(parinvtrans.getBasis());
// problem here: the parent inverse transform combines scaling and rotation
// in the basis but the scenegraph needs separate rotation and scaling.
// This is not important for OpenGL (it uses 4x4 matrix) but it is important
// for the physic engine that needs a separate scaling
//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]));
parentinversenode->AddChild(gameobj->GetSGNode());
}