diff options
author | Melanie | 2014-01-28 21:02:20 +0000 |
---|---|---|
committer | Melanie | 2014-01-28 21:02:20 +0000 |
commit | c6e9db58669d773c85041db99b19b942f70324f7 (patch) | |
tree | 99f69fb669332cff69a45ce6f7473aed6d965a0d /OpenSim/Region/CoreModules | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'justincc-master' (diff) | |
download | opensim-SC-c6e9db58669d773c85041db99b19b942f70324f7.zip opensim-SC-c6e9db58669d773c85041db99b19b942f70324f7.tar.gz opensim-SC-c6e9db58669d773c85041db99b19b942f70324f7.tar.bz2 opensim-SC-c6e9db58669d773c85041db99b19b942f70324f7.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Framework/RegionSettings.cs
OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
Diffstat (limited to 'OpenSim/Region/CoreModules')
18 files changed, 456 insertions, 477 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index f43305f..9b0e1f4 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -194,10 +194,12 @@ namespace OpenSim.Region.CoreModules.Asset | |||
194 | 194 | ||
195 | #region IImprovedAssetCache Members | 195 | #region IImprovedAssetCache Members |
196 | 196 | ||
197 | |||
198 | public bool Check(string id) | 197 | public bool Check(string id) |
199 | { | 198 | { |
200 | return false; | 199 | AssetBase asset; |
200 | |||
201 | // XXX:This is probably not an efficient implementation. | ||
202 | return m_cache.TryGetValue(id, out asset); | ||
201 | } | 203 | } |
202 | 204 | ||
203 | /// <summary> | 205 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 58ce61a..f720748 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs | |||
@@ -114,7 +114,8 @@ namespace OpenSim.Region.CoreModules.Asset | |||
114 | // | 114 | // |
115 | public bool Check(string id) | 115 | public bool Check(string id) |
116 | { | 116 | { |
117 | return false; | 117 | // XXX This is probably not an efficient implementation. |
118 | return Get(id) != null; | ||
118 | } | 119 | } |
119 | 120 | ||
120 | public void Cache(AssetBase asset) | 121 | public void Cache(AssetBase asset) |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index f1fee63..b270de9 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -248,71 +248,68 @@ namespace OpenSim.Region.CoreModules.Asset | |||
248 | 248 | ||
249 | private void UpdateFileCache(string key, AssetBase asset) | 249 | private void UpdateFileCache(string key, AssetBase asset) |
250 | { | 250 | { |
251 | // TODO: Spawn this off to some seperate thread to do the actual writing | 251 | string filename = GetFileName(key); |
252 | if (asset != null) | ||
253 | { | ||
254 | string filename = GetFileName(key); | ||
255 | 252 | ||
256 | try | 253 | try |
254 | { | ||
255 | // If the file is already cached, don't cache it, just touch it so access time is updated | ||
256 | if (File.Exists(filename)) | ||
257 | { | 257 | { |
258 | // If the file is already cached, don't cache it, just touch it so access time is updated | 258 | // We don't really want to know about sharing |
259 | if (File.Exists(filename)) | 259 | // violations here. If the file is locked, then |
260 | // the other thread has updated the time for us. | ||
261 | try | ||
260 | { | 262 | { |
261 | // We don't really want to know about sharing | 263 | lock (m_CurrentlyWriting) |
262 | // violations here. If the file is locked, then | ||
263 | // the other thread has updated the time for us. | ||
264 | try | ||
265 | { | 264 | { |
266 | lock (m_CurrentlyWriting) | 265 | if (!m_CurrentlyWriting.Contains(filename)) |
267 | { | 266 | File.SetLastAccessTime(filename, DateTime.Now); |
268 | if (!m_CurrentlyWriting.Contains(filename)) | ||
269 | File.SetLastAccessTime(filename, DateTime.Now); | ||
270 | } | ||
271 | } | 267 | } |
272 | catch | 268 | } |
269 | catch | ||
270 | { | ||
271 | } | ||
272 | } | ||
273 | else | ||
274 | { | ||
275 | // Once we start writing, make sure we flag that we're writing | ||
276 | // that object to the cache so that we don't try to write the | ||
277 | // same file multiple times. | ||
278 | lock (m_CurrentlyWriting) | ||
279 | { | ||
280 | #if WAIT_ON_INPROGRESS_REQUESTS | ||
281 | if (m_CurrentlyWriting.ContainsKey(filename)) | ||
273 | { | 282 | { |
283 | return; | ||
274 | } | 284 | } |
275 | } else { | 285 | else |
276 | |||
277 | // Once we start writing, make sure we flag that we're writing | ||
278 | // that object to the cache so that we don't try to write the | ||
279 | // same file multiple times. | ||
280 | lock (m_CurrentlyWriting) | ||
281 | { | 286 | { |
282 | #if WAIT_ON_INPROGRESS_REQUESTS | 287 | m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); |
283 | if (m_CurrentlyWriting.ContainsKey(filename)) | 288 | } |
284 | { | ||
285 | return; | ||
286 | } | ||
287 | else | ||
288 | { | ||
289 | m_CurrentlyWriting.Add(filename, new ManualResetEvent(false)); | ||
290 | } | ||
291 | 289 | ||
292 | #else | 290 | #else |
293 | if (m_CurrentlyWriting.Contains(filename)) | 291 | if (m_CurrentlyWriting.Contains(filename)) |
294 | { | 292 | { |
295 | return; | 293 | return; |
296 | } | ||
297 | else | ||
298 | { | ||
299 | m_CurrentlyWriting.Add(filename); | ||
300 | } | ||
301 | #endif | ||
302 | |||
303 | } | 294 | } |
295 | else | ||
296 | { | ||
297 | m_CurrentlyWriting.Add(filename); | ||
298 | } | ||
299 | #endif | ||
304 | 300 | ||
305 | Util.FireAndForget( | ||
306 | delegate { WriteFileCache(filename, asset); }); | ||
307 | } | 301 | } |
308 | } | 302 | |
309 | catch (Exception e) | 303 | Util.FireAndForget( |
310 | { | 304 | delegate { WriteFileCache(filename, asset); }); |
311 | m_log.ErrorFormat( | ||
312 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", | ||
313 | asset.ID, e.Message, e.StackTrace); | ||
314 | } | 305 | } |
315 | } | 306 | } |
307 | catch (Exception e) | ||
308 | { | ||
309 | m_log.ErrorFormat( | ||
310 | "[FLOTSAM ASSET CACHE]: Failed to update cache for asset {0}. Exception {1} {2}", | ||
311 | asset.ID, e.Message, e.StackTrace); | ||
312 | } | ||
316 | } | 313 | } |
317 | 314 | ||
318 | public void Cache(AssetBase asset) | 315 | public void Cache(AssetBase asset) |
@@ -347,15 +344,9 @@ namespace OpenSim.Region.CoreModules.Asset | |||
347 | 344 | ||
348 | private bool CheckFromMemoryCache(string id) | 345 | private bool CheckFromMemoryCache(string id) |
349 | { | 346 | { |
350 | AssetBase asset = null; | 347 | return m_MemoryCache.Contains(id); |
351 | |||
352 | if (m_MemoryCache.TryGetValue(id, out asset)) | ||
353 | return true; | ||
354 | |||
355 | return false; | ||
356 | } | 348 | } |
357 | 349 | ||
358 | |||
359 | /// <summary> | 350 | /// <summary> |
360 | /// Try to get an asset from the file cache. | 351 | /// Try to get an asset from the file cache. |
361 | /// </summary> | 352 | /// </summary> |
@@ -393,15 +384,16 @@ namespace OpenSim.Region.CoreModules.Asset | |||
393 | 384 | ||
394 | if (File.Exists(filename)) | 385 | if (File.Exists(filename)) |
395 | { | 386 | { |
396 | FileStream stream = null; | ||
397 | try | 387 | try |
398 | { | 388 | { |
399 | stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); | 389 | using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) |
400 | BinaryFormatter bformatter = new BinaryFormatter(); | 390 | { |
391 | BinaryFormatter bformatter = new BinaryFormatter(); | ||
401 | 392 | ||
402 | asset = (AssetBase)bformatter.Deserialize(stream); | 393 | asset = (AssetBase)bformatter.Deserialize(stream); |
403 | 394 | ||
404 | m_DiskHits++; | 395 | m_DiskHits++; |
396 | } | ||
405 | } | 397 | } |
406 | catch (System.Runtime.Serialization.SerializationException e) | 398 | catch (System.Runtime.Serialization.SerializationException e) |
407 | { | 399 | { |
@@ -420,12 +412,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
420 | m_log.WarnFormat( | 412 | m_log.WarnFormat( |
421 | "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", | 413 | "[FLOTSAM ASSET CACHE]: Failed to get file {0} for asset {1}. Exception {2} {3}", |
422 | filename, id, e.Message, e.StackTrace); | 414 | filename, id, e.Message, e.StackTrace); |
423 | |||
424 | } | ||
425 | finally | ||
426 | { | ||
427 | if (stream != null) | ||
428 | stream.Close(); | ||
429 | } | 415 | } |
430 | } | 416 | } |
431 | 417 | ||
@@ -437,36 +423,19 @@ namespace OpenSim.Region.CoreModules.Asset | |||
437 | bool found = false; | 423 | bool found = false; |
438 | 424 | ||
439 | string filename = GetFileName(id); | 425 | string filename = GetFileName(id); |
426 | |||
440 | if (File.Exists(filename)) | 427 | if (File.Exists(filename)) |
441 | { | 428 | { |
442 | // actually check if we can open it, and so update expire | ||
443 | FileStream stream = null; | ||
444 | try | 429 | try |
445 | { | 430 | { |
446 | stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); | 431 | using (FileStream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) |
447 | if (stream != null) | ||
448 | { | 432 | { |
449 | found = true; | 433 | if (stream != null) |
450 | stream.Close(); | 434 | found = true; |
451 | } | 435 | } |
452 | |||
453 | } | ||
454 | catch (System.Runtime.Serialization.SerializationException e) | ||
455 | { | ||
456 | found = false; | ||
457 | m_log.ErrorFormat( | ||
458 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", | ||
459 | filename, id, e.Message, e.StackTrace); | ||
460 | |||
461 | // If there was a problem deserializing the asset, the asset may | ||
462 | // either be corrupted OR was serialized under an old format | ||
463 | // {different version of AssetBase} -- we should attempt to | ||
464 | // delete it and re-cache | ||
465 | File.Delete(filename); | ||
466 | } | 436 | } |
467 | catch (Exception e) | 437 | catch (Exception e) |
468 | { | 438 | { |
469 | found = false; | ||
470 | m_log.ErrorFormat( | 439 | m_log.ErrorFormat( |
471 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", | 440 | "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", |
472 | filename, id, e.Message, e.StackTrace); | 441 | filename, id, e.Message, e.StackTrace); |
@@ -518,11 +487,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
518 | return Get(id); | 487 | return Get(id); |
519 | } | 488 | } |
520 | 489 | ||
521 | public AssetBase CheckCached(string id) | ||
522 | { | ||
523 | return Get(id); | ||
524 | } | ||
525 | |||
526 | public void Expire(string id) | 490 | public void Expire(string id) |
527 | { | 491 | { |
528 | if (m_LogLevel >= 2) | 492 | if (m_LogLevel >= 2) |
@@ -807,7 +771,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
807 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); | 771 | UuidGatherer gatherer = new UuidGatherer(m_AssetService); |
808 | 772 | ||
809 | HashSet<UUID> uniqueUuids = new HashSet<UUID>(); | 773 | HashSet<UUID> uniqueUuids = new HashSet<UUID>(); |
810 | Dictionary<UUID, AssetType> assets = new Dictionary<UUID, AssetType>(); | 774 | Dictionary<UUID, sbyte> assets = new Dictionary<UUID, sbyte>(); |
811 | 775 | ||
812 | foreach (Scene s in m_Scenes) | 776 | foreach (Scene s in m_Scenes) |
813 | { | 777 | { |
@@ -830,7 +794,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
830 | else if (storeUncached) | 794 | else if (storeUncached) |
831 | { | 795 | { |
832 | AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); | 796 | AssetBase cachedAsset = m_AssetService.Get(assetID.ToString()); |
833 | if (cachedAsset == null && assets[assetID] != AssetType.Unknown) | 797 | if (cachedAsset == null && assets[assetID] != (sbyte)AssetType.Unknown) |
834 | m_log.DebugFormat( | 798 | m_log.DebugFormat( |
835 | "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", | 799 | "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", |
836 | assetID, assets[assetID], e.Name, e.AbsolutePosition, s.Name); | 800 | assetID, assets[assetID], e.Name, e.AbsolutePosition, s.Name); |
@@ -1067,11 +1031,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
1067 | return asset.Data; | 1031 | return asset.Data; |
1068 | } | 1032 | } |
1069 | 1033 | ||
1070 | public bool CheckData(string id) | ||
1071 | { | ||
1072 | return Check(id); ; | ||
1073 | } | ||
1074 | |||
1075 | public bool Get(string id, object sender, AssetRetrieved handler) | 1034 | public bool Get(string id, object sender, AssetRetrieved handler) |
1076 | { | 1035 | { |
1077 | AssetBase asset = Get(id); | 1036 | AssetBase asset = Get(id); |
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index ce9b546..5f76ac2 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs | |||
@@ -117,7 +117,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
117 | 117 | ||
118 | public bool Check(string id) | 118 | public bool Check(string id) |
119 | { | 119 | { |
120 | return false; | 120 | return m_Cache.Contains(id); |
121 | } | 121 | } |
122 | 122 | ||
123 | public void Cache(AssetBase asset) | 123 | public void Cache(AssetBase asset) |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 4ec8ae7..4292719 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -78,7 +78,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
78 | /// <value> | 78 | /// <value> |
79 | /// Used to collect the uuids of the assets that we need to save into the archive | 79 | /// Used to collect the uuids of the assets that we need to save into the archive |
80 | /// </value> | 80 | /// </value> |
81 | protected Dictionary<UUID, AssetType> m_assetUuids = new Dictionary<UUID, AssetType>(); | 81 | protected Dictionary<UUID, sbyte> m_assetUuids = new Dictionary<UUID, sbyte>(); |
82 | 82 | ||
83 | /// <value> | 83 | /// <value> |
84 | /// Used to collect the uuids of the users that we need to save into the archive | 84 | /// Used to collect the uuids of the users that we need to save into the archive |
@@ -187,7 +187,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
187 | 187 | ||
188 | // Don't chase down link asset items as they actually point to their target item IDs rather than an asset | 188 | // Don't chase down link asset items as they actually point to their target item IDs rather than an asset |
189 | if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder) | 189 | if (SaveAssets && itemAssetType != AssetType.Link && itemAssetType != AssetType.LinkFolder) |
190 | m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, m_assetUuids); | 190 | m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (sbyte)inventoryItem.AssetType, m_assetUuids); |
191 | } | 191 | } |
192 | 192 | ||
193 | /// <summary> | 193 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 246b253..5fea0cf 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -1385,7 +1385,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1385 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos) | 1385 | public GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos) |
1386 | { | 1386 | { |
1387 | version = String.Empty; | 1387 | version = String.Empty; |
1388 | newpos = new Vector3(pos.X, pos.Y, pos.Z); | 1388 | newpos = pos; |
1389 | 1389 | ||
1390 | // m_log.DebugFormat( | 1390 | // m_log.DebugFormat( |
1391 | // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); | 1391 | // "[ENTITY TRANSFER MODULE]: Crossing agent {0} at pos {1} in {2}", agent.Name, pos, scene.Name); |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 74b834a..7abdc21 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -182,11 +182,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
182 | { | 182 | { |
183 | string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | 183 | string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); |
184 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachment {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); | 184 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachment {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); |
185 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 185 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
186 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url); | 186 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url); |
187 | uuidGatherer.GatherAssetUuids(so, ids); | 187 | uuidGatherer.GatherAssetUuids(so, ids); |
188 | 188 | ||
189 | foreach (KeyValuePair<UUID, AssetType> kvp in ids) | 189 | foreach (KeyValuePair<UUID, sbyte> kvp in ids) |
190 | uuidGatherer.FetchAsset(kvp.Key); | 190 | uuidGatherer.FetchAsset(kvp.Key); |
191 | } | 191 | } |
192 | } | 192 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index b7a4d1a..d4fb1ba 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | |||
@@ -260,9 +260,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
260 | 260 | ||
261 | // The act of gathering UUIDs downloads some assets from the remote server | 261 | // The act of gathering UUIDs downloads some assets from the remote server |
262 | // but not all... | 262 | // but not all... |
263 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 263 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
264 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); | 264 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL); |
265 | uuidGatherer.GatherAssetUuids(assetID, (AssetType)meta.Type, ids); | 265 | uuidGatherer.GatherAssetUuids(assetID, meta.Type, ids); |
266 | m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count); | 266 | m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count); |
267 | bool success = true; | 267 | bool success = true; |
268 | foreach (UUID uuid in ids.Keys) | 268 | foreach (UUID uuid in ids.Keys) |
@@ -286,9 +286,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); | 286 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); |
287 | if (asset != null) | 287 | if (asset != null) |
288 | { | 288 | { |
289 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | 289 | Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); |
290 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); | 290 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty); |
291 | uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); | 291 | uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids); |
292 | bool success = false; | 292 | bool success = false; |
293 | foreach (UUID uuid in ids.Keys) | 293 | foreach (UUID uuid in ids.Keys) |
294 | { | 294 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 3be80eb..7a6a174 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
174 | 174 | ||
175 | #endregion | 175 | #endregion |
176 | 176 | ||
177 | #region ISimulation | 177 | #region ISimulationService |
178 | 178 | ||
179 | public IScene GetScene(UUID regionId) | 179 | public IScene GetScene(UUID regionId) |
180 | { | 180 | { |
@@ -352,7 +352,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
352 | return false; | 352 | return false; |
353 | } | 353 | } |
354 | 354 | ||
355 | #endregion /* IInterregionComms */ | 355 | #endregion |
356 | 356 | ||
357 | #region Misc | 357 | #region Misc |
358 | 358 | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index 8bd1d10..ab912ed 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
146 | 146 | ||
147 | #endregion | 147 | #endregion |
148 | 148 | ||
149 | #region IInterregionComms | 149 | #region ISimulationService |
150 | 150 | ||
151 | public IScene GetScene(UUID regionId) | 151 | public IScene GetScene(UUID regionId) |
152 | { | 152 | { |
@@ -278,6 +278,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
278 | return false; | 278 | return false; |
279 | } | 279 | } |
280 | 280 | ||
281 | #endregion /* IInterregionComms */ | 281 | #endregion |
282 | } | 282 | } |
283 | } | 283 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index a990898..7a844f4 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | |||
@@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
178 | 178 | ||
179 | // Archive the regions | 179 | // Archive the regions |
180 | 180 | ||
181 | Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); | 181 | Dictionary<UUID, sbyte> assetUuids = new Dictionary<UUID, sbyte>(); |
182 | 182 | ||
183 | scenesGroup.ForEachScene(delegate(Scene scene) | 183 | scenesGroup.ForEachScene(delegate(Scene scene) |
184 | { | 184 | { |
@@ -216,7 +216,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, AssetType> assetUuids) | 219 | private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, sbyte> assetUuids) |
220 | { | 220 | { |
221 | m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); | 221 | m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); |
222 | 222 | ||
@@ -276,16 +276,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
276 | RegionSettings regionSettings = scene.RegionInfo.RegionSettings; | 276 | RegionSettings regionSettings = scene.RegionInfo.RegionSettings; |
277 | 277 | ||
278 | if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1) | 278 | if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1) |
279 | assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture; | 279 | assetUuids[regionSettings.TerrainTexture1] = (sbyte)AssetType.Texture; |
280 | 280 | ||
281 | if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2) | 281 | if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2) |
282 | assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture; | 282 | assetUuids[regionSettings.TerrainTexture2] = (sbyte)AssetType.Texture; |
283 | 283 | ||
284 | if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3) | 284 | if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3) |
285 | assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture; | 285 | assetUuids[regionSettings.TerrainTexture3] = (sbyte)AssetType.Texture; |
286 | 286 | ||
287 | if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4) | 287 | if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4) |
288 | assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture; | 288 | assetUuids[regionSettings.TerrainTexture4] = (sbyte)AssetType.Texture; |
289 | 289 | ||
290 | Save(scene, sceneObjects, regionDir); | 290 | Save(scene, sceneObjects, regionDir); |
291 | } | 291 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index ada7ecc..6c2a631 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | |||
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
81 | /// <value> | 81 | /// <value> |
82 | /// uuids to request | 82 | /// uuids to request |
83 | /// </value> | 83 | /// </value> |
84 | protected IDictionary<UUID, AssetType> m_uuids; | 84 | protected IDictionary<UUID, sbyte> m_uuids; |
85 | 85 | ||
86 | /// <value> | 86 | /// <value> |
87 | /// Callback used when all the assets requested have been received. | 87 | /// Callback used when all the assets requested have been received. |
@@ -115,7 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
115 | protected Dictionary<string, object> m_options; | 115 | protected Dictionary<string, object> m_options; |
116 | 116 | ||
117 | protected internal AssetsRequest( | 117 | protected internal AssetsRequest( |
118 | AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> uuids, | 118 | AssetsArchiver assetsArchiver, IDictionary<UUID, sbyte> uuids, |
119 | IAssetService assetService, IUserAccountService userService, | 119 | IAssetService assetService, IUserAccountService userService, |
120 | UUID scope, Dictionary<string, object> options, | 120 | UUID scope, Dictionary<string, object> options, |
121 | AssetsRequestCallback assetsRequestCallback) | 121 | AssetsRequestCallback assetsRequestCallback) |
@@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
154 | 154 | ||
155 | m_requestCallbackTimer.Enabled = true; | 155 | m_requestCallbackTimer.Enabled = true; |
156 | 156 | ||
157 | foreach (KeyValuePair<UUID, AssetType> kvp in m_uuids) | 157 | foreach (KeyValuePair<UUID, sbyte> kvp in m_uuids) |
158 | { | 158 | { |
159 | // m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key); | 159 | // m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key); |
160 | 160 | ||
@@ -235,9 +235,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
235 | // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer | 235 | // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer |
236 | if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown) | 236 | if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown) |
237 | { | 237 | { |
238 | AssetType type = (AssetType)assetType; | 238 | m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, SLUtil.AssetTypeFromCode((sbyte)assetType)); |
239 | m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, type); | 239 | fetchedAsset.Type = (sbyte)assetType; |
240 | fetchedAsset.Type = (sbyte)type; | ||
241 | } | 240 | } |
242 | 241 | ||
243 | AssetRequestCallback(fetchedAssetID, this, fetchedAsset); | 242 | AssetRequestCallback(fetchedAssetID, this, fetchedAsset); |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs index 173b603..1659493 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs | |||
@@ -60,7 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
60 | 60 | ||
61 | public void Initialise() | 61 | public void Initialise() |
62 | { | 62 | { |
63 | m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName); | 63 | // m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName); |
64 | 64 | ||
65 | m_module.Scene.AddCommand("Regions", m_module, "set terrain texture", | 65 | m_module.Scene.AddCommand("Regions", m_module, "set terrain texture", |
66 | "set terrain texture <number> <uuid> [<x>] [<y>]", | 66 | "set terrain texture <number> <uuid> [<x>] [<y>]", |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 4750b46..7aa1ced 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -712,7 +712,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
712 | } | 712 | } |
713 | } | 713 | } |
714 | 714 | ||
715 | public void handleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) | 715 | public void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) |
716 | { | 716 | { |
717 | SceneObjectPart part; | 717 | SceneObjectPart part; |
718 | 718 | ||
@@ -752,7 +752,9 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
752 | default: | 752 | default: |
753 | break; | 753 | break; |
754 | } | 754 | } |
755 | SendTelehubInfo(client); | 755 | |
756 | if (client != null) | ||
757 | SendTelehubInfo(client); | ||
756 | } | 758 | } |
757 | 759 | ||
758 | private void SendSimulatorBlueBoxMessage( | 760 | private void SendSimulatorBlueBoxMessage( |
@@ -1224,7 +1226,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1224 | client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; | 1226 | client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; |
1225 | client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; | 1227 | client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; |
1226 | client.OnEstateChangeInfo += handleEstateChangeInfo; | 1228 | client.OnEstateChangeInfo += handleEstateChangeInfo; |
1227 | client.OnEstateManageTelehub += handleOnEstateManageTelehub; | 1229 | client.OnEstateManageTelehub += HandleOnEstateManageTelehub; |
1228 | client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; | 1230 | client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; |
1229 | client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; | 1231 | client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; |
1230 | client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; | 1232 | client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index 40638f8..bc52a43 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
55 | public struct DrawStruct | 55 | public struct DrawStruct |
56 | { | 56 | { |
57 | public DrawRoutine dr; | 57 | public DrawRoutine dr; |
58 | public Rectangle rect; | 58 | // public Rectangle rect; |
59 | public SolidBrush brush; | 59 | public SolidBrush brush; |
60 | public face[] trns; | 60 | public face[] trns; |
61 | } | 61 | } |
@@ -119,6 +119,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
119 | { | 119 | { |
120 | mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID); | 120 | mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID); |
121 | } | 121 | } |
122 | |||
122 | return mapbmp; | 123 | return mapbmp; |
123 | } | 124 | } |
124 | 125 | ||
@@ -127,7 +128,10 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
127 | try | 128 | try |
128 | { | 129 | { |
129 | using (Bitmap mapbmp = CreateMapTile()) | 130 | using (Bitmap mapbmp = CreateMapTile()) |
130 | return OpenJPEG.EncodeFromImage(mapbmp, true); | 131 | { |
132 | if (mapbmp != null) | ||
133 | return OpenJPEG.EncodeFromImage(mapbmp, true); | ||
134 | } | ||
131 | } | 135 | } |
132 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke | 136 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke |
133 | { | 137 | { |
@@ -277,321 +281,331 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
277 | tc = Environment.TickCount; | 281 | tc = Environment.TickCount; |
278 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); | 282 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); |
279 | EntityBase[] objs = whichScene.GetEntities(); | 283 | EntityBase[] objs = whichScene.GetEntities(); |
280 | Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); | ||
281 | //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); | ||
282 | List<float> z_sortheights = new List<float>(); | 284 | List<float> z_sortheights = new List<float>(); |
283 | List<uint> z_localIDs = new List<uint>(); | 285 | List<uint> z_localIDs = new List<uint>(); |
286 | Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>(); | ||
284 | 287 | ||
285 | lock (objs) | 288 | try |
286 | { | 289 | { |
287 | foreach (EntityBase obj in objs) | 290 | //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>(); |
291 | |||
292 | lock (objs) | ||
288 | { | 293 | { |
289 | // Only draw the contents of SceneObjectGroup | 294 | foreach (EntityBase obj in objs) |
290 | if (obj is SceneObjectGroup) | ||
291 | { | 295 | { |
292 | SceneObjectGroup mapdot = (SceneObjectGroup)obj; | 296 | // Only draw the contents of SceneObjectGroup |
293 | Color mapdotspot = Color.Gray; // Default color when prim color is white | 297 | if (obj is SceneObjectGroup) |
294 | |||
295 | // Loop over prim in group | ||
296 | foreach (SceneObjectPart part in mapdot.Parts) | ||
297 | { | 298 | { |
298 | if (part == null) | 299 | SceneObjectGroup mapdot = (SceneObjectGroup)obj; |
299 | continue; | 300 | Color mapdotspot = Color.Gray; // Default color when prim color is white |
300 | 301 | ||
301 | // Draw if the object is at least 1 meter wide in any direction | 302 | // Loop over prim in group |
302 | if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f) | 303 | foreach (SceneObjectPart part in mapdot.Parts) |
303 | { | 304 | { |
304 | // Try to get the RGBA of the default texture entry.. | 305 | if (part == null) |
305 | // | 306 | continue; |
306 | try | 307 | |
308 | // Draw if the object is at least 1 meter wide in any direction | ||
309 | if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f) | ||
307 | { | 310 | { |
308 | // get the null checks out of the way | 311 | // Try to get the RGBA of the default texture entry.. |
309 | // skip the ones that break | 312 | // |
310 | if (part == null) | 313 | try |
311 | continue; | 314 | { |
315 | // get the null checks out of the way | ||
316 | // skip the ones that break | ||
317 | if (part == null) | ||
318 | continue; | ||
312 | 319 | ||
313 | if (part.Shape == null) | 320 | if (part.Shape == null) |
314 | continue; | 321 | continue; |
315 | 322 | ||
316 | if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass) | 323 | if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass) |
317 | continue; // eliminates trees from this since we don't really have a good tree representation | 324 | continue; // eliminates trees from this since we don't really have a good tree representation |
318 | // if you want tree blocks on the map comment the above line and uncomment the below line | 325 | // if you want tree blocks on the map comment the above line and uncomment the below line |
319 | //mapdotspot = Color.PaleGreen; | 326 | //mapdotspot = Color.PaleGreen; |
320 | 327 | ||
321 | Primitive.TextureEntry textureEntry = part.Shape.Textures; | 328 | Primitive.TextureEntry textureEntry = part.Shape.Textures; |
322 | 329 | ||
323 | if (textureEntry == null || textureEntry.DefaultTexture == null) | 330 | if (textureEntry == null || textureEntry.DefaultTexture == null) |
324 | continue; | 331 | continue; |
325 | 332 | ||
326 | Color4 texcolor = textureEntry.DefaultTexture.RGBA; | 333 | Color4 texcolor = textureEntry.DefaultTexture.RGBA; |
327 | 334 | ||
328 | // Not sure why some of these are null, oh well. | 335 | // Not sure why some of these are null, oh well. |
329 | 336 | ||
330 | int colorr = 255 - (int)(texcolor.R * 255f); | 337 | int colorr = 255 - (int)(texcolor.R * 255f); |
331 | int colorg = 255 - (int)(texcolor.G * 255f); | 338 | int colorg = 255 - (int)(texcolor.G * 255f); |
332 | int colorb = 255 - (int)(texcolor.B * 255f); | 339 | int colorb = 255 - (int)(texcolor.B * 255f); |
333 | 340 | ||
334 | if (!(colorr == 255 && colorg == 255 && colorb == 255)) | 341 | if (!(colorr == 255 && colorg == 255 && colorb == 255)) |
335 | { | ||
336 | //Try to set the map spot color | ||
337 | try | ||
338 | { | ||
339 | // If the color gets goofy somehow, skip it *shakes fist at Color4 | ||
340 | mapdotspot = Color.FromArgb(colorr, colorg, colorb); | ||
341 | } | ||
342 | catch (ArgumentException) | ||
343 | { | 342 | { |
343 | //Try to set the map spot color | ||
344 | try | ||
345 | { | ||
346 | // If the color gets goofy somehow, skip it *shakes fist at Color4 | ||
347 | mapdotspot = Color.FromArgb(colorr, colorg, colorb); | ||
348 | } | ||
349 | catch (ArgumentException) | ||
350 | { | ||
351 | } | ||
344 | } | 352 | } |
345 | } | 353 | } |
346 | } | 354 | catch (IndexOutOfRangeException) |
347 | catch (IndexOutOfRangeException) | 355 | { |
348 | { | 356 | // Windows Array |
349 | // Windows Array | 357 | } |
350 | } | 358 | catch (ArgumentOutOfRangeException) |
351 | catch (ArgumentOutOfRangeException) | 359 | { |
352 | { | 360 | // Mono Array |
353 | // Mono Array | 361 | } |
354 | } | ||
355 | |||
356 | Vector3 pos = part.GetWorldPosition(); | ||
357 | |||
358 | // skip prim outside of retion | ||
359 | if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f) | ||
360 | continue; | ||
361 | |||
362 | // skip prim in non-finite position | ||
363 | if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) || | ||
364 | Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y)) | ||
365 | continue; | ||
366 | |||
367 | // Figure out if object is under 256m above the height of the terrain | ||
368 | bool isBelow256AboveTerrain = false; | ||
369 | 362 | ||
370 | try | 363 | Vector3 pos = part.GetWorldPosition(); |
371 | { | ||
372 | isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f)); | ||
373 | } | ||
374 | catch (Exception) | ||
375 | { | ||
376 | } | ||
377 | 364 | ||
378 | if (isBelow256AboveTerrain) | 365 | // skip prim outside of retion |
379 | { | 366 | if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f) |
380 | // Translate scale by rotation so scale is represented properly when object is rotated | ||
381 | Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); | ||
382 | Vector3 scale = new Vector3(); | ||
383 | Vector3 tScale = new Vector3(); | ||
384 | Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z); | ||
385 | |||
386 | Quaternion llrot = part.GetWorldRotation(); | ||
387 | Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); | ||
388 | scale = lscale * rot; | ||
389 | |||
390 | // negative scales don't work in this situation | ||
391 | scale.X = Math.Abs(scale.X); | ||
392 | scale.Y = Math.Abs(scale.Y); | ||
393 | scale.Z = Math.Abs(scale.Z); | ||
394 | |||
395 | // This scaling isn't very accurate and doesn't take into account the face rotation :P | ||
396 | int mapdrawstartX = (int)(pos.X - scale.X); | ||
397 | int mapdrawstartY = (int)(pos.Y - scale.Y); | ||
398 | int mapdrawendX = (int)(pos.X + scale.X); | ||
399 | int mapdrawendY = (int)(pos.Y + scale.Y); | ||
400 | |||
401 | // If object is beyond the edge of the map, don't draw it to avoid errors | ||
402 | if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) | ||
403 | || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 | ||
404 | || mapdrawendY > ((int)Constants.RegionSize - 1)) | ||
405 | continue; | 367 | continue; |
406 | 368 | ||
407 | #region obb face reconstruction part duex | 369 | // skip prim in non-finite position |
408 | Vector3[] vertexes = new Vector3[8]; | 370 | if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) || |
409 | 371 | Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y)) | |
410 | // float[] distance = new float[6]; | 372 | continue; |
411 | Vector3[] FaceA = new Vector3[6]; // vertex A for Facei | ||
412 | Vector3[] FaceB = new Vector3[6]; // vertex B for Facei | ||
413 | Vector3[] FaceC = new Vector3[6]; // vertex C for Facei | ||
414 | Vector3[] FaceD = new Vector3[6]; // vertex D for Facei | ||
415 | |||
416 | tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z); | ||
417 | scale = ((tScale * rot)); | ||
418 | vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
419 | // vertexes[0].x = pos.X + vertexes[0].x; | ||
420 | //vertexes[0].y = pos.Y + vertexes[0].y; | ||
421 | //vertexes[0].z = pos.Z + vertexes[0].z; | ||
422 | |||
423 | FaceA[0] = vertexes[0]; | ||
424 | FaceB[3] = vertexes[0]; | ||
425 | FaceA[4] = vertexes[0]; | ||
426 | |||
427 | tScale = lscale; | ||
428 | scale = ((tScale * rot)); | ||
429 | vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
430 | |||
431 | // vertexes[1].x = pos.X + vertexes[1].x; | ||
432 | // vertexes[1].y = pos.Y + vertexes[1].y; | ||
433 | //vertexes[1].z = pos.Z + vertexes[1].z; | ||
434 | |||
435 | FaceB[0] = vertexes[1]; | ||
436 | FaceA[1] = vertexes[1]; | ||
437 | FaceC[4] = vertexes[1]; | ||
438 | |||
439 | tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z); | ||
440 | scale = ((tScale * rot)); | ||
441 | |||
442 | vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
443 | |||
444 | //vertexes[2].x = pos.X + vertexes[2].x; | ||
445 | //vertexes[2].y = pos.Y + vertexes[2].y; | ||
446 | //vertexes[2].z = pos.Z + vertexes[2].z; | ||
447 | |||
448 | FaceC[0] = vertexes[2]; | ||
449 | FaceD[3] = vertexes[2]; | ||
450 | FaceC[5] = vertexes[2]; | ||
451 | |||
452 | tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z); | ||
453 | scale = ((tScale * rot)); | ||
454 | vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
455 | |||
456 | //vertexes[3].x = pos.X + vertexes[3].x; | ||
457 | // vertexes[3].y = pos.Y + vertexes[3].y; | ||
458 | // vertexes[3].z = pos.Z + vertexes[3].z; | ||
459 | |||
460 | FaceD[0] = vertexes[3]; | ||
461 | FaceC[1] = vertexes[3]; | ||
462 | FaceA[5] = vertexes[3]; | ||
463 | |||
464 | tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z); | ||
465 | scale = ((tScale * rot)); | ||
466 | vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
467 | |||
468 | // vertexes[4].x = pos.X + vertexes[4].x; | ||
469 | // vertexes[4].y = pos.Y + vertexes[4].y; | ||
470 | // vertexes[4].z = pos.Z + vertexes[4].z; | ||
471 | |||
472 | FaceB[1] = vertexes[4]; | ||
473 | FaceA[2] = vertexes[4]; | ||
474 | FaceD[4] = vertexes[4]; | ||
475 | |||
476 | tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z); | ||
477 | scale = ((tScale * rot)); | ||
478 | vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
479 | |||
480 | // vertexes[5].x = pos.X + vertexes[5].x; | ||
481 | // vertexes[5].y = pos.Y + vertexes[5].y; | ||
482 | // vertexes[5].z = pos.Z + vertexes[5].z; | ||
483 | |||
484 | FaceD[1] = vertexes[5]; | ||
485 | FaceC[2] = vertexes[5]; | ||
486 | FaceB[5] = vertexes[5]; | ||
487 | 373 | ||
488 | tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z); | 374 | // Figure out if object is under 256m above the height of the terrain |
489 | scale = ((tScale * rot)); | 375 | bool isBelow256AboveTerrain = false; |
490 | vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
491 | 376 | ||
492 | // vertexes[6].x = pos.X + vertexes[6].x; | 377 | try |
493 | // vertexes[6].y = pos.Y + vertexes[6].y; | 378 | { |
494 | // vertexes[6].z = pos.Z + vertexes[6].z; | 379 | isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f)); |
380 | } | ||
381 | catch (Exception) | ||
382 | { | ||
383 | } | ||
495 | 384 | ||
496 | FaceB[2] = vertexes[6]; | 385 | if (isBelow256AboveTerrain) |
497 | FaceA[3] = vertexes[6]; | 386 | { |
498 | FaceB[4] = vertexes[6]; | 387 | // Translate scale by rotation so scale is represented properly when object is rotated |
388 | Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z); | ||
389 | Vector3 scale = new Vector3(); | ||
390 | Vector3 tScale = new Vector3(); | ||
391 | Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z); | ||
392 | |||
393 | Quaternion llrot = part.GetWorldRotation(); | ||
394 | Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z); | ||
395 | scale = lscale * rot; | ||
396 | |||
397 | // negative scales don't work in this situation | ||
398 | scale.X = Math.Abs(scale.X); | ||
399 | scale.Y = Math.Abs(scale.Y); | ||
400 | scale.Z = Math.Abs(scale.Z); | ||
401 | |||
402 | // This scaling isn't very accurate and doesn't take into account the face rotation :P | ||
403 | int mapdrawstartX = (int)(pos.X - scale.X); | ||
404 | int mapdrawstartY = (int)(pos.Y - scale.Y); | ||
405 | int mapdrawendX = (int)(pos.X + scale.X); | ||
406 | int mapdrawendY = (int)(pos.Y + scale.Y); | ||
407 | |||
408 | // If object is beyond the edge of the map, don't draw it to avoid errors | ||
409 | if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1) | ||
410 | || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0 | ||
411 | || mapdrawendY > ((int)Constants.RegionSize - 1)) | ||
412 | continue; | ||
413 | |||
414 | #region obb face reconstruction part duex | ||
415 | Vector3[] vertexes = new Vector3[8]; | ||
416 | |||
417 | // float[] distance = new float[6]; | ||
418 | Vector3[] FaceA = new Vector3[6]; // vertex A for Facei | ||
419 | Vector3[] FaceB = new Vector3[6]; // vertex B for Facei | ||
420 | Vector3[] FaceC = new Vector3[6]; // vertex C for Facei | ||
421 | Vector3[] FaceD = new Vector3[6]; // vertex D for Facei | ||
422 | |||
423 | tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z); | ||
424 | scale = ((tScale * rot)); | ||
425 | vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
426 | // vertexes[0].x = pos.X + vertexes[0].x; | ||
427 | //vertexes[0].y = pos.Y + vertexes[0].y; | ||
428 | //vertexes[0].z = pos.Z + vertexes[0].z; | ||
429 | |||
430 | FaceA[0] = vertexes[0]; | ||
431 | FaceB[3] = vertexes[0]; | ||
432 | FaceA[4] = vertexes[0]; | ||
433 | |||
434 | tScale = lscale; | ||
435 | scale = ((tScale * rot)); | ||
436 | vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
437 | |||
438 | // vertexes[1].x = pos.X + vertexes[1].x; | ||
439 | // vertexes[1].y = pos.Y + vertexes[1].y; | ||
440 | //vertexes[1].z = pos.Z + vertexes[1].z; | ||
441 | |||
442 | FaceB[0] = vertexes[1]; | ||
443 | FaceA[1] = vertexes[1]; | ||
444 | FaceC[4] = vertexes[1]; | ||
445 | |||
446 | tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z); | ||
447 | scale = ((tScale * rot)); | ||
448 | |||
449 | vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
450 | |||
451 | //vertexes[2].x = pos.X + vertexes[2].x; | ||
452 | //vertexes[2].y = pos.Y + vertexes[2].y; | ||
453 | //vertexes[2].z = pos.Z + vertexes[2].z; | ||
454 | |||
455 | FaceC[0] = vertexes[2]; | ||
456 | FaceD[3] = vertexes[2]; | ||
457 | FaceC[5] = vertexes[2]; | ||
458 | |||
459 | tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z); | ||
460 | scale = ((tScale * rot)); | ||
461 | vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
462 | |||
463 | //vertexes[3].x = pos.X + vertexes[3].x; | ||
464 | // vertexes[3].y = pos.Y + vertexes[3].y; | ||
465 | // vertexes[3].z = pos.Z + vertexes[3].z; | ||
466 | |||
467 | FaceD[0] = vertexes[3]; | ||
468 | FaceC[1] = vertexes[3]; | ||
469 | FaceA[5] = vertexes[3]; | ||
470 | |||
471 | tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z); | ||
472 | scale = ((tScale * rot)); | ||
473 | vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
474 | |||
475 | // vertexes[4].x = pos.X + vertexes[4].x; | ||
476 | // vertexes[4].y = pos.Y + vertexes[4].y; | ||
477 | // vertexes[4].z = pos.Z + vertexes[4].z; | ||
478 | |||
479 | FaceB[1] = vertexes[4]; | ||
480 | FaceA[2] = vertexes[4]; | ||
481 | FaceD[4] = vertexes[4]; | ||
482 | |||
483 | tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z); | ||
484 | scale = ((tScale * rot)); | ||
485 | vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
486 | |||
487 | // vertexes[5].x = pos.X + vertexes[5].x; | ||
488 | // vertexes[5].y = pos.Y + vertexes[5].y; | ||
489 | // vertexes[5].z = pos.Z + vertexes[5].z; | ||
490 | |||
491 | FaceD[1] = vertexes[5]; | ||
492 | FaceC[2] = vertexes[5]; | ||
493 | FaceB[5] = vertexes[5]; | ||
494 | |||
495 | tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z); | ||
496 | scale = ((tScale * rot)); | ||
497 | vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | ||
498 | |||
499 | // vertexes[6].x = pos.X + vertexes[6].x; | ||
500 | // vertexes[6].y = pos.Y + vertexes[6].y; | ||
501 | // vertexes[6].z = pos.Z + vertexes[6].z; | ||
502 | |||
503 | FaceB[2] = vertexes[6]; | ||
504 | FaceA[3] = vertexes[6]; | ||
505 | FaceB[4] = vertexes[6]; | ||
499 | 506 | ||
500 | tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z); | 507 | tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z); |
501 | scale = ((tScale * rot)); | 508 | scale = ((tScale * rot)); |
502 | vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); | 509 | vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); |
503 | 510 | ||
504 | // vertexes[7].x = pos.X + vertexes[7].x; | 511 | // vertexes[7].x = pos.X + vertexes[7].x; |
505 | // vertexes[7].y = pos.Y + vertexes[7].y; | 512 | // vertexes[7].y = pos.Y + vertexes[7].y; |
506 | // vertexes[7].z = pos.Z + vertexes[7].z; | 513 | // vertexes[7].z = pos.Z + vertexes[7].z; |
507 | 514 | ||
508 | FaceD[2] = vertexes[7]; | 515 | FaceD[2] = vertexes[7]; |
509 | FaceC[3] = vertexes[7]; | 516 | FaceC[3] = vertexes[7]; |
510 | FaceD[5] = vertexes[7]; | 517 | FaceD[5] = vertexes[7]; |
511 | #endregion | 518 | #endregion |
512 | 519 | ||
513 | //int wy = 0; | 520 | //int wy = 0; |
514 | 521 | ||
515 | //bool breakYN = false; // If we run into an error drawing, break out of the | 522 | //bool breakYN = false; // If we run into an error drawing, break out of the |
516 | // loop so we don't lag to death on error handling | 523 | // loop so we don't lag to death on error handling |
517 | DrawStruct ds = new DrawStruct(); | 524 | DrawStruct ds = new DrawStruct(); |
518 | ds.brush = new SolidBrush(mapdotspot); | 525 | ds.brush = new SolidBrush(mapdotspot); |
519 | //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY); | 526 | //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY); |
520 | 527 | ||
521 | ds.trns = new face[FaceA.Length]; | 528 | ds.trns = new face[FaceA.Length]; |
522 | 529 | ||
523 | for (int i = 0; i < FaceA.Length; i++) | 530 | for (int i = 0; i < FaceA.Length; i++) |
524 | { | 531 | { |
525 | Point[] working = new Point[5]; | 532 | Point[] working = new Point[5]; |
526 | working[0] = project(FaceA[i], axPos); | 533 | working[0] = project(FaceA[i], axPos); |
527 | working[1] = project(FaceB[i], axPos); | 534 | working[1] = project(FaceB[i], axPos); |
528 | working[2] = project(FaceD[i], axPos); | 535 | working[2] = project(FaceD[i], axPos); |
529 | working[3] = project(FaceC[i], axPos); | 536 | working[3] = project(FaceC[i], axPos); |
530 | working[4] = project(FaceA[i], axPos); | 537 | working[4] = project(FaceA[i], axPos); |
531 | 538 | ||
532 | face workingface = new face(); | 539 | face workingface = new face(); |
533 | workingface.pts = working; | 540 | workingface.pts = working; |
534 | 541 | ||
535 | ds.trns[i] = workingface; | 542 | ds.trns[i] = workingface; |
536 | } | 543 | } |
537 | 544 | ||
538 | z_sort.Add(part.LocalId, ds); | 545 | z_sort.Add(part.LocalId, ds); |
539 | z_localIDs.Add(part.LocalId); | 546 | z_localIDs.Add(part.LocalId); |
540 | z_sortheights.Add(pos.Z); | 547 | z_sortheights.Add(pos.Z); |
541 | 548 | ||
542 | //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) | 549 | //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) |
543 | //{ | ||
544 | //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) | ||
545 | //{ | 550 | //{ |
546 | //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); | 551 | //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) |
547 | //try | ||
548 | //{ | ||
549 | // Remember, flip the y! | ||
550 | // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); | ||
551 | //} | ||
552 | //catch (ArgumentException) | ||
553 | //{ | 552 | //{ |
554 | // breakYN = true; | 553 | //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); |
554 | //try | ||
555 | //{ | ||
556 | // Remember, flip the y! | ||
557 | // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); | ||
558 | //} | ||
559 | //catch (ArgumentException) | ||
560 | //{ | ||
561 | // breakYN = true; | ||
562 | //} | ||
563 | |||
564 | //if (breakYN) | ||
565 | // break; | ||
555 | //} | 566 | //} |
556 | 567 | ||
557 | //if (breakYN) | 568 | //if (breakYN) |
558 | // break; | 569 | // break; |
559 | //} | 570 | //} |
571 | } // Object is within 256m Z of terrain | ||
572 | } // object is at least a meter wide | ||
573 | } // loop over group children | ||
574 | } // entitybase is sceneobject group | ||
575 | } // foreach loop over entities | ||
560 | 576 | ||
561 | //if (breakYN) | 577 | float[] sortedZHeights = z_sortheights.ToArray(); |
562 | // break; | 578 | uint[] sortedlocalIds = z_localIDs.ToArray(); |
563 | //} | ||
564 | } // Object is within 256m Z of terrain | ||
565 | } // object is at least a meter wide | ||
566 | } // loop over group children | ||
567 | } // entitybase is sceneobject group | ||
568 | } // foreach loop over entities | ||
569 | |||
570 | float[] sortedZHeights = z_sortheights.ToArray(); | ||
571 | uint[] sortedlocalIds = z_localIDs.ToArray(); | ||
572 | |||
573 | // Sort prim by Z position | ||
574 | Array.Sort(sortedZHeights, sortedlocalIds); | ||
575 | 579 | ||
576 | Graphics g = Graphics.FromImage(mapbmp); | 580 | // Sort prim by Z position |
581 | Array.Sort(sortedZHeights, sortedlocalIds); | ||
577 | 582 | ||
578 | for (int s = 0; s < sortedZHeights.Length; s++) | 583 | using (Graphics g = Graphics.FromImage(mapbmp)) |
579 | { | ||
580 | if (z_sort.ContainsKey(sortedlocalIds[s])) | ||
581 | { | 584 | { |
582 | DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; | 585 | for (int s = 0; s < sortedZHeights.Length; s++) |
583 | for (int r = 0; r < rectDrawStruct.trns.Length; r++) | ||
584 | { | 586 | { |
585 | g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts); | 587 | if (z_sort.ContainsKey(sortedlocalIds[s])) |
588 | { | ||
589 | DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; | ||
590 | for (int r = 0; r < rectDrawStruct.trns.Length; r++) | ||
591 | { | ||
592 | g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts); | ||
593 | } | ||
594 | //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect); | ||
595 | } | ||
586 | } | 596 | } |
587 | //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect); | ||
588 | } | 597 | } |
589 | } | 598 | } // lock entities objs |
590 | 599 | ||
591 | g.Dispose(); | 600 | } |
592 | } // lock entities objs | 601 | finally |
602 | { | ||
603 | foreach (DrawStruct ds in z_sort.Values) | ||
604 | ds.brush.Dispose(); | ||
605 | } | ||
593 | 606 | ||
594 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); | 607 | m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); |
608 | |||
595 | return mapbmp; | 609 | return mapbmp; |
596 | } | 610 | } |
597 | 611 | ||
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs index 992bff3..cb06fd4 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs | |||
@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
54 | public void TerrainToBitmap(Bitmap mapbmp) | 54 | public void TerrainToBitmap(Bitmap mapbmp) |
55 | { | 55 | { |
56 | int tc = Environment.TickCount; | 56 | int tc = Environment.TickCount; |
57 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); | 57 | m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Terrain"); |
58 | 58 | ||
59 | double[,] hm = m_scene.Heightmap.GetDoubles(); | 59 | double[,] hm = m_scene.Heightmap.GetDoubles(); |
60 | bool ShadowDebugContinue = true; | 60 | bool ShadowDebugContinue = true; |
@@ -199,7 +199,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
199 | { | 199 | { |
200 | if (!terraincorruptedwarningsaid) | 200 | if (!terraincorruptedwarningsaid) |
201 | { | 201 | { |
202 | m_log.WarnFormat("[MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName); | 202 | m_log.WarnFormat("[SHADED MAP TILE RENDERER]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName); |
203 | terraincorruptedwarningsaid = true; | 203 | terraincorruptedwarningsaid = true; |
204 | } | 204 | } |
205 | color = Color.Black; | 205 | color = Color.Black; |
@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
229 | { | 229 | { |
230 | if (!terraincorruptedwarningsaid) | 230 | if (!terraincorruptedwarningsaid) |
231 | { | 231 | { |
232 | m_log.WarnFormat("[MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName); | 232 | m_log.WarnFormat("[SHADED MAP TILE RENDERER]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName); |
233 | terraincorruptedwarningsaid = true; | 233 | terraincorruptedwarningsaid = true; |
234 | } | 234 | } |
235 | Color black = Color.Black; | 235 | Color black = Color.Black; |
@@ -238,7 +238,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | 241 | |
242 | m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | ||
242 | } | 243 | } |
243 | } | 244 | } |
244 | } | 245 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs index d13c2ef..e895178 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs | |||
@@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
173 | private Bitmap fetchTexture(UUID id) | 173 | private Bitmap fetchTexture(UUID id) |
174 | { | 174 | { |
175 | AssetBase asset = m_scene.AssetService.Get(id.ToString()); | 175 | AssetBase asset = m_scene.AssetService.Get(id.ToString()); |
176 | m_log.DebugFormat("[TexturedMapTileRenderer]: Fetched texture {0}, found: {1}", id, asset != null); | 176 | m_log.DebugFormat("[TEXTURED MAP TILE RENDERER]: Fetched texture {0}, found: {1}", id, asset != null); |
177 | if (asset == null) return null; | 177 | if (asset == null) return null; |
178 | 178 | ||
179 | ManagedImage managedImage; | 179 | ManagedImage managedImage; |
@@ -188,17 +188,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
188 | } | 188 | } |
189 | catch (DllNotFoundException) | 189 | catch (DllNotFoundException) |
190 | { | 190 | { |
191 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id); | 191 | m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id); |
192 | 192 | ||
193 | } | 193 | } |
194 | catch (IndexOutOfRangeException) | 194 | catch (IndexOutOfRangeException) |
195 | { | 195 | { |
196 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); | 196 | m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); |
197 | 197 | ||
198 | } | 198 | } |
199 | catch (Exception) | 199 | catch (Exception) |
200 | { | 200 | { |
201 | m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); | 201 | m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); |
202 | 202 | ||
203 | } | 203 | } |
204 | return null; | 204 | return null; |
@@ -233,10 +233,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
233 | if (textureID == UUID.Zero) return defaultColor; // not set | 233 | if (textureID == UUID.Zero) return defaultColor; // not set |
234 | if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures | 234 | if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures |
235 | 235 | ||
236 | Bitmap bmp = fetchTexture(textureID); | 236 | Color color; |
237 | Color color = bmp == null ? defaultColor : computeAverageColor(bmp); | 237 | |
238 | // store it for future reference | 238 | using (Bitmap bmp = fetchTexture(textureID)) |
239 | m_mapping[textureID] = color; | 239 | { |
240 | color = bmp == null ? defaultColor : computeAverageColor(bmp); | ||
241 | // store it for future reference | ||
242 | m_mapping[textureID] = color; | ||
243 | } | ||
240 | 244 | ||
241 | return color; | 245 | return color; |
242 | } | 246 | } |
@@ -278,7 +282,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
278 | public void TerrainToBitmap(Bitmap mapbmp) | 282 | public void TerrainToBitmap(Bitmap mapbmp) |
279 | { | 283 | { |
280 | int tc = Environment.TickCount; | 284 | int tc = Environment.TickCount; |
281 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); | 285 | m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Terrain"); |
282 | 286 | ||
283 | // These textures should be in the AssetCache anyway, as every client conneting to this | 287 | // These textures should be in the AssetCache anyway, as every client conneting to this |
284 | // region needs them. Except on start, when the map is recreated (before anyone connected), | 288 | // region needs them. Except on start, when the map is recreated (before anyone connected), |
@@ -412,7 +416,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
412 | } | 416 | } |
413 | } | 417 | } |
414 | } | 418 | } |
415 | m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | 419 | |
420 | m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); | ||
416 | } | 421 | } |
417 | } | 422 | } |
418 | } | 423 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 98fa763..5412359 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
115 | "export-map [<path>]", | 115 | "export-map [<path>]", |
116 | "Save an image of the world map", HandleExportWorldMapConsoleCommand); | 116 | "Save an image of the world map", HandleExportWorldMapConsoleCommand); |
117 | 117 | ||
118 | m_scene.AddCommand( | ||
119 | "Regions", this, "generate map", | ||
120 | "generate map", | ||
121 | "Generates and stores a new maptile.", HandleGenerateMapConsoleCommand); | ||
122 | |||
118 | AddHandlers(); | 123 | AddHandlers(); |
119 | } | 124 | } |
120 | } | 125 | } |
@@ -1324,6 +1329,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1324 | m_scene.RegionInfo.RegionName, exportPath); | 1329 | m_scene.RegionInfo.RegionName, exportPath); |
1325 | } | 1330 | } |
1326 | 1331 | ||
1332 | public void HandleGenerateMapConsoleCommand(string module, string[] cmdparams) | ||
1333 | { | ||
1334 | Scene consoleScene = m_scene.ConsoleScene(); | ||
1335 | |||
1336 | if (consoleScene != null && consoleScene != m_scene) | ||
1337 | return; | ||
1338 | |||
1339 | GenerateMaptile(); | ||
1340 | } | ||
1341 | |||
1327 | public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) | 1342 | public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) |
1328 | { | 1343 | { |
1329 | uint xstart = 0; | 1344 | uint xstart = 0; |
@@ -1561,88 +1576,69 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1561 | 1576 | ||
1562 | private Byte[] GenerateOverlay() | 1577 | private Byte[] GenerateOverlay() |
1563 | { | 1578 | { |
1564 | Bitmap overlay = new Bitmap(256, 256); | 1579 | using (Bitmap overlay = new Bitmap(256, 256)) |
1565 | |||
1566 | bool[,] saleBitmap = new bool[64, 64]; | ||
1567 | for (int x = 0 ; x < 64 ; x++) | ||
1568 | { | 1580 | { |
1569 | for (int y = 0 ; y < 64 ; y++) | 1581 | bool[,] saleBitmap = new bool[64, 64]; |
1570 | saleBitmap[x, y] = false; | 1582 | for (int x = 0 ; x < 64 ; x++) |
1571 | } | 1583 | { |
1572 | 1584 | for (int y = 0 ; y < 64 ; y++) | |
1573 | bool landForSale = false; | 1585 | saleBitmap[x, y] = false; |
1586 | } | ||
1574 | 1587 | ||
1575 | List<ILandObject> parcels = m_scene.LandChannel.AllParcels(); | 1588 | bool landForSale = false; |
1576 | 1589 | ||
1577 | Color background = Color.FromArgb(0, 0, 0, 0); | 1590 | List<ILandObject> parcels = m_scene.LandChannel.AllParcels(); |
1578 | SolidBrush transparent = new SolidBrush(background); | ||
1579 | Graphics g = Graphics.FromImage(overlay); | ||
1580 | g.FillRectangle(transparent, 0, 0, 255, 255); | ||
1581 | 1591 | ||
1582 | SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); | 1592 | Color background = Color.FromArgb(0, 0, 0, 0); |
1583 | Pen grey = new Pen(Color.FromArgb(255, 92, 92, 92)); | ||
1584 | 1593 | ||
1585 | foreach (ILandObject land in parcels) | 1594 | using (Graphics g = Graphics.FromImage(overlay)) |
1586 | { | ||
1587 | // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags); | ||
1588 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) | ||
1589 | { | 1595 | { |
1590 | landForSale = true; | 1596 | using (SolidBrush transparent = new SolidBrush(background)) |
1591 | 1597 | g.FillRectangle(transparent, 0, 0, 256, 256); | |
1592 | bool[,] landBitmap = land.GetLandBitmap(); | 1598 | |
1599 | |||
1600 | foreach (ILandObject land in parcels) | ||
1601 | { | ||
1602 | // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags); | ||
1603 | if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0) | ||
1604 | { | ||
1605 | landForSale = true; | ||
1606 | |||
1607 | saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap()); | ||
1608 | } | ||
1609 | } | ||
1610 | |||
1611 | if (!landForSale) | ||
1612 | { | ||
1613 | m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName); | ||
1614 | return null; | ||
1615 | } | ||
1616 | |||
1617 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); | ||
1593 | 1618 | ||
1594 | for (int x = 0 ; x < 64 ; x++) | 1619 | using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9))) |
1595 | { | 1620 | { |
1596 | for (int y = 0 ; y < 64 ; y++) | 1621 | for (int x = 0 ; x < 64 ; x++) |
1597 | { | 1622 | { |
1598 | if (landBitmap[x, y]) | 1623 | for (int y = 0 ; y < 64 ; y++) |
1599 | { | 1624 | { |
1600 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | 1625 | if (saleBitmap[x, y]) |
1601 | 1626 | g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); | |
1602 | if (x > 0) | ||
1603 | { | ||
1604 | if ((saleBitmap[x - 1, y] || landBitmap[x - 1, y]) == false) | ||
1605 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4, 255 - (y * 4)); | ||
1606 | } | ||
1607 | if (y > 0) | ||
1608 | { | ||
1609 | if ((saleBitmap[x, y-1] || landBitmap[x, y-1]) == false) | ||
1610 | g.DrawLine(grey, x * 4, 255 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1611 | } | ||
1612 | if (x < 63) | ||
1613 | { | ||
1614 | if ((saleBitmap[x + 1, y] || landBitmap[x + 1, y]) == false) | ||
1615 | g.DrawLine(grey, x * 4 + 3, 252 - (y * 4), x * 4 + 3, 255 - (y * 4)); | ||
1616 | } | ||
1617 | if (y < 63) | ||
1618 | { | ||
1619 | if ((saleBitmap[x, y + 1] || landBitmap[x, y + 1]) == false) | ||
1620 | g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4 + 3, 252 - (y * 4)); | ||
1621 | } | ||
1622 | } | 1627 | } |
1623 | } | 1628 | } |
1624 | } | 1629 | } |
1625 | |||
1626 | saleBitmap = land.MergeLandBitmaps(saleBitmap, landBitmap); | ||
1627 | } | 1630 | } |
1628 | } | ||
1629 | 1631 | ||
1630 | if (!landForSale) | 1632 | try |
1631 | { | 1633 | { |
1632 | m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName); | 1634 | return OpenJPEG.EncodeFromImage(overlay, true); |
1633 | return null; | 1635 | } |
1636 | catch (Exception e) | ||
1637 | { | ||
1638 | m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString()); | ||
1639 | } | ||
1634 | } | 1640 | } |
1635 | 1641 | ||
1636 | m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); | ||
1637 | |||
1638 | try | ||
1639 | { | ||
1640 | return OpenJPEG.EncodeFromImage(overlay, true); | ||
1641 | } | ||
1642 | catch (Exception e) | ||
1643 | { | ||
1644 | m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString()); | ||
1645 | } | ||
1646 | return null; | 1642 | return null; |
1647 | } | 1643 | } |
1648 | } | 1644 | } |