DragPointMune.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using UnityEngine;
  2. using Input = MeidoPhotoStudio.Plugin.InputManager;
  3. namespace MeidoPhotoStudio.Plugin;
  4. public class DragPointMune : DragPointChain
  5. {
  6. private bool isMuneL;
  7. private int inv = 1;
  8. public override void Set(Transform myObject)
  9. {
  10. base.Set(myObject);
  11. isMuneL = myObject.name[5] is 'L'; // Mune_L_Sub
  12. if (isMuneL)
  13. inv *= -1;
  14. }
  15. protected override void ApplyDragType() =>
  16. ApplyProperties(CurrentDragType is not DragType.None, false, false);
  17. protected override void OnMouseDown()
  18. {
  19. base.OnMouseDown();
  20. meido.SetMune(false, isMuneL);
  21. }
  22. protected override void OnDoubleClick()
  23. {
  24. if (CurrentDragType is not DragType.None)
  25. meido.SetMune(true, isMuneL);
  26. }
  27. protected override void UpdateDragType() =>
  28. // TODO: Rethink this formatting
  29. CurrentDragType = Input.Control && Input.Alt
  30. ? Input.Shift
  31. ? DragType.RotLocalY
  32. : DragType.RotLocalXZ
  33. : DragType.None;
  34. protected override void Drag()
  35. {
  36. if (isPlaying)
  37. meido.Stop = true;
  38. if (CurrentDragType is DragType.RotLocalXZ)
  39. {
  40. Porc(IK, ikCtrlData, ikChain[JointUpper], ikChain[JointMiddle], ikChain[JointLower]);
  41. InitializeRotation();
  42. }
  43. if (CurrentDragType is DragType.RotLocalY)
  44. {
  45. var mouseDelta = MouseDelta();
  46. ikChain[JointLower].localRotation = jointRotation[JointLower];
  47. // TODO: Reorder operands for better performance
  48. ikChain[JointLower].Rotate(Vector3.up * (-mouseDelta.x / 1.5f) * inv);
  49. ikChain[JointLower].Rotate(Vector3.forward * (mouseDelta.y / 1.5f) * inv);
  50. }
  51. }
  52. }