aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-07-11 14:27:33 +0100
committerMelanie2012-07-11 14:27:33 +0100
commit89c9528e38b4e06a2af6231ced4ed733bbafa174 (patch)
treeaed380f4bc51d9102e593446762f476694b9d87c /OpenSim
parentMerge branch 'master' into careminster (diff)
parent remove expensive and leaked ( in Xengine at least) SayShout timer and (diff)
downloadopensim-SC-89c9528e38b4e06a2af6231ced4ed733bbafa174.zip
opensim-SC-89c9528e38b4e06a2af6231ced4ed733bbafa174.tar.gz
opensim-SC-89c9528e38b4e06a2af6231ced4ed733bbafa174.tar.bz2
opensim-SC-89c9528e38b4e06a2af6231ced4ed733bbafa174.tar.xz
Merge branch 'avination' into careminster
Conflicts: OpenSim/Data/MySQL/MySQLSimulationData.cs
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs19
-rw-r--r--OpenSim/Framework/LocklessQueue.cs11
-rw-r--r--OpenSim/Framework/MinHeap.cs12
-rw-r--r--OpenSim/Framework/Statistics/BaseStatsCollector.cs24
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs161
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs497
-rw-r--r--OpenSim/Region/Framework/Scenes/SOPVehicle.cs54
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs79
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs17
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs2
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs9
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs68
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs9
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs114
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs33
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs16
-rw-r--r--OpenSim/Server/Handlers/Map/MapGetServerConnector.cs15
19 files changed, 746 insertions, 400 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 31c80c1..29bd6b6 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -176,7 +176,8 @@ namespace OpenSim.Data.MySQL
176 "PassCollisions, " + 176 "PassCollisions, " +
177 "LinkNumber, MediaURL, KeyframeMotion, " + 177 "LinkNumber, MediaURL, KeyframeMotion, " +
178 "PhysicsShapeType, Density, GravityModifier, " + 178 "PhysicsShapeType, Density, GravityModifier, " +
179 "Friction, Restitution) values (" + "?UUID, " + 179 "Friction, Restitution, Vehicle " +
180 ") values (" + "?UUID, " +
180 "?CreationDate, ?Name, ?Text, " + 181 "?CreationDate, ?Name, ?Text, " +
181 "?Description, ?SitName, ?TouchName, " + 182 "?Description, ?SitName, ?TouchName, " +
182 "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " + 183 "?ObjectFlags, ?OwnerMask, ?NextOwnerMask, " +
@@ -210,7 +211,7 @@ namespace OpenSim.Data.MySQL
210 "?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " + 211 "?CollisionSoundVolume, ?PassTouches, ?PassCollisions, " +
211 "?LinkNumber, ?MediaURL, ?KeyframeMotion, " + 212 "?LinkNumber, ?MediaURL, ?KeyframeMotion, " +
212 "?PhysicsShapeType, ?Density, ?GravityModifier, " + 213 "?PhysicsShapeType, ?Density, ?GravityModifier, " +
213 "?Friction, ?Restitution)"; 214 "?Friction, ?Restitution, ?Vehicle)";
214 215
215 FillPrimCommand(cmd, prim, obj.UUID, regionUUID); 216 FillPrimCommand(cmd, prim, obj.UUID, regionUUID);
216 217
@@ -1320,6 +1321,15 @@ namespace OpenSim.Data.MySQL
1320 prim.GravityModifier = (float)(double)row["GravityModifier"]; 1321 prim.GravityModifier = (float)(double)row["GravityModifier"];
1321 prim.Friction = (float)(double)row["Friction"]; 1322 prim.Friction = (float)(double)row["Friction"];
1322 prim.Bounciness = (float)(double)row["Restitution"]; 1323 prim.Bounciness = (float)(double)row["Restitution"];
1324
1325 SOPVehicle vehicle = null;
1326
1327 if (row["Vehicle"].ToString() != String.Empty)
1328 {
1329 vehicle = SOPVehicle.FromXml2(row["Vehicle"].ToString());
1330 if (vehicle != null)
1331 prim.VehicleParams = vehicle;
1332 }
1323 1333
1324 return prim; 1334 return prim;
1325 } 1335 }
@@ -1697,6 +1707,11 @@ namespace OpenSim.Data.MySQL
1697 cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier); 1707 cmd.Parameters.AddWithValue("GravityModifier", (double)prim.GravityModifier);
1698 cmd.Parameters.AddWithValue("Friction", (double)prim.Friction); 1708 cmd.Parameters.AddWithValue("Friction", (double)prim.Friction);
1699 cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness); 1709 cmd.Parameters.AddWithValue("Restitution", (double)prim.Bounciness);
1710
1711 if (prim.VehicleParams != null)
1712 cmd.Parameters.AddWithValue("Vehicle", prim.VehicleParams.ToXml2());
1713 else
1714 cmd.Parameters.AddWithValue("Vehicle", String.Empty);
1700 } 1715 }
1701 1716
1702 /// <summary> 1717 /// <summary>
diff --git a/OpenSim/Framework/LocklessQueue.cs b/OpenSim/Framework/LocklessQueue.cs
index dd3d201..84f887c 100644
--- a/OpenSim/Framework/LocklessQueue.cs
+++ b/OpenSim/Framework/LocklessQueue.cs
@@ -99,8 +99,13 @@ namespace OpenSim.Framework
99 } 99 }
100 else 100 else
101 { 101 {
102 item = oldHeadNext.Item; 102 item = oldHeadNext.Item;
103 haveAdvancedHead = CAS(ref head, oldHead, oldHeadNext); 103 haveAdvancedHead = CAS(ref head, oldHead, oldHeadNext);
104 if (haveAdvancedHead)
105 {
106 oldHeadNext.Item = default(T);
107 oldHead.Next = null;
108 }
104 } 109 }
105 } 110 }
106 } 111 }
@@ -111,6 +116,10 @@ namespace OpenSim.Framework
111 116
112 public void Clear() 117 public void Clear()
113 { 118 {
119 // ugly
120 T item;
121 while(count > 0)
122 Dequeue(out item);
114 Init(); 123 Init();
115 } 124 }
116 125
diff --git a/OpenSim/Framework/MinHeap.cs b/OpenSim/Framework/MinHeap.cs
index 33d0364..99ac25d 100644
--- a/OpenSim/Framework/MinHeap.cs
+++ b/OpenSim/Framework/MinHeap.cs
@@ -63,12 +63,15 @@ namespace OpenSim.Framework
63 63
64 internal void Clear() 64 internal void Clear()
65 { 65 {
66 this.value = default(T);
67 if (this.handle != null) 66 if (this.handle != null)
68 {
69 this.handle.Clear(); 67 this.handle.Clear();
70 this.handle = null; 68 ClearRef();
71 } 69 }
70
71 internal void ClearRef()
72 {
73 this.value = default(T);
74 this.handle = null;
72 } 75 }
73 } 76 }
74 77
@@ -285,6 +288,7 @@ namespace OpenSim.Framework
285 if (--this.size > 0 && index != this.size) 288 if (--this.size > 0 && index != this.size)
286 { 289 {
287 Set(this.items[this.size], index); 290 Set(this.items[this.size], index);
291 this.items[this.size].ClearRef();
288 if (!BubbleUp(index)) 292 if (!BubbleUp(index))
289 BubbleDown(index); 293 BubbleDown(index);
290 } 294 }
diff --git a/OpenSim/Framework/Statistics/BaseStatsCollector.cs b/OpenSim/Framework/Statistics/BaseStatsCollector.cs
index c9e57ce..3f918f3 100644
--- a/OpenSim/Framework/Statistics/BaseStatsCollector.cs
+++ b/OpenSim/Framework/Statistics/BaseStatsCollector.cs
@@ -48,10 +48,26 @@ namespace OpenSim.Framework.Statistics
48 string.Format( 48 string.Format(
49 "Allocated to OpenSim objects: {0} MB\n", 49 "Allocated to OpenSim objects: {0} MB\n",
50 Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0))); 50 Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)));
51 sb.Append( 51
52 string.Format( 52 Process myprocess = Process.GetCurrentProcess();
53 "Process memory : {0} MB\n", 53 if (!myprocess.HasExited)
54 Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0))); 54 {
55 myprocess.Refresh();
56 sb.Append(
57 string.Format(
58 "Process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
59 Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0),
60 Math.Round(Process.GetCurrentProcess().PagedMemorySize64 / 1024.0 / 1024.0),
61 Math.Round(Process.GetCurrentProcess().VirtualMemorySize64 / 1024.0 / 1024.0)));
62 sb.Append(
63 string.Format(
64 "Peak process memory: Physical {0} MB \t Paged {1} MB \t Virtual {2} MB\n",
65 Math.Round(Process.GetCurrentProcess().PeakWorkingSet64 / 1024.0 / 1024.0),
66 Math.Round(Process.GetCurrentProcess().PeakPagedMemorySize64 / 1024.0 / 1024.0),
67 Math.Round(Process.GetCurrentProcess().PeakVirtualMemorySize64 / 1024.0 / 1024.0)));
68 }
69 else
70 sb.Append("Process reported as Exited \n");
55 71
56 return sb.ToString(); 72 return sb.ToString();
57 } 73 }
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
index 0c60391..4f18b53 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs
@@ -90,9 +90,9 @@ namespace OpenSim.Region.CoreModules.Hypergrid
90 } 90 }
91 } 91 }
92 92
93 protected override List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 93 protected override List<MapBlockData> GetAndSendBlocksInternal(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
94 { 94 {
95 List<MapBlockData> mapBlocks = base.GetAndSendBlocks(remoteClient, minX, minY, maxX, maxY, flag); 95 List<MapBlockData> mapBlocks = base.GetAndSendBlocksInternal(remoteClient, minX, minY, maxX, maxY, flag);
96 lock (m_SeenMapBlocks) 96 lock (m_SeenMapBlocks)
97 { 97 {
98 if (!m_SeenMapBlocks.ContainsKey(remoteClient.AgentId)) 98 if (!m_SeenMapBlocks.ContainsKey(remoteClient.AgentId))
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
index 4e6bfb8..2417b1a 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs
@@ -86,90 +86,93 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
86 86
87 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) 87 private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags)
88 { 88 {
89 if (mapName.Length < 2) 89 Util.FireAndForget(x =>
90 { 90 {
91 remoteClient.SendAlertMessage("Use a search string with at least 2 characters"); 91 if (mapName.Length < 2)
92 return; 92 {
93 } 93 remoteClient.SendAlertMessage("Use a search string with at least 2 characters");
94 return;
95 }
94 96
95 //m_log.DebugFormat("MAP NAME=({0})", mapName); 97 //m_log.DebugFormat("MAP NAME=({0})", mapName);
96 98
97 // Hack to get around the fact that ll V3 now drops the port from the 99 // Hack to get around the fact that ll V3 now drops the port from the
98 // map name. See https://jira.secondlife.com/browse/VWR-28570 100 // map name. See https://jira.secondlife.com/browse/VWR-28570
99 // 101 //
100 // Caller, use this magic form instead: 102 // Caller, use this magic form instead:
101 // secondlife://http|!!mygrid.com|8002|Region+Name/128/128 103 // secondlife://http|!!mygrid.com|8002|Region+Name/128/128
102 // or url encode if possible. 104 // or url encode if possible.
103 // the hacks we do with this viewer... 105 // the hacks we do with this viewer...
104 // 106 //
105 string mapNameOrig = mapName; 107 string mapNameOrig = mapName;
106 if (mapName.Contains("|")) 108 if (mapName.Contains("|"))
107 mapName = mapName.Replace('|', ':'); 109 mapName = mapName.Replace('|', ':');
108 if (mapName.Contains("+")) 110 if (mapName.Contains("+"))
109 mapName = mapName.Replace('+', ' '); 111 mapName = mapName.Replace('+', ' ');
110 if (mapName.Contains("!")) 112 if (mapName.Contains("!"))
111 mapName = mapName.Replace('!', '/'); 113 mapName = mapName.Replace('!', '/');
112 114
113 // try to fetch from GridServer 115 // try to fetch from GridServer
114 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); 116 List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
115// if (regionInfos.Count == 0) 117 // if (regionInfos.Count == 0)
116// remoteClient.SendAlertMessage("Hyperlink could not be established."); 118 // remoteClient.SendAlertMessage("Hyperlink could not be established.");
117 119
118 //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count); 120 //m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions", mapName, regionInfos.Count);
119 List<MapBlockData> blocks = new List<MapBlockData>(); 121 List<MapBlockData> blocks = new List<MapBlockData>();
120 122
121 MapBlockData data; 123 MapBlockData data;
122 if (regionInfos.Count > 0) 124 if (regionInfos.Count > 0)
123 {
124 foreach (GridRegion info in regionInfos)
125 { 125 {
126 data = new MapBlockData(); 126 foreach (GridRegion info in regionInfos)
127 data.Agents = 0; 127 {
128 data.Access = info.Access; 128 data = new MapBlockData();
129 if (flags == 2) // V2 sends this 129 data.Agents = 0;
130 data.MapImageId = UUID.Zero; 130 data.Access = info.Access;
131 else 131 if (flags == 2) // V2 sends this
132 data.MapImageId = info.TerrainImage; 132 data.MapImageId = UUID.Zero;
133 // ugh! V2-3 is very sensitive about the result being 133 else
134 // exactly the same as the requested name 134 data.MapImageId = info.TerrainImage;
135 if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+")) 135 // ugh! V2-3 is very sensitive about the result being
136 data.Name = mapNameOrig; 136 // exactly the same as the requested name
137 else 137 if (regionInfos.Count == 1 && mapNameOrig.Contains("|") || mapNameOrig.Contains("+"))
138 data.Name = info.RegionName; 138 data.Name = mapNameOrig;
139 data.RegionFlags = 0; // TODO not used? 139 else
140 data.WaterHeight = 0; // not used 140 data.Name = info.RegionName;
141 data.X = (ushort)(info.RegionLocX / Constants.RegionSize); 141 data.RegionFlags = 0; // TODO not used?
142 data.Y = (ushort)(info.RegionLocY / Constants.RegionSize); 142 data.WaterHeight = 0; // not used
143 blocks.Add(data); 143 data.X = (ushort)(info.RegionLocX / Constants.RegionSize);
144 data.Y = (ushort)(info.RegionLocY / Constants.RegionSize);
145 blocks.Add(data);
146 }
144 } 147 }
145 }
146 148
147 // final block, closing the search result 149 // final block, closing the search result
148 data = new MapBlockData(); 150 data = new MapBlockData();
149 data.Agents = 0; 151 data.Agents = 0;
150 data.Access = 255; 152 data.Access = 255;
151 data.MapImageId = UUID.Zero; 153 data.MapImageId = UUID.Zero;
152 data.Name = mapName; 154 data.Name = mapName;
153 data.RegionFlags = 0; 155 data.RegionFlags = 0;
154 data.WaterHeight = 0; // not used 156 data.WaterHeight = 0; // not used
155 data.X = 0; 157 data.X = 0;
156 data.Y = 0; 158 data.Y = 0;
157 blocks.Add(data); 159 blocks.Add(data);
158 160
159 // flags are agent flags sent from the viewer. 161 // flags are agent flags sent from the viewer.
160 // they have different values depending on different viewers, apparently 162 // they have different values depending on different viewers, apparently
161 remoteClient.SendMapBlock(blocks, flags); 163 remoteClient.SendMapBlock(blocks, flags);
162 164
163 // send extra user messages for V3 165 // send extra user messages for V3
164 // because the UI is very confusing 166 // because the UI is very confusing
165 // while we don't fix the hard-coded urls 167 // while we don't fix the hard-coded urls
166 if (flags == 2) 168 if (flags == 2)
167 { 169 {
168 if (regionInfos.Count == 0) 170 if (regionInfos.Count == 0)
169 remoteClient.SendAgentAlertMessage("No regions found with that name.", true); 171 remoteClient.SendAgentAlertMessage("No regions found with that name.", true);
170 else if (regionInfos.Count == 1) 172 else if (regionInfos.Count == 1)
171 remoteClient.SendAgentAlertMessage("Region found!", false); 173 remoteClient.SendAgentAlertMessage("Region found!", false);
172 } 174 }
175 });
173 } 176 }
174 177
175// private Scene GetClientScene(IClientAPI client) 178// private Scene GetClientScene(IClientAPI client)
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 00be5df..309856f 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -63,7 +63,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
63 private static readonly UUID STOP_UUID = UUID.Random(); 63 private static readonly UUID STOP_UUID = UUID.Random();
64 private static readonly string m_mapLayerPath = "0001/"; 64 private static readonly string m_mapLayerPath = "0001/";
65 65
66 private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); 66 private ManualResetEvent queueEvent = new ManualResetEvent(false);
67 private Queue<MapRequestState> requests = new Queue<MapRequestState>();
68
69 private ManualResetEvent m_mapBlockRequestEvent = new ManualResetEvent(false);
70 private Dictionary<UUID, Queue<MapBlockRequestData>> m_mapBlockRequests = new Dictionary<UUID, Queue<MapBlockRequestData>>();
67 71
68 protected Scene m_scene; 72 protected Scene m_scene;
69 private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); 73 private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>();
@@ -71,7 +75,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
71 private int blacklistTimeout = 10*60*1000; // 10 minutes 75 private int blacklistTimeout = 10*60*1000; // 10 minutes
72 private byte[] myMapImageJPEG; 76 private byte[] myMapImageJPEG;
73 protected volatile bool m_Enabled = false; 77 protected volatile bool m_Enabled = false;
74 private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>();
75 private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>(); 78 private Dictionary<string, int> m_blacklistedurls = new Dictionary<string, int>();
76 private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); 79 private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>();
77 private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>(); 80 private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>();
@@ -228,54 +231,54 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
228 // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is 231 // 6/8/2011 -- I'm adding an explicit 2048 check, so that we never forget that there is
229 // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks. 232 // a hack here, and so that regions below 4096 don't get spammed with unnecessary map blocks.
230 233
231 if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048) 234 //if (m_scene.RegionInfo.RegionLocX >= 2048 || m_scene.RegionInfo.RegionLocY >= 2048)
232 { 235 //{
233 ScenePresence avatarPresence = null; 236 // ScenePresence avatarPresence = null;
234 237
235 m_scene.TryGetScenePresence(agentID, out avatarPresence); 238 // m_scene.TryGetScenePresence(agentID, out avatarPresence);
236 239
237 if (avatarPresence != null) 240 // if (avatarPresence != null)
238 { 241 // {
239 bool lookup = false; 242 // bool lookup = false;
240 243
241 lock (cachedMapBlocks) 244 // lock (cachedMapBlocks)
242 { 245 // {
243 if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch())) 246 // if (cachedMapBlocks.Count > 0 && ((cachedTime + 1800) > Util.UnixTimeSinceEpoch()))
244 { 247 // {
245 List<MapBlockData> mapBlocks; 248 // List<MapBlockData> mapBlocks;
246 249
247 mapBlocks = cachedMapBlocks; 250 // mapBlocks = cachedMapBlocks;
248 avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); 251 // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
249 } 252 // }
250 else 253 // else
251 { 254 // {
252 lookup = true; 255 // lookup = true;
253 } 256 // }
254 } 257 // }
255 if (lookup) 258 // if (lookup)
256 { 259 // {
257 List<MapBlockData> mapBlocks = new List<MapBlockData>(); ; 260 // List<MapBlockData> mapBlocks = new List<MapBlockData>(); ;
258 261
259 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, 262 // List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
260 (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize, 263 // (int)(m_scene.RegionInfo.RegionLocX - 8) * (int)Constants.RegionSize,
261 (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize, 264 // (int)(m_scene.RegionInfo.RegionLocX + 8) * (int)Constants.RegionSize,
262 (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize, 265 // (int)(m_scene.RegionInfo.RegionLocY - 8) * (int)Constants.RegionSize,
263 (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize); 266 // (int)(m_scene.RegionInfo.RegionLocY + 8) * (int)Constants.RegionSize);
264 foreach (GridRegion r in regions) 267 // foreach (GridRegion r in regions)
265 { 268 // {
266 MapBlockData block = new MapBlockData(); 269 // MapBlockData block = new MapBlockData();
267 MapBlockFromGridRegion(block, r, 0); 270 // MapBlockFromGridRegion(block, r, 0);
268 mapBlocks.Add(block); 271 // mapBlocks.Add(block);
269 } 272 // }
270 avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0); 273 // avatarPresence.ControllingClient.SendMapBlock(mapBlocks, 0);
271 274
272 lock (cachedMapBlocks) 275 // lock (cachedMapBlocks)
273 cachedMapBlocks = mapBlocks; 276 // cachedMapBlocks = mapBlocks;
274 277
275 cachedTime = Util.UnixTimeSinceEpoch(); 278 // cachedTime = Util.UnixTimeSinceEpoch();
276 } 279 // }
277 } 280 // }
278 } 281 //}
279 282
280 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse(); 283 LLSDMapLayerResponse mapResponse = new LLSDMapLayerResponse();
281 mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse()); 284 mapResponse.LayerData.Array.Add(GetOSDMapLayerResponse());
@@ -302,8 +305,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
302 protected static OSDMapLayer GetOSDMapLayerResponse() 305 protected static OSDMapLayer GetOSDMapLayerResponse()
303 { 306 {
304 OSDMapLayer mapLayer = new OSDMapLayer(); 307 OSDMapLayer mapLayer = new OSDMapLayer();
305 mapLayer.Right = 5000; 308 mapLayer.Right = 2048;
306 mapLayer.Top = 5000; 309 mapLayer.Top = 2048;
307 mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006"); 310 mapLayer.ImageID = new UUID("00000000-0000-1111-9999-000000000006");
308 311
309 return mapLayer; 312 return mapLayer;
@@ -332,6 +335,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
332 { 335 {
333 m_rootAgents.Remove(AgentId); 336 m_rootAgents.Remove(AgentId);
334 } 337 }
338 lock (m_mapBlockRequestEvent)
339 {
340 if (m_mapBlockRequests.ContainsKey(AgentId))
341 m_mapBlockRequests.Remove(AgentId);
342 }
335 } 343 }
336 #endregion 344 #endregion
337 345
@@ -354,6 +362,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
354 ThreadPriority.BelowNormal, 362 ThreadPriority.BelowNormal,
355 true, 363 true,
356 true); 364 true);
365 Watchdog.StartThread(
366 MapBlockSendThread,
367 string.Format("MapBlockSendThread ({0})", m_scene.RegionInfo.RegionName),
368 ThreadPriority.BelowNormal,
369 true,
370 true);
357 } 371 }
358 372
359 /// <summary> 373 /// <summary>
@@ -369,7 +383,27 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
369 st.itemtype=0; 383 st.itemtype=0;
370 st.regionhandle=0; 384 st.regionhandle=0;
371 385
372 requests.Enqueue(st); 386 lock (requests)
387 {
388 queueEvent.Set();
389 requests.Enqueue(st);
390 }
391
392 MapBlockRequestData req = new MapBlockRequestData();
393
394 req.client = null;
395 req.minX = 0;
396 req.maxX = 0;
397 req.minY = 0;
398 req.maxY = 0;
399 req.flags = 0;
400
401 lock (m_mapBlockRequestEvent)
402 {
403 m_mapBlockRequests[UUID.Zero] = new Queue<MapBlockRequestData>();
404 m_mapBlockRequests[UUID.Zero].Enqueue(req);
405 m_mapBlockRequestEvent.Set();
406 }
373 } 407 }
374 408
375 public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags, 409 public virtual void HandleMapItemRequest(IClientAPI remoteClient, uint flags,
@@ -525,7 +559,21 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
525 { 559 {
526 while (true) 560 while (true)
527 { 561 {
528 MapRequestState st = requests.Dequeue(1000); 562 MapRequestState st = new MapRequestState();
563 bool valid = false;
564 queueEvent.WaitOne();
565 lock (requests)
566 {
567 if (requests.Count > 0)
568 {
569 st = requests.Dequeue();
570 valid = true;
571 }
572 if (requests.Count == 0)
573 queueEvent.Reset();
574 }
575 if (!valid)
576 continue;
529 577
530 // end gracefully 578 // end gracefully
531 if (st.agentID == STOP_UUID) 579 if (st.agentID == STOP_UUID)
@@ -543,13 +591,13 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
543 if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle)) 591 if (dorequest && !m_blacklistedregions.ContainsKey(st.regionhandle))
544 { 592 {
545 while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break 593 while (nAsyncRequests >= MAX_ASYNC_REQUESTS) // hit the break
546 Thread.Sleep(80); 594 Thread.Sleep(100);
547 595
548 RequestMapItemsDelegate d = RequestMapItemsAsync;
549 d.BeginInvoke(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle, RequestMapItemsCompleted, null);
550 //OSDMap response = RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle);
551 //RequestMapItemsCompleted(response);
552 Interlocked.Increment(ref nAsyncRequests); 596 Interlocked.Increment(ref nAsyncRequests);
597 Util.FireAndForget(x =>
598 {
599 RequestMapItemsAsync(st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle);
600 });
553 } 601 }
554 } 602 }
555 603
@@ -571,110 +619,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
571 /// <param name="state"></param> 619 /// <param name="state"></param>
572 public void EnqueueMapItemRequest(MapRequestState state) 620 public void EnqueueMapItemRequest(MapRequestState state)
573 { 621 {
574 requests.Enqueue(state); 622 lock (requests)
575 }
576
577 /// <summary>
578 /// Sends the mapitem response to the IClientAPI
579 /// </summary>
580 /// <param name="response">The OSDMap Response for the mapitem</param>
581 private void RequestMapItemsCompleted(IAsyncResult iar)
582 {
583 AsyncResult result = (AsyncResult)iar;
584 RequestMapItemsDelegate icon = (RequestMapItemsDelegate)result.AsyncDelegate;
585
586 OSDMap response = (OSDMap)icon.EndInvoke(iar);
587
588 Interlocked.Decrement(ref nAsyncRequests);
589
590 if (!response.ContainsKey("requestID"))
591 return;
592
593 UUID requestID = response["requestID"].AsUUID();
594
595 if (requestID != UUID.Zero)
596 { 623 {
597 MapRequestState mrs = new MapRequestState(); 624 queueEvent.Set();
598 mrs.agentID = UUID.Zero; 625 requests.Enqueue(state);
599 lock (m_openRequests)
600 {
601 if (m_openRequests.ContainsKey(requestID))
602 {
603 mrs = m_openRequests[requestID];
604 m_openRequests.Remove(requestID);
605 }
606 }
607
608 if (mrs.agentID != UUID.Zero)
609 {
610 ScenePresence av = null;
611 m_scene.TryGetScenePresence(mrs.agentID, out av);
612 if (av != null)
613 {
614 if (response.ContainsKey(mrs.itemtype.ToString()))
615 {
616 List<mapItemReply> returnitems = new List<mapItemReply>();
617 OSDArray itemarray = (OSDArray)response[mrs.itemtype.ToString()];
618 for (int i = 0; i < itemarray.Count; i++)
619 {
620 OSDMap mapitem = (OSDMap)itemarray[i];
621 mapItemReply mi = new mapItemReply();
622 mi.x = (uint)mapitem["X"].AsInteger();
623 mi.y = (uint)mapitem["Y"].AsInteger();
624 mi.id = mapitem["ID"].AsUUID();
625 mi.Extra = mapitem["Extra"].AsInteger();
626 mi.Extra2 = mapitem["Extra2"].AsInteger();
627 mi.name = mapitem["Name"].AsString();
628 returnitems.Add(mi);
629 }
630 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags);
631 }
632
633 // Service 7 (MAP_ITEM_LAND_FOR_SALE)
634 uint itemtype = 7;
635
636 if (response.ContainsKey(itemtype.ToString()))
637 {
638 List<mapItemReply> returnitems = new List<mapItemReply>();
639 OSDArray itemarray = (OSDArray)response[itemtype.ToString()];
640 for (int i = 0; i < itemarray.Count; i++)
641 {
642 OSDMap mapitem = (OSDMap)itemarray[i];
643 mapItemReply mi = new mapItemReply();
644 mi.x = (uint)mapitem["X"].AsInteger();
645 mi.y = (uint)mapitem["Y"].AsInteger();
646 mi.id = mapitem["ID"].AsUUID();
647 mi.Extra = mapitem["Extra"].AsInteger();
648 mi.Extra2 = mapitem["Extra2"].AsInteger();
649 mi.name = mapitem["Name"].AsString();
650 returnitems.Add(mi);
651 }
652 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags);
653 }
654
655 // Service 1 (MAP_ITEM_TELEHUB)
656 itemtype = 1;
657
658 if (response.ContainsKey(itemtype.ToString()))
659 {
660 List<mapItemReply> returnitems = new List<mapItemReply>();
661 OSDArray itemarray = (OSDArray)response[itemtype.ToString()];
662 for (int i = 0; i < itemarray.Count; i++)
663 {
664 OSDMap mapitem = (OSDMap)itemarray[i];
665 mapItemReply mi = new mapItemReply();
666 mi.x = (uint)mapitem["X"].AsInteger();
667 mi.y = (uint)mapitem["Y"].AsInteger();
668 mi.id = mapitem["ID"].AsUUID();
669 mi.Extra = mapitem["Extra"].AsInteger();
670 mi.Extra2 = mapitem["Extra2"].AsInteger();
671 mi.name = mapitem["Name"].AsString();
672 returnitems.Add(mi);
673 }
674 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, mrs.flags);
675 }
676 }
677 }
678 } 626 }
679 } 627 }
680 628
@@ -701,8 +649,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
701 EnqueueMapItemRequest(st); 649 EnqueueMapItemRequest(st);
702 } 650 }
703 651
704 private delegate OSDMap RequestMapItemsDelegate(UUID id, uint flags,
705 uint EstateID, bool godlike, uint itemtype, ulong regionhandle);
706 /// <summary> 652 /// <summary>
707 /// Does the actual remote mapitem request 653 /// Does the actual remote mapitem request
708 /// This should be called from an asynchronous thread 654 /// This should be called from an asynchronous thread
@@ -717,7 +663,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
717 /// <param name="itemtype">passed in from packet</param> 663 /// <param name="itemtype">passed in from packet</param>
718 /// <param name="regionhandle">Region we're looking up</param> 664 /// <param name="regionhandle">Region we're looking up</param>
719 /// <returns></returns> 665 /// <returns></returns>
720 private OSDMap RequestMapItemsAsync(UUID id, uint flags, 666 private void RequestMapItemsAsync(UUID id, uint flags,
721 uint EstateID, bool godlike, uint itemtype, ulong regionhandle) 667 uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
722 { 668 {
723// m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype); 669// m_log.DebugFormat("[WORLDMAP]: RequestMapItemsAsync; region handle: {0} {1}", regionhandle, itemtype);
@@ -740,7 +686,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
740 } 686 }
741 687
742 if (blacklisted) 688 if (blacklisted)
743 return new OSDMap(); 689 {
690 Interlocked.Decrement(ref nAsyncRequests);
691 return;
692 }
744 693
745 UUID requestID = UUID.Random(); 694 UUID requestID = UUID.Random();
746 lock (m_cachedRegionMapItemsAddress) 695 lock (m_cachedRegionMapItemsAddress)
@@ -748,6 +697,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
748 if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle)) 697 if (m_cachedRegionMapItemsAddress.ContainsKey(regionhandle))
749 httpserver = m_cachedRegionMapItemsAddress[regionhandle]; 698 httpserver = m_cachedRegionMapItemsAddress[regionhandle];
750 } 699 }
700
751 if (httpserver.Length == 0) 701 if (httpserver.Length == 0)
752 { 702 {
753 uint x = 0, y = 0; 703 uint x = 0, y = 0;
@@ -792,18 +742,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
792 742
793 // Can't find the http server 743 // Can't find the http server
794 if (httpserver.Length == 0 || blacklisted) 744 if (httpserver.Length == 0 || blacklisted)
795 return new OSDMap(); 745 {
796 746 Interlocked.Decrement(ref nAsyncRequests);
797 MapRequestState mrs = new MapRequestState(); 747 return;
798 mrs.agentID = id; 748 }
799 mrs.EstateID = EstateID;
800 mrs.flags = flags;
801 mrs.godlike = godlike;
802 mrs.itemtype=itemtype;
803 mrs.regionhandle = regionhandle;
804
805 lock (m_openRequests)
806 m_openRequests.Add(requestID, mrs);
807 749
808 WebRequest mapitemsrequest = null; 750 WebRequest mapitemsrequest = null;
809 try 751 try
@@ -813,7 +755,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
813 catch (Exception e) 755 catch (Exception e)
814 { 756 {
815 m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e); 757 m_log.DebugFormat("[WORLD MAP]: Access to {0} failed with {1}", httpserver, e);
816 return new OSDMap(); 758 Interlocked.Decrement(ref nAsyncRequests);
759 return;
817 } 760 }
818 761
819 mapitemsrequest.Method = "POST"; 762 mapitemsrequest.Method = "POST";
@@ -838,7 +781,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
838 catch (WebException ex) 781 catch (WebException ex)
839 { 782 {
840 m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message); 783 m_log.WarnFormat("[WORLD MAP]: Bad send on GetMapItems {0}", ex.Message);
841 responseMap["connect"] = OSD.FromBoolean(false);
842 lock (m_blacklistedurls) 784 lock (m_blacklistedurls)
843 { 785 {
844 if (!m_blacklistedurls.ContainsKey(httpserver)) 786 if (!m_blacklistedurls.ContainsKey(httpserver))
@@ -847,13 +789,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
847 789
848 m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); 790 m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver);
849 791
850 return responseMap; 792 Interlocked.Decrement(ref nAsyncRequests);
793 return;
851 } 794 }
852 catch 795 catch
853 { 796 {
854 m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); 797 m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver);
855 responseMap["connect"] = OSD.FromBoolean(false); 798 Interlocked.Decrement(ref nAsyncRequests);
856 return responseMap; 799 return;
857 } 800 }
858 finally 801 finally
859 { 802 {
@@ -874,12 +817,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
874 } 817 }
875 else 818 else
876 { 819 {
877 return new OSDMap(); 820 Interlocked.Decrement(ref nAsyncRequests);
821 return;
878 } 822 }
879 } 823 }
880 catch (WebException) 824 catch (WebException)
881 { 825 {
882 responseMap["connect"] = OSD.FromBoolean(false);
883 lock (m_blacklistedurls) 826 lock (m_blacklistedurls)
884 { 827 {
885 if (!m_blacklistedurls.ContainsKey(httpserver)) 828 if (!m_blacklistedurls.ContainsKey(httpserver))
@@ -888,19 +831,20 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
888 831
889 m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver); 832 m_log.WarnFormat("[WORLD MAP]: Blacklisted {0}", httpserver);
890 833
891 return responseMap; 834 Interlocked.Decrement(ref nAsyncRequests);
835 return;
892 } 836 }
893 catch 837 catch
894 { 838 {
895 m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver); 839 m_log.DebugFormat("[WORLD MAP]: RequestMapItems failed for {0}", httpserver);
896 responseMap["connect"] = OSD.FromBoolean(false);
897 lock (m_blacklistedregions) 840 lock (m_blacklistedregions)
898 { 841 {
899 if (!m_blacklistedregions.ContainsKey(regionhandle)) 842 if (!m_blacklistedregions.ContainsKey(regionhandle))
900 m_blacklistedregions.Add(regionhandle, Environment.TickCount); 843 m_blacklistedregions.Add(regionhandle, Environment.TickCount);
901 } 844 }
902 845
903 return responseMap; 846 Interlocked.Decrement(ref nAsyncRequests);
847 return;
904 } 848 }
905 finally 849 finally
906 { 850 {
@@ -919,14 +863,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
919 catch (Exception ex) 863 catch (Exception ex)
920 { 864 {
921 m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message); 865 m_log.InfoFormat("[WORLD MAP]: exception on parse of RequestMapItems reply from {0}: {1}", httpserver, ex.Message);
922 responseMap["connect"] = OSD.FromBoolean(false);
923 lock (m_blacklistedregions) 866 lock (m_blacklistedregions)
924 { 867 {
925 if (!m_blacklistedregions.ContainsKey(regionhandle)) 868 if (!m_blacklistedregions.ContainsKey(regionhandle))
926 m_blacklistedregions.Add(regionhandle, Environment.TickCount); 869 m_blacklistedregions.Add(regionhandle, Environment.TickCount);
927 } 870 }
928 871
929 return responseMap; 872 Interlocked.Decrement(ref nAsyncRequests);
873 return;
930 } 874 }
931 } 875 }
932 876
@@ -940,7 +884,78 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
940 } 884 }
941 } 885 }
942 886
943 return responseMap; 887 Interlocked.Decrement(ref nAsyncRequests);
888
889 if (id != UUID.Zero)
890 {
891 ScenePresence av = null;
892 m_scene.TryGetScenePresence(id, out av);
893 if (av != null)
894 {
895 if (responseMap.ContainsKey(itemtype.ToString()))
896 {
897 List<mapItemReply> returnitems = new List<mapItemReply>();
898 OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()];
899 for (int i = 0; i < itemarray.Count; i++)
900 {
901 OSDMap mapitem = (OSDMap)itemarray[i];
902 mapItemReply mi = new mapItemReply();
903 mi.x = (uint)mapitem["X"].AsInteger();
904 mi.y = (uint)mapitem["Y"].AsInteger();
905 mi.id = mapitem["ID"].AsUUID();
906 mi.Extra = mapitem["Extra"].AsInteger();
907 mi.Extra2 = mapitem["Extra2"].AsInteger();
908 mi.name = mapitem["Name"].AsString();
909 returnitems.Add(mi);
910 }
911 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
912 }
913
914 // Service 7 (MAP_ITEM_LAND_FOR_SALE)
915 itemtype = 7;
916
917 if (responseMap.ContainsKey(itemtype.ToString()))
918 {
919 List<mapItemReply> returnitems = new List<mapItemReply>();
920 OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()];
921 for (int i = 0; i < itemarray.Count; i++)
922 {
923 OSDMap mapitem = (OSDMap)itemarray[i];
924 mapItemReply mi = new mapItemReply();
925 mi.x = (uint)mapitem["X"].AsInteger();
926 mi.y = (uint)mapitem["Y"].AsInteger();
927 mi.id = mapitem["ID"].AsUUID();
928 mi.Extra = mapitem["Extra"].AsInteger();
929 mi.Extra2 = mapitem["Extra2"].AsInteger();
930 mi.name = mapitem["Name"].AsString();
931 returnitems.Add(mi);
932 }
933 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
934 }
935
936 // Service 1 (MAP_ITEM_TELEHUB)
937 itemtype = 1;
938
939 if (responseMap.ContainsKey(itemtype.ToString()))
940 {
941 List<mapItemReply> returnitems = new List<mapItemReply>();
942 OSDArray itemarray = (OSDArray)responseMap[itemtype.ToString()];
943 for (int i = 0; i < itemarray.Count; i++)
944 {
945 OSDMap mapitem = (OSDMap)itemarray[i];
946 mapItemReply mi = new mapItemReply();
947 mi.x = (uint)mapitem["X"].AsInteger();
948 mi.y = (uint)mapitem["Y"].AsInteger();
949 mi.id = mapitem["ID"].AsUUID();
950 mi.Extra = mapitem["Extra"].AsInteger();
951 mi.Extra2 = mapitem["Extra2"].AsInteger();
952 mi.name = mapitem["Name"].AsString();
953 returnitems.Add(mi);
954 }
955 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags);
956 }
957 }
958 }
944 } 959 }
945 960
946 /// <summary> 961 /// <summary>
@@ -950,7 +965,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
950 /// <param name="minY"></param> 965 /// <param name="minY"></param>
951 /// <param name="maxX"></param> 966 /// <param name="maxX"></param>
952 /// <param name="maxY"></param> 967 /// <param name="maxY"></param>
953 public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 968 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
954 { 969 {
955 //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag); 970 //m_log.ErrorFormat("[YYY] RequestMapBlocks {0}={1}={2}={3} {4}", minX, minY, maxX, maxY, flag);
956 if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible 971 if ((flag & 0x10000) != 0) // user clicked on qthe map a tile that isn't visible
@@ -1003,21 +1018,91 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1003 1018
1004 protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag) 1019 protected virtual List<MapBlockData> GetAndSendBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
1005 { 1020 {
1021 MapBlockRequestData req = new MapBlockRequestData();
1022
1023 req.client = remoteClient;
1024 req.minX = minX;
1025 req.maxX = maxX;
1026 req.minY = minY;
1027 req.maxY = maxY;
1028 req.flags = flag;
1029
1030 lock (m_mapBlockRequestEvent)
1031 {
1032 if (!m_mapBlockRequests.ContainsKey(remoteClient.AgentId))
1033 m_mapBlockRequests[remoteClient.AgentId] = new Queue<MapBlockRequestData>();
1034 m_mapBlockRequests[remoteClient.AgentId].Enqueue(req);
1035 m_mapBlockRequestEvent.Set();
1036 }
1037
1038 return new List<MapBlockData>();
1039 }
1040
1041 protected void MapBlockSendThread()
1042 {
1043 while (true)
1044 {
1045 List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>();
1046
1047 m_mapBlockRequestEvent.WaitOne();
1048 lock (m_mapBlockRequestEvent)
1049 {
1050 int total = 0;
1051 foreach (Queue<MapBlockRequestData> q in m_mapBlockRequests.Values)
1052 {
1053 if (q.Count > 0)
1054 thisRunData.Add(q.Dequeue());
1055
1056 total += q.Count;
1057 }
1058
1059 if (total == 0)
1060 m_mapBlockRequestEvent.Reset();
1061 }
1062
1063 foreach (MapBlockRequestData req in thisRunData)
1064 {
1065 // Null client stops thread
1066 if (req.client == null)
1067 return;
1068
1069 GetAndSendBlocksInternal(req.client, req.minX, req.minY, req.maxX, req.maxY, req.flags);
1070 }
1071
1072 Thread.Sleep(50);
1073 }
1074 }
1075
1076 protected virtual List<MapBlockData> GetAndSendBlocksInternal(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
1077 {
1078 List<MapBlockData> allBlocks = new List<MapBlockData>();
1006 List<MapBlockData> mapBlocks = new List<MapBlockData>(); 1079 List<MapBlockData> mapBlocks = new List<MapBlockData>();
1007 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, 1080 List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
1008 (minX - 4) * (int)Constants.RegionSize, 1081 minX * (int)Constants.RegionSize,
1009 (maxX + 4) * (int)Constants.RegionSize, 1082 maxX * (int)Constants.RegionSize,
1010 (minY - 4) * (int)Constants.RegionSize, 1083 minY * (int)Constants.RegionSize,
1011 (maxY + 4) * (int)Constants.RegionSize); 1084 maxY * (int)Constants.RegionSize);
1085// (minX - 4) * (int)Constants.RegionSize,
1086// (maxX + 4) * (int)Constants.RegionSize,
1087// (minY - 4) * (int)Constants.RegionSize,
1088// (maxY + 4) * (int)Constants.RegionSize);
1012 foreach (GridRegion r in regions) 1089 foreach (GridRegion r in regions)
1013 { 1090 {
1014 MapBlockData block = new MapBlockData(); 1091 MapBlockData block = new MapBlockData();
1015 MapBlockFromGridRegion(block, r, flag); 1092 MapBlockFromGridRegion(block, r, flag);
1016 mapBlocks.Add(block); 1093 mapBlocks.Add(block);
1094 allBlocks.Add(block);
1095 if (mapBlocks.Count >= 10)
1096 {
1097 remoteClient.SendMapBlock(mapBlocks, flag & 0xffff);
1098 mapBlocks.Clear();
1099 Thread.Sleep(50);
1100 }
1017 } 1101 }
1018 remoteClient.SendMapBlock(mapBlocks, flag & 0xffff); 1102 if (mapBlocks.Count > 0)
1103 remoteClient.SendMapBlock(mapBlocks, flag & 0xffff);
1019 1104
1020 return mapBlocks; 1105 return allBlocks;
1021 } 1106 }
1022 1107
1023 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag) 1108 protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag)
@@ -1417,6 +1502,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1417 { 1502 {
1418 m_rootAgents.Remove(avatar.UUID); 1503 m_rootAgents.Remove(avatar.UUID);
1419 } 1504 }
1505
1506 lock (m_mapBlockRequestEvent)
1507 {
1508 if (m_mapBlockRequests.ContainsKey(avatar.UUID))
1509 m_mapBlockRequests.Remove(avatar.UUID);
1510 }
1420 } 1511 }
1421 1512
1422 public void OnRegionUp(GridRegion otherRegion) 1513 public void OnRegionUp(GridRegion otherRegion)
@@ -1540,4 +1631,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1540 public uint itemtype; 1631 public uint itemtype;
1541 public ulong regionhandle; 1632 public ulong regionhandle;
1542 } 1633 }
1634
1635 public struct MapBlockRequestData
1636 {
1637 public IClientAPI client;
1638 public int minX;
1639 public int minY;
1640 public int maxX;
1641 public int maxY;
1642 public uint flags;
1643 }
1543} 1644}
diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs
index d3c2d27..41e8944 100644
--- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs
+++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs
@@ -30,6 +30,8 @@ using System.Collections.Generic;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.Physics.Manager;
33using System.Text;
34using System.IO;
33using System.Xml; 35using System.Xml;
34using OpenSim.Framework.Serialization; 36using OpenSim.Framework.Serialization;
35using OpenSim.Framework.Serialization.External; 37using OpenSim.Framework.Serialization.External;
@@ -561,8 +563,56 @@ namespace OpenSim.Region.Framework.Scenes
561 } 563 }
562 564
563 565
566 public string ToXml2()
567 {
568 MemoryStream ms = new MemoryStream(512);
569 UTF8Encoding enc = new UTF8Encoding();
570 XmlTextWriter xwriter = new XmlTextWriter(ms, enc);
571 ToXml2(xwriter);
572 xwriter.Flush();
573 string s = ms.GetStreamString();
574 xwriter.Close();
575 return s;
576 }
577
578 public static SOPVehicle FromXml2(string text)
579 {
580 if (text == String.Empty)
581 return null;
582
583 UTF8Encoding enc = new UTF8Encoding();
584 MemoryStream ms = new MemoryStream(enc.GetBytes(text));
585 XmlTextReader xreader = new XmlTextReader(ms);
586
587 SOPVehicle v = new SOPVehicle();
588 bool error;
589
590 v.FromXml2(xreader, out error);
591
592 xreader.Close();
593
594 if (error)
595 {
596 v = null;
597 return null;
598 }
599 return v;
600 }
601
602 public static SOPVehicle FromXml2(XmlTextReader reader)
603 {
604 SOPVehicle vehicle = new SOPVehicle();
605
606 bool errors = false;
607
608 vehicle.FromXml2(reader, out errors);
609 if (errors)
610 return null;
611
612 return vehicle;
613 }
564 614
565 public void FromXml2(XmlTextReader _reader, out bool errors) 615 private void FromXml2(XmlTextReader _reader, out bool errors)
566 { 616 {
567 errors = false; 617 errors = false;
568 reader = _reader; 618 reader = _reader;
@@ -739,4 +789,4 @@ namespace OpenSim.Region.Framework.Scenes
739 vd.m_referenceFrame = XRquat(); 789 vd.m_referenceFrame = XRquat();
740 } 790 }
741 } 791 }
742} \ No newline at end of file 792}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index b23d2e5..c3d66eb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1824,6 +1824,8 @@ namespace OpenSim.Region.Framework.Scenes
1824 { 1824 {
1825 parentGroup.LinkToGroup(child); 1825 parentGroup.LinkToGroup(child);
1826 1826
1827 child.DetachFromBackup();
1828
1827 // this is here so physics gets updated! 1829 // this is here so physics gets updated!
1828 // Don't remove! Bad juju! Stay away! or fix physics! 1830 // Don't remove! Bad juju! Stay away! or fix physics!
1829 child.AbsolutePosition = child.AbsolutePosition; 1831 child.AbsolutePosition = child.AbsolutePosition;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 1f1caca..2410970 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -353,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes
353 private int LastColSoundSentTime; 353 private int LastColSoundSentTime;
354 354
355 355
356 private SOPVehicle m_vehicle = null; 356 private SOPVehicle m_vehicleParams = null;
357 357
358 private KeyframeMotion m_keyframeMotion = null; 358 private KeyframeMotion m_keyframeMotion = null;
359 359
@@ -973,7 +973,15 @@ namespace OpenSim.Region.Framework.Scenes
973 } 973 }
974 return m_angularVelocity; 974 return m_angularVelocity;
975 } 975 }
976 set { m_angularVelocity = value; } 976 set
977 {
978 m_angularVelocity = value;
979 PhysicsActor actor = PhysActor;
980 if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE)
981 {
982 actor.RotationalVelocity = m_angularVelocity;
983 }
984 }
977 } 985 }
978 986
979 /// <summary></summary> 987 /// <summary></summary>
@@ -1877,7 +1885,7 @@ namespace OpenSim.Region.Framework.Scenes
1877 } 1885 }
1878 } 1886 }
1879 1887
1880// SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future 1888 // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future
1881 public void SetVelocity(Vector3 pVel, bool localGlobalTF) 1889 public void SetVelocity(Vector3 pVel, bool localGlobalTF)
1882 { 1890 {
1883 if (ParentGroup == null || ParentGroup.IsDeleted) 1891 if (ParentGroup == null || ParentGroup.IsDeleted)
@@ -1903,6 +1911,33 @@ namespace OpenSim.Region.Framework.Scenes
1903 1911
1904 ParentGroup.Velocity = pVel; 1912 ParentGroup.Velocity = pVel;
1905 } 1913 }
1914
1915 // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future
1916 public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF)
1917 {
1918 if (ParentGroup == null || ParentGroup.IsDeleted)
1919 return;
1920
1921 if (ParentGroup.IsAttachment)
1922 return; // don't work on attachments (for now ??)
1923
1924 SceneObjectPart root = ParentGroup.RootPart;
1925
1926 if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles
1927 return;
1928
1929 PhysicsActor pa = root.PhysActor;
1930
1931 if (pa == null || !pa.IsPhysical)
1932 return;
1933
1934 if (localGlobalTF)
1935 {
1936 pAngVel = pAngVel * GetWorldRotation();
1937 }
1938
1939 root.AngularVelocity = pAngVel;
1940 }
1906 1941
1907 1942
1908 /// <summary> 1943 /// <summary>
@@ -3415,15 +3450,15 @@ namespace OpenSim.Region.Framework.Scenes
3415 Force = force; 3450 Force = force;
3416 } 3451 }
3417 3452
3418 public SOPVehicle sopVehicle 3453 public SOPVehicle VehicleParams
3419 { 3454 {
3420 get 3455 get
3421 { 3456 {
3422 return m_vehicle; 3457 return m_vehicleParams;
3423 } 3458 }
3424 set 3459 set
3425 { 3460 {
3426 m_vehicle = value; 3461 m_vehicleParams = value;
3427 } 3462 }
3428 } 3463 }
3429 3464
@@ -3432,10 +3467,10 @@ namespace OpenSim.Region.Framework.Scenes
3432 { 3467 {
3433 get 3468 get
3434 { 3469 {
3435 if (m_vehicle == null) 3470 if (m_vehicleParams == null)
3436 return (int)Vehicle.TYPE_NONE; 3471 return (int)Vehicle.TYPE_NONE;
3437 else 3472 else
3438 return (int)m_vehicle.Type; 3473 return (int)m_vehicleParams.Type;
3439 } 3474 }
3440 set 3475 set
3441 { 3476 {
@@ -3445,7 +3480,7 @@ namespace OpenSim.Region.Framework.Scenes
3445 3480
3446 public void SetVehicleType(int type) 3481 public void SetVehicleType(int type)
3447 { 3482 {
3448 m_vehicle = null; 3483 m_vehicleParams = null;
3449 3484
3450 if (type == (int)Vehicle.TYPE_NONE) 3485 if (type == (int)Vehicle.TYPE_NONE)
3451 { 3486 {
@@ -3453,8 +3488,8 @@ namespace OpenSim.Region.Framework.Scenes
3453 PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; 3488 PhysActor.VehicleType = (int)Vehicle.TYPE_NONE;
3454 return; 3489 return;
3455 } 3490 }
3456 m_vehicle = new SOPVehicle(); 3491 m_vehicleParams = new SOPVehicle();
3457 m_vehicle.ProcessTypeChange((Vehicle)type); 3492 m_vehicleParams.ProcessTypeChange((Vehicle)type);
3458 { 3493 {
3459 if (_parentID ==0 && PhysActor != null) 3494 if (_parentID ==0 && PhysActor != null)
3460 PhysActor.VehicleType = type; 3495 PhysActor.VehicleType = type;
@@ -3464,10 +3499,10 @@ namespace OpenSim.Region.Framework.Scenes
3464 3499
3465 public void SetVehicleFlags(int param, bool remove) 3500 public void SetVehicleFlags(int param, bool remove)
3466 { 3501 {
3467 if (m_vehicle == null) 3502 if (m_vehicleParams == null)
3468 return; 3503 return;
3469 3504
3470 m_vehicle.ProcessVehicleFlags(param, remove); 3505 m_vehicleParams.ProcessVehicleFlags(param, remove);
3471 3506
3472 if (_parentID ==0 && PhysActor != null) 3507 if (_parentID ==0 && PhysActor != null)
3473 { 3508 {
@@ -3477,10 +3512,10 @@ namespace OpenSim.Region.Framework.Scenes
3477 3512
3478 public void SetVehicleFloatParam(int param, float value) 3513 public void SetVehicleFloatParam(int param, float value)
3479 { 3514 {
3480 if (m_vehicle == null) 3515 if (m_vehicleParams == null)
3481 return; 3516 return;
3482 3517
3483 m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); 3518 m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value);
3484 3519
3485 if (_parentID == 0 && PhysActor != null) 3520 if (_parentID == 0 && PhysActor != null)
3486 { 3521 {
@@ -3490,10 +3525,10 @@ namespace OpenSim.Region.Framework.Scenes
3490 3525
3491 public void SetVehicleVectorParam(int param, Vector3 value) 3526 public void SetVehicleVectorParam(int param, Vector3 value)
3492 { 3527 {
3493 if (m_vehicle == null) 3528 if (m_vehicleParams == null)
3494 return; 3529 return;
3495 3530
3496 m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); 3531 m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value);
3497 3532
3498 if (_parentID == 0 && PhysActor != null) 3533 if (_parentID == 0 && PhysActor != null)
3499 { 3534 {
@@ -3503,10 +3538,10 @@ namespace OpenSim.Region.Framework.Scenes
3503 3538
3504 public void SetVehicleRotationParam(int param, Quaternion rotation) 3539 public void SetVehicleRotationParam(int param, Quaternion rotation)
3505 { 3540 {
3506 if (m_vehicle == null) 3541 if (m_vehicleParams == null)
3507 return; 3542 return;
3508 3543
3509 m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); 3544 m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation);
3510 3545
3511 if (_parentID == 0 && PhysActor != null) 3546 if (_parentID == 0 && PhysActor != null)
3512 { 3547 {
@@ -4673,8 +4708,8 @@ namespace OpenSim.Region.Framework.Scenes
4673 if (VolumeDetectActive) // change if not the default only 4708 if (VolumeDetectActive) // change if not the default only
4674 pa.SetVolumeDetect(1); 4709 pa.SetVolumeDetect(1);
4675 4710
4676 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId) 4711 if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId)
4677 m_vehicle.SetVehicle(pa); 4712 m_vehicleParams.SetVehicle(pa);
4678 4713
4679 // we are going to tell rest of code about physics so better have this here 4714 // we are going to tell rest of code about physics so better have this here
4680 PhysActor = pa; 4715 PhysActor = pa;
@@ -4712,7 +4747,7 @@ namespace OpenSim.Region.Framework.Scenes
4712 pa.RotationalVelocity = rotationalVelocity; 4747 pa.RotationalVelocity = rotationalVelocity;
4713 4748
4714 // if not vehicle and root part apply force and torque 4749 // if not vehicle and root part apply force and torque
4715 if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE) 4750 if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE)
4716 && LocalId == ParentGroup.RootPart.LocalId) 4751 && LocalId == ParentGroup.RootPart.LocalId)
4717 { 4752 {
4718 pa.Force = Force; 4753 pa.Force = Force;
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index e223f47..2372d6b 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -623,20 +623,19 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
623 623
624 private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) 624 private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader)
625 { 625 {
626 bool errors = false; 626 SOPVehicle vehicle = SOPVehicle.FromXml2(reader);
627 SOPVehicle _vehicle = new SOPVehicle();
628 627
629 _vehicle.FromXml2(reader, out errors); 628 if (vehicle == null)
630
631 if (errors)
632 { 629 {
633 obj.sopVehicle = null; 630 obj.VehicleParams = null;
634 m_log.DebugFormat( 631 m_log.DebugFormat(
635 "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", 632 "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.",
636 obj.Name, obj.UUID); 633 obj.Name, obj.UUID);
637 } 634 }
638 else 635 else
639 obj.sopVehicle = _vehicle; 636 {
637 obj.VehicleParams = vehicle;
638 }
640 } 639 }
641 640
642 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) 641 private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader)
@@ -1325,8 +1324,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1325 1324
1326 writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); 1325 writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
1327 1326
1328 if (sop.sopVehicle != null) 1327 if (sop.VehicleParams != null)
1329 sop.sopVehicle.ToXml2(writer); 1328 sop.VehicleParams.ToXml2(writer);
1330 1329
1331 if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) 1330 if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType())
1332 writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); 1331 writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower());
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 6e4e41f..865180f 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -740,6 +740,7 @@ namespace OpenSim.Region.Physics.OdePlugin
740 if (Shell != IntPtr.Zero) 740 if (Shell != IntPtr.Zero)
741 { 741 {
742 _parent_scene.geom_name_map.Remove(Shell); 742 _parent_scene.geom_name_map.Remove(Shell);
743 _parent_scene.actor_name_map.Remove(Shell);
743 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); 744 _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
744 d.GeomDestroy(Shell); 745 d.GeomDestroy(Shell);
745 Shell = IntPtr.Zero; 746 Shell = IntPtr.Zero;
@@ -1188,6 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1188 } 1189 }
1189 else 1190 else
1190 { 1191 {
1192 _parent_scene.RemoveCollisionEventReporting(this);
1191 _parent_scene.RemoveCharacter(this); 1193 _parent_scene.RemoveCharacter(this);
1192 // destroy avatar capsule and related ODE data 1194 // destroy avatar capsule and related ODE data
1193 AvatarGeomAndBodyDestroy(); 1195 AvatarGeomAndBodyDestroy();
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
index e27be1e..e900c02 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
@@ -137,6 +137,7 @@ namespace OpenSim.Region.Physics.OdePlugin
137 float m_amdampY; 137 float m_amdampY;
138 float m_amdampZ; 138 float m_amdampZ;
139 139
140
140 public float FrictionFactor 141 public float FrictionFactor
141 { 142 {
142 get 143 get
@@ -145,6 +146,7 @@ namespace OpenSim.Region.Physics.OdePlugin
145 } 146 }
146 } 147 }
147 148
149
148 public ODEDynamics(OdePrim rootp) 150 public ODEDynamics(OdePrim rootp)
149 { 151 {
150 rootPrim = rootp; 152 rootPrim = rootp;
@@ -345,7 +347,7 @@ namespace OpenSim.Region.Physics.OdePlugin
345 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; 347 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale;
346 m_lmEfect = 1.0f; // turn it on 348 m_lmEfect = 1.0f; // turn it on
347 349
348 m_ffactor = 0.01f; 350 m_ffactor = 0.0f;
349 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 351 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
350 && !rootPrim.m_isSelected && !rootPrim.m_disabled) 352 && !rootPrim.m_isSelected && !rootPrim.m_disabled)
351 d.BodyEnable(rootPrim.Body); 353 d.BodyEnable(rootPrim.Body);
@@ -401,7 +403,7 @@ namespace OpenSim.Region.Physics.OdePlugin
401 m_lmEfect = 1.0f; // turn it on 403 m_lmEfect = 1.0f; // turn it on
402 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; 404 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale;
403 405
404 m_ffactor = 0.01f; 406 m_ffactor = 0.0f;
405 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 407 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
406 && !rootPrim.m_isSelected && !rootPrim.m_disabled) 408 && !rootPrim.m_isSelected && !rootPrim.m_disabled)
407 d.BodyEnable(rootPrim.Body); 409 d.BodyEnable(rootPrim.Body);
@@ -805,7 +807,8 @@ namespace OpenSim.Region.Physics.OdePlugin
805 } 807 }
806 808
807 m_lmEfect *= m_lmDecay; 809 m_lmEfect *= m_lmDecay;
808 m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared(); 810// m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared();
811 m_ffactor = 0.0f;
809 } 812 }
810 else 813 else
811 { 814 {
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 9b3b51b..ff17a6e 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -275,6 +275,7 @@ namespace OpenSim.Region.Physics.OdePlugin
275 275
276 if (veh != null && veh.Type != Vehicle.TYPE_NONE) 276 if (veh != null && veh.Type != Vehicle.TYPE_NONE)
277 cdata.mu *= veh.FrictionFactor; 277 cdata.mu *= veh.FrictionFactor;
278// cdata.mu *= 0;
278 } 279 }
279 } 280 }
280 281
@@ -582,8 +583,6 @@ namespace OpenSim.Region.Physics.OdePlugin
582 if (value.IsFinite()) 583 if (value.IsFinite())
583 { 584 {
584 AddChange(changes.Velocity, value); 585 AddChange(changes.Velocity, value);
585// _velocity = value;
586
587 } 586 }
588 else 587 else
589 { 588 {
@@ -675,9 +674,7 @@ namespace OpenSim.Region.Physics.OdePlugin
675 { 674 {
676 if (value.IsFinite()) 675 if (value.IsFinite())
677 { 676 {
678 m_rotationalVelocity = value; 677 AddChange(changes.AngVelocity, value);
679 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
680 d.BodyEnable(Body);
681 } 678 }
682 else 679 else
683 { 680 {
@@ -686,7 +683,6 @@ namespace OpenSim.Region.Physics.OdePlugin
686 } 683 }
687 } 684 }
688 685
689
690 public override float Buoyancy 686 public override float Buoyancy
691 { 687 {
692 get { return m_buoyancy; } 688 get { return m_buoyancy; }
@@ -947,6 +943,8 @@ namespace OpenSim.Region.Physics.OdePlugin
947 CollisionEventsThisFrame = null; 943 CollisionEventsThisFrame = null;
948 } 944 }
949 m_eventsubscription = 0; 945 m_eventsubscription = 0;
946 // for now still done on odescene
947// _parent_scene.RemoveCollisionEventReporting(this);
950 } 948 }
951 949
952 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 950 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
@@ -1736,17 +1734,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1736 1734
1737 d.BodySetAutoDisableFlag(Body, true); 1735 d.BodySetAutoDisableFlag(Body, true);
1738 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 1736 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
1739// d.BodySetLinearDampingThreshold(Body, 0.01f); 1737 d.BodySetDamping(Body, .005f, .005f);
1740// d.BodySetAngularDampingThreshold(Body, 0.001f);
1741 d.BodySetDamping(Body, .002f, .002f);
1742
1743 if (m_targetSpace != IntPtr.Zero)
1744 {
1745 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1746 if (d.SpaceQuery(m_targetSpace, prim_geom))
1747 d.SpaceRemove(m_targetSpace, prim_geom);
1748 }
1749 1738
1739 if (m_targetSpace != IntPtr.Zero)
1740 {
1741 _parent_scene.waitForSpaceUnlock(m_targetSpace);
1742 if (d.SpaceQuery(m_targetSpace, prim_geom))
1743 d.SpaceRemove(m_targetSpace, prim_geom);
1744 }
1750 1745
1751 if (childrenPrim.Count == 0) 1746 if (childrenPrim.Count == 0)
1752 { 1747 {
@@ -3295,6 +3290,13 @@ namespace OpenSim.Region.Physics.OdePlugin
3295 3290
3296 private void changevelocity(Vector3 newVel) 3291 private void changevelocity(Vector3 newVel)
3297 { 3292 {
3293 float len = newVel.LengthSquared();
3294 if (len > 100000.0f) // limit to 100m/s
3295 {
3296 len = 100.0f / (float)Math.Sqrt(len);
3297 newVel *= len;
3298 }
3299
3298 if (!m_isSelected) 3300 if (!m_isSelected)
3299 { 3301 {
3300 if (Body != IntPtr.Zero) 3302 if (Body != IntPtr.Zero)
@@ -3311,6 +3313,33 @@ namespace OpenSim.Region.Physics.OdePlugin
3311 _velocity = newVel; 3313 _velocity = newVel;
3312 } 3314 }
3313 3315
3316
3317 private void changeangvelocity(Vector3 newAngVel)
3318 {
3319 float len = newAngVel.LengthSquared();
3320 if (len > 144.0f) // limit to 12rad/s
3321 {
3322 len = 12.0f / (float)Math.Sqrt(len);
3323 newAngVel *= len;
3324 }
3325
3326 if (!m_isSelected)
3327 {
3328 if (Body != IntPtr.Zero)
3329 {
3330 if (m_disabled)
3331 enableBodySoft();
3332 else if (!d.BodyIsEnabled(Body))
3333 d.BodyEnable(Body);
3334
3335
3336 d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z);
3337 }
3338 //resetCollisionAccounting();
3339 }
3340 m_rotationalVelocity = newAngVel;
3341 }
3342
3314 private void changeVolumedetetion(bool newVolDtc) 3343 private void changeVolumedetetion(bool newVolDtc)
3315 { 3344 {
3316 m_isVolumeDetect = newVolDtc; 3345 m_isVolumeDetect = newVolDtc;
@@ -3947,9 +3976,10 @@ namespace OpenSim.Region.Physics.OdePlugin
3947// case changes.Acceleration: 3976// case changes.Acceleration:
3948// changeacceleration((Vector3)arg); 3977// changeacceleration((Vector3)arg);
3949// break; 3978// break;
3950// case changes.AngVelocity: 3979
3951// changeangvelocity((Vector3)arg); 3980 case changes.AngVelocity:
3952// break; 3981 changeangvelocity((Vector3)arg);
3982 break;
3953 3983
3954 case changes.Force: 3984 case changes.Force:
3955 changeForce((Vector3)arg); 3985 changeForce((Vector3)arg);
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
index 0e4961b..2341186 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs
@@ -1312,7 +1312,14 @@ namespace OdeAPI
1312 public static extern void GeomTriMeshSetRayCallback(IntPtr g, TriRayCallback callback); 1312 public static extern void GeomTriMeshSetRayCallback(IntPtr g, TriRayCallback callback);
1313 1313
1314 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGetConfiguration"), SuppressUnmanagedCodeSecurity] 1314 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGetConfiguration"), SuppressUnmanagedCodeSecurity]
1315 public static extern string GetConfiguration(string str); 1315 public static extern IntPtr iGetConfiguration();
1316
1317 public static string GetConfiguration()
1318 {
1319 IntPtr ptr = iGetConfiguration();
1320 string s = Marshal.PtrToStringAnsi(ptr);
1321 return s;
1322 }
1316 1323
1317 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dHashSpaceCreate"), SuppressUnmanagedCodeSecurity] 1324 [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dHashSpaceCreate"), SuppressUnmanagedCodeSecurity]
1318 public static extern IntPtr HashSpaceCreate(IntPtr space); 1325 public static extern IntPtr HashSpaceCreate(IntPtr space);
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 6c72324..7848b35 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -237,20 +237,20 @@ namespace OpenSim.Region.Physics.OdePlugin
237 237
238 private d.NearCallback nearCallback; 238 private d.NearCallback nearCallback;
239 239
240 private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>(); 240 private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
241 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); 241 private HashSet<OdePrim> _prims = new HashSet<OdePrim>();
242 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); 242 private HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
243 private readonly HashSet<OdePrim> _activegroups = new HashSet<OdePrim>(); 243 private HashSet<OdePrim> _activegroups = new HashSet<OdePrim>();
244 244
245 public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>(); 245 public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>();
246 246
247 /// <summary> 247 /// <summary>
248 /// A list of actors that should receive collision events. 248 /// A list of actors that should receive collision events.
249 /// </summary> 249 /// </summary>
250 private readonly List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>(); 250 private List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>();
251 private readonly List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>(); 251 private List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>();
252 252
253 private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>(); 253 private HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
254 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>(); 254 public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
255 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>(); 255 public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
256 256
@@ -264,26 +264,21 @@ namespace OpenSim.Region.Physics.OdePlugin
264 private volatile int m_global_contactcount = 0; 264 private volatile int m_global_contactcount = 0;
265 265
266 266
267 private readonly IntPtr contactgroup; 267 private IntPtr contactgroup;
268 268
269 public ContactData[] m_materialContactsData = new ContactData[8]; 269 public ContactData[] m_materialContactsData = new ContactData[8];
270 270
271 private readonly DoubleDictionary<Vector3, IntPtr, IntPtr> RegionTerrain = new DoubleDictionary<Vector3, IntPtr, IntPtr>(); 271 private Dictionary<Vector3, IntPtr> RegionTerrain = new Dictionary<Vector3, IntPtr>();
272 private readonly Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>(); 272 private Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>();
273 private readonly Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>(); 273 private Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>();
274 274
275 private int m_physicsiterations = 10; 275 private int m_physicsiterations = 10;
276 private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag 276 private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
277 private readonly PhysicsActor PANull = new NullPhysicsActor(); 277 private PhysicsActor PANull = new NullPhysicsActor();
278 private float step_time = 0.0f; 278 private float step_time = 0.0f;
279 279
280 public IntPtr world; 280 public IntPtr world;
281 281
282 private uint obj2LocalID = 0;
283 private OdeCharacter cc1;
284 private OdePrim cp1;
285 private OdeCharacter cc2;
286 private OdePrim cp2;
287 282
288 // split the spaces acording to contents type 283 // split the spaces acording to contents type
289 // ActiveSpace contains characters and active prims 284 // ActiveSpace contains characters and active prims
@@ -408,8 +403,8 @@ namespace OpenSim.Region.Physics.OdePlugin
408// checkThread(); 403// checkThread();
409 mesher = meshmerizer; 404 mesher = meshmerizer;
410 m_config = config; 405 m_config = config;
411/* 406
412 string ode_config = d.GetConfiguration("ODE"); 407 string ode_config = d.GetConfiguration();
413 if (ode_config != null && ode_config != "") 408 if (ode_config != null && ode_config != "")
414 { 409 {
415 m_log.WarnFormat("ODE configuration: {0}", ode_config); 410 m_log.WarnFormat("ODE configuration: {0}", ode_config);
@@ -419,7 +414,7 @@ namespace OpenSim.Region.Physics.OdePlugin
419 OdeUbitLib = true; 414 OdeUbitLib = true;
420 } 415 }
421 } 416 }
422*/ 417
423 /* 418 /*
424 if (region != null) 419 if (region != null)
425 { 420 {
@@ -526,8 +521,8 @@ namespace OpenSim.Region.Physics.OdePlugin
526 d.WorldSetGravity(world, gravityx, gravityy, gravityz); 521 d.WorldSetGravity(world, gravityx, gravityy, gravityz);
527 d.WorldSetContactSurfaceLayer(world, contactsurfacelayer); 522 d.WorldSetContactSurfaceLayer(world, contactsurfacelayer);
528 523
529 d.WorldSetLinearDamping(world, 0.001f); 524 d.WorldSetLinearDamping(world, 0.002f);
530 d.WorldSetAngularDamping(world, 0.001f); 525 d.WorldSetAngularDamping(world, 0.002f);
531 d.WorldSetAngularDampingThreshold(world, 0f); 526 d.WorldSetAngularDampingThreshold(world, 0f);
532 d.WorldSetLinearDampingThreshold(world, 0f); 527 d.WorldSetLinearDampingThreshold(world, 0f);
533 d.WorldSetMaxAngularSpeed(world, 100f); 528 d.WorldSetMaxAngularSpeed(world, 100f);
@@ -921,6 +916,8 @@ namespace OpenSim.Region.Physics.OdePlugin
921 cfm = 0.0001f / cfm; 916 cfm = 0.0001f / cfm;
922 if (cfm > 0.01f) 917 if (cfm > 0.01f)
923 cfm = 0.01f; 918 cfm = 0.01f;
919 else if (cfm < 0.00001f)
920 cfm = 0.00001f;
924 921
925 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) 922 if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
926 mu *= frictionMovementMult; 923 mu *= frictionMovementMult;
@@ -947,6 +944,8 @@ namespace OpenSim.Region.Physics.OdePlugin
947 cfm = 0.0001f / cfm; 944 cfm = 0.0001f / cfm;
948 if (cfm > 0.01f) 945 if (cfm > 0.01f)
949 cfm = 0.01f; 946 cfm = 0.01f;
947 else if (cfm < 0.00001f)
948 cfm = 0.00001f;
950 949
951 if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) 950 if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
952 { 951 {
@@ -989,6 +988,8 @@ namespace OpenSim.Region.Physics.OdePlugin
989 cfm = 0.0001f / cfm; 988 cfm = 0.0001f / cfm;
990 if (cfm > 0.01f) 989 if (cfm > 0.01f)
991 cfm = 0.01f; 990 cfm = 0.01f;
991 else if (cfm < 0.00001f)
992 cfm = 0.00001f;
992 993
993 if (curContact.side1 > 0) // should be 2 ? 994 if (curContact.side1 > 0) // should be 2 ?
994 IgnoreNegSides = true; 995 IgnoreNegSides = true;
@@ -1155,7 +1156,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1155 1156
1156 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) 1157 private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
1157 { 1158 {
1158 obj2LocalID = 0; 1159
1160 OdeCharacter cc1;
1161 OdePrim cp1;
1162 OdeCharacter cc2;
1163 OdePrim cp2;
1164
1165 uint obj2LocalID = 0;
1159 bool p1events = p1.SubscribedEvents(); 1166 bool p1events = p1.SubscribedEvents();
1160 bool p2events = p2.SubscribedEvents(); 1167 bool p2events = p2.SubscribedEvents();
1161 1168
@@ -1892,18 +1899,22 @@ namespace OpenSim.Region.Physics.OdePlugin
1892 lock (SimulationLock) 1899 lock (SimulationLock)
1893 lock(OdeLock) 1900 lock(OdeLock)
1894 { 1901 {
1902 if (world == IntPtr.Zero)
1903 return 0;
1904
1895 // adjust number of iterations per step 1905 // adjust number of iterations per step
1896 try 1906
1897 { 1907// try
1908// {
1898 d.WorldSetQuickStepNumIterations(world, curphysiteractions); 1909 d.WorldSetQuickStepNumIterations(world, curphysiteractions);
1899 } 1910/* }
1900 catch (StackOverflowException) 1911 catch (StackOverflowException)
1901 { 1912 {
1902 m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); 1913 m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim.");
1903// ode.drelease(world); 1914// ode.drelease(world);
1904 base.TriggerPhysicsBasedRestart(); 1915 base.TriggerPhysicsBasedRestart();
1905 } 1916 }
1906 1917*/
1907 while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever 1918 while (step_time > HalfOdeStep && nodeframes < 10) //limit number of steps so we don't say here for ever
1908 { 1919 {
1909 try 1920 try
@@ -1955,6 +1966,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1955 { 1966 {
1956 RemoveCharacter(defect); 1967 RemoveCharacter(defect);
1957 } 1968 }
1969 defects.Clear();
1958 } 1970 }
1959 } 1971 }
1960 1972
@@ -2060,13 +2072,13 @@ namespace OpenSim.Region.Physics.OdePlugin
2060 _badCharacter.Clear(); 2072 _badCharacter.Clear();
2061 } 2073 }
2062 } 2074 }
2063 2075/*
2064 int nactivegeoms = d.SpaceGetNumGeoms(ActiveSpace); 2076 int nactivegeoms = d.SpaceGetNumGeoms(ActiveSpace);
2065 int nstaticgeoms = d.SpaceGetNumGeoms(StaticSpace); 2077 int nstaticgeoms = d.SpaceGetNumGeoms(StaticSpace);
2066 int ntopgeoms = d.SpaceGetNumGeoms(TopSpace); 2078 int ntopgeoms = d.SpaceGetNumGeoms(TopSpace);
2067 int nbodies = d.NTotalBodies; 2079 int nbodies = d.NTotalBodies;
2068 int ngeoms = d.NTotalGeoms; 2080 int ngeoms = d.NTotalGeoms;
2069 2081*/
2070 // Finished with all sim stepping. If requested, dump world state to file for debugging. 2082 // Finished with all sim stepping. If requested, dump world state to file for debugging.
2071 // TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed? 2083 // TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed?
2072 // TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots? 2084 // TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots?
@@ -2383,11 +2395,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2383 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); 2395 d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
2384 d.GeomSetRotation(GroundGeom, ref R); 2396 d.GeomSetRotation(GroundGeom, ref R);
2385 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); 2397 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
2386 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); 2398 RegionTerrain.Add(pOffset, GroundGeom);
2387// TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
2388 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2399 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
2389 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); 2400 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
2390
2391 } 2401 }
2392 } 2402 }
2393 2403
@@ -2486,8 +2496,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2486 geom_name_map[GroundGeom] = "Terrain"; 2496 geom_name_map[GroundGeom] = "Terrain";
2487 2497
2488 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); 2498 d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0);
2489 RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); 2499 RegionTerrain.Add(pOffset, GroundGeom);
2490 // TerrainHeightFieldHeights.Add(GroundGeom, ODElandMap);
2491 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); 2500 TerrainHeightFieldHeights.Add(GroundGeom, _heightmap);
2492 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); 2501 TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler);
2493 } 2502 }
@@ -2649,19 +2658,42 @@ namespace OpenSim.Region.Physics.OdePlugin
2649 2658
2650 public override void Dispose() 2659 public override void Dispose()
2651 { 2660 {
2652 m_rayCastManager.Dispose();
2653 m_rayCastManager = null;
2654
2655 lock (OdeLock) 2661 lock (OdeLock)
2656 { 2662 {
2663 m_rayCastManager.Dispose();
2664 m_rayCastManager = null;
2665
2657 lock (_prims) 2666 lock (_prims)
2658 { 2667 {
2668 ChangesQueue.Clear();
2659 foreach (OdePrim prm in _prims) 2669 foreach (OdePrim prm in _prims)
2660 { 2670 {
2661 RemovePrim(prm); 2671 prm.DoAChange(changes.Remove, null);
2672 _collisionEventPrim.Remove(prm);
2662 } 2673 }
2674 _prims.Clear();
2663 } 2675 }
2664 2676
2677 OdeCharacter[] chtorem;
2678 lock (_characters)
2679 {
2680 chtorem = new OdeCharacter[_characters.Count];
2681 _characters.CopyTo(chtorem);
2682 }
2683
2684 ChangesQueue.Clear();
2685 foreach (OdeCharacter ch in chtorem)
2686 ch.DoAChange(changes.Remove, null);
2687
2688
2689 foreach (IntPtr GroundGeom in RegionTerrain.Values)
2690 {
2691 if (GroundGeom != IntPtr.Zero)
2692 d.GeomDestroy(GroundGeom);
2693 }
2694
2695 RegionTerrain.Clear();
2696
2665 if (TerrainHeightFieldHeightsHandlers.Count > 0) 2697 if (TerrainHeightFieldHeightsHandlers.Count > 0)
2666 { 2698 {
2667 foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values) 2699 foreach (GCHandle gch in TerrainHeightFieldHeightsHandlers.Values)
@@ -2671,6 +2703,9 @@ namespace OpenSim.Region.Physics.OdePlugin
2671 } 2703 }
2672 } 2704 }
2673 2705
2706 TerrainHeightFieldHeightsHandlers.Clear();
2707 TerrainHeightFieldHeights.Clear();
2708
2674 if (WaterGeom != IntPtr.Zero) 2709 if (WaterGeom != IntPtr.Zero)
2675 { 2710 {
2676 d.GeomDestroy(WaterGeom); 2711 d.GeomDestroy(WaterGeom);
@@ -2691,6 +2726,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2691 2726
2692 2727
2693 d.WorldDestroy(world); 2728 d.WorldDestroy(world);
2729 world = IntPtr.Zero;
2694 //d.CloseODE(); 2730 //d.CloseODE();
2695 } 2731 }
2696 } 2732 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index b257cd4..e9db5d5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -113,8 +113,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
113 new Dictionary<UUID, UserInfoCacheEntry>(); 113 new Dictionary<UUID, UserInfoCacheEntry>();
114 protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. 114 protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
115 115
116 protected Timer m_ShoutSayTimer; 116// protected Timer m_ShoutSayTimer;
117 protected int m_SayShoutCount = 0; 117 protected int m_SayShoutCount = 0;
118 DateTime m_lastSayShoutCheck;
118 119
119 private Dictionary<string, string> MovementAnimationsForLSL = 120 private Dictionary<string, string> MovementAnimationsForLSL =
120 new Dictionary<string, string> { 121 new Dictionary<string, string> {
@@ -140,10 +141,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
140 141
141 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) 142 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
142 { 143 {
144/*
143 m_ShoutSayTimer = new Timer(1000); 145 m_ShoutSayTimer = new Timer(1000);
144 m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed; 146 m_ShoutSayTimer.Elapsed += SayShoutTimerElapsed;
145 m_ShoutSayTimer.AutoReset = true; 147 m_ShoutSayTimer.AutoReset = true;
146 m_ShoutSayTimer.Start(); 148 m_ShoutSayTimer.Start();
149*/
150 m_lastSayShoutCheck = DateTime.UtcNow;
147 151
148 m_ScriptEngine = ScriptEngine; 152 m_ScriptEngine = ScriptEngine;
149 m_host = host; 153 m_host = host;
@@ -858,12 +862,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
858 wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text); 862 wComm.DeliverMessage(ChatTypeEnum.Whisper, channelID, m_host.Name, m_host.UUID, text);
859 } 863 }
860 864
865 private void CheckSayShoutTime()
866 {
867 DateTime now = DateTime.UtcNow;
868 if ((now - m_lastSayShoutCheck).Ticks > 10000000) // 1sec
869 {
870 m_lastSayShoutCheck = now;
871 m_SayShoutCount = 0;
872 }
873 else
874 m_SayShoutCount++;
875 }
876
861 public void llSay(int channelID, string text) 877 public void llSay(int channelID, string text)
862 { 878 {
863 m_host.AddScriptLPS(1); 879 m_host.AddScriptLPS(1);
864 880
865 if (channelID == 0) 881 if (channelID == 0)
866 m_SayShoutCount++; 882// m_SayShoutCount++;
883 CheckSayShoutTime();
867 884
868 if (m_SayShoutCount >= 11) 885 if (m_SayShoutCount >= 11)
869 ScriptSleep(2000); 886 ScriptSleep(2000);
@@ -891,7 +908,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
891 m_host.AddScriptLPS(1); 908 m_host.AddScriptLPS(1);
892 909
893 if (channelID == 0) 910 if (channelID == 0)
894 m_SayShoutCount++; 911// m_SayShoutCount++;
912 CheckSayShoutTime();
895 913
896 if (m_SayShoutCount >= 11) 914 if (m_SayShoutCount >= 11)
897 ScriptSleep(2000); 915 ScriptSleep(2000);
@@ -2556,12 +2574,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2556 return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); 2574 return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z);
2557 } 2575 }
2558 2576
2559
2560 public void llSetAngularVelocity(LSL_Vector avel, int local) 2577 public void llSetAngularVelocity(LSL_Vector avel, int local)
2561 { 2578 {
2562 m_host.AddScriptLPS(1); 2579 m_host.AddScriptLPS(1);
2563 // Still not done !!!! 2580 m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0);
2564// m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0);
2565 } 2581 }
2566 2582
2567 public LSL_Vector llGetOmega() 2583 public LSL_Vector llGetOmega()
@@ -3671,6 +3687,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3671 3687
3672 protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain) 3688 protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain)
3673 { 3689 {
3690 spinrate *= gain;
3674 part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate))); 3691 part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate)));
3675 } 3692 }
3676 3693
@@ -12044,12 +12061,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12044 12061
12045 return rq.ToString(); 12062 return rq.ToString();
12046 } 12063 }
12047 12064/*
12048 private void SayShoutTimerElapsed(Object sender, ElapsedEventArgs args) 12065 private void SayShoutTimerElapsed(Object sender, ElapsedEventArgs args)
12049 { 12066 {
12050 m_SayShoutCount = 0; 12067 m_SayShoutCount = 0;
12051 } 12068 }
12052 12069*/
12053 private struct Tri 12070 private struct Tri
12054 { 12071 {
12055 public Vector3 p1; 12072 public Vector3 p1;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 2886344..cc783aa 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -636,7 +636,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
636 if (!m_Enabled) 636 if (!m_Enabled)
637 return; 637 return;
638 lockScriptsForRead(true); 638 lockScriptsForRead(true);
639 foreach (IScriptInstance instance in m_Scripts.Values) 639
640 List<IScriptInstance> instancesToDel = new List<IScriptInstance>(m_Scripts.Values);
641
642// foreach (IScriptInstance instance in m_Scripts.Values)
643 foreach (IScriptInstance instance in instancesToDel)
640 { 644 {
641 // Force a final state save 645 // Force a final state save
642 // 646 //
@@ -659,7 +663,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
659 // Must be done explicitly because they have infinite 663 // Must be done explicitly because they have infinite
660 // lifetime 664 // lifetime
661 // 665 //
662 if (!m_SimulatorShuttingDown) 666// if (!m_SimulatorShuttingDown)
663 { 667 {
664 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID); 668 m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
665 if (m_DomainScripts[instance.AppDomain].Count == 0) 669 if (m_DomainScripts[instance.AppDomain].Count == 0)
@@ -669,10 +673,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
669 } 673 }
670 } 674 }
671 675
672 m_Scripts.Clear(); 676// m_Scripts.Clear();
673 m_PrimObjects.Clear(); 677// m_PrimObjects.Clear();
674 m_Assemblies.Clear(); 678// m_Assemblies.Clear();
675 m_DomainScripts.Clear(); 679// m_DomainScripts.Clear();
676 } 680 }
677 lockScriptsForRead(false); 681 lockScriptsForRead(false);
678 lockScriptsForWrite(true); 682 lockScriptsForWrite(true);
diff --git a/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs b/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs
index fb85d1c..4502b7d 100644
--- a/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs
@@ -29,6 +29,7 @@ using System;
29using System.IO; 29using System.IO;
30using System.Net; 30using System.Net;
31using System.Reflection; 31using System.Reflection;
32using System.Threading;
32 33
33using Nini.Config; 34using Nini.Config;
34using log4net; 35using log4net;
@@ -70,6 +71,8 @@ namespace OpenSim.Server.Handlers.MapImage
70 71
71 class MapServerGetHandler : BaseStreamHandler 72 class MapServerGetHandler : BaseStreamHandler
72 { 73 {
74 public static ManualResetEvent ev = new ManualResetEvent(true);
75
73// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 76// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
74 77
75 private IMapImageService m_MapService; 78 private IMapImageService m_MapService;
@@ -82,8 +85,13 @@ namespace OpenSim.Server.Handlers.MapImage
82 85
83 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 86 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
84 { 87 {
85 byte[] result = new byte[0]; 88 ev.WaitOne();
89 lock (ev)
90 {
91 ev.Reset();
92 }
86 93
94 byte[] result = new byte[0];
87 string format = string.Empty; 95 string format = string.Empty;
88 result = m_MapService.GetMapTile(path.Trim('/'), out format); 96 result = m_MapService.GetMapTile(path.Trim('/'), out format);
89 if (result.Length > 0) 97 if (result.Length > 0)
@@ -100,6 +108,11 @@ namespace OpenSim.Server.Handlers.MapImage
100 httpResponse.ContentType = "text/plain"; 108 httpResponse.ContentType = "text/plain";
101 } 109 }
102 110
111 lock (ev)
112 {
113 ev.Set();
114 }
115
103 return result; 116 return result;
104 } 117 }
105 118