Procházet zdrojové kódy

First commit where physics work as region module.
Moved all physics dlls out of Physics and into bin directly, so they can be found by the module loader.
Removed call to PhysicsPluginManager.

Diva Canto před 8 roky
rodič
revize
11194209df

+ 1 - 14
OpenSim/Region/Application/OpenSimBase.cs

@@ -734,10 +734,6 @@ namespace OpenSim
             clientServer = clientNetworkServers;
             scene.LoadWorldMap();
 
-            scene.PhysicsScene.RequestAssetMethod = scene.PhysicsRequestAsset;
-            scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
-            scene.PhysicsScene.SetWaterLevel((float) regionInfo.RegionSettings.WaterHeight);
-
             return scene;
         }
 
@@ -749,11 +745,8 @@ namespace OpenSim
         protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService,
             IEstateDataService estateDataService, AgentCircuitManager circuitManager)
         {
-            Vector3 regionExtent = new Vector3(regionInfo.RegionSizeX, regionInfo.RegionSizeY, regionInfo.RegionSizeZ);
-            PhysicsScene physicsScene = GetPhysicsScene(regionInfo.RegionName, regionExtent);
-
             return new Scene(
-                regionInfo, circuitManager, physicsScene, 
+                regionInfo, circuitManager,  
                 simDataService, estateDataService,
                 Config, m_version);
         }
@@ -796,12 +789,6 @@ namespace OpenSim
 
         # region Setup methods
 
-        protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier, Vector3 regionExtent)
-        {
-            return GetPhysicsScene(
-                m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, Config, osSceneIdentifier, regionExtent);
-        }
-
         /// <summary>
         /// Handler to supply the current status of this sim
         /// </summary>

+ 0 - 29
OpenSim/Region/ClientStack/RegionApplicationBase.cs

@@ -62,16 +62,6 @@ namespace OpenSim.Region.ClientStack
        
         protected abstract void Initialize();
         
-        /// <summary>
-        /// Get a new physics scene.
-        /// </summary>
-        /// 
-        /// <param name="osSceneIdentifier">
-        /// 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, Vector3 regionExtent);
-        
         protected abstract ClientStackManager CreateClientStackManager();
         protected abstract Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService, IEstateDataService estateDataService, AgentCircuitManager circuitManager);
 
@@ -113,24 +103,5 @@ namespace OpenSim.Region.ClientStack
             base.StartupSpecific();
         }
 
-        /// <summary>
-        /// Get a new physics scene.
-        /// </summary>
-        /// <param name="engine">The name of the physics engine to use</param>
-        /// <param name="meshEngine">The name of the mesh engine to use</param>
-        /// <param name="config">The configuration data to pass to the physics and mesh engines</param>
-        /// <param name="osSceneIdentifier">
-        /// The name of the OpenSim scene this physics scene is serving.  This will be used in log messages.
-        /// </param>
-        /// <returns></returns>
-        protected PhysicsScene GetPhysicsScene(
-            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, regionExtent);
-        }
     }
 }

+ 1 - 1
OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs

@@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library
             }
 
             RegionInfo regInfo = new RegionInfo();
-            Scene m_MockScene = new Scene(regInfo, null);
+            Scene m_MockScene = new Scene(regInfo);
             LocalInventoryService invService = new LocalInventoryService(lib);
             m_MockScene.RegisterModuleInterface<IInventoryService>(invService);
             m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService);

+ 4 - 4
OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs

@@ -85,7 +85,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
             r1.ExternalHostName = "127.0.0.1";
             r1.HttpPort = 9001;
             r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
-            Scene s = new Scene(new RegionInfo(), null);
+            Scene s = new Scene(new RegionInfo());
             s.RegionInfo.RegionID = r1.RegionID;
             m_LocalConnector.AddRegion(s);
             
@@ -97,7 +97,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
             r2.ExternalHostName = "127.0.0.1";
             r2.HttpPort = 9002;
             r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
