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 85a20e9..b4274ba 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; |
@@ -2386,7 +2389,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2386 | if (regionCombinerModule != null) | 2389 | if (regionCombinerModule != null) |
2387 | regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); | 2390 | regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); |
2388 | else | 2391 | else |
2389 | regionSize = new Vector2(Constants.RegionSize); | 2392 | regionSize = new Vector2(m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY); |
2390 | 2393 | ||
2391 | if (pos.X < 0 || pos.X >= regionSize.X | 2394 | if (pos.X < 0 || pos.X >= regionSize.X |
2392 | || pos.Y < 0 || pos.Y >= regionSize.Y | 2395 | || pos.Y < 0 || pos.Y >= regionSize.Y |
@@ -2404,8 +2407,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2404 | // } | 2407 | // } |
2405 | 2408 | ||
2406 | // Get terrain height for sub-region in a megaregion if necessary | 2409 | // Get terrain height for sub-region in a megaregion if necessary |
2407 | int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); | 2410 | int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X); |
2408 | int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); | 2411 | int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y); |
2409 | GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); | 2412 | GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); |
2410 | // If X and Y is NaN, target_region will be null | 2413 | // If X and Y is NaN, target_region will be null |
2411 | if (target_region == null) | 2414 | if (target_region == null) |
@@ -2416,7 +2419,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2416 | if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) | 2419 | if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) |
2417 | targetScene = m_scene; | 2420 | targetScene = m_scene; |
2418 | 2421 | ||
2419 | float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % Constants.RegionSize), (int)(pos.Y % Constants.RegionSize)]; | 2422 | float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; |
2420 | pos.Z = Math.Max(terrainHeight, pos.Z); | 2423 | pos.Z = Math.Max(terrainHeight, pos.Z); |
2421 | 2424 | ||
2422 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is | 2425 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is |
@@ -3451,10 +3454,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3451 | if (!IsInTransit) | 3454 | if (!IsInTransit) |
3452 | { | 3455 | { |
3453 | Vector3 pos2 = AbsolutePosition; | 3456 | Vector3 pos2 = AbsolutePosition; |
3457 | Vector3 origPosition = pos2; | ||
3454 | Vector3 vel = Velocity; | 3458 | Vector3 vel = Velocity; |
3455 | int neighbor = 0; | 3459 | int neighbor = 0; |
3456 | int[] fix = new int[2]; | 3460 | int[] fix = new int[2]; |
3457 | 3461 | ||
3462 | // Compute the avatar position in the next physics tick. | ||
3463 | // If the avatar will be crossing, we force the crossing to happen now | ||
3464 | // in the hope that this will make the avatar movement smoother when crossing. | ||
3458 | float timeStep = 0.1f; | 3465 | float timeStep = 0.1f; |
3459 | pos2.X = pos2.X + (vel.X * timeStep); | 3466 | pos2.X = pos2.X + (vel.X * timeStep); |
3460 | pos2.Y = pos2.Y + (vel.Y * timeStep); | 3467 | pos2.Y = pos2.Y + (vel.Y * timeStep); |
@@ -3462,111 +3469,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
3462 | 3469 | ||
3463 | if (!IsInTransit) | 3470 | if (!IsInTransit) |
3464 | { | 3471 | { |
3465 | // m_log.DebugFormat( | 3472 | if (!m_scene.PositionIsInCurrentRegion(pos2)) |
3466 | // "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", | ||
3467 | // pos2, Name, Scene.Name); | ||
3468 | |||
3469 | // Checks if where it's headed exists a region | ||
3470 | bool needsTransit = false; | ||
3471 | if (m_scene.TestBorderCross(pos2, Cardinals.W)) | ||
3472 | { | ||
3473 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) | ||
3474 | { | ||
3475 | needsTransit = true; | ||
3476 | neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); | ||
3477 | } | ||
3478 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
3479 | { | ||
3480 | needsTransit = true; | ||
3481 | neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); | ||
3482 | } | ||
3483 | else | ||
3484 | { | ||
3485 | needsTransit = true; | ||
3486 | neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); | ||
3487 | } | ||
3488 | } | ||
3489 | else if (m_scene.TestBorderCross(pos2, Cardinals.E)) | ||
3490 | { | 3473 | { |
3491 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) | 3474 | m_log.DebugFormat("{0} CheckForBorderCrossing: position outside region. {1} in {2} at pos {3}", |
3475 | LogHeader, Name, Scene.Name, pos2); | ||
3476 | |||
3477 | // Disconnect from the current region | ||
3478 | bool isFlying = Flying; | ||
3479 | RemoveFromPhysicalScene(); | ||
3480 | // pos2 is the forcasted position so make that the 'current' position so the crossing | ||
3481 | // code will move us into the newly addressed region. | ||
3482 | m_pos = pos2; | ||
3483 | if (CrossToNewRegion()) | ||
3492 | { | 3484 | { |
3493 | needsTransit = true; | 3485 | AddToPhysicalScene(isFlying); |
3494 | neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); | ||
3495 | } | ||
3496 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
3497 | { | ||
3498 | needsTransit = true; | ||
3499 | neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); | ||
3500 | } | 3486 | } |
3501 | else | 3487 | else |
3502 | { | 3488 | { |
3503 | needsTransit = true; | 3489 | // Tried to make crossing happen but it failed. |
3504 | neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); | ||
3505 | } | ||
3506 | } | ||
3507 | else if (m_scene.TestBorderCross(pos2, Cardinals.S)) | ||
3508 | { | ||
3509 | needsTransit = true; | ||
3510 | neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); | ||
3511 | } | ||
3512 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) | ||
3513 | { | ||
3514 | needsTransit = true; | ||
3515 | neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); | ||
3516 | } | ||
3517 | |||
3518 | // Makes sure avatar does not end up outside region | ||
3519 | if (neighbor <= 0) | ||
3520 | { | ||
3521 | if (needsTransit) | ||
3522 | { | ||
3523 | if (m_requestedSitTargetUUID == UUID.Zero) | ||
3524 | { | ||
3525 | bool isFlying = Flying; | ||
3526 | RemoveFromPhysicalScene(); | ||
3527 | |||
3528 | Vector3 pos = AbsolutePosition; | ||
3529 | if (AbsolutePosition.X < 0) | ||
3530 | pos.X += Velocity.X * 2; | ||
3531 | else if (AbsolutePosition.X > Constants.RegionSize) | ||
3532 | pos.X -= Velocity.X * 2; | ||
3533 | if (AbsolutePosition.Y < 0) | ||
3534 | pos.Y += Velocity.Y * 2; | ||
3535 | else if (AbsolutePosition.Y > Constants.RegionSize) | ||
3536 | pos.Y -= Velocity.Y * 2; | ||
3537 | Velocity = Vector3.Zero; | ||
3538 | AbsolutePosition = pos; | ||
3539 | |||
3540 | // m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); | ||
3541 | |||
3542 | AddToPhysicalScene(isFlying); | ||
3543 | } | ||
3544 | } | ||
3545 | } | ||
3546 | else if (neighbor > 0) | ||
3547 | { | ||
3548 | if (!CrossToNewRegion()) | ||
3549 | { | ||
3550 | if (m_requestedSitTargetUUID == UUID.Zero) | 3490 | if (m_requestedSitTargetUUID == UUID.Zero) |
3551 | { | 3491 | { |
3552 | bool isFlying = Flying; | 3492 | m_log.DebugFormat("{0} CheckForBorderCrossing: Crossing failed. Restoring old position.", LogHeader); |
3553 | RemoveFromPhysicalScene(); | 3493 | const float borderFudge = 0.1f; |
3554 | 3494 | ||
3555 | Vector3 pos = AbsolutePosition; | 3495 | if (origPosition.X < 0) |
3556 | if (AbsolutePosition.X < 0) | 3496 | origPosition.X = borderFudge; |
3557 | pos.X += Velocity.X * 2; | 3497 | else if (origPosition.X > (float)m_scene.RegionInfo.RegionSizeX) |
3558 | else if (AbsolutePosition.X > Constants.RegionSize) | 3498 | origPosition.X = (float)m_scene.RegionInfo.RegionSizeX - borderFudge; |
3559 | pos.X -= Velocity.X * 2; | 3499 | if (origPosition.Y < 0) |
3560 | if (AbsolutePosition.Y < 0) | 3500 | origPosition.Y = borderFudge; |
3561 | pos.Y += Velocity.Y * 2; | 3501 | else if (origPosition.Y > (float)m_scene.RegionInfo.RegionSizeY) |
3562 | else if (AbsolutePosition.Y > Constants.RegionSize) | 3502 | origPosition.Y = (float)m_scene.RegionInfo.RegionSizeY - borderFudge; |
3563 | pos.Y -= Velocity.Y * 2; | ||
3564 | Velocity = Vector3.Zero; | 3503 | Velocity = Vector3.Zero; |
3565 | AbsolutePosition = pos; | 3504 | AbsolutePosition = origPosition; |
3566 | 3505 | ||
3567 | AddToPhysicalScene(isFlying); | 3506 | AddToPhysicalScene(isFlying); |
3568 | } | 3507 | } |
3569 | } | 3508 | } |
3509 | |||
3570 | } | 3510 | } |
3571 | } | 3511 | } |
3572 | else | 3512 | else |
@@ -3608,7 +3548,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3608 | 3548 | ||
3609 | // Put the child agent back at the center | 3549 | // Put the child agent back at the center |
3610 | AbsolutePosition | 3550 | AbsolutePosition |
3611 | = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); | 3551 | = new Vector3(((float)m_scene.RegionInfo.RegionSizeX * 0.5f), ((float)m_scene.RegionInfo.RegionSizeY * 0.5f), 70); |
3612 | 3552 | ||
3613 | Animator.ResetAnimations(); | 3553 | Animator.ResetAnimations(); |
3614 | } | 3554 | } |
@@ -3635,9 +3575,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3635 | if (handle != Scene.RegionInfo.RegionHandle) | 3575 | if (handle != Scene.RegionInfo.RegionHandle) |
3636 | { | 3576 | { |
3637 | uint x, y; | 3577 | uint x, y; |
3638 | Utils.LongToUInts(handle, out x, out y); | 3578 | Util.RegionHandleToRegionLoc(handle, out x, out y); |
3639 | x = x / Constants.RegionSize; | ||
3640 | y = y / Constants.RegionSize; | ||
3641 | 3579 | ||
3642 | // m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); | 3580 | // m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); |
3643 | // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); | 3581 | // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); |
@@ -3718,8 +3656,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3718 | return; | 3656 | return; |
3719 | 3657 | ||
3720 | //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); | 3658 | //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); |
3721 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; | 3659 | // Find the distance (in meters) between the two regions |
3722 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; | 3660 | uint shiftx = Util.RegionToWorldLoc(rRegionX - tRegionX); |
3661 | uint shifty = Util.RegionToWorldLoc(rRegionY - tRegionY); | ||
3723 | 3662 | ||
3724 | Vector3 offset = new Vector3(shiftx, shifty, 0f); | 3663 | Vector3 offset = new Vector3(shiftx, shifty, 0f); |
3725 | 3664 | ||
@@ -4755,6 +4694,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4755 | } | 4694 | } |
4756 | } | 4695 | } |
4757 | 4696 | ||
4697 | // Modify landing point based on possible banning, telehubs or parcel restrictions. | ||
4758 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4698 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4759 | { | 4699 | { |
4760 | string reason; | 4700 | string reason; |