1
0
mirror of synced 2025-01-31 12:23:52 +01:00

Property check ints for the key data so animations don't break

This commit is contained in:
KillzXGaming 2019-05-25 21:44:50 -04:00
parent f9fbd19b82
commit f25e1ad294
2 changed files with 29 additions and 5 deletions

Binary file not shown.

View File

@ -655,6 +655,7 @@ namespace BrawlboxHelper
float MaxFrame = 0; float MaxFrame = 0;
float MaxValues = 0; float MaxValues = 0;
List<bool> IntegerValues = new List<bool>();
for (int frame = 0; frame < curve.Frames.Length; frame++) for (int frame = 0; frame < curve.Frames.Length; frame++)
{ {
MaxFrame = Math.Max(MaxFrame, curve.Frames[frame]); MaxFrame = Math.Max(MaxFrame, curve.Frames[frame]);
@ -663,6 +664,9 @@ namespace BrawlboxHelper
{ {
MaxValues = Math.Max(MaxValues, curve.Keys[frame, 0]); MaxValues = Math.Max(MaxValues, curve.Keys[frame, 0]);
MaxValues = Math.Max(MaxValues, curve.Keys[frame, 1]); MaxValues = Math.Max(MaxValues, curve.Keys[frame, 1]);
IntegerValues.Add(IsInt(curve.Keys[frame, 0]));
IntegerValues.Add(IsInt(curve.Keys[frame, 1]));
} }
else if (curve.CurveType == AnimCurveType.Cubic) else if (curve.CurveType == AnimCurveType.Cubic)
{ {
@ -670,11 +674,21 @@ namespace BrawlboxHelper
MaxValues = Math.Max(MaxValues, curve.Keys[frame, 1]); MaxValues = Math.Max(MaxValues, curve.Keys[frame, 1]);
MaxValues = Math.Max(MaxValues, curve.Keys[frame, 2]); MaxValues = Math.Max(MaxValues, curve.Keys[frame, 2]);
MaxValues = Math.Max(MaxValues, curve.Keys[frame, 3]); MaxValues = Math.Max(MaxValues, curve.Keys[frame, 3]);
IntegerValues.Add(IsInt(curve.Keys[frame, 0]));
IntegerValues.Add(IsInt(curve.Keys[frame, 1]));
IntegerValues.Add(IsInt(curve.Keys[frame, 2]));
IntegerValues.Add(IsInt(curve.Keys[frame, 3]));
} }
else else
{ {
MaxValues = Math.Max(MaxValues, curve.Keys[frame, 0]); MaxValues = Math.Max(MaxValues, curve.Keys[frame, 0]);
IntegerValues.Add(IsInt(curve.Keys[frame, 0]));
} }
int ConvertedInt = Convert.ToInt32(MaxValues);
} }
if (MaxFrame < Byte.MaxValue) if (MaxFrame < Byte.MaxValue)
@ -684,14 +698,24 @@ namespace BrawlboxHelper
else else
curve.FrameType = AnimCurveFrameType.Single; curve.FrameType = AnimCurveFrameType.Single;
if (MaxValues < Byte.MaxValue)
curve.KeyType = AnimCurveKeyType.SByte; if (IntegerValues.Any(x => x == false))
else if (MaxFrame < Int16.MaxValue) {
curve.KeyType = AnimCurveKeyType.Int16;
else
curve.KeyType = AnimCurveKeyType.Single; curve.KeyType = AnimCurveKeyType.Single;
}
else
{
if (MaxValues < Byte.MaxValue)
curve.KeyType = AnimCurveKeyType.SByte;
else if (MaxFrame < Int16.MaxValue)
curve.KeyType = AnimCurveKeyType.Int16;
else
curve.KeyType = AnimCurveKeyType.Single;
}
} }
private static bool IsInt(float value) => value == Math.Truncate(value);
private static AnimCurve GenerateCurve(uint AnimOffset, CHR0EntryNode entry) private static AnimCurve GenerateCurve(uint AnimOffset, CHR0EntryNode entry)
{ {
AnimCurve curve = new AnimCurve(); AnimCurve curve = new AnimCurve();