-            s = new Scene(new RegionInfo(), null);
+            s = new Scene(new RegionInfo());
             s.RegionInfo.RegionID = r2.RegionID;
             m_LocalConnector.AddRegion(s);
 
@@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
             r3.ExternalHostName = "127.0.0.1";
             r3.HttpPort = 9003;
             r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
-            s = new Scene(new RegionInfo(), null);
+            s = new Scene(new RegionInfo());
             s.RegionInfo.RegionID = r3.RegionID;
             m_LocalConnector.AddRegion(s);
 
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
             r4.ExternalHostName = "127.0.0.1";
             r4.HttpPort = 9004;
             r4.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0);
-            s = new Scene(new RegionInfo(), null);
+            s = new Scene(new RegionInfo());
             s.RegionInfo.RegionID = r4.RegionID;
             m_LocalConnector.AddRegion(s);
 

+ 3 - 4
OpenSim/Region/Framework/Scenes/Scene.cs

@@ -850,10 +850,10 @@ namespace OpenSim.Region.Framework.Scenes
 
         #region Constructors
 
-        public Scene(RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene,
+        public Scene(RegionInfo regInfo, AgentCircuitManager authen, 
                      ISimulationDataService simDataService, IEstateDataService estateDataService,
                      IConfigSource config, string simulatorVersion)
-            : this(regInfo, physicsScene)
+            : this(regInfo)
         {
             m_config = config;
             MinFrameTicks = 89;
@@ -1192,11 +1192,10 @@ namespace OpenSim.Region.Framework.Scenes
 
         }
 
-        public Scene(RegionInfo regInfo, PhysicsScene physicsScene)
+        public Scene(RegionInfo regInfo)
             : base(regInfo)
         {
             m_sceneGraph = new SceneGraph(this);
-            m_sceneGraph.PhysicsScene = physicsScene;
 
             // If the scene graph has an Unrecoverable error, restart this sim.
             // Currently the only thing that causes it to happen is two kinds of specific

+ 6 - 1
OpenSim/Region/Framework/Scenes/SceneGraph.cs

@@ -111,7 +111,12 @@ namespace OpenSim.Region.Framework.Scenes
 
         public PhysicsScene PhysicsScene
         {
-            get { return _PhyScene; }
+            get 
+            {
+                if (_PhyScene == null)
+                    _PhyScene = m_parentScene.RequestModuleInterface<PhysicsScene>();
+                return _PhyScene; 
+            }
             set
             {
                 // If we're not doing the initial set

+ 1 - 0
OpenSim/Region/PhysicsModules/BasicPhysics/BasicPhysicsScene.cs

@@ -93,6 +93,7 @@ namespace OpenSim.Region.PhysicsModule.BasicPhysics
 
             scene.RegisterModuleInterface<PhysicsScene>(this);
             m_regionExtent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
+            base.Initialise(scene.PhysicsRequestAsset, scene.Heightmap.GetFloatsSerialised(), (float)scene.RegionInfo.RegionSettings.WaterHeight);
 
         }
 

+ 4 - 1
OpenSim/Region/PhysicsModules/BulletS/BSScene.cs

@@ -248,7 +248,10 @@ namespace OpenSim.Region.PhysicsModule.BulletS
 
             scene.RegisterModuleInterface<PhysicsScene>(this);
             Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
-            Initialise(m_Config, extent);   
+            Initialise(m_Config, extent);
+
+            base.Initialise(scene.PhysicsRequestAsset, scene.Heightmap.GetFloatsSerialised(), (float)scene.RegionInfo.RegionSettings.WaterHeight);
+
         }
 
         public void RemoveRegion(Scene scene)

+ 19 - 8
OpenSim/Region/PhysicsModules/BulletS/Tests/BulletSimTestsUtil.cs

@@ -35,6 +35,7 @@ using Nini.Config;
 using OpenSim.Framework;
 using OpenSim.Region.PhysicsModules.SharedBase;
 using OpenSim.Region.PhysicsModules.Meshing;
+using OpenSim.Region.Framework.Interfaces;
 
 using OpenMetaverse;
 
@@ -78,22 +79,32 @@ public static class BulletSimTestsUtil
             bulletSimConfig.Set("VehicleLoggingEnabled","True");
         }
 
-        PhysicsPluginManager physicsPluginManager;
-        physicsPluginManager = new PhysicsPluginManager();
-        physicsPluginManager.LoadPluginsFromAssemblies("Physics");
-
         Vector3 regionExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
        
-        PhysicsScene pScene = physicsPluginManager.GetPhysicsScene(
-                        "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent);
+        //PhysicsScene pScene = physicsPluginManager.GetPhysicsScene(
+        //                "BulletSim", "Meshmerizer", openSimINI, "BSTestRegion", regionExtent);
+        RegionInfo info = new RegionInfo();
+        info.RegionName = "BSTestRegion";
+        info.RegionSizeX = info.RegionSizeY = info.RegionSizeZ = Constants.RegionSize;
+        OpenSim.Region.Framework.Scenes.Scene scene = new OpenSim.Region.Framework.Scenes.Scene(info);
+
+        IMesher mesher = new OpenSim.Region.PhysicsModules.Meshing.Meshmerizer();
+        INonSharedRegionModule mod = mesher as INonSharedRegionModule;
+        mod.Initialise(openSimINI);
+        mod.AddRegion(scene);
+        mod.RegionLoaded(scene);
 
-        BSScene bsScene = pScene as BSScene;
+        BSScene pScene = new BSScene();
+        mod = (pScene as INonSharedRegionModule);
+        mod.Initialise(openSimINI);
+        mod.AddRegion(scene);
+        mod.RegionLoaded(scene);
 
         // Since the asset requestor is not initialized, any mesh or sculptie will be a cube.
         // In the future, add a fake asset fetcher to get meshes and sculpts.
         // bsScene.RequestAssetMethod = ???;
 
-        return bsScene;
+        return pScene;
     }
 
 }

