mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 10:46:00 +08:00
Add coalesced scene objects class and serializer. This is currently only used by the TestRezCoalescedObject() regression test.
This structure matches the existing one for SceneObjects and will allow code to be reused by the uuid gatherer, other tests, etc. Test is not yet fully implemented due to a bug in rezzing coalesced objects where they all get the same name as the item. Only one object should get the same name as the item, which appears to be the one selected last when the the objects were coalesced in the first place. This bug will be addressed shortly.
This commit is contained in:
@@ -274,7 +274,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
float minX, minY, minZ;
|
||||
float maxX, maxY, maxZ;
|
||||
|
||||
Vector3[] offsets = m_Scene.GetCombinedBoundingBox(objlist,
|
||||
Vector3[] offsets = Scene.GetCombinedBoundingBox(objlist,
|
||||
out minX, out maxX, out minY, out maxY,
|
||||
out minZ, out maxZ);
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
XmlDocument doc = new XmlDocument();
|
||||
SceneObjectGroup g = objlist[i];
|
||||
doc.LoadXml(xmlStrings[g.UUID]);
|
||||
XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup");
|
||||
XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup");
|
||||
e.SetAttribute("offsetx", offsets[i].X.ToString());
|
||||
e.SetAttribute("offsety", offsets[i].Y.ToString());
|
||||
e.SetAttribute("offsetz", offsets[i].Z.ToString());
|
||||
@@ -659,9 +659,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||
itemId, n.OuterXml);
|
||||
objlist.Add(g);
|
||||
XmlElement el = (XmlElement)n;
|
||||
float x = Convert.ToSingle(el.GetAttribute("offsetx"));
|
||||
float y = Convert.ToSingle(el.GetAttribute("offsety"));
|
||||
float z = Convert.ToSingle(el.GetAttribute("offsetz"));
|
||||
|
||||
string rawX = el.GetAttribute("offsetx");
|
||||
string rawY = el.GetAttribute("offsety");
|
||||
string rawZ = el.GetAttribute("offsetz");
|
||||
//
|
||||
// m_log.DebugFormat(
|
||||
// "[INVENTORY ACCESS MODULE]: Converting coalesced object {0} offset <{1}, {2}, {3}>",
|
||||
// g.Name, rawX, rawY, rawZ);
|
||||
|
||||
float x = Convert.ToSingle(rawX);
|
||||
float y = Convert.ToSingle(rawY);
|
||||
float z = Convert.ToSingle(rawZ);
|
||||
veclist.Add(new Vector3(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,85 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
|
||||
m_tc = new TestClient(acd, m_scene);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRezCoalescedObject()
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
// Create asset
|
||||
SceneObjectGroup object1;
|
||||
{
|
||||
string partName = "Object1";
|
||||
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
|
||||
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
|
||||
Vector3 groupPosition = new Vector3(10, 20, 30);
|
||||
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
|
||||
Vector3 offsetPosition = new Vector3(5, 10, 15);
|
||||
|
||||
SceneObjectPart part1
|
||||
= new SceneObjectPart(
|
||||
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
|
||||
part1.Name = partName;
|
||||
|
||||
object1 = new SceneObjectGroup(part1);
|
||||
}
|
||||
|
||||
SceneObjectGroup object2;
|
||||
{
|
||||
string partName = "Object2";
|
||||
UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040");
|
||||
PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere();
|
||||
Vector3 groupPosition = new Vector3(10, 20, 30);
|
||||
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
|
||||
Vector3 offsetPosition = new Vector3(5, 10, 15);
|
||||
|
||||
SceneObjectPart part1
|
||||
= new SceneObjectPart(
|
||||
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
|
||||
part1.Name = partName;
|
||||
|
||||
object2 = new SceneObjectGroup(part1);
|
||||
}
|
||||
|
||||
CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2);
|
||||
|
||||
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
|
||||
AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, coa);
|
||||
m_scene.AssetService.Store(asset1);
|
||||
|
||||
// Create item
|
||||
UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
|
||||
string item1Name = "My Little Dog";
|
||||
InventoryItemBase item1 = new InventoryItemBase();
|
||||
item1.Name = item1Name;
|
||||
item1.AssetID = asset1.FullID;
|
||||
item1.ID = item1Id;
|
||||
InventoryFolderBase objsFolder
|
||||
= InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0];
|
||||
item1.Folder = objsFolder.ID;
|
||||
m_scene.AddInventoryItem(item1);
|
||||
|
||||
SceneObjectGroup so
|
||||
= m_iam.RezObject(
|
||||
m_tc, item1Id, Vector3.Zero, Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false);
|
||||
|
||||
Assert.That(so, Is.Not.Null);
|
||||
|
||||
Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(2));
|
||||
|
||||
SceneObjectPart retrievedObj1Part = m_scene.GetSceneObjectPart(object1.Name);
|
||||
Assert.That(retrievedObj1Part, Is.Null);
|
||||
|
||||
retrievedObj1Part = m_scene.GetSceneObjectPart(item1.Name);
|
||||
Assert.That(retrievedObj1Part, Is.Not.Null);
|
||||
Assert.That(retrievedObj1Part.Name, Is.EqualTo(item1.Name));
|
||||
|
||||
// FIXME: Can't test yet due to a bug where objects in coalescence all get the item name when rerezzed.
|
||||
// SceneObjectPart retrievedObj2Part = m_scene.GetSceneObjectPart(object2.Name);
|
||||
// Assert.That(retrievedObj2Part, Is.Not.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestRezObject()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user