Improve previous ILandObject method doc.

For test code, take a part name prefix when creating objects, so that these can be more easily identified in the logs
0.7.1-dev
Justin Clark-Casey (justincc) 2011-04-06 18:57:50 +01:00
parent fa202a05e9
commit 63533412f8
5 changed files with 104 additions and 56 deletions

View File

@ -92,8 +92,12 @@ namespace OpenSim.Framework
/// Create a square land bitmap. /// Create a square land bitmap.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Land co-ordinates are zero indexed. At the moment, the smallest parcel of land is 4m x 4m, so if the /// Land co-ordinates are zero indexed. The inputs are treated as points. So if you want to create a bitmap
/// region is 256 x 256m (the SL size), the largest land parcel starts at (0,0) and ends at (63,63). /// that covers an entire 256 x 256m region apart from a strip of land on the east, then you would need to
/// specify start_x = 0, start_y = 0, end_x = 252 (or anything up to 255), end_y = 256.
///
/// At the moment, the smallest parcel of land is 4m x 4m, so if the
/// region is 256 x 256m (the SL size), the bitmap returned will start at (0,0) and end at (63,63).
/// </remarks> /// </remarks>
/// <param name="start_x"></param> /// <param name="start_x"></param>
/// <param name="start_y"></param> /// <param name="start_y"></param>

View File

@ -612,6 +612,10 @@ namespace OpenSim.Region.CoreModules.World.Land
{ {
if (landBitmap[x, y]) if (landBitmap[x, y])
{ {
// m_log.DebugFormat(
// "[LAND MANAGEMENT MODULE]: Registering parcel {0} for land co-ord ({1}, {2}) on {3}",
// new_land.LandData.Name, x, y, m_scene.RegionInfo.RegionName);
m_landIDList[x, y] = newLandLocalID; m_landIDList[x, y] = newLandLocalID;
} }
} }
@ -741,8 +745,16 @@ namespace OpenSim.Region.CoreModules.World.Land
// Corner case. If an autoreturn happens during sim startup // Corner case. If an autoreturn happens during sim startup
// we will come here with the list uninitialized // we will come here with the list uninitialized
// //
int landId = m_landIDList[x, y];
// if (landId == 0)
// m_log.DebugFormat(
// "[LAND MANAGEMENT MODULE]: No land object found at ({0}, {1}) on {2}",
// x, y, m_scene.RegionInfo.RegionName);
if (m_landList.ContainsKey(m_landIDList[x, y])) if (m_landList.ContainsKey(m_landIDList[x, y]))
return m_landList[m_landIDList[x, y]]; return m_landList[m_landIDList[x, y]];
return null; return null;
} }
} }

View File

@ -174,8 +174,6 @@ namespace OpenSim.Region.CoreModules.World.Land
// NOTE: Call under Taint Lock // NOTE: Call under Taint Lock
private void AddObject(SceneObjectGroup obj) private void AddObject(SceneObjectGroup obj)
{ {
// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding object {0} {1} to prim count", obj.Name, obj.UUID);
if (obj.IsAttachment) if (obj.IsAttachment)
return; return;
if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0)) if (((obj.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0))
@ -186,10 +184,20 @@ namespace OpenSim.Region.CoreModules.World.Land
// If for some reason there is no land object (perhaps the object is out of bounds) then we can't count it // If for some reason there is no land object (perhaps the object is out of bounds) then we can't count it
if (landObject == null) if (landObject == null)
{
// m_log.WarnFormat(
// "[PRIM COUNT MODULE]: Found no land object for {0} at position ({1}, {2}) on {3}",
// obj.Name, pos.X, pos.Y, m_Scene.RegionInfo.RegionName);
return; return;
}
LandData landData = landObject.LandData; LandData landData = landObject.LandData;
// m_log.DebugFormat(
// "[PRIM COUNT MODULE]: Adding object {0} with {1} parts to prim count for parcel {2} on {3}",
// obj.Name, obj.Parts.Length, landData.Name, m_Scene.RegionInfo.RegionName);
// m_log.DebugFormat( // m_log.DebugFormat(
// "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}", // "[PRIM COUNT MODULE]: Object {0} is owned by {1} over land owned by {2}",
// obj.Name, obj.OwnerID, landData.OwnerID); // obj.Name, obj.OwnerID, landData.OwnerID);
@ -473,7 +481,9 @@ namespace OpenSim.Region.CoreModules.World.Land
m_OwnerMap[landData.GlobalID] = landData.OwnerID; m_OwnerMap[landData.GlobalID] = landData.OwnerID;
m_SimwideCounts[landData.OwnerID] = 0; m_SimwideCounts[landData.OwnerID] = 0;
// m_log.DebugFormat("[PRIM COUNT MODULE]: Adding parcel count for {0}", landData.GlobalID); // m_log.DebugFormat(
// "[PRIM COUNT MODULE]: Initializing parcel count for {0} on {1}",
// landData.Name, m_Scene.RegionInfo.RegionName);
m_ParcelCounts[landData.GlobalID] = new ParcelCounts(); m_ParcelCounts[landData.GlobalID] = new ParcelCounts();
} }

