private bool BorderCrossLLAgent(LLAgent agent, SceneInfo neighbor)
{
IPAddress simHost;
int simPort;
Uri seedCapability;
// Send a rez_avatar/request message to create a root agent or upgrade a child agent
if (SendRezAvatarRequest(agent, neighbor, false, out simHost, out simPort, out seedCapability))
{
// Demote this agent to a child agent
agent.IsChildPresence = true;
// Calculate our position relative to the new region
Vector3 relativePosition = agent.ScenePosition - new Vector3(neighbor.MinPosition - m_scene.MinPosition);
// Send the CrossedRegion message over the event queue to the client
CrossedRegionMessage crossed = new CrossedRegionMessage();
crossed.AgentID = agent.ID;
crossed.SessionID = agent.SessionID;
crossed.RegionHandle = Util.PositionToRegionHandle(neighbor.MinPosition);
crossed.IP = simHost;
crossed.Port = simPort;
crossed.Position = relativePosition;
crossed.LookAt = agent.CameraAtAxis; // TODO: Get LookAt from the agent's rotation
crossed.SeedCapability = seedCapability;
m_log.Info("Sending CrossedRegion to " + agent.Name + " from " + m_scene.Name + " to " + neighbor.Name +
", pos=" + relativePosition + ", vel=" + agent.Velocity);
agent.EventQueue.QueueEvent("CrossedRegion", crossed.Serialize());
return true;
}
else
{
m_log.Warn("Border crossing " + agent.Name + " from " + m_scene.Name + " to " + neighbor.Name +
" failed, rez_avatar/request did not succeed");
return false;
}
}