diff --git a/OpenSim/Region/Framework/Scenes/EntityUpdates.cs b/OpenSim/Region/Framework/Scenes/EntityUpdates.cs index fe42e1af2e..64f2dbf916 100644 --- a/OpenSim/Region/Framework/Scenes/EntityUpdates.cs +++ b/OpenSim/Region/Framework/Scenes/EntityUpdates.cs @@ -46,30 +46,17 @@ namespace OpenSim.Region.Framework.Scenes NoObject = unchecked((byte)~Object) } - public class EntityUpdate : IComparable + public class EntityUpdate { - // for priority queue public int PriorityQueue; public int PriorityQueueIndex; - private ulong m_entryorder; + public ulong EntryOrder; private ISceneEntity m_entity; private PrimUpdateFlags m_flags; public ObjectPropertyUpdateFlags m_propsFlags; - public ulong EntryOrder - { - get - { - return m_entryorder; - } - set - { - m_entryorder = value; - } - } - public ObjectPropertyUpdateFlags PropsFlags { get @@ -100,6 +87,7 @@ namespace OpenSim.Region.Framework.Scenes set { m_flags = value; } } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] public void Update(int pqueue, ulong entry) { if ((m_flags & PrimUpdateFlags.CancelKill) != 0) @@ -111,35 +99,12 @@ namespace OpenSim.Region.Framework.Scenes } PriorityQueue = pqueue; - m_entryorder = entry; - } - - public void Update(EntityUpdate oldupdate, int pqueue, ulong entry) - { - // we are on the new one - m_propsFlags |= oldupdate.PropsFlags; - - PrimUpdateFlags updateFlags = oldupdate.Flags; - if ((m_flags & PrimUpdateFlags.UpdateProbe) != 0) - updateFlags &= ~PrimUpdateFlags.UpdateProbe; - - if ((m_flags & PrimUpdateFlags.CancelKill) != 0) - { - if ((m_flags & PrimUpdateFlags.UpdateProbe) != 0) - m_flags = PrimUpdateFlags.UpdateProbe; - else - m_flags = PrimUpdateFlags.FullUpdatewithAnim; - } - else - m_flags |= updateFlags; - - PriorityQueue = pqueue; - m_entryorder = entry; + EntryOrder = entry; } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] public void UpdateFromNew(EntityUpdate newupdate, int pqueue) { - // we are on the new one m_propsFlags |= newupdate.PropsFlags; PrimUpdateFlags newFlags = newupdate.Flags; @@ -159,6 +124,7 @@ namespace OpenSim.Region.Framework.Scenes PriorityQueue = pqueue; } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] public void Free() { m_entity = null; @@ -186,14 +152,7 @@ namespace OpenSim.Region.Framework.Scenes public override string ToString() { - return String.Format("[{0},{1},{2}]", PriorityQueue, m_entryorder, m_entity.LocalId); - } - - public int CompareTo(EntityUpdate other) - { - // I'm assuming that the root part of an SOG is added to the update queue - // before the component parts - return Comparer.Default.Compare(this.EntryOrder, other.EntryOrder); + return String.Format("[{0},{1},{2}]", PriorityQueue, EntryOrder, m_entity.LocalId); } } diff --git a/OpenSim/Region/Framework/Scenes/PriorityQueue.cs b/OpenSim/Region/Framework/Scenes/PriorityQueue.cs index 40d75ab1f6..c4814396da 100644 --- a/OpenSim/Region/Framework/Scenes/PriorityQueue.cs +++ b/OpenSim/Region/Framework/Scenes/PriorityQueue.cs @@ -291,28 +291,26 @@ namespace OpenSim.Region.Framework.Scenes public int Count { get { return m_size; } } - [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] - private void Set(EntityUpdate item, int index) - { - m_items[index] = item; - item.PriorityQueueIndex = index; - } - private bool BubbleUp(int index) { + EntityUpdate tmp; EntityUpdate item = m_items[index]; + ulong itemEntryOrder = item.EntryOrder; int current, parent; for (current = index, parent = (current - 1) / 2; - (current > 0) && m_items[parent].EntryOrder > item.EntryOrder; + (current > 0) && m_items[parent].EntryOrder > itemEntryOrder; current = parent, parent = (current - 1) / 2) { - Set(m_items[parent], current); + tmp = m_items[parent]; + tmp.PriorityQueueIndex = current; + m_items[current] = tmp; } if (current != index) { - Set(item, current); + item.PriorityQueueIndex = current; + m_items[current] = item; return true; } return false; @@ -323,23 +321,42 @@ namespace OpenSim.Region.Framework.Scenes if(m_size < 2) return; + EntityUpdate childItem; + EntityUpdate childItemR; EntityUpdate item = m_items[index]; + + ulong itemEntryOrder = item.EntryOrder; int current; int child; + int childlimit = m_size - 1; for (current = index, child = (2 * current) + 1; current < m_size / 2; current = child, child = (2 * current) + 1) { - if ((child < m_size - 1) && m_items[child].EntryOrder > m_items[child + 1].EntryOrder) - ++child; - if (m_items[child].EntryOrder >= item.EntryOrder) + childItem = m_items[child]; + if (child < childlimit) + { + childItemR = m_items[child + 1]; + + if(childItem.EntryOrder > childItemR.EntryOrder) + { + childItem = childItemR; + ++child; + } + } + if (childItem.EntryOrder >= itemEntryOrder) break; - Set(m_items[child], current); + + childItem.PriorityQueueIndex = current; + m_items[current] = childItem; } if (current != index) - Set(item, current); + { + item.PriorityQueueIndex = current; + m_items[current] = item; + } } public void Add(EntityUpdate value) @@ -352,7 +369,9 @@ namespace OpenSim.Region.Framework.Scenes Array.Resize(ref m_items, newcapacity); } - Set(value, m_size); + value.PriorityQueueIndex = m_size; + m_items[m_size] = value; + BubbleUp(m_size); ++m_size; } @@ -376,7 +395,10 @@ namespace OpenSim.Region.Framework.Scenes { if (index != m_size) { - Set(m_items[m_size], index); + EntityUpdate tmp = m_items[m_size]; + tmp.PriorityQueueIndex = index; + m_items[index] = tmp; + m_items[m_size] = null; if (!BubbleUp(index)) BubbleDown(index); @@ -395,9 +417,12 @@ namespace OpenSim.Region.Framework.Scenes --m_size; if (m_size > 0) { - Set(m_items[m_size], 0); - m_items[m_size] = null; - BubbleDown(0); + EntityUpdate tmp = m_items[m_size]; + tmp.PriorityQueueIndex = 0; + m_items[0] = tmp; + m_items[m_size] = null; + + BubbleDown(0); } else if (m_items.Length > 4 * minCapacity) m_items = new EntityUpdate[minCapacity];