diff options
author | Homer Horwitz | 2008-10-05 19:06:00 +0000 |
---|---|---|
committer | Homer Horwitz | 2008-10-05 19:06:00 +0000 |
commit | 5a31fb9df4ed0df20aca27f4f12e595b2bb3a5f6 (patch) | |
tree | f37730a5bbfb1abbbbeb2777c09fee291da7b601 /OpenSim | |
parent | * Fixes the last snag with the EventQueue. The situation where the seedcap g... (diff) | |
download | opensim-SC-5a31fb9df4ed0df20aca27f4f12e595b2bb3a5f6.zip opensim-SC-5a31fb9df4ed0df20aca27f4f12e595b2bb3a5f6.tar.gz opensim-SC-5a31fb9df4ed0df20aca27f4f12e595b2bb3a5f6.tar.bz2 opensim-SC-5a31fb9df4ed0df20aca27f4f12e595b2bb3a5f6.tar.xz |
Fix a problem with land-search and non-convex parcels.
You'll need to update your snapshots.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/DataSnapshot/LandSnapshot.cs | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/OpenSim/Region/DataSnapshot/LandSnapshot.cs b/OpenSim/Region/DataSnapshot/LandSnapshot.cs index 680a1fa..5288c74 100644 --- a/OpenSim/Region/DataSnapshot/LandSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/LandSnapshot.cs | |||
@@ -189,9 +189,10 @@ namespace OpenSim.Region.DataSnapshot.Providers | |||
189 | xmlparcel.AppendChild(tpLocation); | 189 | xmlparcel.AppendChild(tpLocation); |
190 | 190 | ||
191 | XmlNode infouuid = nodeFactory.CreateNode(XmlNodeType.Element, "infouuid", ""); | 191 | XmlNode infouuid = nodeFactory.CreateNode(XmlNodeType.Element, "infouuid", ""); |
192 | uint x = (uint)loc.X, y = (uint)loc.Y; | ||
193 | findPointInParcel(land, ref x, ref y); // find a suitable spot | ||
192 | infouuid.InnerText = Util.BuildFakeParcelID( | 194 | infouuid.InnerText = Util.BuildFakeParcelID( |
193 | m_scene.RegionInfo.RegionHandle, | 195 | m_scene.RegionInfo.RegionHandle, x, y).ToString(); |
194 | (uint)loc.X, (uint)loc.Y).ToString(); | ||
195 | xmlparcel.AppendChild(infouuid); | 196 | xmlparcel.AppendChild(infouuid); |
196 | 197 | ||
197 | XmlNode dwell = nodeFactory.CreateNode(XmlNodeType.Element, "dwell", ""); | 198 | XmlNode dwell = nodeFactory.CreateNode(XmlNodeType.Element, "dwell", ""); |
@@ -345,5 +346,41 @@ namespace OpenSim.Region.DataSnapshot.Providers | |||
345 | } | 346 | } |
346 | 347 | ||
347 | #endregion | 348 | #endregion |
349 | |||
350 | // this is needed for non-convex parcels (example: rectangular parcel, and in the exact center | ||
351 | // another, smaller rectangular parcel). Both will have the same initial coordinates. | ||
352 | private void findPointInParcel(ILandObject land, ref uint refX, ref uint refY) | ||
353 | { | ||
354 | m_log.DebugFormat("[LAND] trying {0}, {1}", refX, refY); | ||
355 | // the point we started with already is in the parcel | ||
356 | if (land.containsPoint((int)refX, (int)refY)) return; | ||
357 | |||
358 | // ... otherwise, we have to search for a point within the parcel | ||
359 | uint startX = (uint)land.landData.AABBMin.X; | ||
360 | uint startY = (uint)land.landData.AABBMin.Y; | ||
361 | uint endX = (uint)land.landData.AABBMax.X; | ||
362 | uint endY = (uint)land.landData.AABBMax.Y; | ||
363 | |||
364 | // default: center of the parcel | ||
365 | refX = (startX + endX) / 2; | ||
366 | refY = (startY + endY) / 2; | ||
367 | // If the center point is within the parcel, take that one | ||
368 | if (land.containsPoint((int)refX, (int)refY)) return; | ||
369 | |||
370 | // otherwise, go the long way. | ||
371 | for (uint y = startY; y <= endY; ++y) | ||
372 | { | ||
373 | for (uint x = startX; x <= endX; ++x) | ||
374 | { | ||
375 | if (land.containsPoint((int)x, (int)y)) | ||
376 | { | ||
377 | // found a point | ||
378 | refX = x; | ||
379 | refY = y; | ||
380 | return; | ||
381 | } | ||
382 | } | ||
383 | } | ||
384 | } | ||
348 | } | 385 | } |
349 | } | 386 | } |