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.varregion
parent
cd1a23fc14
commit
f2810bf03a
|
@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -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.
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
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
|
|||
/// </param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -209,6 +209,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<TaintCallbackEntry>();
|
||||
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Vector3,BSTerrainPhys>();
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
|||
/// <param name="meshEngineName"></param>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an avatar
|
||||
/// </summary>
|
||||
|
|
|
@ -186,8 +186,9 @@ namespace OpenSim.Tests.Common
|
|||
|
||||
PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
|
||||
physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll");
|
||||
Vector3 regionExtent = new Vector3( regInfo.RegionSizeX, regInfo.RegionSizeY, regInfo.RegionSizeZ);
|
||||
testScene.PhysicsScene
|
||||
= physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test");
|
||||
= physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test", regionExtent);
|
||||
|
||||
testScene.RegionInfo.EstateSettings = new EstateSettings();
|
||||
testScene.LoginsEnabled = true;
|
||||
|
|
Loading…
Reference in New Issue