aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLUserProfilesData.cs5
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs12
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs21
-rw-r--r--OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs45
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs67
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs30
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs75
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs10
-rwxr-xr-xOpenSim/Region/Framework/Scenes/SceneGraph.cs66
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs101
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs40
-rw-r--r--OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs423
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs51
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs47
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs49
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs8
21 files changed, 675 insertions, 400 deletions
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
index 295e131..c389ae4 100644
--- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
@@ -524,8 +524,7 @@ namespace OpenSim.Data.MySQL
524 query += "SELECT `notes` FROM usernotes WHERE "; 524 query += "SELECT `notes` FROM usernotes WHERE ";
525 query += "useruuid = ?Id AND "; 525 query += "useruuid = ?Id AND ";
526 query += "targetuuid = ?TargetId"; 526 query += "targetuuid = ?TargetId";
527 OSDArray data = new OSDArray(); 527
528
529 try 528 try
530 { 529 {
531 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 530 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
@@ -904,8 +903,6 @@ namespace OpenSim.Data.MySQL
904 query += "usersettings WHERE "; 903 query += "usersettings WHERE ";
905 query += "useruuid = ?Id"; 904 query += "useruuid = ?Id";
906 905
907 OSDArray data = new OSDArray();
908
909 try 906 try
910 { 907 {
911 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 908 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index d7b3bbe..cd20c4e 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -1354,7 +1354,7 @@ namespace OpenSim.Data.SQLite
1354 createCol(land, "Name", typeof(String)); 1354 createCol(land, "Name", typeof(String));
1355 createCol(land, "Desc", typeof(String)); 1355 createCol(land, "Desc", typeof(String));
1356 createCol(land, "OwnerUUID", typeof(String)); 1356 createCol(land, "OwnerUUID", typeof(String));
1357 createCol(land, "IsGroupOwned", typeof(Boolean)); 1357 createCol(land, "IsGroupOwned", typeof(String));
1358 createCol(land, "Area", typeof(Int32)); 1358 createCol(land, "Area", typeof(Int32));
1359 createCol(land, "AuctionID", typeof(Int32)); //Unemplemented 1359 createCol(land, "AuctionID", typeof(Int32)); //Unemplemented
1360 createCol(land, "Category", typeof(Int32)); //Enum OpenMetaverse.Parcel.ParcelCategory 1360 createCol(land, "Category", typeof(Int32)); //Enum OpenMetaverse.Parcel.ParcelCategory
@@ -1387,6 +1387,9 @@ namespace OpenSim.Data.SQLite
1387 createCol(land, "MediaLoop", typeof(Boolean)); 1387 createCol(land, "MediaLoop", typeof(Boolean));
1388 createCol(land, "ObscureMedia", typeof(Boolean)); 1388 createCol(land, "ObscureMedia", typeof(Boolean));
1389 createCol(land, "ObscureMusic", typeof(Boolean)); 1389 createCol(land, "ObscureMusic", typeof(Boolean));
1390 createCol(land, "SeeAVs", typeof(Boolean));
1391 createCol(land, "AnyAVSounds", typeof(Boolean));
1392 createCol(land, "GroupAVSounds", typeof(Boolean));
1390 1393
1391 land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] }; 1394 land.PrimaryKey = new DataColumn[] { land.Columns["UUID"] };
1392 1395
@@ -1829,7 +1832,7 @@ namespace OpenSim.Data.SQLite
1829 newData.Name = (String)row["Name"]; 1832 newData.Name = (String)row["Name"];
1830 newData.Description = (String)row["Desc"]; 1833 newData.Description = (String)row["Desc"];
1831 newData.OwnerID = (UUID)(String)row["OwnerUUID"]; 1834 newData.OwnerID = (UUID)(String)row["OwnerUUID"];
1832 newData.IsGroupOwned = (Boolean)row["IsGroupOwned"]; 1835 newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]);
1833 newData.Area = Convert.ToInt32(row["Area"]); 1836 newData.Area = Convert.ToInt32(row["Area"]);
1834 newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented 1837 newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented
1835 newData.Category = (ParcelCategory)Convert.ToInt32(row["Category"]); 1838 newData.Category = (ParcelCategory)Convert.ToInt32(row["Category"]);
@@ -2245,7 +2248,7 @@ namespace OpenSim.Data.SQLite
2245 row["Name"] = land.Name; 2248 row["Name"] = land.Name;
2246 row["Desc"] = land.Description; 2249 row["Desc"] = land.Description;
2247 row["OwnerUUID"] = land.OwnerID.ToString(); 2250 row["OwnerUUID"] = land.OwnerID.ToString();
2248 row["IsGroupOwned"] = land.IsGroupOwned; 2251 row["IsGroupOwned"] = land.IsGroupOwned.ToString();
2249 row["Area"] = land.Area; 2252 row["Area"] = land.Area;
2250 row["AuctionID"] = land.AuctionID; //Unemplemented 2253 row["AuctionID"] = land.AuctionID; //Unemplemented
2251 row["Category"] = land.Category; //Enum OpenMetaverse.Parcel.ParcelCategory 2254 row["Category"] = land.Category; //Enum OpenMetaverse.Parcel.ParcelCategory
@@ -2939,6 +2942,9 @@ namespace OpenSim.Data.SQLite
2939 { 2942 {
2940 return DbType.Binary; 2943 return DbType.Binary;
2941 } 2944 }
2945 else if (type == typeof(Boolean)) {
2946 return DbType.Boolean;
2947 }
2942 else 2948 else
2943 { 2949 {
2944 return DbType.String; 2950 return DbType.String;
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index fad250b..2d337f1 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -6108,7 +6108,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6108 AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes); 6108 AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
6109 AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard); 6109 AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
6110 AddLocalPacketHandler(PacketType.ChangeInventoryItemFlags, HandleChangeInventoryItemFlags); 6110 AddLocalPacketHandler(PacketType.ChangeInventoryItemFlags, HandleChangeInventoryItemFlags);
6111 6111 AddLocalPacketHandler(PacketType.RevokePermissions, HandleRevokePermissions);
6112 AddGenericPacketHandler("autopilot", HandleAutopilot); 6112 AddGenericPacketHandler("autopilot", HandleAutopilot);
6113 } 6113 }
6114 6114
@@ -10997,6 +10997,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10997 return true; 10997 return true;
10998 } 10998 }
10999 10999
11000
11000 private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack) 11001 private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
11001 { 11002 {
11002 return true; 11003 return true;
@@ -12371,6 +12372,24 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12371 return true; 12372 return true;
12372 } 12373 }
12373 12374
12375 private bool HandleRevokePermissions(IClientAPI sender, Packet Pack)
12376 {
12377 RevokePermissionsPacket pkt = (RevokePermissionsPacket)Pack;
12378 if (pkt.AgentData.SessionID != SessionId ||
12379 pkt .AgentData.AgentID != AgentId)
12380 return true;
12381
12382 // don't use multidelegate "event"
12383 ScenePresence sp = (ScenePresence)SceneAgent;
12384 if(sp != null && !sp.IsDeleted && !sp.IsInTransit)
12385 {
12386 UUID objectID = pkt.Data.ObjectID;
12387 uint permissions = pkt.Data.ObjectPermissions;
12388
12389 sp.HandleRevokePermissions(objectID , permissions);
12390 }
12391 return true;
12392 }
12374 private bool HandlePlacesQuery(IClientAPI sender, Packet Pack) 12393 private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
12375 { 12394 {
12376 PlacesQueryPacket placesQueryPacket = 12395 PlacesQueryPacket placesQueryPacket =
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
index 0752ae5..d59cfa9 100644
--- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs
@@ -113,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
113 } 113 }
114 catch (Exception e) 114 catch (Exception e)
115 { 115 {
116 m_log.Error("[EMAIL] DefaultEmailModule not configured: " + e.Message); 116 m_log.Error("[EMAIL]: DefaultEmailModule not configured: " + e.Message);
117 m_Enabled = false; 117 m_Enabled = false;
118 return; 118 return;
119 } 119 }
@@ -142,7 +142,7 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
142 } 142 }
143 } 143 }
144 144
145 m_log.Info("[EMAIL] Activated DefaultEmailModule"); 145 m_log.Info("[EMAIL]: Activated DefaultEmailModule");
146 } 146 }
147 147
148 public void RemoveRegion(Scene scene) 148 public void RemoveRegion(Scene scene)
@@ -268,12 +268,12 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
268 bool isEMailStrictMatch = EMailreStrict.IsMatch(address); 268 bool isEMailStrictMatch = EMailreStrict.IsMatch(address);
269 if (!isEMailStrictMatch) 269 if (!isEMailStrictMatch)
270 { 270 {
271 m_log.Error("[EMAIL] REGEX Problem in EMail Address: "+address); 271 m_log.Error("[EMAIL]: REGEX Problem in EMail Address: "+address);
272 return; 272 return;
273 } 273 }
274 if ((subject.Length + body.Length) > m_MaxEmailSize) 274 if ((subject.Length + body.Length) > m_MaxEmailSize)
275 { 275 {
276 m_log.Error("[EMAIL] subject + body larger than limit of " + m_MaxEmailSize + " bytes"); 276 m_log.Error("[EMAIL]: subject + body larger than limit of " + m_MaxEmailSize + " bytes");
277 return; 277 return;
278 } 278 }
279 279
@@ -318,11 +318,11 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
318 emailMessage.Send(smtpServer); 318 emailMessage.Send(smtpServer);
319 319
320 //Log 320 //Log
321 m_log.Info("[EMAIL] EMail sent to: " + address + " from object: " + objectID.ToString() + "@" + m_HostName); 321 m_log.Info("[EMAIL]: EMail sent to: " + address + " from object: " + objectID.ToString() + "@" + m_HostName);
322 } 322 }
323 catch (Exception e) 323 catch (Exception e)
324 { 324 {
325 m_log.Error("[EMAIL] DefaultEmailModule Exception: " + e.Message); 325 m_log.Error("[EMAIL]: DefaultEmailModule Exception: " + e.Message);
326 } 326 }
327 } 327 }
328 else 328 else
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 7d8ae57..70733fc 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -52,6 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
52 52
53 private IGridService m_GridService; 53 private IGridService m_GridService;
54 private RegionInfoCache m_RegionInfoCache; 54 private RegionInfoCache m_RegionInfoCache;
55 private HashSet<Scene> m_scenes = new HashSet<Scene>();
55 56
56 private bool m_Enabled; 57 private bool m_Enabled;
57 58
@@ -68,7 +69,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
68 69
69 public LocalGridServicesConnector(IConfigSource source, RegionInfoCache regionInfoCache) 70 public LocalGridServicesConnector(IConfigSource source, RegionInfoCache regionInfoCache)
70 { 71 {
71 m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly witj cache.", LogHeader); 72 m_log.DebugFormat("{0} LocalGridServicesConnector instantiated directly with cache.", LogHeader);
72 InitialiseService(source, regionInfoCache); 73 InitialiseService(source, regionInfoCache);
73 } 74 }
74 75
@@ -137,11 +138,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
137 138
138 public void PostInitialise() 139 public void PostInitialise()
139 { 140 {
140 // FIXME: We will still add this command even if we aren't enabled since RemoteGridServiceConnector
141 // will have instantiated us directly.
142 MainConsole.Instance.Commands.AddCommand("Regions", false, "show neighbours",
143 "show neighbours",
144 "Shows the local regions' neighbours", HandleShowNeighboursCommand);
145 } 141 }
146 142
147 public void Close() 143 public void Close()
@@ -153,6 +149,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
153 if (!m_Enabled) 149 if (!m_Enabled)
154 return; 150 return;
155 151
152 lock(m_scenes)
153 {
154 if(!m_scenes.Contains(scene))
155 m_scenes.Add(scene);
156 }
156 scene.RegisterModuleInterface<IGridService>(this); 157 scene.RegisterModuleInterface<IGridService>(this);
157 158
158 GridRegion r = new GridRegion(scene.RegionInfo); 159 GridRegion r = new GridRegion(scene.RegionInfo);
@@ -166,6 +167,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
166 if (!m_Enabled) 167 if (!m_Enabled)
167 return; 168 return;
168 169
170 lock(m_scenes)
171 {
172 if(m_scenes.Contains(scene))
173 m_scenes.Remove(scene);
174 }
175
169 m_RegionInfoCache.Remove(scene.RegionInfo.ScopeID, scene.RegionInfo.RegionHandle); 176 m_RegionInfoCache.Remove(scene.RegionInfo.ScopeID, scene.RegionInfo.RegionHandle);
170 scene.EventManager.OnRegionUp -= OnRegionUp; 177 scene.EventManager.OnRegionUp -= OnRegionUp;
171 } 178 }
@@ -221,14 +228,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
221 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) 228 public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
222 { 229 {
223 230
224 // try in cache by handler first
225// ulong regionHandle = Util.RegionWorldLocToHandle((uint)x, (uint)y);
226
227 bool inCache = false; 231 bool inCache = false;
228// GridRegion rinfo = m_RegionInfoCache.Get(scopeID, regionHandle, out inCache);
229// if (inCache)
230// return rinfo;
231
232 GridRegion rinfo = m_RegionInfoCache.Get(scopeID, (uint)x, (uint)y, out inCache); 232 GridRegion rinfo = m_RegionInfoCache.Get(scopeID, (uint)x, (uint)y, out inCache);
233 if (inCache) 233 if (inCache)
234 return rinfo; 234 return rinfo;
@@ -295,24 +295,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
295 295
296 #endregion 296 #endregion
297 297
298 public void HandleShowNeighboursCommand(string module, string[] cmdparams)
299 {
300 System.Text.StringBuilder caps = new System.Text.StringBuilder();
301/* temporary broken
302 lock (m_LocalCache)
303 {
304 foreach (KeyValuePair<UUID, RegionCache> kvp in m_LocalCache)
305 {
306 caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
307 List<GridRegion> regions = kvp.Value.GetNeighbours();
308 foreach (GridRegion r in regions)
309 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY));
310 }
311 }
312
313 MainConsole.Instance.Output(caps.ToString());
314*/
315 MainConsole.Instance.Output("Neighbours list not avaiable in this version\n");
316 }
317 } 298 }
318} 299}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
index f40541e..1357825 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
@@ -210,7 +210,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
210 return; 210 return;
211 } 211 }
212 212
213 m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.Name);
214 213
215 // mapTile.Save( // DEBUG DEBUG 214 // mapTile.Save( // DEBUG DEBUG
216 // String.Format("maptiles/raw-{0}-{1}-{2}.jpg", regionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY), 215 // String.Format("maptiles/raw-{0}-{1}-{2}.jpg", regionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY),
@@ -218,12 +217,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
218 // If the region/maptile is legacy sized, just upload the one tile like it has always been done 217 // If the region/maptile is legacy sized, just upload the one tile like it has always been done
219 if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) 218 if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
220 { 219 {
220 m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.Name);
221 ConvertAndUploadMaptile(scene, mapTile, 221 ConvertAndUploadMaptile(scene, mapTile,
222 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, 222 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
223 scene.RegionInfo.RegionName); 223 scene.RegionInfo.RegionName);
224 } 224 }
225 else 225 else
226 { 226 {
227 m_log.DebugFormat("{0} Upload {1} maptiles for {2}", LogHeader,
228 (mapTile.Width * mapTile.Height) / (Constants.RegionSize * Constants.RegionSize),
229 scene.Name);
230
227 // For larger regions (varregion) we must cut the region image into legacy sized 231 // For larger regions (varregion) we must cut the region image into legacy sized
228 // pieces since that is how the maptile system works. 232 // pieces since that is how the maptile system works.
229 // Note the assumption that varregions are always a multiple of legacy size. 233 // Note the assumption that varregions are always a multiple of legacy size.
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 4324ddc..68c9c97 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -1435,6 +1435,9 @@ namespace OpenSim.Region.CoreModules.World.Land
1435 land.LandData.IsGroupOwned = false; 1435 land.LandData.IsGroupOwned = false;
1436 land.LandData.SalePrice = 0; 1436 land.LandData.SalePrice = 0;
1437 land.LandData.AuthBuyerID = UUID.Zero; 1437 land.LandData.AuthBuyerID = UUID.Zero;
1438 land.LandData.SeeAVs = true;
1439 land.LandData.AnyAVSounds = true;
1440 land.LandData.GroupAVSounds = true;
1438 land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory); 1441 land.LandData.Flags &= ~(uint) (ParcelFlags.ForSale | ParcelFlags.ForSaleObjects | ParcelFlags.SellParcelObjects | ParcelFlags.ShowDirectory);
1439 m_scene.ForEachClient(SendParcelOverlay); 1442 m_scene.ForEachClient(SendParcelOverlay);
1440 land.SendLandUpdateToClient(true, remote_client); 1443 land.SendLandUpdateToClient(true, remote_client);
diff --git a/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs b/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs
index b9bcb8b..411c4d6 100644
--- a/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs
+++ b/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs
@@ -40,6 +40,7 @@ using OpenSim.Framework.Console;
40using OpenSim.Framework.Monitoring; 40using OpenSim.Framework.Monitoring;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43 44
44namespace OpenSim.Region.CoreModules.World.Objects.Commands 45namespace OpenSim.Region.CoreModules.World.Objects.Commands
45{ 46{
@@ -107,6 +108,15 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
107 + "max-agent-limit <int> - Maximum root agent limit. agent-limit cannot exceed this." 108 + "max-agent-limit <int> - Maximum root agent limit. agent-limit cannot exceed this."
108 + " This is not persisted over restart - to set it every time you must add a MaxAgents entry to your regions file.", 109 + " This is not persisted over restart - to set it every time you must add a MaxAgents entry to your regions file.",
109 HandleRegionSet); 110 HandleRegionSet);
111
112 m_console.Commands.AddCommand("Regions", false, "show neighbours",
113 "show neighbours",
114 "Shows the local region neighbours", HandleShowNeighboursCommand);
115
116 m_console.Commands.AddCommand("Regions", false, "show regionsinview",
117 "show regionsinview",
118 "Shows regions that can be seen from a region", HandleShowRegionsInViewCommand);
119
110 } 120 }
111 121
112 public void RemoveRegion(Scene scene) 122 public void RemoveRegion(Scene scene)
@@ -309,5 +319,60 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
309 319
310 MainConsole.Instance.Output(sb.ToString()); 320 MainConsole.Instance.Output(sb.ToString());
311 } 321 }
322
323 public void HandleShowNeighboursCommand(string module, string[] cmdparams)
324 {
325 if(m_scene == null)
326 return;
327
328 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
329 return;
330
331 System.Text.StringBuilder caps = new System.Text.StringBuilder();
332
333 RegionInfo sr = m_scene.RegionInfo;
334 caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", sr.RegionName, sr.RegionID);
335 List<GridRegion> regions = m_scene.GridService.GetNeighbours(sr.ScopeID, sr.RegionID);
336 foreach (GridRegion r in regions)
337 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY));
338
339 MainConsole.Instance.Output(caps.ToString());
340 }
341
342 public void HandleShowRegionsInViewCommand(string module, string[] cmdparams)
343 {
344 if(m_scene == null)
345 return;
346
347 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
348 return;
349
350 System.Text.StringBuilder caps = new System.Text.StringBuilder();
351 int maxview = (int)m_scene.MaxRegionViewDistance;
352 RegionInfo sr = m_scene.RegionInfo;
353 caps.AppendFormat("*** Regions that can be seen from {0} ({1}) (MaxRegionViewDistance {2}m) ***\n", sr.RegionName, sr.RegionID, maxview);
354 int startX = (int)sr.WorldLocX;
355 int endX = startX + (int)sr.RegionSizeX;
356 int startY = (int)sr.WorldLocY;
357 int endY = startY + (int)sr.RegionSizeY;
358 startX -= maxview;
359 if(startX < 0 )
360 startX = 0;
361 startY -= maxview;
362 if(startY < 0)
363 startY = 0;
364 endX += maxview;
365 endY += maxview;
366
367 List<GridRegion> regions = m_scene.GridService.GetRegionRange(sr.ScopeID, startX, endX, startY, endY);
368 foreach (GridRegion r in regions)
369 {
370 if(r.RegionHandle == sr.RegionHandle)
371 continue;
372 caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY));
373 }
374
375 MainConsole.Instance.Output(caps.ToString());
376 }
312 } 377 }
313} \ No newline at end of file 378}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 05d18da..69fa5f6 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -1122,8 +1122,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1122 } 1122 }
1123 */ 1123 */
1124 1124
1125 int[] xPieces = new int[toSend.Count];
1126 int[] yPieces = new int[toSend.Count];
1127 float[] patchPieces = new float[toSend.Count * 2]; 1125 float[] patchPieces = new float[toSend.Count * 2];
1128 int pieceIndex = 0; 1126 int pieceIndex = 0;
1129 foreach (PatchesToSend pts in toSend) 1127 foreach (PatchesToSend pts in toSend)
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 57ec800..c249e9d 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -66,7 +66,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
66 66
67 private static readonly string DEFAULT_WORLD_MAP_EXPORT_PATH = "exportmap.jpg"; 67 private static readonly string DEFAULT_WORLD_MAP_EXPORT_PATH = "exportmap.jpg";
68 private static readonly UUID STOP_UUID = UUID.Random(); 68 private static readonly UUID STOP_UUID = UUID.Random();
69 private static readonly string m_mapLayerPath = "0001/";
70 69
71 private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); 70 private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>();
72 71
@@ -177,6 +176,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
177 regionimage = regionimage.Replace("-", ""); 176 regionimage = regionimage.Replace("-", "");
178 m_log.Info("[WORLD MAP]: JPEG Map location: " + m_scene.RegionInfo.ServerURI + "index.php?method=" + regionimage); 177 m_log.Info("[WORLD MAP]: JPEG Map location: " + m_scene.RegionInfo.ServerURI + "index.php?method=" + regionimage);
179 178
179/*
180 MainServer.Instance.AddHTTPHandler(regionimage, 180 MainServer.Instance.AddHTTPHandler(regionimage,
181 new GenericHTTPDOSProtector(OnHTTPGetMapImage, OnHTTPThrottled, new BasicDosProtectorOptions() 181 new GenericHTTPDOSProtector(OnHTTPGetMapImage, OnHTTPThrottled, new BasicDosProtectorOptions()
182 { 182 {
@@ -187,6 +187,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
187 RequestTimeSpan = TimeSpan.FromSeconds(10), 187 RequestTimeSpan = TimeSpan.FromSeconds(10),
188 ThrottledAction = BasicDOSProtector.ThrottleAction.DoThrottledMethod 188 ThrottledAction = BasicDOSProtector.ThrottleAction.DoThrottledMethod
189 }).Process); 189 }).Process);
190*/
191
192 MainServer.Instance.AddHTTPHandler(regionimage, OnHTTPGetMapImage);
190 MainServer.Instance.AddLLSDHandler( 193 MainServer.Instance.AddLLSDHandler(
191 "/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest); 194 "/MAP/MapItems/" + m_scene.RegionInfo.RegionHandle.ToString(), HandleRemoteMapItemRequest);
192 195
@@ -222,12 +225,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
222 public void OnRegisterCaps(UUID agentID, Caps caps) 225 public void OnRegisterCaps(UUID agentID, Caps caps)
223 { 226 {
224 //m_log.DebugFormat("[WORLD MAP]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); 227 //m_log.DebugFormat("[WORLD MAP]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
225 string capsBase = "/CAPS/" + caps.CapsObjectPath; 228 string capspath = "/CAPS/" + UUID.Random();
226 caps.RegisterHandler( 229 caps.RegisterHandler(
227 "MapLayer", 230 "MapLayer",
228 new RestStreamHandler( 231 new RestStreamHandler(
229 "POST", 232 "POST",
230 capsBase + m_mapLayerPath, 233 capspath,
231 (request, path, param, httpRequest, httpResponse) 234 (request, path, param, httpRequest, httpResponse)
232 => MapLayerRequest(request, path, param, agentID, caps), 235 => MapLayerRequest(request, path, param, agentID, caps),
233 "MapLayer", 236 "MapLayer",
@@ -1142,10 +1145,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1142 1145
1143 protected void MapBlockSendThread() 1146 protected void MapBlockSendThread()
1144 { 1147 {
1148 List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>();
1145 while (true) 1149 while (true)
1146 { 1150 {
1147 List<MapBlockRequestData> thisRunData = new List<MapBlockRequestData>();
1148
1149 m_mapBlockRequestEvent.WaitOne(); 1151 m_mapBlockRequestEvent.WaitOne();
1150 lock (m_mapBlockRequestEvent) 1152 lock (m_mapBlockRequestEvent)
1151 { 1153 {
@@ -1162,13 +1164,18 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1162 m_mapBlockRequestEvent.Reset(); 1164 m_mapBlockRequestEvent.Reset();
1163 } 1165 }
1164 1166
1165 foreach (MapBlockRequestData req in thisRunData) 1167 if(thisRunData.Count > 0)
1166 { 1168 {
1167 // Null client stops thread 1169 foreach (MapBlockRequestData req in thisRunData)
1168 if (req.client == null) 1170 {
1169 return; 1171 // Null client stops thread
1172 if (req.client == null)
1173 return;
1174
1175 GetAndSendBlocksInternal(req.client, req.minX, req.minY, req.maxX, req.maxY, req.flags);
1176 }
1170 1177
1171 GetAndSendBlocksInternal(req.client, req.minX, req.minY, req.maxX, req.maxY, req.flags); 1178 thisRunData.Clear();
1172 } 1179 }
1173 1180
1174 Thread.Sleep(50); 1181 Thread.Sleep(50);
@@ -1590,6 +1597,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1590 { 1597 {
1591 m_scene.AssetService.Delete(lastID.ToString()); 1598 m_scene.AssetService.Delete(lastID.ToString());
1592 m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Zero; 1599 m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Zero;
1600 myMapImageJPEG = new byte[0];
1593 needRegionSave = true; 1601 needRegionSave = true;
1594 } 1602 }
1595 1603
@@ -1648,7 +1656,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1648 asset.Flags = AssetFlags.Maptile; 1656 asset.Flags = AssetFlags.Maptile;
1649 1657
1650 // Store the new one 1658 // Store the new one
1651 m_log.DebugFormat("[WORLD MAP]: Storing map tile {0} for {1}", asset.ID, m_scene.RegionInfo.RegionName); 1659 m_log.DebugFormat("[WORLD MAP]: Storing map image {0} for {1}", asset.ID, m_scene.RegionInfo.RegionName);
1652 1660
1653 m_scene.AssetService.Store(asset); 1661 m_scene.AssetService.Store(asset);
1654 1662
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 8683599..6ff3049 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -1881,7 +1881,7 @@ namespace OpenSim.Region.Framework.Scenes
1881 catch (Exception e) 1881 catch (Exception e)
1882 { 1882 {
1883 m_log.ErrorFormat( 1883 m_log.ErrorFormat(
1884 "[EVENT MANAGER]: Delegate for TriggerOnAttach failed - continuing. {0} {1}", 1884 "[EVENT MANAGER]: Delegate for TriggerGroupMove failed - continuing. {0} {1}",
1885 e.Message, e.StackTrace); 1885 e.Message, e.StackTrace);
1886 } 1886 }
1887 } 1887 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 4d491d1..a5abe76 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -340,13 +340,11 @@ namespace OpenSim.Region.Framework.Scenes
340 obj.ObjectGrabHandler(localID, offsetPos, remoteClient); 340 obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
341 341
342 // If the touched prim handles touches, deliver it 342 // If the touched prim handles touches, deliver it
343 // If not, deliver to root prim
344 if ((part.ScriptEvents & scriptEvents.touch_start) != 0) 343 if ((part.ScriptEvents & scriptEvents.touch_start) != 0)
345 EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg); 344 EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
346 345
347 // Deliver to the root prim if the touched prim doesn't handle touches 346 // Deliver to the root prim if the touched prim doesn't handle touches
348 // or if we're meant to pass on touches anyway. Don't send to root prim 347 // or if we're meant to pass on touches anyway.
349 // if prim touched is the root prim as we just did it
350 if (((part.ScriptEvents & scriptEvents.touch_start) == 0) || 348 if (((part.ScriptEvents & scriptEvents.touch_start) == 0) ||
351 (part.PassTouches && (part.LocalId != obj.RootPart.LocalId))) 349 (part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
352 { 350 {
@@ -381,12 +379,10 @@ namespace OpenSim.Region.Framework.Scenes
381 surfaceArg = surfaceArgs[0]; 379 surfaceArg = surfaceArgs[0];
382 380
383 // If the touched prim handles touches, deliver it 381 // If the touched prim handles touches, deliver it
384 // If not, deliver to root prim
385 if ((part.ScriptEvents & scriptEvents.touch) != 0) 382 if ((part.ScriptEvents & scriptEvents.touch) != 0)
386 EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg); 383 EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
387 // Deliver to the root prim if the touched prim doesn't handle touches 384 // Deliver to the root prim if the touched prim doesn't handle touches
388 // or if we're meant to pass on touches anyway. Don't send to root prim 385 // or if we're meant to pass on touches anyway.
389 // if prim touched is the root prim as we just did it
390 if (((part.ScriptEvents & scriptEvents.touch) == 0) || 386 if (((part.ScriptEvents & scriptEvents.touch) == 0) ||
391 (part.PassTouches && (part.LocalId != group.RootPart.LocalId))) 387 (part.PassTouches && (part.LocalId != group.RootPart.LocalId)))
392 { 388 {
@@ -400,18 +396,77 @@ namespace OpenSim.Region.Framework.Scenes
400 if (part == null) 396 if (part == null)
401 return; 397 return;
402 398
403 SceneObjectGroup obj = part.ParentGroup; 399 SceneObjectGroup grp = part.ParentGroup;
404 400
405 SurfaceTouchEventArgs surfaceArg = null; 401 SurfaceTouchEventArgs surfaceArg = null;
406 if (surfaceArgs != null && surfaceArgs.Count > 0) 402 if (surfaceArgs != null && surfaceArgs.Count > 0)
407 surfaceArg = surfaceArgs[0]; 403 surfaceArg = surfaceArgs[0];
408 404
409 // If the touched prim handles touches, deliver it 405 // If the touched prim handles touches, deliver it
410 // If not, deliver to root prim
411 if ((part.ScriptEvents & scriptEvents.touch_end) != 0) 406 if ((part.ScriptEvents & scriptEvents.touch_end) != 0)
412 EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg); 407 EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg);
413 else 408 // if not or PassTouchs, send it also to root.
414 EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg); 409 if (((part.ScriptEvents & scriptEvents.touch_end) == 0) ||
410 (part.PassTouches && (part.LocalId != grp.RootPart.LocalId)))
411 {
412 EventManager.TriggerObjectDeGrab(grp.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
413 }
414 }
415
416 /// <summary>
417 /// Start spinning the given object
418 /// </summary>
419 /// <param name="objectID"></param>
420 /// <param name="rotation"></param>
421 /// <param name="remoteClient"></param>
422 public virtual void ProcessSpinStart(UUID objectID, IClientAPI remoteClient)
423 {
424 SceneObjectGroup group = GetGroupByPrim(objectID);
425 if (group != null)
426 {
427 if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
428 {
429 group.SpinStart(remoteClient);
430 }
431 }
432 }
433
434 /// <summary>
435 /// Spin the given object
436 /// </summary>
437 /// <param name="objectID"></param>
438 /// <param name="rotation"></param>
439 /// <param name="remoteClient"></param>
440 public virtual void ProcessSpinObject(UUID objectID, Quaternion rotation, IClientAPI remoteClient)
441 {
442 SceneObjectGroup group = GetGroupByPrim(objectID);
443 if (group != null)
444 {
445 if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
446 {
447 group.SpinMovement(rotation, remoteClient);
448 }
449 // This is outside the above permissions condition
450 // so that if the object is locked the client moving the object
451 // get's it's position on the simulator even if it was the same as before
452 // This keeps the moving user's client in sync with the rest of the world.
453 group.SendGroupTerseUpdate();
454 }
455 }
456
457 public virtual void ProcessSpinObjectStop(UUID objectID, IClientAPI remoteClient)
458 {
459/* no op for now
460 SceneObjectGroup group = GetGroupByPrim(objectID);
461 if (group != null)
462 {
463 if (Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
464 {
465// group.SpinMovement(rotation, remoteClient);
466 }
467 group.SendGroupTerseUpdate();
468 }
469*/
415 } 470 }
416 471
417 public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID, 472 public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID,
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0d6af77..d77b8ae 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3329,8 +3329,6 @@ namespace OpenSim.Region.Framework.Scenes
3329 client.OnObjectRequest += RequestPrim; 3329 client.OnObjectRequest += RequestPrim;
3330 client.OnObjectSelect += SelectPrim; 3330 client.OnObjectSelect += SelectPrim;
3331 client.OnObjectDeselect += DeselectPrim; 3331 client.OnObjectDeselect += DeselectPrim;
3332 client.OnSpinStart += m_sceneGraph.SpinStart;
3333 client.OnSpinUpdate += m_sceneGraph.SpinObject;
3334 client.OnDeRezObject += DeRezObjects; 3332 client.OnDeRezObject += DeRezObjects;
3335 3333
3336 client.OnObjectName += m_sceneGraph.PrimName; 3334 client.OnObjectName += m_sceneGraph.PrimName;
@@ -3346,6 +3344,9 @@ namespace OpenSim.Region.Framework.Scenes
3346 client.OnGrabObject += ProcessObjectGrab; 3344 client.OnGrabObject += ProcessObjectGrab;
3347 client.OnGrabUpdate += ProcessObjectGrabUpdate; 3345 client.OnGrabUpdate += ProcessObjectGrabUpdate;
3348 client.OnDeGrabObject += ProcessObjectDeGrab; 3346 client.OnDeGrabObject += ProcessObjectDeGrab;
3347 client.OnSpinStart += ProcessSpinStart;
3348 client.OnSpinUpdate += ProcessSpinObject;
3349 client.OnSpinStop += ProcessSpinObjectStop;
3349 client.OnUndo += m_sceneGraph.HandleUndo; 3350 client.OnUndo += m_sceneGraph.HandleUndo;
3350 client.OnRedo += m_sceneGraph.HandleRedo; 3351 client.OnRedo += m_sceneGraph.HandleRedo;
3351 client.OnObjectDescription += m_sceneGraph.PrimDescription; 3352 client.OnObjectDescription += m_sceneGraph.PrimDescription;
@@ -3456,8 +3457,6 @@ namespace OpenSim.Region.Framework.Scenes
3456 client.OnObjectRequest -= RequestPrim; 3457 client.OnObjectRequest -= RequestPrim;
3457 client.OnObjectSelect -= SelectPrim; 3458 client.OnObjectSelect -= SelectPrim;
3458 client.OnObjectDeselect -= DeselectPrim; 3459 client.OnObjectDeselect -= DeselectPrim;
3459 client.OnSpinStart -= m_sceneGraph.SpinStart;
3460 client.OnSpinUpdate -= m_sceneGraph.SpinObject;
3461 client.OnDeRezObject -= DeRezObjects; 3460 client.OnDeRezObject -= DeRezObjects;
3462 client.OnObjectName -= m_sceneGraph.PrimName; 3461 client.OnObjectName -= m_sceneGraph.PrimName;
3463 client.OnObjectClickAction -= m_sceneGraph.PrimClickAction; 3462 client.OnObjectClickAction -= m_sceneGraph.PrimClickAction;
@@ -3472,6 +3471,9 @@ namespace OpenSim.Region.Framework.Scenes
3472 client.OnGrabObject -= ProcessObjectGrab; 3471 client.OnGrabObject -= ProcessObjectGrab;
3473 client.OnGrabUpdate -= ProcessObjectGrabUpdate; 3472 client.OnGrabUpdate -= ProcessObjectGrabUpdate;
3474 client.OnDeGrabObject -= ProcessObjectDeGrab; 3473 client.OnDeGrabObject -= ProcessObjectDeGrab;
3474 client.OnSpinStart -= ProcessSpinStart;
3475 client.OnSpinUpdate -= ProcessSpinObject;
3476 client.OnSpinStop -= ProcessSpinObjectStop;
3475 client.OnUndo -= m_sceneGraph.HandleUndo; 3477 client.OnUndo -= m_sceneGraph.HandleUndo;
3476 client.OnRedo -= m_sceneGraph.HandleRedo; 3478 client.OnRedo -= m_sceneGraph.HandleRedo;
3477 client.OnObjectDescription -= m_sceneGraph.PrimDescription; 3479 client.OnObjectDescription -= m_sceneGraph.PrimDescription;
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 0e5720f..77c66b6 100755
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1674,72 +1674,6 @@ namespace OpenSim.Region.Framework.Scenes
1674 } 1674 }
1675 } 1675 }
1676 } 1676 }
1677/* moved to scene ProcessObjectGrabUpdate
1678 /// <summary>
1679 /// Move the given object
1680 /// </summary>
1681 /// <param name="objectID"></param>
1682 /// <param name="offset"></param>
1683 /// <param name="pos"></param>
1684 /// <param name="remoteClient"></param>
1685 protected internal void MoveObject(UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
1686 {
1687 SceneObjectGroup group = GetGroupByPrim(objectID);
1688 if (group != null)
1689 {
1690 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
1691 {
1692 group.GrabMovement(objectID, offset, pos, remoteClient);
1693 }
1694
1695 // This is outside the above permissions condition
1696 // so that if the object is locked the client moving the object
1697 // get's it's position on the simulator even if it was the same as before
1698 // This keeps the moving user's client in sync with the rest of the world.
1699 group.SendGroupTerseUpdate();
1700 }
1701 }
1702*/
1703 /// <summary>
1704 /// Start spinning the given object
1705 /// </summary>
1706 /// <param name="objectID"></param>
1707 /// <param name="rotation"></param>
1708 /// <param name="remoteClient"></param>
1709 protected internal void SpinStart(UUID objectID, IClientAPI remoteClient)
1710 {
1711 SceneObjectGroup group = GetGroupByPrim(objectID);
1712 if (group != null)
1713 {
1714 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
1715 {
1716 group.SpinStart(remoteClient);
1717 }
1718 }
1719 }
1720
1721 /// <summary>
1722 /// Spin the given object
1723 /// </summary>
1724 /// <param name="objectID"></param>
1725 /// <param name="rotation"></param>
1726 /// <param name="remoteClient"></param>
1727 protected internal void SpinObject(UUID objectID, Quaternion rotation, IClientAPI remoteClient)
1728 {
1729 SceneObjectGroup group = GetGroupByPrim(objectID);
1730 if (group != null)
1731 {
1732 if (m_parentScene.Permissions.CanMoveObject(group.UUID, remoteClient.AgentId))// && PermissionsMngr.)
1733 {
1734 group.SpinMovement(rotation, remoteClient);
1735 }
1736 // This is outside the above permissions condition
1737 // so that if the object is locked the client moving the object
1738 // get's it's position on the simulator even if it was the same as before
1739 // This keeps the moving user's client in sync with the rest of the world.
1740 group.SendGroupTerseUpdate();
1741 }
1742 }
1743 1677
1744 /// <summary> 1678 /// <summary>
1745 /// 1679 ///
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index b7c5b6b..17dfb85 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -79,7 +79,8 @@ namespace OpenSim.Region.Framework.Scenes
79 touch_end = 536870912, 79 touch_end = 536870912,
80 touch_start = 2097152, 80 touch_start = 2097152,
81 transaction_result = 33554432, 81 transaction_result = 33554432,
82 object_rez = 4194304 82 object_rez = 4194304,
83 anytouch = touch | touch_end | touch_start
83 } 84 }
84 85
85 public struct scriptPosTarget 86 public struct scriptPosTarget
@@ -3497,34 +3498,26 @@ namespace OpenSim.Region.Framework.Scenes
3497 { 3498 {
3498 if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) 3499 if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
3499 { 3500 {
3501 if (BlockGrabOverride)
3502 return;
3503
3500 SceneObjectPart part = GetPart(partID); 3504 SceneObjectPart part = GetPart(partID);
3501 3505
3502 if (part == null) 3506 if (part == null)
3503 return; 3507 return;
3504 3508
3509 if (part.BlockGrab)
3510 return;
3511
3505 PhysicsActor pa = m_rootPart.PhysActor; 3512 PhysicsActor pa = m_rootPart.PhysActor;
3506 3513
3507 if (pa != null) 3514 if (pa != null && pa.IsPhysical)
3508 { 3515 {
3509 if (pa.IsPhysical) 3516 // empirically convert distance diference to a impulse
3510 { 3517 Vector3 grabforce = pos - AbsolutePosition;
3511 if (!BlockGrabOverride && !part.BlockGrab) 3518 grabforce = grabforce * (pa.Mass * 0.1f);
3512 { 3519 pa.AddForce(grabforce, false);
3513/* Vector3 llmoveforce = pos - AbsolutePosition; 3520 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
3514 Vector3 grabforce = llmoveforce;
3515 grabforce = (grabforce / 10) * pa.Mass;
3516 */
3517 // empirically convert distance diference to a impulse
3518 Vector3 grabforce = pos - AbsolutePosition;
3519 grabforce = grabforce * (pa.Mass/ 10.0f);
3520 pa.AddForce(grabforce, false);
3521 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
3522 }
3523 }
3524 else
3525 {
3526 NonPhysicalGrabMovement(pos);
3527 }
3528 } 3521 }
3529 else 3522 else
3530 { 3523 {
@@ -3553,6 +3546,8 @@ namespace OpenSim.Region.Framework.Scenes
3553 /// <param name="remoteClient"></param> 3546 /// <param name="remoteClient"></param>
3554 public void SpinStart(IClientAPI remoteClient) 3547 public void SpinStart(IClientAPI remoteClient)
3555 { 3548 {
3549 if (BlockGrabOverride || m_rootPart.BlockGrab)
3550 return;
3556 if (m_scene.EventManager.TriggerGroupSpinStart(UUID)) 3551 if (m_scene.EventManager.TriggerGroupSpinStart(UUID))
3557 { 3552 {
3558 PhysicsActor pa = m_rootPart.PhysActor; 3553 PhysicsActor pa = m_rootPart.PhysActor;
@@ -3600,46 +3595,48 @@ namespace OpenSim.Region.Framework.Scenes
3600 // but it will result in over-shoot or under-shoot of the target orientation. 3595 // but it will result in over-shoot or under-shoot of the target orientation.
3601 // For the end user, this means that ctrl+shift+drag can be used for relative, 3596 // For the end user, this means that ctrl+shift+drag can be used for relative,
3602 // but not absolute, adjustments of orientation for physical prims. 3597 // but not absolute, adjustments of orientation for physical prims.
3598
3599 if (BlockGrabOverride || m_rootPart.BlockGrab)
3600 return;
3601
3603 if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation)) 3602 if (m_scene.EventManager.TriggerGroupSpin(UUID, newOrientation))
3604 { 3603 {
3605 PhysicsActor pa = m_rootPart.PhysActor; 3604 PhysicsActor pa = m_rootPart.PhysActor;
3606 3605
3607 if (pa != null) 3606 if (pa != null && pa.IsPhysical)
3608 { 3607 {
3609 if (pa.IsPhysical) 3608 if (m_rootPart.IsWaitingForFirstSpinUpdatePacket)
3610 { 3609 {
3611 if (m_rootPart.IsWaitingForFirstSpinUpdatePacket) 3610 // first time initialization of "old" orientation for calculation of delta rotations
3612 { 3611 m_rootPart.SpinOldOrientation = newOrientation;
3613 // first time initialization of "old" orientation for calculation of delta rotations 3612 m_rootPart.IsWaitingForFirstSpinUpdatePacket = false;
3614 m_rootPart.SpinOldOrientation = newOrientation;
3615 m_rootPart.IsWaitingForFirstSpinUpdatePacket = false;
3616 }
3617 else
3618 {
3619 // save and update old orientation
3620 Quaternion old = m_rootPart.SpinOldOrientation;
3621 m_rootPart.SpinOldOrientation = newOrientation;
3622 //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old);
3623 //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation);
3624
3625 // compute difference between previous old rotation and new incoming rotation
3626 Quaternion minimalRotationFromQ1ToQ2 = Quaternion.Inverse(old) * newOrientation;
3627
3628 float rotationAngle;
3629 Vector3 rotationAxis;
3630 minimalRotationFromQ1ToQ2.GetAxisAngle(out rotationAxis, out rotationAngle);
3631 rotationAxis.Normalize();
3632
3633 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
3634 Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z);
3635 spinforce = (spinforce/8) * pa.Mass; // 8 is an arbitrary torque scaling factor
3636 pa.AddAngularForce(spinforce,true);
3637 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
3638 }
3639 } 3613 }
3640 else 3614 else
3641 { 3615 {
3642 NonPhysicalSpinMovement(newOrientation); 3616 // save and update old orientation
3617 Quaternion old = m_rootPart.SpinOldOrientation;
3618 m_rootPart.SpinOldOrientation = newOrientation;
3619 //m_log.Error("[SCENE OBJECT GROUP]: Old orientation is " + old);
3620 //m_log.Error("[SCENE OBJECT GROUP]: Incoming new orientation is " + newOrientation);
3621
3622 // compute difference between previous old rotation and new incoming rotation
3623 Quaternion minimalRotationFromQ1ToQ2 = newOrientation * Quaternion.Inverse(old);
3624
3625 float rotationAngle;
3626 Vector3 spinforce;
3627 minimalRotationFromQ1ToQ2.GetAxisAngle(out spinforce, out rotationAngle);
3628 if(Math.Abs(rotationAngle)< 0.001)
3629 return;
3630
3631 spinforce.Normalize();
3632
3633 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
3634 if(rotationAngle > 0)
3635 spinforce = spinforce * pa.Mass * 0.1f; // 0.1 is an arbitrary torque scaling factor
3636 else
3637 spinforce = spinforce * pa.Mass * -0.1f; // 0.1 is an arbitrary torque scaling
3638 pa.AddAngularForce(spinforce,true);
3639 m_scene.PhysicsScene.AddPhysicsActorTaint(pa);
3643 } 3640 }
3644 } 3641 }
3645 else 3642 else
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index cb7422b..bb6e89b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3335,11 +3335,16 @@ namespace OpenSim.Region.Framework.Scenes
3335 Velocity = Vector3.Zero; 3335 Velocity = Vector3.Zero;
3336 m_AngularVelocity = Vector3.Zero; 3336 m_AngularVelocity = Vector3.Zero;
3337 3337
3338 m_requestedSitTargetID = 0;
3339 part.AddSittingAvatar(this);
3340
3341 ParentPart = part;
3342 ParentID = part.LocalId;
3343
3338 Vector3 cameraAtOffset = part.GetCameraAtOffset(); 3344 Vector3 cameraAtOffset = part.GetCameraAtOffset();
3339 Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); 3345 Vector3 cameraEyeOffset = part.GetCameraEyeOffset();
3340 bool forceMouselook = part.GetForceMouselook(); 3346 bool forceMouselook = part.GetForceMouselook();
3341 3347
3342
3343 if (!part.IsRoot) 3348 if (!part.IsRoot)
3344 { 3349 {
3345 Orientation = part.RotationOffset * Orientation; 3350 Orientation = part.RotationOffset * Orientation;
@@ -3365,13 +3370,7 @@ namespace OpenSim.Region.Framework.Scenes
3365 3370
3366 ControllingClient.SendSitResponse( 3371 ControllingClient.SendSitResponse(
3367 part.ParentGroup.UUID, offset, Orientation, true, cameraAtOffset, cameraEyeOffset, forceMouselook); 3372 part.ParentGroup.UUID, offset, Orientation, true, cameraAtOffset, cameraEyeOffset, forceMouselook);
3368
3369 3373
3370 m_requestedSitTargetID = 0;
3371 part.AddSittingAvatar(this);
3372
3373 ParentPart = part;
3374 ParentID = part.LocalId;
3375 3374
3376 SendAvatarDataToAllAgents(); 3375 SendAvatarDataToAllAgents();
3377 3376
@@ -5560,6 +5559,13 @@ namespace OpenSim.Region.Framework.Scenes
5560 5559
5561 public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID) 5560 public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID)
5562 { 5561 {
5562 foreach (ScriptControllers c in scriptedcontrols.Values)
5563 {
5564 SceneObjectGroup sog = m_scene.GetSceneObjectGroup(c.objectID);
5565 if(sog != null && !sog.IsDeleted && sog.RootPart.PhysActor != null)
5566 sog.RootPart.PhysActor.OnPhysicsRequestingCameraData -= physActor_OnPhysicsRequestingCameraData;
5567 }
5568
5563 IgnoredControls = ScriptControlled.CONTROL_ZERO; 5569 IgnoredControls = ScriptControlled.CONTROL_ZERO;
5564 lock (scriptedcontrols) 5570 lock (scriptedcontrols)
5565 { 5571 {
@@ -5568,6 +5574,26 @@ namespace OpenSim.Region.Framework.Scenes
5568 ControllingClient.SendTakeControls(int.MaxValue, false, false); 5574 ControllingClient.SendTakeControls(int.MaxValue, false, false);
5569 } 5575 }
5570 5576
5577 public void HandleRevokePermissions(UUID objectID, uint permissions )
5578 {
5579
5580 // still skeleton code
5581 if((permissions & (16 | 0x8000 )) == 0) //PERMISSION_TRIGGER_ANIMATION | PERMISSION_OVERRIDE_ANIMATIONS
5582 return;
5583 if(objectID == m_scene.RegionInfo.RegionID) // for all objects
5584 {
5585
5586 }
5587 else
5588 {
5589 SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
5590 if(part != null)
5591 {
5592
5593 }
5594 }
5595 }
5596
5571 public void ClearControls() 5597 public void ClearControls()
5572 { 5598 {
5573 IgnoredControls = ScriptControlled.CONTROL_ZERO; 5599 IgnoredControls = ScriptControlled.CONTROL_ZERO;
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
index e95889d..006b730 100644
--- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
@@ -63,11 +63,16 @@ namespace OpenSim.Region.OptionalModules.Materials
63 63
64 public Type ReplaceableInterface { get { return null; } } 64 public Type ReplaceableInterface { get { return null; } }
65 65
66 IImprovedAssetCache m_cache;
66 private Scene m_scene = null; 67 private Scene m_scene = null;
67 private bool m_enabled = false; 68 private bool m_enabled = false;
68 private int m_maxMaterialsPerTransaction = 50; 69 private int m_maxMaterialsPerTransaction = 50;
69 70
70 public Dictionary<UUID, OSDMap> m_regionMaterials = new Dictionary<UUID, OSDMap>(); 71 public Dictionary<UUID, OSDMap> m_Materials = new Dictionary<UUID, OSDMap>();
72 public Dictionary<UUID, int> m_MaterialsRefCount = new Dictionary<UUID, int>();
73
74 private Dictionary<ulong, AssetBase> m_changes = new Dictionary<ulong, AssetBase>();
75 private Dictionary<ulong, double> m_changesTime = new Dictionary<ulong, double>();
71 76
72 public void Initialise(IConfigSource source) 77 public void Initialise(IConfigSource source)
73 { 78 {
@@ -98,6 +103,56 @@ namespace OpenSim.Region.OptionalModules.Materials
98 m_scene = scene; 103 m_scene = scene;
99 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; 104 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
100 m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; 105 m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene;
106 m_scene.EventManager.OnBackup += EventManager_OnBackup;
107 }
108
109 private void EventManager_OnBackup(ISimulationDataService datastore, bool forcedBackup)
110 {
111 List<AssetBase> toStore;
112 List<ulong> hashlist;
113
114
115 lock (m_Materials)
116 {
117 if(m_changes.Count == 0)
118 return;
119
120 if(forcedBackup)
121 {
122 toStore = new List<AssetBase>(m_changes.Values);
123 m_changes.Clear();
124 m_changesTime.Clear();
125 }
126 else
127 {
128 toStore = new List<AssetBase>();
129 hashlist = new List<ulong>();
130 double storetime = Util.GetTimeStampMS() - 60000;
131 foreach(KeyValuePair<ulong,double> kvp in m_changesTime)
132 {
133 if(kvp.Value < storetime)
134 {
135 toStore.Add(m_changes[kvp.Key]);
136 hashlist.Add(kvp.Key);
137 }
138 }
139 foreach(ulong u in hashlist)
140 {
141 m_changesTime.Remove(u);
142 m_changes.Remove(u);
143 }
144 }
145
146 if(toStore.Count > 0)
147 Util.FireAndForget(delegate
148 {
149 foreach(AssetBase a in toStore)
150 {
151 a.Local = false;
152 m_scene.AssetService.Store(a);
153 }
154 });
155 }
101 } 156 }
102 157
103 private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) 158 private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj)
@@ -133,7 +188,7 @@ namespace OpenSim.Region.OptionalModules.Materials
133 IRequestHandler renderMaterialsPutHandler 188 IRequestHandler renderMaterialsPutHandler
134 = new RestStreamHandler("PUT", capsBase + "/", 189 = new RestStreamHandler("PUT", capsBase + "/",
135 (request, path, param, httpRequest, httpResponse) 190 (request, path, param, httpRequest, httpResponse)
136 => RenderMaterialsPostCap(request, agentID), 191 => RenderMaterialsPutCap(request, agentID),
137 "RenderMaterials", null); 192 "RenderMaterials", null);
138 MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); 193 MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler);
139 } 194 }
@@ -145,12 +200,14 @@ namespace OpenSim.Region.OptionalModules.Materials
145 200
146 m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; 201 m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps;
147 m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; 202 m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene;
203 m_scene.EventManager.OnBackup -= EventManager_OnBackup;
148 } 204 }
149 205
150 public void RegionLoaded(Scene scene) 206 public void RegionLoaded(Scene scene)
151 { 207 {
152 if (!m_enabled) return; 208 if (!m_enabled) return;
153 209
210 m_cache = scene.RequestModuleInterface<IImprovedAssetCache>();
154 ISimulatorFeaturesModule featuresModule = scene.RequestModuleInterface<ISimulatorFeaturesModule>(); 211 ISimulatorFeaturesModule featuresModule = scene.RequestModuleInterface<ISimulatorFeaturesModule>();
155 if (featuresModule != null) 212 if (featuresModule != null)
156 featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest; 213 featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest;
@@ -203,8 +260,17 @@ namespace OpenSim.Region.OptionalModules.Materials
203 { 260 {
204 try 261 try
205 { 262 {
206 lock (m_regionMaterials) 263 lock (m_Materials)
207 m_regionMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; 264 {
265 UUID id = matMap["ID"].AsUUID();
266 if(m_Materials.ContainsKey(id))
267 m_MaterialsRefCount[id]++;
268 else
269 {
270 m_Materials[id] = (OSDMap)matMap["Material"];
271 m_MaterialsRefCount[id] = 1;
272 }
273 }
208 } 274 }
209 catch (Exception e) 275 catch (Exception e)
210 { 276 {
@@ -252,18 +318,22 @@ namespace OpenSim.Region.OptionalModules.Materials
252 if (id == UUID.Zero) 318 if (id == UUID.Zero)
253 return; 319 return;
254 320
255 lock (m_regionMaterials) 321 lock (m_Materials)
256 { 322 {
257 if (m_regionMaterials.ContainsKey(id)) 323 if (m_Materials.ContainsKey(id))
324 {
325 m_MaterialsRefCount[id]++;
258 return; 326 return;
259 327 }
260 byte[] data = m_scene.AssetService.GetData(id.ToString()); 328
261 if (data == null) 329 AssetBase matAsset = m_scene.AssetService.Get(id.ToString());
330 if (matAsset == null || matAsset.Data == null || matAsset.Data.Length == 0 )
262 { 331 {
263 m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id); 332 m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id);
264 return; 333 return;
265 } 334 }
266 335
336 byte[] data = matAsset.Data;
267 OSDMap mat; 337 OSDMap mat;
268 try 338 try
269 { 339 {
@@ -275,7 +345,8 @@ namespace OpenSim.Region.OptionalModules.Materials
275 return; 345 return;
276 } 346 }
277 347
278 m_regionMaterials[id] = mat; 348 m_Materials[id] = mat;
349 m_MaterialsRefCount[id] = 1;
279 } 350 }
280 } 351 }
281 352
@@ -284,8 +355,6 @@ namespace OpenSim.Region.OptionalModules.Materials
284 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); 355 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
285 OSDMap resp = new OSDMap(); 356 OSDMap resp = new OSDMap();
286 357
287 OSDMap materialsFromViewer = null;
288
289 OSDArray respArr = new OSDArray(); 358 OSDArray respArr = new OSDArray();
290 359
291 if (req.ContainsKey("Zipped")) 360 if (req.ContainsKey("Zipped"))
@@ -298,150 +367,220 @@ namespace OpenSim.Region.OptionalModules.Materials
298 { 367 {
299 osd = ZDecompressBytesToOsd(inBytes); 368 osd = ZDecompressBytesToOsd(inBytes);
300 369
301 if (osd != null) 370 if (osd != null && osd is OSDArray)
302 { 371 {
303 if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries 372 foreach (OSD elem in (OSDArray)osd)
304 { 373 {
305 foreach (OSD elem in (OSDArray)osd) 374 try
306 { 375 {
307 try 376 UUID id = new UUID(elem.AsBinary(), 0);
308 {
309 UUID id = new UUID(elem.AsBinary(), 0);
310 377
311 lock (m_regionMaterials) 378 lock (m_Materials)
379 {
380 if (m_Materials.ContainsKey(id))
312 { 381 {
313 if (m_regionMaterials.ContainsKey(id)) 382 OSDMap matMap = new OSDMap();
314 { 383 matMap["ID"] = OSD.FromBinary(id.GetBytes());
315 OSDMap matMap = new OSDMap(); 384 matMap["Material"] = m_Materials[id];
316 matMap["ID"] = OSD.FromBinary(id.GetBytes()); 385 respArr.Add(matMap);
317 matMap["Material"] = m_regionMaterials[id]; 386 }
318 respArr.Add(matMap); 387 else
319 } 388 {
320 else 389 m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());
321 {
322 m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());
323 390
324 // Theoretically we could try to load the material from the assets service, 391 // Theoretically we could try to load the material from the assets service,
325 // but that shouldn't be necessary because the viewer should only request 392 // but that shouldn't be necessary because the viewer should only request
326 // materials that exist in a prim on the region, and all of these materials 393 // materials that exist in a prim on the region, and all of these materials
327 // are already stored in m_regionMaterials. 394 // are already stored in m_regionMaterials.
328 }
329 } 395 }
330 } 396 }
331 catch (Exception e) 397 }
332 { 398 catch (Exception e)
333 m_log.Error("Error getting materials in response to viewer request", e); 399 {
334 continue; 400 m_log.Error("Error getting materials in response to viewer request", e);
335 } 401 continue;
336 } 402 }
337 } 403 }
338 else if (osd is OSDMap) // request to assign a material 404 }
339 { 405 }
340 materialsFromViewer = osd as OSDMap; 406 catch (Exception e)
407 {
408 m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e);
409 //return "";
410 }
411 }
412
413 resp["Zipped"] = ZCompressOSD(respArr, false);
414 string response = OSDParser.SerializeLLSDXmlString(resp);
415
416 //m_log.Debug("[Materials]: cap request: " + request);
417 //m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary()));
418 //m_log.Debug("[Materials]: cap response: " + response);
419 return response;
420 }
421
422 public string RenderMaterialsPutCap(string request, UUID agentID)
423 {
424 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
425 OSDMap resp = new OSDMap();
426
427 OSDMap materialsFromViewer = null;
428
429 OSDArray respArr = new OSDArray();
430
431 HashSet<SceneObjectPart> parts = new HashSet<SceneObjectPart>();
432 if (req.ContainsKey("Zipped"))
433 {
434 OSD osd = null;
435
436 byte[] inBytes = req["Zipped"].AsBinary();
437
438 try
439 {
440 osd = ZDecompressBytesToOsd(inBytes);
341 441
342 if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) 442 if (osd != null && osd is OSDMap)
443 {
444 materialsFromViewer = osd as OSDMap;
445
446 if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
447 {
448 OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
449 if (matsOsd is OSDArray)
343 { 450 {
344 OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; 451 OSDArray matsArr = matsOsd as OSDArray;
345 if (matsOsd is OSDArray)
346 {
347 OSDArray matsArr = matsOsd as OSDArray;
348 452
349 try 453 try
454 {
455 foreach (OSDMap matsMap in matsArr)
350 { 456 {
351 foreach (OSDMap matsMap in matsArr) 457 uint primLocalID = 0;
352 { 458 try {
353 uint primLocalID = 0; 459 primLocalID = matsMap["ID"].AsUInteger();
354 try { 460 }
355 primLocalID = matsMap["ID"].AsUInteger(); 461 catch (Exception e) {
356 } 462 m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
357 catch (Exception e) { 463 continue;
358 m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message); 464 }
359 continue;
360 }
361
362 OSDMap mat = null;
363 try
364 {
365 mat = matsMap["Material"] as OSDMap;
366 }
367 catch (Exception e)
368 {
369 m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
370 continue;
371 }
372 465
373 SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID); 466 SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
374 if (sop == null) 467 if (sop == null)
375 { 468 {
376 m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString()); 469 m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
377 continue; 470 continue;
378 } 471 }
379 472
380 if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID)) 473 if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
381 { 474 {
382 m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID); 475 m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
383 continue; 476 continue;
384 } 477 }
385 478
386 Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); 479 OSDMap mat = null;
387 if (te == null) 480 try
388 { 481 {
389 m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID); 482 mat = matsMap["Material"] as OSDMap;
390 continue; 483 }
391 } 484 catch (Exception e)
485 {
486 m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
487 continue;
488 }
392 489
490 Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
491 if (te == null)
492 {
493 m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID);
494 continue;
495 }
496
497 UUID id;
498 if (mat == null)
499 {
500 // This happens then the user removes a material from a prim
501 id = UUID.Zero;
502 }
503 else
504 {
505 id = getNewID(mat);
506 }
393 507
394 UUID id; 508 int face = -1;
395 if (mat == null) 509 UUID oldid = UUID.Zero;
396 { 510 if (matsMap.ContainsKey("Face"))
397 // This happens then the user removes a material from a prim 511 {
398 id = UUID.Zero; 512 face = matsMap["Face"].AsInteger();
399 } 513 Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face);
514 oldid = faceEntry.MaterialID;
515 faceEntry.MaterialID = id;
516 }
517 else
518 {
519 if (te.DefaultTexture == null)
520 m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID);
400 else 521 else
401 { 522 {
402 id = StoreMaterialAsAsset(agentID, mat, sop); 523 oldid = te.DefaultTexture.MaterialID;
524 te.DefaultTexture.MaterialID = id;
403 } 525 }
526 }
404 527
528 //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id);
405 529
406 int face = -1; 530 // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
531 sop.Shape.TextureEntry = te.GetBytes();
407 532
408 if (matsMap.ContainsKey("Face")) 533 lock(m_Materials)
409 { 534 {
410 face = matsMap["Face"].AsInteger(); 535 if(oldid != UUID.Zero)
411 Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face);
412 faceEntry.MaterialID = id;
413 }
414 else
415 { 536 {
416 if (te.DefaultTexture == null) 537 m_MaterialsRefCount[oldid]--;
417 m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID); 538 if(m_MaterialsRefCount[oldid] <= 0)
418 else 539 {
419 te.DefaultTexture.MaterialID = id; 540 m_Materials.Remove(oldid);
541 m_MaterialsRefCount.Remove(oldid);
542 m_cache.Expire(oldid.ToString());
543 }
420 } 544 }
421 545
422 //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id); 546 if(id != UUID.Zero)
423
424 // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
425 sop.Shape.TextureEntry = te.GetBytes();
426
427 if (sop.ParentGroup != null)
428 { 547 {
429 sop.TriggerScriptChangedEvent(Changed.TEXTURE); 548 AssetBase asset = CacheMaterialAsAsset(id, agentID, mat, sop);
430 sop.UpdateFlag = UpdateRequired.FULL; 549 if(asset != null)
431 sop.ParentGroup.HasGroupChanged = true; 550 {
432 sop.ScheduleFullUpdate(); 551 ulong materialHash = (ulong)primLocalID << 32;
552 if(face < 0)
553 materialHash += 0xffffffff;
554 else
555 materialHash +=(ulong)face;
556
557 m_changes[materialHash] = asset;
558 m_changesTime[materialHash] = Util.GetTimeStampMS();
559 }
433 } 560 }
434 } 561 }
562
563 if(!parts.Contains(sop))
564 parts.Add(sop);
435 } 565 }
436 catch (Exception e) 566
567 foreach(SceneObjectPart sop in parts)
437 { 568 {
438 m_log.Warn("[Materials]: exception processing received material ", e); 569 if (sop.ParentGroup != null && !sop.ParentGroup.IsDeleted)
570 {
571 sop.TriggerScriptChangedEvent(Changed.TEXTURE);
572 sop.ScheduleFullUpdate();
573 sop.ParentGroup.HasGroupChanged = true;
574 }
439 } 575 }
440 } 576 }
577 catch (Exception e)
578 {
579 m_log.Warn("[Materials]: exception processing received material ", e);
580 }
441 } 581 }
442 } 582 }
443 } 583 }
444
445 } 584 }
446 catch (Exception e) 585 catch (Exception e)
447 { 586 {
@@ -449,7 +588,6 @@ namespace OpenSim.Region.OptionalModules.Materials
449 //return ""; 588 //return "";
450 } 589 }
451 } 590 }
452
453 591
454 resp["Zipped"] = ZCompressOSD(respArr, false); 592 resp["Zipped"] = ZCompressOSD(respArr, false);
455 string response = OSDParser.SerializeLLSDXmlString(resp); 593 string response = OSDParser.SerializeLLSDXmlString(resp);
@@ -460,6 +598,40 @@ namespace OpenSim.Region.OptionalModules.Materials
460 return response; 598 return response;
461 } 599 }
462 600
601 private UUID getNewID(OSDMap mat)
602 {
603 // ugly and done twice but keep compatibility for now
604 Byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat));
605 using (var md5 = MD5.Create())
606 return new UUID(md5.ComputeHash(data), 0);
607 }
608
609 private AssetBase CacheMaterialAsAsset(UUID id, UUID agentID, OSDMap mat, SceneObjectPart sop)
610 {
611 AssetBase asset = null;
612 lock (m_Materials)
613 {
614 if (!m_Materials.ContainsKey(id))
615 {
616 m_Materials[id] = mat;
617 m_MaterialsRefCount[id] = 1;
618
619 byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat));
620
621 // This asset might exist already, but it's ok to try to store it again
622 string name = "Material " + ChooseMaterialName(mat, sop);
623 name = name.Substring(0, Math.Min(64, name.Length)).Trim();
624 asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, agentID.ToString());
625 asset.Data = data;
626 asset.Local = true;
627 m_cache.Cache(asset);
628 }
629 else
630 m_MaterialsRefCount[id]++;
631 }
632 return asset;
633 }
634
463 private UUID StoreMaterialAsAsset(UUID agentID, OSDMap mat, SceneObjectPart sop) 635 private UUID StoreMaterialAsAsset(UUID agentID, OSDMap mat, SceneObjectPart sop)
464 { 636 {
465 UUID id; 637 UUID id;
@@ -469,11 +641,12 @@ namespace OpenSim.Region.OptionalModules.Materials
469 using (var md5 = MD5.Create()) 641 using (var md5 = MD5.Create())
470 id = new UUID(md5.ComputeHash(data), 0); 642 id = new UUID(md5.ComputeHash(data), 0);
471 643
472 lock (m_regionMaterials) 644 lock (m_Materials)
473 { 645 {
474 if (!m_regionMaterials.ContainsKey(id)) 646 if (!m_Materials.ContainsKey(id))
475 { 647 {
476 m_regionMaterials[id] = mat; 648 m_Materials[id] = mat;
649 m_MaterialsRefCount[id] = 1;
477 650
478 // This asset might exist already, but it's ok to try to store it again 651 // This asset might exist already, but it's ok to try to store it again
479 string name = "Material " + ChooseMaterialName(mat, sop); 652 string name = "Material " + ChooseMaterialName(mat, sop);
@@ -482,6 +655,8 @@ namespace OpenSim.Region.OptionalModules.Materials
482 asset.Data = data; 655 asset.Data = data;
483 m_scene.AssetService.Store(asset); 656 m_scene.AssetService.Store(asset);
484 } 657 }
658 else
659 m_MaterialsRefCount[id]++;
485 } 660 }
486 return id; 661 return id;
487 } 662 }
@@ -523,9 +698,9 @@ namespace OpenSim.Region.OptionalModules.Materials
523 int matsCount = 0; 698 int matsCount = 0;
524 OSDArray allOsd = new OSDArray(); 699 OSDArray allOsd = new OSDArray();
525 700
526 lock (m_regionMaterials) 701 lock (m_Materials)
527 { 702 {
528 foreach (KeyValuePair<UUID, OSDMap> kvp in m_regionMaterials) 703 foreach (KeyValuePair<UUID, OSDMap> kvp in m_Materials)
529 { 704 {
530 OSDMap matMap = new OSDMap(); 705 OSDMap matMap = new OSDMap();
531 706
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
index 3a5a936..9640e91 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
@@ -112,7 +112,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
112 private bool _zeroFlag = false; 112 private bool _zeroFlag = false;
113 private bool m_haveLastFallVel = false; 113 private bool m_haveLastFallVel = false;
114 114
115
116 private uint m_localID = 0; 115 private uint m_localID = 0;
117 public bool m_returnCollisions = false; 116 public bool m_returnCollisions = false;
118 // taints and their non-tainted counterparts 117 // taints and their non-tainted counterparts
@@ -149,7 +148,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
149 148
150 public int m_eventsubscription = 0; 149 public int m_eventsubscription = 0;
151 private int m_cureventsubscription = 0; 150 private int m_cureventsubscription = 0;
152 private CollisionEventUpdate CollisionEventsThisFrame = null; 151 private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
153 private bool SentEmptyCollisionsEvent; 152 private bool SentEmptyCollisionsEvent;
154 153
155 // unique UUID of this character object 154 // unique UUID of this character object
@@ -1556,32 +1555,26 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1556 1555
1557 public override float APIDDamping { set { return; } } 1556 public override float APIDDamping { set { return; } }
1558 1557
1559
1560 public override void SubscribeEvents(int ms) 1558 public override void SubscribeEvents(int ms)
1561 { 1559 {
1562 m_eventsubscription = ms; 1560 m_eventsubscription = ms;
1563 m_cureventsubscription = 0; 1561 m_cureventsubscription = 0;
1564 if (CollisionEventsThisFrame == null) 1562 CollisionEventsThisFrame.Clear();
1565 CollisionEventsThisFrame = new CollisionEventUpdate();
1566 SentEmptyCollisionsEvent = false; 1563 SentEmptyCollisionsEvent = false;
1567 } 1564 }
1568 1565
1569 public override void UnSubscribeEvents() 1566 public override void UnSubscribeEvents()
1570 { 1567 {
1571 if (CollisionEventsThisFrame != null)
1572 {
1573 CollisionEventsThisFrame.Clear();
1574 CollisionEventsThisFrame = null;
1575 }
1576 m_eventsubscription = 0; 1568 m_eventsubscription = 0;
1577 _parent_scene.RemoveCollisionEventReporting(this); 1569 _parent_scene.RemoveCollisionEventReporting(this);
1570 lock(CollisionEventsThisFrame)
1571 CollisionEventsThisFrame.Clear();
1578 } 1572 }
1579 1573
1580 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact) 1574 public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
1581 { 1575 {
1582 if (CollisionEventsThisFrame == null) 1576 lock(CollisionEventsThisFrame)
1583 CollisionEventsThisFrame = new CollisionEventUpdate(); 1577 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1584 CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
1585 _parent_scene.AddCollisionEventReporting(this); 1578 _parent_scene.AddCollisionEventReporting(this);
1586 } 1579 }
1587 1580
@@ -1590,28 +1583,28 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1590 if (m_cureventsubscription < 50000) 1583 if (m_cureventsubscription < 50000)
1591 m_cureventsubscription += timestep; 1584 m_cureventsubscription += timestep;
1592 1585
1593 if (CollisionEventsThisFrame == null)
1594 return;
1595
1596 if (m_cureventsubscription < m_eventsubscription) 1586 if (m_cureventsubscription < m_eventsubscription)
1597 return; 1587 return;
1598 1588
1599 int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count; 1589 lock(CollisionEventsThisFrame)
1600
1601 if (!SentEmptyCollisionsEvent || ncolisions > 0)
1602 { 1590 {
1603 base.SendCollisionUpdate(CollisionEventsThisFrame); 1591 int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
1604 m_cureventsubscription = 0;
1605 1592
1606 if (ncolisions == 0) 1593 if (!SentEmptyCollisionsEvent || ncolisions > 0)
1607 { 1594 {
1608 SentEmptyCollisionsEvent = true; 1595 base.SendCollisionUpdate(CollisionEventsThisFrame);
1609// _parent_scene.RemoveCollisionEventReporting(this); 1596 m_cureventsubscription = 0;
1610 } 1597
1611 else 1598 if (ncolisions == 0)
1612 { 1599 {
1613 SentEmptyCollisionsEvent = false; 1600 SentEmptyCollisionsEvent = true;
1614 CollisionEventsThisFrame.Clear(); 1601 // _parent_scene.RemoveCollisionEventReporting(this);
1602 }
1603 else
1604 {
1605 SentEmptyCollisionsEvent = false;
1606 CollisionEventsThisFrame.Clear();
1607 }
1615 } 1608 }
1616 } 1609 }
1617 } 1610 }
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs
index 5b1510f..d9ea4a4 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs
@@ -588,38 +588,37 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
588 Mesh mesh = new Mesh(); 588 Mesh mesh = new Mesh();
589 mesh.releaseBuildingMeshData(); 589 mesh.releaseBuildingMeshData();
590 590
591 BinaryReader br = new BinaryReader(st);
592
593 bool ok = true; 591 bool ok = true;
594 try 592 using(BinaryReader br = new BinaryReader(st))
595 { 593 {
596 mesh.m_vertexCount = br.ReadInt32(); 594 try
597 mesh.m_indexCount = br.ReadInt32(); 595 {
596 mesh.m_vertexCount = br.ReadInt32();
597 mesh.m_indexCount = br.ReadInt32();
598 598
599 int n = 3 * mesh.m_vertexCount; 599 int n = 3 * mesh.m_vertexCount;
600 mesh.vertices = new float[n]; 600 mesh.vertices = new float[n];
601 for (int i = 0; i < n; i++) 601 for (int i = 0; i < n; i++)
602 mesh.vertices[i] = br.ReadSingle(); 602 mesh.vertices[i] = br.ReadSingle();
603 603
604 mesh.indexes = new int[mesh.m_indexCount]; 604 mesh.indexes = new int[mesh.m_indexCount];
605 for (int i = 0; i < mesh.m_indexCount; i++) 605 for (int i = 0; i < mesh.m_indexCount; i++)
606 mesh.indexes[i] = br.ReadInt32(); 606 mesh.indexes[i] = br.ReadInt32();
607 607
608 mesh.m_obb.X = br.ReadSingle(); 608 mesh.m_obb.X = br.ReadSingle();
609 mesh.m_obb.Y = br.ReadSingle(); 609 mesh.m_obb.Y = br.ReadSingle();
610 mesh.m_obb.Z = br.ReadSingle(); 610 mesh.m_obb.Z = br.ReadSingle();
611 611
612 mesh.m_obboffset.X = br.ReadSingle(); 612 mesh.m_obboffset.X = br.ReadSingle();
613 mesh.m_obboffset.Y = br.ReadSingle(); 613 mesh.m_obboffset.Y = br.ReadSingle();
614 mesh.m_obboffset.Z = br.ReadSingle(); 614 mesh.m_obboffset.Z = br.ReadSingle();
615 } 615 }
616 catch 616 catch
617 { 617 {
618 ok = false; 618 ok = false;
619 }
619 } 620 }
620 621
621 br.Close();
622
623 if (ok) 622 if (ok)
624 { 623 {
625 mesh.pinMemory(); 624 mesh.pinMemory();
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
index d9544db..ff10e7f 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
60 60
61 private bool m_Enabled = false; 61 private bool m_Enabled = false;
62 62
63 public object diskLock = new object(); 63 public static object diskLock = new object();
64 64
65 public bool doMeshFileCache = true; 65 public bool doMeshFileCache = true;
66 66
@@ -1426,13 +1426,13 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1426 { 1426 {
1427 if (File.Exists(filename)) 1427 if (File.Exists(filename))
1428 { 1428 {
1429 FileStream stream = null;
1430 try 1429 try
1431 { 1430 {
1432 stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); 1431 using(FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
1433 BinaryFormatter bformatter = new BinaryFormatter(); 1432 {
1434 1433// BinaryFormatter bformatter = new BinaryFormatter();
1435 mesh = Mesh.FromStream(stream, key); 1434 mesh = Mesh.FromStream(stream,key);
1435 }
1436 1436
1437 } 1437 }
1438 catch (Exception e) 1438 catch (Exception e)
@@ -1443,13 +1443,17 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1443 filename, e.Message, e.StackTrace); 1443 filename, e.Message, e.StackTrace);
1444 } 1444 }
1445 1445
1446 if (stream != null) 1446 try
1447 stream.Close(); 1447 {
1448 if (mesh == null || !ok)
1449 File.Delete(filename);
1450 else
1451 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
1452 }
1453 catch
1454 {
1455 }
1448 1456
1449 if (mesh == null || !ok)
1450 File.Delete(filename);
1451 else
1452 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
1453 } 1457 }
1454 } 1458 }
1455 1459
@@ -1458,7 +1462,6 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1458 1462
1459 private void StoreToFileCache(AMeshKey key, Mesh mesh) 1463 private void StoreToFileCache(AMeshKey key, Mesh mesh)
1460 { 1464 {
1461 Stream stream = null;
1462 bool ok = false; 1465 bool ok = false;
1463 1466
1464 // Make sure the target cache directory exists 1467 // Make sure the target cache directory exists
@@ -1476,8 +1479,8 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1476 Directory.CreateDirectory(dir); 1479 Directory.CreateDirectory(dir);
1477 } 1480 }
1478 1481
1479 stream = File.Open(filename, FileMode.Create); 1482 using(Stream stream = File.Open(filename, FileMode.Create))
1480 ok = mesh.ToStream(stream); 1483 ok = mesh.ToStream(stream);
1481 } 1484 }
1482 catch (IOException e) 1485 catch (IOException e)
1483 { 1486 {
@@ -1487,15 +1490,17 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
1487 ok = false; 1490 ok = false;
1488 } 1491 }
1489 1492
1490 if (stream != null) 1493 if (!ok && File.Exists(filename))
1491 stream.Close();
1492
1493 if (File.Exists(filename))
1494 { 1494 {
1495 if (ok) 1495 try
1496 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow); 1496 {
1497 else
1498 File.Delete(filename); 1497 File.Delete(filename);
1498 }
1499 catch (IOException e)
1500 {
1501 m_log.ErrorFormat(
1502 "[MESH CACHE]: Failed to delete file {0}",filename);
1503 }
1499 } 1504 }
1500 } 1505 }
1501 } 1506 }
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 92b3137..1ea17b5 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -588,6 +588,7 @@ namespace OpenSim.Services.LLLoginService
588 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); 588 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
589 if (defaults != null && defaults.Count > 0) 589 if (defaults != null && defaults.Count > 0)
590 { 590 {
591 flags |= TeleportFlags.ViaRegionID;
591 region = defaults[0]; 592 region = defaults[0];
592 where = "safe"; 593 where = "safe";
593 } 594 }
@@ -597,7 +598,10 @@ namespace OpenSim.Services.LLLoginService
597 account.FirstName, account.LastName); 598 account.FirstName, account.LastName);
598 region = FindAlternativeRegion(scopeID); 599 region = FindAlternativeRegion(scopeID);
599 if (region != null) 600 if (region != null)
601 {
602 flags |= TeleportFlags.ViaRegionID;
600 where = "safe"; 603 where = "safe";
604 }
601 } 605 }
602 } 606 }
603 607
@@ -618,6 +622,7 @@ namespace OpenSim.Services.LLLoginService
618 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); 622 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
619 if (defaults != null && defaults.Count > 0) 623 if (defaults != null && defaults.Count > 0)
620 { 624 {
625 flags |= TeleportFlags.ViaRegionID;
621 region = defaults[0]; 626 region = defaults[0];
622 where = "safe"; 627 where = "safe";
623 } 628 }
@@ -626,7 +631,10 @@ namespace OpenSim.Services.LLLoginService
626 m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region"); 631 m_log.Info("[LLOGIN SERVICE]: Last Region Not Found Attempting to find random region");
627 region = FindAlternativeRegion(scopeID); 632 region = FindAlternativeRegion(scopeID);
628 if (region != null) 633 if (region != null)
634 {
635 flags |= TeleportFlags.ViaRegionID;
629 where = "safe"; 636 where = "safe";
637 }
630 } 638 }
631 639
632 } 640 }