SAMeshColliderCommon.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System;
  2. using UnityEngine;
  3. public class SAMeshColliderCommon
  4. {
  5. public enum SplitMode
  6. {
  7. None,
  8. Material,
  9. Primitive,
  10. Polygon
  11. }
  12. [Serializable]
  13. public class SplitMesh
  14. {
  15. public void PurgeTemporary()
  16. {
  17. this.triangles = null;
  18. this.vertices = null;
  19. this.triangleNormals = null;
  20. }
  21. public int subMeshCount;
  22. public int subMesh = -1;
  23. public int triangle = -1;
  24. public Vector3 triangleVertex;
  25. public int[] polygonTriangles;
  26. public Vector3[] polygonVertices;
  27. [NonSerialized]
  28. public int[] triangles;
  29. [NonSerialized]
  30. public Vector3[] vertices;
  31. [NonSerialized]
  32. public Vector3[] triangleNormals;
  33. }
  34. [Serializable]
  35. public class SplitProperty
  36. {
  37. public SAMeshColliderCommon.SplitProperty ShallowCopy()
  38. {
  39. return (SAMeshColliderCommon.SplitProperty)base.MemberwiseClone();
  40. }
  41. public bool splitMaterialEnabled = true;
  42. public bool splitPrimitiveEnabled = true;
  43. public bool splitPolygonNormalEnabled;
  44. public float splitPolygonNormalAngle = 45f;
  45. }
  46. [Serializable]
  47. public class SAMeshColliderProperty
  48. {
  49. public SAMeshColliderCommon.SAMeshColliderProperty Copy()
  50. {
  51. SAMeshColliderCommon.SAMeshColliderProperty sameshColliderProperty = new SAMeshColliderCommon.SAMeshColliderProperty();
  52. if (this.splitProperty != null)
  53. {
  54. sameshColliderProperty.splitProperty = this.splitProperty.ShallowCopy();
  55. }
  56. if (this.reducerProperty != null)
  57. {
  58. sameshColliderProperty.reducerProperty = this.reducerProperty.ShallowCopy();
  59. }
  60. if (this.colliderProperty != null)
  61. {
  62. sameshColliderProperty.colliderProperty = this.colliderProperty.ShallowCopy();
  63. }
  64. if (this.rigidbodyProperty != null)
  65. {
  66. sameshColliderProperty.rigidbodyProperty = this.rigidbodyProperty.ShallowCopy();
  67. }
  68. sameshColliderProperty.modifyNameEnabled = this.modifyNameEnabled;
  69. return sameshColliderProperty;
  70. }
  71. public SAMeshColliderCommon.SplitProperty splitProperty = new SAMeshColliderCommon.SplitProperty();
  72. public SAColliderBuilderCommon.ReducerProperty reducerProperty = new SAColliderBuilderCommon.ReducerProperty();
  73. public SAColliderBuilderCommon.ColliderProperty colliderProperty = new SAColliderBuilderCommon.ColliderProperty();
  74. public SAColliderBuilderCommon.RigidbodyProperty rigidbodyProperty = new SAColliderBuilderCommon.RigidbodyProperty();
  75. public bool modifyNameEnabled = true;
  76. }
  77. [Serializable]
  78. public class SAMeshColliderBuilderProperty
  79. {
  80. public SAMeshColliderCommon.SAMeshColliderBuilderProperty Copy()
  81. {
  82. SAMeshColliderCommon.SAMeshColliderBuilderProperty sameshColliderBuilderProperty = new SAMeshColliderCommon.SAMeshColliderBuilderProperty();
  83. if (this.splitProperty != null)
  84. {
  85. sameshColliderBuilderProperty.splitProperty = this.splitProperty.ShallowCopy();
  86. }
  87. if (this.reducerProperty != null)
  88. {
  89. sameshColliderBuilderProperty.reducerProperty = this.reducerProperty.ShallowCopy();
  90. }
  91. if (this.colliderProperty != null)
  92. {
  93. sameshColliderBuilderProperty.colliderProperty = this.colliderProperty.ShallowCopy();
  94. }
  95. if (this.rigidbodyProperty != null)
  96. {
  97. sameshColliderBuilderProperty.rigidbodyProperty = this.rigidbodyProperty.ShallowCopy();
  98. }
  99. sameshColliderBuilderProperty.modifyNameEnabled = this.modifyNameEnabled;
  100. return sameshColliderBuilderProperty;
  101. }
  102. public SAMeshColliderCommon.SAMeshColliderProperty ToSAMeshColliderProperty()
  103. {
  104. SAMeshColliderCommon.SAMeshColliderProperty sameshColliderProperty = new SAMeshColliderCommon.SAMeshColliderProperty();
  105. if (this.splitProperty != null)
  106. {
  107. sameshColliderProperty.splitProperty = this.splitProperty.ShallowCopy();
  108. }
  109. if (this.reducerProperty != null)
  110. {
  111. sameshColliderProperty.reducerProperty = this.reducerProperty.ShallowCopy();
  112. }
  113. if (this.colliderProperty != null)
  114. {
  115. sameshColliderProperty.colliderProperty = this.colliderProperty.ShallowCopy();
  116. }
  117. if (this.rigidbodyProperty != null)
  118. {
  119. sameshColliderProperty.rigidbodyProperty = this.rigidbodyProperty.ShallowCopy();
  120. }
  121. sameshColliderProperty.modifyNameEnabled = this.modifyNameEnabled;
  122. return sameshColliderProperty;
  123. }
  124. public SAMeshColliderCommon.SplitProperty splitProperty = new SAMeshColliderCommon.SplitProperty();
  125. public SAColliderBuilderCommon.ReducerProperty reducerProperty = new SAColliderBuilderCommon.ReducerProperty();
  126. public SAColliderBuilderCommon.ColliderProperty colliderProperty = new SAColliderBuilderCommon.ColliderProperty();
  127. public SAColliderBuilderCommon.RigidbodyProperty rigidbodyProperty = new SAColliderBuilderCommon.RigidbodyProperty();
  128. public bool modifyNameEnabled = true;
  129. }
  130. }