* Deal with teleports to other virtual regions in the same scene.
parent
ac718843d9
commit
9eb8c14e87
|
@ -3267,16 +3267,47 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
if (sp != null)
|
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)
|
if (m_teleportModule != null)
|
||||||
{
|
{
|
||||||
m_teleportModule.RequestTeleportToLocation(sp, regionHandle,
|
m_teleportModule.RequestTeleportToLocation(sp, regionHandle,
|
||||||
position, lookAt, teleportFlags);
|
position, lookAt, teleportFlags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_sceneGridService.RequestTeleportToLocation(sp, regionHandle,
|
m_sceneGridService.RequestTeleportToLocation(sp, regionHandle,
|
||||||
position, lookAt, teleportFlags);
|
position, lookAt, teleportFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -803,11 +803,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (regionHandle == m_regionInfo.RegionHandle)
|
if (regionHandle == m_regionInfo.RegionHandle)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
|
"[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
|
||||||
position, m_regionInfo.RegionName);
|
position, m_regionInfo.RegionName);
|
||||||
|
|
||||||
// Teleport within the same region
|
// 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);
|
Vector3 emergencyPos = new Vector3(128, 128, 128);
|
||||||
|
|
||||||
|
@ -816,10 +816,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
position, avatar.Name, avatar.UUID, emergencyPos);
|
position, avatar.Name, avatar.UUID, emergencyPos);
|
||||||
position = emergencyPos;
|
position = emergencyPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Get proper AVG Height
|
// TODO: Get proper AVG Height
|
||||||
float localAVHeight = 1.56f;
|
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;
|
float newPosZ = posZLimit + localAVHeight;
|
||||||
if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
|
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)
|
public bool WaitForCallback(UUID id)
|
||||||
{
|
{
|
||||||
int count = 200;
|
int count = 200;
|
||||||
|
@ -1165,27 +1187,76 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// distance into new region to place avatar
|
// distance into new region to place avatar
|
||||||
const float enterDistance = 0.1f;
|
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--;
|
neighbourx--;
|
||||||
newpos.X = Constants.RegionSize - enterDistance;
|
newpos.X = Constants.RegionSize - enterDistance;
|
||||||
}
|
}
|
||||||
else if (pos.X > Constants.RegionSize - boundaryDistance)
|
else if (pos.X > Constants.RegionSize - boundaryDistance) // East
|
||||||
{
|
{
|
||||||
neighbourx++;
|
neighbourx++;
|
||||||
newpos.X = enterDistance;
|
newpos.X = enterDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos.Y < boundaryDistance)
|
if (pos.Y < boundaryDistance) // South
|
||||||
{
|
{
|
||||||
neighboury--;
|
neighboury--;
|
||||||
newpos.Y = Constants.RegionSize - enterDistance;
|
newpos.Y = Constants.RegionSize - enterDistance;
|
||||||
}
|
}
|
||||||
else if (pos.Y > Constants.RegionSize - boundaryDistance)
|
else if (pos.Y > Constants.RegionSize - boundaryDistance) // North
|
||||||
{
|
{
|
||||||
neighboury++;
|
neighboury++;
|
||||||
newpos.Y = enterDistance;
|
newpos.Y = enterDistance;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
|
CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
|
||||||
d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
|
d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
|
||||||
|
|
|
@ -2854,6 +2854,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
else if (m_scene.TestBorderCross(pos2, Cardinals.N))
|
else if (m_scene.TestBorderCross(pos2, Cardinals.N))
|
||||||
neighbor = HaveNeighbor(Cardinals.N, ref fix);
|
neighbor = HaveNeighbor(Cardinals.N, ref fix);
|
||||||
|
|
||||||
|
|
||||||
// Makes sure avatar does not end up outside region
|
// Makes sure avatar does not end up outside region
|
||||||
if (neighbor < 0)
|
if (neighbor < 0)
|
||||||
AbsolutePosition = new Vector3(
|
AbsolutePosition = new Vector3(
|
||||||
|
|
Loading…
Reference in New Issue