fix potential errors in matrix multiplication

This commit is contained in:
Nomango 2019-07-30 13:05:16 +08:00
parent cfebf15974
commit d025adb453
2 changed files with 18 additions and 6 deletions

View File

@ -220,7 +220,7 @@ namespace kiwano
if (parent_) if (parent_)
{ {
transform_matrix_ = transform_matrix_ * parent_->transform_matrix_; transform_matrix_ *= parent_->transform_matrix_;
} }
// update children's transform // update children's transform

View File

@ -78,8 +78,8 @@ namespace kiwano
{ {
} }
template <typename T> template <typename _MTy>
MatrixT(T const& other) MatrixT(_MTy const& other)
{ {
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
m[i] = other[i]; m[i] = other[i];
@ -95,12 +95,24 @@ namespace kiwano
return m[index]; return m[index];
} }
template <typename _Lty, typename _Rty> inline MatrixT& operator= (MatrixT const& other)
inline MatrixT& operator= (MatrixMultiply<value_type, _Lty, _Rty> const& other)
{ {
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
m[i] = other[i]; m[i] = other[i];
return *this; return (*this);
}
template <typename _Lty, typename _Rty>
inline MatrixT& operator= (MatrixMultiply<value_type, _Lty, _Rty> const& other)
{
MatrixT result(other);
(*this) = result;
return (*this);
}
inline MatrixT& operator*= (MatrixT const& other)
{
return operator=((*this) * other);
} }
inline void Identity() inline void Identity()