SliderMath.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using static AnimationKeyInfo;
  4. namespace SliderUnlocker
  5. {
  6. public static class SliderMath
  7. {
  8. public static Vector3 CalculateScale(List<AnmKeyInfo> list, float rate)
  9. {
  10. Vector3 min = list[0].scl;
  11. Vector3 max = list[list.Count - 1].scl;
  12. return min + (max - min) * rate;
  13. }
  14. public static Vector3 CalculatePosition(List<AnmKeyInfo> list, float rate)
  15. {
  16. Vector3 min = list[0].pos;
  17. Vector3 max = list[list.Count - 1].pos;
  18. return min + (max - min) * rate;
  19. }
  20. public static Vector3 CalculateRotation(List<AnmKeyInfo> list, float rate)
  21. {
  22. Vector3 rot1 = list[0].rot;
  23. Vector3 rot2 = list[1].rot;
  24. Vector3 rot3 = list[list.Count - 1].rot;
  25. Vector3 vector = rot2 - rot1;
  26. Vector3 vector2 = rot3 - rot1;
  27. bool xFlag = vector.x >= 0f;
  28. bool yFlag = vector.y >= 0f;
  29. bool zFlag = vector.z >= 0f;
  30. if (vector2.x > 0f && !xFlag)
  31. {
  32. vector2.x -= 360f;
  33. }
  34. else if (vector2.x < 0f && xFlag)
  35. {
  36. vector2.x += 360f;
  37. }
  38. if (vector2.y > 0f && !yFlag)
  39. {
  40. vector2.y -= 360f;
  41. }
  42. else if (vector2.y < 0f && yFlag)
  43. {
  44. vector2.y += 360f;
  45. }
  46. if (vector2.z > 0f && !zFlag)
  47. {
  48. vector2.z -= 360f;
  49. }
  50. else if (vector2.z < 0f && zFlag)
  51. {
  52. vector2.z += 360f;
  53. }
  54. if (rate < 0f)
  55. {
  56. return rot1 - vector2 * Mathf.Abs(rate);
  57. }
  58. return rot3 + vector2 * Mathf.Abs(rate - 1f);
  59. }
  60. public static Vector3 SafeCalculateRotation(Vector3 original, string name, List<AnmKeyInfo> list, float rate)
  61. {
  62. if (!(name.StartsWith("cf_a_bust") && name.EndsWith("_size")) && //breast fix
  63. !(name.Contains("thigh") && name.Contains("01"))) //thigh fix
  64. {
  65. return CalculateRotation(list, rate);
  66. }
  67. else
  68. {
  69. return original;
  70. }
  71. }
  72. }
  73. }