diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-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 'OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs')
-rw-r--r-- | OpenSim/Region/PhysicsModules/BulletS/BSTerrainHeightmap.cs | 24 |
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 | { |