aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
diff options
context:
space:
mode:
authoronefang2019-09-11 16:36:50 +1000
committeronefang2019-09-11 16:36:50 +1000
commit50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch)
tree52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
parentRenamed branch to SledjChisl. (diff)
parentBump to release flavour, build 0. (diff)
downloadopensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2
opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz
Merge branch 'SledjChisl'
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs24
1 files changed, 20 insertions, 4 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs b/OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
index 42fc11b..f72ad28 100644
--- a/OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs
@@ -141,14 +141,30 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
141 } 141 }
142 142
143 // The passed position is relative to the base of the region. 143 // The passed position is relative to the base of the region.
144 // There are many assumptions herein that the heightmap increment is 1.
144 public override float GetTerrainHeightAtXYZ(Vector3 pos) 145 public override float GetTerrainHeightAtXYZ(Vector3 pos)
145 { 146 {
146 float ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET; 147 float ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET;
147 148
148 int mapIndex = (int)pos.Y * (int)m_mapInfo.sizeY + (int)pos.X; 149 try {
149 try 150 int baseX = (int)pos.X;
150 { 151 int baseY = (int)pos.Y;
151 ret = m_mapInfo.heightMap[mapIndex]; 152 int maxX = (int)m_mapInfo.sizeX;
153 int maxY = (int)m_mapInfo.sizeY;
154 float diffX = pos.X - (float)baseX;
155 float diffY = pos.Y - (float)baseY;
156
157 float mapHeight1 = m_mapInfo.heightMap[baseY * maxY + baseX];
158 float mapHeight2 = m_mapInfo.heightMap[Math.Min(baseY + 1, maxY - 1) * maxY + baseX];
159 float mapHeight3 = m_mapInfo.heightMap[baseY * maxY + Math.Min(baseX + 1, maxX - 1)];
160 float mapHeight4 = m_mapInfo.heightMap[Math.Min(baseY + 1, maxY - 1) * maxY + Math.Min(baseX + 1, maxX - 1)];
161
162 float Xrise = (mapHeight4 - mapHeight3) * diffX;
163 float Yrise = (mapHeight2 - mapHeight1) * diffY;
164
165 ret = mapHeight1 + ((Xrise + Yrise) / 2f);
166 // m_physicsScene.DetailLog("{0},BSTerrainHeightMap,GetTerrainHeightAtXYZ,pos={1},{2}/{3}/{4}/{5},ret={6}",
167 // BSScene.DetailLogZero, pos, mapHeight1, mapHeight2, mapHeight3, mapHeight4, ret);
152 } 168 }
153 catch 169 catch
154 { 170 {