public void Init() { TestHelper.InMethod(); scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); interregionComms.Initialise(new IniConfigSource()); interregionComms.PostInitialise(); SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); SceneSetupHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms); agent1 = UUID.Random(); agent2 = UUID.Random(); agent3 = UUID.Random(); random = new Random(); sog1 = NewSOG(UUID.Random(), scene, agent1); sog2 = NewSOG(UUID.Random(), scene, agent1); sog3 = NewSOG(UUID.Random(), scene, agent1); //ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); region1 = scene.RegionInfo.RegionHandle; region2 = scene2.RegionInfo.RegionHandle; region3 = scene3.RegionInfo.RegionHandle; }
public void TestPartSerialzationDeserialization() { SceneObjectPart rootPart = new SceneObjectPart(UUID.Zero, new OpenSim.Framework.PrimitiveBaseShape(), new Vector3(1, 2, 3), Quaternion.Identity, Vector3.Zero, false); rootPart.Name = "RootPart"; SceneObjectPart part = Util.RandomSOP("ChildPart", 2); var pgrp1 = new SceneObjectGroup(rootPart); pgrp1.AddPart(part); part.InventorySerial = 1; part.Rezzed = DateTime.Now; part.TextColor = System.Drawing.Color.FromArgb(1,2,3,4); byte[] bytes = serEngine.SceneObjectSerializer.SerializePartToBytes(part, OpenSim.Region.Framework.Scenes.Serialization.SerializationFlags.None); SceneObjectPart rootPart2 = new SceneObjectPart(UUID.Zero, new OpenSim.Framework.PrimitiveBaseShape(), new Vector3(1, 2, 3), Quaternion.Identity, Vector3.Zero, false); rootPart2.Name = "RootPart2"; SceneObjectPart deserPart = serEngine.SceneObjectSerializer.DeserializePartFromBytes(bytes); var pgrp2 = new SceneObjectGroup(rootPart2); pgrp2.AddPart(deserPart); deserPart.Rezzed = part.Rezzed; CompareObjects comp = new CompareObjects(); comp.CompareStaticFields = false; comp.CompareStaticProperties = false; comp.ElementsToIgnore = PrimCompareIgnoreList; Assert.IsTrue(comp.Compare(part, deserPart), comp.DifferencesString); }
public void AddObject(SceneObjectGroup obj) { if (m_childNodes == null) { if (!m_objects.Contains(obj)) { m_objects.Add(obj); } } else { if (obj.AbsolutePosition.X < (m_leftX + (m_width/2))) { if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) { m_childNodes[0].AddObject(obj); } else { m_childNodes[2].AddObject(obj); } } else { if (obj.AbsolutePosition.Y < (m_leftY + (m_height/2))) { m_childNodes[1].AddObject(obj); } else { m_childNodes[3].AddObject(obj); } } } }
public void Init() { TestHelpers.InMethod(); scene = SceneHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); scene2 = SceneHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); scene3 = SceneHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); interregionComms.Initialise(new IniConfigSource()); interregionComms.PostInitialise(); SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms); SceneHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms); agent1 = UUID.Random(); agent2 = UUID.Random(); agent3 = UUID.Random(); random = new Random(); sog1 = SceneHelpers.CreateSceneObject(1, agent1); scene.AddSceneObject(sog1); sog2 = SceneHelpers.CreateSceneObject(1, agent1); scene.AddSceneObject(sog2); sog3 = SceneHelpers.CreateSceneObject(1, agent1); scene.AddSceneObject(sog3); region1 = scene.RegionInfo.RegionHandle; region2 = scene2.RegionInfo.RegionHandle; region3 = scene3.RegionInfo.RegionHandle; }
public void T010_AddObjects() { TestHelpers.InMethod(); random = new Random(); SceneObjectGroup found; EntityManager entman = new EntityManager(); SceneObjectGroup sog = NewSOG(); UUID obj1 = sog.UUID; uint li1 = sog.LocalId; entman.Add(sog); sog = NewSOG(); UUID obj2 = sog.UUID; uint li2 = sog.LocalId; entman.Add(sog); found = (SceneObjectGroup)entman[obj1]; Assert.That(found.UUID ,Is.EqualTo(obj1)); found = (SceneObjectGroup)entman[li1]; Assert.That(found.UUID ,Is.EqualTo(obj1)); found = (SceneObjectGroup)entman[obj2]; Assert.That(found.UUID ,Is.EqualTo(obj2)); found = (SceneObjectGroup)entman[li2]; Assert.That(found.UUID ,Is.EqualTo(obj2)); entman.Remove(obj1); entman.Remove(li2); Assert.That(entman.ContainsKey(obj1), Is.False); Assert.That(entman.ContainsKey(li1), Is.False); Assert.That(entman.ContainsKey(obj2), Is.False); Assert.That(entman.ContainsKey(li2), Is.False); }
public void TestGroupSerializationDeserialization() { var sop1 = SceneUtil.RandomSOP("Root", 1); var sop2 = SceneUtil.RandomSOP("Child1", 2); var sop3 = SceneUtil.RandomSOP("Child2", 3); SceneObjectGroup group = new SceneObjectGroup(sop1); group.AddPart(sop2); group.AddPart(sop3); SceneObjectGroup deserGroup = null; string grpBytes = null; Assert.DoesNotThrow(() => { grpBytes = SceneObjectSerializer.ToXml2Format(group, true); }); Assert.NotNull(grpBytes); Assert.DoesNotThrow(() => { deserGroup = SceneObjectSerializer.FromXml2Format(grpBytes); }); CompareObjects comp = new CompareObjects(); comp.CompareStaticFields = false; comp.CompareStaticProperties = false; comp.ElementsToIgnore = PrimCompareIgnoreList; Assert.IsTrue(comp.Compare(group, deserGroup), comp.DifferencesString); }
// Connect the Telehub public void Connect(SceneObjectGroup grp) { m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); m_Scene.RegionInfo.RegionSettings.TelehubObject = grp.UUID; m_Scene.RegionInfo.RegionSettings.Save(); }
/// <summary> /// Delete the given object from the scene /// </summary> public void DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient, bool permissionToDelete) { if (Enabled) lock (m_inventoryTicker) m_inventoryTicker.Stop(); lock (m_inventoryDeletes) { DeleteToInventoryHolder dtis = new DeleteToInventoryHolder(); dtis.action = action; dtis.folderID = folderID; dtis.objectGroup = objectGroup; dtis.remoteClient = remoteClient; dtis.permissionToDelete = permissionToDelete; m_inventoryDeletes.Enqueue(dtis); } if (Enabled) lock (m_inventoryTicker) m_inventoryTicker.Start(); // Visually remove it, even if it isnt really gone yet. This means that if we crash before the object // has gone to inventory, it will reappear in the region again on restart instead of being lost. // This is not ideal since the object will still be available for manipulation when it should be, but it's // better than losing the object for now. if (permissionToDelete) objectGroup.DeleteGroup(false); }
/// <summary> /// Create an asset from the given scene object. /// </summary> /// <param name="assetUuid"></param> /// <param name="sog"></param> /// <returns></returns> public static AssetBase CreateAsset(UUID assetUuid, SceneObjectGroup sog) { return CreateAsset( assetUuid, AssetType.Object, Encoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)), sog.OwnerID); }
/// <summary> /// Add an existing scene object as an item in the user's inventory. /// </summary> /// <remarks> /// Will be added to the system Objects folder. /// </remarks> /// <param name='scene'></param> /// <param name='so'></param> /// <param name='inventoryIdTail'></param> /// <param name='assetIdTail'></param> /// <returns>The inventory item created.</returns> public static InventoryItemBase AddInventoryItem( Scene scene, SceneObjectGroup so, int inventoryIdTail, int assetIdTail) { return AddInventoryItem( scene, so.Name, TestHelpers.ParseTail(inventoryIdTail), InventoryType.Object, AssetHelpers.CreateAsset(TestHelpers.ParseTail(assetIdTail), so), so.OwnerID); }
/// <summary> /// Deserialize a scene object from the original xml format /// </summary> /// <param name="xmlData"></param> /// <returns>The scene object deserialized. Null on failure.</returns> public static SceneObjectGroup FromOriginalXmlFormat(string xmlData) { //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); //int time = System.Environment.TickCount; try { StringReader sr; XmlTextReader reader; XmlNodeList parts; XmlDocument doc; int linkNum; doc = new XmlDocument(); doc.LoadXml(xmlData); parts = doc.GetElementsByTagName("RootPart"); if (parts.Count == 0) throw new Exception("Invalid Xml format - no root part"); sr = new StringReader(parts[0].InnerXml); reader = new XmlTextReader(sr); SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader)); reader.Close(); sr.Close(); parts = doc.GetElementsByTagName("Part"); for (int i = 0; i < parts.Count; i++) { sr = new StringReader(parts[i].InnerXml); reader = new XmlTextReader(sr); SceneObjectPart part = SceneObjectPart.FromXml(reader); linkNum = part.LinkNum; sceneObject.AddPart(part); part.LinkNum = linkNum; part.TrimPermissions(); reader.Close(); sr.Close(); } // Script state may, or may not, exist. Not having any, is NOT // ever a problem. sceneObject.LoadScriptState(doc); return sceneObject; } catch (Exception e) { m_log.ErrorFormat( "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData); return null; } }
/// <summary> /// Creates a new snapshot from the given group /// </summary> /// <param name="sog"></param> /// <returns></returns> public static SceneObjectGroupSnapshot FromSceneObjectGroup(SceneObjectGroup sog, SerializationFlags flags) { SceneObjectGroupSnapshot snapshot = new SceneObjectGroupSnapshot { RootPart = SceneObjectPartSnapshot.FromSceneObjectPart(sog.RootPart, flags) }; var parts = sog.GetParts(); SceneObjectPartSnapshot[] partsSnap; //do we have more than just the root? if (parts.Count > 1) { List<SceneObjectPartSnapshot> partsCollect = new List<SceneObjectPartSnapshot>(); foreach (SceneObjectPart part in parts) { if (!part.IsRootPart()) { partsCollect.Add(SceneObjectPartSnapshot.FromSceneObjectPart(part, flags)); } } partsSnap = partsCollect.ToArray(); } else { //nope, just the root partsSnap = new SceneObjectPartSnapshot[0]; } snapshot.ChildParts = partsSnap; if (sog.IsAttachment && sog.HasGroupChanged) { snapshot.TaintedAttachment = true; } else { snapshot.TaintedAttachment = false; } if (sog.IsAttachment && sog.IsTempAttachment) { snapshot.TempAttachment = true; } else { snapshot.TempAttachment = false; } return snapshot; }
public void TestDuplicateObject() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); Scene scene = new SceneHelpers().SetupScene(); UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010"); string part1Name = "part1"; UUID part1Id = new UUID("00000000-0000-0000-0000-000000000001"); string part2Name = "part2"; UUID part2Id = new UUID("00000000-0000-0000-0000-000000000002"); SceneObjectPart part1 = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) { Name = part1Name, UUID = part1Id }; SceneObjectGroup so = new SceneObjectGroup(part1); SceneObjectPart part2 = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) { Name = part2Name, UUID = part2Id }; so.AddPart(part2); scene.AddNewSceneObject(so, false); SceneObjectGroup dupeSo = scene.SceneGraph.DuplicateObject( part1.LocalId, new Vector3(10, 0, 0), 0, ownerId, UUID.Zero, Quaternion.Identity); Assert.That(dupeSo.Parts.Length, Is.EqualTo(2)); SceneObjectPart dupePart1 = dupeSo.GetLinkNumPart(1); SceneObjectPart dupePart2 = dupeSo.GetLinkNumPart(2); Assert.That(dupePart1.LocalId, Is.Not.EqualTo(part1.LocalId)); Assert.That(dupePart2.LocalId, Is.Not.EqualTo(part2.LocalId)); Assert.That(dupePart1.Flags, Is.EqualTo(part1.Flags)); Assert.That(dupePart2.Flags, Is.EqualTo(part2.Flags)); /* Assert.That(part1.PhysActor, Is.Not.Null); Assert.That(part2.PhysActor, Is.Not.Null); Assert.That(dupePart1.PhysActor, Is.Not.Null); Assert.That(dupePart2.PhysActor, Is.Not.Null); */ // TestHelpers.DisableLogging(); }
public override void SetUp() { base.SetUp(); m_engine = new MockScriptEngine(); m_scene = new SceneHelpers().SetupScene(); SceneHelpers.SetupSceneModules(m_scene, new IniConfigSource(), m_engine); m_so = SceneHelpers.AddSceneObject(m_scene); m_scriptItem = TaskInventoryHelpers.AddScript(m_scene.AssetService, m_so.RootPart); // This is disconnected from the actual script - the mock engine does not set up any LSL_Api atm. // Possibly this could be done and we could obtain it directly from the MockScriptEngine. m_lslApi = new LSL_Api(); m_lslApi.Initialize(m_engine, m_so.RootPart, m_scriptItem); }
public void TestDelinkPersistence() { TestHelpers.InMethod(); //log4net.Config.XmlConfigurator.Configure(); TestScene scene = new SceneHelpers().SetupScene(); string rootPartName = "rootpart"; UUID rootPartUuid = new UUID("00000000-0000-0000-0000-000000000001"); string linkPartName = "linkpart"; UUID linkPartUuid = new UUID("00000000-0000-0000-0001-000000000000"); SceneObjectPart rootPart = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) { Name = rootPartName, UUID = rootPartUuid }; SceneObjectPart linkPart = new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) { Name = linkPartName, UUID = linkPartUuid }; SceneObjectGroup linkGroup = new SceneObjectGroup(linkPart); scene.AddNewSceneObject(linkGroup, true); SceneObjectGroup sog = new SceneObjectGroup(rootPart); scene.AddNewSceneObject(sog, true); Assert.IsFalse(sog.GroupContainsForeignPrims); sog.LinkToGroup(linkGroup); Assert.IsTrue(sog.GroupContainsForeignPrims); scene.Backup(true); Assert.AreEqual(1, scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID).Count); // These changes should occur immediately without waiting for a backup pass SceneObjectGroup groupToDelete = sog.DelinkFromGroup(linkPart, false); Assert.IsFalse(groupToDelete.GroupContainsForeignPrims); scene.DeleteSceneObject(groupToDelete, false); List<SceneObjectGroup> storedObjects = scene.SimulationDataService.LoadObjects(scene.RegionInfo.RegionID); Assert.AreEqual(1, storedObjects.Count); Assert.AreEqual(1, storedObjects[0].Parts.Length); Assert.IsTrue(storedObjects[0].ContainsPart(rootPartUuid)); }
/// <summary> /// Deserialize a scene object from the original xml format /// </summary> /// <param name="xmlData"></param> /// <returns>The scene object deserialized. Null on failure.</returns> public static SceneObjectGroup FromOriginalXmlFormat(XmlReader reader) { //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); //int time = System.Environment.TickCount; SceneObjectGroup sceneObject = null; try { int linkNum; reader.ReadToFollowing("RootPart"); reader.ReadToFollowing("SceneObjectPart"); sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader)); reader.ReadToFollowing("OtherParts"); if (reader.ReadToDescendant("Part")) { do { if (reader.ReadToDescendant("SceneObjectPart")) { SceneObjectPart part = SceneObjectPart.FromXml(reader); linkNum = part.LinkNum; sceneObject.AddPart(part); part.LinkNum = linkNum; part.TrimPermissions(); } } while (reader.ReadToNextSibling("Part")); } // Script state may, or may not, exist. Not having any, is NOT // ever a problem. sceneObject.LoadScriptState(reader); } catch (Exception e) { m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed. Exception {0}", e); return null; } return sceneObject; }
public void TestGroupInventorySerializationDeserialization() { var sop1 = Util.RandomSOP("Root", 1); var sop2 = Util.RandomSOP("Child1", 2); var sop3 = Util.RandomSOP("Child2", 3); SceneObjectGroup group = new SceneObjectGroup(sop1); group.AddPart(sop2); group.AddPart(sop3); var grpBytes = serEngine.InventoryObjectSerializer.SerializeGroupToInventoryBytes(group, SerializationFlags.None); SceneObjectGroup deserGroup = serEngine.InventoryObjectSerializer.DeserializeGroupFromInventoryBytes(grpBytes); CompareObjects comp = new CompareObjects(); comp.CompareStaticFields = false; comp.CompareStaticProperties = false; comp.ElementsToIgnore = PrimCompareIgnoreList; Assert.IsTrue(comp.Compare(group, deserGroup), comp.DifferencesString); }
public SceneObjectGroup CreateEntity( UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) { if (Array.IndexOf(creationCapabilities, (PCode)shape.PCode) < 0) { m_log.DebugFormat("[VEGETATION]: PCode {0} not handled by {1}", shape.PCode, Name); return null; } SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); SceneObjectPart rootPart = sceneObject.GetChildPart(sceneObject.UUID); // if grass or tree, make phantom //rootPart.TrimPermissions(); rootPart.AddFlag(PrimFlags.Phantom); if (rootPart.Shape.PCode != (byte)PCode.Grass) AdaptTree(ref shape); m_scene.AddNewSceneObject(sceneObject, true); sceneObject.SetGroup(groupID, null); return sceneObject; }
private void CreatePointEntity(Scene scene, UUID uuid, Vector3 groupPos) { SceneObjectGroup x = new SceneObjectGroup(); SceneObjectPart y = new SceneObjectPart(); //Initialize part y.Name = "Very Small Point"; y.RegionHandle = scene.RegionInfo.RegionHandle; y.CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; y.OwnerID = UUID.Zero; y.CreatorID = UUID.Zero; y.LastOwnerID = UUID.Zero; y.UUID = uuid; y.Shape = PrimitiveBaseShape.CreateBox(); y.Scale = new Vector3(0.01f,0.01f,0.01f); y.LastOwnerID = UUID.Zero; y.GroupPosition = groupPos; y.OffsetPosition = new Vector3(0, 0, 0); y.RotationOffset = new Quaternion(0,0,0,0); y.Velocity = new Vector3(0, 0, 0); y.RotationalVelocity = new Vector3(0, 0, 0); y.AngularVelocity = new Vector3(0, 0, 0); y.Acceleration = new Vector3(0, 0, 0); y.Flags = 0; y.TrimPermissions(); //Initialize group and add part as root part x.SetScene(scene); x.SetRootPart(y); x.RegionHandle = scene.RegionInfo.RegionHandle; x.SetScene(scene); m_Entity = x; }
/// <summary> /// Move the given scene object into a new region depending on which region its absolute position has moved /// into. /// /// This method locates the new region handle and offsets the prim position for the new region /// </summary> /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> /// <param name="grp">the scene object that we're crossing</param> public void Cross(SceneObjectGroup grp, Vector3 attemptedPosition, bool silent) { if (grp == null) return; if (grp.IsDeleted) return; Scene scene = grp.Scene; if (scene == null) return; if (grp.RootPart.DIE_AT_EDGE) { // We remove the object here try { scene.DeleteSceneObject(grp, false); } catch (Exception) { m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border."); } return; } int thisx = (int)scene.RegionInfo.RegionLocX; int thisy = (int)scene.RegionInfo.RegionLocY; /* Vector3 EastCross = new Vector3(0.1f, 0, 0); Vector3 WestCross = new Vector3(-0.1f, 0, 0); Vector3 NorthCross = new Vector3(0, 0.1f, 0); Vector3 SouthCross = new Vector3(0, -0.1f, 0); // use this if no borders were crossed! ulong newRegionHandle = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize), (uint)((thisy) * Constants.RegionSize)); Vector3 pos = attemptedPosition; int changeX = 1; int changeY = 1; if (scene.TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) { if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) { Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); if (crossedBorderx.BorderLine.Z > 0) { pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); } else pos.X = ((pos.X + Constants.RegionSize)); Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) if (crossedBordery.BorderLine.Z > 0) { pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); } else pos.Y = ((pos.Y + Constants.RegionSize)); newRegionHandle = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize)); // x - 1 // y - 1 } else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) { Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); if (crossedBorderx.BorderLine.Z > 0) { pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); } else pos.X = ((pos.X + Constants.RegionSize)); Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) if (crossedBordery.BorderLine.Z > 0) { pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); } else pos.Y = ((pos.Y + Constants.RegionSize)); newRegionHandle = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize)); // x - 1 // y + 1 } else { Border crossedBorderx = scene.GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); if (crossedBorderx.BorderLine.Z > 0) { pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); } else pos.X = ((pos.X + Constants.RegionSize)); newRegionHandle = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); // x - 1 } } else if (scene.TestBorderCross(attemptedPosition + EastCross, Cardinals.E)) { if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) { pos.X = ((pos.X - Constants.RegionSize)); Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) if (crossedBordery.BorderLine.Z > 0) { pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); } else pos.Y = ((pos.Y + Constants.RegionSize)); newRegionHandle = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize)); // x + 1 // y - 1 } else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) { pos.X = ((pos.X - Constants.RegionSize)); pos.Y = ((pos.Y - Constants.RegionSize)); newRegionHandle = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize)); // x + 1 // y + 1 } else { pos.X = ((pos.X - Constants.RegionSize)); newRegionHandle = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); // x + 1 } } else if (scene.TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) { Border crossedBordery = scene.GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) if (crossedBordery.BorderLine.Z > 0) { pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); } else pos.Y = ((pos.Y + Constants.RegionSize)); newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize)); // y - 1 } else if (scene.TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) { pos.Y = ((pos.Y - Constants.RegionSize)); newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize)); // y + 1 } */ // If we fail to cross the border, then reset the position of the scene object on that border. // Utils.LongToUInts(newRegionHandle, out x, out y); int x, y; Vector3 pos = attemptedPosition; Vector3 newpos = pos; float boundaryDistance = 1.0f; if (scene.RegionInfo.CombinedRegionHandle != 0) // we are a slave region send to main region { uint tmp1; uint tmp2; Utils.LongToUInts(scene.RegionInfo.CombinedRegionHandle, out tmp1, out tmp2); x = (int)tmp1; y = (int)tmp2; newpos.X += ((int)scene.RegionInfo.RegionLocX * Constants.RegionSize - x); newpos.Y += ((int)scene.RegionInfo.RegionLocY * Constants.RegionSize - y); } else { if (pos.X - boundaryDistance < 0) // going W { x = -1; newpos.X = Constants.RegionSize + pos.X - boundaryDistance; } else // assume we are going E { x = ((int)(pos.X + boundaryDistance) / (int)Constants.RegionSize); newpos.X = pos.X - x * (int)Constants.RegionSize; } x += (int)scene.RegionInfo.RegionLocX; x *= (int)Constants.RegionSize; if (pos.Y - boundaryDistance < 0) // going S SW or SE { y = -1; newpos.Y = Constants.RegionSize + pos.Y - boundaryDistance; } else // assume we are going N NW or NE { y = ((int)(pos.Y + boundaryDistance) / (int)Constants.RegionSize); newpos.Y = pos.Y - y * (int)Constants.RegionSize; } y += (int)scene.RegionInfo.RegionLocY; y *= (int)Constants.RegionSize; } // int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); ulong neighbourHandle = Utils.UIntsToLong((uint)x, (uint)y); GridRegion destination = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); if (destination == null) { // let physics know (for now ode needs this) if (!grp.IsDeleted) { if (grp.RootPart.PhysActor != null) { grp.RootPart.PhysActor.CrossingFailure(); } } } else { // Offset the positions for the new region across the border Vector3 oldGroupPosition = grp.RootPart.GroupPosition; grp.RootPart.GroupPosition = newpos; if (!CrossPrimGroupIntoNewRegion(destination, grp, silent)) { if (!grp.IsDeleted) { grp.RootPart.GroupPosition = oldGroupPosition; if (grp.RootPart.PhysActor != null) { grp.RootPart.PhysActor.CrossingFailure(); } grp.ScheduleGroupForFullUpdate(); } } } }
/// <summary> /// Append a scene object report to an input StringBuilder /// </summary> /// <returns></returns> /// <param name='sb'></param> /// <param name='so'</param> /// <param name='showFull'> /// If true then information on all parts of an object is appended. /// If false then only summary information about an object is appended. /// </param> private StringBuilder AddSceneObjectReport(StringBuilder sb, SceneObjectGroup so, bool showFull) { if (showFull) { foreach (SceneObjectPart sop in so.Parts) { AddScenePartReport(sb, sop, false); sb.Append("\n"); } } else { AddSummarySceneObjectReport(sb, so); } return sb; }
private StringBuilder AddSummarySceneObjectReport(StringBuilder sb, SceneObjectGroup so) { ConsoleDisplayList cdl = new ConsoleDisplayList(); cdl.AddRow("Name", so.Name); cdl.AddRow("Descrition", so.Description); cdl.AddRow("Local ID", so.LocalId); cdl.AddRow("UUID", so.UUID); cdl.AddRow("Location", string.Format("{0} @ {1}", so.AbsolutePosition, so.Scene.Name)); cdl.AddRow("Parts", so.PrimCount); cdl.AddRow("Flags", so.RootPart.Flags); return sb.Append(cdl.ToString()); }
// This builds a minimalistic Prim, 1 SOG with 1 root SOP. A // common failure case is people adding new fields that aren't // initialized, but have non-null db constraints. We should // honestly be passing more and more null things in here. // // Please note that in Sqlite.BuildPrim there is a commented out inline version // of this so you can debug and step through the build process and check the fields // // Real World Value: Tests for situation where extending a SceneObjectGroup/SceneObjectPart // causes the application to crash at the database layer because of null values // in NOT NULL fields // private SceneObjectGroup NewSOG(string name, UUID uuid, UUID regionId) { RegionInfo regionInfo = new RegionInfo(); regionInfo.RegionID = regionId; regionInfo.RegionLocX = 0; regionInfo.RegionLocY = 0; Scene scene = new Scene(regionInfo); SceneObjectPart sop = new SceneObjectPart(); sop.Name = name; sop.Description = name; sop.Text = RandomName(); sop.SitName = RandomName(); sop.TouchName = RandomName(); sop.UUID = uuid; sop.Shape = PrimitiveBaseShape.Default; SceneObjectGroup sog = new SceneObjectGroup(sop); sog.SetScene(scene); return sog; }
void OnIncomingSceneObject(SceneObjectGroup so) { if (!so.IsAttachment) return; if (so.AttachedAvatar == UUID.Zero || Scene.UserManagementModule.IsLocalGridUser(so.AttachedAvatar)) return; // foreign user AgentCircuitData aCircuit = Scene.AuthenticateHandler.GetAgentCircuitData(so.AttachedAvatar); if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) { if (aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) { string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachment {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); Dictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url); uuidGatherer.GatherAssetUuids(so, ids); foreach (KeyValuePair<UUID, sbyte> kvp in ids) uuidGatherer.FetchAsset(kvp.Key); } } }
public void T013_DatabasePersistency() { // Sets all ScenePart parameters, stores and retrieves them, then check for consistency with initial data // The commented Asserts are the ones that are unchangeable (when storing on the database, their "Set" values are ignored // The ObjectFlags is an exception, if it is entered incorrectly, the object IS REJECTED on the database silently. UUID creator,uuid = new UUID(); creator = UUID.Random(); uint iserial = (uint)random.Next(); TaskInventoryDictionary dic = new TaskInventoryDictionary(); uint objf = (uint) random.Next(); uuid = prim4; uint localid = localID+1; localID = localID + 1; string name = "Adam West"; byte material = (byte) random.Next(127); ulong regionh = (ulong)random.NextDouble() * (ulong)random.Next(); int pin = random.Next(); Byte[] partsys = new byte[8]; Byte[] textani = new byte[8]; random.NextBytes(textani); random.NextBytes(partsys); DateTime expires = new DateTime(2008, 12, 20); DateTime rezzed = new DateTime(2009, 07, 15); Vector3 groupos = new Vector3(random.Next(),random.Next(),random.Next()); Vector3 offset = new Vector3(random.Next(),random.Next(),random.Next()); Quaternion rotoff = new Quaternion(random.Next(),random.Next(),random.Next(),random.Next()); Vector3 velocity = new Vector3(random.Next(),random.Next(),random.Next()); Vector3 angvelo = new Vector3(random.Next(),random.Next(),random.Next()); Vector3 accel = new Vector3(random.Next(),random.Next(),random.Next()); string description = name; Color color = Color.FromArgb(255, 165, 50, 100); string text = "All Your Base Are Belong to Us"; string sitname = "SitName"; string touchname = "TouchName"; int linknum = random.Next(); byte clickaction = (byte) random.Next(127); PrimitiveBaseShape pbshap = new PrimitiveBaseShape(); pbshap = PrimitiveBaseShape.Default; pbshap.PathBegin = ushort.MaxValue; pbshap.PathEnd = ushort.MaxValue; pbshap.ProfileBegin = ushort.MaxValue; pbshap.ProfileEnd = ushort.MaxValue; pbshap.ProfileHollow = ushort.MaxValue; Vector3 scale = new Vector3(random.Next(),random.Next(),random.Next()); byte updatef = (byte) random.Next(127); RegionInfo regionInfo = new RegionInfo(); regionInfo.RegionID = region3; regionInfo.RegionLocX = 0; regionInfo.RegionLocY = 0; Scene scene = new Scene(regionInfo); SceneObjectPart sop = new SceneObjectPart(); sop.RegionHandle = regionh; sop.UUID = uuid; sop.LocalId = localid; sop.Shape = pbshap; sop.GroupPosition = groupos; sop.RotationOffset = rotoff; sop.CreatorID = creator; sop.InventorySerial = iserial; sop.TaskInventory = dic; sop.ObjectFlags = objf; sop.Name = name; sop.Material = material; sop.ScriptAccessPin = pin; sop.TextureAnimation = textani; sop.ParticleSystem = partsys; sop.Expires = expires; sop.Rezzed = rezzed; sop.OffsetPosition = offset; sop.Velocity = velocity; sop.AngularVelocity = angvelo; sop.Acceleration = accel; sop.Description = description; sop.Color = color; sop.Text = text; sop.SitName = sitname; sop.TouchName = touchname; sop.LinkNum = linknum; sop.ClickAction = clickaction; sop.Scale = scale; sop.UpdateFlag = updatef; //Tests if local part accepted the parameters: Assert.That(regionh,Is.EqualTo(sop.RegionHandle), "Assert.That(regionh,Is.EqualTo(sop.RegionHandle))"); Assert.That(localid,Is.EqualTo(sop.LocalId), "Assert.That(localid,Is.EqualTo(sop.LocalId))"); Assert.That(groupos,Is.EqualTo(sop.GroupPosition), "Assert.That(groupos,Is.EqualTo(sop.GroupPosition))"); Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))"); Assert.That(rotoff,Is.EqualTo(sop.RotationOffset), "Assert.That(rotoff,Is.EqualTo(sop.RotationOffset))"); Assert.That(uuid,Is.EqualTo(sop.UUID), "Assert.That(uuid,Is.EqualTo(sop.UUID))"); Assert.That(creator,Is.EqualTo(sop.CreatorID), "Assert.That(creator,Is.EqualTo(sop.CreatorID))"); // Modified in-class // Assert.That(iserial,Is.EqualTo(sop.InventorySerial), "Assert.That(iserial,Is.EqualTo(sop.InventorySerial))"); Assert.That(dic,Is.EqualTo(sop.TaskInventory), "Assert.That(dic,Is.EqualTo(sop.TaskInventory))"); Assert.That(objf,Is.EqualTo(sop.ObjectFlags), "Assert.That(objf,Is.EqualTo(sop.ObjectFlags))"); Assert.That(name,Is.EqualTo(sop.Name), "Assert.That(name,Is.EqualTo(sop.Name))"); Assert.That(material,Is.EqualTo(sop.Material), "Assert.That(material,Is.EqualTo(sop.Material))"); Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(sop.ScriptAccessPin))"); Assert.That(textani,Is.EqualTo(sop.TextureAnimation), "Assert.That(textani,Is.EqualTo(sop.TextureAnimation))"); Assert.That(partsys,Is.EqualTo(sop.ParticleSystem), "Assert.That(partsys,Is.EqualTo(sop.ParticleSystem))"); Assert.That(expires,Is.EqualTo(sop.Expires), "Assert.That(expires,Is.EqualTo(sop.Expires))"); Assert.That(rezzed,Is.EqualTo(sop.Rezzed), "Assert.That(rezzed,Is.EqualTo(sop.Rezzed))"); Assert.That(offset,Is.EqualTo(sop.OffsetPosition), "Assert.That(offset,Is.EqualTo(sop.OffsetPosition))"); Assert.That(velocity,Is.EqualTo(sop.Velocity), "Assert.That(velocity,Is.EqualTo(sop.Velocity))"); Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(sop.AngularVelocity))"); Assert.That(accel,Is.EqualTo(sop.Acceleration), "Assert.That(accel,Is.EqualTo(sop.Acceleration))"); Assert.That(description,Is.EqualTo(sop.Description), "Assert.That(description,Is.EqualTo(sop.Description))"); Assert.That(color,Is.EqualTo(sop.Color), "Assert.That(color,Is.EqualTo(sop.Color))"); Assert.That(text,Is.EqualTo(sop.Text), "Assert.That(text,Is.EqualTo(sop.Text))"); Assert.That(sitname,Is.EqualTo(sop.SitName), "Assert.That(sitname,Is.EqualTo(sop.SitName))"); Assert.That(touchname,Is.EqualTo(sop.TouchName), "Assert.That(touchname,Is.EqualTo(sop.TouchName))"); Assert.That(linknum,Is.EqualTo(sop.LinkNum), "Assert.That(linknum,Is.EqualTo(sop.LinkNum))"); Assert.That(clickaction,Is.EqualTo(sop.ClickAction), "Assert.That(clickaction,Is.EqualTo(sop.ClickAction))"); Assert.That(scale,Is.EqualTo(sop.Scale), "Assert.That(scale,Is.EqualTo(sop.Scale))"); Assert.That(updatef,Is.EqualTo(sop.UpdateFlag), "Assert.That(updatef,Is.EqualTo(sop.UpdateFlag))"); // This is necessary or object will not be inserted in DB sop.ObjectFlags = 0; SceneObjectGroup sog = new SceneObjectGroup(sop); // Inserts group in DB db.StoreObject(sog,region3); List<SceneObjectGroup> sogs = db.LoadObjects(region3); Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); // Makes sure there are no double insertions: db.StoreObject(sog,region3); sogs = db.LoadObjects(region3); Assert.That(sogs.Count, Is.EqualTo(1), "Assert.That(sogs.Count, Is.EqualTo(1))"); // Tests if the parameters were inserted correctly SceneObjectPart p = sogs[0].RootPart; Assert.That(regionh,Is.EqualTo(p.RegionHandle), "Assert.That(regionh,Is.EqualTo(p.RegionHandle))"); //Assert.That(localid,Is.EqualTo(p.LocalId), "Assert.That(localid,Is.EqualTo(p.LocalId))"); Assert.That(groupos,Is.EqualTo(p.GroupPosition), "Assert.That(groupos,Is.EqualTo(p.GroupPosition))"); Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); Assert.That(rotoff,Is.EqualTo(p.RotationOffset), "Assert.That(rotoff,Is.EqualTo(p.RotationOffset))"); Assert.That(uuid,Is.EqualTo(p.UUID), "Assert.That(uuid,Is.EqualTo(p.UUID))"); Assert.That(creator,Is.EqualTo(p.CreatorID), "Assert.That(creator,Is.EqualTo(p.CreatorID))"); //Assert.That(iserial,Is.EqualTo(p.InventorySerial), "Assert.That(iserial,Is.EqualTo(p.InventorySerial))"); Assert.That(dic,Is.EqualTo(p.TaskInventory), "Assert.That(dic,Is.EqualTo(p.TaskInventory))"); //Assert.That(objf,Is.EqualTo(p.ObjectFlags), "Assert.That(objf,Is.EqualTo(p.ObjectFlags))"); Assert.That(name,Is.EqualTo(p.Name), "Assert.That(name,Is.EqualTo(p.Name))"); Assert.That(material,Is.EqualTo(p.Material), "Assert.That(material,Is.EqualTo(p.Material))"); Assert.That(pin,Is.EqualTo(p.ScriptAccessPin), "Assert.That(pin,Is.EqualTo(p.ScriptAccessPin))"); Assert.That(textani,Is.EqualTo(p.TextureAnimation), "Assert.That(textani,Is.EqualTo(p.TextureAnimation))"); Assert.That(partsys,Is.EqualTo(p.ParticleSystem), "Assert.That(partsys,Is.EqualTo(p.ParticleSystem))"); //Assert.That(expires,Is.EqualTo(p.Expires), "Assert.That(expires,Is.EqualTo(p.Expires))"); //Assert.That(rezzed,Is.EqualTo(p.Rezzed), "Assert.That(rezzed,Is.EqualTo(p.Rezzed))"); Assert.That(offset,Is.EqualTo(p.OffsetPosition), "Assert.That(offset,Is.EqualTo(p.OffsetPosition))"); Assert.That(velocity,Is.EqualTo(p.Velocity), "Assert.That(velocity,Is.EqualTo(p.Velocity))"); Assert.That(angvelo,Is.EqualTo(p.AngularVelocity), "Assert.That(angvelo,Is.EqualTo(p.AngularVelocity))"); Assert.That(accel,Is.EqualTo(p.Acceleration), "Assert.That(accel,Is.EqualTo(p.Acceleration))"); Assert.That(description,Is.EqualTo(p.Description), "Assert.That(description,Is.EqualTo(p.Description))"); Assert.That(color,Is.EqualTo(p.Color), "Assert.That(color,Is.EqualTo(p.Color))"); Assert.That(text,Is.EqualTo(p.Text), "Assert.That(text,Is.EqualTo(p.Text))"); Assert.That(sitname,Is.EqualTo(p.SitName), "Assert.That(sitname,Is.EqualTo(p.SitName))"); Assert.That(touchname,Is.EqualTo(p.TouchName), "Assert.That(touchname,Is.EqualTo(p.TouchName))"); //Assert.That(linknum,Is.EqualTo(p.LinkNum), "Assert.That(linknum,Is.EqualTo(p.LinkNum))"); Assert.That(clickaction,Is.EqualTo(p.ClickAction), "Assert.That(clickaction,Is.EqualTo(p.ClickAction))"); Assert.That(scale,Is.EqualTo(p.Scale), "Assert.That(scale,Is.EqualTo(p.Scale))"); //Assert.That(updatef,Is.EqualTo(p.UpdateFlag), "Assert.That(updatef,Is.EqualTo(p.UpdateFlag))"); Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin), "Assert.That(pbshap.PathBegin, Is.EqualTo(p.Shape.PathBegin))"); Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd), "Assert.That(pbshap.PathEnd, Is.EqualTo(p.Shape.PathEnd))"); Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin), "Assert.That(pbshap.ProfileBegin, Is.EqualTo(p.Shape.ProfileBegin))"); Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd), "Assert.That(pbshap.ProfileEnd, Is.EqualTo(p.Shape.ProfileEnd))"); Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow), "Assert.That(pbshap.ProfileHollow, Is.EqualTo(p.Shape.ProfileHollow))"); }
public void RemoveGroupTarget(SceneObjectGroup grp) { m_scene.EventManager.OnFrame -= checkAtTargets; }
public void AddGroupTarget(SceneObjectGroup grp) { m_scene.EventManager.OnFrame += checkAtTargets; }
/// <summary> /// Delink the given prim from this group. The delinked prim is established as /// an independent SceneObjectGroup. /// </summary> /// <param name="partID"></param> /// <param name="sendEvents"></param> /// <returns>The object group of the newly delinked prim.</returns> public SceneObjectGroup DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents) { // m_log.DebugFormat( // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); Quaternion worldRot = linkPart.GetWorldRotation(); // Remove the part from this object m_scene.SceneGraph.DeLinkPartFromEntity(this, linkPart); /* this is already done in DeLinkPartFromEntity if (m_partsList.Count == 1 && RootPart != null) //Single prim is left RootPart.LinkNum = 0; else { lock (m_partsLock) { foreach (SceneObjectPart p in m_partsList) { if (p.LinkNum > linkPart.LinkNum) p.LinkNum--; } } } */ linkPart.SetParentLocalId(0); linkPart.LinkNum = 0; if (linkPart.PhysActor != null) { m_scene.SceneGraph.PhysicsScene.RemovePrim(linkPart.PhysActor); // linkPart.PhysActor.delink(); } // We need to reset the child part's position // ready for life as a separate object after being a part of another object Quaternion parentRot = m_rootPart.RotationOffset; Vector3 axPos = linkPart.OffsetPosition; axPos *= parentRot; linkPart.SetOffsetPosition(axPos); linkPart.FixGroupPosition(AbsolutePosition + linkPart.OffsetPosition,false); linkPart.FixOffsetPosition(Vector3.Zero, false); linkPart.RotationOffset = worldRot; SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart, Scene); m_scene.SceneGraph.DelinkPartToScene(objectGroup); if (sendEvents) linkPart.TriggerScriptChangedEvent(Changed.LINK); linkPart.Rezzed = RootPart.Rezzed; //This is already set multiple places, no need to do it again //HasGroupChanged = true; //We need to send this so that we don't have issues with the client not realizing that the prims were unlinked ScheduleGroupUpdate(PrimUpdateFlags.FullUpdate); return objectGroup; }
/// <summary> /// Move the given scene object into a new region /// </summary> /// <param name="newRegionHandle"></param> /// <param name="grp">Scene Object Group that we're crossing</param> /// <returns> /// true if the crossing itself was successful, false on failure /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region /// </returns> protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, SceneObjectGroup grp, bool silent) { //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); bool successYN = false; grp.RootPart.ClearUpdateSchedule(); //int primcrossingXMLmethod = 0; if (destination != null) { //string objectState = grp.GetStateSnapshot(); //successYN // = m_sceneGridService.PrimCrossToNeighboringRegion( // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod); //if (successYN && (objectState != "") && m_allowScriptCrossings) //{ // successYN = m_sceneGridService.PrimCrossToNeighboringRegion( // newRegionHandle, grp.UUID, objectState, 100); //} //// And the new channel... //if (m_interregionCommsOut != null) // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); if (m_aScene.SimulationService != null) try { successYN = m_aScene.SimulationService.CreateObject(destination, grp, true); } catch { successYN = false; } if (successYN) { // We remove the object here try { grp.Scene.DeleteSceneObject(grp, silent); } catch (Exception e) { m_log.ErrorFormat( "[ENTITY TRANSFER MODULE]: Exception deleting the old object left behind on a border crossing for {0}, {1}", grp, e); } } else { if (!grp.IsDeleted) { if (grp.RootPart.PhysActor != null) { grp.RootPart.PhysActor.CrossingFailure(); } } m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp); } } else { m_log.Error("[ENTITY TRANSFER MODULE]: destination was unexpectedly null in Scene.CrossPrimGroupIntoNewRegion()"); } return successYN; }
public bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, List<UUID> avatars, bool isLocalCall, Vector3 posInOtherRegion, bool isAttachment) { int createObjectStart = Environment.TickCount; try { // Try local first if (m_localBackend.SendCreateObject(regionHandle, sog, avatars, true, posInOtherRegion, isAttachment)) { //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); return true; } // else do the remote thing if (!m_localBackend.IsLocalRegion(regionHandle)) { RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle); if (regInfo != null) { var engine = ProviderRegistry.Instance.Get<ISerializationEngine>(); byte[] sogBytes = engine.SceneObjectSerializer.SerializeGroupToBytes(sog, SerializationFlags.SerializePhysicsShapes | SerializationFlags.SerializeScriptBytecode); long nonceID = NextNonceID(); RegionClient.CreateObject2Ret ret = m_regionClient.DoCreateObject2Call(regInfo, sog.UUID, sogBytes, true, posInOtherRegion, isAttachment, nonceID, avatars); if (ret == RegionClient.CreateObject2Ret.Ok) return true; // create failed, make sure the other side didn't get it late and create one // we could check for a soecific range of "ret" here, representing the timeout if (ret != RegionClient.CreateObject2Ret.AccessDenied) m_regionClient.DoDeleteObject2Call(regInfo, sog.UUID, nonceID); } } return false; } finally { m_log.DebugFormat("[REST COMM] SendCreateObject: {0} ms", Environment.TickCount - createObjectStart); } }
public ISceneEntity GetRezReadySceneObject(TaskInventoryItem item) { AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); if (null == rezAsset) { MainConsole.Instance.WarnFormat( "[PRIM INVENTORY]: Could not find asset {0} for inventory item {1} in {2}", item.AssetID, item.Name, m_part.Name); return(null); } string xmlData = Utils.BytesToString(rezAsset.Data); SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData, m_part.ParentGroup.Scene); if (group == null) { return(null); } group.IsDeleted = false; group.m_isLoaded = true; foreach (SceneObjectPart part in group.ChildrenList) { part.IsLoading = false; } //Reset IDs, etc m_part.ParentGroup.Scene.SceneGraph.PrepPrimForAdditionToScene(group); SceneObjectPart rootPart = (SceneObjectPart)group.GetChildPart(group.UUID); // Since renaming the item in the inventory does not affect the name stored // in the serialization, transfer the correct name from the inventory to the // object itself before we rez. rootPart.Name = item.Name; rootPart.Description = item.Description; SceneObjectPart[] partList = group.Parts; group.SetGroup(m_part.GroupID, group.OwnerID, false); if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) { if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) { foreach (SceneObjectPart part in partList) { part.EveryoneMask = item.EveryonePermissions; part.NextOwnerMask = item.NextPermissions; } group.ApplyNextOwnerPermissions(); } } foreach (SceneObjectPart part in partList) { if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0) { part.LastOwnerID = part.OwnerID; part.OwnerID = item.OwnerID; part.Inventory.ChangeInventoryOwner(item.OwnerID); } part.EveryoneMask = item.EveryonePermissions; part.NextOwnerMask = item.NextPermissions; } rootPart.TrimPermissions(); return(group); }