mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[libgdx] Fixed binary data loader scale for transform constraint, clean up.
This commit is contained in:
parent
4a351ceb2d
commit
ead468332c
@ -289,30 +289,46 @@ public class SkeletonBinary extends SkeletonLoader {
|
|||||||
data.clamp = (flags & 16) != 0;
|
data.clamp = (flags & 16) != 0;
|
||||||
Object[] froms = data.properties.setSize(nn = flags >> 5);
|
Object[] froms = data.properties.setSize(nn = flags >> 5);
|
||||||
for (int ii = 0, tn; ii < nn; ii++) {
|
for (int ii = 0, tn; ii < nn; ii++) {
|
||||||
FromProperty from = switch (input.readByte()) {
|
float fromScale = 1;
|
||||||
case 0 -> new FromRotate();
|
FromProperty from;
|
||||||
case 1 -> new FromX();
|
switch (input.readByte()) {
|
||||||
case 2 -> new FromY();
|
case 0 -> from = new FromRotate();
|
||||||
case 3 -> new FromScaleX();
|
case 1 -> {
|
||||||
case 4 -> new FromScaleY();
|
from = new FromX();
|
||||||
case 5 -> new FromShearY();
|
fromScale = scale;
|
||||||
default -> null;
|
}
|
||||||
};
|
case 2 -> {
|
||||||
from.offset = input.readFloat() * scale;
|
from = new FromY();
|
||||||
|
fromScale = scale;
|
||||||
|
}
|
||||||
|
case 3 -> from = new FromScaleX();
|
||||||
|
case 4 -> from = new FromScaleY();
|
||||||
|
case 5 -> from = new FromShearY();
|
||||||
|
default -> from = null;
|
||||||
|
}
|
||||||
|
from.offset = input.readFloat() * fromScale;
|
||||||
Object[] tos = from.to.setSize(tn = input.readByte());
|
Object[] tos = from.to.setSize(tn = input.readByte());
|
||||||
for (int t = 0; t < tn; t++) {
|
for (int t = 0; t < tn; t++) {
|
||||||
ToProperty to = switch (input.readByte()) {
|
float toScale = 1;
|
||||||
case 0 -> new ToRotate();
|
ToProperty to;
|
||||||
case 1 -> new ToX();
|
switch (input.readByte()) {
|
||||||
case 2 -> new ToY();
|
case 0 -> to = new ToRotate();
|
||||||
case 3 -> new ToScaleX();
|
case 1 -> {
|
||||||
case 4 -> new ToScaleY();
|
to = new ToX();
|
||||||
case 5 -> new ToShearY();
|
toScale = scale;
|
||||||
default -> null;
|
}
|
||||||
};
|
case 2 -> {
|
||||||
to.offset = input.readFloat() * scale;
|
to = new ToY();
|
||||||
to.max = input.readFloat() * scale;
|
toScale = scale;
|
||||||
to.scale = input.readFloat();
|
}
|
||||||
|
case 3 -> to = new ToScaleX();
|
||||||
|
case 4 -> to = new ToScaleY();
|
||||||
|
case 5 -> to = new ToShearY();
|
||||||
|
default -> to = null;
|
||||||
|
}
|
||||||
|
to.offset = input.readFloat() * toScale;
|
||||||
|
to.max = input.readFloat() * toScale;
|
||||||
|
to.scale = input.readFloat() * toScale / fromScale;
|
||||||
tos[t] = to;
|
tos[t] = to;
|
||||||
}
|
}
|
||||||
froms[ii] = from;
|
froms[ii] = from;
|
||||||
|
|||||||
@ -266,9 +266,7 @@ public class SkeletonJson extends SkeletonLoader {
|
|||||||
float fromScale = 1;
|
float fromScale = 1;
|
||||||
FromProperty from;
|
FromProperty from;
|
||||||
switch (fromEntry.name) {
|
switch (fromEntry.name) {
|
||||||
case "rotate" -> {
|
case "rotate" -> from = new FromRotate();
|
||||||
from = new FromRotate();
|
|
||||||
}
|
|
||||||
case "x" -> {
|
case "x" -> {
|
||||||
from = new FromX();
|
from = new FromX();
|
||||||
fromScale = scale;
|
fromScale = scale;
|
||||||
@ -277,15 +275,9 @@ public class SkeletonJson extends SkeletonLoader {
|
|||||||
from = new FromY();
|
from = new FromY();
|
||||||
fromScale = scale;
|
fromScale = scale;
|
||||||
}
|
}
|
||||||
case "scaleX" -> {
|
case "scaleX" -> from = new FromScaleX();
|
||||||
from = new FromScaleX();
|
case "scaleY" -> from = new FromScaleY();
|
||||||
}
|
case "shearY" -> from = new FromShearY();
|
||||||
case "scaleY" -> {
|
|
||||||
from = new FromScaleY();
|
|
||||||
}
|
|
||||||
case "shearY" -> {
|
|
||||||
from = new FromShearY();
|
|
||||||
}
|
|
||||||
default -> throw new SerializationException("Invalid transform constraint from property: " + fromEntry.name);
|
default -> throw new SerializationException("Invalid transform constraint from property: " + fromEntry.name);
|
||||||
}
|
}
|
||||||
from.offset = fromEntry.getFloat("offset", 0) * fromScale;
|
from.offset = fromEntry.getFloat("offset", 0) * fromScale;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user