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.cs86
1 files changed, 61 insertions, 25 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index cf98ef2..0cd8b21 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -749,9 +749,8 @@ namespace OpenSim.Region.Framework.Scenes
749 foreach (ulong handle in seeds.Keys) 749 foreach (ulong handle in seeds.Keys)
750 { 750 {
751 uint x, y; 751 uint x, y;
752 Utils.LongToUInts(handle, out x, out y); 752 Util.RegionHandleToRegionLoc(handle, out x, out y);
753 x = x / Constants.RegionSize; 753
754 y = y / Constants.RegionSize;
755 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) 754 if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY))
756 { 755 {
757 old.Add(handle); 756 old.Add(handle);
@@ -773,9 +772,7 @@ namespace OpenSim.Region.Framework.Scenes
773 foreach (KeyValuePair<ulong, string> kvp in KnownRegions) 772 foreach (KeyValuePair<ulong, string> kvp in KnownRegions)
774 { 773 {
775 uint x, y; 774 uint x, y;
776 Utils.LongToUInts(kvp.Key, out x, out y); 775 Util.RegionHandleToRegionLoc(kvp.Key, out x, out y);
777 x = x / Constants.RegionSize;
778 y = y / Constants.RegionSize;
779 m_log.Info(" >> "+x+", "+y+": "+kvp.Value); 776 m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
780 } 777 }
781 } 778 }
@@ -1109,7 +1106,7 @@ namespace OpenSim.Region.Framework.Scenes
1109 1106
1110 float posZLimit = 0; 1107 float posZLimit = 0;
1111 1108
1112 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) 1109 if (pos.X < m_scene.RegionInfo.RegionSizeX && pos.Y < m_scene.RegionInfo.RegionSizeY)
1113 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 1110 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
1114 1111
1115 float newPosZ = posZLimit + localAVHeight / 2; 1112 float newPosZ = posZLimit + localAVHeight / 2;
@@ -2362,7 +2359,7 @@ namespace OpenSim.Region.Framework.Scenes
2362 if (regionCombinerModule != null) 2359 if (regionCombinerModule != null)
2363 regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); 2360 regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID);
2364 else 2361 else
2365 regionSize = new Vector2(Constants.RegionSize); 2362 regionSize = new Vector2(m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY);
2366 2363
2367 if (pos.X < 0 || pos.X >= regionSize.X 2364 if (pos.X < 0 || pos.X >= regionSize.X
2368 || pos.Y < 0 || pos.Y >= regionSize.Y 2365 || pos.Y < 0 || pos.Y >= regionSize.Y
@@ -2380,8 +2377,8 @@ namespace OpenSim.Region.Framework.Scenes
2380// } 2377// }
2381 2378
2382 // Get terrain height for sub-region in a megaregion if necessary 2379 // Get terrain height for sub-region in a megaregion if necessary
2383 int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); 2380 int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X);
2384 int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); 2381 int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y);
2385 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); 2382 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
2386 // If X and Y is NaN, target_region will be null 2383 // If X and Y is NaN, target_region will be null
2387 if (target_region == null) 2384 if (target_region == null)
@@ -2392,7 +2389,7 @@ namespace OpenSim.Region.Framework.Scenes
2392 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) 2389 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
2393 targetScene = m_scene; 2390 targetScene = m_scene;
2394 2391
2395 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % Constants.RegionSize), (int)(pos.Y % Constants.RegionSize)]; 2392 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)];
2396 pos.Z = Math.Max(terrainHeight, pos.Z); 2393 pos.Z = Math.Max(terrainHeight, pos.Z);
2397 2394
2398 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is 2395 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is
@@ -3431,6 +3428,9 @@ namespace OpenSim.Region.Framework.Scenes
3431 int neighbor = 0; 3428 int neighbor = 0;
3432 int[] fix = new int[2]; 3429 int[] fix = new int[2];
3433 3430
3431 // Compute the avatar position in the next physics tick.
3432 // If the avatar will be crossing, we force the crossing to happen now
3433 // in the hope that this will make the avatar movement smoother when crossing.
3434 float timeStep = 0.1f; 3434 float timeStep = 0.1f;
3435 pos2.X = pos2.X + (vel.X * timeStep); 3435 pos2.X = pos2.X + (vel.X * timeStep);
3436 pos2.Y = pos2.Y + (vel.Y * timeStep); 3436 pos2.Y = pos2.Y + (vel.Y * timeStep);
@@ -3438,12 +3438,48 @@ namespace OpenSim.Region.Framework.Scenes
3438 3438
3439 if (!IsInTransit) 3439 if (!IsInTransit)
3440 { 3440 {
3441// m_log.DebugFormat( 3441 m_log.DebugFormat(
3442// "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", 3442 "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}",
3443// pos2, Name, Scene.Name); 3443 pos2, Name, Scene.Name);
3444
3445 if (!m_scene.PositionIsInCurrentRegion(pos2))
3446 {
3447 // Disconnect from the current region
3448 bool isFlying = Flying;
3449 RemoveFromPhysicalScene();
3450 // pos2 is the forcasted position so make that the 'current' position so the crossing
3451 // code will move us into the newly addressed region.
3452 m_pos = pos2;
3453 if (CrossToNewRegion())
3454 {
3455 AddToPhysicalScene(isFlying);
3456 }
3457 else
3458 {
3459 // Tried to make crossing happen but it failed.
3460 if (m_requestedSitTargetUUID == UUID.Zero)
3461 {
3462
3463 Vector3 pos = AbsolutePosition;
3464 if (AbsolutePosition.X < 0)
3465 pos.X += Velocity.X * 2;
3466 else if (AbsolutePosition.X > m_scene.RegionInfo.RegionSizeX)
3467 pos.X -= Velocity.X * 2;
3468 if (AbsolutePosition.Y < 0)
3469 pos.Y += Velocity.Y * 2;
3470 else if (AbsolutePosition.Y > m_scene.RegionInfo.RegionSizeY)
3471 pos.Y -= Velocity.Y * 2;
3472 Velocity = Vector3.Zero;
3473 AbsolutePosition = pos;
3474
3475 AddToPhysicalScene(isFlying);
3476 }
3477 }
3478
3479 }
3444 3480
3481 /*
3445 // Checks if where it's headed exists a region 3482 // Checks if where it's headed exists a region
3446 bool needsTransit = false;
3447 if (m_scene.TestBorderCross(pos2, Cardinals.W)) 3483 if (m_scene.TestBorderCross(pos2, Cardinals.W))
3448 { 3484 {
3449 if (m_scene.TestBorderCross(pos2, Cardinals.S)) 3485 if (m_scene.TestBorderCross(pos2, Cardinals.S))
@@ -3504,11 +3540,11 @@ namespace OpenSim.Region.Framework.Scenes
3504 Vector3 pos = AbsolutePosition; 3540 Vector3 pos = AbsolutePosition;
3505 if (AbsolutePosition.X < 0) 3541 if (AbsolutePosition.X < 0)
3506 pos.X += Velocity.X * 2; 3542 pos.X += Velocity.X * 2;
3507 else if (AbsolutePosition.X > Constants.RegionSize) 3543 else if (AbsolutePosition.X > m_scene.RegionInfo.RegionSizeX)
3508 pos.X -= Velocity.X * 2; 3544 pos.X -= Velocity.X * 2;
3509 if (AbsolutePosition.Y < 0) 3545 if (AbsolutePosition.Y < 0)
3510 pos.Y += Velocity.Y * 2; 3546 pos.Y += Velocity.Y * 2;
3511 else if (AbsolutePosition.Y > Constants.RegionSize) 3547 else if (AbsolutePosition.Y > m_scene.RegionInfo.RegionSizeY)
3512 pos.Y -= Velocity.Y * 2; 3548 pos.Y -= Velocity.Y * 2;
3513 Velocity = Vector3.Zero; 3549 Velocity = Vector3.Zero;
3514 AbsolutePosition = pos; 3550 AbsolutePosition = pos;
@@ -3531,11 +3567,11 @@ namespace OpenSim.Region.Framework.Scenes
3531 Vector3 pos = AbsolutePosition; 3567 Vector3 pos = AbsolutePosition;
3532 if (AbsolutePosition.X < 0) 3568 if (AbsolutePosition.X < 0)
3533 pos.X += Velocity.X * 2; 3569 pos.X += Velocity.X * 2;
3534 else if (AbsolutePosition.X > Constants.RegionSize) 3570 else if (AbsolutePosition.X > m_scene.RegionInfo.RegionSizeX)
3535 pos.X -= Velocity.X * 2; 3571 pos.X -= Velocity.X * 2;
3536 if (AbsolutePosition.Y < 0) 3572 if (AbsolutePosition.Y < 0)
3537 pos.Y += Velocity.Y * 2; 3573 pos.Y += Velocity.Y * 2;
3538 else if (AbsolutePosition.Y > Constants.RegionSize) 3574 else if (AbsolutePosition.Y > m_scene.RegionInfo.RegionSizeY)
3539 pos.Y -= Velocity.Y * 2; 3575 pos.Y -= Velocity.Y * 2;
3540 Velocity = Vector3.Zero; 3576 Velocity = Vector3.Zero;
3541 AbsolutePosition = pos; 3577 AbsolutePosition = pos;
@@ -3544,6 +3580,7 @@ namespace OpenSim.Region.Framework.Scenes
3544 } 3580 }
3545 } 3581 }
3546 } 3582 }
3583 */
3547 } 3584 }
3548 else 3585 else
3549 { 3586 {
@@ -3584,7 +3621,7 @@ namespace OpenSim.Region.Framework.Scenes
3584 3621
3585 // Put the child agent back at the center 3622 // Put the child agent back at the center
3586 AbsolutePosition 3623 AbsolutePosition
3587 = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); 3624 = new Vector3(((float)m_scene.RegionInfo.RegionSizeX * 0.5f), ((float)m_scene.RegionInfo.RegionSizeY * 0.5f), 70);
3588 3625
3589 Animator.ResetAnimations(); 3626 Animator.ResetAnimations();
3590 } 3627 }
@@ -3611,9 +3648,7 @@ namespace OpenSim.Region.Framework.Scenes
3611 if (handle != Scene.RegionInfo.RegionHandle) 3648 if (handle != Scene.RegionInfo.RegionHandle)
3612 { 3649 {
3613 uint x, y; 3650 uint x, y;
3614 Utils.LongToUInts(handle, out x, out y); 3651 Util.RegionHandleToRegionLoc(handle, out x, out y);
3615 x = x / Constants.RegionSize;
3616 y = y / Constants.RegionSize;
3617 3652
3618// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3653// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3619// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3654// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
@@ -3694,8 +3729,9 @@ namespace OpenSim.Region.Framework.Scenes
3694 return; 3729 return;
3695 3730
3696 //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); 3731 //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY);
3697 int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; 3732 // Find the distance (in meters) between the two regions
3698 int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; 3733 uint shiftx = Util.RegionToWorldLoc(rRegionX - tRegionX);
3734 uint shifty = Util.RegionToWorldLoc(rRegionY - tRegionY);
3699 3735
3700 Vector3 offset = new Vector3(shiftx, shifty, 0f); 3736 Vector3 offset = new Vector3(shiftx, shifty, 0f);
3701 3737