From 21728b312948bb57dadeb3ba50ad318368342279 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 28 Dec 2018 11:38:00 +0000 Subject: [PATCH] some retouchs on animationset code --- .../Scenes/Animation/AnimationSet.cs | 36 +++++++++++-------- .../Scenes/Animation/ScenePresenceAnimator.cs | 3 +- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 4d350ddc55..43c9288aee 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -182,13 +182,14 @@ namespace OpenSim.Region.Framework.Scenes.Animation { lock (m_animations) { - int defaultSize = 0; + int j = 0; if (m_defaultAnimation.AnimID != UUID.Zero) - defaultSize++; + ++j; - animIDs = new UUID[m_animations.Count + defaultSize]; - sequenceNums = new int[m_animations.Count + defaultSize]; - objectIDs = new UUID[m_animations.Count + defaultSize]; + int defaultSize = m_animations.Count + j; + animIDs = new UUID[defaultSize]; + sequenceNums = new int[defaultSize]; + objectIDs = new UUID[defaultSize]; if (m_defaultAnimation.AnimID != UUID.Zero) { @@ -197,35 +198,40 @@ namespace OpenSim.Region.Framework.Scenes.Animation objectIDs[0] = m_defaultAnimation.ObjectID; } - for (int i = 0; i < m_animations.Count; ++i) + for (int i = 0; i < m_animations.Count; ++i,++j) { - animIDs[i + defaultSize] = m_animations[i].AnimID; - sequenceNums[i + defaultSize] = m_animations[i].SequenceNum; - objectIDs[i + defaultSize] = m_animations[i].ObjectID; + animIDs[j] = m_animations[i].AnimID; + sequenceNums[j] = m_animations[i].SequenceNum; + objectIDs[j] = m_animations[i].ObjectID; } } } public OpenSim.Framework.Animation[] ToArray() { - OpenSim.Framework.Animation[] theArray = new OpenSim.Framework.Animation[m_animations.Count]; - uint i = 0; + OpenSim.Framework.Animation[] theArray = null; try { - foreach (OpenSim.Framework.Animation anim in m_animations) - theArray[i++] = anim; + theArray = m_animations.ToArray(); } catch { - /* S%^t happens. Ignore. */ + return new OpenSim.Framework.Animation[0]; } + return theArray; } - public void FromArray(OpenSim.Framework.Animation[] theArray) + public int FromArray(OpenSim.Framework.Animation[] theArray) { + int ret = 0; foreach (OpenSim.Framework.Animation anim in theArray) + { m_animations.Add(anim); + if(anim.SequenceNum > ret) + ret = anim.SequenceNum; + } + return ret; } // Create representation of this AnimationSet as an OSDArray. diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 5c33f1272e..f564b2a768 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -237,8 +237,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation if (anim == "SIT" || anim == "SITGROUND") anim = m_scenePresence.sitAnimation; - if (m_animations.TrySetDefaultAnimation( - anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) + if (m_animations.TrySetDefaultAnimation(anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) { // m_log.DebugFormat( // "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}",