diff options
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 67 |
1 files changed, 18 insertions, 49 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b67b83a..b526fe9 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -639,6 +639,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
639 | // Get the current list of updates and clear the list before iterating | 639 | // Get the current list of updates and clear the list before iterating |
640 | lock (m_updateLock) | 640 | lock (m_updateLock) |
641 | { | 641 | { |
642 | if(m_updateList.Count == 0) | ||
643 | return; | ||
644 | |||
642 | updates = m_updateList; | 645 | updates = m_updateList; |
643 | m_updateList = new Dictionary<UUID, SceneObjectGroup>(); | 646 | m_updateList = new Dictionary<UUID, SceneObjectGroup>(); |
644 | } | 647 | } |
@@ -728,19 +731,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
728 | ScenePresence oldref; | 731 | ScenePresence oldref; |
729 | if (m_scenePresenceMap.TryGetValue(id, out oldref)) | 732 | if (m_scenePresenceMap.TryGetValue(id, out oldref)) |
730 | { | 733 | { |
731 | // Remember the old presence reference from the dictionary | ||
732 | uint oldLocalID = oldref.LocalId; | 734 | uint oldLocalID = oldref.LocalId; |
733 | // Replace the presence reference in the dictionary with the new value | ||
734 | m_scenePresenceMap[id] = presence; | ||
735 | if (localid != oldLocalID) | 735 | if (localid != oldLocalID) |
736 | m_scenePresenceLocalIDMap.Remove(oldLocalID); | 736 | m_scenePresenceLocalIDMap.Remove(oldLocalID); |
737 | m_scenePresenceLocalIDMap[localid] = presence; | ||
738 | } | ||
739 | else | ||
740 | { | ||
741 | m_scenePresenceMap[id] = presence; | ||
742 | m_scenePresenceLocalIDMap[localid] = presence; | ||
743 | } | 737 | } |
738 | m_scenePresenceMap[id] = presence; | ||
739 | m_scenePresenceLocalIDMap[localid] = presence; | ||
744 | m_scenePresenceList = null; | 740 | m_scenePresenceList = null; |
745 | } | 741 | } |
746 | finally | 742 | finally |
@@ -748,7 +744,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
748 | if(entered) | 744 | if(entered) |
749 | m_scenePresencesLock.ExitWriteLock(); | 745 | m_scenePresencesLock.ExitWriteLock(); |
750 | } | 746 | } |
751 | |||
752 | return presence; | 747 | return presence; |
753 | } | 748 | } |
754 | 749 | ||
@@ -1163,8 +1158,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1163 | { | 1158 | { |
1164 | EntityBase[] entities = Entities.GetEntities(); | 1159 | EntityBase[] entities = Entities.GetEntities(); |
1165 | List<SceneObjectGroup> ret = new List<SceneObjectGroup>(256); | 1160 | List<SceneObjectGroup> ret = new List<SceneObjectGroup>(256); |
1166 | int len = entities.Length; | 1161 | |
1167 | for (int i = 0; i < len; ++i) | 1162 | for (int i = 0; i < entities.Length; ++i) |
1168 | { | 1163 | { |
1169 | if(entities[i] is SceneObjectGroup) | 1164 | if(entities[i] is SceneObjectGroup) |
1170 | ret.Add((SceneObjectGroup)entities[i]); | 1165 | ret.Add((SceneObjectGroup)entities[i]); |
@@ -1207,8 +1202,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1207 | { | 1202 | { |
1208 | EntityBase entity = null; | 1203 | EntityBase entity = null; |
1209 | EntityBase[] entities = Entities.GetEntities(); | 1204 | EntityBase[] entities = Entities.GetEntities(); |
1210 | int len = entities.Length; | 1205 | for (int i = 0; i < entities.Length; ++i) |
1211 | for (int i = 0; i < len; ++i) | ||
1212 | { | 1206 | { |
1213 | entity = entities[i]; | 1207 | entity = entities[i]; |
1214 | if (entity is SceneObjectGroup && entity.Name == name) | 1208 | if (entity is SceneObjectGroup && entity.Name == name) |
@@ -1289,9 +1283,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1289 | protected internal SceneObjectPart GetSceneObjectPart(string name) | 1283 | protected internal SceneObjectPart GetSceneObjectPart(string name) |
1290 | { | 1284 | { |
1291 | SceneObjectPart[] parts = GetPartsArray(); | 1285 | SceneObjectPart[] parts = GetPartsArray(); |
1292 | int len = parts.Length; | ||
1293 | SceneObjectPart sop; | 1286 | SceneObjectPart sop; |
1294 | for (int i = 0; i < len; ++i) | 1287 | for (int i = 0; i < parts.Length; ++i) |
1295 | { | 1288 | { |
1296 | sop = parts[i]; | 1289 | sop = parts[i]; |
1297 | if (sop.ParentGroup == null || sop.ParentGroup.IsDeleted) | 1290 | if (sop.ParentGroup == null || sop.ParentGroup.IsDeleted) |
@@ -1356,9 +1349,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1356 | protected internal void ForEachSOG(Action<SceneObjectGroup> action) | 1349 | protected internal void ForEachSOG(Action<SceneObjectGroup> action) |
1357 | { | 1350 | { |
1358 | EntityBase[] entities = Entities.GetEntities(); | 1351 | EntityBase[] entities = Entities.GetEntities(); |
1359 | int len = entities.Length; | ||
1360 | EntityBase entity; | 1352 | EntityBase entity; |
1361 | for (int i = 0; i < len; ++i) | 1353 | for (int i = 0; i < entities.Length; ++i) |
1362 | { | 1354 | { |
1363 | entity = entities[i]; | 1355 | entity = entities[i]; |
1364 | if (entity is SceneObjectGroup) | 1356 | if (entity is SceneObjectGroup) |
@@ -1790,7 +1782,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1790 | { | 1782 | { |
1791 | if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) | 1783 | if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) |
1792 | { | 1784 | { |
1793 | SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); | 1785 | SceneObjectPart part = group.GetPart(primLocalID); |
1794 | if (part != null) | 1786 | if (part != null) |
1795 | { | 1787 | { |
1796 | part.ClickAction = Convert.ToByte(clickAction); | 1788 | part.ClickAction = Convert.ToByte(clickAction); |
@@ -1807,7 +1799,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1807 | { | 1799 | { |
1808 | if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) | 1800 | if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) |
1809 | { | 1801 | { |
1810 | SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); | 1802 | SceneObjectPart part = group.GetPart(primLocalID); |
1811 | if (part != null) | 1803 | if (part != null) |
1812 | { | 1804 | { |
1813 | part.Material = Convert.ToByte(material); | 1805 | part.Material = Convert.ToByte(material); |
@@ -1963,23 +1955,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1963 | /// <param name="prims"></param> | 1955 | /// <param name="prims"></param> |
1964 | protected internal void DelinkObjects(List<SceneObjectPart> prims) | 1956 | protected internal void DelinkObjects(List<SceneObjectPart> prims) |
1965 | { | 1957 | { |
1958 | List<SceneObjectPart> childParts = new List<SceneObjectPart>(); | ||
1959 | List<SceneObjectPart> rootParts = new List<SceneObjectPart>(); | ||
1960 | List<SceneObjectGroup> affectedGroups = new List<SceneObjectGroup>(); | ||
1961 | // Look them all up in one go, since that is comparatively expensive | ||
1962 | // | ||
1966 | Monitor.Enter(m_linkLock); | 1963 | Monitor.Enter(m_linkLock); |
1967 | try | 1964 | try |
1968 | { | 1965 | { |
1969 | List<SceneObjectPart> childParts = new List<SceneObjectPart>(); | ||
1970 | List<SceneObjectPart> rootParts = new List<SceneObjectPart>(); | ||
1971 | List<SceneObjectGroup> affectedGroups = new List<SceneObjectGroup>(); | ||
1972 | // Look them all up in one go, since that is comparatively expensive | ||
1973 | // | ||
1974 | foreach (SceneObjectPart part in prims) | 1966 | foreach (SceneObjectPart part in prims) |
1975 | { | 1967 | { |
1976 | if(part == null) | 1968 | if(part == null) |
1977 | continue; | 1969 | continue; |
1978 | SceneObjectGroup parentSOG = part.ParentGroup; | 1970 | SceneObjectGroup parentSOG = part.ParentGroup; |
1979 | if(parentSOG == null || | 1971 | if(parentSOG == null || parentSOG.IsDeleted || parentSOG.inTransit || parentSOG.PrimCount == 1) |
1980 | parentSOG.IsDeleted || | ||
1981 | parentSOG.inTransit || | ||
1982 | parentSOG.PrimCount == 1) | ||
1983 | continue; | 1972 | continue; |
1984 | 1973 | ||
1985 | if (!affectedGroups.Contains(parentSOG)) | 1974 | if (!affectedGroups.Contains(parentSOG)) |
@@ -2164,7 +2153,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2164 | } | 2153 | } |
2165 | } | 2154 | } |
2166 | 2155 | ||
2167 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() | ||
2168 | bool entered = false; | 2156 | bool entered = false; |
2169 | try | 2157 | try |
2170 | { | 2158 | { |
@@ -2194,9 +2182,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2194 | m_scenePartsLock.ExitWriteLock(); | 2182 | m_scenePartsLock.ExitWriteLock(); |
2195 | } | 2183 | } |
2196 | 2184 | ||
2197 | |||
2198 | // PROBABLE END OF FIXME | ||
2199 | |||
2200 | copy.IsSelected = createSelected; | 2185 | copy.IsSelected = createSelected; |
2201 | 2186 | ||
2202 | if (rot != Quaternion.Identity) | 2187 | if (rot != Quaternion.Identity) |
@@ -2221,23 +2206,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2221 | return null; | 2206 | return null; |
2222 | } | 2207 | } |
2223 | 2208 | ||
2224 | /// Calculates the distance between two Vector3s | ||
2225 | /// </summary> | ||
2226 | /// <param name="v1"></param> | ||
2227 | /// <param name="v2"></param> | ||
2228 | /// <returns></returns> | ||
2229 | protected internal float Vector3Distance(Vector3 v1, Vector3 v2) | ||
2230 | { | ||
2231 | // We don't really need the double floating point precision... | ||
2232 | // so casting it to a single | ||
2233 | |||
2234 | return | ||
2235 | (float) | ||
2236 | Math.Sqrt((v1.X - v2.X) * (v1.X - v2.X) + (v1.Y - v2.Y) * (v1.Y - v2.Y) + (v1.Z - v2.Z) * (v1.Z - v2.Z)); | ||
2237 | } | ||
2238 | |||
2239 | #endregion | 2209 | #endregion |
2240 | 2210 | ||
2241 | |||
2242 | } | 2211 | } |
2243 | } | 2212 | } |