MagicaMeshSpringGizmoDrawer.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Magica Cloth.
  2. // Copyright (c) MagicaSoft, 2020-2022.
  3. // https://magicasoft.jp
  4. using UnityEditor;
  5. using UnityEngine;
  6. namespace MagicaCloth
  7. {
  8. /// <summary>
  9. /// MagicaMeshSpringのギズモ表示
  10. /// </summary>
  11. public class MagicaMeshSpringGizmoDrawer
  12. {
  13. [DrawGizmo(GizmoType.Selected | GizmoType.NonSelected | GizmoType.Active)]
  14. static void DrawGizmo(MagicaMeshSpring scr, GizmoType gizmoType)
  15. {
  16. bool selected = (gizmoType & GizmoType.Selected) != 0;
  17. bool allshow = ClothMonitorMenu.Monitor != null && ClothMonitorMenu.Monitor.UI.AlwaysClothShow;
  18. if (PointSelector.EditEnable)
  19. return;
  20. // スプリング球
  21. if (selected)
  22. DrawSpringSphere(scr);
  23. if (ClothMonitorMenu.Monitor == null)
  24. return;
  25. // データ整合性チェック
  26. if (scr.VerifyData() != Define.Error.None)
  27. return;
  28. // デフォーマーギズモ
  29. /*var dcnt = scr.Contents.DeformerCount;
  30. for (int i = 0; i < dcnt; i++)
  31. {
  32. var deformer = scr.Contents.GetDeformer(i);
  33. if (deformer == null || deformer.IsValidData() == false)
  34. continue;
  35. var datalist = scr.Contents.SpringData.deformerDataList;
  36. if (i >= datalist.Count)
  37. continue;
  38. var springData = datalist[i];
  39. if (springData.vertexCount == 0)
  40. continue;
  41. //DeformerGizmoDrawer.DrawDeformerGizmo(deformer, springData);
  42. }*/
  43. if (ClothMonitorMenu.Monitor.UI.DrawCloth == false)
  44. return;
  45. if ((selected || allshow) == false)
  46. return;
  47. // クロスギズモ
  48. ClothGizmoDrawer.DrawClothGizmo(
  49. scr,
  50. scr.ClothData,
  51. scr.Params,
  52. scr.Setup,
  53. scr,
  54. scr
  55. );
  56. }
  57. /// <summary>
  58. /// スプリングの範囲球ギズモ
  59. /// </summary>
  60. /// <param name="scr"></param>
  61. static void DrawSpringSphere(MagicaMeshSpring scr)
  62. {
  63. var t = scr.CenterTransform;
  64. if (t == null)
  65. return;
  66. Gizmos.color = Color.cyan;
  67. GizmoUtility.DrawWireSphere(t.position, t.rotation, scr.Params.SpringRadiusScale, scr.Params.SpringRadius, true, true);
  68. // 軸矢印
  69. Handles.color = Color.yellow;
  70. Handles.Slider(t.position, scr.CenterTransformDirection, scr.Params.SpringRadius, Handles.ArrowHandleCap, 1.0f);
  71. }
  72. }
  73. }