From c8228ed2f81a8a2d83a5d50e8a7ba30113648116 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 3 Apr 2018 20:24:17 +0900 Subject: [PATCH] remove CustomerEqualityComparer --- Scripts/BlendShape/BlendShapeKey.cs | 29 ++++++++------------ Scripts/BlendShape/VRMBlendShapeProxy.cs | 4 +-- Scripts/Editor/Tests/VRMBlendShapeKeyTest.cs | 2 +- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Scripts/BlendShape/BlendShapeKey.cs b/Scripts/BlendShape/BlendShapeKey.cs index c86669447..67c34a404 100644 --- a/Scripts/BlendShape/BlendShapeKey.cs +++ b/Scripts/BlendShape/BlendShapeKey.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; + namespace VRM { @@ -58,29 +58,24 @@ namespace VRM public bool Equals(BlendShapeKey other) { - /* - if (Preset != BlendShapePreset.Unknown && Preset == other.Preset) - { - // Unknown以外のPresetが一致したら一致とみなす - return true; - } - // .ToUpper()済み - return Name == other.Name; - */ return ID == other.ID; } - public class CustomerEqualityComparer : IEqualityComparer + public override bool Equals(object obj) { - public bool Equals(BlendShapeKey x, BlendShapeKey y) + if (obj is BlendShapeKey) { - return x.Equals(y); + return Equals((BlendShapeKey)obj); } + else + { + return false; + } + } - public int GetHashCode(BlendShapeKey obj) - { - return obj.ToString().GetHashCode(); - } + public override int GetHashCode() + { + return ID.GetHashCode(); } public static BlendShapeKey CreateFrom(BlendShapeClip clip) diff --git a/Scripts/BlendShape/VRMBlendShapeProxy.cs b/Scripts/BlendShape/VRMBlendShapeProxy.cs index 9da07c939..43155003d 100644 --- a/Scripts/BlendShape/VRMBlendShapeProxy.cs +++ b/Scripts/BlendShape/VRMBlendShapeProxy.cs @@ -65,8 +65,8 @@ namespace VRM public BlendShapeMerger(IEnumerable clips, Transform root) { - m_clipMap = clips.ToDictionary(x => BlendShapeKey.CreateFrom(x), x => x, new BlendShapeKey.CustomerEqualityComparer()); - m_valueMap = new Dictionary(new BlendShapeKey.CustomerEqualityComparer()); + m_clipMap = clips.ToDictionary(x => BlendShapeKey.CreateFrom(x), x => x); + m_valueMap = new Dictionary(); foreach (var kv in m_clipMap) { foreach (var binding in kv.Value.Values) { diff --git a/Scripts/Editor/Tests/VRMBlendShapeKeyTest.cs b/Scripts/Editor/Tests/VRMBlendShapeKeyTest.cs index 807ee7634..cb40941a9 100644 --- a/Scripts/Editor/Tests/VRMBlendShapeKeyTest.cs +++ b/Scripts/Editor/Tests/VRMBlendShapeKeyTest.cs @@ -14,7 +14,7 @@ public class VRMBlendShapeKeyTest Assert.AreEqual(key, new BlendShapeKey(BlendShapePreset.Blink)); Assert.AreEqual(key, new BlendShapeKey("xxx", BlendShapePreset.Blink)); - var dict = new Dictionary(new BlendShapeKey.CustomerEqualityComparer()); + var dict = new Dictionary(); dict[new BlendShapeKey("xxx", BlendShapePreset.Blink)] = 1.0f; Assert.IsTrue(dict.ContainsKey(new BlendShapeKey("blink")));