Skip to content

Commit

Permalink
Make sure sum of weights doesn't exceed 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sauceke committed Aug 28, 2023
1 parent 18f1744 commit bab5b53
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion KK_SexFaces/FacialExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,13 @@ private static Dictionary<int, float> GetExpression(FBSBase fbs) =>
Traverse.Create(fbs).Field<Dictionary<int, float>>("dictNowFace").Value;

private static string DictToString(Dictionary<int, float> dict) => dict
.Select(pair => pair.Key + ":" + pair.Value)
.Select(pair => pair.Key + ":" + pair.Value.ToString("F4"))
.Aggregate("", (a, b) => a + ";" + b);

private static Dictionary<int, float> StringToDict(string s) =>
s.Split(';').Skip(1).ToDictionary(
pair => int.Parse(pair.Split(':')[0]),
pair => float.Parse(pair.Split(':')[1]));

}
}

0 comments on commit bab5b53

Please sign in to comment.