Fixed bug
This commit is contained in:
Perfare 2019-01-13 23:21:45 +08:00
parent c3c4697562
commit 903be743ac
7 changed files with 37 additions and 18 deletions

View File

@ -20,7 +20,7 @@ namespace AssetStudio
var m_ProxyHeight = reader.ReadUInt32(); var m_ProxyHeight = reader.ReadUInt32();
var Width = reader.ReadUInt32(); var Width = reader.ReadUInt32();
var Height = reader.ReadUInt32(); var Height = reader.ReadUInt32();
if (version[0] >= 2017) //2017.x and up if (version[0] > 2017 || (version[0] == 2017 && version[1] >= 2)) //2017.2 and up
{ {
var m_PixelAspecRatioNum = reader.ReadUInt32(); var m_PixelAspecRatioNum = reader.ReadUInt32();
var m_PixelAspecRatioDen = reader.ReadUInt32(); var m_PixelAspecRatioDen = reader.ReadUInt32();

View File

@ -83,7 +83,7 @@ namespace AssetStudio
case 13: return M13; case 13: return M13;
case 14: return M23; case 14: return M23;
case 15: return M33; case 15: return M33;
default: throw new IndexOutOfRangeException("Invalid matrix index!"); default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Matrix4x4 index!");
} }
} }
@ -107,7 +107,7 @@ namespace AssetStudio
case 13: M13 = value; break; case 13: M13 = value; break;
case 14: M23 = value; break; case 14: M23 = value; break;
case 15: M33 = value; break; case 15: M33 = value; break;
default: throw new IndexOutOfRangeException("Invalid matrix index!"); default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Matrix4x4 index!");
} }
} }
} }

View File

@ -29,7 +29,7 @@ namespace AssetStudio
case 1: return Y; case 1: return Y;
case 2: return Z; case 2: return Z;
case 3: return W; case 3: return W;
default: throw new IndexOutOfRangeException("Invalid Quaternion index!"); default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Quaternion index!");
} }
} }
@ -41,7 +41,7 @@ namespace AssetStudio
case 1: Y = value; break; case 1: Y = value; break;
case 2: Z = value; break; case 2: Z = value; break;
case 3: W = value; break; case 3: W = value; break;
default: throw new IndexOutOfRangeException("Invalid Quaternion index!"); default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Quaternion index!");
} }
} }
} }
@ -62,5 +62,27 @@ namespace AssetStudio
{ {
return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z) && W.Equals(other.W); return X.Equals(other.X) && Y.Equals(other.Y) && Z.Equals(other.Z) && W.Equals(other.W);
} }
public static float Dot(Quaternion a, Quaternion b)
{
return a.X * b.X + a.Y * b.Y + a.Z * b.Z + a.W * b.W;
}
private static bool IsEqualUsingDot(float dot)
{
return dot > 1.0f - kEpsilon;
}
public static bool operator ==(Quaternion lhs, Quaternion rhs)
{
return IsEqualUsingDot(Dot(lhs, rhs));
}
public static bool operator !=(Quaternion lhs, Quaternion rhs)
{
return !(lhs == rhs);
}
private const float kEpsilon = 0.000001F;
} }
} }

View File

@ -23,8 +23,7 @@ namespace AssetStudio
{ {
case 0: return X; case 0: return X;
case 1: return Y; case 1: return Y;
default: default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Vector2 index!");
throw new IndexOutOfRangeException("Invalid Vector2 index!");
} }
} }
@ -34,8 +33,7 @@ namespace AssetStudio
{ {
case 0: X = value; break; case 0: X = value; break;
case 1: Y = value; break; case 1: Y = value; break;
default: default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Vector2 index!");
throw new IndexOutOfRangeException("Invalid Vector2 index!");
} }
} }
} }

View File

@ -26,8 +26,7 @@ namespace AssetStudio
case 0: return X; case 0: return X;
case 1: return Y; case 1: return Y;
case 2: return Z; case 2: return Z;
default: default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Vector3 index!");
throw new IndexOutOfRangeException("Invalid Vector3 index!");
} }
} }
@ -38,8 +37,7 @@ namespace AssetStudio
case 0: X = value; break; case 0: X = value; break;
case 1: Y = value; break; case 1: Y = value; break;
case 2: Z = value; break; case 2: Z = value; break;
default: default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Vector3 index!");
throw new IndexOutOfRangeException("Invalid Vector3 index!");
} }
} }
} }

View File

@ -37,7 +37,7 @@ namespace AssetStudio
case 1: return Y; case 1: return Y;
case 2: return Z; case 2: return Z;
case 3: return W; case 3: return W;
default: throw new IndexOutOfRangeException("Invalid Vector4 index!"); default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Vector4 index!");
} }
} }
@ -49,7 +49,7 @@ namespace AssetStudio
case 1: Y = value; break; case 1: Y = value; break;
case 2: Z = value; break; case 2: Z = value; break;
case 3: W = value; break; case 3: W = value; break;
default: throw new IndexOutOfRangeException("Invalid Vector4 index!"); default: throw new ArgumentOutOfRangeException(nameof(index), "Invalid Vector4 index!");
} }
} }
} }

View File

@ -380,10 +380,11 @@ namespace AssetStudio
} }
} }
} }
else if (mesh.m_BindPose.Length > 0 && mesh.m_BoneNameHashes?.Length > 0 && mesh.m_BindPose.Length == mesh.m_BoneNameHashes.Length) else if (mesh.m_BindPose.Length > 0 && mesh.m_BoneNameHashes?.Length > 0)
{ {
iMesh.BoneList = new List<ImportedBone>(mesh.m_BoneNameHashes.Length); var boneMax = Math.Min(mesh.m_BindPose.Length, mesh.m_BoneNameHashes.Length);
for (int i = 0; i < mesh.m_BoneNameHashes.Length; i++) iMesh.BoneList = new List<ImportedBone>(boneMax);
for (int i = 0; i < boneMax; i++)
{ {
var bone = new ImportedBone(); var bone = new ImportedBone();
var boneHash = mesh.m_BoneNameHashes[i]; var boneHash = mesh.m_BoneNameHashes[i];