+ 2 - 0
OpenSim/Region/PhysicsModules/Ode/OdeScene.cs

@@ -585,6 +585,8 @@ namespace OpenSim.Region.PhysicsModule.ODE
             Vector3 extent = new Vector3(scene.RegionInfo.RegionSizeX, scene.RegionInfo.RegionSizeY, scene.RegionInfo.RegionSizeZ);
             Initialise();
             InitialiseFromConfig(m_config);
+            base.Initialise(scene.PhysicsRequestAsset, scene.Heightmap.GetFloatsSerialised(), (float)scene.RegionInfo.RegionSettings.WaterHeight);
+
         }
 
         public void RemoveRegion(Scene scene)

+ 2 - 0
OpenSim/Region/PhysicsModules/POS/POSScene.cs

@@ -85,6 +85,8 @@ namespace OpenSim.Region.PhysicsModule.POS
             PhysicsSceneName = EngineType + "/" + scene.RegionInfo.RegionName;
 
             scene.RegisterModuleInterface<PhysicsScene>(this);
+            base.Initialise(scene.PhysicsRequestAsset, scene.Heightmap.GetFloatsSerialised(), (float)scene.RegionInfo.RegionSettings.WaterHeight);
+
         }
 
         public void RemoveRegion(Scene scene)

+ 8 - 0
OpenSim/Region/PhysicsModules/SharedBase/PhysicsScene.cs

@@ -117,6 +117,14 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
 
         public RequestAssetDelegate RequestAssetMethod { get; set; }
 
