aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
diff options
context:
space:
mode:
authorRobert Adams2012-11-21 13:44:02 -0800
committerRobert Adams2012-11-21 16:43:45 -0800
commit4a0de0170412a939bade6cd149c94c7fd3ef020e (patch)
treeb6ca9aff94d236590fe2237eba4d4cf41421939c /OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
parentBulletSim: add terrainImplementation parameter with default to Mesh. (diff)
downloadopensim-SC-4a0de0170412a939bade6cd149c94c7fd3ef020e.zip
opensim-SC-4a0de0170412a939bade6cd149c94c7fd3ef020e.tar.gz
opensim-SC-4a0de0170412a939bade6cd149c94c7fd3ef020e.tar.bz2
opensim-SC-4a0de0170412a939bade6cd149c94c7fd3ef020e.tar.xz
BulletSim: Properly position mesh terrain on creation (fixes terrain not appearing to be working). Centralize terrain shape creation logic. Remove very chatty detail log messages.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs74
1 files changed, 35 insertions, 39 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
index b88f561..097cd3e 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs
@@ -241,38 +241,20 @@ public sealed class BSTerrainManager
241 BSTerrainPhys terrainPhys; 241 BSTerrainPhys terrainPhys;
242 if (m_terrains.TryGetValue(terrainRegionBase, out terrainPhys)) 242 if (m_terrains.TryGetValue(terrainRegionBase, out terrainPhys))
243 { 243 {
244 // If this is terrain we know about, it's easy to update 244 // There is already a terrain in this spot. Free the old and build the new.
245 245 DetailLog("{0},UpdateTerrain:UpdateExisting,call,id={1},base={2},minC={3},maxC={4}",
246 DetailLog("{0},UpdateTerrain:UpdateExisting,call,terrainBase={1}", BSScene.DetailLogZero, terrainRegionBase); 246 BSScene.DetailLogZero, id, terrainRegionBase, minCoords, minCoords);
247 247
248 PhysicsScene.TaintedObject(inTaintTime, "BSScene.UpdateTerrain:UpdateExisting", delegate() 248 PhysicsScene.TaintedObject(inTaintTime, "BSScene.UpdateTerrain:UpdateExisting", delegate()
249 { 249 {
250 // Remove old terrain from the collection 250 // Remove old terrain from the collection
251 m_terrains.Remove(terrainPhys.TerrainBase); 251 m_terrains.Remove(terrainRegionBase);
252 // Release any physical memory it may be using. 252 // Release any physical memory it may be using.
253 terrainPhys.Dispose(); 253 terrainPhys.Dispose();
254 254
255 BSTerrainPhys newTerrainPhys = null; ;
256 if (MegaRegionParentPhysicsScene == null) 255 if (MegaRegionParentPhysicsScene == null)
257 { 256 {
258 // TODO: redo terrain implementation selection to be centralized (there is another 257 BSTerrainPhys newTerrainPhys = BuildPhysicalTerrain(terrainRegionBase, id, heightMap, minCoords, maxCoords);
259 // use below) and to accept an asset specification (for a mesh).
260 switch ((int)PhysicsScene.Params.terrainImplementation)
261 {
262 case (int)BSTerrainPhys.TerrainImplementation.Heightmap:
263 newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id,
264 heightMap, minCoords, maxCoords);
265 break;
266 case (int)BSTerrainPhys.TerrainImplementation.Mesh:
267 newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id,
268 heightMap, minCoords, maxCoords);
269 break;
270 default:
271 PhysicsScene.Logger.ErrorFormat("{0} Bad terrain implementation specified. type={1}/{2}",
272 LogHeader, (int)PhysicsScene.Params.terrainImplementation, PhysicsScene.Params.terrainImplementation);
273 break;
274 }
275
276 m_terrains.Add(terrainRegionBase, newTerrainPhys); 258 m_terrains.Add(terrainRegionBase, newTerrainPhys);
277 259
278 m_terrainModified = true; 260 m_terrainModified = true;
@@ -313,22 +295,7 @@ public sealed class BSTerrainManager
313 { 295 {
314 DetailLog("{0},UpdateTerrain:NewTerrain,taint,baseX={1},baseY={2}", 296 DetailLog("{0},UpdateTerrain:NewTerrain,taint,baseX={1},baseY={2}",
315 BSScene.DetailLogZero, minCoordsX.X, minCoordsX.Y); 297 BSScene.DetailLogZero, minCoordsX.X, minCoordsX.Y);
316 BSTerrainPhys newTerrainPhys = null; 298 BSTerrainPhys newTerrainPhys = BuildPhysicalTerrain(terrainRegionBase, id, heightMap, minCoords, maxCoords);
317 switch ((int)PhysicsScene.Params.terrainImplementation)
318 {
319 case (int)BSTerrainPhys.TerrainImplementation.Heightmap:
320 newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id,
321 heightMap, minCoords, maxCoords);
322 break;
323 case (int)BSTerrainPhys.TerrainImplementation.Mesh:
324 newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id,
325 heightMap, minCoords, maxCoords);
326 break;
327 default:
328 PhysicsScene.Logger.ErrorFormat("{0} Bad terrain implementation specified. type={1}/{2}",
329 LogHeader, (int)PhysicsScene.Params.terrainImplementation, PhysicsScene.Params.terrainImplementation);
330 break;
331 }
332 m_terrains.Add(terrainRegionBase, newTerrainPhys); 299 m_terrains.Add(terrainRegionBase, newTerrainPhys);
333 300
334 m_terrainModified = true; 301 m_terrainModified = true;
@@ -336,6 +303,35 @@ public sealed class BSTerrainManager
336 } 303 }
337 } 304 }
338 305
306 // TODO: redo terrain implementation selection to allow other base types than heightMap.
307 private BSTerrainPhys BuildPhysicalTerrain(Vector3 terrainRegionBase, uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords)
308 {
309 PhysicsScene.Logger.DebugFormat("{0} Terrain for {1}/{2} created with {3}",
310 LogHeader, PhysicsScene.RegionName, terrainRegionBase,
311 PhysicsScene.Params.terrainImplementation);
312 BSTerrainPhys newTerrainPhys = null;
313 switch ((int)PhysicsScene.Params.terrainImplementation)
314 {
315 case (int)BSTerrainPhys.TerrainImplementation.Heightmap:
316 newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id,
317 heightMap, minCoords, maxCoords);
318 break;
319 case (int)BSTerrainPhys.TerrainImplementation.Mesh:
320 newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id,
321 heightMap, minCoords, maxCoords);
322 break;
323 default:
324 PhysicsScene.Logger.ErrorFormat("{0} Bad terrain implementation specified. Type={1}/{2},Region={3}/{4}",
325 LogHeader,
326 (int)PhysicsScene.Params.terrainImplementation,
327 PhysicsScene.Params.terrainImplementation,
328 PhysicsScene.RegionName, terrainRegionBase);
329 break;
330 }
331 return newTerrainPhys;
332 }
333
334
339 // Given an X and Y, find the height of the terrain. 335 // Given an X and Y, find the height of the terrain.
340 // Since we could be handling multiple terrains for a mega-region, 336 // Since we could be handling multiple terrains for a mega-region,
341 // the base of the region is calcuated assuming all regions are 337 // the base of the region is calcuated assuming all regions are