bcAnim написавWould it be possible to write a tool or a button that would automatically fix the rotations of flipped parts that used the old scaling before? I think the new scaling will be good, but I'm not looking forward to fixing all that stuff.
The new scaling changes the way flipping works (flipping a bone uses the bone's local axis, it used to always use the world axis). Unfortunately, it isn't possible to adjust old projects that use flipping to look the same.
Pharan написавHow much more expensive are we talking about when you say disabling inheritance for scale and rotation are expensive?
Old code:
if (data.inheritScale) {
worldScaleX = parent.worldScaleX * scaleX;
worldScaleY = parent.worldScaleY * scaleY;
} else {
worldScaleX = scaleX;
worldScaleY = scaleY;
}
worldRotation = data.inheritRotation ? parent.worldRotation + rotation : rotation;
New code:
if (!data.inheritScale) {
float psx = sqrt(p00 * p00 + p10 * p10);
p00 /= psx;
p10 /= psx;
float shear = p00 * p01 + p10 * p11; // dot
p01 -= p00 * shear;
p11 -= p10 * shear;
float psy = sqrt(p01 * p01 + p11 * p11);
p01 /= psy;
p11 /= psy;
}
if (!data.inheritRotation) {
rotation -= parent.worldRotation
* (parent.worldFlipX != parent.worldFlipY ? -1 : 1);
}
// ...
worldRotation = atan2(m10, m00) * radiansToDegrees;
worldScaleX = sqrt(m01 * m01 + m11 * m11); // Never negative!
worldScaleY = sqrt(m00 * m00 + m10 * m10);
The difference isn't much, but it's there. The math is very likely to pale in comparison to the other things an app is doing. sqrt
should be an intrinsic.
Pharan написавWill the data format change?
If it doesn't, people can just continue to use the old runtime?
The structure of the data format doesn't change, but the interpretation of the data changes. Old exported data should use the old runtimes. If used with the new runtimes, scale will be applied differently and may not look correct (will look the same as if you open an old project with Spine). New exported data should use the new runtimes. If used with the old runtimes, scale will be applied differently and may not look correct.
To be clear, the only bones that are affected by the new scaling are:
-
Bones that inherit scale from their parent and have a parent that has non-uniform scaling (ie, are scaled a different amount on X and Y). A bone's scale works exactly the same for that bone (even when non-uniform!), it's only when inheriting non-uniform scale that the new scaling is different.
-
Or, bones that are flipped and are not the root bone.
I don't expect #1 to affect many projects, because inheriting scale with the old scaling wasn't very useful. It's more likely that people have flipped bones, and those projects will need to be fixed up manually.
I'll do a release of 2.1.19 today which should allow inherit scale/rotation to be disabled with the new scaling, so you guys can better test how your projects work with it.
2.1.19 is up.