diff options
author | Justin Clark-Casey (justincc) | 2014-07-29 01:21:15 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-07-29 01:21:15 +0100 |
commit | 3654ae8d8cea0bf0455974efe18ff99e484d2893 (patch) | |
tree | 4daebd94efd967de9d64f69ace7d057f514635e6 /OpenSim/Region | |
parent | minor: make "debug scene set" usage command accurate again from last commit f... (diff) | |
download | opensim-SC-3654ae8d8cea0bf0455974efe18ff99e484d2893.zip opensim-SC-3654ae8d8cea0bf0455974efe18ff99e484d2893.tar.gz opensim-SC-3654ae8d8cea0bf0455974efe18ff99e484d2893.tar.bz2 opensim-SC-3654ae8d8cea0bf0455974efe18ff99e484d2893.tar.xz |
Allow the "debug scene set physics false|true" command to work when bulletsim physics is running in a separate thread.
This will also allow the "disable physics" setting in the region debug viewer dialog to work in this circumstance.
Diffstat (limited to 'OpenSim/Region')
6 files changed, 66 insertions, 29 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index d2dce24..ab606a3 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -730,8 +730,6 @@ namespace OpenSim | |||
730 | clientServer = clientNetworkServers; | 730 | clientServer = clientNetworkServers; |
731 | scene.LoadWorldMap(); | 731 | scene.LoadWorldMap(); |
732 | 732 | ||
733 | Vector3 regionExtent = new Vector3(regionInfo.RegionSizeX, regionInfo.RegionSizeY, regionInfo.RegionSizeZ); | ||
734 | scene.PhysicsScene = GetPhysicsScene(scene.RegionInfo.RegionName, regionExtent); | ||
735 | scene.PhysicsScene.RequestAssetMethod = scene.PhysicsRequestAsset; | 733 | scene.PhysicsScene.RequestAssetMethod = scene.PhysicsRequestAsset; |
736 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); | 734 | scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); |
737 | scene.PhysicsScene.SetWaterLevel((float) regionInfo.RegionSettings.WaterHeight); | 735 | scene.PhysicsScene.SetWaterLevel((float) regionInfo.RegionSettings.WaterHeight); |
@@ -747,10 +745,13 @@ namespace OpenSim | |||
747 | protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService, | 745 | protected override Scene CreateScene(RegionInfo regionInfo, ISimulationDataService simDataService, |
748 | IEstateDataService estateDataService, AgentCircuitManager circuitManager) | 746 | IEstateDataService estateDataService, AgentCircuitManager circuitManager) |
749 | { | 747 | { |
748 | Vector3 regionExtent = new Vector3(regionInfo.RegionSizeX, regionInfo.RegionSizeY, regionInfo.RegionSizeZ); | ||
749 | PhysicsScene physicsScene = GetPhysicsScene(regionInfo.RegionName, regionExtent); | ||
750 | |||
750 | SceneCommunicationService sceneGridService = new SceneCommunicationService(); | 751 | SceneCommunicationService sceneGridService = new SceneCommunicationService(); |
751 | 752 | ||
752 | return new Scene( | 753 | return new Scene( |
753 | regionInfo, circuitManager, sceneGridService, | 754 | regionInfo, circuitManager, physicsScene, sceneGridService, |
754 | simDataService, estateDataService, | 755 | simDataService, estateDataService, |
755 | Config, m_version); | 756 | Config, m_version); |
756 | } | 757 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index 69d7e16..d10c9b4 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | |||
@@ -159,7 +159,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
159 | } | 159 | } |
160 | 160 | ||
161 | RegionInfo regInfo = new RegionInfo(); | 161 | RegionInfo regInfo = new RegionInfo(); |
162 | Scene m_MockScene = new Scene(regInfo); | 162 | Scene m_MockScene = new Scene(regInfo, null); |
163 | LocalInventoryService invService = new LocalInventoryService(lib); | 163 | LocalInventoryService invService = new LocalInventoryService(lib); |
164 | m_MockScene.RegisterModuleInterface<IInventoryService>(invService); | 164 | m_MockScene.RegisterModuleInterface<IInventoryService>(invService); |
165 | m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService); | 165 | m_MockScene.RegisterModuleInterface<IAssetService>(m_Scene.AssetService); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index 25ae689..aa5f889 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -85,7 +85,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
85 | r1.ExternalHostName = "127.0.0.1"; | 85 | r1.ExternalHostName = "127.0.0.1"; |
86 | r1.HttpPort = 9001; | 86 | r1.HttpPort = 9001; |
87 | r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | 87 | r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); |
88 | Scene s = new Scene(new RegionInfo()); | 88 | Scene s = new Scene(new RegionInfo(), null); |
89 | s.RegionInfo.RegionID = r1.RegionID; | 89 | s.RegionInfo.RegionID = r1.RegionID; |
90 | m_LocalConnector.AddRegion(s); | 90 | m_LocalConnector.AddRegion(s); |
91 | 91 | ||
@@ -97,7 +97,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
97 | r2.ExternalHostName = "127.0.0.1"; | 97 | r2.ExternalHostName = "127.0.0.1"; |
98 | r2.HttpPort = 9002; | 98 | r2.HttpPort = 9002; |
99 | r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | 99 | r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); |
100 | s = new Scene(new RegionInfo()); | 100 | s = new Scene(new RegionInfo(), null); |
101 | s.RegionInfo.RegionID = r2.RegionID; | 101 | s.RegionInfo.RegionID = r2.RegionID; |
102 | m_LocalConnector.AddRegion(s); | 102 | m_LocalConnector.AddRegion(s); |
103 | 103 | ||
@@ -109,7 +109,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
109 | r3.ExternalHostName = "127.0.0.1"; | 109 | r3.ExternalHostName = "127.0.0.1"; |
110 | r3.HttpPort = 9003; | 110 | r3.HttpPort = 9003; |
111 | r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | 111 | r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); |
112 | s = new Scene(new RegionInfo()); | 112 | s = new Scene(new RegionInfo(), null); |
113 | s.RegionInfo.RegionID = r3.RegionID; | 113 | s.RegionInfo.RegionID = r3.RegionID; |
114 | m_LocalConnector.AddRegion(s); | 114 | m_LocalConnector.AddRegion(s); |
115 | 115 | ||
@@ -121,7 +121,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | |||
121 | r4.ExternalHostName = "127.0.0.1"; | 121 | r4.ExternalHostName = "127.0.0.1"; |
122 | r4.HttpPort = 9004; | 122 | r4.HttpPort = 9004; |
123 | r4.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); | 123 | r4.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); |
124 | s = new Scene(new RegionInfo()); | 124 | s = new Scene(new RegionInfo(), null); |
125 | s.RegionInfo.RegionID = r4.RegionID; | 125 | s.RegionInfo.RegionID = r4.RegionID; |
126 | m_LocalConnector.AddRegion(s); | 126 | m_LocalConnector.AddRegion(s); |
127 | 127 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f87ae47..1639ee4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -103,7 +103,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
103 | /// <summary> | 103 | /// <summary> |
104 | /// If false then physical objects are disabled, though collisions will continue as normal. | 104 | /// If false then physical objects are disabled, though collisions will continue as normal. |
105 | /// </summary> | 105 | /// </summary> |
106 | public bool PhysicsEnabled { get; set; } | 106 | public bool PhysicsEnabled |
107 | { | ||
108 | get | ||
109 | { | ||
110 | return m_physicsEnabled; | ||
111 | } | ||
112 | |||
113 | set | ||
114 | { | ||
115 | m_physicsEnabled = value; | ||
116 | |||
117 | if (PhysicsScene != null) | ||
118 | { | ||
119 | IPhysicsParameters physScene = PhysicsScene as IPhysicsParameters; | ||
120 | |||
121 | if (physScene != null) | ||
122 | physScene.SetPhysicsParameter( | ||
123 | "Active", m_physicsEnabled.ToString(), PhysParameterEntry.APPLY_TO_NONE); | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | |||
128 | private bool m_physicsEnabled; | ||
107 | 129 | ||
108 | /// <summary> | 130 | /// <summary> |
109 | /// If false then scripts are not enabled on the smiulator | 131 | /// If false then scripts are not enabled on the smiulator |
@@ -712,11 +734,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
712 | 734 | ||
713 | #region Constructors | 735 | #region Constructors |
714 | 736 | ||
715 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, | 737 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, PhysicsScene physicsScene, |
716 | SceneCommunicationService sceneGridService, | 738 | SceneCommunicationService sceneGridService, |
717 | ISimulationDataService simDataService, IEstateDataService estateDataService, | 739 | ISimulationDataService simDataService, IEstateDataService estateDataService, |
718 | IConfigSource config, string simulatorVersion) | 740 | IConfigSource config, string simulatorVersion) |
719 | : this(regInfo) | 741 | : this(regInfo, physicsScene) |
720 | { | 742 | { |
721 | m_config = config; | 743 | m_config = config; |
722 | MinFrameTime = 0.089f; | 744 | MinFrameTime = 0.089f; |
@@ -789,21 +811,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
789 | EventManager.OnLandObjectRemoved += | 811 | EventManager.OnLandObjectRemoved += |
790 | new EventManager.LandObjectRemoved(simDataService.RemoveLandObject); | 812 | new EventManager.LandObjectRemoved(simDataService.RemoveLandObject); |
791 | 813 | ||
792 | m_sceneGraph = new SceneGraph(this); | ||
793 | |||
794 | // If the scene graph has an Unrecoverable error, restart this sim. | ||
795 | // Currently the only thing that causes it to happen is two kinds of specific | ||
796 | // Physics based crashes. | ||
797 | // | ||
798 | // Out of memory | ||
799 | // Operating system has killed the plugin | ||
800 | m_sceneGraph.UnRecoverableError | ||
801 | += () => | ||
802 | { | ||
803 | m_log.ErrorFormat("[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name); | ||
804 | RestartNow(); | ||
805 | }; | ||
806 | |||
807 | RegisterDefaultSceneEvents(); | 814 | RegisterDefaultSceneEvents(); |
808 | 815 | ||
809 | // XXX: Don't set the public property since we don't want to activate here. This needs to be handled | 816 | // XXX: Don't set the public property since we don't want to activate here. This needs to be handled |
@@ -1014,8 +1021,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1014 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1021 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1015 | } | 1022 | } |
1016 | 1023 | ||
1017 | public Scene(RegionInfo regInfo) : base(regInfo) | 1024 | public Scene(RegionInfo regInfo, PhysicsScene physicsScene) : base(regInfo) |
1018 | { | 1025 | { |
1026 | m_sceneGraph = new SceneGraph(this); | ||
1027 | m_sceneGraph.PhysicsScene = physicsScene; | ||
1028 | |||
1029 | // If the scene graph has an Unrecoverable error, restart this sim. | ||
1030 | // Currently the only thing that causes it to happen is two kinds of specific | ||
1031 | // Physics based crashes. | ||
1032 | // | ||
1033 | // Out of memory | ||
1034 | // Operating system has killed the plugin | ||
1035 | m_sceneGraph.UnRecoverableError | ||
1036 | += () => | ||
1037 | { | ||
1038 | m_log.ErrorFormat("[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name); | ||
1039 | RestartNow(); | ||
1040 | }; | ||
1041 | |||
1019 | PhysicalPrims = true; | 1042 | PhysicalPrims = true; |
1020 | CollidablePrims = true; | 1043 | CollidablePrims = true; |
1021 | PhysicsEnabled = true; | 1044 | PhysicsEnabled = true; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 8b4df05..867d6ff 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | |||
@@ -54,6 +54,14 @@ public static class BSParam | |||
54 | // =================== | 54 | // =================== |
55 | // From: | 55 | // From: |
56 | 56 | ||
57 | /// <summary> | ||
58 | /// Set whether physics is active or not. | ||
59 | /// </summary> | ||
60 | /// <remarks> | ||
61 | /// Can be enabled and disabled to start and stop physics. | ||
62 | /// </remarks> | ||
63 | public static bool Active { get; private set; } | ||
64 | |||
57 | public static bool UseSeparatePhysicsThread { get; private set; } | 65 | public static bool UseSeparatePhysicsThread { get; private set; } |
58 | public static float PhysicsTimeStep { get; private set; } | 66 | public static float PhysicsTimeStep { get; private set; } |
59 | 67 | ||
@@ -373,6 +381,8 @@ public static class BSParam | |||
373 | // v = value (appropriate type) | 381 | // v = value (appropriate type) |
374 | private static ParameterDefnBase[] ParameterDefinitions = | 382 | private static ParameterDefnBase[] ParameterDefinitions = |
375 | { | 383 | { |
384 | new ParameterDefn<bool>("Active", "If 'true', false then physics is not active", | ||
385 | false ), | ||
376 | new ParameterDefn<bool>("UseSeparatePhysicsThread", "If 'true', the physics engine runs independent from the simulator heartbeat", | 386 | new ParameterDefn<bool>("UseSeparatePhysicsThread", "If 'true', the physics engine runs independent from the simulator heartbeat", |
377 | false ), | 387 | false ), |
378 | new ParameterDefn<float>("PhysicsTimeStep", "If separate thread, seconds to simulate each interval", | 388 | new ParameterDefn<float>("PhysicsTimeStep", "If separate thread, seconds to simulate each interval", |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 17d26a9..e517389 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -821,7 +821,10 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
821 | while (m_initialized) | 821 | while (m_initialized) |
822 | { | 822 | { |
823 | int beginSimulationRealtimeMS = Util.EnvironmentTickCount(); | 823 | int beginSimulationRealtimeMS = Util.EnvironmentTickCount(); |
824 | DoPhysicsStep(BSParam.PhysicsTimeStep); | 824 | |
825 | if (BSParam.Active) | ||
826 | DoPhysicsStep(BSParam.PhysicsTimeStep); | ||
827 | |||
825 | int simulationRealtimeMS = Util.EnvironmentTickCountSubtract(beginSimulationRealtimeMS); | 828 | int simulationRealtimeMS = Util.EnvironmentTickCountSubtract(beginSimulationRealtimeMS); |
826 | int simulationTimeVsRealtimeDifferenceMS = ((int)(BSParam.PhysicsTimeStep*1000f)) - simulationRealtimeMS; | 829 | int simulationTimeVsRealtimeDifferenceMS = ((int)(BSParam.PhysicsTimeStep*1000f)) - simulationRealtimeMS; |
827 | 830 | ||