SkeletonExtensions.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. /******************************************************************************
  2. * Spine Runtimes License Agreement
  3. * Last updated July 28, 2023. Replaces all prior versions.
  4. *
  5. * Copyright (c) 2013-2023, Esoteric Software LLC
  6. *
  7. * Integration of the Spine Runtimes into software or otherwise creating
  8. * derivative works of the Spine Runtimes is permitted under the terms and
  9. * conditions of Section 2 of the Spine Editor License Agreement:
  10. * http://esotericsoftware.com/spine-editor-license
  11. *
  12. * Otherwise, it is permitted to integrate the Spine Runtimes into software or
  13. * otherwise create derivative works of the Spine Runtimes (collectively,
  14. * "Products"), provided that each user of the Products must obtain their own
  15. * Spine Editor license and redistribution of the Products in any form must
  16. * include this license and copyright notice.
  17. *
  18. * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
  19. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
  24. * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
  27. * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *****************************************************************************/
  29. using UnityEngine;
  30. namespace Spine.Unity {
  31. public static class SkeletonExtensions {
  32. #region Colors
  33. const float ByteToFloat = 1f / 255f;
  34. public static Color GetColor (this Skeleton s) { return new Color(s.R, s.G, s.B, s.A); }
  35. public static Color GetColor (this RegionAttachment a) { return new Color(a.R, a.G, a.B, a.A); }
  36. public static Color GetColor (this MeshAttachment a) { return new Color(a.R, a.G, a.B, a.A); }
  37. public static Color GetColor (this Slot s) { return new Color(s.R, s.G, s.B, s.A); }
  38. public static Color GetColorTintBlack (this Slot s) { return new Color(s.R2, s.G2, s.B2, 1f); }
  39. public static void SetColor (this Skeleton skeleton, Color color) {
  40. skeleton.A = color.a;
  41. skeleton.R = color.r;
  42. skeleton.G = color.g;
  43. skeleton.B = color.b;
  44. }
  45. public static void SetColor (this Skeleton skeleton, Color32 color) {
  46. skeleton.A = color.a * ByteToFloat;
  47. skeleton.R = color.r * ByteToFloat;
  48. skeleton.G = color.g * ByteToFloat;
  49. skeleton.B = color.b * ByteToFloat;
  50. }
  51. public static void SetColor (this Slot slot, Color color) {
  52. slot.A = color.a;
  53. slot.R = color.r;
  54. slot.G = color.g;
  55. slot.B = color.b;
  56. }
  57. public static void SetColor (this Slot slot, Color32 color) {
  58. slot.A = color.a * ByteToFloat;
  59. slot.R = color.r * ByteToFloat;
  60. slot.G = color.g * ByteToFloat;
  61. slot.B = color.b * ByteToFloat;
  62. }
  63. public static void SetColor (this RegionAttachment attachment, Color color) {
  64. attachment.A = color.a;
  65. attachment.R = color.r;
  66. attachment.G = color.g;
  67. attachment.B = color.b;
  68. }
  69. public static void SetColor (this RegionAttachment attachment, Color32 color) {
  70. attachment.A = color.a * ByteToFloat;
  71. attachment.R = color.r * ByteToFloat;
  72. attachment.G = color.g * ByteToFloat;
  73. attachment.B = color.b * ByteToFloat;
  74. }
  75. public static void SetColor (this MeshAttachment attachment, Color color) {
  76. attachment.A = color.a;
  77. attachment.R = color.r;
  78. attachment.G = color.g;
  79. attachment.B = color.b;
  80. }
  81. public static void SetColor (this MeshAttachment attachment, Color32 color) {
  82. attachment.A = color.a * ByteToFloat;
  83. attachment.R = color.r * ByteToFloat;
  84. attachment.G = color.g * ByteToFloat;
  85. attachment.B = color.b * ByteToFloat;
  86. }
  87. #endregion
  88. #region Skeleton
  89. /// <summary>Sets the Skeleton's local scale using a UnityEngine.Vector2. If only individual components need to be set, set Skeleton.ScaleX or Skeleton.ScaleY.</summary>
  90. public static void SetLocalScale (this Skeleton skeleton, Vector2 scale) {
  91. skeleton.ScaleX = scale.x;
  92. skeleton.ScaleY = scale.y;
  93. }
  94. /// <summary>Gets the internal bone matrix as a Unity bonespace-to-skeletonspace transformation matrix.</summary>
  95. public static Matrix4x4 GetMatrix4x4 (this Bone bone) {
  96. return new Matrix4x4 {
  97. m00 = bone.A,
  98. m01 = bone.B,
  99. m03 = bone.WorldX,
  100. m10 = bone.C,
  101. m11 = bone.D,
  102. m13 = bone.WorldY,
  103. m33 = 1
  104. };
  105. }
  106. #endregion
  107. #region Bone
  108. /// <summary>Sets the bone's (local) X and Y according to a Vector2</summary>
  109. public static void SetLocalPosition (this Bone bone, Vector2 position) {
  110. bone.X = position.x;
  111. bone.Y = position.y;
  112. }
  113. /// <summary>Sets the bone's (local) X and Y according to a Vector3. The z component is ignored.</summary>
  114. public static void SetLocalPosition (this Bone bone, Vector3 position) {
  115. bone.X = position.x;
  116. bone.Y = position.y;
  117. }
  118. /// <summary>Gets the bone's local X and Y as a Vector2.</summary>
  119. public static Vector2 GetLocalPosition (this Bone bone) {
  120. return new Vector2(bone.X, bone.Y);
  121. }
  122. /// <summary>Gets the position of the bone in Skeleton-space.</summary>
  123. public static Vector2 GetSkeletonSpacePosition (this Bone bone) {
  124. return new Vector2(bone.WorldX, bone.WorldY);
  125. }
  126. /// <summary>Gets a local offset from the bone and converts it into Skeleton-space.</summary>
  127. public static Vector2 GetSkeletonSpacePosition (this Bone bone, Vector2 boneLocal) {
  128. Vector2 o;
  129. bone.LocalToWorld(boneLocal.x, boneLocal.y, out o.x, out o.y);
  130. return o;
  131. }
  132. /// <summary>Gets the bone's Unity World position using its Spine GameObject Transform. UpdateWorldTransform needs to have been called for this to return the correct, updated value.</summary>
  133. public static Vector3 GetWorldPosition (this Bone bone, UnityEngine.Transform spineGameObjectTransform) {
  134. return spineGameObjectTransform.TransformPoint(new Vector3(bone.WorldX, bone.WorldY));
  135. }
  136. public static Vector3 GetWorldPosition (this Bone bone, UnityEngine.Transform spineGameObjectTransform, float positionScale) {
  137. return spineGameObjectTransform.TransformPoint(new Vector3(bone.WorldX * positionScale, bone.WorldY * positionScale));
  138. }
  139. public static Vector3 GetWorldPosition (this Bone bone, UnityEngine.Transform spineGameObjectTransform, float positionScale, Vector2 positionOffset) {
  140. return spineGameObjectTransform.TransformPoint(new Vector3(bone.WorldX * positionScale + positionOffset.x, bone.WorldY * positionScale + positionOffset.y));
  141. }
  142. /// <summary>Gets a skeleton space UnityEngine.Quaternion representation of bone.WorldRotationX.</summary>
  143. public static Quaternion GetQuaternion (this Bone bone) {
  144. float halfRotation = Mathf.Atan2(bone.C, bone.A) * 0.5f;
  145. return new Quaternion(0, 0, Mathf.Sin(halfRotation), Mathf.Cos(halfRotation));
  146. }
  147. /// <summary>Gets a bone-local space UnityEngine.Quaternion representation of bone.rotation.</summary>
  148. public static Quaternion GetLocalQuaternion (this Bone bone) {
  149. float halfRotation = bone.Rotation * Mathf.Deg2Rad * 0.5f;
  150. return new Quaternion(0, 0, Mathf.Sin(halfRotation), Mathf.Cos(halfRotation));
  151. }
  152. /// <summary>Returns the Skeleton's local scale as a UnityEngine.Vector2. If only individual components are needed, use Skeleton.ScaleX or Skeleton.ScaleY.</summary>
  153. public static Vector2 GetLocalScale (this Skeleton skeleton) {
  154. return new Vector2(skeleton.ScaleX, skeleton.ScaleY);
  155. }
  156. /// <summary>Calculates a 2x2 Transformation Matrix that can convert a skeleton-space position to a bone-local position.</summary>
  157. public static void GetWorldToLocalMatrix (this Bone bone, out float ia, out float ib, out float ic, out float id) {
  158. float a = bone.A, b = bone.B, c = bone.C, d = bone.D;
  159. float invDet = 1 / (a * d - b * c);
  160. ia = invDet * d;
  161. ib = invDet * -b;
  162. ic = invDet * -c;
  163. id = invDet * a;
  164. }
  165. /// <summary>UnityEngine.Vector2 override of Bone.WorldToLocal. This converts a skeleton-space position into a bone local position.</summary>
  166. public static Vector2 WorldToLocal (this Bone bone, Vector2 worldPosition) {
  167. Vector2 o;
  168. bone.WorldToLocal(worldPosition.x, worldPosition.y, out o.x, out o.y);
  169. return o;
  170. }
  171. /// <summary>Sets the skeleton-space position of a bone.</summary>
  172. /// <returns>The local position in its parent bone space, or in skeleton space if it is the root bone.</returns>
  173. public static Vector2 SetPositionSkeletonSpace (this Bone bone, Vector2 skeletonSpacePosition) {
  174. if (bone.Parent == null) { // root bone
  175. bone.SetLocalPosition(skeletonSpacePosition);
  176. return skeletonSpacePosition;
  177. } else {
  178. Bone parent = bone.Parent;
  179. Vector2 parentLocal = parent.WorldToLocal(skeletonSpacePosition);
  180. bone.SetLocalPosition(parentLocal);
  181. return parentLocal;
  182. }
  183. }
  184. #endregion
  185. #region Attachments
  186. public static Material GetMaterial (this Attachment a) {
  187. object rendererObject = null;
  188. IHasTextureRegion renderableAttachment = a as IHasTextureRegion;
  189. if (renderableAttachment != null)
  190. rendererObject = renderableAttachment.Region;
  191. if (rendererObject == null)
  192. return null;
  193. #if SPINE_TK2D
  194. return (rendererObject.GetType() == typeof(Material)) ? (Material)rendererObject : (Material)((AtlasRegion)rendererObject).page.rendererObject;
  195. #else
  196. return (Material)((AtlasRegion)rendererObject).page.rendererObject;
  197. #endif
  198. }
  199. /// <summary>Fills a Vector2 buffer with local vertices.</summary>
  200. /// <param name="va">The VertexAttachment</param>
  201. /// <param name="slot">Slot where the attachment belongs.</param>
  202. /// <param name="buffer">Correctly-sized buffer. Use attachment's .WorldVerticesLength to get the correct size. If null, a new Vector2[] of the correct size will be allocated.</param>
  203. public static Vector2[] GetLocalVertices (this VertexAttachment va, Slot slot, Vector2[] buffer) {
  204. int floatsCount = va.WorldVerticesLength;
  205. int bufferTargetSize = floatsCount >> 1;
  206. buffer = buffer ?? new Vector2[bufferTargetSize];
  207. if (buffer.Length < bufferTargetSize) throw new System.ArgumentException(string.Format("Vector2 buffer too small. {0} requires an array of size {1}. Use the attachment's .WorldVerticesLength to get the correct size.", va.Name, floatsCount), "buffer");
  208. if (va.Bones == null && slot.Deform.Count == 0) {
  209. float[] localVerts = va.Vertices;
  210. for (int i = 0; i < bufferTargetSize; i++) {
  211. int j = i * 2;
  212. buffer[i] = new Vector2(localVerts[j], localVerts[j + 1]);
  213. }
  214. } else {
  215. float[] floats = new float[floatsCount];
  216. va.ComputeWorldVertices(slot, floats);
  217. Bone sb = slot.Bone;
  218. float ia, ib, ic, id, bwx = sb.WorldX, bwy = sb.WorldY;
  219. sb.GetWorldToLocalMatrix(out ia, out ib, out ic, out id);
  220. for (int i = 0; i < bufferTargetSize; i++) {
  221. int j = i * 2;
  222. float x = floats[j] - bwx, y = floats[j + 1] - bwy;
  223. buffer[i] = new Vector2(x * ia + y * ib, x * ic + y * id);
  224. }
  225. }
  226. return buffer;
  227. }
  228. /// <summary>Calculates world vertices and fills a Vector2 buffer.</summary>
  229. /// <param name="a">The VertexAttachment</param>
  230. /// <param name="slot">Slot where the attachment belongs.</param>
  231. /// <param name="buffer">Correctly-sized buffer. Use attachment's .WorldVerticesLength to get the correct size. If null, a new Vector2[] of the correct size will be allocated.</param>
  232. public static Vector2[] GetWorldVertices (this VertexAttachment a, Slot slot, Vector2[] buffer) {
  233. int worldVertsLength = a.WorldVerticesLength;
  234. int bufferTargetSize = worldVertsLength >> 1;
  235. buffer = buffer ?? new Vector2[bufferTargetSize];
  236. if (buffer.Length < bufferTargetSize) throw new System.ArgumentException(string.Format("Vector2 buffer too small. {0} requires an array of size {1}. Use the attachment's .WorldVerticesLength to get the correct size.", a.Name, worldVertsLength), "buffer");
  237. float[] floats = new float[worldVertsLength];
  238. a.ComputeWorldVertices(slot, floats);
  239. for (int i = 0, n = worldVertsLength >> 1; i < n; i++) {
  240. int j = i * 2;
  241. buffer[i] = new Vector2(floats[j], floats[j + 1]);
  242. }
  243. return buffer;
  244. }
  245. /// <summary>Gets the PointAttachment's Unity World position using its Spine GameObject Transform.</summary>
  246. public static Vector3 GetWorldPosition (this PointAttachment attachment, Slot slot, Transform spineGameObjectTransform) {
  247. Vector3 skeletonSpacePosition;
  248. skeletonSpacePosition.z = 0;
  249. attachment.ComputeWorldPosition(slot.Bone, out skeletonSpacePosition.x, out skeletonSpacePosition.y);
  250. return spineGameObjectTransform.TransformPoint(skeletonSpacePosition);
  251. }
  252. /// <summary>Gets the PointAttachment's Unity World position using its Spine GameObject Transform.</summary>
  253. public static Vector3 GetWorldPosition (this PointAttachment attachment, Bone bone, Transform spineGameObjectTransform) {
  254. Vector3 skeletonSpacePosition;
  255. skeletonSpacePosition.z = 0;
  256. attachment.ComputeWorldPosition(bone, out skeletonSpacePosition.x, out skeletonSpacePosition.y);
  257. return spineGameObjectTransform.TransformPoint(skeletonSpacePosition);
  258. }
  259. #endregion
  260. }
  261. }
  262. namespace Spine {
  263. using System;
  264. public struct BoneMatrix {
  265. public float a, b, c, d, x, y;
  266. /// <summary>Recursively calculates a worldspace bone matrix based on BoneData.</summary>
  267. public static BoneMatrix CalculateSetupWorld (BoneData boneData) {
  268. if (boneData == null)
  269. return default(BoneMatrix);
  270. // End condition: isRootBone
  271. if (boneData.Parent == null)
  272. return GetInheritedInternal(boneData, default(BoneMatrix));
  273. BoneMatrix result = CalculateSetupWorld(boneData.Parent);
  274. return GetInheritedInternal(boneData, result);
  275. }
  276. static BoneMatrix GetInheritedInternal (BoneData boneData, BoneMatrix parentMatrix) {
  277. BoneData parent = boneData.Parent;
  278. if (parent == null) return new BoneMatrix(boneData); // isRootBone
  279. float pa = parentMatrix.a, pb = parentMatrix.b, pc = parentMatrix.c, pd = parentMatrix.d;
  280. BoneMatrix result = default(BoneMatrix);
  281. result.x = pa * boneData.X + pb * boneData.Y + parentMatrix.x;
  282. result.y = pc * boneData.X + pd * boneData.Y + parentMatrix.y;
  283. switch (boneData.Inherit) {
  284. case Inherit.Normal: {
  285. float rotationY = boneData.Rotation + 90 + boneData.ShearY;
  286. float la = MathUtils.CosDeg(boneData.Rotation + boneData.ShearX) * boneData.ScaleX;
  287. float lb = MathUtils.CosDeg(rotationY) * boneData.ScaleY;
  288. float lc = MathUtils.SinDeg(boneData.Rotation + boneData.ShearX) * boneData.ScaleX;
  289. float ld = MathUtils.SinDeg(rotationY) * boneData.ScaleY;
  290. result.a = pa * la + pb * lc;
  291. result.b = pa * lb + pb * ld;
  292. result.c = pc * la + pd * lc;
  293. result.d = pc * lb + pd * ld;
  294. break;
  295. }
  296. case Inherit.OnlyTranslation: {
  297. float rotationY = boneData.Rotation + 90 + boneData.ShearY;
  298. result.a = MathUtils.CosDeg(boneData.Rotation + boneData.ShearX) * boneData.ScaleX;
  299. result.b = MathUtils.CosDeg(rotationY) * boneData.ScaleY;
  300. result.c = MathUtils.SinDeg(boneData.Rotation + boneData.ShearX) * boneData.ScaleX;
  301. result.d = MathUtils.SinDeg(rotationY) * boneData.ScaleY;
  302. break;
  303. }
  304. case Inherit.NoRotationOrReflection: {
  305. float s = pa * pa + pc * pc, prx;
  306. if (s > 0.0001f) {
  307. s = Math.Abs(pa * pd - pb * pc) / s;
  308. pb = pc * s;
  309. pd = pa * s;
  310. prx = MathUtils.Atan2(pc, pa) * MathUtils.RadDeg;
  311. } else {
  312. pa = 0;
  313. pc = 0;
  314. prx = 90 - MathUtils.Atan2(pd, pb) * MathUtils.RadDeg;
  315. }
  316. float rx = boneData.Rotation + boneData.ShearX - prx;
  317. float ry = boneData.Rotation + boneData.ShearY - prx + 90;
  318. float la = MathUtils.CosDeg(rx) * boneData.ScaleX;
  319. float lb = MathUtils.CosDeg(ry) * boneData.ScaleY;
  320. float lc = MathUtils.SinDeg(rx) * boneData.ScaleX;
  321. float ld = MathUtils.SinDeg(ry) * boneData.ScaleY;
  322. result.a = pa * la - pb * lc;
  323. result.b = pa * lb - pb * ld;
  324. result.c = pc * la + pd * lc;
  325. result.d = pc * lb + pd * ld;
  326. break;
  327. }
  328. case Inherit.NoScale:
  329. case Inherit.NoScaleOrReflection: {
  330. float cos = MathUtils.CosDeg(boneData.Rotation), sin = MathUtils.SinDeg(boneData.Rotation);
  331. float za = pa * cos + pb * sin;
  332. float zc = pc * cos + pd * sin;
  333. float s = (float)Math.Sqrt(za * za + zc * zc);
  334. if (s > 0.00001f)
  335. s = 1 / s;
  336. za *= s;
  337. zc *= s;
  338. s = (float)Math.Sqrt(za * za + zc * zc);
  339. float r = MathUtils.PI / 2 + MathUtils.Atan2(zc, za);
  340. float zb = MathUtils.Cos(r) * s;
  341. float zd = MathUtils.Sin(r) * s;
  342. float la = MathUtils.CosDeg(boneData.ShearX) * boneData.ScaleX;
  343. float lb = MathUtils.CosDeg(90 + boneData.ShearY) * boneData.ScaleY;
  344. float lc = MathUtils.SinDeg(boneData.ShearX) * boneData.ScaleX;
  345. float ld = MathUtils.SinDeg(90 + boneData.ShearY) * boneData.ScaleY;
  346. if (boneData.Inherit != Inherit.NoScaleOrReflection ? pa * pd - pb * pc < 0 : false) {
  347. zb = -zb;
  348. zd = -zd;
  349. }
  350. result.a = za * la + zb * lc;
  351. result.b = za * lb + zb * ld;
  352. result.c = zc * la + zd * lc;
  353. result.d = zc * lb + zd * ld;
  354. break;
  355. }
  356. }
  357. return result;
  358. }
  359. /// <summary>Constructor for a local bone matrix based on Setup Pose BoneData.</summary>
  360. public BoneMatrix (BoneData boneData) {
  361. float rotationY = boneData.Rotation + 90 + boneData.ShearY;
  362. float rotationX = boneData.Rotation + boneData.ShearX;
  363. a = MathUtils.CosDeg(rotationX) * boneData.ScaleX;
  364. c = MathUtils.SinDeg(rotationX) * boneData.ScaleX;
  365. b = MathUtils.CosDeg(rotationY) * boneData.ScaleY;
  366. d = MathUtils.SinDeg(rotationY) * boneData.ScaleY;
  367. x = boneData.X;
  368. y = boneData.Y;
  369. }
  370. /// <summary>Constructor for a local bone matrix based on a bone instance's current pose.</summary>
  371. public BoneMatrix (Bone bone) {
  372. float rotationY = bone.Rotation + 90 + bone.ShearY;
  373. float rotationX = bone.Rotation + bone.ShearX;
  374. a = MathUtils.CosDeg(rotationX) * bone.ScaleX;
  375. c = MathUtils.SinDeg(rotationX) * bone.ScaleX;
  376. b = MathUtils.CosDeg(rotationY) * bone.ScaleY;
  377. d = MathUtils.SinDeg(rotationY) * bone.ScaleY;
  378. x = bone.X;
  379. y = bone.Y;
  380. }
  381. public BoneMatrix TransformMatrix (BoneMatrix local) {
  382. return new BoneMatrix {
  383. a = this.a * local.a + this.b * local.c,
  384. b = this.a * local.b + this.b * local.d,
  385. c = this.c * local.a + this.d * local.c,
  386. d = this.c * local.b + this.d * local.d,
  387. x = this.a * local.x + this.b * local.y + this.x,
  388. y = this.c * local.x + this.d * local.y + this.y
  389. };
  390. }
  391. }
  392. public static class SpineSkeletonExtensions {
  393. public static bool IsWeighted (this VertexAttachment va) {
  394. return va.Bones != null && va.Bones.Length > 0;
  395. }
  396. #region Inherit Modes
  397. public static bool InheritsRotation (this Inherit mode) {
  398. return mode == Inherit.Normal || mode == Inherit.NoScale || mode == Inherit.NoScaleOrReflection;
  399. }
  400. public static bool InheritsScale (this Inherit mode) {
  401. return mode == Inherit.Normal || mode == Inherit.NoRotationOrReflection;
  402. }
  403. #endregion
  404. }
  405. }