From 469955889ed5499ed1dbb8fcc224d6912c651d06 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 22 Dec 2011 09:30:06 -0800 Subject: [PATCH] Region crossings redone: (1) removed WaitForCallback. Now that we are passing the entire agent with attachs in one big message we don't necessarily need to wait for confirmation. The callback sometimes is problematic and it adds delay to the process. (2) Z velocity sent to the viewer = 0. This is an heuristic; the Z velocity usually is negative, and it makes the viewer move the avie down. This only matters while the agent is in transit and therefore not being physically simulated by neither region. As soon as the receiving region receives CompleteMovement from the viewer, the position and velocity get corrected. --- .../EntityTransfer/EntityTransferModule.cs | 71 +++++++++---------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 87f292c102..b9d5d325ab 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -676,9 +676,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer Vector3 eastCross = new Vector3(boundaryDistance, 0, 0); Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0); - // distance to edge that will trigger crossing - - // distance into new region to place avatar const float enterDistance = 0.5f; @@ -960,29 +957,31 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer m_log.DebugFormat( "[ENTITY TRANSFER MODULE]: Failed validation of all attachments for region crossing of {0} from {1} to {2}. Continuing.", agent.Name, agent.Scene.RegionInfo.RegionName, neighbourRegion.RegionName); - - pos = pos + (agent.Velocity); - + + pos = pos + agent.Velocity; + Vector3 vel2 = new Vector3(agent.Velocity.X, agent.Velocity.Y, 0); + + agent.RemoveFromPhysicalScene(); SetInTransit(agent.UUID); - AgentData cAgent = new AgentData(); + + AgentData cAgent = new AgentData(); agent.CopyTo(cAgent); cAgent.Position = pos; if (isFlying) cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; - cAgent.CallbackURI = m_scene.RegionInfo.ServerURI + - "agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/"; - + + // We don't need the callback anymnore + cAgent.CallbackURI = String.Empty; + if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent)) { // region doesn't take it ReInstantiateScripts(agent); + agent.AddToPhysicalScene(isFlying); ResetFromTransit(agent.UUID); return agent; } - // Next, let's close the child agent connections that are too far away. - agent.CloseChildAgents(neighbourx, neighboury); - //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); agent.ControllingClient.RequestClientInfo(); @@ -999,11 +998,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer string capsPath = neighbourRegion.ServerURI + CapsUtil.GetCapsSeedPath(agentcaps); m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); - + IEventQueue eq = agent.Scene.RequestModuleInterface(); if (eq != null) { - eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, + eq.CrossRegion(neighbourHandle, pos, vel2 /* agent.Velocity */, neighbourRegion.ExternalEndPoint, capsPath, agent.UUID, agent.ControllingClient.SessionId); } else @@ -1011,32 +1010,26 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, capsPath); } - - if (!WaitForCallback(agent.UUID)) - { - m_log.Debug("[ENTITY TRANSFER MODULE]: Callback never came in crossing agent"); - ReInstantiateScripts(agent); - ResetFromTransit(agent.UUID); - - // Yikes! We should just have a ref to scene here. - //agent.Scene.InformClientOfNeighbours(agent); - EnableChildAgents(agent); - - return agent; - } - + + // SUCCESS! agent.MakeChildAgent(); - + ResetFromTransit(agent.UUID); + // now we have a child agent in this region. Request all interesting data about other (root) agents agent.SendOtherAgentsAvatarDataToMe(); agent.SendOtherAgentsAppearanceToMe(); - - // Backwards compatibility + + // Backwards compatibility. Best effort if (version == "Unknown" || version == string.Empty) { - m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Old neighbor, passing attachments one by one..."); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: neighbor with old version, passing attachments one by one..."); + Thread.Sleep(3000); // wait a little now that we're not waiting for the callback CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true); } + + + // Next, let's close the child agent connections that are too far away. + agent.CloseChildAgents(neighbourx, neighboury); AgentHasMovedAway(agent, false); @@ -1069,16 +1062,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; ScenePresence agent = icon.EndInvoke(iar); - // If the cross was successful, this agent is a child agent - if (agent.IsChildAgent) - agent.Reset(); - else // Not successful - agent.RestoreInCurrentScene(); + //// If the cross was successful, this agent is a child agent + //if (agent.IsChildAgent) + // agent.Reset(); + //else // Not successful + // agent.RestoreInCurrentScene(); // In any case agent.IsInTransit = false; - //m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); + m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); } #endregion