From 1dfc9902649bfb4f02340644a0589fe139a3322a Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 23 Feb 2012 01:40:30 +0000 Subject: Add a position parameter to region crossing of objects. This avoids the potential bad update that places an object at the opposite side of the origin sim for a moment before actually crossing it. Especially important in grids like OSG where lag between sims is high. --- .../CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 9 ++++----- .../ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | 6 +++--- .../ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | 6 +++--- OpenSim/Region/Framework/Scenes/Scene.cs | 5 ++++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 8f047ea..f6e4dbf 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1704,14 +1704,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // Offset the positions for the new region across the border Vector3 oldGroupPosition = grp.RootPart.GroupPosition; - grp.RootPart.GroupPosition = pos; // If we fail to cross the border, then reset the position of the scene object on that border. uint x = 0, y = 0; Utils.LongToUInts(newRegionHandle, out x, out y); GridRegion destination = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y); - if (destination == null || !CrossPrimGroupIntoNewRegion(destination, grp, silent)) + if (destination == null || !CrossPrimGroupIntoNewRegion(destination, pos, grp, silent)) { m_log.InfoFormat("[ENTITY TRANSFER MODULE] cross region transfer failed for object {0}",grp.UUID); @@ -1741,7 +1740,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer /// 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 /// - protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, SceneObjectGroup grp, bool silent) + protected bool CrossPrimGroupIntoNewRegion(GridRegion destination, Vector3 newPosition, SceneObjectGroup grp, bool silent) { //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); @@ -1766,7 +1765,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer //if (m_interregionCommsOut != null) // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); if (m_aScene.SimulationService != null) - successYN = m_aScene.SimulationService.CreateObject(destination, grp, true); + successYN = m_aScene.SimulationService.CreateObject(destination, newPosition, grp, true); if (successYN) { @@ -1825,7 +1824,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer gobj.IsAttachment = false; //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); - CrossPrimGroupIntoNewRegion(destination, gobj, silent); + CrossPrimGroupIntoNewRegion(destination, Vector3.Zero, gobj, silent); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index a17c6ae..85e7e94 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -315,7 +315,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation * Object-related communications */ - public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) + public bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog, bool isLocalCall) { if (destination == null) return false; @@ -330,12 +330,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation // We need to make a local copy of the object ISceneObject sogClone = sog.CloneForNewScene(); sogClone.SetState(sog.GetStateSnapshot(), s); - return s.IncomingCreateObject(sogClone); + return s.IncomingCreateObject(newPosition, sogClone); } else { // Use the object as it came through the wire - return s.IncomingCreateObject(sog); + return s.IncomingCreateObject(newPosition, sog); } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index f8cea71..eaf9506 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -282,13 +282,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation * Object-related communications */ - public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) + public bool CreateObject(GridRegion destination, Vector3 newPosition, ISceneObject sog, bool isLocalCall) { if (destination == null) return false; // Try local first - if (m_localBackend.CreateObject(destination, sog, isLocalCall)) + if (m_localBackend.CreateObject(destination, newPosition, sog, isLocalCall)) { //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded"); return true; @@ -296,7 +296,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation // else do the remote thing if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) - return m_remoteConnector.CreateObject(destination, sog, isLocalCall); + return m_remoteConnector.CreateObject(destination, newPosition, sog, isLocalCall); return false; } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e7f835c..7b79732 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2317,7 +2317,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - public bool IncomingCreateObject(ISceneObject sog) + public bool IncomingCreateObject(Vector3 newPosition, ISceneObject sog) { //m_log.DebugFormat(" >>> IncomingCreateObject(sog) <<< {0} deleted? {1} isAttach? {2}", ((SceneObjectGroup)sog).AbsolutePosition, // ((SceneObjectGroup)sog).IsDeleted, ((SceneObjectGroup)sog).RootPart.IsAttachment); @@ -2333,6 +2333,9 @@ namespace OpenSim.Region.Framework.Scenes return false; } + if (newPosition != Vector3.Zero) + newObject.RootPart.GroupPosition = newPosition; + if (!AddSceneObject(newObject)) { m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index daf711c..9cfdf9f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3223,7 +3223,7 @@ namespace OpenSim.Region.Framework.Scenes ((SceneObjectGroup)so).LocalId = 0; ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule(); so.SetState(cAgent.AttachmentObjectStates[i++], m_scene); - m_scene.IncomingCreateObject(so); + m_scene.IncomingCreateObject(Vector3.Zero, so); } } } -- cgit v1.1