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/Application/OpenSimBase.cs | 7 ++++--- OpenSim/Region/ClientStack/RegionApplicationBase.cs | 6 +++--- 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 +++-- OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs | 6 ++++-- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 9 +++++++++ 8 files changed, 39 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 1e34a1e..70d7ee9 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -690,7 +690,8 @@ namespace OpenSim clientServer = clientNetworkServers; scene.LoadWorldMap(); - scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName); + Vector3 regionExtent = new Vector3(regionInfo.RegionSizeX, regionInfo.RegionSizeY, regionInfo.RegionSizeZ); + scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName, regionExtent); scene.PhysicsScene.RequestAssetMethod = scene.PhysicsRequestAsset; scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); scene.PhysicsScene.SetWaterLevel((float) regionInfo.RegionSettings.WaterHeight); @@ -752,10 +753,10 @@ namespace OpenSim # region Setup methods - protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier) + protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier, Vector3 regionExtent) { return GetPhysicsScene( - m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, Config, osSceneIdentifier); + m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, Config, osSceneIdentifier, regionExtent); } /// diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 853b72d..1ce166e 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs @@ -69,7 +69,7 @@ namespace OpenSim.Region.ClientStack /// The name of the OpenSim scene this physics scene is serving. This will be used in log messages. /// /// - protected abstract PhysicsScene GetPhysicsScene(string osSceneIdentifier); + protected abstract PhysicsScene GetPhysicsScene(string osSceneIdentifier, Vector3 regionExtent); protected abstract ClientStackManager CreateClientStackManager(); protected abstract Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService, IEstateDataService estateDataService, AgentCircuitManager circuitManager); @@ -123,13 +123,13 @@ namespace OpenSim.Region.ClientStack /// /// protected PhysicsScene GetPhysicsScene( - string engine, string meshEngine, IConfigSource config, string osSceneIdentifier) + string engine, string meshEngine, IConfigSource config, string osSceneIdentifier, Vector3 regionExtent) { PhysicsPluginManager physicsPluginManager; physicsPluginManager = new PhysicsPluginManager(); physicsPluginManager.LoadPluginsFromAssemblies("Physics"); - return physicsPluginManager.GetPhysicsScene(engine, meshEngine, config, osSceneIdentifier); + return physicsPluginManager.GetPhysicsScene(engine, meshEngine, config, osSceneIdentifier, regionExtent); } } } \ No newline at end of file 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; diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index 8ccfda5..9b06353 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs @@ -32,6 +32,7 @@ using System.Reflection; using Nini.Config; using log4net; using OpenSim.Framework; +using OpenMetaverse; namespace OpenSim.Region.Physics.Manager { @@ -66,7 +67,8 @@ namespace OpenSim.Region.Physics.Manager /// /// /// - public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, IConfigSource config, string regionName) + public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, + IConfigSource config, string regionName, Vector3 regionExtent) { if (String.IsNullOrEmpty(physEngineName)) { @@ -94,7 +96,7 @@ namespace OpenSim.Region.Physics.Manager { m_log.Info("[PHYSICS]: creating " + physEngineName); PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName); - result.Initialise(meshEngine, config); + result.Initialise(meshEngine, config, regionExtent); return result; } else diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index c93206d..71ad795 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -126,8 +126,17 @@ namespace OpenSim.Region.Physics.Manager } } + // Deprecated. Do not use this for new physics engines. public abstract void Initialise(IMesher meshmerizer, IConfigSource config); + // For older physics engines that do not implement non-legacy region sizes. + // If the physics engine handles the region extent feature, it overrides this function. + public virtual void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) + { + // If not overridden, call the old initialization entry. + Initialise(meshmerizer, config); + } + /// /// Add an avatar /// -- cgit v1.1