+        protected void Initialise(RequestAssetDelegate m, float[] terrain, float waterHeight)
+        {
+            RequestAssetMethod = m;
+            SetTerrain(terrain);
+            SetWaterLevel(waterHeight);
+
+        }
+
         public virtual void TriggerPhysicsBasedRestart()
         {
             physicsCrash handler = OnPhysicsCrash;

+ 1 - 4
OpenSim/Tests/Common/Helpers/SceneHelpers.cs

@@ -151,12 +151,9 @@ namespace OpenSim.Tests.Common
             PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager();
             physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.PhysicsModule.BasicPhysics.dll");
             Vector3 regionExtent = new Vector3( regInfo.RegionSizeX, regInfo.RegionSizeY, regInfo.RegionSizeZ);
-            PhysicsScene physicsScene 
-                = physicsPluginManager.GetPhysicsScene(
-                    "basicphysics", "ZeroMesher", new IniConfigSource(), "test", regionExtent);
 
             TestScene testScene = new TestScene(
-                regInfo, m_acm, physicsScene, SimDataService, m_estateDataService, configSource, null);
+                regInfo, m_acm, SimDataService, m_estateDataService, configSource, null);
 
             INonSharedRegionModule godsModule = new GodsModule();
             godsModule.Initialise(new IniConfigSource());

+ 2 - 2
OpenSim/Tests/Common/Mock/TestScene.cs

