diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 160 |
1 files changed, 50 insertions, 110 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 84201cc..715a9b6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -76,6 +76,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
76 | public class ScenePresence : EntityBase, IScenePresence | 76 | public class ScenePresence : EntityBase, IScenePresence |
77 | { | 77 | { |
78 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 78 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
79 | private static readonly String LogHeader = "[SCENE PRESENCE]"; | ||
79 | 80 | ||
80 | // ~ScenePresence() | 81 | // ~ScenePresence() |
81 | // { | 82 | // { |
@@ -759,9 +760,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
759 | foreach (ulong handle in seeds.Keys) | 760 | foreach (ulong handle in seeds.Keys) |
760 | { | 761 | { |
761 | uint x, y; | 762 | uint x, y; |
762 | Utils.LongToUInts(handle, out x, out y); | 763 | Util.RegionHandleToRegionLoc(handle, out x, out y); |
763 | x = x / Constants.RegionSize; | 764 | |
764 | y = y / Constants.RegionSize; | ||
765 | if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) | 765 | if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) |
766 | { | 766 | { |
767 | old.Add(handle); | 767 | old.Add(handle); |
@@ -783,9 +783,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
783 | foreach (KeyValuePair<ulong, string> kvp in KnownRegions) | 783 | foreach (KeyValuePair<ulong, string> kvp in KnownRegions) |
784 | { | 784 | { |
785 | uint x, y; | 785 | uint x, y; |
786 | Utils.LongToUInts(kvp.Key, out x, out y); | 786 | Util.RegionHandleToRegionLoc(kvp.Key, out x, out y); |
787 | x = x / Constants.RegionSize; | ||
788 | y = y / Constants.RegionSize; | ||
789 | m_log.Info(" >> "+x+", "+y+": "+kvp.Value); | 787 | m_log.Info(" >> "+x+", "+y+": "+kvp.Value); |
790 | } | 788 | } |
791 | } | 789 | } |
@@ -1092,6 +1090,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1092 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | 1090 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
1093 | // related to the handling of attachments | 1091 | // related to the handling of attachments |
1094 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | 1092 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); |
1093 | |||
1094 | /* RA 20140111: Commented out these TestBorderCross's. | ||
1095 | * Not sure why this code is here. It is not checking all the borders | ||
1096 | * and 'in region' sanity checking is done in CheckAndAdjustLandingPoint and below. | ||
1095 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | 1097 | if (m_scene.TestBorderCross(pos, Cardinals.E)) |
1096 | { | 1098 | { |
1097 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 1099 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); |
@@ -1103,6 +1105,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1103 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 1105 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
1104 | pos.Y = crossedBorder.BorderLine.Z - 1; | 1106 | pos.Y = crossedBorder.BorderLine.Z - 1; |
1105 | } | 1107 | } |
1108 | */ | ||
1106 | 1109 | ||
1107 | CheckAndAdjustLandingPoint(ref pos); | 1110 | CheckAndAdjustLandingPoint(ref pos); |
1108 | 1111 | ||
@@ -1123,7 +1126,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1123 | 1126 | ||
1124 | float posZLimit = 0; | 1127 | float posZLimit = 0; |
1125 | 1128 | ||
1126 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 1129 | if (pos.X < m_scene.RegionInfo.RegionSizeX && pos.Y < m_scene.RegionInfo.RegionSizeY) |
1127 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 1130 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
1128 | 1131 | ||
1129 | float newPosZ = posZLimit + localAVHeight / 2; | 1132 | float newPosZ = posZLimit + localAVHeight / 2; |
@@ -2400,7 +2403,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2400 | if (regionCombinerModule != null) | 2403 | if (regionCombinerModule != null) |
2401 | regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); | 2404 | regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); |
2402 | else | 2405 | else |
2403 | regionSize = new Vector2(Constants.RegionSize); | 2406 | regionSize = new Vector2(m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY); |
2404 | 2407 | ||
2405 | if (pos.X < 0 || pos.X >= regionSize.X | 2408 | if (pos.X < 0 || pos.X >= regionSize.X |
2406 | || pos.Y < 0 || pos.Y >= regionSize.Y | 2409 | || pos.Y < 0 || pos.Y >= regionSize.Y |
@@ -2418,8 +2421,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2418 | // } | 2421 | // } |
2419 | 2422 | ||
2420 | // Get terrain height for sub-region in a megaregion if necessary | 2423 | // Get terrain height for sub-region in a megaregion if necessary |
2421 | int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); | 2424 | int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X); |
2422 | int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); | 2425 | int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y); |
2423 | GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); | 2426 | GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); |
2424 | // If X and Y is NaN, target_region will be null | 2427 | // If X and Y is NaN, target_region will be null |
2425 | if (target_region == null) | 2428 | if (target_region == null) |
@@ -2430,7 +2433,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2430 | if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) | 2433 | if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) |
2431 | targetScene = m_scene; | 2434 | targetScene = m_scene; |
2432 | 2435 | ||
2433 | float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % Constants.RegionSize), (int)(pos.Y % Constants.RegionSize)]; | 2436 | float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; |
2434 | pos.Z = Math.Max(terrainHeight, pos.Z); | 2437 | pos.Z = Math.Max(terrainHeight, pos.Z); |
2435 | 2438 | ||
2436 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is | 2439 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is |
@@ -3466,10 +3469,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3466 | if (!IsInTransit) | 3469 | if (!IsInTransit) |
3467 | { | 3470 | { |
3468 | Vector3 pos2 = AbsolutePosition; | 3471 | Vector3 pos2 = AbsolutePosition; |
3472 | Vector3 origPosition = pos2; | ||
3469 | Vector3 vel = Velocity; | 3473 | Vector3 vel = Velocity; |
3470 | int neighbor = 0; | 3474 | int neighbor = 0; |
3471 | int[] fix = new int[2]; | 3475 | int[] fix = new int[2]; |
3472 | 3476 | ||
3477 | // Compute the avatar position in the next physics tick. | ||
3478 | // If the avatar will be crossing, we force the crossing to happen now | ||
3479 | // in the hope that this will make the avatar movement smoother when crossing. | ||
3473 | float timeStep = 0.1f; | 3480 | float timeStep = 0.1f; |
3474 | pos2.X = pos2.X + (vel.X * timeStep); | 3481 | pos2.X = pos2.X + (vel.X * timeStep); |
3475 | pos2.Y = pos2.Y + (vel.Y * timeStep); | 3482 | pos2.Y = pos2.Y + (vel.Y * timeStep); |
@@ -3477,111 +3484,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
3477 | 3484 | ||
3478 | if (!IsInTransit) | 3485 | if (!IsInTransit) |
3479 | { | 3486 | { |
3480 | // m_log.DebugFormat( | 3487 | if (!m_scene.PositionIsInCurrentRegion(pos2)) |
3481 | // "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", | ||
3482 | // pos2, Name, Scene.Name); | ||
3483 | |||
3484 | // Checks if where it's headed exists a region | ||
3485 | bool needsTransit = false; | ||
3486 | if (m_scene.TestBorderCross(pos2, Cardinals.W)) | ||
3487 | { | ||
3488 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) | ||
3489 | { | ||
3490 | needsTransit = true; | ||
3491 | neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); | ||
3492 | } | ||
3493 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
3494 | { | ||
3495 | needsTransit = true; | ||
3496 | neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); | ||
3497 | } | ||
3498 | else | ||
3499 | { | ||
3500 | needsTransit = true; | ||
3501 | neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); | ||
3502 | } | ||
3503 | } | ||
3504 | else if (m_scene.TestBorderCross(pos2, Cardinals.E)) | ||
3505 | { | 3488 | { |
3506 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) | 3489 | m_log.DebugFormat("{0} CheckForBorderCrossing: position outside region. {1} in {2} at pos {3}", |
3490 | LogHeader, Name, Scene.Name, pos2); | ||
3491 | |||
3492 | // Disconnect from the current region | ||
3493 | bool isFlying = Flying; | ||
3494 | RemoveFromPhysicalScene(); | ||
3495 | // pos2 is the forcasted position so make that the 'current' position so the crossing | ||
3496 | // code will move us into the newly addressed region. | ||
3497 | m_pos = pos2; | ||
3498 | if (CrossToNewRegion()) | ||
3507 | { | 3499 | { |
3508 | needsTransit = true; | 3500 | AddToPhysicalScene(isFlying); |
3509 | neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); | ||
3510 | } | ||
3511 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
3512 | { | ||
3513 | needsTransit = true; | ||
3514 | neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); | ||
3515 | } | 3501 | } |
3516 | else | 3502 | else |
3517 | { | 3503 | { |
3518 | needsTransit = true; | 3504 | // Tried to make crossing happen but it failed. |
3519 | neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); | ||
3520 | } | ||
3521 | } | ||
3522 | else if (m_scene.TestBorderCross(pos2, Cardinals.S)) | ||
3523 | { | ||
3524 | needsTransit = true; | ||
3525 | neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); | ||
3526 | } | ||
3527 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
3528 | { | ||
3529 | needsTransit = true; | ||
3530 | neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); | ||
3531 | } | ||
3532 | |||
3533 | // Makes sure avatar does not end up outside region | ||
3534 | if (neighbor <= 0) | ||
3535 | { | ||
3536 | if (needsTransit) | ||
3537 | { | ||
3538 | if (m_requestedSitTargetUUID == UUID.Zero) | ||
3539 | { | ||
3540 | bool isFlying = Flying; | ||
3541 | RemoveFromPhysicalScene(); | ||
3542 | |||
3543 | Vector3 pos = AbsolutePosition; | ||
3544 | if (AbsolutePosition.X < 0) | ||
3545 | pos.X += Velocity.X * 2; | ||
3546 | else if (AbsolutePosition.X > Constants.RegionSize) | ||
3547 | pos.X -= Velocity.X * 2; | ||
3548 | if (AbsolutePosition.Y < 0) | ||
3549 | pos.Y += Velocity.Y * 2; | ||
3550 | else if (AbsolutePosition.Y > Constants.RegionSize) | ||
3551 | pos.Y -= Velocity.Y * 2; | ||
3552 | Velocity = Vector3.Zero; | ||
3553 | AbsolutePosition = pos; | ||
3554 | |||
3555 | // m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); | ||
3556 | |||
3557 | AddToPhysicalScene(isFlying); | ||
3558 | } | ||
3559 | } | ||
3560 | } | ||
3561 | else if (neighbor > 0) | ||
3562 | { | ||
3563 | if (!CrossToNewRegion()) | ||
3564 | { | ||
3565 | if (m_requestedSitTargetUUID == UUID.Zero) | 3505 | if (m_requestedSitTargetUUID == UUID.Zero) |
3566 | { | 3506 | { |
3567 | bool isFlying = Flying; | 3507 | m_log.DebugFormat("{0} CheckForBorderCrossing: Crossing failed. Restoring old position.", LogHeader); |
3568 | RemoveFromPhysicalScene(); | 3508 | const float borderFudge = 0.1f; |
3569 | 3509 | ||
3570 | Vector3 pos = AbsolutePosition; | 3510 | if (origPosition.X < 0) |
3571 | if (AbsolutePosition.X < 0) | 3511 | origPosition.X = borderFudge; |
3572 | pos.X += Velocity.X * 2; | 3512 | else if (origPosition.X > (float)m_scene.RegionInfo.RegionSizeX) |
3573 | else if (AbsolutePosition.X > Constants.RegionSize) | 3513 | origPosition.X = (float)m_scene.RegionInfo.RegionSizeX - borderFudge; |
3574 | pos.X -= Velocity.X * 2; | 3514 | if (origPosition.Y < 0) |
3575 | if (AbsolutePosition.Y < 0) | 3515 | origPosition.Y = borderFudge; |
3576 | pos.Y += Velocity.Y * 2; | 3516 | else if (origPosition.Y > (float)m_scene.RegionInfo.RegionSizeY) |
3577 | else if (AbsolutePosition.Y > Constants.RegionSize) | 3517 | origPosition.Y = (float)m_scene.RegionInfo.RegionSizeY - borderFudge; |
3578 | pos.Y -= Velocity.Y * 2; | ||
3579 | Velocity = Vector3.Zero; | 3518 | Velocity = Vector3.Zero; |
3580 | AbsolutePosition = pos; | 3519 | AbsolutePosition = origPosition; |
3581 | 3520 | ||
3582 | AddToPhysicalScene(isFlying); | 3521 | AddToPhysicalScene(isFlying); |
3583 | } | 3522 | } |
3584 | } | 3523 | } |
3524 | |||
3585 | } | 3525 | } |
3586 | } | 3526 | } |
3587 | else | 3527 | else |
@@ -3623,7 +3563,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3623 | 3563 | ||
3624 | // Put the child agent back at the center | 3564 | // Put the child agent back at the center |
3625 | AbsolutePosition | 3565 | AbsolutePosition |
3626 | = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); | 3566 | = new Vector3(((float)m_scene.RegionInfo.RegionSizeX * 0.5f), ((float)m_scene.RegionInfo.RegionSizeY * 0.5f), 70); |
3627 | 3567 | ||
3628 | Animator.ResetAnimations(); | 3568 | Animator.ResetAnimations(); |
3629 | } | 3569 | } |
@@ -3650,9 +3590,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3650 | if (handle != Scene.RegionInfo.RegionHandle) | 3590 | if (handle != Scene.RegionInfo.RegionHandle) |
3651 | { | 3591 | { |
3652 | uint x, y; | 3592 | uint x, y; |
3653 | Utils.LongToUInts(handle, out x, out y); | 3593 | Util.RegionHandleToRegionLoc(handle, out x, out y); |
3654 | x = x / Constants.RegionSize; | ||
3655 | y = y / Constants.RegionSize; | ||
3656 | 3594 | ||
3657 | // m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); | 3595 | // m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); |
3658 | // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); | 3596 | // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); |
@@ -3733,8 +3671,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3733 | return; | 3671 | return; |
3734 | 3672 | ||
3735 | //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); | 3673 | //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); |
3736 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; | 3674 | // Find the distance (in meters) between the two regions |
3737 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; | 3675 | uint shiftx = Util.RegionToWorldLoc(rRegionX - tRegionX); |
3676 | uint shifty = Util.RegionToWorldLoc(rRegionY - tRegionY); | ||
3738 | 3677 | ||
3739 | Vector3 offset = new Vector3(shiftx, shifty, 0f); | 3678 | Vector3 offset = new Vector3(shiftx, shifty, 0f); |
3740 | 3679 | ||
@@ -4770,6 +4709,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4770 | } | 4709 | } |
4771 | } | 4710 | } |
4772 | 4711 | ||
4712 | // Modify landing point based on possible banning, telehubs or parcel restrictions. | ||
4773 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4713 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4774 | { | 4714 | { |
4775 | string reason; | 4715 | string reason; |