* Deal with teleports to other virtual regions in the same scene.

remotes/origin/0.6.7-post-fixes
Teravus Ovares (Dan Olivares) 2009-08-28 19:42:28 -04:00
parent ac718843d9
commit 9eb8c14e87
3 changed files with 113 additions and 10 deletions

View File

@ -3267,6 +3267,36 @@ namespace OpenSim.Region.Framework.Scenes
if (sp != null)
{
uint regionX = m_regInfo.RegionLocX;
uint regionY = m_regInfo.RegionLocY;
Utils.LongToUInts(regionHandle, out regionX, out regionY);
int shiftx = (int) regionX - (int) m_regInfo.RegionLocX * (int)Constants.RegionSize;
int shifty = (int)regionY - (int)m_regInfo.RegionLocY * (int)Constants.RegionSize;
position.X += shiftx;
position.Y += shifty;
bool result = false;
if (TestBorderCross(position,Cardinals.N))
result = true;
if (TestBorderCross(position, Cardinals.S))
result = true;
if (TestBorderCross(position, Cardinals.E))
result = true;
if (TestBorderCross(position, Cardinals.W))
result = true;
// bordercross if position is outside of region
if (!result)
regionHandle = m_regInfo.RegionHandle;
if (m_teleportModule != null)
{
m_teleportModule.RequestTeleportToLocation(sp, regionHandle,
@ -3277,6 +3307,7 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.RequestTeleportToLocation(sp, regionHandle,
position, lookAt, teleportFlags);
}
}
}

View File

@ -807,7 +807,7 @@ namespace OpenSim.Region.Framework.Scenes
position, m_regionInfo.RegionName);
// Teleport within the same region
if (position.X < 0 || position.X > Constants.RegionSize || position.Y < 0 || position.Y > Constants.RegionSize || position.Z < 0)
if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
{
Vector3 emergencyPos = new Vector3(128, 128, 128);
@ -819,7 +819,14 @@ namespace OpenSim.Region.Framework.Scenes
// TODO: Get proper AVG Height
float localAVHeight = 1.56f;
float posZLimit = (float)avatar.Scene.Heightmap[(int)position.X, (int)position.Y];
float posZLimit = 22;
// TODO: Check other Scene HeightField
if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <=(int)Constants.RegionSize)
{
posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
}
float newPosZ = posZLimit + localAVHeight;
if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
{
@ -1084,6 +1091,21 @@ namespace OpenSim.Region.Framework.Scenes
}
}
private bool IsOutsideRegion(Scene s, Vector3 pos)
{
if (s.TestBorderCross(pos,Cardinals.N))
return true;
if (s.TestBorderCross(pos, Cardinals.S))
return true;
if (s.TestBorderCross(pos, Cardinals.E))
return true;
if (s.TestBorderCross(pos, Cardinals.W))
return true;
return false;
}
public bool WaitForCallback(UUID id)
{
int count = 200;
@ -1165,27 +1187,76 @@ namespace OpenSim.Region.Framework.Scenes
// distance into new region to place avatar
const float enterDistance = 0.1f;
if (pos.X < boundaryDistance)
if (scene.TestBorderCross(pos, Cardinals.W))
{
if (scene.TestBorderCross(pos, Cardinals.N))
{
Border b = scene.GetCrossedBorder(pos, Cardinals.N);
neighboury += (uint)(int)(b.BorderLine.Z/(int)Constants.RegionSize);
}
neighbourx--;
newpos.X = Constants.RegionSize - enterDistance;
}
else if (scene.TestBorderCross(pos, Cardinals.E))
{
if (scene.TestBorderCross(pos, Cardinals.S))
{
neighboury--;
newpos.Y = Constants.RegionSize - enterDistance;
}
else if (scene.TestBorderCross(pos, Cardinals.N))
{
Border b = scene.GetCrossedBorder(pos, Cardinals.N);
neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
newpos.Y = enterDistance;
}
else
{
Border b = scene.GetCrossedBorder(pos, Cardinals.E);
neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
newpos.X = enterDistance;
}
}
else if (scene.TestBorderCross(pos, Cardinals.S))
{
neighboury--;
newpos.Y = Constants.RegionSize - enterDistance;
}
else if (scene.TestBorderCross(pos, Cardinals.N))
{
Border b = scene.GetCrossedBorder(pos, Cardinals.N);
neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
newpos.Y = enterDistance;
}
/*
if (pos.X < boundaryDistance) //West
{
neighbourx--;
newpos.X = Constants.RegionSize - enterDistance;
}
else if (pos.X > Constants.RegionSize - boundaryDistance)
else if (pos.X > Constants.RegionSize - boundaryDistance) // East
{
neighbourx++;
newpos.X = enterDistance;
}
if (pos.Y < boundaryDistance)
if (pos.Y < boundaryDistance) // South
{
neighboury--;
newpos.Y = Constants.RegionSize - enterDistance;
}
else if (pos.Y > Constants.RegionSize - boundaryDistance)
else if (pos.Y > Constants.RegionSize - boundaryDistance) // North
{
neighboury++;
newpos.Y = enterDistance;
}
*/
CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);

View File

@ -2854,6 +2854,7 @@ namespace OpenSim.Region.Framework.Scenes
else if (m_scene.TestBorderCross(pos2, Cardinals.N))
neighbor = HaveNeighbor(Cardinals.N, ref fix);
// Makes sure avatar does not end up outside region
if (neighbor < 0)
AbsolutePosition = new Vector3(