DragPointPelvis.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using UnityEngine;
  2. using Input = MeidoPhotoStudio.Plugin.InputManager;
  3. namespace MeidoPhotoStudio.Plugin;
  4. public class DragPointPelvis : DragPointMeido
  5. {
  6. private Quaternion pelvisRotation;
  7. protected override void ApplyDragType()
  8. {
  9. if (CurrentDragType is DragType.Ignore)
  10. ApplyProperties();
  11. else if (IsBone)
  12. ApplyProperties(false, false, false);
  13. else
  14. ApplyProperties(CurrentDragType is not DragType.None, false, false);
  15. }
  16. protected override void UpdateDragType() =>
  17. // TODO: Rethink this formatting
  18. CurrentDragType = Input.Alt && !Input.Control
  19. ? Input.Shift
  20. ? DragType.RotLocalY
  21. : DragType.RotLocalXZ
  22. : OtherDragType()
  23. ? DragType.Ignore
  24. : DragType.None;
  25. protected override void OnMouseDown()
  26. {
  27. base.OnMouseDown();
  28. pelvisRotation = MyObject.rotation;
  29. }
  30. protected override void Drag()
  31. {
  32. if (CurrentDragType is DragType.None)
  33. return;
  34. if (isPlaying)
  35. meido.Stop = true;
  36. var mouseDelta = MouseDelta();
  37. if (CurrentDragType is DragType.RotLocalXZ)
  38. {
  39. MyObject.rotation = pelvisRotation;
  40. MyObject.Rotate(camera.transform.forward, mouseDelta.x / 6f, Space.World);
  41. MyObject.Rotate(camera.transform.right, mouseDelta.y / 4f, Space.World);
  42. }
  43. if (CurrentDragType is DragType.RotLocalY)
  44. {
  45. MyObject.rotation = pelvisRotation;
  46. MyObject.Rotate(Vector3.right * (mouseDelta.x / 2.2f));
  47. }
  48. }
  49. }