aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorlillith_xue2014-04-21 06:11:15 +0200
committerRobert Adams2014-04-21 05:58:29 -0700
commitbc969a6b466272a5b4f05b6774b5370bd75a39e7 (patch)
tree26760f5f3626d4649b0aa2a185068ab7a2facd15 /OpenSim/Region/Framework
parentBetter error-handling when storing assets: recognize that 'null' is an error ... (diff)
downloadopensim-SC_OLD-bc969a6b466272a5b4f05b6774b5370bd75a39e7.zip
opensim-SC_OLD-bc969a6b466272a5b4f05b6774b5370bd75a39e7.tar.gz
opensim-SC_OLD-bc969a6b466272a5b4f05b6774b5370bd75a39e7.tar.bz2
opensim-SC_OLD-bc969a6b466272a5b4f05b6774b5370bd75a39e7.tar.xz
Possible solution for #7120 and #7051
Signed-off-by: Robert Adams <misterblue@misterblue.com>
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs55
1 files changed, 32 insertions, 23 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 7a6ed5c..57f9d01 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2472,35 +2472,44 @@ namespace OpenSim.Region.Framework.Scenes
2472// } 2472// }
2473 2473
2474 // Get terrain height for sub-region in a megaregion if necessary 2474 // Get terrain height for sub-region in a megaregion if necessary
2475 int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X);
2476 int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y);
2477 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
2478 // If X and Y is NaN, target_region will be null
2479 if (target_region == null)
2480 return;
2481 UUID target_regionID = target_region.RegionID;
2482 Scene targetScene = m_scene;
2483
2484 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
2485 targetScene = m_scene;
2486
2487 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)];
2488 pos.Z = Math.Max(terrainHeight, pos.Z);
2489 2475
2490 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is 2476 //COMMENT: If its only nessesary in a megaregion, why do it on normal region's too?
2491 // always slightly higher than the actual terrain height. 2477
2492 // FIXME: This constrains NPC movements as well, so should be somewhere else. 2478 if (regionCombinerModule != null)
2493 if (pos.Z - terrainHeight < 0.2) 2479 {
2494 pos.Z = terrainHeight; 2480 int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X);
2481 int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y);
2482 GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
2483 // If X and Y is NaN, target_region will be null
2484 if (target_region == null)
2485 return;
2486 UUID target_regionID = target_region.RegionID;
2487 Scene targetScene = m_scene;
2488
2489 if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
2490 targetScene = m_scene;
2491
2492 float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)];
2493 pos.Z = Math.Max(terrainHeight, pos.Z);
2494
2495 // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is
2496 // always slightly higher than the actual terrain height.
2497 // FIXME: This constrains NPC movements as well, so should be somewhere else.
2498 if (pos.Z - terrainHeight < 0.2)
2499 pos.Z = terrainHeight;
2500
2501 if (noFly)
2502 Flying = false;
2503 else if (pos.Z > terrainHeight)
2504 Flying = true;
2505 }
2495 2506
2496// m_log.DebugFormat( 2507// m_log.DebugFormat(
2497// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", 2508// "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}",
2498// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); 2509// Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
2499 2510
2500 if (noFly) 2511 if (noFly)
2501 Flying = false; 2512 Flying = false;
2502 else if (pos.Z > terrainHeight)
2503 Flying = true;
2504 2513
2505 LandAtTarget = landAtTarget; 2514 LandAtTarget = landAtTarget;
2506 MovingToTarget = true; 2515 MovingToTarget = true;