Join GitHub today
Matrix multiplication fix #5030
@ricardoquesada @minggo As we used kazMath instead of CCAffineTransform in our develop branch, the multiplication order of concatenated transform need to be reversed. The pull request https://github.com/cocos2d/cocos2d-x/pull/4847/files has demonstrate this. We fix NodeToWorld Transform calculation bug by reverse the order of matrix multiplication.
The multiplication order on master branch is
The order used in v2.x are correct because we used CCAffineTransform. Their multiplication order are different.
Given a Case a node A has a child Node B, And B has an additional Transform.
The skewMatrix act the same as additionalTransform.
Besides, if our node has both skewMatrix and additionalTransform. In v2.x,
The bug is in v2.x.
Let me explain:
// v2.2. nodeToParentTransform() // Correct order: First skew, then transform m_sTransform = CCAffineTransformConcat(skewMatrix, m_sTransform); // Incorrect order!! // Why it is doing Contact(transform, additionalTransform) ???? m_sTransform = CCAffineTransformConcat(m_sTransform, m_sAdditionalTransform); // Instead, this should be the order m_sTransform = CCAffineTransformConcat(m_sAdditionalTransform, m_sTransform); }
I don't know why v2.2 has that order, it is not the correct one. And I don't know how Armature is using it, but by changing the order in the Concat() everything is confusing.
Instead, in v3.0 everything is using the correct order. Which is not compatible with v2.2, but it is using the correct one. Its use is simple to understand... If you pass an Additional Transform Matrix, it will work as expected.
In v2.2, if you pass an Additional Transform Matrix, the results are not the expected one.
If I'm missing something, please let me know.
So, we could rollback the behavior, and make it work like in v2.2... which is not the correct behavior.
As an example, try to add a Translate matrix to
Fixing these kind of bugs in a "silent" way is not recommended because users won't understand why v3.0 behaves differently, but on the other hand,
Another thing that we could do is to remove
Is there any suggestion about this? Thank you.