Bug 1241161 - make Matrix4x4::ProjectTo2D normalize out perpective where possible. r=mattwoodrow

This commit is contained in:
Lee Salzman 2016-03-10 16:10:04 -05:00
Родитель ec0f6159f9
Коммит 04fb5babb0
1 изменённых файлов: 18 добавлений и 0 удалений

Просмотреть файл

@ -548,6 +548,24 @@ public:
_33 = 1.0f;
_43 = 0.0f;
_34 = 0.0f;
// Some matrices, such as those derived from perspective transforms,
// can modify _44 from 1, while leaving the rest of the fourth column
// (_14, _24) at 0. In this case, after resetting the third row and
// third column above, the value of _44 functions only to scale the
// coordinate transform divide by W. The matrix can be converted to
// a true 2D matrix by normalizing out the scaling effect of _44 on
// the remaining components ahead of time.
if (_14 == 0.0f && _24 == 0.0f &&
_44 != 1.0f && _44 != 0.0f) {
Float scale = 1.0f / _44;
_11 *= scale;
_12 *= scale;
_21 *= scale;
_22 *= scale;
_41 *= scale;
_42 *= scale;
_44 = 1.0f;
}
return *this;
}