View File

@ -51,10 +51,15 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
protected PrimCountModule m_pcm; protected PrimCountModule m_pcm;
/// <summary> /// <summary>
/// A parcel that covers the entire sim. /// A parcel that covers the entire sim except for a 1 unit wide strip on the eastern side.
/// </summary> /// </summary>
protected ILandObject m_lo; protected ILandObject m_lo;
/// <summary>
/// A parcel that covers just the eastern strip of the sim.
/// </summary>
protected ILandObject m_lo2;
[SetUp] [SetUp]
public void SetUp() public void SetUp()
{ {
@ -63,10 +68,19 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
m_scene = SceneSetupHelpers.SetupScene(); m_scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm); SceneSetupHelpers.SetupSceneModules(m_scene, lmm, m_pcm);
int xParcelDivider = (int)Constants.RegionSize - 1;
ILandObject lo = new LandObject(m_userId, false, m_scene); ILandObject lo = new LandObject(m_userId, false, m_scene);
lo.LandData.Name = "m_lo";
lo.SetLandBitmap( lo.SetLandBitmap(
lo.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize / 4 - 1, (int)Constants.RegionSize / 4 - 1)); lo.GetSquareLandBitmap(0, 0, xParcelDivider, (int)Constants.RegionSize));
m_lo = lmm.AddLandObject(lo); m_lo = lmm.AddLandObject(lo);
ILandObject lo2 = new LandObject(m_userId, false, m_scene);
lo2.SetLandBitmap(
lo2.GetSquareLandBitmap(xParcelDivider, 0, (int)Constants.RegionSize, (int)Constants.RegionSize));
lo2.LandData.Name = "m_lo2";
m_lo2 = lmm.AddLandObject(lo2);
} }
/// <summary> /// <summary>
@ -98,7 +112,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts; IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false); m_scene.AddNewSceneObject(sog, false);
Assert.That(pc.Owner, Is.EqualTo(3)); Assert.That(pc.Owner, Is.EqualTo(3));
@ -111,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
Assert.That(pc.Simulator, Is.EqualTo(3)); Assert.That(pc.Simulator, Is.EqualTo(3));
// Add a second object and retest // Add a second object and retest
SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, 0x10); SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(sog2, false); m_scene.AddNewSceneObject(sog2, false);
Assert.That(pc.Owner, Is.EqualTo(5)); Assert.That(pc.Owner, Is.EqualTo(5));
@ -135,7 +149,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts; IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false); m_scene.AddNewSceneObject(sog, false);
m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity); m_scene.SceneGraph.DuplicateObject(sog.LocalId, Vector3.Zero, 0, m_userId, UUID.Zero, Quaternion.Identity);
@ -156,35 +170,37 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
//[Test] //[Test]
public void TestMoveOwnerObject() public void TestMoveOwnerObject()
{ {
// TestHelper.InMethod(); TestHelper.InMethod();
//// log4net.Config.XmlConfigurator.Configure(); log4net.Config.XmlConfigurator.Configure();
//
// IPrimCounts pc = m_lo.PrimCounts; SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
// m_scene.AddNewSceneObject(sog, false);
// SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, "b", 0x10);
// m_scene.AddNewSceneObject(sog, false); m_scene.AddNewSceneObject(sog2, false);
//
// Assert.That(pc.Owner, Is.EqualTo(3)); sog.AbsolutePosition = new Vector3(254, 2, 2);
// Assert.That(pc.Group, Is.EqualTo(0));
// Assert.That(pc.Others, Is.EqualTo(0)); IPrimCounts pclo1 = m_lo.PrimCounts;
// Assert.That(pc.Total, Is.EqualTo(3));
// Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pclo1.Owner, Is.EqualTo(2));
// Assert.That(pc.Users[m_userId], Is.EqualTo(3)); Assert.That(pclo1.Group, Is.EqualTo(0));
// Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); Assert.That(pclo1.Others, Is.EqualTo(0));
// Assert.That(pc.Simulator, Is.EqualTo(3)); Assert.That(pclo1.Total, Is.EqualTo(2));
// Assert.That(pclo1.Selected, Is.EqualTo(0));
// // Add a second object and retest Assert.That(pclo1.Users[m_userId], Is.EqualTo(2));
// SceneObjectGroup sog2 = SceneSetupHelpers.CreateSceneObject(2, m_userId, 0x10); Assert.That(pclo1.Users[m_otherUserId], Is.EqualTo(0));
// m_scene.AddNewSceneObject(sog2, false); Assert.That(pclo1.Simulator, Is.EqualTo(2));
//
// Assert.That(pc.Owner, Is.EqualTo(5)); IPrimCounts pclo2 = m_lo2.PrimCounts;
// Assert.That(pc.Group, Is.EqualTo(0));
// Assert.That(pc.Others, Is.EqualTo(0)); Assert.That(pclo2.Owner, Is.EqualTo(3));
// Assert.That(pc.Total, Is.EqualTo(5)); Assert.That(pclo2.Group, Is.EqualTo(0));
// Assert.That(pc.Selected, Is.EqualTo(0)); Assert.That(pclo2.Others, Is.EqualTo(0));
// Assert.That(pc.Users[m_userId], Is.EqualTo(5)); Assert.That(pclo2.Total, Is.EqualTo(3));
// Assert.That(pc.Users[m_otherUserId], Is.EqualTo(0)); Assert.That(pclo2.Selected, Is.EqualTo(0));
// Assert.That(pc.Simulator, Is.EqualTo(5)); Assert.That(pclo2.Users[m_userId], Is.EqualTo(3));
Assert.That(pclo2.Users[m_otherUserId], Is.EqualTo(0));
Assert.That(pclo2.Simulator, Is.EqualTo(3));
} }
/// <summary> /// <summary>
@ -198,8 +214,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts; IPrimCounts pc = m_lo.PrimCounts;
m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, 0x1), false); m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1), false);
SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x10); SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(sogToDelete, false); m_scene.AddNewSceneObject(sogToDelete, false);
m_scene.DeleteSceneObject(sogToDelete, false); m_scene.DeleteSceneObject(sogToDelete, false);
@ -223,7 +239,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts; IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x01); SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
sog.GroupID = m_groupId; sog.GroupID = m_groupId;
m_scene.AddNewSceneObject(sog, false); m_scene.AddNewSceneObject(sog, false);
@ -254,11 +270,11 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts; IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, 0x1); SceneObjectGroup sogToKeep = SceneSetupHelpers.CreateSceneObject(1, m_userId, "a", 0x1);
sogToKeep.GroupID = m_groupId; sogToKeep.GroupID = m_groupId;
m_scene.AddNewSceneObject(sogToKeep, false); m_scene.AddNewSceneObject(sogToKeep, false);
SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x10); SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_userId, "b", 0x10);
m_scene.AddNewSceneObject(sogToDelete, false); m_scene.AddNewSceneObject(sogToDelete, false);
m_scene.DeleteSceneObject(sogToDelete, false); m_scene.DeleteSceneObject(sogToDelete, false);
@ -281,7 +297,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts; IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x01); SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false); m_scene.AddNewSceneObject(sog, false);
Assert.That(pc.Owner, Is.EqualTo(0)); Assert.That(pc.Owner, Is.EqualTo(0));
@ -302,8 +318,8 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
IPrimCounts pc = m_lo.PrimCounts; IPrimCounts pc = m_lo.PrimCounts;
m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, 0x1), false); m_scene.AddNewSceneObject(SceneSetupHelpers.CreateSceneObject(1, m_otherUserId, "a", 0x1), false);
SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, 0x10); SceneObjectGroup sogToDelete = SceneSetupHelpers.CreateSceneObject(3, m_otherUserId, "b", 0x10);
m_scene.AddNewSceneObject(sogToDelete, false); m_scene.AddNewSceneObject(sogToDelete, false);
m_scene.DeleteSceneObject(sogToDelete, false); m_scene.DeleteSceneObject(sogToDelete, false);
@ -326,7 +342,7 @@ namespace OpenSim.Region.CoreModules.World.Land.Tests
TestHelper.InMethod(); TestHelper.InMethod();
IPrimCounts pc = m_lo.PrimCounts; IPrimCounts pc = m_lo.PrimCounts;
SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, 0x01); SceneObjectGroup sog = SceneSetupHelpers.CreateSceneObject(3, m_userId, "a", 0x01);
m_scene.AddNewSceneObject(sog, false); m_scene.AddNewSceneObject(sog, false);
m_pcm.TaintPrimCount(); m_pcm.TaintPrimCount();