@@ -41,10 +41,10 @@ namespace OpenSim.Tests.Common
     public class TestScene : Scene
     {
         public TestScene(
-            RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene,
+            RegionInfo regInfo, AgentCircuitManager authen, 
             ISimulationDataService simDataService, IEstateDataService estateDataService,
             IConfigSource config, string simulatorVersion)
-            : base(regInfo, authen, physicsScene, simDataService, estateDataService,
+            : base(regInfo, authen, simDataService, estateDataService,
                    config, simulatorVersion)
         {
         }

+ 1 - 1
OpenSim/Tests/Common/OpenSimTestCase.cs

@@ -38,7 +38,7 @@ namespace OpenSim.Tests.Common
         [SetUp]
         public virtual void SetUp()
         {
-//            TestHelpers.InMethod();
+            //TestHelpers.InMethod();
             // Disable logging for each test so that one where logging is enabled doesn't cause all subsequent tests
             // to have logging on if it failed with an exception.
             TestHelpers.DisableLogging();

+ 0 - 0
bin/Physics/OpenSim.Region.Physics.BulletSPlugin.dll.config → bin/OpenSim.Region.PhysicsModule.BulletS.dll.config


+ 35 - 36
prebuild.xml

@@ -487,6 +487,32 @@
       </Files>
     </Project>
 
+    <Project frameworkVersion="v4_0" name="OpenSim.Region.PhysicsModules.SharedBase" path="OpenSim/Region/PhysicsModules/SharedBase" type="Library">
+      <Configuration name="Debug">
+        <Options>
+          <OutputPath>../../../../bin/</OutputPath>
+        </Options>
+      </Configuration>
+      <Configuration name="Release">
+        <Options>
+          <OutputPath>../../../../bin/</OutputPath>
+        </Options>
+      </Configuration>
+
+      <ReferencePath>../../../../bin/</ReferencePath>
+      <Reference name="System"/>
+      <Reference name="System.Xml"/>
+      <Reference name="OpenMetaverseTypes" path="../../../../bin/"/>
+      <Reference name="OpenSim.Framework"/>
+      <Reference name="OpenSim.Framework.Console"/>
+      <Reference name="nunit.framework" path="../../../../bin/"/>
+      <Reference name="Nini" path="../../../../bin/"/>
+      <Reference name="log4net" path="../../../../bin/"/>
+
+      <Files>
+        <Match pattern="*.cs" recurse="false"/>
+      </Files>
+    </Project>
 
     <Project frameworkVersion="v4_0" name="OpenSim.Region.Framework" path="OpenSim/Region/Framework" type="Library">
       <Configuration name="Debug">
@@ -1692,7 +1718,7 @@
       </Files>
     </Project>
 
-    <Project frameworkVersion="v4_0" name="OpenSim.Region.PhysicsModules.SharedBase" path="OpenSim/Region/PhysicsModules/SharedBase" type="Library">
+    <Project frameworkVersion="v4_0" name="OpenSim.Region.PhysicsModules.Meshing" path="OpenSim/Region/PhysicsModules/Meshing" type="Library">
       <Configuration name="Debug">
         <Options>
           <OutputPath>../../../../bin/</OutputPath>
@@ -1704,33 +1730,6 @@
         </Options>
       </Configuration>
 
-      <ReferencePath>../../../../bin/</ReferencePath>
-      <Reference name="System"/>
-      <Reference name="System.Xml"/>
-      <Reference name="OpenMetaverseTypes" path="../../../../bin/"/>
-      <Reference name="OpenSim.Framework"/>
-      <Reference name="OpenSim.Framework.Console"/>
-      <Reference name="nunit.framework" path="../../../../bin/"/>
-      <Reference name="Nini" path="../../../../bin/"/>
-      <Reference name="log4net" path="../../../../bin/"/>
-
-      <Files>
-        <Match pattern="*.cs" recurse="false"/>
-      </Files>
-    </Project>
-
-    <Project frameworkVersion="v4_0" name="OpenSim.Region.PhysicsModules.Meshing" path="OpenSim/Region/PhysicsModules/Meshing" type="Library">
-      <Configuration name="Debug">
-        <Options>
-          <OutputPath>../../../../bin/Physics/</OutputPath>
-        </Options>
-      </Configuration>
-      <Configuration name="Release">
-        <Options>
-          <OutputPath>../../../../bin/Physics/</OutputPath>
-        </Options>
-      </Configuration>
-
       <ReferencePath>../../../../bin/</ReferencePath>
       <Reference name="System"/>
       <Reference name="System.Drawing"/>
@@ -1755,12 +1754,12 @@
     <Project frameworkVersion="v4_0" name="OpenSim.Region.PhysicsModule.BasicPhysics" path="OpenSim/Region/PhysicsModules/BasicPhysics" type="Library">
       <Configuration name="Debug">
         <Options>
-          <OutputPath>../../../../bin/Physics/</OutputPath>
+          <OutputPath>../../../../bin/</OutputPath>
         </Options>
       </Configuration>
       <Configuration name="Release">
         <Options>
-          <OutputPath>../../../../bin/Physics/</OutputPath>
+          <OutputPath>../../../../bin/</OutputPath>
         </Options>
       </Configuration>
 
@@ -1780,12 +1779,12 @@
     <Project frameworkVersion="v4_0" name="OpenSim.Region.PhysicsModule.POS" path="OpenSim/Region/PhysicsModules/POS" type="Library">
       <Configuration name="Debug">
         <Options>
-          <OutputPath>../../../../bin/Physics/</OutputPath>
+          <OutputPath>../../../../bin/</OutputPath>
         </Options>
       </Configuration>
       <Configuration name="Release">
         <Options>
-          <OutputPath>../../../../bin/Physics/</OutputPath>
+          <OutputPath>../../../../bin/</OutputPath>
         </Options>
       </Configuration>
 
@@ -1805,12 +1804,12 @@
     <Project frameworkVersion="v4_0" name="OpenSim.Region.PhysicsModule.Ode" path="OpenSim/Region/PhysicsModules/Ode" type="Library">
       <Configuration name="Debug">
         <Options>
-          <OutputPath>../../../../bin/Physics/</OutputPath>
+          <OutputPath>../../../../bin/</OutputPath>
         </Options>
       </Configuration>
       <Configuration name="Release">
         <Options>
-          <OutputPath>../../../../bin/Physics/</OutputPath>
+          <OutputPath>../../../../bin/</OutputPath>
         </Options>
       </Configuration>
 
@@ -1837,13 +1836,13 @@
     <Project frameworkVersion="v4_0" name="OpenSim.Region.PhysicsModule.BulletS" path="OpenSim/Region/PhysicsModules/BulletS" type="Library">
       <Configuration name="Debug">
         <Options>
-          <OutputPath>../../../../bin/Physics/</OutputPath>
+          <OutputPath>../../../../bin/</OutputPath>
           <AllowUnsafe>true</AllowUnsafe>
         </Options>
       </Configuration>
       <Configuration name="Release">
         <Options>
-          <OutputPath>../../../../bin/Physics/</OutputPath>
+          <OutputPath>../../../../bin/</OutputPath>
           <AllowUnsafe>true</AllowUnsafe>
         </Options>
       </Configuration>