KeyframeMotion.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Timers;
  29. using System.Collections;
  30. using System.Collections.Generic;
  31. using System.IO;
  32. using System.Diagnostics;
  33. using System.Reflection;
  34. using System.Threading;
  35. using OpenMetaverse;
  36. using OpenSim.Framework;
  37. using OpenSim.Region.Framework.Interfaces;
  38. using OpenSim.Region.Physics.Manager;
  39. using OpenSim.Region.Framework.Scenes.Serialization;
  40. using System.Runtime.Serialization.Formatters.Binary;
  41. using System.Runtime.Serialization;
  42. using Timer = System.Timers.Timer;
  43. using log4net;
  44. namespace OpenSim.Region.Framework.Scenes
  45. {
  46. public class KeyframeTimer
  47. {
  48. private static Dictionary<Scene, KeyframeTimer>m_timers =
  49. new Dictionary<Scene, KeyframeTimer>();
  50. private Timer m_timer;
  51. private Dictionary<KeyframeMotion, object> m_motions = new Dictionary<KeyframeMotion, object>();
  52. private object m_lockObject = new object();
  53. private object m_timerLock = new object();
  54. private const double m_tickDuration = 50.0;
  55. public double TickDuration
  56. {
  57. get { return m_tickDuration; }
  58. }
  59. public KeyframeTimer(Scene scene)
  60. {
  61. m_timer = new Timer();
  62. m_timer.Interval = TickDuration;
  63. m_timer.AutoReset = true;
  64. m_timer.Elapsed += OnTimer;
  65. m_timer.Start();
  66. }
  67. private void OnTimer(object sender, ElapsedEventArgs ea)
  68. {
  69. if (!Monitor.TryEnter(m_timerLock))
  70. return;
  71. try
  72. {
  73. List<KeyframeMotion> motions;
  74. lock (m_lockObject)
  75. {
  76. motions = new List<KeyframeMotion>(m_motions.Keys);
  77. }
  78. foreach (KeyframeMotion m in motions)
  79. {
  80. try
  81. {
  82. m.OnTimer(TickDuration);
  83. }
  84. catch (Exception)
  85. {
  86. // Don't stop processing
  87. }
  88. }
  89. }
  90. catch (Exception)
  91. {
  92. // Keep running no matter what
  93. }
  94. finally
  95. {
  96. Monitor.Exit(m_timerLock);
  97. }
  98. }
  99. public static void Add(KeyframeMotion motion)
  100. {
  101. KeyframeTimer timer;
  102. if (motion.Scene == null)
  103. return;
  104. lock (m_timers)
  105. {
  106. if (!m_timers.TryGetValue(motion.Scene, out timer))
  107. {
  108. timer = new KeyframeTimer(motion.Scene);
  109. m_timers[motion.Scene] = timer;
  110. }
  111. }
  112. lock (timer.m_lockObject)
  113. {
  114. timer.m_motions[motion] = null;
  115. }
  116. }
  117. public static void Remove(KeyframeMotion motion)
  118. {
  119. KeyframeTimer timer;
  120. if (motion.Scene == null)
  121. return;
  122. lock (m_timers)
  123. {
  124. if (!m_timers.TryGetValue(motion.Scene, out timer))
  125. {
  126. return;
  127. }
  128. }
  129. lock (timer.m_lockObject)
  130. {
  131. timer.m_motions.Remove(motion);
  132. }
  133. }
  134. }
  135. [Serializable]
  136. public class KeyframeMotion
  137. {
  138. // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  139. public enum PlayMode : int
  140. {
  141. Forward = 0,
  142. Reverse = 1,
  143. Loop = 2,
  144. PingPong = 3
  145. };
  146. [Flags]
  147. public enum DataFormat : int
  148. {
  149. Translation = 2,
  150. Rotation = 1
  151. }
  152. [Serializable]
  153. public struct Keyframe
  154. {
  155. public Vector3? Position;
  156. public Quaternion? Rotation;
  157. public Quaternion StartRotation;
  158. public int TimeMS;
  159. public int TimeTotal;
  160. public Vector3 AngularVelocity;
  161. };
  162. private Vector3 m_serializedPosition;
  163. private Vector3 m_basePosition;
  164. private Quaternion m_baseRotation;
  165. private Keyframe m_currentFrame;
  166. private List<Keyframe> m_frames = new List<Keyframe>();
  167. private Keyframe[] m_keyframes;
  168. // skip timer events.
  169. //timer.stop doesn't assure there aren't event threads still being fired
  170. [NonSerialized()]
  171. private bool m_timerStopped;
  172. [NonSerialized()]
  173. private bool m_isCrossing;
  174. [NonSerialized()]
  175. private bool m_waitingCrossing;
  176. // retry position for cross fail
  177. [NonSerialized()]
  178. private Vector3 m_nextPosition;
  179. [NonSerialized()]
  180. private SceneObjectGroup m_group;
  181. private PlayMode m_mode = PlayMode.Forward;
  182. private DataFormat m_data = DataFormat.Translation | DataFormat.Rotation;
  183. private bool m_running = false;
  184. [NonSerialized()]
  185. private bool m_selected = false;
  186. private int m_iterations = 0;
  187. private int m_skipLoops = 0;
  188. [NonSerialized()]
  189. private Scene m_scene;
  190. public Scene Scene
  191. {
  192. get { return m_scene; }
  193. }
  194. public DataFormat Data
  195. {
  196. get { return m_data; }
  197. }
  198. public bool Selected
  199. {
  200. set
  201. {
  202. if (m_group != null)
  203. {
  204. if (!value)
  205. {
  206. // Once we're let go, recompute positions
  207. if (m_selected)
  208. UpdateSceneObject(m_group);
  209. }
  210. else
  211. {
  212. // Save selection position in case we get moved
  213. if (!m_selected)
  214. {
  215. StopTimer();
  216. m_serializedPosition = m_group.AbsolutePosition;
  217. }
  218. }
  219. }
  220. m_isCrossing = false;
  221. m_waitingCrossing = false;
  222. m_selected = value;
  223. }
  224. }
  225. private void StartTimer()
  226. {
  227. KeyframeTimer.Add(this);
  228. m_timerStopped = false;
  229. }
  230. private void StopTimer()
  231. {
  232. m_timerStopped = true;
  233. KeyframeTimer.Remove(this);
  234. }
  235. public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
  236. {
  237. KeyframeMotion newMotion = null;
  238. try
  239. {
  240. MemoryStream ms = new MemoryStream(data);
  241. BinaryFormatter fmt = new BinaryFormatter();
  242. newMotion = (KeyframeMotion)fmt.Deserialize(ms);
  243. newMotion.m_group = grp;
  244. if (grp != null)
  245. {
  246. newMotion.m_scene = grp.Scene;
  247. if (grp.IsSelected)
  248. newMotion.m_selected = true;
  249. }
  250. newMotion.m_timerStopped = false;
  251. newMotion.m_running = true;
  252. newMotion.m_isCrossing = false;
  253. newMotion.m_waitingCrossing = false;
  254. }
  255. catch
  256. {
  257. newMotion = null;
  258. }
  259. return newMotion;
  260. }
  261. public void UpdateSceneObject(SceneObjectGroup grp)
  262. {
  263. m_isCrossing = false;
  264. m_waitingCrossing = false;
  265. StopTimer();
  266. if (grp == null)
  267. return;
  268. m_group = grp;
  269. m_scene = grp.Scene;
  270. Vector3 grppos = grp.AbsolutePosition;
  271. Vector3 offset = grppos - m_serializedPosition;
  272. // avoid doing it more than once
  273. // current this will happen draging a prim to other region
  274. m_serializedPosition = grppos;
  275. m_basePosition += offset;
  276. m_currentFrame.Position += offset;
  277. m_nextPosition += offset;
  278. for (int i = 0; i < m_frames.Count; i++)
  279. {
  280. Keyframe k = m_frames[i];
  281. k.Position += offset;
  282. m_frames[i]=k;
  283. }
  284. if (m_running)
  285. Start();
  286. }
  287. public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data)
  288. {
  289. m_mode = mode;
  290. m_data = data;
  291. m_group = grp;
  292. if (grp != null)
  293. {
  294. m_basePosition = grp.AbsolutePosition;
  295. m_baseRotation = grp.GroupRotation;
  296. m_scene = grp.Scene;
  297. }
  298. m_timerStopped = true;
  299. m_isCrossing = false;
  300. m_waitingCrossing = false;
  301. }
  302. public void SetKeyframes(Keyframe[] frames)
  303. {
  304. m_keyframes = frames;
  305. }
  306. public KeyframeMotion Copy(SceneObjectGroup newgrp)
  307. {
  308. StopTimer();
  309. KeyframeMotion newmotion = new KeyframeMotion(null, m_mode, m_data);
  310. newmotion.m_group = newgrp;
  311. newmotion.m_scene = newgrp.Scene;
  312. if (m_keyframes != null)
  313. {
  314. newmotion.m_keyframes = new Keyframe[m_keyframes.Length];
  315. m_keyframes.CopyTo(newmotion.m_keyframes, 0);
  316. }
  317. newmotion.m_frames = new List<Keyframe>(m_frames);
  318. newmotion.m_basePosition = m_basePosition;
  319. newmotion.m_baseRotation = m_baseRotation;
  320. if (m_selected)
  321. newmotion.m_serializedPosition = m_serializedPosition;
  322. else
  323. {
  324. if (m_group != null)
  325. newmotion.m_serializedPosition = m_group.AbsolutePosition;
  326. else
  327. newmotion.m_serializedPosition = m_serializedPosition;
  328. }
  329. newmotion.m_currentFrame = m_currentFrame;
  330. newmotion.m_iterations = m_iterations;
  331. newmotion.m_running = m_running;
  332. if (m_running && !m_waitingCrossing)
  333. StartTimer();
  334. return newmotion;
  335. }
  336. public void Delete()
  337. {
  338. m_running = false;
  339. StopTimer();
  340. m_isCrossing = false;
  341. m_waitingCrossing = false;
  342. m_frames.Clear();
  343. m_keyframes = null;
  344. }
  345. public void Start()
  346. {
  347. m_isCrossing = false;
  348. m_waitingCrossing = false;
  349. if (m_keyframes != null && m_group != null && m_keyframes.Length > 0)
  350. {
  351. StartTimer();
  352. m_running = true;
  353. }
  354. else
  355. {
  356. m_running = false;
  357. StopTimer();
  358. }
  359. }
  360. public void Stop()
  361. {
  362. m_running = false;
  363. m_isCrossing = false;
  364. m_waitingCrossing = false;
  365. StopTimer();
  366. m_basePosition = m_group.AbsolutePosition;
  367. m_baseRotation = m_group.GroupRotation;
  368. m_group.RootPart.Velocity = Vector3.Zero;
  369. m_group.RootPart.AngularVelocity = Vector3.Zero;
  370. m_group.SendGroupRootTerseUpdate();
  371. // m_group.RootPart.ScheduleTerseUpdate();
  372. m_frames.Clear();
  373. }
  374. public void Pause()
  375. {
  376. m_running = false;
  377. StopTimer();
  378. m_group.RootPart.Velocity = Vector3.Zero;
  379. m_group.RootPart.AngularVelocity = Vector3.Zero;
  380. m_group.SendGroupRootTerseUpdate();
  381. // m_group.RootPart.ScheduleTerseUpdate();
  382. }
  383. private void GetNextList()
  384. {
  385. m_frames.Clear();
  386. Vector3 pos = m_basePosition;
  387. Quaternion rot = m_baseRotation;
  388. if (m_mode == PlayMode.Loop || m_mode == PlayMode.PingPong || m_iterations == 0)
  389. {
  390. int direction = 1;
  391. if (m_mode == PlayMode.Reverse || ((m_mode == PlayMode.PingPong) && ((m_iterations & 1) != 0)))
  392. direction = -1;
  393. int start = 0;
  394. int end = m_keyframes.Length;
  395. if (direction < 0)
  396. {
  397. start = m_keyframes.Length - 1;
  398. end = -1;
  399. }
  400. for (int i = start; i != end ; i += direction)
  401. {
  402. Keyframe k = m_keyframes[i];
  403. if (k.Position.HasValue)
  404. {
  405. k.Position = (k.Position * direction);
  406. // k.Velocity = (Vector3)k.Position / (k.TimeMS / 1000.0f);
  407. k.Position += pos;
  408. }
  409. else
  410. {
  411. k.Position = pos;
  412. // k.Velocity = Vector3.Zero;
  413. }
  414. k.StartRotation = rot;
  415. if (k.Rotation.HasValue)
  416. {
  417. if (direction == -1)
  418. k.Rotation = Quaternion.Conjugate((Quaternion)k.Rotation);
  419. k.Rotation = rot * k.Rotation;
  420. }
  421. else
  422. {
  423. k.Rotation = rot;
  424. }
  425. /* ang vel not in use for now
  426. float angle = 0;
  427. float aa = k.StartRotation.X * k.StartRotation.X + k.StartRotation.Y * k.StartRotation.Y + k.StartRotation.Z * k.StartRotation.Z + k.StartRotation.W * k.StartRotation.W;
  428. float bb = ((Quaternion)k.Rotation).X * ((Quaternion)k.Rotation).X + ((Quaternion)k.Rotation).Y * ((Quaternion)k.Rotation).Y + ((Quaternion)k.Rotation).Z * ((Quaternion)k.Rotation).Z + ((Quaternion)k.Rotation).W * ((Quaternion)k.Rotation).W;
  429. float aa_bb = aa * bb;
  430. if (aa_bb == 0)
  431. {
  432. angle = 0;
  433. }
  434. else
  435. {
  436. float ab = k.StartRotation.X * ((Quaternion)k.Rotation).X +
  437. k.StartRotation.Y * ((Quaternion)k.Rotation).Y +
  438. k.StartRotation.Z * ((Quaternion)k.Rotation).Z +
  439. k.StartRotation.W * ((Quaternion)k.Rotation).W;
  440. float q = (ab * ab) / aa_bb;
  441. if (q > 1.0f)
  442. {
  443. angle = 0;
  444. }
  445. else
  446. {
  447. angle = (float)Math.Acos(2 * q - 1);
  448. }
  449. }
  450. k.AngularVelocity = (new Vector3(0, 0, 1) * (Quaternion)k.Rotation) * (angle / (k.TimeMS / 1000));
  451. */
  452. k.TimeTotal = k.TimeMS;
  453. m_frames.Add(k);
  454. pos = (Vector3)k.Position;
  455. rot = (Quaternion)k.Rotation;
  456. }
  457. m_basePosition = pos;
  458. m_baseRotation = rot;
  459. m_iterations++;
  460. }
  461. }
  462. public void OnTimer(double tickDuration)
  463. {
  464. if (m_skipLoops > 0)
  465. {
  466. m_skipLoops--;
  467. return;
  468. }
  469. if (m_timerStopped) // trap events still in air even after a timer.stop
  470. return;
  471. if (m_group == null)
  472. return;
  473. bool update = false;
  474. if (m_selected)
  475. {
  476. if (m_group.RootPart.Velocity != Vector3.Zero)
  477. {
  478. m_group.RootPart.Velocity = Vector3.Zero;
  479. m_group.SendGroupRootTerseUpdate();
  480. }
  481. return;
  482. }
  483. if (m_isCrossing)
  484. {
  485. // if crossing and timer running then cross failed
  486. // wait some time then
  487. // retry to set the position that evtually caused the outbound
  488. // if still outside region this will call startCrossing below
  489. m_isCrossing = false;
  490. m_group.AbsolutePosition = m_nextPosition;
  491. if (!m_isCrossing)
  492. {
  493. StopTimer();
  494. StartTimer();
  495. }
  496. return;
  497. }
  498. if (m_frames.Count == 0)
  499. {
  500. GetNextList();
  501. if (m_frames.Count == 0)
  502. {
  503. Stop();
  504. Scene scene = m_group.Scene;
  505. IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
  506. foreach (IScriptModule m in scriptModules)
  507. {
  508. if (m == null)
  509. continue;
  510. m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]);
  511. }
  512. return;
  513. }
  514. m_currentFrame = m_frames[0];
  515. m_currentFrame.TimeMS += (int)tickDuration;
  516. //force a update on a keyframe transition
  517. update = true;
  518. }
  519. m_currentFrame.TimeMS -= (int)tickDuration;
  520. // Do the frame processing
  521. double steps = (double)m_currentFrame.TimeMS / tickDuration;
  522. if (steps <= 0.0)
  523. {
  524. m_group.RootPart.Velocity = Vector3.Zero;
  525. m_group.RootPart.AngularVelocity = Vector3.Zero;
  526. m_nextPosition = (Vector3)m_currentFrame.Position;
  527. m_group.AbsolutePosition = m_nextPosition;
  528. // we are sending imediate updates, no doing force a extra terseUpdate
  529. // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
  530. m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation;
  531. m_frames.RemoveAt(0);
  532. if (m_frames.Count > 0)
  533. m_currentFrame = m_frames[0];
  534. update = true;
  535. }
  536. else
  537. {
  538. float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal;
  539. Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition;
  540. Vector3 motionThisFrame = v / (float)steps;
  541. v = v * 1000 / m_currentFrame.TimeMS;
  542. if (Vector3.Mag(motionThisFrame) >= 0.05f)
  543. {
  544. // m_group.AbsolutePosition += motionThisFrame;
  545. m_nextPosition = m_group.AbsolutePosition + motionThisFrame;
  546. m_group.AbsolutePosition = m_nextPosition;
  547. //m_group.RootPart.Velocity = v;
  548. update = true;
  549. }
  550. if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation)
  551. {
  552. Quaternion current = m_group.GroupRotation;
  553. Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete);
  554. step.Normalize();
  555. /* use simpler change detection
  556. * float angle = 0;
  557. float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W;
  558. float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W;
  559. float aa_bb = aa * bb;
  560. if (aa_bb == 0)
  561. {
  562. angle = 0;
  563. }
  564. else
  565. {
  566. float ab = current.X * step.X +
  567. current.Y * step.Y +
  568. current.Z * step.Z +
  569. current.W * step.W;
  570. float q = (ab * ab) / aa_bb;
  571. if (q > 1.0f)
  572. {
  573. angle = 0;
  574. }
  575. else
  576. {
  577. angle = (float)Math.Acos(2 * q - 1);
  578. }
  579. }
  580. if (angle > 0.01f)
  581. */
  582. if(Math.Abs(step.X - current.X) > 0.001f
  583. || Math.Abs(step.Y - current.Y) > 0.001f
  584. || Math.Abs(step.Z - current.Z) > 0.001f)
  585. // assuming w is a dependente var
  586. {
  587. // m_group.UpdateGroupRotationR(step);
  588. m_group.RootPart.RotationOffset = step;
  589. //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
  590. update = true;
  591. }
  592. }
  593. }
  594. if (update)
  595. {
  596. m_group.SendGroupRootTerseUpdate();
  597. }
  598. }
  599. public Byte[] Serialize()
  600. {
  601. StopTimer();
  602. MemoryStream ms = new MemoryStream();
  603. BinaryFormatter fmt = new BinaryFormatter();
  604. SceneObjectGroup tmp = m_group;
  605. m_group = null;
  606. if (!m_selected && tmp != null)
  607. m_serializedPosition = tmp.AbsolutePosition;
  608. fmt.Serialize(ms, this);
  609. m_group = tmp;
  610. if (m_running && !m_waitingCrossing)
  611. StartTimer();
  612. return ms.ToArray();
  613. }
  614. public void StartCrossingCheck()
  615. {
  616. // timer will be restart by crossingFailure
  617. // or never since crossing worked and this
  618. // should be deleted
  619. StopTimer();
  620. m_isCrossing = true;
  621. m_waitingCrossing = true;
  622. // to remove / retune to smoth crossings
  623. if (m_group.RootPart.Velocity != Vector3.Zero)
  624. {
  625. m_group.RootPart.Velocity = Vector3.Zero;
  626. m_group.SendGroupRootTerseUpdate();
  627. // m_group.RootPart.ScheduleTerseUpdate();
  628. }
  629. }
  630. public void CrossingFailure()
  631. {
  632. m_waitingCrossing = false;
  633. if (m_group != null)
  634. {
  635. m_group.RootPart.Velocity = Vector3.Zero;
  636. m_group.SendGroupRootTerseUpdate();
  637. // m_group.RootPart.ScheduleTerseUpdate();
  638. if (m_running)
  639. {
  640. StopTimer();
  641. m_skipLoops = 1200; // 60 seconds
  642. StartTimer();
  643. }
  644. }
  645. }
  646. }
  647. }