MagicaBoneSpringGizmoDrawer.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Magica Cloth.
  2. // Copyright (c) MagicaSoft, 2020-2022.
  3. // https://magicasoft.jp
  4. using UnityEditor;
  5. namespace MagicaCloth
  6. {
  7. /// <summary>
  8. /// MagicaBoneSpringのギズモ表示
  9. /// </summary>
  10. public class MagicaBoneSpringGizmoDrawer
  11. {
  12. [DrawGizmo(GizmoType.Selected | GizmoType.NonSelected | GizmoType.Active)]
  13. //[DrawGizmo(GizmoType.Selected | GizmoType.Active)]
  14. static void DrawGizmo(MagicaBoneSpring scr, GizmoType gizmoType)
  15. {
  16. bool selected = (gizmoType & GizmoType.Selected) != 0 || (ClothMonitorMenu.Monitor != null && ClothMonitorMenu.Monitor.UI.AlwaysClothShow);
  17. if (scr.VerifyData() != Define.Error.None)
  18. {
  19. //DrawRootLine(scr);
  20. return;
  21. }
  22. if (PointSelector.EditEnable)
  23. {
  24. //DrawRootLine(scr);
  25. return;
  26. }
  27. if (ClothMonitorMenu.Monitor == null)
  28. return;
  29. if (selected == false)
  30. return;
  31. // デフォーマーギズモ
  32. DeformerGizmoDrawer.DrawDeformerGizmo(scr, scr, 0.015f);
  33. if (ClothMonitorMenu.Monitor.UI.DrawCloth)
  34. {
  35. // クロスギズモ
  36. ClothGizmoDrawer.DrawClothGizmo(
  37. scr,
  38. scr.ClothData,
  39. scr.Params,
  40. scr.Setup,
  41. scr,
  42. scr
  43. );
  44. }
  45. //else
  46. //{
  47. // DrawRootLine(scr);
  48. //}
  49. }
  50. //=========================================================================================
  51. #if false
  52. static void DrawRootLine(BoneSpring scr)
  53. {
  54. for (int i = 0; i < scr.ClothTarget.RootCount; i++)
  55. {
  56. var root = scr.ClothTarget.GetRoot(i);
  57. if (root == null)
  58. continue;
  59. DrawTransformLine(root, root);
  60. }
  61. }
  62. static void DrawTransformLine(Transform t, Transform root)
  63. {
  64. if (t == null)
  65. return;
  66. // トランスフォーム描画
  67. if (PointSelector.EditEnable == false)
  68. {
  69. Gizmos.color = (t == root) ? GizmoUtility.ColorKinematic : GizmoUtility.ColorDynamic;
  70. GizmoUtility.DrawWireCube(t.position, t.rotation, Vector3.one * 0.01f);
  71. }
  72. int cnt = t.childCount;
  73. for (int i = 0; i < cnt; i++)
  74. {
  75. Transform ct = t.GetChild(i);
  76. // ライン
  77. Gizmos.color = GizmoUtility.ColorRotationLine;
  78. Gizmos.DrawLine(t.position, ct.position);
  79. DrawTransformLine(ct, root);
  80. }
  81. }
  82. #endif
  83. }
  84. }