diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index db04299..ed0dfa8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -45,14 +45,18 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
45 | public abstract class BSTerrainPhys : IDisposable | 45 | public abstract class BSTerrainPhys : IDisposable |
46 | { | 46 | { |
47 | public BSScene PhysicsScene { get; private set; } | 47 | public BSScene PhysicsScene { get; private set; } |
48 | // Base of the region in world coordinates. Coordinates inside the region are relative to this. | ||
49 | public Vector3 TerrainBase { get; private set; } | ||
50 | public uint ID { get; private set; } | ||
48 | 51 | ||
49 | public BSTerrainPhys(BSScene physicsScene) | 52 | public BSTerrainPhys(BSScene physicsScene, Vector3 regionBase, uint id) |
50 | { | 53 | { |
51 | PhysicsScene = physicsScene; | 54 | PhysicsScene = physicsScene; |
55 | TerrainBase = regionBase; | ||
56 | ID = id; | ||
52 | } | 57 | } |
53 | public abstract void Dispose(); | 58 | public abstract void Dispose(); |
54 | public abstract float GetHeightAtXYZ(Vector3 pos); | 59 | public abstract float GetHeightAtXYZ(Vector3 pos); |
55 | public abstract Vector3 TerrainBase { get; } | ||
56 | } | 60 | } |
57 | 61 | ||
58 | // ========================================================================================== | 62 | // ========================================================================================== |
@@ -133,7 +137,7 @@ public sealed class BSTerrainManager | |||
133 | (uint)CollisionFilterGroups.GroundPlaneFilter, (uint)CollisionFilterGroups.GroundPlaneMask); | 137 | (uint)CollisionFilterGroups.GroundPlaneFilter, (uint)CollisionFilterGroups.GroundPlaneMask); |
134 | 138 | ||
135 | // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain. | 139 | // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain. |
136 | BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, BSScene.TERRAIN_ID, DefaultRegionSize); | 140 | BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize); |
137 | m_terrains.Add(Vector3.Zero, initialTerrain); | 141 | m_terrains.Add(Vector3.Zero, initialTerrain); |
138 | } | 142 | } |
139 | 143 | ||
@@ -208,10 +212,9 @@ public sealed class BSTerrainManager | |||
208 | BSScene.DetailLogZero, minCoords, maxCoords, inTaintTime); | 212 | BSScene.DetailLogZero, minCoords, maxCoords, inTaintTime); |
209 | 213 | ||
210 | // Find high and low points of passed heightmap. | 214 | // Find high and low points of passed heightmap. |
211 | // The min and max passed in are usually the region objects can exist in (maximum | 215 | // The min and max passed in is usually the area objects can be in (maximum |
212 | // object height, for instance). The terrain wants the bounding box for the | 216 | // object height, for instance). The terrain wants the bounding box for the |
213 | // terrain so we replace passed min and max Z with the actual terrain min/max Z. | 217 | // terrain so we replace passed min and max Z with the actual terrain min/max Z. |
214 | // limit, for | ||
215 | float minZ = float.MaxValue; | 218 | float minZ = float.MaxValue; |
216 | float maxZ = float.MinValue; | 219 | float maxZ = float.MinValue; |
217 | foreach (float height in heightMap) | 220 | foreach (float height in heightMap) |
@@ -219,6 +222,11 @@ public sealed class BSTerrainManager | |||
219 | if (height < minZ) minZ = height; | 222 | if (height < minZ) minZ = height; |
220 | if (height > maxZ) maxZ = height; | 223 | if (height > maxZ) maxZ = height; |
221 | } | 224 | } |
225 | if (minZ == maxZ) | ||
226 | { | ||
227 | // If min and max are the same, reduce min a little bit so a good bounding box is created. | ||
228 | minZ -= BSTerrainManager.HEIGHT_EQUAL_FUDGE; | ||
229 | } | ||
222 | minCoords.Z = minZ; | 230 | minCoords.Z = minZ; |
223 | maxCoords.Z = maxZ; | 231 | maxCoords.Z = maxZ; |
224 | 232 | ||
@@ -240,7 +248,9 @@ public sealed class BSTerrainManager | |||
240 | 248 | ||
241 | if (MegaRegionParentPhysicsScene == null) | 249 | if (MegaRegionParentPhysicsScene == null) |
242 | { | 250 | { |
243 | BSTerrainPhys newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, id, | 251 | // BSTerrainPhys newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id, |
252 | // heightMap, minCoords, maxCoords); | ||
253 | BSTerrainPhys newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id, | ||
244 | heightMap, minCoords, maxCoords); | 254 | heightMap, minCoords, maxCoords); |
245 | m_terrains.Add(terrainRegionBase, newTerrainPhys); | 255 | m_terrains.Add(terrainRegionBase, newTerrainPhys); |
246 | 256 | ||
@@ -282,8 +292,8 @@ public sealed class BSTerrainManager | |||
282 | { | 292 | { |
283 | DetailLog("{0},UpdateTerrain:NewTerrain,taint,baseX={1},baseY={2}", | 293 | DetailLog("{0},UpdateTerrain:NewTerrain,taint,baseX={1},baseY={2}", |
284 | BSScene.DetailLogZero, minCoordsX.X, minCoordsX.Y); | 294 | BSScene.DetailLogZero, minCoordsX.X, minCoordsX.Y); |
285 | BSTerrainPhys newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, newTerrainID, | 295 | BSTerrainPhys newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, |
286 | heightMapX, minCoordsX, maxCoordsX); | 296 | newTerrainID, heightMapX, minCoordsX, maxCoordsX); |
287 | m_terrains.Add(terrainRegionBase, newTerrainPhys); | 297 | m_terrains.Add(terrainRegionBase, newTerrainPhys); |
288 | 298 | ||
289 | m_terrainModified = true; | 299 | m_terrainModified = true; |