mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-25 05:40:21 -04:00
Add AnimationClip equality comparer
This commit is contained in:
parent
9024e6a235
commit
81cd6d79d0
@ -1200,5 +1200,21 @@ namespace AssetStudio
|
|||||||
reader.AlignStream();
|
reader.AlignStream();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class EqComparer : IEqualityComparer<AnimationClip>
|
||||||
|
{
|
||||||
|
public bool Equals(AnimationClip clipA, AnimationClip clipB)
|
||||||
|
{
|
||||||
|
return clipA?.m_PathID == clipB?.m_PathID
|
||||||
|
&& clipA?.byteSize == clipB?.byteSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHashCode(AnimationClip obj)
|
||||||
|
{
|
||||||
|
var result = obj.m_PathID * 31;
|
||||||
|
result = result * 31 + obj.byteSize;
|
||||||
|
return result.GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,13 @@ namespace AssetStudio
|
|||||||
|
|
||||||
private ImageFormat imageFormat;
|
private ImageFormat imageFormat;
|
||||||
private Avatar avatar;
|
private Avatar avatar;
|
||||||
private AnimationClip[] animationClipUniqArray = Array.Empty<AnimationClip>(); //TODO: a proper AnimationClip equality comparer
|
private AnimationClip[] animationClipUniqArray = Array.Empty<AnimationClip>();
|
||||||
private Dictionary<AnimationClip, string> boundAnimationPathDic = new Dictionary<AnimationClip, string>();
|
private Dictionary<AnimationClip, string> boundAnimationPathDic = new Dictionary<AnimationClip, string>();
|
||||||
private Dictionary<uint, string> bonePathHash = new Dictionary<uint, string>();
|
private Dictionary<uint, string> bonePathHash = new Dictionary<uint, string>();
|
||||||
private Dictionary<Texture2D, string> textureNameDictionary = new Dictionary<Texture2D, string>();
|
private Dictionary<Texture2D, string> textureNameDictionary = new Dictionary<Texture2D, string>();
|
||||||
private Dictionary<Transform, ImportedFrame> transformDictionary = new Dictionary<Transform, ImportedFrame>();
|
private Dictionary<Transform, ImportedFrame> transformDictionary = new Dictionary<Transform, ImportedFrame>();
|
||||||
Dictionary<uint, string> morphChannelNames = new Dictionary<uint, string>();
|
Dictionary<uint, string> morphChannelNames = new Dictionary<uint, string>();
|
||||||
|
private IEqualityComparer<AnimationClip> animationClipEqComparer = new AnimationClip.EqComparer();
|
||||||
|
|
||||||
public ModelConverter(GameObject m_GameObject, ImageFormat imageFormat, AnimationClip[] animationList = null)
|
public ModelConverter(GameObject m_GameObject, ImageFormat imageFormat, AnimationClip[] animationList = null)
|
||||||
{
|
{
|
||||||
@ -40,7 +41,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
if (animationList != null)
|
if (animationList != null)
|
||||||
{
|
{
|
||||||
animationClipUniqArray = animationList.Distinct().ToArray();
|
animationClipUniqArray = animationList.Distinct(animationClipEqComparer).ToArray();
|
||||||
}
|
}
|
||||||
ConvertAnimations();
|
ConvertAnimations();
|
||||||
}
|
}
|
||||||
@ -67,7 +68,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
if (animationList != null)
|
if (animationList != null)
|
||||||
{
|
{
|
||||||
animationClipUniqArray = animationList.Distinct().ToArray();
|
animationClipUniqArray = animationList.Distinct(animationClipEqComparer).ToArray();
|
||||||
}
|
}
|
||||||
ConvertAnimations();
|
ConvertAnimations();
|
||||||
}
|
}
|
||||||
@ -82,7 +83,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
animationClipUniqArray = animationList.Distinct().ToArray();
|
animationClipUniqArray = animationList.Distinct(animationClipEqComparer).ToArray();
|
||||||
}
|
}
|
||||||
ConvertAnimations();
|
ConvertAnimations();
|
||||||
}
|
}
|
||||||
@ -163,7 +164,7 @@ namespace AssetStudio
|
|||||||
animationList.Add(animationClip);
|
animationList.Add(animationClip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
animationClipUniqArray = animationList.Distinct().ToArray();
|
animationClipUniqArray = animationList.Distinct(animationClipEqComparer).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var pptr in m_Transform.m_Children)
|
foreach (var pptr in m_Transform.m_Children)
|
||||||
@ -207,7 +208,7 @@ namespace AssetStudio
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
animationClipUniqArray = animationList.Distinct().ToArray();
|
animationClipUniqArray = animationList.Distinct(animationClipEqComparer).ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user