remove CustomerEqualityComparer

This commit is contained in:
ousttrue 2018-04-03 20:24:17 +09:00
parent 8fb64eb6cd
commit c8228ed2f8
3 changed files with 15 additions and 20 deletions

View File

@ -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<BlendShapeKey>
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)

View File

@ -65,8 +65,8 @@ namespace VRM
public BlendShapeMerger(IEnumerable<BlendShapeClip> clips, Transform root)
{
m_clipMap = clips.ToDictionary(x => BlendShapeKey.CreateFrom(x), x => x, new BlendShapeKey.CustomerEqualityComparer());
m_valueMap = new Dictionary<BlendShapeKey, float>(new BlendShapeKey.CustomerEqualityComparer());
m_clipMap = clips.ToDictionary(x => BlendShapeKey.CreateFrom(x), x => x);
m_valueMap = new Dictionary<BlendShapeKey, float>();
foreach (var kv in m_clipMap)
{
foreach (var binding in kv.Value.Values) {

View File

@ -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<BlendShapeKey, float>(new BlendShapeKey.CustomerEqualityComparer());
var dict = new Dictionary<BlendShapeKey, float>();
dict[new BlendShapeKey("xxx", BlendShapePreset.Blink)] = 1.0f;
Assert.IsTrue(dict.ContainsKey(new BlendShapeKey("blink")));