From 07dead7dcb8b0f2a27a50748e4a460d9669903fc Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 29 Mar 2015 14:25:12 -0700 Subject: varregion: any conversions of use of Constants.RegionSize converted into Util.cs routines to convert region coords to and from world coords or handles. --- .../Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs | 17 ++++++++++++----- OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs | 14 ++++++++++++-- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 9 +++++++++ 3 files changed, 33 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs index 0816b7b..8e40561 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs @@ -46,6 +46,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin private List _actors = new List(); private List _prims = new List(); private float[] _heightMap; + private Vector3 m_regionExtent; //protected internal string sceneIdentifier; @@ -58,6 +59,12 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin public override void Initialise(IMesher meshmerizer, IConfigSource config) { + throw new Exception("Should not be called."); + } + + public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent) + { + m_regionExtent = regionExtent; } public override void Dispose() {} @@ -121,23 +128,23 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin { actorPosition.Y = 0.1F; } - else if (actor.Position.Y >= Constants.RegionSize) + else if (actor.Position.Y >= m_regionExtent.Y) { - actorPosition.Y = ((int)Constants.RegionSize - 0.1f); + actorPosition.Y = (m_regionExtent.Y - 0.1f); } if (actor.Position.X < 0) { actorPosition.X = 0.1F; } - else if (actor.Position.X >= Constants.RegionSize) + else if (actor.Position.X >= m_regionExtent.X) { - actorPosition.X = ((int)Constants.RegionSize - 0.1f); + actorPosition.X = (m_regionExtent.X - 0.1f); } float terrainHeight = 0; if (_heightMap != null) - terrainHeight = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X]; + terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X]; float height = terrainHeight + actor.Size.Z; diff --git a/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs b/OpenSim/Region/Physics/Manager/PhysicsPluginManager.cs index 8ccfda5..d14edfd 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 { @@ -59,6 +60,14 @@ namespace OpenSim.Region.Physics.Manager m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName()); } + // Legacy method for simulators before extent was passed + public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, + IConfigSource config, string regionName) + { + Vector3 extent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); + return GetPhysicsScene(physEngineName, meshEngineName, config, regionName, extent); + } + /// /// Get a physics scene for the given physics engine and mesher. /// @@ -66,7 +75,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 +104,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 dd9bbc1..4f4ff07 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -132,8 +132,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