View File

@ -489,32 +489,38 @@ namespace OpenSim.Tests.Common.Setup
/// <returns></returns> /// <returns></returns>
public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId) public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId)
{ {
return CreateSceneObject(parts, ownerId, 0x1); return CreateSceneObject(parts, ownerId, "", 0x1);
} }
/// <summary> /// <summary>
/// Create a scene object but do not add it to the scene. /// Create a scene object but do not add it to the scene.
/// </summary> /// </summary>
/// <param name="parts">The number of parts that should be in the scene object</param> /// <param name="parts">
/// The number of parts that should be in the scene object
/// </param>
/// <param name="ownerId"></param> /// <param name="ownerId"></param>
/// <param name="partNamePrefix">
/// The prefix to be given to part names. This will be suffixed with "Part<part no>"
/// (e.g. mynamePart0 for the root part)
/// </param>
/// <param name="uuidTail"> /// <param name="uuidTail">
/// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}" /// The hexadecimal last part of the UUID for parts created. A UUID of the form "00000000-0000-0000-0000-{0:XD12}"
/// will be given to the root part, and incremented for each part thereafter. /// will be given to the root part, and incremented for each part thereafter.
/// </param> /// </param>
/// <returns></returns> /// <returns></returns>
public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, int uuidTail) public static SceneObjectGroup CreateSceneObject(int parts, UUID ownerId, string partNamePrefix, int uuidTail)
{ {
string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail); string rawSogId = string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail);
SceneObjectGroup sog SceneObjectGroup sog
= new SceneObjectGroup( = new SceneObjectGroup(
CreateSceneObjectPart("part0", new UUID(rawSogId), ownerId)); CreateSceneObjectPart(string.Format("{0}Part0", partNamePrefix), new UUID(rawSogId), ownerId));
if (parts > 1) if (parts > 1)
for (int i = 1; i < parts; i++) for (int i = 1; i < parts; i++)
sog.AddPart( sog.AddPart(
CreateSceneObjectPart( CreateSceneObjectPart(
string.Format("obj{0}", i), string.Format("{0}Part{1}", partNamePrefix, i),
new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)), new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail + i)),
ownerId)); ownerId));