PathConstraint.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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 System;
  30. namespace Spine {
  31. using Physics = Skeleton.Physics;
  32. /// <summary>
  33. /// <para>
  34. /// Stores the current pose for a path constraint. A path constraint adjusts the rotation, translation, and scale of the
  35. /// constrained bones so they follow a <see cref="PathAttachment"/>.</para>
  36. /// <para>
  37. /// See <a href="http://esotericsoftware.com/spine-path-constraints">Path constraints</a> in the Spine User Guide.</para>
  38. /// </summary>
  39. public class PathConstraint : IUpdatable {
  40. const int NONE = -1, BEFORE = -2, AFTER = -3;
  41. const float Epsilon = 0.00001f;
  42. internal readonly PathConstraintData data;
  43. internal readonly ExposedList<Bone> bones;
  44. internal Slot target;
  45. internal float position, spacing, mixRotate, mixX, mixY;
  46. internal bool active;
  47. internal readonly ExposedList<float> spaces = new ExposedList<float>(), positions = new ExposedList<float>();
  48. internal readonly ExposedList<float> world = new ExposedList<float>(), curves = new ExposedList<float>(), lengths = new ExposedList<float>();
  49. internal readonly float[] segments = new float[10];
  50. public PathConstraint (PathConstraintData data, Skeleton skeleton) {
  51. if (data == null) throw new ArgumentNullException("data", "data cannot be null.");
  52. if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
  53. this.data = data;
  54. bones = new ExposedList<Bone>(data.Bones.Count);
  55. foreach (BoneData boneData in data.bones)
  56. bones.Add(skeleton.bones.Items[boneData.index]);
  57. target = skeleton.slots.Items[data.target.index];
  58. position = data.position;
  59. spacing = data.spacing;
  60. mixRotate = data.mixRotate;
  61. mixX = data.mixX;
  62. mixY = data.mixY;
  63. }
  64. /// <summary>Copy constructor.</summary>
  65. public PathConstraint (PathConstraint constraint, Skeleton skeleton)
  66. : this(constraint.data, skeleton) {
  67. position = constraint.position;
  68. spacing = constraint.spacing;
  69. mixRotate = constraint.mixRotate;
  70. mixX = constraint.mixX;
  71. mixY = constraint.mixY;
  72. }
  73. public static void ArraysFill (float[] a, int fromIndex, int toIndex, float val) {
  74. for (int i = fromIndex; i < toIndex; i++)
  75. a[i] = val;
  76. }
  77. public void SetToSetupPose () {
  78. PathConstraintData data = this.data;
  79. position = data.position;
  80. spacing = data.spacing;
  81. mixRotate = data.mixRotate;
  82. mixX = data.mixX;
  83. mixY = data.mixY;
  84. }
  85. public void Update (Physics physics) {
  86. PathAttachment attachment = target.Attachment as PathAttachment;
  87. if (attachment == null) return;
  88. float mixRotate = this.mixRotate, mixX = this.mixX, mixY = this.mixY;
  89. if (mixRotate == 0 && mixX == 0 && mixY == 0) return;
  90. PathConstraintData data = this.data;
  91. bool tangents = data.rotateMode == RotateMode.Tangent, scale = data.rotateMode == RotateMode.ChainScale;
  92. int boneCount = this.bones.Count, spacesCount = tangents ? boneCount : boneCount + 1;
  93. Bone[] bonesItems = this.bones.Items;
  94. float[] spaces = this.spaces.Resize(spacesCount).Items, lengths = scale ? this.lengths.Resize(boneCount).Items : null;
  95. float spacing = this.spacing;
  96. switch (data.spacingMode) {
  97. case SpacingMode.Percent:
  98. if (scale) {
  99. for (int i = 0, n = spacesCount - 1; i < n; i++) {
  100. Bone bone = bonesItems[i];
  101. float setupLength = bone.data.length;
  102. float x = setupLength * bone.a, y = setupLength * bone.c;
  103. lengths[i] = (float)Math.Sqrt(x * x + y * y);
  104. }
  105. }
  106. ArraysFill(spaces, 1, spacesCount, spacing);
  107. break;
  108. case SpacingMode.Proportional: {
  109. float sum = 0;
  110. for (int i = 0, n = spacesCount - 1; i < n;) {
  111. Bone bone = bonesItems[i];
  112. float setupLength = bone.data.length;
  113. if (setupLength < PathConstraint.Epsilon) {
  114. if (scale) lengths[i] = 0;
  115. spaces[++i] = spacing;
  116. } else {
  117. float x = setupLength * bone.a, y = setupLength * bone.c;
  118. float length = (float)Math.Sqrt(x * x + y * y);
  119. if (scale) lengths[i] = length;
  120. spaces[++i] = length;
  121. sum += length;
  122. }
  123. }
  124. if (sum > 0) {
  125. sum = spacesCount / sum * spacing;
  126. for (int i = 1; i < spacesCount; i++)
  127. spaces[i] *= sum;
  128. }
  129. break;
  130. }
  131. default: {
  132. bool lengthSpacing = data.spacingMode == SpacingMode.Length;
  133. for (int i = 0, n = spacesCount - 1; i < n;) {
  134. Bone bone = bonesItems[i];
  135. float setupLength = bone.data.length;
  136. if (setupLength < PathConstraint.Epsilon) {
  137. if (scale) lengths[i] = 0;
  138. spaces[++i] = spacing;
  139. } else {
  140. float x = setupLength * bone.a, y = setupLength * bone.c;
  141. float length = (float)Math.Sqrt(x * x + y * y);
  142. if (scale) lengths[i] = length;
  143. spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
  144. }
  145. }
  146. break;
  147. }
  148. }
  149. float[] positions = ComputeWorldPositions(attachment, spacesCount, tangents);
  150. float boneX = positions[0], boneY = positions[1], offsetRotation = data.offsetRotation;
  151. bool tip;
  152. if (offsetRotation == 0) {
  153. tip = data.rotateMode == RotateMode.Chain;
  154. } else {
  155. tip = false;
  156. Bone p = target.bone;
  157. offsetRotation *= p.a * p.d - p.b * p.c > 0 ? MathUtils.DegRad : -MathUtils.DegRad;
  158. }
  159. for (int i = 0, p = 3; i < boneCount; i++, p += 3) {
  160. Bone bone = bonesItems[i];
  161. bone.worldX += (boneX - bone.worldX) * mixX;
  162. bone.worldY += (boneY - bone.worldY) * mixY;
  163. float x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY;
  164. if (scale) {
  165. float length = lengths[i];
  166. if (length >= PathConstraint.Epsilon) {
  167. float s = ((float)Math.Sqrt(dx * dx + dy * dy) / length - 1) * mixRotate + 1;
  168. bone.a *= s;
  169. bone.c *= s;
  170. }
  171. }
  172. boneX = x;
  173. boneY = y;
  174. if (mixRotate > 0) {
  175. float a = bone.a, b = bone.b, c = bone.c, d = bone.d, r, cos, sin;
  176. if (tangents)
  177. r = positions[p - 1];
  178. else if (spaces[i + 1] < PathConstraint.Epsilon)
  179. r = positions[p + 2];
  180. else
  181. r = MathUtils.Atan2(dy, dx);
  182. r -= MathUtils.Atan2(c, a);
  183. if (tip) {
  184. cos = MathUtils.Cos(r);
  185. sin = MathUtils.Sin(r);
  186. float length = bone.data.length;
  187. boneX += (length * (cos * a - sin * c) - dx) * mixRotate;
  188. boneY += (length * (sin * a + cos * c) - dy) * mixRotate;
  189. } else
  190. r += offsetRotation;
  191. if (r > MathUtils.PI)
  192. r -= MathUtils.PI2;
  193. else if (r < -MathUtils.PI) //
  194. r += MathUtils.PI2;
  195. r *= mixRotate;
  196. cos = MathUtils.Cos(r);
  197. sin = MathUtils.Sin(r);
  198. bone.a = cos * a - sin * c;
  199. bone.b = cos * b - sin * d;
  200. bone.c = sin * a + cos * c;
  201. bone.d = sin * b + cos * d;
  202. }
  203. bone.UpdateAppliedTransform();
  204. }
  205. }
  206. float[] ComputeWorldPositions (PathAttachment path, int spacesCount, bool tangents) {
  207. Slot target = this.target;
  208. float position = this.position;
  209. float[] spaces = this.spaces.Items, output = this.positions.Resize(spacesCount * 3 + 2).Items, world;
  210. bool closed = path.Closed;
  211. int verticesLength = path.WorldVerticesLength, curveCount = verticesLength / 6, prevCurve = NONE;
  212. float pathLength, multiplier;
  213. if (!path.ConstantSpeed) {
  214. float[] lengths = path.Lengths;
  215. curveCount -= closed ? 1 : 2;
  216. pathLength = lengths[curveCount];
  217. if (data.positionMode == PositionMode.Percent) position *= pathLength;
  218. switch (data.spacingMode) {
  219. case SpacingMode.Percent:
  220. multiplier = pathLength;
  221. break;
  222. case SpacingMode.Proportional:
  223. multiplier = pathLength / spacesCount;
  224. break;
  225. default:
  226. multiplier = 1;
  227. break;
  228. }
  229. world = this.world.Resize(8).Items;
  230. for (int i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) {
  231. float space = spaces[i] * multiplier;
  232. position += space;
  233. float p = position;
  234. if (closed) {
  235. p %= pathLength;
  236. if (p < 0) p += pathLength;
  237. curve = 0;
  238. } else if (p < 0) {
  239. if (prevCurve != BEFORE) {
  240. prevCurve = BEFORE;
  241. path.ComputeWorldVertices(target, 2, 4, world, 0, 2);
  242. }
  243. AddBeforePosition(p, world, 0, output, o);
  244. continue;
  245. } else if (p > pathLength) {
  246. if (prevCurve != AFTER) {
  247. prevCurve = AFTER;
  248. path.ComputeWorldVertices(target, verticesLength - 6, 4, world, 0, 2);
  249. }
  250. AddAfterPosition(p - pathLength, world, 0, output, o);
  251. continue;
  252. }
  253. // Determine curve containing position.
  254. for (; ; curve++) {
  255. float length = lengths[curve];
  256. if (p > length) continue;
  257. if (curve == 0)
  258. p /= length;
  259. else {
  260. float prev = lengths[curve - 1];
  261. p = (p - prev) / (length - prev);
  262. }
  263. break;
  264. }
  265. if (curve != prevCurve) {
  266. prevCurve = curve;
  267. if (closed && curve == curveCount) {
  268. path.ComputeWorldVertices(target, verticesLength - 4, 4, world, 0, 2);
  269. path.ComputeWorldVertices(target, 0, 4, world, 4, 2);
  270. } else
  271. path.ComputeWorldVertices(target, curve * 6 + 2, 8, world, 0, 2);
  272. }
  273. AddCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], output, o,
  274. tangents || (i > 0 && space < PathConstraint.Epsilon));
  275. }
  276. return output;
  277. }
  278. // World vertices.
  279. if (closed) {
  280. verticesLength += 2;
  281. world = this.world.Resize(verticesLength).Items;
  282. path.ComputeWorldVertices(target, 2, verticesLength - 4, world, 0, 2);
  283. path.ComputeWorldVertices(target, 0, 2, world, verticesLength - 4, 2);
  284. world[verticesLength - 2] = world[0];
  285. world[verticesLength - 1] = world[1];
  286. } else {
  287. curveCount--;
  288. verticesLength -= 4;
  289. world = this.world.Resize(verticesLength).Items;
  290. path.ComputeWorldVertices(target, 2, verticesLength, world, 0, 2);
  291. }
  292. // Curve lengths.
  293. float[] curves = this.curves.Resize(curveCount).Items;
  294. pathLength = 0;
  295. float x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0;
  296. float tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy;
  297. for (int i = 0, w = 2; i < curveCount; i++, w += 6) {
  298. cx1 = world[w];
  299. cy1 = world[w + 1];
  300. cx2 = world[w + 2];
  301. cy2 = world[w + 3];
  302. x2 = world[w + 4];
  303. y2 = world[w + 5];
  304. tmpx = (x1 - cx1 * 2 + cx2) * 0.1875f;
  305. tmpy = (y1 - cy1 * 2 + cy2) * 0.1875f;
  306. dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375f;
  307. dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375f;
  308. ddfx = tmpx * 2 + dddfx;
  309. ddfy = tmpy * 2 + dddfy;
  310. dfx = (cx1 - x1) * 0.75f + tmpx + dddfx * 0.16666667f;
  311. dfy = (cy1 - y1) * 0.75f + tmpy + dddfy * 0.16666667f;
  312. pathLength += (float)Math.Sqrt(dfx * dfx + dfy * dfy);
  313. dfx += ddfx;
  314. dfy += ddfy;
  315. ddfx += dddfx;
  316. ddfy += dddfy;
  317. pathLength += (float)Math.Sqrt(dfx * dfx + dfy * dfy);
  318. dfx += ddfx;
  319. dfy += ddfy;
  320. pathLength += (float)Math.Sqrt(dfx * dfx + dfy * dfy);
  321. dfx += ddfx + dddfx;
  322. dfy += ddfy + dddfy;
  323. pathLength += (float)Math.Sqrt(dfx * dfx + dfy * dfy);
  324. curves[i] = pathLength;
  325. x1 = x2;
  326. y1 = y2;
  327. }
  328. if (data.positionMode == PositionMode.Percent) position *= pathLength;
  329. switch (data.spacingMode) {
  330. case SpacingMode.Percent:
  331. multiplier = pathLength;
  332. break;
  333. case SpacingMode.Proportional:
  334. multiplier = pathLength / spacesCount;
  335. break;
  336. default:
  337. multiplier = 1;
  338. break;
  339. }
  340. float[] segments = this.segments;
  341. float curveLength = 0;
  342. for (int i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) {
  343. float space = spaces[i] * multiplier;
  344. position += space;
  345. float p = position;
  346. if (closed) {
  347. p %= pathLength;
  348. if (p < 0) p += pathLength;
  349. curve = 0;
  350. } else if (p < 0) {
  351. AddBeforePosition(p, world, 0, output, o);
  352. continue;
  353. } else if (p > pathLength) {
  354. AddAfterPosition(p - pathLength, world, verticesLength - 4, output, o);
  355. continue;
  356. }
  357. // Determine curve containing position.
  358. for (; ; curve++) {
  359. float length = curves[curve];
  360. if (p > length) continue;
  361. if (curve == 0)
  362. p /= length;
  363. else {
  364. float prev = curves[curve - 1];
  365. p = (p - prev) / (length - prev);
  366. }
  367. break;
  368. }
  369. // Curve segment lengths.
  370. if (curve != prevCurve) {
  371. prevCurve = curve;
  372. int ii = curve * 6;
  373. x1 = world[ii];
  374. y1 = world[ii + 1];
  375. cx1 = world[ii + 2];
  376. cy1 = world[ii + 3];
  377. cx2 = world[ii + 4];
  378. cy2 = world[ii + 5];
  379. x2 = world[ii + 6];
  380. y2 = world[ii + 7];
  381. tmpx = (x1 - cx1 * 2 + cx2) * 0.03f;
  382. tmpy = (y1 - cy1 * 2 + cy2) * 0.03f;
  383. dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006f;
  384. dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006f;
  385. ddfx = tmpx * 2 + dddfx;
  386. ddfy = tmpy * 2 + dddfy;
  387. dfx = (cx1 - x1) * 0.3f + tmpx + dddfx * 0.16666667f;
  388. dfy = (cy1 - y1) * 0.3f + tmpy + dddfy * 0.16666667f;
  389. curveLength = (float)Math.Sqrt(dfx * dfx + dfy * dfy);
  390. segments[0] = curveLength;
  391. for (ii = 1; ii < 8; ii++) {
  392. dfx += ddfx;
  393. dfy += ddfy;
  394. ddfx += dddfx;
  395. ddfy += dddfy;
  396. curveLength += (float)Math.Sqrt(dfx * dfx + dfy * dfy);
  397. segments[ii] = curveLength;
  398. }
  399. dfx += ddfx;
  400. dfy += ddfy;
  401. curveLength += (float)Math.Sqrt(dfx * dfx + dfy * dfy);
  402. segments[8] = curveLength;
  403. dfx += ddfx + dddfx;
  404. dfy += ddfy + dddfy;
  405. curveLength += (float)Math.Sqrt(dfx * dfx + dfy * dfy);
  406. segments[9] = curveLength;
  407. segment = 0;
  408. }
  409. // Weight by segment length.
  410. p *= curveLength;
  411. for (; ; segment++) {
  412. float length = segments[segment];
  413. if (p > length) continue;
  414. if (segment == 0)
  415. p /= length;
  416. else {
  417. float prev = segments[segment - 1];
  418. p = segment + (p - prev) / (length - prev);
  419. }
  420. break;
  421. }
  422. AddCurvePosition(p * 0.1f, x1, y1, cx1, cy1, cx2, cy2, x2, y2, output, o, tangents || (i > 0 && space < PathConstraint.Epsilon));
  423. }
  424. return output;
  425. }
  426. static void AddBeforePosition (float p, float[] temp, int i, float[] output, int o) {
  427. float x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = MathUtils.Atan2(dy, dx);
  428. output[o] = x1 + p * MathUtils.Cos(r);
  429. output[o + 1] = y1 + p * MathUtils.Sin(r);
  430. output[o + 2] = r;
  431. }
  432. static void AddAfterPosition (float p, float[] temp, int i, float[] output, int o) {
  433. float x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = MathUtils.Atan2(dy, dx);
  434. output[o] = x1 + p * MathUtils.Cos(r);
  435. output[o + 1] = y1 + p * MathUtils.Sin(r);
  436. output[o + 2] = r;
  437. }
  438. static void AddCurvePosition (float p, float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2, float y2,
  439. float[] output, int o, bool tangents) {
  440. if (p < PathConstraint.Epsilon || float.IsNaN(p)) {
  441. output[o] = x1;
  442. output[o + 1] = y1;
  443. output[o + 2] = (float)Math.Atan2(cy1 - y1, cx1 - x1);
  444. return;
  445. }
  446. float tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u;
  447. float ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p;
  448. float x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt;
  449. output[o] = x;
  450. output[o + 1] = y;
  451. if (tangents) {
  452. if (p < 0.001f)
  453. output[o + 2] = (float)Math.Atan2(cy1 - y1, cx1 - x1);
  454. else
  455. output[o + 2] = (float)Math.Atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
  456. }
  457. }
  458. /// <summary>The position along the path.</summary>
  459. public float Position { get { return position; } set { position = value; } }
  460. /// <summary>The spacing between bones.</summary>
  461. public float Spacing { get { return spacing; } set { spacing = value; } }
  462. /// <summary>A percentage (0-1) that controls the mix between the constrained and unconstrained rotations.</summary>
  463. public float MixRotate { get { return mixRotate; } set { mixRotate = value; } }
  464. /// <summary>A percentage (0-1) that controls the mix between the constrained and unconstrained translation X.</summary>
  465. public float MixX { get { return mixX; } set { mixX = value; } }
  466. /// <summary>A percentage (0-1) that controls the mix between the constrained and unconstrained translation Y.</summary>
  467. public float MixY { get { return mixY; } set { mixY = value; } }
  468. /// <summary>The bones that will be modified by this path constraint.</summary>
  469. public ExposedList<Bone> Bones { get { return bones; } }
  470. /// <summary>The slot whose path attachment will be used to constrained the bones.</summary>
  471. public Slot Target { get { return target; } set { target = value; } }
  472. public bool Active { get { return active; } }
  473. /// <summary>The path constraint's setup pose data.</summary>
  474. public PathConstraintData Data { get { return data; } }
  475. override public string ToString () {
  476. return data.name;
  477. }
  478. }
  479. }