aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs70
1 files changed, 64 insertions, 6 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 58a2f2a..db83cb0 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -200,6 +200,10 @@ namespace OpenSim.Region.Framework.Scenes
200 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG 200 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
201 } 201 }
202 202
203 protected enum Cardinals
204 {
205 N=1,NE,E,SE,S,SW,W,NW
206 }
203 /// <summary> 207 /// <summary>
204 /// Position at which a significant movement was made 208 /// Position at which a significant movement was made
205 /// </summary> 209 /// </summary>
@@ -2260,7 +2264,7 @@ namespace OpenSim.Region.Framework.Scenes
2260 } 2264 }
2261 } 2265 }
2262 } 2266 }
2263 2267
2264 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2268 m_scene.StatsReporter.AddAgentUpdates(avatars.Count);
2265 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2269 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2266 2270
@@ -2517,6 +2521,8 @@ namespace OpenSim.Region.Framework.Scenes
2517 2521
2518 Vector3 pos2 = AbsolutePosition; 2522 Vector3 pos2 = AbsolutePosition;
2519 Vector3 vel = Velocity; 2523 Vector3 vel = Velocity;
2524 int neighbor = 0;
2525 int[] fix = new int[2];
2520 2526
2521 float timeStep = 0.1f; 2527 float timeStep = 0.1f;
2522 pos2.X = pos2.X + (vel.X*timeStep); 2528 pos2.X = pos2.X + (vel.X*timeStep);
@@ -2525,15 +2531,38 @@ namespace OpenSim.Region.Framework.Scenes
2525 2531
2526 if (!IsInTransit) 2532 if (!IsInTransit)
2527 { 2533 {
2528 if ((pos2.X < 0) || (pos2.X > Constants.RegionSize)) 2534 // Checks if where it's headed exists a region
2535 if (pos2.X < 0)
2529 { 2536 {
2530 CrossToNewRegion(); 2537 if (pos2.Y < 0)
2538 neighbor = HaveNeighbor(Cardinals.SW, ref fix);
2539 else if (pos2.Y > Constants.RegionSize)
2540 neighbor = HaveNeighbor(Cardinals.NW, ref fix);
2541 else
2542 neighbor = HaveNeighbor(Cardinals.W, ref fix);
2531 } 2543 }
2532 2544 else if (pos2.X > Constants.RegionSize)
2533 if ((pos2.Y < 0) || (pos2.Y > Constants.RegionSize))
2534 { 2545 {
2546 if (pos2.Y < 0)
2547 neighbor = HaveNeighbor(Cardinals.SE, ref fix);
2548 else if (pos2.Y > Constants.RegionSize)
2549 neighbor = HaveNeighbor(Cardinals.NE, ref fix);
2550 else
2551 neighbor = HaveNeighbor(Cardinals.E, ref fix);
2552 }
2553 else if (pos2.Y < 0)
2554 neighbor = HaveNeighbor(Cardinals.S, ref fix);
2555 else if (pos2.Y > Constants.RegionSize)
2556 neighbor = HaveNeighbor(Cardinals.N, ref fix);
2557
2558 // Makes sure avatar does not end up outside region
2559 if (neighbor < 0)
2560 AbsolutePosition = new Vector3(
2561 AbsolutePosition.X + 3*fix[0],
2562 AbsolutePosition.Y + 3*fix[1],
2563 AbsolutePosition.Z);
2564 else if (neighbor > 0)
2535 CrossToNewRegion(); 2565 CrossToNewRegion();
2536 }
2537 } 2566 }
2538 else 2567 else
2539 { 2568 {
@@ -2547,7 +2576,36 @@ namespace OpenSim.Region.Framework.Scenes
2547 pos2.Z = pos2.Z + (vel.Z * timeStep); 2576 pos2.Z = pos2.Z + (vel.Z * timeStep);
2548 m_pos = pos2; 2577 m_pos = pos2;
2549 } 2578 }
2579 }
2550 2580
2581 protected int HaveNeighbor(Cardinals car, ref int[] fix)
2582 {
2583 uint neighbourx = m_regionInfo.RegionLocX;
2584 uint neighboury = m_regionInfo.RegionLocY;
2585
2586 int dir = (int)car;
2587
2588 if (dir > 1 && dir < 5) //Heading East
2589 neighbourx++;
2590 else if (dir > 5) // Heading West
2591 neighbourx--;
2592
2593 if (dir < 3 || dir == 8) // Heading North
2594 neighboury++;
2595 else if (dir > 3 && dir < 7) // Heading Sout
2596 neighboury--;
2597
2598 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
2599 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle);
2600
2601 if (neighbourRegion == null)
2602 {
2603 fix[0] = (int)(m_regionInfo.RegionLocX - neighbourx);
2604 fix[1] = (int)(m_regionInfo.RegionLocY - neighboury);
2605 return dir * (-1);
2606 }
2607 else
2608 return dir;
2551 } 2609 }
2552 2610
2553 /// <summary> 2611 /// <summary>