aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs88
1 files changed, 62 insertions, 26 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 7ed3a4b..8eb6f7d 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -700,10 +700,9 @@ namespace OpenSim.Region.Framework.Scenes
700 foreach (ulong handle in seeds.Keys) 700 foreach (ulong handle in seeds.Keys)
701 { 701 {
702 uint x, y; 702 uint x, y;
703 Utils.LongToUInts(handle, out x, out y); 703 Util.RegionHandleToRegionLoc(handle, out x, out y);
704 x = x / Constants.RegionSize; 704
705 y = y / Constants.RegionSize; 705 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.LegacyRegionLocX, y, Scene.RegionInfo.LegacyRegionLocY))
706 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY))
707 { 706 {
708 old.Add(handle); 707 old.Add(handle);
709 } 708 }
@@ -724,9 +723,7 @@ namespace OpenSim.Region.Framework.Scenes
724 foreach (KeyValuePair<ulong, string> kvp in KnownRegions) 723 foreach (KeyValuePair<ulong, string> kvp in KnownRegions)
725 { 724 {
726 uint x, y; 725 uint x, y;
727 Utils.LongToUInts(kvp.Key, out x, out y); 726 Util.RegionHandleToRegionLoc(kvp.Key, out x, out y);
728 x = x / Constants.RegionSize;
729 y = y / Constants.RegionSize;
730 m_log.Info(" >> "+x+", "+y+": "+kvp.Value); 727 m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
731 } 728 }
732 } 729 }
@@ -972,7 +969,7 @@ namespace OpenSim.Region.Framework.Scenes
972 969
973 float posZLimit = 0; 970 float posZLimit = 0;
974 971
975 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) 972 if (pos.X < m_scene.RegionInfo.RegionSizeX && pos.Y < m_scene.RegionInfo.RegionSizeY)
976 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 973 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
977 974
978 float newPosZ = posZLimit + localAVHeight / 2; 975 float newPosZ = posZLimit + localAVHeight / 2;
@@ -2100,7 +2097,7 @@ namespace OpenSim.Region.Framework.Scenes
2100 if (regionCombinerModule != null) 2097 if (regionCombinerModule != null)
2101 regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); 2098 regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID);
2102 else 2099 else
2103 regionSize = new Vector2(Constants.RegionSize); 2100 regionSize = new Vector2(m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY);
2104 2101
2105 if (pos.X < 0 || pos.X >= regionSize.X 2102 if (pos.X < 0 || pos.X >= regionSize.X
2106 || pos.Y < 0 || pos.Y >= regionSize.Y 2103 || pos.Y < 0 || pos.Y >= regionSize.Y
@@ -2118,8 +2115,8 @@ namespace OpenSim.Region.Framework.Scenes
2118// } 2115// }
2119 2116
2120 // Get terrain height for sub-region in a megaregion if necessary 2117 // Get terrain height for sub-region in a megaregion if necessary
2121 int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); 2118 int X = (int)((m_scene.RegionInfo.RegionWorldLocX) + pos.X);
2122 int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); 2119 int Y = (int)((m_scene.RegionInfo.RegionWorldLocY) + pos.Y);
2123 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); 2120 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
2124 // If X and Y is NaN, target_region will be null 2121 // If X and Y is NaN, target_region will be null
2125 if (target_region == null) 2122 if (target_region == null)
@@ -2130,7 +2127,7 @@ namespace OpenSim.Region.Framework.Scenes
2130 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) 2127 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
2131 targetScene = m_scene; 2128 targetScene = m_scene;
2132 2129
2133 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % Constants.RegionSize), (int)(pos.Y % Constants.RegionSize)]; 2130 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)];
2134 pos.Z = Math.Max(terrainHeight, pos.Z); 2131 pos.Z = Math.Max(terrainHeight, pos.Z);
2135 2132
2136 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is 2133 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is
@@ -3227,6 +3224,9 @@ namespace OpenSim.Region.Framework.Scenes
3227 int neighbor = 0; 3224 int neighbor = 0;
3228 int[] fix = new int[2]; 3225 int[] fix = new int[2];
3229 3226
3227 // Compute the avatar position in the next physics tick.
3228 // If the avatar will be crossing, we force the crossing to happen now
3229 // in the hope that this will make the avatar movement smoother when crossing.
3230 float timeStep = 0.1f; 3230 float timeStep = 0.1f;
3231 pos2.X = pos2.X + (vel.X * timeStep); 3231 pos2.X = pos2.X + (vel.X * timeStep);
3232 pos2.Y = pos2.Y + (vel.Y * timeStep); 3232 pos2.Y = pos2.Y + (vel.Y * timeStep);
@@ -3234,12 +3234,48 @@ namespace OpenSim.Region.Framework.Scenes
3234 3234
3235 if (!IsInTransit) 3235 if (!IsInTransit)
3236 { 3236 {
3237// m_log.DebugFormat( 3237 m_log.DebugFormat(
3238// "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", 3238 "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}",
3239// pos2, Name, Scene.Name); 3239 pos2, Name, Scene.Name);
3240
3241 if (!m_scene.PositionIsInCurrentRegion(pos2))
3242 {
3243 // Disconnect from the current region
3244 bool isFlying = Flying;
3245 RemoveFromPhysicalScene();
3246 // pos2 is the forcasted position so make that the 'current' position so the crossing
3247 // code will move us into the newly addressed region.
3248 m_pos = pos2;
3249 if (CrossToNewRegion())
3250 {
3251 AddToPhysicalScene(isFlying);
3252 }
3253 else
3254 {
3255 // Tried to make crossing happen but it failed.
3256 if (m_requestedSitTargetUUID == UUID.Zero)
3257 {
3258
3259 Vector3 pos = AbsolutePosition;
3260 if (AbsolutePosition.X < 0)
3261 pos.X += Velocity.X * 2;
3262 else if (AbsolutePosition.X > m_scene.RegionInfo.RegionSizeX)
3263 pos.X -= Velocity.X * 2;
3264 if (AbsolutePosition.Y < 0)
3265 pos.Y += Velocity.Y * 2;
3266 else if (AbsolutePosition.Y > m_scene.RegionInfo.RegionSizeY)
3267 pos.Y -= Velocity.Y * 2;
3268 Velocity = Vector3.Zero;
3269 AbsolutePosition = pos;
3270
3271 AddToPhysicalScene(isFlying);
3272 }
3273 }
3274
3275 }
3240 3276
3277 /*
3241 // Checks if where it's headed exists a region 3278 // Checks if where it's headed exists a region
3242 bool needsTransit = false;
3243 if (m_scene.TestBorderCross(pos2, Cardinals.W)) 3279 if (m_scene.TestBorderCross(pos2, Cardinals.W))
3244 { 3280 {
3245 if (m_scene.TestBorderCross(pos2, Cardinals.S)) 3281 if (m_scene.TestBorderCross(pos2, Cardinals.S))
@@ -3300,11 +3336,11 @@ namespace OpenSim.Region.Framework.Scenes
3300 Vector3 pos = AbsolutePosition; 3336 Vector3 pos = AbsolutePosition;
3301 if (AbsolutePosition.X < 0) 3337 if (AbsolutePosition.X < 0)
3302 pos.X += Velocity.X * 2; 3338 pos.X += Velocity.X * 2;
3303 else if (AbsolutePosition.X > Constants.RegionSize) 3339 else if (AbsolutePosition.X > m_scene.RegionInfo.RegionSizeX)
3304 pos.X -= Velocity.X * 2; 3340 pos.X -= Velocity.X * 2;
3305 if (AbsolutePosition.Y < 0) 3341 if (AbsolutePosition.Y < 0)
3306 pos.Y += Velocity.Y * 2; 3342 pos.Y += Velocity.Y * 2;
3307 else if (AbsolutePosition.Y > Constants.RegionSize) 3343 else if (AbsolutePosition.Y > m_scene.RegionInfo.RegionSizeY)
3308 pos.Y -= Velocity.Y * 2; 3344 pos.Y -= Velocity.Y * 2;
3309 Velocity = Vector3.Zero; 3345 Velocity = Vector3.Zero;
3310 AbsolutePosition = pos; 3346 AbsolutePosition = pos;
@@ -3327,11 +3363,11 @@ namespace OpenSim.Region.Framework.Scenes
3327 Vector3 pos = AbsolutePosition; 3363 Vector3 pos = AbsolutePosition;
3328 if (AbsolutePosition.X < 0) 3364 if (AbsolutePosition.X < 0)
3329 pos.X += Velocity.X * 2; 3365 pos.X += Velocity.X * 2;
3330 else if (AbsolutePosition.X > Constants.RegionSize) 3366 else if (AbsolutePosition.X > m_scene.RegionInfo.RegionSizeX)
3331 pos.X -= Velocity.X * 2; 3367 pos.X -= Velocity.X * 2;
3332 if (AbsolutePosition.Y < 0) 3368 if (AbsolutePosition.Y < 0)
3333 pos.Y += Velocity.Y * 2; 3369 pos.Y += Velocity.Y * 2;
3334 else if (AbsolutePosition.Y > Constants.RegionSize) 3370 else if (AbsolutePosition.Y > m_scene.RegionInfo.RegionSizeY)
3335 pos.Y -= Velocity.Y * 2; 3371 pos.Y -= Velocity.Y * 2;
3336 Velocity = Vector3.Zero; 3372 Velocity = Vector3.Zero;
3337 AbsolutePosition = pos; 3373 AbsolutePosition = pos;
@@ -3340,6 +3376,7 @@ namespace OpenSim.Region.Framework.Scenes
3340 } 3376 }
3341 } 3377 }
3342 } 3378 }
3379 */
3343 } 3380 }
3344 else 3381 else
3345 { 3382 {
@@ -3380,7 +3417,7 @@ namespace OpenSim.Region.Framework.Scenes
3380 3417
3381 // Put the child agent back at the center 3418 // Put the child agent back at the center
3382 AbsolutePosition 3419 AbsolutePosition
3383 = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); 3420 = new Vector3(((float)m_scene.RegionInfo.RegionSizeX * 0.5f), ((float)m_scene.RegionInfo.RegionSizeY * 0.5f), 70);
3384 3421
3385 Animator.ResetAnimations(); 3422 Animator.ResetAnimations();
3386 } 3423 }
@@ -3407,9 +3444,7 @@ namespace OpenSim.Region.Framework.Scenes
3407 if (handle != Scene.RegionInfo.RegionHandle) 3444 if (handle != Scene.RegionInfo.RegionHandle)
3408 { 3445 {
3409 uint x, y; 3446 uint x, y;
3410 Utils.LongToUInts(handle, out x, out y); 3447 Util.RegionHandleToRegionLoc(handle, out x, out y);
3411 x = x / Constants.RegionSize;
3412 y = y / Constants.RegionSize;
3413 3448
3414// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3449// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3415// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3450// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
@@ -3490,8 +3525,9 @@ namespace OpenSim.Region.Framework.Scenes
3490 return; 3525 return;
3491 3526
3492 //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); 3527 //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY);
3493 int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; 3528 // Find the distance (in meters) between the two regions
3494 int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; 3529 uint shiftx = Util.RegionToWorldLoc(rRegionX - tRegionX);
3530 uint shifty = Util.RegionToWorldLoc(rRegionY - tRegionY);
3495 3531
3496 Vector3 offset = new Vector3(shiftx, shifty, 0f); 3532 Vector3 offset = new Vector3(shiftx, shifty, 0f);
3497 3533