mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 17:56:04 +08:00
[csharp] Fix Transform constraint import scale.
This commit is contained in:
parent
90bfdba422
commit
60a34ef995
@ -271,39 +271,41 @@ namespace Spine {
|
|||||||
data.clamp = (flags & 16) != 0;
|
data.clamp = (flags & 16) != 0;
|
||||||
FromProperty[] froms = data.properties.Resize(nn = flags >> 5).Items;
|
FromProperty[] froms = data.properties.Resize(nn = flags >> 5).Items;
|
||||||
for (int ii = 0, tn; ii < nn; ii++) {
|
for (int ii = 0, tn; ii < nn; ii++) {
|
||||||
|
float fromScale = 1.0f;
|
||||||
FromProperty from;
|
FromProperty from;
|
||||||
switch (input.ReadSByte()) {
|
switch (input.ReadSByte()) {
|
||||||
case 0: from = new FromRotate(); break;
|
case 0: from = new FromRotate(); break;
|
||||||
case 1: from = new FromX(); break;
|
case 1: from = new FromX(); fromScale = scale; break;
|
||||||
case 2: from = new FromY(); break;
|
case 2: from = new FromY(); fromScale = scale; break;
|
||||||
case 3: from = new FromScaleX(); break;
|
case 3: from = new FromScaleX(); break;
|
||||||
case 4: from = new FromScaleY(); break;
|
case 4: from = new FromScaleY(); break;
|
||||||
case 5: from = new FromShearY(); break;
|
case 5: from = new FromShearY(); break;
|
||||||
default: from = null; break;
|
default: from = null; break;
|
||||||
};
|
};
|
||||||
from.offset = input.ReadFloat() * scale;
|
from.offset = input.ReadFloat() * fromScale;
|
||||||
ToProperty[] tos = from.to.Resize(tn = input.ReadSByte()).Items;
|
ToProperty[] tos = from.to.Resize(tn = input.ReadSByte()).Items;
|
||||||
for (int t = 0; t < tn; t++) {
|
for (int t = 0; t < tn; t++) {
|
||||||
|
float toScale = 1.0f;
|
||||||
ToProperty to;
|
ToProperty to;
|
||||||
switch (input.ReadSByte()) {
|
switch (input.ReadSByte()) {
|
||||||
case 0: to = new ToRotate(); break;
|
case 0: to = new ToRotate(); break;
|
||||||
case 1: to = new ToX(); break;
|
case 1: to = new ToX(); toScale = scale; break;
|
||||||
case 2: to = new ToY(); break;
|
case 2: to = new ToY(); toScale = scale; break;
|
||||||
case 3: to = new ToScaleX(); break;
|
case 3: to = new ToScaleX(); break;
|
||||||
case 4: to = new ToScaleY(); break;
|
case 4: to = new ToScaleY(); break;
|
||||||
case 5: to = new ToShearY(); break;
|
case 5: to = new ToShearY(); break;
|
||||||
default: to = null; break;
|
default: to = null; break;
|
||||||
};
|
};
|
||||||
to.offset = input.ReadFloat() * scale;
|
to.offset = input.ReadFloat() * toScale;
|
||||||
to.max = input.ReadFloat() * scale;
|
to.max = input.ReadFloat() * toScale;
|
||||||
to.scale = input.ReadFloat();
|
to.scale = input.ReadFloat() * (toScale / fromScale);
|
||||||
tos[t] = to;
|
tos[t] = to;
|
||||||
}
|
}
|
||||||
froms[ii] = from;
|
froms[ii] = from;
|
||||||
}
|
}
|
||||||
flags = input.Read();
|
flags = input.Read();
|
||||||
if ((flags & 1) != 0) data.offsetX = input.ReadFloat();
|
if ((flags & 1) != 0) data.offsetX = input.ReadFloat() * scale;
|
||||||
if ((flags & 2) != 0) data.offsetY = input.ReadFloat();
|
if ((flags & 2) != 0) data.offsetY = input.ReadFloat() * scale;
|
||||||
if ((flags & 4) != 0) data.mixRotate = input.ReadFloat();
|
if ((flags & 4) != 0) data.mixRotate = input.ReadFloat();
|
||||||
if ((flags & 8) != 0) data.mixX = input.ReadFloat();
|
if ((flags & 8) != 0) data.mixX = input.ReadFloat();
|
||||||
if ((flags & 16) != 0) data.mixY = input.ReadFloat();
|
if ((flags & 16) != 0) data.mixY = input.ReadFloat();
|
||||||
|
|||||||
@ -249,23 +249,25 @@ namespace Spine {
|
|||||||
var fromEntry = (Dictionary<string, Object>)fromEntryObject.Value;
|
var fromEntry = (Dictionary<string, Object>)fromEntryObject.Value;
|
||||||
string fromEntryName = fromEntryObject.Key;
|
string fromEntryName = fromEntryObject.Key;
|
||||||
|
|
||||||
|
float fromScale = 1.0f;
|
||||||
FromProperty from;
|
FromProperty from;
|
||||||
switch (fromEntryName) {
|
switch (fromEntryName) {
|
||||||
case "rotate": from = new FromRotate(); break;
|
case "rotate": from = new FromRotate(); break;
|
||||||
case "x": from = new FromX(); break;
|
case "x": from = new FromX(); fromScale = scale; break;
|
||||||
case "y": from = new FromY(); break;
|
case "y": from = new FromY(); fromScale = scale; break;
|
||||||
case "scaleX": from = new FromScaleX(); break;
|
case "scaleX": from = new FromScaleX(); break;
|
||||||
case "scaleY": from = new FromScaleY(); break;
|
case "scaleY": from = new FromScaleY(); break;
|
||||||
case "shearY": from = new FromShearY(); break;
|
case "shearY": from = new FromShearY(); break;
|
||||||
default: throw new Exception("Invalid transform constraint from property: " + fromEntryName);
|
default: throw new Exception("Invalid transform constraint from property: " + fromEntryName);
|
||||||
};
|
};
|
||||||
|
|
||||||
from.offset = GetFloat(fromEntry, "offset", 0) * scale;
|
from.offset = GetFloat(fromEntry, "offset", 0) * fromScale;
|
||||||
if (fromEntry.ContainsKey("to")) {
|
if (fromEntry.ContainsKey("to")) {
|
||||||
foreach (KeyValuePair<string, Object> toEntryObject in (Dictionary<string, Object>)fromEntry["to"]) {
|
foreach (KeyValuePair<string, Object> toEntryObject in (Dictionary<string, Object>)fromEntry["to"]) {
|
||||||
var toEntry = (Dictionary<string, Object>)toEntryObject.Value;
|
var toEntry = (Dictionary<string, Object>)toEntryObject.Value;
|
||||||
string toEntryName = toEntryObject.Key;
|
string toEntryName = toEntryObject.Key;
|
||||||
|
|
||||||
|
float toScale = 1.0f;
|
||||||
ToProperty to;
|
ToProperty to;
|
||||||
switch (toEntryName) {
|
switch (toEntryName) {
|
||||||
case "rotate": {
|
case "rotate": {
|
||||||
@ -276,11 +278,13 @@ namespace Spine {
|
|||||||
case "x": {
|
case "x": {
|
||||||
x = true;
|
x = true;
|
||||||
to = new ToX();
|
to = new ToX();
|
||||||
|
toScale = scale;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "y": {
|
case "y": {
|
||||||
y = true;
|
y = true;
|
||||||
to = new ToY();
|
to = new ToY();
|
||||||
|
toScale = scale;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "scaleX": {
|
case "scaleX": {
|
||||||
@ -300,9 +304,9 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
default: throw new Exception("Invalid transform constraint to property: " + toEntryName);
|
default: throw new Exception("Invalid transform constraint to property: " + toEntryName);
|
||||||
}
|
}
|
||||||
to.offset = GetFloat(toEntry, "offset", 0) * scale;
|
to.offset = GetFloat(toEntry, "offset", 0) * toScale;
|
||||||
to.max = GetFloat(toEntry, "max", 1) * scale;
|
to.max = GetFloat(toEntry, "max", 1) * toScale;
|
||||||
to.scale = GetFloat(toEntry, "scale");
|
to.scale = GetFloat(toEntry, "scale") * (toScale / fromScale);
|
||||||
from.to.Add(to);
|
from.to.Add(to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,8 +314,8 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data.offsetX = GetFloat(constraintMap, "x", 0);
|
data.offsetX = GetFloat(constraintMap, "x", 0) * scale;
|
||||||
data.offsetY = GetFloat(constraintMap, "y", 0);
|
data.offsetY = GetFloat(constraintMap, "y", 0) * scale;
|
||||||
if (rotate) data.mixRotate = GetFloat(constraintMap, "mixRotate", 1);
|
if (rotate) data.mixRotate = GetFloat(constraintMap, "mixRotate", 1);
|
||||||
if (x) data.mixX = GetFloat(constraintMap, "mixX", 1);
|
if (x) data.mixX = GetFloat(constraintMap, "mixX", 1);
|
||||||
if (y) data.mixY = GetFloat(constraintMap, "mixY", data.mixX);
|
if (y) data.mixY = GetFloat(constraintMap, "mixY", data.mixX);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user