From f2810bf03a3e254e0ef8d9bdd639c69cc5cf570c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 4 Nov 2013 22:10:54 -0800 Subject: varregion: add plumbing to pass region size from Scene down to the physics engine. Older physics engines will default to the legacy region size. Update BulletSim to use the new region size information. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 12 ++++++++++-- OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs | 4 ++-- OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | 6 ++++-- OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs | 5 +++-- 4 files changed, 19 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index b3dfa41..83ef1f6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -210,6 +210,14 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters public override void Initialise(IMesher meshmerizer, IConfigSource config) { + m_log.ErrorFormat("{0} WARNING WARNING WARNING! BulletSim initialized without region extent specification. Terrain will be messed up."); + Vector3 regionExtent = new Vector3( Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); + Initialise(meshmerizer, config, regionExtent); + + } + + public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) + { mesher = meshmerizer; _taintOperations = new List(); _postTaintOperations = new Dictionary(); @@ -250,13 +258,13 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters // a child in a mega-region. // Bullet actually doesn't care about the extents of the simulated // area. It tracks active objects no matter where they are. - Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); + Vector3 worldExtent = regionExtent; World = PE.Initialize(worldExtent, Params, m_maxCollisionsPerFrame, ref m_collisionArray, m_maxUpdatesPerFrame, ref m_updateArray); Constraints = new BSConstraintCollection(World); - TerrainManager = new BSTerrainManager(this); + TerrainManager = new BSTerrainManager(this, worldExtent); TerrainManager.CreateInitialGroundPlaneAndTerrain(); // Put some informational messages into the log file. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs index 8888d6d..d70b2fb 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs @@ -58,7 +58,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys { initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION; } - m_mapInfo = new BulletHMapInfo(id, initialMap); + m_mapInfo = new BulletHMapInfo(id, initialMap, regionSize.X, regionSize.Y); m_mapInfo.minCoords = minTerrainCoords; m_mapInfo.maxCoords = maxTerrainCoords; m_mapInfo.terrainRegionBase = TerrainBase; @@ -72,7 +72,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys Vector3 minCoords, Vector3 maxCoords) : base(physicsScene, regionBase, id) { - m_mapInfo = new BulletHMapInfo(id, initialMap); + m_mapInfo = new BulletHMapInfo(id, initialMap, maxCoords.X - minCoords.X, maxCoords.Y - minCoords.Y); m_mapInfo.minCoords = minCoords; m_mapInfo.maxCoords = maxCoords; m_mapInfo.minZ = minCoords.Z; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index 441d2d3..3013077 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs @@ -111,9 +111,11 @@ public sealed class BSTerrainManager : IDisposable private Vector3 m_worldMax; private PhysicsScene MegaRegionParentPhysicsScene { get; set; } - public BSTerrainManager(BSScene physicsScene) + public BSTerrainManager(BSScene physicsScene, Vector3 regionSize) { m_physicsScene = physicsScene; + DefaultRegionSize = regionSize; + m_terrains = new Dictionary(); // Assume one region of default size @@ -268,7 +270,7 @@ public sealed class BSTerrainManager : IDisposable { // There is already a terrain in this spot. Free the old and build the new. DetailLog("{0},BSTErrainManager.UpdateTerrain:UpdateExisting,call,id={1},base={2},minC={3},maxC={4}", - BSScene.DetailLogZero, id, terrainRegionBase, minCoords, minCoords); + BSScene.DetailLogZero, id, terrainRegionBase, minCoords, maxCoords); // Remove old terrain from the collection m_terrains.Remove(terrainRegionBase); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs index 971ff9f..3425d9e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs @@ -165,14 +165,15 @@ public class BulletConstraint // than making copies. public class BulletHMapInfo { - public BulletHMapInfo(uint id, float[] hm) { + public BulletHMapInfo(uint id, float[] hm, float pSizeX, float pSizeY) { ID = id; heightMap = hm; terrainRegionBase = OMV.Vector3.Zero; minCoords = new OMV.Vector3(100f, 100f, 25f); maxCoords = new OMV.Vector3(101f, 101f, 26f); minZ = maxZ = 0f; - sizeX = sizeY = 256f; + sizeX = pSizeX; + sizeY = pSizeY; } public uint ID; public float[] heightMap; -- cgit v1.1