aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKittoFlora2009-10-27 22:42:55 +0100
committerKittoFlora2009-10-27 22:42:55 +0100
commit1113b3b6ebba3e358326a7be90b338d8c95af688 (patch)
treed923340600e5a2699ceaceeb52fd6c45994f334a
parentllRotLookAt Pt 2 (diff)
parentMerge branch 'master' into vehicles (diff)
downloadopensim-SC_OLD-1113b3b6ebba3e358326a7be90b338d8c95af688.zip
opensim-SC_OLD-1113b3b6ebba3e358326a7be90b338d8c95af688.tar.gz
opensim-SC_OLD-1113b3b6ebba3e358326a7be90b338d8c95af688.tar.bz2
opensim-SC_OLD-1113b3b6ebba3e358326a7be90b338d8c95af688.tar.xz
Merge branch 'vehicles' into tests
Conflicts: OpenSim/Region/Physics/Manager/PhysicsActor.cs OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
-rw-r--r--OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs13
-rw-r--r--OpenSim/Client/Linden/LLStandaloneLoginModule.cs2
-rw-r--r--OpenSim/Client/MXP/MXPModule.cs5
-rw-r--r--OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs5
-rw-r--r--OpenSim/Data/DataPluginFactory.cs15
-rw-r--r--OpenSim/Data/IPresenceData.cs (renamed from OpenSim/ScriptEngine/Shared/IScriptScheduler.cs)32
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs3
-rw-r--r--OpenSim/Data/MySQL/MySQLLegacyRegionData.cs85
-rw-r--r--OpenSim/Framework/ClientManager.cs5
-rw-r--r--OpenSim/Framework/IScene.cs1
-rw-r--r--[-rwxr-xr-x]OpenSim/Framework/MinHeap.cs27
-rw-r--r--OpenSim/Framework/Parallel.cs3
-rw-r--r--OpenSim/Framework/PluginLoader.cs9
-rw-r--r--OpenSim/Framework/PrimitiveBaseShape.cs66
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs8
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs6
-rw-r--r--OpenSim/Framework/Servers/VersionInfo.cs4
-rw-r--r--OpenSim/Framework/Util.cs59
-rw-r--r--OpenSim/Framework/Watchdog.cs183
-rw-r--r--OpenSim/Grid/GridServer/GridServerBase.cs11
-rw-r--r--OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs8
-rw-r--r--OpenSim/Region/Application/OpenSim.cs22
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs10
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs190
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs27
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs107
-rw-r--r--OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs45
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs17
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs36
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs44
-rw-r--r--OpenSim/Region/Framework/Scenes/AnimationSet.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs154
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs160
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs53
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs65
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs318
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs174
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs10
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs7
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs3
-rw-r--r--OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs10
-rw-r--r--OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs42
-rw-r--r--OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs13
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs11
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs54
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs40
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs96
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs257
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs12
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs158
-rw-r--r--OpenSim/Region/Physics/Manager/IMesher.cs7
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs80
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsJoint.cs2
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsScene.cs32
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsSensor.cs7
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsVector.cs28
-rw-r--r--OpenSim/Region/Physics/Manager/ZeroMesher.cs8
-rw-r--r--OpenSim/Region/Physics/Meshing/HelperTypes.cs62
-rw-r--r--OpenSim/Region/Physics/Meshing/Mesh.cs13
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs27
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs113
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs15
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs304
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs67
-rw-r--r--OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs4
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSCharacter.cs55
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPrim.cs53
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSScene.cs52
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs122
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs234
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs51
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs544
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs460
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs428
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs241
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Properties/AssemblyInfo.cs65
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Resources/DotNetEngine.addin.xml13
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs485
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs703
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs28
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs32
-rw-r--r--OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs14
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/Commands_LSL.cs40
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/LSL_BaseClass.cs56
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Commands_OSSL/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/CILCompiler.cs187
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_CS.cs70
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_JS.cs56
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_LSL.cs57
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_VB.cs56
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_YP.cs55
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/LSL/LSL2CS.cs44
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/YP/YP2CS.cs54
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs121
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Events/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/BaseClassFactory.cs240
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/LoadUnloadStructure.cs49
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/Scheduler.cs55
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptLoader.cs216
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptManager.cs203
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptManager_ScriptLoadUnload.cs287
-rw-r--r--OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine.cs196
-rw-r--r--OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine_ScriptLoadUnload.cs95
-rw-r--r--OpenSim/ScriptEngine/Engines/DotNetEngine/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/ScriptEngine/Shared.Script/ICommandProvider.cs39
-rw-r--r--OpenSim/ScriptEngine/Shared.Script/IScript.cs38
-rw-r--r--OpenSim/ScriptEngine/Shared.Script/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/ScriptEngine/Shared.Script/ScriptBase.cs72
-rw-r--r--OpenSim/ScriptEngine/Shared/EventParams.cs82
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptCommandProvider.cs37
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptCompiler.cs40
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptEngine.cs49
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptEngineComponent.cs36
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptEngineRegionComponent.cs34
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptEventProvider.cs38
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptExecutor.cs39
-rw-r--r--OpenSim/ScriptEngine/Shared/IScriptLoader.cs36
-rw-r--r--OpenSim/ScriptEngine/Shared/Properties/AssemblyInfo.cs63
-rw-r--r--OpenSim/ScriptEngine/Shared/RegionInfoStructure.cs120
-rw-r--r--OpenSim/ScriptEngine/Shared/ScriptMetaData.cs95
-rw-r--r--OpenSim/ScriptEngine/Shared/ScriptStructure.cs137
-rw-r--r--OpenSim/Server/ServerMain.cs2
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs (renamed from OpenSim/ScriptEngine/Components/DotNetEngine/Commands_OSSL/Commands_OSSL.cs)25
-rw-r--r--OpenSim/Services/PresenceService/PresenceServiceBase.cs84
-rw-r--r--OpenSim/Tools/pCampBot/PhysicsBot.cs7
-rw-r--r--Prebuild/src/Core/Nodes/ProjectNode.cs4
-rw-r--r--Prebuild/src/Core/Targets/VS2008Target.cs2
-rw-r--r--Prebuild/src/Core/Targets/VS2010Target.cs134
-rw-r--r--Prebuild/src/Core/Targets/VSGenericTarget.cs2
-rw-r--r--Prebuild/src/Core/Targets/VSVersion.cs6
-rw-r--r--README.txt2
-rw-r--r--ThirdParty/SmartThreadPool/SmartThreadPool.cs6
-rw-r--r--bin/OpenMetaverse.dllbin1630208 -> 1642496 bytes
-rw-r--r--bin/OpenMetaverseTypes.dllbin102400 -> 102400 bytes
-rw-r--r--bin/OpenSim.ini.example224
-rwxr-xr-xbin/Prebuild.exebin246272 -> 237568 bytes
-rw-r--r--prebuild.xml320
-rw-r--r--runprebuild2010.bat2
152 files changed, 2575 insertions, 8896 deletions
diff --git a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
index ddc37ed..6c0c74d 100644
--- a/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RegionModulesController/RegionModulesControllerPlugin.cs
@@ -341,14 +341,15 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
341 341
342 // Actually load it 342 // Actually load it
343 INonSharedRegionModule module = null; 343 INonSharedRegionModule module = null;
344 try 344
345 { 345 Type[] ctorParamTypes = new Type[ctorArgs.Length];
346 for (int i = 0; i < ctorParamTypes.Length; i++)
347 ctorParamTypes[i] = ctorArgs[i].GetType();
348
349 if (node.Type.GetConstructor(ctorParamTypes) != null)
346 module = (INonSharedRegionModule)Activator.CreateInstance(node.Type, ctorArgs); 350 module = (INonSharedRegionModule)Activator.CreateInstance(node.Type, ctorArgs);
347 } 351 else
348 catch
349 {
350 module = (INonSharedRegionModule)Activator.CreateInstance(node.Type); 352 module = (INonSharedRegionModule)Activator.CreateInstance(node.Type);
351 }
352 353
353 // Check for replaceable interfaces 354 // Check for replaceable interfaces
354 Type replaceableInterface = module.ReplaceableInterface; 355 Type replaceableInterface = module.ReplaceableInterface;
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
index fb0aaa5..bb9b623 100644
--- a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
+++ b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
@@ -286,7 +286,7 @@ namespace OpenSim.Client.Linden
286 { 286 {
287 foreach (Scene nextScene in m_scenes) 287 foreach (Scene nextScene in m_scenes)
288 { 288 {
289 if (nextScene.RegionInfo.RegionName == regionName) 289 if (nextScene.RegionInfo.RegionName.Equals(regionName, StringComparison.InvariantCultureIgnoreCase))
290 { 290 {
291 scene = nextScene; 291 scene = nextScene;
292 return true; 292 return true;
diff --git a/OpenSim/Client/MXP/MXPModule.cs b/OpenSim/Client/MXP/MXPModule.cs
index 2d28b8c..a6b0396 100644
--- a/OpenSim/Client/MXP/MXPModule.cs
+++ b/OpenSim/Client/MXP/MXPModule.cs
@@ -52,10 +52,10 @@ namespace OpenSim.Client.MXP
52 52
53 private IConfigSource m_config; 53 private IConfigSource m_config;
54 private int m_port = 1253; 54 private int m_port = 1253;
55 private Timer m_ticker;
55 56
56 private readonly Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 57 private readonly Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
57 private readonly Timer m_ticker = new Timer(100); 58 private bool m_shutdown;
58 private bool m_shutdown = false;
59 59
60 public void Initialise(Scene scene, IConfigSource source) 60 public void Initialise(Scene scene, IConfigSource source)
61 { 61 {
@@ -78,6 +78,7 @@ namespace OpenSim.Client.MXP
78 78
79 m_server = new MXPPacketServer(m_port, m_scenes,m_config.Configs["StandAlone"].GetBoolean("accounts_authenticate",true)); 79 m_server = new MXPPacketServer(m_port, m_scenes,m_config.Configs["StandAlone"].GetBoolean("accounts_authenticate",true));
80 80
81 m_ticker = new Timer(100);
81 m_ticker.AutoReset = false; 82 m_ticker.AutoReset = false;
82 m_ticker.Elapsed += ticker_Elapsed; 83 m_ticker.Elapsed += ticker_Elapsed;
83 84
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
index ba9c653..63381a4 100644
--- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
+++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
@@ -85,10 +85,7 @@ namespace OpenSim.Client.MXP.PacketHandler
85 85
86 m_transmitter = new Transmitter(port); 86 m_transmitter = new Transmitter(port);
87 87
88 m_clientThread = new Thread(StartListener); 88 StartListener();
89 m_clientThread.Name = "MXPThread";
90 m_clientThread.IsBackground = true;
91 m_clientThread.Start();
92 } 89 }
93 90
94 public void StartListener() 91 public void StartListener()
diff --git a/OpenSim/Data/DataPluginFactory.cs b/OpenSim/Data/DataPluginFactory.cs
index 718c6b2..841f71e 100644
--- a/OpenSim/Data/DataPluginFactory.cs
+++ b/OpenSim/Data/DataPluginFactory.cs
@@ -119,14 +119,15 @@ namespace OpenSim.Data
119 119
120 PluginLoaderParamFactory<T>(connect, out pluginInitialiser, out extensionPointPath); 120 PluginLoaderParamFactory<T>(connect, out pluginInitialiser, out extensionPointPath);
121 121
122 PluginLoader<T> loader = new PluginLoader<T>(pluginInitialiser); 122 using (PluginLoader<T> loader = new PluginLoader<T>(pluginInitialiser))
123 123 {
124 // loader will try to load all providers (MySQL, MSSQL, etc) 124 // loader will try to load all providers (MySQL, MSSQL, etc)
125 // unless it is constrainted to the correct "Provider" entry in the addin.xml 125 // unless it is constrainted to the correct "Provider" entry in the addin.xml
126 loader.Add(extensionPointPath, new PluginProviderFilter(provider)); 126 loader.Add(extensionPointPath, new PluginProviderFilter(provider));
127 loader.Load(); 127 loader.Load();
128 128
129 return loader.Plugins; 129 return loader.Plugins;
130 }
130 } 131 }
131 132
132 /// <summary> 133 /// <summary>
diff --git a/OpenSim/ScriptEngine/Shared/IScriptScheduler.cs b/OpenSim/Data/IPresenceData.cs
index cf1f1ab..ca661a2 100644
--- a/OpenSim/ScriptEngine/Shared/IScriptScheduler.cs
+++ b/OpenSim/Data/IPresenceData.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -24,18 +24,32 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27
27using System; 28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.Text;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.ScriptEngine.Shared; 31using OpenSim.Framework;
32 32
33namespace OpenSim.ScriptEngine.Shared 33namespace OpenSim.Data
34{ 34{
35 public interface IScriptScheduler : IScriptEngineComponent 35 public class PresenceData
36 {
37 public UUID PrincipalID;
38 public UUID RegionID;
39 public Dictionary<string, object> Data;
40 }
41
42 /// <summary>
43 /// An interface for connecting to the authentication datastore
44 /// </summary>
45 public interface IPresenceData
36 { 46 {
37 void AddScript(ScriptStructure script); 47 bool Store(PresenceData data);
38 void Removecript(uint id, UUID itemID); 48
39 void Close(); 49 PresenceData Get(UUID principalID);
50
51 bool SetDataItem(UUID principalID, string item, string value);
52
53 bool Delete(UUID regionID);
40 } 54 }
41} \ No newline at end of file 55}
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index fc05d1d..4d49733 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -167,9 +167,6 @@ namespace OpenSim.Data.MySQL
167 asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); 167 asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
168 } 168 }
169 } 169 }
170
171 if (asset != null)
172 UpdateAccessTime(asset);
173 } 170 }
174 catch (Exception e) 171 catch (Exception e)
175 { 172 {
diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
index 801d6b9..a807948 100644
--- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs
@@ -66,22 +66,26 @@ namespace OpenSim.Data.MySQL
66 Migration m = new Migration(m_Connection, assem, "RegionStore"); 66 Migration m = new Migration(m_Connection, assem, "RegionStore");
67 m.Update(); 67 m.Update();
68 68
69 // NOTE: This is a very slow query that times out on regions with a lot of prims.
70 // I'm told that it is no longer relevant so it's commented out now, but if it
71 // is relevant it should be added as a console command instead of part of the
72 // startup phase
69 // Clean dropped attachments 73 // Clean dropped attachments
70 // 74 //
71 try 75 //try
72 { 76 //{
73 using (MySqlCommand cmd = m_Connection.CreateCommand()) 77 // using (MySqlCommand cmd = m_Connection.CreateCommand())
74 { 78 // {
75 cmd.CommandText = "delete from prims, primshapes using prims " + 79 // cmd.CommandText = "delete from prims, primshapes using prims " +
76 "left join primshapes on prims.uuid = primshapes.uuid " + 80 // "left join primshapes on prims.uuid = primshapes.uuid " +
77 "where PCode = 9 and State <> 0"; 81 // "where PCode = 9 and State <> 0";
78 ExecuteNonQuery(cmd); 82 // ExecuteNonQuery(cmd);
79 } 83 // }
80 } 84 //}
81 catch (MySqlException ex) 85 //catch (MySqlException ex)
82 { 86 //{
83 m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message); 87 // m_log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message);
84 } 88 //}
85 } 89 }
86 90
87 private IDataReader ExecuteReader(MySqlCommand c) 91 private IDataReader ExecuteReader(MySqlCommand c)
@@ -1430,37 +1434,36 @@ namespace OpenSim.Data.MySQL
1430 { 1434 {
1431 PrimitiveBaseShape s = new PrimitiveBaseShape(); 1435 PrimitiveBaseShape s = new PrimitiveBaseShape();
1432 s.Scale = new Vector3( 1436 s.Scale = new Vector3(
1433 Convert.ToSingle(row["ScaleX"]), 1437 (float)(double)row["ScaleX"],
1434 Convert.ToSingle(row["ScaleY"]), 1438 (float)(double)row["ScaleY"],
1435 Convert.ToSingle(row["ScaleZ"]) 1439 (float)(double)row["ScaleZ"]
1436 ); 1440 );
1437 // paths 1441 // paths
1438 s.PCode = Convert.ToByte(row["PCode"]); 1442 s.PCode = (byte)(int)row["PCode"];
1439 s.PathBegin = Convert.ToUInt16(row["PathBegin"]); 1443 s.PathBegin = (ushort)(int)row["PathBegin"];
1440 s.PathEnd = Convert.ToUInt16(row["PathEnd"]); 1444 s.PathEnd = (ushort)(int)row["PathEnd"];
1441 s.PathScaleX = Convert.ToByte(row["PathScaleX"]); 1445 s.PathScaleX = (byte)(int)row["PathScaleX"];
1442 s.PathScaleY = Convert.ToByte(row["PathScaleY"]); 1446 s.PathScaleY = (byte)(int)row["PathScaleY"];
1443 s.PathShearX = Convert.ToByte(row["PathShearX"]); 1447 s.PathShearX = (byte)(int)row["PathShearX"];
1444 s.PathShearY = Convert.ToByte(row["PathShearY"]); 1448 s.PathShearY = (byte)(int)row["PathShearY"];
1445 s.PathSkew = Convert.ToSByte(row["PathSkew"]); 1449 s.PathSkew = (sbyte)(int)row["PathSkew"];
1446 s.PathCurve = Convert.ToByte(row["PathCurve"]); 1450 s.PathCurve = (byte)(int)row["PathCurve"];
1447 s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]); 1451 s.PathRadiusOffset = (sbyte)(int)row["PathRadiusOffset"];
1448 s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]); 1452 s.PathRevolutions = (byte)(int)row["PathRevolutions"];
1449 s.PathTaperX = Convert.ToSByte(row["PathTaperX"]); 1453 s.PathTaperX = (sbyte)(int)row["PathTaperX"];
1450 s.PathTaperY = Convert.ToSByte(row["PathTaperY"]); 1454 s.PathTaperY = (sbyte)(int)row["PathTaperY"];
1451 s.PathTwist = Convert.ToSByte(row["PathTwist"]); 1455 s.PathTwist = (sbyte)(int)row["PathTwist"];
1452 s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]); 1456 s.PathTwistBegin = (sbyte)(int)row["PathTwistBegin"];
1453 // profile 1457 // profile
1454 s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]); 1458 s.ProfileBegin = (ushort)(int)row["ProfileBegin"];
1455 s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]); 1459 s.ProfileEnd = (ushort)(int)row["ProfileEnd"];
1456 s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]); 1460 s.ProfileCurve = (byte)(int)row["ProfileCurve"];
1457 s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]); 1461 s.ProfileHollow = (ushort)(int)row["ProfileHollow"];
1458 byte[] textureEntry = (byte[]) row["Texture"]; 1462 s.TextureEntry = (byte[])row["Texture"];
1459 s.TextureEntry = textureEntry;
1460 1463
1461 s.ExtraParams = (byte[]) row["ExtraParams"]; 1464 s.ExtraParams = (byte[])row["ExtraParams"];
1462 1465
1463 s.State = Convert.ToByte(row["State"]); 1466 s.State = (byte)(int)row["State"];
1464 1467
1465 return s; 1468 return s;
1466 } 1469 }
diff --git a/OpenSim/Framework/ClientManager.cs b/OpenSim/Framework/ClientManager.cs
index 61b59e7..baff2f4 100644
--- a/OpenSim/Framework/ClientManager.cs
+++ b/OpenSim/Framework/ClientManager.cs
@@ -204,7 +204,10 @@ namespace OpenSim.Framework
204 public void ForEach(Action<IClientAPI> action) 204 public void ForEach(Action<IClientAPI> action)
205 { 205 {
206 IClientAPI[] localArray = m_array; 206 IClientAPI[] localArray = m_array;
207 Parallel.ForEach<IClientAPI>(localArray, action); 207 Parallel.For(0, localArray.Length,
208 delegate(int i)
209 { action(localArray[i]); }
210 );
208 } 211 }
209 212
210 /// <summary> 213 /// <summary>
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs
index f34027d..8067052 100644
--- a/OpenSim/Framework/IScene.cs
+++ b/OpenSim/Framework/IScene.cs
@@ -62,7 +62,6 @@ namespace OpenSim.Framework
62 RegionInfo RegionInfo { get; } 62 RegionInfo RegionInfo { get; }
63 RegionStatus RegionStatus { get; set; } 63 RegionStatus RegionStatus { get; set; }
64 64
65 ClientManager ClientManager { get; }
66 IConfigSource Config { get; } 65 IConfigSource Config { get; }
67 66
68 float TimeDilation { get; } 67 float TimeDilation { get; }
diff --git a/OpenSim/Framework/MinHeap.cs b/OpenSim/Framework/MinHeap.cs
index ad39bbc..33d0364 100755..100644
--- a/OpenSim/Framework/MinHeap.cs
+++ b/OpenSim/Framework/MinHeap.cs
@@ -1,3 +1,30 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
1using System; 28using System;
2using System.Threading; 29using System.Threading;
3using System.Collections; 30using System.Collections;
diff --git a/OpenSim/Framework/Parallel.cs b/OpenSim/Framework/Parallel.cs
index 70eecdc..515852f 100644
--- a/OpenSim/Framework/Parallel.cs
+++ b/OpenSim/Framework/Parallel.cs
@@ -118,6 +118,7 @@ namespace OpenSim.Framework
118 int counter = threadCount; 118 int counter = threadCount;
119 AutoResetEvent threadFinishEvent = new AutoResetEvent(false); 119 AutoResetEvent threadFinishEvent = new AutoResetEvent(false);
120 IEnumerator<T> enumerator = enumerable.GetEnumerator(); 120 IEnumerator<T> enumerator = enumerable.GetEnumerator();
121 object syncRoot = new object();
121 Exception exception = null; 122 Exception exception = null;
122 123
123 for (int i = 0; i < threadCount; i++) 124 for (int i = 0; i < threadCount; i++)
@@ -131,7 +132,7 @@ namespace OpenSim.Framework
131 { 132 {
132 T entry; 133 T entry;
133 134
134 lock (enumerator) 135 lock (syncRoot)
135 { 136 {
136 if (!enumerator.MoveNext()) 137 if (!enumerator.MoveNext())
137 break; 138 break;
diff --git a/OpenSim/Framework/PluginLoader.cs b/OpenSim/Framework/PluginLoader.cs
index 5d38f5f..819cb7b 100644
--- a/OpenSim/Framework/PluginLoader.cs
+++ b/OpenSim/Framework/PluginLoader.cs
@@ -194,10 +194,15 @@ namespace OpenSim.Framework
194 } 194 }
195 } 195 }
196 196
197 /// <summary>
198 /// Unregisters Mono.Addins event handlers, allowing temporary Mono.Addins
199 /// data to be garbage collected. Since the plugins created by this loader
200 /// are meant to outlive the loader itself, they must be disposed separately
201 /// </summary>
197 public void Dispose() 202 public void Dispose()
198 { 203 {
199 foreach (T plugin in Plugins) 204 AddinManager.AddinLoadError -= on_addinloaderror_;
200 plugin.Dispose(); 205 AddinManager.AddinLoaded -= on_addinloaded_;
201 } 206 }
202 207
203 private void initialise_plugin_dir_(string dir) 208 private void initialise_plugin_dir_(string dir)
diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs
index b646f92..5e4d175 100644
--- a/OpenSim/Framework/PrimitiveBaseShape.cs
+++ b/OpenSim/Framework/PrimitiveBaseShape.cs
@@ -76,7 +76,7 @@ namespace OpenSim.Framework
76 { 76 {
77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
78 78
79 private static readonly Primitive.TextureEntry m_defaultTexture; 79 private static readonly byte[] DEFAULT_TEXTURE = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f")).GetBytes();
80 80
81 private byte[] m_textureEntry; 81 private byte[] m_textureEntry;
82 82
@@ -104,33 +104,32 @@ namespace OpenSim.Framework
104 private HollowShape _hollowShape; 104 private HollowShape _hollowShape;
105 105
106 // Sculpted 106 // Sculpted
107 [XmlIgnore] private UUID _sculptTexture = UUID.Zero; 107 [XmlIgnore] private UUID _sculptTexture;
108 [XmlIgnore] private byte _sculptType = (byte)0; 108 [XmlIgnore] private byte _sculptType;
109 [XmlIgnore] private byte[] _sculptData = new byte[0]; 109 [XmlIgnore] private byte[] _sculptData = Utils.EmptyBytes;
110 [XmlIgnore] private Image _sculptBitmap = null;
111 110
112 // Flexi 111 // Flexi
113 [XmlIgnore] private int _flexiSoftness = 0; 112 [XmlIgnore] private int _flexiSoftness;
114 [XmlIgnore] private float _flexiTension = 0f; 113 [XmlIgnore] private float _flexiTension;
115 [XmlIgnore] private float _flexiDrag = 0f; 114 [XmlIgnore] private float _flexiDrag;
116 [XmlIgnore] private float _flexiGravity = 0f; 115 [XmlIgnore] private float _flexiGravity;
117 [XmlIgnore] private float _flexiWind = 0f; 116 [XmlIgnore] private float _flexiWind;
118 [XmlIgnore] private float _flexiForceX = 0f; 117 [XmlIgnore] private float _flexiForceX;
119 [XmlIgnore] private float _flexiForceY = 0f; 118 [XmlIgnore] private float _flexiForceY;
120 [XmlIgnore] private float _flexiForceZ = 0f; 119 [XmlIgnore] private float _flexiForceZ;
121 120
122 //Bright n sparkly 121 //Bright n sparkly
123 [XmlIgnore] private float _lightColorR = 0f; 122 [XmlIgnore] private float _lightColorR;
124 [XmlIgnore] private float _lightColorG = 0f; 123 [XmlIgnore] private float _lightColorG;
125 [XmlIgnore] private float _lightColorB = 0f; 124 [XmlIgnore] private float _lightColorB;
126 [XmlIgnore] private float _lightColorA = 1f; 125 [XmlIgnore] private float _lightColorA = 1.0f;
127 [XmlIgnore] private float _lightRadius = 0f; 126 [XmlIgnore] private float _lightRadius;
128 [XmlIgnore] private float _lightCutoff = 0f; 127 [XmlIgnore] private float _lightCutoff;
129 [XmlIgnore] private float _lightFalloff = 0f; 128 [XmlIgnore] private float _lightFalloff;
130 [XmlIgnore] private float _lightIntensity = 1f; 129 [XmlIgnore] private float _lightIntensity = 1.0f;
131 [XmlIgnore] private bool _flexiEntry = false; 130 [XmlIgnore] private bool _flexiEntry;
132 [XmlIgnore] private bool _lightEntry = false; 131 [XmlIgnore] private bool _lightEntry;
133 [XmlIgnore] private bool _sculptEntry = false; 132 [XmlIgnore] private bool _sculptEntry;
134 133
135 public byte ProfileCurve 134 public byte ProfileCurve
136 { 135 {
@@ -172,17 +171,11 @@ namespace OpenSim.Framework
172 } 171 }
173 } 172 }
174 173
175 static PrimitiveBaseShape()
176 {
177 m_defaultTexture =
178 new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
179 }
180
181 public PrimitiveBaseShape() 174 public PrimitiveBaseShape()
182 { 175 {
183 PCode = (byte) PCodeEnum.Primitive; 176 PCode = (byte) PCodeEnum.Primitive;
184 ExtraParams = new byte[1]; 177 ExtraParams = new byte[1];
185 Textures = m_defaultTexture; 178 m_textureEntry = DEFAULT_TEXTURE;
186 } 179 }
187 180
188 public PrimitiveBaseShape(bool noShape) 181 public PrimitiveBaseShape(bool noShape)
@@ -192,7 +185,7 @@ namespace OpenSim.Framework
192 185
193 PCode = (byte)PCodeEnum.Primitive; 186 PCode = (byte)PCodeEnum.Primitive;
194 ExtraParams = new byte[1]; 187 ExtraParams = new byte[1];
195 Textures = m_defaultTexture; 188 m_textureEntry = DEFAULT_TEXTURE;
196 } 189 }
197 190
198 [XmlIgnore] 191 [XmlIgnore]
@@ -577,15 +570,6 @@ namespace OpenSim.Framework
577 } 570 }
578 } 571 }
579 572
580 public Image SculptBitmap {
581 get {
582 return _sculptBitmap;
583 }
584 set {
585 _sculptBitmap = value;
586 }
587 }
588
589 public int FlexiSoftness { 573 public int FlexiSoftness {
590 get { 574 get {
591 return _flexiSoftness; 575 return _flexiSoftness;
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 85d7be2..bec5ed3 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -1559,15 +1559,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1559 public void Start() 1559 public void Start()
1560 { 1560 {
1561 m_log.Info("[HTTPD]: Starting up HTTP Server"); 1561 m_log.Info("[HTTPD]: Starting up HTTP Server");
1562
1563 //m_workerThread = new Thread(new ThreadStart(StartHTTP));
1564 //m_workerThread.Name = "HttpThread";
1565 //m_workerThread.IsBackground = true;
1566 //m_workerThread.Start();
1567 //ThreadTracker.Add(m_workerThread);
1568 StartHTTP(); 1562 StartHTTP();
1569
1570
1571 } 1563 }
1572 1564
1573 private void StartHTTP() 1565 private void StartHTTP()
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index 1c54581..e7a64f7 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -50,9 +50,7 @@ namespace OpenSim.Framework.Servers.HttpServer
50 m_WorkerThreadCount = pWorkerThreadCount; 50 m_WorkerThreadCount = pWorkerThreadCount;
51 m_workerThreads = new Thread[m_WorkerThreadCount]; 51 m_workerThreads = new Thread[m_WorkerThreadCount];
52 m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount]; 52 m_PollServiceWorkerThreads = new PollServiceWorkerThread[m_WorkerThreadCount];
53 m_watcherThread = new Thread(ThreadStart);
54 53
55
56 //startup worker threads 54 //startup worker threads
57 for (uint i=0;i<m_WorkerThreadCount;i++) 55 for (uint i=0;i<m_WorkerThreadCount;i++)
58 { 56 {
@@ -65,11 +63,11 @@ namespace OpenSim.Framework.Servers.HttpServer
65 m_workerThreads[i].Start(); 63 m_workerThreads[i].Start();
66 64
67 } 65 }
66
68 //start watcher threads 67 //start watcher threads
68 m_watcherThread = new Thread(ThreadStart);
69 m_watcherThread.Name = "PollServiceWatcherThread"; 69 m_watcherThread.Name = "PollServiceWatcherThread";
70 m_watcherThread.Start(); 70 m_watcherThread.Start();
71
72
73 } 71 }
74 72
75 internal void ReQueueEvent(PollServiceHttpRequest req) 73 internal void ReQueueEvent(PollServiceHttpRequest req)
diff --git a/OpenSim/Framework/Servers/VersionInfo.cs b/OpenSim/Framework/Servers/VersionInfo.cs
index 62e7e92..9f98310 100644
--- a/OpenSim/Framework/Servers/VersionInfo.cs
+++ b/OpenSim/Framework/Servers/VersionInfo.cs
@@ -29,8 +29,8 @@ namespace OpenSim
29{ 29{
30 public class VersionInfo 30 public class VersionInfo
31 { 31 {
32 private const string VERSION_NUMBER = "0.6.7"; 32 private const string VERSION_NUMBER = "0.6.8";
33 private const Flavour VERSION_FLAVOUR = Flavour.RC1; 33 private const Flavour VERSION_FLAVOUR = Flavour.Dev;
34 34
35 public enum Flavour 35 public enum Flavour
36 { 36 {
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index d09bd6d..87ba5a8 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -69,8 +69,6 @@ namespace OpenSim.Framework
69 /// </summary> 69 /// </summary>
70 public class Util 70 public class Util
71 { 71 {
72 private static SmartThreadPool m_ThreadPool = null;
73
74 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 72 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
75 73
76 private static uint nextXferID = 5000; 74 private static uint nextXferID = 5000;
@@ -79,6 +77,9 @@ namespace OpenSim.Framework
79 private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]"; 77 private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]";
80 private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]"; 78 private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]";
81 private static object XferLock = new object(); 79 private static object XferLock = new object();
80 /// <summary>Thread pool used for Util.FireAndForget if
81 /// FireAndForgetMethod.SmartThreadPool is used</summary>
82 private static SmartThreadPool m_ThreadPool;
82 83
83 // Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC. 84 // Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC.
84 private static readonly DateTime unixEpoch = 85 private static readonly DateTime unixEpoch =
@@ -1319,21 +1320,35 @@ namespace OpenSim.Framework
1319 FireAndForget(callback, null); 1320 FireAndForget(callback, null);
1320 } 1321 }
1321 1322
1322 public static void SetMaxThreads(int maxThreads) 1323 public static void InitThreadPool(int maxThreads)
1323 { 1324 {
1325 if (maxThreads < 2)
1326 throw new ArgumentOutOfRangeException("maxThreads", "maxThreads must be greater than 2");
1324 if (m_ThreadPool != null) 1327 if (m_ThreadPool != null)
1325 return; 1328 throw new InvalidOperationException("SmartThreadPool is already initialized");
1326 1329
1327 STPStartInfo startInfo = new STPStartInfo(); 1330 m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2);
1328 startInfo.IdleTimeout = 2000; // 2 seconds 1331 }
1329 startInfo.MaxWorkerThreads = maxThreads;
1330 startInfo.MinWorkerThreads = 2;
1331 startInfo.StackSize = 524288;
1332 startInfo.ThreadPriority = ThreadPriority.Normal;
1333 1332
1334 startInfo.StartSuspended = false; 1333 public static int FireAndForgetCount()
1334 {
1335 const int MAX_SYSTEM_THREADS = 200;
1335 1336
1336 m_ThreadPool = new SmartThreadPool(startInfo); 1337 switch (FireAndForgetMethod)
1338 {
1339 case FireAndForgetMethod.UnsafeQueueUserWorkItem:
1340 case FireAndForgetMethod.QueueUserWorkItem:
1341 case FireAndForgetMethod.BeginInvoke:
1342 int workerThreads, iocpThreads;
1343 ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads);
1344 return workerThreads;
1345 case FireAndForgetMethod.SmartThreadPool:
1346 return m_ThreadPool.MaxThreads - m_ThreadPool.InUseThreads;
1347 case FireAndForgetMethod.Thread:
1348 return MAX_SYSTEM_THREADS - System.Diagnostics.Process.GetCurrentProcess().Threads.Count;
1349 default:
1350 throw new NotImplementedException();
1351 }
1337 } 1352 }
1338 1353
1339 public static void FireAndForget(System.Threading.WaitCallback callback, object obj) 1354 public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
@@ -1341,20 +1356,22 @@ namespace OpenSim.Framework
1341 switch (FireAndForgetMethod) 1356 switch (FireAndForgetMethod)
1342 { 1357 {
1343 case FireAndForgetMethod.UnsafeQueueUserWorkItem: 1358 case FireAndForgetMethod.UnsafeQueueUserWorkItem:
1344 System.Threading.ThreadPool.UnsafeQueueUserWorkItem(callback, obj); 1359 ThreadPool.UnsafeQueueUserWorkItem(callback, obj);
1345 break; 1360 break;
1346 case FireAndForgetMethod.QueueUserWorkItem: 1361 case FireAndForgetMethod.QueueUserWorkItem:
1347 System.Threading.ThreadPool.QueueUserWorkItem(callback, obj); 1362 ThreadPool.QueueUserWorkItem(callback, obj);
1348 break; 1363 break;
1349 case FireAndForgetMethod.BeginInvoke: 1364 case FireAndForgetMethod.BeginInvoke:
1350 FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>(); 1365 FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>();
1351 wrapper.FireAndForget(callback, obj); 1366 wrapper.FireAndForget(callback, obj);
1352 break; 1367 break;
1353 case FireAndForgetMethod.SmartThreadPool: 1368 case FireAndForgetMethod.SmartThreadPool:
1354 m_ThreadPool.QueueWorkItem(delegate(object o) { callback(o); return null; }, obj); 1369 if (m_ThreadPool == null)
1370 m_ThreadPool = new SmartThreadPool(2000, 15, 2);
1371 m_ThreadPool.QueueWorkItem(SmartThreadPoolCallback, new object[] { callback, obj });
1355 break; 1372 break;
1356 case FireAndForgetMethod.Thread: 1373 case FireAndForgetMethod.Thread:
1357 System.Threading.Thread thread = new System.Threading.Thread(delegate(object o) { callback(o); }); 1374 Thread thread = new Thread(delegate(object o) { callback(o); });
1358 thread.Start(obj); 1375 thread.Start(obj);
1359 break; 1376 break;
1360 default: 1377 default:
@@ -1362,6 +1379,16 @@ namespace OpenSim.Framework
1362 } 1379 }
1363 } 1380 }
1364 1381
1382 private static object SmartThreadPoolCallback(object o)
1383 {
1384 object[] array = (object[])o;
1385 WaitCallback callback = (WaitCallback)array[0];
1386 object obj = array[1];
1387
1388 callback(obj);
1389 return null;
1390 }
1391
1365 #endregion FireAndForget Threading Pattern 1392 #endregion FireAndForget Threading Pattern
1366 } 1393 }
1367} 1394}
diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs
new file mode 100644
index 0000000..5d46905
--- /dev/null
+++ b/OpenSim/Framework/Watchdog.cs
@@ -0,0 +1,183 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Threading;
31using log4net;
32
33namespace OpenSim.Framework
34{
35 /// <summary>
36 /// Manages launching threads and keeping watch over them for timeouts
37 /// </summary>
38 public static class Watchdog
39 {
40 /// <summary>Timer interval in milliseconds for the watchdog timer</summary>
41 const double WATCHDOG_INTERVAL_MS = 2500.0d;
42 /// <summary>Maximum timeout in milliseconds before a thread is considered dead</summary>
43 const int WATCHDOG_TIMEOUT_MS = 5000;
44
45 [System.Diagnostics.DebuggerDisplay("{Thread.Name}")]
46 private class ThreadWatchdogInfo
47 {
48 public Thread Thread;
49 public int LastTick;
50
51 public ThreadWatchdogInfo(Thread thread)
52 {
53 Thread = thread;
54 LastTick = Environment.TickCount & Int32.MaxValue;
55 }
56 }
57
58 /// <summary>
59 /// This event is called whenever a tracked thread is stopped or
60 /// has not called UpdateThread() in time
61 /// </summary>
62 /// <param name="thread">The thread that has been identified as dead</param>
63 /// <param name="lastTick">The last time this thread called UpdateThread()</param>
64 public delegate void WatchdogTimeout(Thread thread, int lastTick);
65
66 /// <summary>This event is called whenever a tracked thread is
67 /// stopped or has not called UpdateThread() in time</summary>
68 public static event WatchdogTimeout OnWatchdogTimeout;
69
70 private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
71 private static Dictionary<int, ThreadWatchdogInfo> m_threads;
72 private static System.Timers.Timer m_watchdogTimer;
73
74 static Watchdog()
75 {
76 m_threads = new Dictionary<int, ThreadWatchdogInfo>();
77 m_watchdogTimer = new System.Timers.Timer(WATCHDOG_INTERVAL_MS);
78 m_watchdogTimer.AutoReset = false;
79 m_watchdogTimer.Elapsed += WatchdogTimerElapsed;
80 m_watchdogTimer.Start();
81 }
82
83 /// <summary>
84 /// Start a new thread that is tracked by the watchdog timer
85 /// </summary>
86 /// <param name="start">The method that will be executed in a new thread</param>
87 /// <param name="name">A name to give to the new thread</param>
88 /// <param name="priority">Priority to run the thread at</param>
89 /// <param name="isBackground">True to run this thread as a background
90 /// thread, otherwise false</param>
91 /// <returns>The newly created Thread object</returns>
92 public static Thread StartThread(ThreadStart start, string name, ThreadPriority priority, bool isBackground)
93 {
94 Thread thread = new Thread(start);
95 thread.Name = name;
96 thread.Priority = priority;
97 thread.IsBackground = isBackground;
98 thread.Start();
99
100 return thread;
101 }
102
103 /// <summary>
104 /// Marks the current thread as alive
105 /// </summary>
106 public static void UpdateThread()
107 {
108 UpdateThread(Thread.CurrentThread.ManagedThreadId);
109 }
110
111 /// <summary>
112 /// Stops watchdog tracking on the current thread
113 /// </summary>
114 /// <returns>True if the thread was removed from the list of tracked
115 /// threads, otherwise false</returns>
116 public static bool RemoveThread()
117 {
118 return RemoveThread(Thread.CurrentThread.ManagedThreadId);
119 }
120
121 private static void AddThread(ThreadWatchdogInfo threadInfo)
122 {
123 m_log.Debug("[WATCHDOG]: Started tracking thread \"" + threadInfo.Thread.Name + "\" (ID " + threadInfo.Thread.ManagedThreadId + ")");
124
125 lock (m_threads)
126 m_threads.Add(threadInfo.Thread.ManagedThreadId, threadInfo);
127 }
128
129 private static bool RemoveThread(int threadID)
130 {
131 lock (m_threads)
132 return m_threads.Remove(threadID);
133 }
134
135 private static void UpdateThread(int threadID)
136 {
137 ThreadWatchdogInfo threadInfo;
138
139 // Although TryGetValue is not a thread safe operation, we use a try/catch here instead
140 // of a lock for speed. Adding/removing threads is a very rare operation compared to
141 // UpdateThread(), and a single UpdateThread() failure here and there won't break
142 // anything
143 try
144 {
145 if (m_threads.TryGetValue(threadID, out threadInfo))
146 threadInfo.LastTick = Environment.TickCount & Int32.MaxValue;
147 else
148 AddThread(new ThreadWatchdogInfo(Thread.CurrentThread));
149 }
150 catch { }
151 }
152
153 private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
154 {
155 WatchdogTimeout callback = OnWatchdogTimeout;
156
157 if (callback != null)
158 {
159 ThreadWatchdogInfo timedOut = null;
160
161 lock (m_threads)
162 {
163 int now = Environment.TickCount & Int32.MaxValue;
164
165 foreach (ThreadWatchdogInfo threadInfo in m_threads.Values)
166 {
167 if (threadInfo.Thread.ThreadState == ThreadState.Stopped || now - threadInfo.LastTick >= WATCHDOG_TIMEOUT_MS)
168 {
169 timedOut = threadInfo;
170 m_threads.Remove(threadInfo.Thread.ManagedThreadId);
171 break;
172 }
173 }
174 }
175
176 if (timedOut != null)
177 callback(timedOut.Thread, timedOut.LastTick);
178 }
179
180 m_watchdogTimer.Start();
181 }
182 }
183}
diff --git a/OpenSim/Grid/GridServer/GridServerBase.cs b/OpenSim/Grid/GridServer/GridServerBase.cs
index d63ac2e..9b0d7ea 100644
--- a/OpenSim/Grid/GridServer/GridServerBase.cs
+++ b/OpenSim/Grid/GridServer/GridServerBase.cs
@@ -29,7 +29,6 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Timers;
33using log4net; 32using log4net;
34using Nini.Config; 33using Nini.Config;
35using OpenSim.Framework; 34using OpenSim.Framework;
@@ -115,11 +114,11 @@ namespace OpenSim.Grid.GridServer
115 114
116 protected virtual void LoadPlugins() 115 protected virtual void LoadPlugins()
117 { 116 {
118 PluginLoader<IGridPlugin> loader = 117 using (PluginLoader<IGridPlugin> loader = new PluginLoader<IGridPlugin>(new GridPluginInitialiser(this)))
119 new PluginLoader<IGridPlugin>(new GridPluginInitialiser(this)); 118 {
120 119 loader.Load("/OpenSim/GridServer");
121 loader.Load("/OpenSim/GridServer"); 120 m_plugins = loader.Plugins;
122 m_plugins = loader.Plugins; 121 }
123 } 122 }
124 123
125 public override void ShutdownSpecific() 124 public override void ShutdownSpecific()
diff --git a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs b/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
index 8ce353c..f24cef6 100644
--- a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
+++ b/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
@@ -78,8 +78,6 @@ namespace OpenSim.Grid.UserServer.Modules
78 private OpenSim.Framework.BlockingQueue<PresenceNotification> m_NotifyQueue = 78 private OpenSim.Framework.BlockingQueue<PresenceNotification> m_NotifyQueue =
79 new OpenSim.Framework.BlockingQueue<PresenceNotification>(); 79 new OpenSim.Framework.BlockingQueue<PresenceNotification>();
80 80
81 Thread m_NotifyThread;
82
83 private IGridServiceCore m_core; 81 private IGridServiceCore m_core;
84 82
85 public event AgentLocationDelegate OnAgentLocation; 83 public event AgentLocationDelegate OnAgentLocation;
@@ -96,8 +94,8 @@ namespace OpenSim.Grid.UserServer.Modules
96 { 94 {
97 m_core = core; 95 m_core = core;
98 m_core.RegisterInterface<MessageServersConnector>(this); 96 m_core.RegisterInterface<MessageServersConnector>(this);
99 m_NotifyThread = new Thread(new ThreadStart(NotifyQueueRunner)); 97
100 m_NotifyThread.Start(); 98 Watchdog.StartThread(NotifyQueueRunner, "NotifyQueueRunner", ThreadPriority.Normal, true);
101 } 99 }
102 100
103 public void PostInitialise() 101 public void PostInitialise()
@@ -427,6 +425,8 @@ namespace OpenSim.Grid.UserServer.Modules
427 { 425 {
428 TellMessageServersAboutUserLogoffInternal(presence.agentID); 426 TellMessageServersAboutUserLogoffInternal(presence.agentID);
429 } 427 }
428
429 Watchdog.UpdateThread();
430 } 430 }
431 } 431 }
432 432
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index c04b8c2..b448182 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -67,7 +67,7 @@ namespace OpenSim
67 67
68 IConfig startupConfig = m_config.Source.Configs["Startup"]; 68 IConfig startupConfig = m_config.Source.Configs["Startup"];
69 69
70 Util.SetMaxThreads(startupConfig.GetInt("MaxPoolThreads", 15)); 70 int stpMaxThreads = 15;
71 71
72 if (startupConfig != null) 72 if (startupConfig != null)
73 { 73 {
@@ -100,8 +100,13 @@ namespace OpenSim
100 FireAndForgetMethod asyncCallMethod; 100 FireAndForgetMethod asyncCallMethod;
101 if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod)) 101 if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod))
102 Util.FireAndForgetMethod = asyncCallMethod; 102 Util.FireAndForgetMethod = asyncCallMethod;
103
104 stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 15);
103 } 105 }
104 106
107 if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
108 Util.InitThreadPool(stpMaxThreads);
109
105 m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod); 110 m_log.Info("[OPENSIM MAIN]: Using async_call_method " + Util.FireAndForgetMethod);
106 } 111 }
107 112
@@ -167,6 +172,9 @@ namespace OpenSim
167 m_scriptTimer.Elapsed += RunAutoTimerScript; 172 m_scriptTimer.Elapsed += RunAutoTimerScript;
168 } 173 }
169 174
175 // Hook up to the watchdog timer
176 Watchdog.OnWatchdogTimeout += WatchdogTimeoutHandler;
177
170 PrintFileToConsole("startuplogo.txt"); 178 PrintFileToConsole("startuplogo.txt");
171 179
172 // For now, start at the 'root' level by default 180 // For now, start at the 'root' level by default
@@ -379,6 +387,14 @@ namespace OpenSim
379 } 387 }
380 } 388 }
381 389
390 private void WatchdogTimeoutHandler(System.Threading.Thread thread, int lastTick)
391 {
392 int now = Environment.TickCount & Int32.MaxValue;
393
394 m_log.ErrorFormat("[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago",
395 thread.Name, thread.ThreadState, now - lastTick);
396 }
397
382 #region Console Commands 398 #region Console Commands
383 399
384 /// <summary> 400 /// <summary>
@@ -954,12 +970,12 @@ namespace OpenSim
954 m_sceneManager.ForEachScene( 970 m_sceneManager.ForEachScene(
955 delegate(Scene scene) 971 delegate(Scene scene)
956 { 972 {
957 scene.ClientManager.ForEachSync( 973 scene.ForEachClient(
958 delegate(IClientAPI client) 974 delegate(IClientAPI client)
959 { 975 {
960 connections.AppendFormat("{0}: {1} ({2}) from {3} on circuit {4}\n", 976 connections.AppendFormat("{0}: {1} ({2}) from {3} on circuit {4}\n",
961 scene.RegionInfo.RegionName, client.Name, client.AgentId, client.RemoteEndPoint, client.CircuitCode); 977 scene.RegionInfo.RegionName, client.Name, client.AgentId, client.RemoteEndPoint, client.CircuitCode);
962 } 978 }, false
963 ); 979 );
964 } 980 }
965 ); 981 );
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 3df3a1c..cc18f1a 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -162,11 +162,11 @@ namespace OpenSim
162 162
163 protected virtual void LoadPlugins() 163 protected virtual void LoadPlugins()
164 { 164 {
165 PluginLoader<IApplicationPlugin> loader = 165 using (PluginLoader<IApplicationPlugin> loader = new PluginLoader<IApplicationPlugin>(new ApplicationPluginInitialiser(this)))
166 new PluginLoader<IApplicationPlugin>(new ApplicationPluginInitialiser(this)); 166 {
167 167 loader.Load("/OpenSim/Startup");
168 loader.Load("/OpenSim/Startup"); 168 m_plugins = loader.Plugins;
169 m_plugins = loader.Plugins; 169 }
170 } 170 }
171 171
172 protected override List<string> GetHelpTopics() 172 protected override List<string> GetHelpTopics()
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 0ba76ec..f6a7a0c 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -346,15 +346,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
346 protected int m_terrainCheckerCount; 346 protected int m_terrainCheckerCount;
347 protected uint m_agentFOVCounter; 347 protected uint m_agentFOVCounter;
348 348
349 // These numbers are guesses at a decent tradeoff between responsiveness
350 // of the interest list and throughput. Lower is more responsive, higher
351 // is better throughput
352 protected int m_primTerseUpdatesPerPacket = 25;
353 protected int m_primFullUpdatesPerPacket = 100;
354 protected int m_avatarTerseUpdatesPerPacket = 10;
355 /// <summary>Number of texture packets to put on the queue each time the
356 /// OnQueueEmpty event is triggered for the texture category</summary>
357 protected int m_textureSendLimit = 20;
358 protected IAssetService m_assetService; 349 protected IAssetService m_assetService;
359 private IHyperAssetService m_hyperAssets; 350 private IHyperAssetService m_hyperAssets;
360 351
@@ -827,7 +818,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
827 for (int i = x1; i <= x2; i++) 818 for (int i = x1; i <= x2; i++)
828 SendLayerData(i, y1, map); 819 SendLayerData(i, y1, map);
829 820
830 // Column 821 // Column
831 for (int j = y1 + 1; j <= y2; j++) 822 for (int j = y1 + 1; j <= y2; j++)
832 SendLayerData(x2, j, map); 823 SendLayerData(x2, j, map);
833 824
@@ -2114,12 +2105,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2114 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks) 2105 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
2115 { 2106 {
2116 ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect); 2107 ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
2117 packet.Effect = effectBlocks; 2108 packet.Header.Reliable = false;
2109 packet.Header.Zerocoded = true;
2118 2110
2119 packet.AgentData.AgentID = AgentId; 2111 packet.AgentData.AgentID = AgentId;
2120 packet.AgentData.SessionID = SessionId; 2112 packet.AgentData.SessionID = SessionId;
2121 packet.Header.Reliable = false; 2113
2122 packet.Header.Zerocoded = true; 2114 packet.Effect = effectBlocks;
2115
2123 OutPacket(packet, ThrottleOutPacketType.State); 2116 OutPacket(packet, ThrottleOutPacketType.State);
2124 } 2117 }
2125 2118
@@ -3333,7 +3326,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3333 3326
3334 lock (m_avatarTerseUpdates.SyncRoot) 3327 lock (m_avatarTerseUpdates.SyncRoot)
3335 { 3328 {
3336 int count = Math.Min(m_avatarTerseUpdates.Count, m_avatarTerseUpdatesPerPacket); 3329 int count = Math.Min(m_avatarTerseUpdates.Count, m_udpServer.AvatarTerseUpdatesPerPacket);
3337 if (count == 0) 3330 if (count == 0)
3338 return; 3331 return;
3339 3332
@@ -3418,7 +3411,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3418 3411
3419 lock (m_primFullUpdates.SyncRoot) 3412 lock (m_primFullUpdates.SyncRoot)
3420 { 3413 {
3421 int count = Math.Min(m_primFullUpdates.Count, m_primFullUpdatesPerPacket); 3414 int count = Math.Min(m_primFullUpdates.Count, m_udpServer.PrimFullUpdatesPerPacket);
3422 if (count == 0) 3415 if (count == 0)
3423 return; 3416 return;
3424 3417
@@ -3462,7 +3455,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3462 3455
3463 lock (m_primTerseUpdates.SyncRoot) 3456 lock (m_primTerseUpdates.SyncRoot)
3464 { 3457 {
3465 int count = Math.Min(m_primTerseUpdates.Count, m_primTerseUpdatesPerPacket); 3458 int count = Math.Min(m_primTerseUpdates.Count, m_udpServer.PrimTerseUpdatesPerPacket);
3466 if (count == 0) 3459 if (count == 0)
3467 return; 3460 return;
3468 3461
@@ -3585,7 +3578,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3585 void ProcessTextureRequests() 3578 void ProcessTextureRequests()
3586 { 3579 {
3587 if (m_imageManager != null) 3580 if (m_imageManager != null)
3588 m_imageManager.ProcessImageQueue(m_textureSendLimit); 3581 m_imageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
3589 } 3582 }
3590 3583
3591 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) 3584 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
@@ -4167,6 +4160,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4167 4160
4168 pack.Data = dataBlock; 4161 pack.Data = dataBlock;
4169 } 4162 }
4163 else
4164 {
4165 pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
4166 }
4170 pack.Header.Zerocoded = true; 4167 pack.Header.Zerocoded = true;
4171 this.OutPacket(pack, ThrottleOutPacketType.Task); 4168 this.OutPacket(pack, ThrottleOutPacketType.Task);
4172 } 4169 }
@@ -4434,6 +4431,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4434 protected virtual void RegisterLocalPacketHandlers() 4431 protected virtual void RegisterLocalPacketHandlers()
4435 { 4432 {
4436 AddLocalPacketHandler(PacketType.LogoutRequest, Logout); 4433 AddLocalPacketHandler(PacketType.LogoutRequest, Logout);
4434 AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate);
4437 AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect); 4435 AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect);
4438 AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached); 4436 AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached);
4439 AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate); 4437 AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate);
@@ -4446,6 +4444,75 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4446 4444
4447 #region Packet Handlers 4445 #region Packet Handlers
4448 4446
4447 private bool HandleAgentUpdate(IClientAPI sener, Packet Pack)
4448 {
4449 if (OnAgentUpdate != null)
4450 {
4451 bool update = false;
4452 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
4453
4454 #region Packet Session and User Check
4455 if (agenUpdate.AgentData.SessionID != SessionId || agenUpdate.AgentData.AgentID != AgentId)
4456 return false;
4457 #endregion
4458
4459 AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData;
4460
4461 // We can only check when we have something to check
4462 // against.
4463
4464 if (lastarg != null)
4465 {
4466 update =
4467 (
4468 (x.BodyRotation != lastarg.BodyRotation) ||
4469 (x.CameraAtAxis != lastarg.CameraAtAxis) ||
4470 (x.CameraCenter != lastarg.CameraCenter) ||
4471 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
4472 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
4473 (x.ControlFlags != lastarg.ControlFlags) ||
4474 (x.Far != lastarg.Far) ||
4475 (x.Flags != lastarg.Flags) ||
4476 (x.State != lastarg.State) ||
4477 (x.HeadRotation != lastarg.HeadRotation) ||
4478 (x.SessionID != lastarg.SessionID) ||
4479 (x.AgentID != lastarg.AgentID)
4480 );
4481 }
4482 else
4483 update = true;
4484
4485 // These should be ordered from most-likely to
4486 // least likely to change. I've made an initial
4487 // guess at that.
4488
4489 if (update)
4490 {
4491 AgentUpdateArgs arg = new AgentUpdateArgs();
4492 arg.AgentID = x.AgentID;
4493 arg.BodyRotation = x.BodyRotation;
4494 arg.CameraAtAxis = x.CameraAtAxis;
4495 arg.CameraCenter = x.CameraCenter;
4496 arg.CameraLeftAxis = x.CameraLeftAxis;
4497 arg.CameraUpAxis = x.CameraUpAxis;
4498 arg.ControlFlags = x.ControlFlags;
4499 arg.Far = x.Far;
4500 arg.Flags = x.Flags;
4501 arg.HeadRotation = x.HeadRotation;
4502 arg.SessionID = x.SessionID;
4503 arg.State = x.State;
4504 UpdateAgent handlerAgentUpdate = OnAgentUpdate;
4505 lastarg = arg; // save this set of arguments for nexttime
4506 if (handlerAgentUpdate != null)
4507 OnAgentUpdate(this, arg);
4508
4509 handlerAgentUpdate = null;
4510 }
4511 }
4512
4513 return true;
4514 }
4515
4449 private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack) 4516 private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
4450 { 4517 {
4451 MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack; 4518 MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
@@ -5631,77 +5698,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5631 5698
5632 break; 5699 break;
5633 5700
5634 case PacketType.AgentUpdate:
5635 if (OnAgentUpdate != null)
5636 {
5637 bool update = false;
5638 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
5639
5640 #region Packet Session and User Check
5641 if (m_checkPackets)
5642 {
5643 if (agenUpdate.AgentData.SessionID != SessionId ||
5644 agenUpdate.AgentData.AgentID != AgentId)
5645 break;
5646 }
5647 #endregion
5648
5649 AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData;
5650
5651 // We can only check when we have something to check
5652 // against.
5653
5654 if (lastarg != null)
5655 {
5656 update =
5657 (
5658 (x.BodyRotation != lastarg.BodyRotation) ||
5659 (x.CameraAtAxis != lastarg.CameraAtAxis) ||
5660 (x.CameraCenter != lastarg.CameraCenter) ||
5661 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
5662 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
5663 (x.ControlFlags != lastarg.ControlFlags) ||
5664 (x.Far != lastarg.Far) ||
5665 (x.Flags != lastarg.Flags) ||
5666 (x.State != lastarg.State) ||
5667 (x.HeadRotation != lastarg.HeadRotation) ||
5668 (x.SessionID != lastarg.SessionID) ||
5669 (x.AgentID != lastarg.AgentID)
5670 );
5671 }
5672 else
5673 update = true;
5674
5675 // These should be ordered from most-likely to
5676 // least likely to change. I've made an initial
5677 // guess at that.
5678
5679 if (update)
5680 {
5681 AgentUpdateArgs arg = new AgentUpdateArgs();
5682 arg.AgentID = x.AgentID;
5683 arg.BodyRotation = x.BodyRotation;
5684 arg.CameraAtAxis = x.CameraAtAxis;
5685 arg.CameraCenter = x.CameraCenter;
5686 arg.CameraLeftAxis = x.CameraLeftAxis;
5687 arg.CameraUpAxis = x.CameraUpAxis;
5688 arg.ControlFlags = x.ControlFlags;
5689 arg.Far = x.Far;
5690 arg.Flags = x.Flags;
5691 arg.HeadRotation = x.HeadRotation;
5692 arg.SessionID = x.SessionID;
5693 arg.State = x.State;
5694 UpdateAgent handlerAgentUpdate = OnAgentUpdate;
5695 lastarg = arg; // save this set of arguments for nexttime
5696 if (handlerAgentUpdate != null)
5697 OnAgentUpdate(this, arg);
5698
5699 handlerAgentUpdate = null;
5700 }
5701
5702 }
5703 break;
5704
5705 case PacketType.AgentAnimation: 5701 case PacketType.AgentAnimation:
5706 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; 5702 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
5707 5703
@@ -6762,11 +6758,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6762 if (OnRequestTexture != null) 6758 if (OnRequestTexture != null)
6763 { 6759 {
6764 TextureRequestArgs args = new TextureRequestArgs(); 6760 TextureRequestArgs args = new TextureRequestArgs();
6765 args.RequestedAssetID = imageRequest.RequestImage[i].Image; 6761
6766 args.DiscardLevel = imageRequest.RequestImage[i].DiscardLevel; 6762 RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
6767 args.PacketNumber = imageRequest.RequestImage[i].Packet; 6763
6768 args.Priority = imageRequest.RequestImage[i].DownloadPriority; 6764 args.RequestedAssetID = block.Image;
6765 args.DiscardLevel = block.DiscardLevel;
6766 args.PacketNumber = block.Packet;
6767 args.Priority = block.DownloadPriority;
6769 args.requestSequence = imageRequest.Header.Sequence; 6768 args.requestSequence = imageRequest.Header.Sequence;
6769
6770 // NOTE: This is not a built in part of the LLUDP protocol, but we double the
6771 // priority of avatar textures to get avatars rezzing in faster than the
6772 // surrounding scene
6773 if ((ImageType)block.Type == ImageType.Baked)
6774 args.Priority *= 2.0f;
6775
6770 //handlerTextureRequest = OnRequestTexture; 6776 //handlerTextureRequest = OnRequestTexture;
6771 6777
6772 //if (handlerTextureRequest != null) 6778 //if (handlerTextureRequest != null)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index a9bc7d2..84a4959 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -304,8 +304,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
304 304
305 int total = resend + land + wind + cloud + task + texture + asset + state; 305 int total = resend + land + wind + cloud + task + texture + asset + state;
306 306
307 m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, State={8}, Total={9}", 307 //m_log.DebugFormat("[LLUDPCLIENT]: {0} is setting throttles. Resend={1}, Land={2}, Wind={3}, Cloud={4}, Task={5}, Texture={6}, Asset={7}, State={8}, Total={9}",
308 AgentID, resend, land, wind, cloud, task, texture, asset, state, total); 308 // AgentID, resend, land, wind, cloud, task, texture, asset, state, total);
309 309
310 // Update the token buckets with new throttle values 310 // Update the token buckets with new throttle values
311 TokenBucket bucket; 311 TokenBucket bucket;
@@ -372,7 +372,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
372 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category]; 372 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category];
373 TokenBucket bucket = m_throttleCategories[category]; 373 TokenBucket bucket = m_throttleCategories[category];
374 374
375 if (m_throttleCategories[category].RemoveTokens(packet.Buffer.DataLength)) 375 if (bucket.RemoveTokens(packet.Buffer.DataLength))
376 { 376 {
377 // Enough tokens were removed from the bucket, the packet will not be queued 377 // Enough tokens were removed from the bucket, the packet will not be queued
378 return false; 378 return false;
@@ -497,16 +497,33 @@ namespace OpenSim.Region.ClientStack.LindenUDP
497 SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r; 497 SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r;
498 } 498 }
499 499
500 RTO = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR)); 500 int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR));
501 501
502 // Clamp the retransmission timeout to manageable values 502 // Clamp the retransmission timeout to manageable values
503 RTO = Utils.Clamp(RTO, 3000, 10000); 503 rto = Utils.Clamp(RTO, 3000, 60000);
504
505 RTO = rto;
504 506
505 //m_log.Debug("[LLUDPCLIENT]: Setting agent " + this.Agent.FullName + "'s RTO to " + RTO + "ms with an RTTVAR of " + 507 //m_log.Debug("[LLUDPCLIENT]: Setting agent " + this.Agent.FullName + "'s RTO to " + RTO + "ms with an RTTVAR of " +
506 // RTTVAR + " based on new RTT of " + r + "ms"); 508 // RTTVAR + " based on new RTT of " + r + "ms");
507 } 509 }
508 510
509 /// <summary> 511 /// <summary>
512 /// Exponential backoff of the retransmission timeout, per section 5.5
513 /// of RFC 2988
514 /// </summary>
515 public void BackoffRTO()
516 {
517 // Reset SRTT and RTTVAR, we assume they are bogus since things
518 // didn't work out and we're backing off the timeout
519 SRTT = 0.0f;
520 RTTVAR = 0.0f;
521
522 // Double the retransmission timeout
523 RTO = Math.Min(RTO * 2, 60000);
524 }
525
526 /// <summary>
510 /// Does an early check to see if this queue empty callback is already 527 /// Does an early check to see if this queue empty callback is already
511 /// running, then asynchronously firing the event 528 /// running, then asynchronously firing the event
512 /// </summary> 529 /// </summary>
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index a9f4b2c..74d3262 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -98,6 +98,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
98 98
99 /// <summary>The measured resolution of Environment.TickCount</summary> 99 /// <summary>The measured resolution of Environment.TickCount</summary>
100 public readonly float TickCountResolution; 100 public readonly float TickCountResolution;
101 /// <summary>Number of terse prim updates to put on the queue each time the
102 /// OnQueueEmpty event is triggered for updates</summary>
103 public readonly int PrimTerseUpdatesPerPacket;
104 /// <summary>Number of terse avatar updates to put on the queue each time the
105 /// OnQueueEmpty event is triggered for updates</summary>
106 public readonly int AvatarTerseUpdatesPerPacket;
107 /// <summary>Number of full prim updates to put on the queue each time the
108 /// OnQueueEmpty event is triggered for updates</summary>
109 public readonly int PrimFullUpdatesPerPacket;
110 /// <summary>Number of texture packets to put on the queue each time the
111 /// OnQueueEmpty event is triggered for textures</summary>
112 public readonly int TextureSendLimit;
101 113
102 /// <summary>Handlers for incoming packets</summary> 114 /// <summary>Handlers for incoming packets</summary>
103 //PacketEventDictionary packetEvents = new PacketEventDictionary(); 115 //PacketEventDictionary packetEvents = new PacketEventDictionary();
@@ -172,6 +184,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
172 m_asyncPacketHandling = config.GetBoolean("async_packet_handling", false); 184 m_asyncPacketHandling = config.GetBoolean("async_packet_handling", false);
173 m_recvBufferSize = config.GetInt("client_socket_rcvbuf_size", 0); 185 m_recvBufferSize = config.GetInt("client_socket_rcvbuf_size", 0);
174 sceneThrottleBps = config.GetInt("scene_throttle_max_bps", 0); 186 sceneThrottleBps = config.GetInt("scene_throttle_max_bps", 0);
187
188 PrimTerseUpdatesPerPacket = config.GetInt("PrimTerseUpdatesPerPacket", 25);
189 AvatarTerseUpdatesPerPacket = config.GetInt("AvatarTerseUpdatesPerPacket", 10);
190 PrimFullUpdatesPerPacket = config.GetInt("PrimFullUpdatesPerPacket", 100);
191 TextureSendLimit = config.GetInt("TextureSendLimit", 20);
192 }
193 else
194 {
195 PrimTerseUpdatesPerPacket = 25;
196 AvatarTerseUpdatesPerPacket = 10;
197 PrimFullUpdatesPerPacket = 100;
198 TextureSendLimit = 20;
175 } 199 }
176 200
177 m_throttle = new TokenBucket(null, sceneThrottleBps, sceneThrottleBps); 201 m_throttle = new TokenBucket(null, sceneThrottleBps, sceneThrottleBps);
@@ -187,14 +211,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
187 211
188 base.Start(m_recvBufferSize, m_asyncPacketHandling); 212 base.Start(m_recvBufferSize, m_asyncPacketHandling);
189 213
190 // Start the incoming packet processing thread 214 // Start the packet processing threads
191 Thread incomingThread = new Thread(IncomingPacketHandler); 215 Watchdog.StartThread(IncomingPacketHandler, "Incoming Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false);
192 incomingThread.Name = "Incoming Packets (" + m_scene.RegionInfo.RegionName + ")"; 216 Watchdog.StartThread(OutgoingPacketHandler, "Outgoing Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false);
193 incomingThread.Start();
194
195 Thread outgoingThread = new Thread(OutgoingPacketHandler);
196 outgoingThread.Name = "Outgoing Packets (" + m_scene.RegionInfo.RegionName + ")";
197 outgoingThread.Start();
198 } 217 }
199 218
200 public new void Stop() 219 public new void Stop()
@@ -243,7 +262,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
243 for (int i = 0; i < packetCount; i++) 262 for (int i = 0; i < packetCount; i++)
244 { 263 {
245 byte[] data = datas[i]; 264 byte[] data = datas[i];
246 m_scene.ClientManager.ForEach( 265 m_scene.ForEachClient(
247 delegate(IClientAPI client) 266 delegate(IClientAPI client)
248 { 267 {
249 if (client is LLClientView) 268 if (client is LLClientView)
@@ -255,7 +274,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
255 else 274 else
256 { 275 {
257 byte[] data = packet.ToBytes(); 276 byte[] data = packet.ToBytes();
258 m_scene.ClientManager.ForEach( 277 m_scene.ForEachClient(
259 delegate(IClientAPI client) 278 delegate(IClientAPI client)
260 { 279 {
261 if (client is LLClientView) 280 if (client is LLClientView)
@@ -412,6 +431,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
412 { 431 {
413 m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO); 432 m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO);
414 433
434 // Exponential backoff of the retransmission timeout
435 udpClient.BackoffRTO();
436
415 // Resend packets 437 // Resend packets
416 for (int i = 0; i < expiredPackets.Count; i++) 438 for (int i = 0; i < expiredPackets.Count; i++)
417 { 439 {
@@ -548,27 +570,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
548 // UseCircuitCode handling 570 // UseCircuitCode handling
549 if (packet.Type == PacketType.UseCircuitCode) 571 if (packet.Type == PacketType.UseCircuitCode)
550 { 572 {
551 Util.FireAndForget( 573 m_log.Debug("[LLUDPSERVER]: Handling UseCircuitCode packet from " + buffer.RemoteEndPoint);
552 delegate(object o) 574 object[] array = new object[] { buffer, packet };
553 {
554 IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint;
555 575
556 // Begin the process of adding the client to the simulator 576 if (m_asyncPacketHandling)
557 AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint); 577 Util.FireAndForget(HandleUseCircuitCode, array);
578 else
579 HandleUseCircuitCode(array);
558 580
559 // Acknowledge the UseCircuitCode packet
560 SendAckImmediate(remoteEndPoint, packet.Header.Sequence);
561 }
562 );
563 return; 581 return;
564 } 582 }
565 583
566 // Determine which agent this packet came from 584 // Determine which agent this packet came from
567 IClientAPI client; 585 IClientAPI client;
568 if (!m_scene.ClientManager.TryGetValue(address, out client) || !(client is LLClientView)) 586 if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView))
569 { 587 {
570 m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + 588 m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName);
571 " in " + m_scene.RegionInfo.RegionName + ", currently tracking " + m_scene.ClientManager.Count + " clients");
572 return; 589 return;
573 } 590 }
574 591
@@ -670,6 +687,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
670 packetInbox.Enqueue(new IncomingPacket(udpClient, packet)); 687 packetInbox.Enqueue(new IncomingPacket(udpClient, packet));
671 } 688 }
672 689
690 private void HandleUseCircuitCode(object o)
691 {
692 object[] array = (object[])o;
693 UDPPacketBuffer buffer = (UDPPacketBuffer)array[0];
694 UseCircuitCodePacket packet = (UseCircuitCodePacket)array[1];
695
696 IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint;
697
698 // Begin the process of adding the client to the simulator
699 AddNewClient((UseCircuitCodePacket)packet, remoteEndPoint);
700
701 // Acknowledge the UseCircuitCode packet
702 SendAckImmediate(remoteEndPoint, packet.Header.Sequence);
703 }
704
673 private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber) 705 private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber)
674 { 706 {
675 PacketAckPacket ack = new PacketAckPacket(); 707 PacketAckPacket ack = new PacketAckPacket();
@@ -731,8 +763,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
731 { 763 {
732 // Create the LLUDPClient 764 // Create the LLUDPClient
733 LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint); 765 LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint);
766 IClientAPI existingClient;
734 767
735 if (!m_scene.ClientManager.ContainsKey(agentID)) 768 if (!m_scene.TryGetClient(agentID, out existingClient))
736 { 769 {
737 // Create the LLClientView 770 // Create the LLClientView
738 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode); 771 LLClientView client = new LLClientView(remoteEndPoint, m_scene, this, udpClient, sessionInfo, agentID, sessionID, circuitCode);
@@ -752,7 +785,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
752 { 785 {
753 // Remove this client from the scene 786 // Remove this client from the scene
754 IClientAPI client; 787 IClientAPI client;
755 if (m_scene.ClientManager.TryGetValue(udpClient.AgentID, out client)) 788 if (m_scene.TryGetClient(udpClient.AgentID, out client))
756 client.Close(); 789 client.Close();
757 } 790 }
758 791
@@ -768,6 +801,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
768 { 801 {
769 IncomingPacket incomingPacket = null; 802 IncomingPacket incomingPacket = null;
770 803
804 // HACK: This is a test to try and rate limit packet handling on Mono.
805 // If it works, a more elegant solution can be devised
806 if (Util.FireAndForgetCount() < 2)
807 {
808 //m_log.Debug("[LLUDPSERVER]: Incoming packet handler is sleeping");
809 Thread.Sleep(30);
810 }
811
771 if (packetInbox.Dequeue(100, ref incomingPacket)) 812 if (packetInbox.Dequeue(100, ref incomingPacket))
772 Util.FireAndForget(ProcessInPacket, incomingPacket); 813 Util.FireAndForget(ProcessInPacket, incomingPacket);
773 } 814 }
@@ -775,11 +816,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
775 { 816 {
776 m_log.Error("[LLUDPSERVER]: Error in the incoming packet handler loop: " + ex.Message, ex); 817 m_log.Error("[LLUDPSERVER]: Error in the incoming packet handler loop: " + ex.Message, ex);
777 } 818 }
819
820 Watchdog.UpdateThread();
778 } 821 }
779 822
780 if (packetInbox.Count > 0) 823 if (packetInbox.Count > 0)
781 m_log.Warn("[LLUDPSERVER]: IncomingPacketHandler is shutting down, dropping " + packetInbox.Count + " packets"); 824 m_log.Warn("[LLUDPSERVER]: IncomingPacketHandler is shutting down, dropping " + packetInbox.Count + " packets");
782 packetInbox.Clear(); 825 packetInbox.Clear();
826
827 Watchdog.RemoveThread();
783 } 828 }
784 829
785 private void OutgoingPacketHandler() 830 private void OutgoingPacketHandler()
@@ -788,6 +833,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
788 // on to en-US to avoid number parsing issues 833 // on to en-US to avoid number parsing issues
789 Culture.SetCurrentCulture(); 834 Culture.SetCurrentCulture();
790 835
836 // Typecast the function to an Action<IClientAPI> once here to avoid allocating a new
837 // Action generic every round
838 Action<IClientAPI> clientPacketHandler = ClientOutgoingPacketHandler;
839
791 while (base.IsRunning) 840 while (base.IsRunning)
792 { 841 {
793 try 842 try
@@ -836,18 +885,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
836 885
837 // Handle outgoing packets, resends, acknowledgements, and pings for each 886 // Handle outgoing packets, resends, acknowledgements, and pings for each
838 // client. m_packetSent will be set to true if a packet is sent 887 // client. m_packetSent will be set to true if a packet is sent
839 m_scene.ClientManager.ForEachSync(ClientOutgoingPacketHandler); 888 m_scene.ForEachClient(clientPacketHandler, false);
840 889
841 // If nothing was sent, sleep for the minimum amount of time before a 890 // If nothing was sent, sleep for the minimum amount of time before a
842 // token bucket could get more tokens 891 // token bucket could get more tokens
843 if (!m_packetSent) 892 if (!m_packetSent)
844 Thread.Sleep((int)TickCountResolution); 893 Thread.Sleep((int)TickCountResolution);
894
895 Watchdog.UpdateThread();
845 } 896 }
846 catch (Exception ex) 897 catch (Exception ex)
847 { 898 {
848 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex); 899 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex);
849 } 900 }
850 } 901 }
902
903 Watchdog.RemoveThread();
851 } 904 }
852 905
853 private void ClientOutgoingPacketHandler(IClientAPI client) 906 private void ClientOutgoingPacketHandler(IClientAPI client)
@@ -897,7 +950,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
897 } 950 }
898 951
899 // Make sure this client is still alive 952 // Make sure this client is still alive
900 if (m_scene.ClientManager.TryGetValue(udpClient.AgentID, out client)) 953 if (m_scene.TryGetClient(udpClient.AgentID, out client))
901 { 954 {
902 try 955 try
903 { 956 {
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
index 834aa14..ef7dce8 100644
--- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs
@@ -38,9 +38,20 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
38 public class XferModule : IRegionModule, IXfer 38 public class XferModule : IRegionModule, IXfer
39 { 39 {
40 private Scene m_scene; 40 private Scene m_scene;
41 private Dictionary<string, XferRequest> Requests = new Dictionary<string, XferRequest>();
42 private List<XferRequest> RequestTime = new List<XferRequest>();
41 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); 43 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
42 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); 44 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
45
43 46
47 public struct XferRequest
48 {
49 public IClientAPI remoteClient;
50 public ulong xferID;
51 public string fileName;
52 public DateTime timeStamp;
53 }
54
44 #region IRegionModule Members 55 #region IRegionModule Members
45 56
46 public void Initialise(Scene scene, IConfigSource config) 57 public void Initialise(Scene scene, IConfigSource config)
@@ -86,6 +97,13 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
86 NewFiles.Add(fileName, data); 97 NewFiles.Add(fileName, data);
87 } 98 }
88 } 99 }
100
101 if (Requests.ContainsKey(fileName))
102 {
103 RequestXfer(Requests[fileName].remoteClient, Requests[fileName].xferID, fileName);
104 Requests.Remove(fileName);
105 }
106
89 return true; 107 return true;
90 } 108 }
91 109
@@ -105,7 +123,6 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
105 /// <param name="fileName"></param> 123 /// <param name="fileName"></param>
106 public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName) 124 public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
107 { 125 {
108
109 lock (NewFiles) 126 lock (NewFiles)
110 { 127 {
111 if (NewFiles.ContainsKey(fileName)) 128 if (NewFiles.ContainsKey(fileName))
@@ -114,6 +131,7 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
114 { 131 {
115 byte[] fileData = NewFiles[fileName]; 132 byte[] fileData = NewFiles[fileName];
116 XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); 133 XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
134
117 Transfers.Add(xferID, transaction); 135 Transfers.Add(xferID, transaction);
118 NewFiles.Remove(fileName); 136 NewFiles.Remove(fileName);
119 137
@@ -123,6 +141,30 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
123 } 141 }
124 } 142 }
125 } 143 }
144 else
145 {
146 if (RequestTime.Count > 0)
147 {
148 TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks);
149 if (ts.TotalSeconds > 30)
150 {
151 Requests.Remove(RequestTime[0].fileName);
152 RequestTime.RemoveAt(0);
153 }
154 }
155
156 if (!Requests.ContainsKey(fileName))
157 {
158 XferRequest nRequest = new XferRequest();
159 nRequest.remoteClient = remoteClient;
160 nRequest.xferID = xferID;
161 nRequest.fileName = fileName;
162 nRequest.timeStamp = DateTime.UtcNow;
163 Requests.Add(fileName, nRequest);
164 RequestTime.Add(nRequest);
165 }
166
167 }
126 } 168 }
127 } 169 }
128 170
@@ -177,7 +219,6 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer
177 Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4); 219 Array.Copy(Utils.IntToBytes(Data.Length), 0, transferData, 0, 4);
178 Array.Copy(Data, 0, transferData, 4, Data.Length); 220 Array.Copy(Data, 0, transferData, 4, Data.Length);
179 Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); 221 Client.SendXferPacket(XferID, 0 + 0x80000000, transferData);
180
181 complete = true; 222 complete = true;
182 } 223 }
183 else 224 else
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
index 9387bce..61b6d65 100644
--- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs
@@ -96,12 +96,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule
96 else 96 else
97 { 97 {
98 bool foundResult = false; 98 bool foundResult = false;
99 string resultstring = ""; 99 string resultstring = String.Empty;
100 List<ScenePresence> allav = DeadAvatar.Scene.GetScenePresences(); 100 ScenePresence[] allav = DeadAvatar.Scene.GetScenePresences();
101 try 101 try
102 { 102 {
103 foreach (ScenePresence av in allav) 103 for (int i = 0; i < allav.Length; i++)
104 { 104 {
105 ScenePresence av = allav[i];
106
105 if (av.LocalId == killerObjectLocalID) 107 if (av.LocalId == killerObjectLocalID)
106 { 108 {
107 av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname); 109 av.ControllingClient.SendAlertMessage("You fragged " + DeadAvatar.Firstname + " " + DeadAvatar.Lastname);
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
index ebebaf9..72ec869 100644
--- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs
@@ -85,10 +85,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
85 85
86 public void SendAlertToUser(string firstName, string lastName, string message, bool modal) 86 public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
87 { 87 {
88 List<ScenePresence> presenceList = m_scene.GetScenePresences(); 88 ScenePresence[] presenceList = m_scene.GetScenePresences();
89 89
90 foreach (ScenePresence presence in presenceList) 90 for (int i = 0; i < presenceList.Length; i++)
91 { 91 {
92 ScenePresence presence = presenceList[i];
93
92 if (presence.Firstname == firstName && presence.Lastname == lastName) 94 if (presence.Firstname == firstName && presence.Lastname == lastName)
93 { 95 {
94 presence.ControllingClient.SendAgentAlertMessage(message, modal); 96 presence.ControllingClient.SendAgentAlertMessage(message, modal);
@@ -99,10 +101,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
99 101
100 public void SendGeneralAlert(string message) 102 public void SendGeneralAlert(string message)
101 { 103 {
102 List<ScenePresence> presenceList = m_scene.GetScenePresences(); 104 ScenePresence[] presenceList = m_scene.GetScenePresences();
103 105
104 foreach (ScenePresence presence in presenceList) 106 for (int i = 0; i < presenceList.Length; i++)
105 { 107 {
108 ScenePresence presence = presenceList[i];
109
106 if (!presence.IsChildAgent) 110 if (!presence.IsChildAgent)
107 presence.ControllingClient.SendAlertMessage(message); 111 presence.ControllingClient.SendAlertMessage(message);
108 } 112 }
@@ -150,10 +154,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog
150 public void SendNotificationToUsersInRegion( 154 public void SendNotificationToUsersInRegion(
151 UUID fromAvatarID, string fromAvatarName, string message) 155 UUID fromAvatarID, string fromAvatarName, string message)
152 { 156 {
153 List<ScenePresence> presenceList = m_scene.GetScenePresences(); 157 ScenePresence[] presences = m_scene.GetScenePresences();
154 158
155 foreach (ScenePresence presence in presenceList) 159 for (int i = 0; i < presences.Length; i++)
156 { 160 {
161 ScenePresence presence = presences[i];
157 if (!presence.IsChildAgent) 162 if (!presence.IsChildAgent)
158 presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); 163 presence.ControllingClient.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message);
159 } 164 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 7855862..273c128 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -114,7 +114,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
114 { 114 {
115 string reasonStr = Utils.BytesToString(reason); 115 string reasonStr = Utils.BytesToString(reason);
116 116
117 m_scene.ClientManager.ForEach( 117 m_scene.ForEachClient(
118 delegate(IClientAPI controller) 118 delegate(IClientAPI controller)
119 { 119 {
120 if (controller.AgentId != godID) 120 if (controller.AgentId != godID)
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
index ad05bab..f5ab454 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs
@@ -274,8 +274,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
274 } 274 }
275 m_RootAgents[agentID] = scene; 275 m_RootAgents[agentID] = scene;
276 } 276 }
277
277 // inform messaging server that agent changed the region 278 // inform messaging server that agent changed the region
278 NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); 279 Util.FireAndForget(
280 delegate(object o)
281 {
282 NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle);
283 }
284 );
279 } 285 }
280 286
281 private void OnEconomyDataRequest(UUID agentID) 287 private void OnEconomyDataRequest(UUID agentID)
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
index d636b1c..62500a2 100644
--- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
+++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs
@@ -1208,10 +1208,7 @@ namespace OpenSim.Region.CoreModules.InterGrid
1208 if (homeScene.TryGetAvatar(avatarId,out avatar)) 1208 if (homeScene.TryGetAvatar(avatarId,out avatar))
1209 { 1209 {
1210 KillAUser ku = new KillAUser(avatar,mod); 1210 KillAUser ku = new KillAUser(avatar,mod);
1211 Thread ta = new Thread(ku.ShutdownNoLogout); 1211 Watchdog.StartThread(ku.ShutdownNoLogout, "OGPShutdown", ThreadPriority.Normal, true);
1212 ta.IsBackground = true;
1213 ta.Name = "ShutdownThread";
1214 ta.Start();
1215 } 1212 }
1216 } 1213 }
1217 1214
@@ -1261,7 +1258,13 @@ namespace OpenSim.Region.CoreModules.InterGrid
1261 1258
1262 avToBeKilled.ControllingClient.SendLogoutPacketWhenClosing = false; 1259 avToBeKilled.ControllingClient.SendLogoutPacketWhenClosing = false;
1263 1260
1264 Thread.Sleep(30000); 1261 int sleepMS = 30000;
1262 while (sleepMS > 0)
1263 {
1264 Watchdog.UpdateThread();
1265 Thread.Sleep(1000);
1266 sleepMS -= 1000;
1267 }
1265 1268
1266 // test for child agent because they might have come back 1269 // test for child agent because they might have come back
1267 if (avToBeKilled.IsChildAgent) 1270 if (avToBeKilled.IsChildAgent)
@@ -1270,6 +1273,8 @@ namespace OpenSim.Region.CoreModules.InterGrid
1270 avToBeKilled.ControllingClient.Close(); 1273 avToBeKilled.ControllingClient.Close();
1271 } 1274 }
1272 } 1275 }
1276
1277 Watchdog.RemoveThread();
1273 } 1278 }
1274 1279
1275 } 1280 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index fe9c8d9..c9fce91 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -128,7 +128,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
128 if (m_repliesRequired == 0) 128 if (m_repliesRequired == 0)
129 { 129 {
130 m_requestState = RequestState.Completed; 130 m_requestState = RequestState.Completed;
131 PerformAssetsRequestCallback(); 131 PerformAssetsRequestCallback(null);
132 return; 132 return;
133 } 133 }
134 134
@@ -246,9 +246,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
246 246
247 // We want to stop using the asset cache thread asap 247 // We want to stop using the asset cache thread asap
248 // as we now need to do the work of producing the rest of the archive 248 // as we now need to do the work of producing the rest of the archive
249 Thread newThread = new Thread(PerformAssetsRequestCallback); 249 Util.FireAndForget(PerformAssetsRequestCallback);
250 newThread.Name = "OpenSimulator archiving thread post assets receipt";
251 newThread.Start();
252 } 250 }
253 else 251 else
254 { 252 {
@@ -265,7 +263,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
265 /// <summary> 263 /// <summary>
266 /// Perform the callback on the original requester of the assets 264 /// Perform the callback on the original requester of the assets
267 /// </summary> 265 /// </summary>
268 protected void PerformAssetsRequestCallback() 266 protected void PerformAssetsRequestCallback(object o)
269 { 267 {
270 try 268 try
271 { 269 {
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 3bb162e..e3a395e 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -414,9 +414,12 @@ namespace OpenSim.Region.CoreModules.World.Estate
414 private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID) 414 private void handleEstateTeleportAllUsersHomeRequest(IClientAPI remover_client, UUID invoice, UUID senderID)
415 { 415 {
416 // Get a fresh list that will not change as people get teleported away 416 // Get a fresh list that will not change as people get teleported away
417 List<ScenePresence> prescences = m_scene.GetScenePresences(); 417 ScenePresence[] presences = m_scene.GetScenePresences();
418 foreach (ScenePresence p in prescences) 418
419 for (int i = 0; i < presences.Length; i++)
419 { 420 {
421 ScenePresence p = presences[i];
422
420 if (p.UUID != senderID) 423 if (p.UUID != senderID)
421 { 424 {
422 // make sure they are still there, we could be working down a long list 425 // make sure they are still there, we could be working down a long list
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 53c64cb..93a949a 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -264,10 +264,8 @@ namespace OpenSim.Region.CoreModules.World.Land
264 avatar.ControllingClient.SendAlertMessage( 264 avatar.ControllingClient.SendAlertMessage(
265 "You are not allowed on this parcel because you are banned. Please go away."); 265 "You are not allowed on this parcel because you are banned. Please go away.");
266 266
267 avatar.PhysicsActor.Position = 267 avatar.PhysicsActor.Position = avatar.lastKnownAllowedPosition;
268 new PhysicsVector(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y, 268 avatar.PhysicsActor.Velocity = Vector3.Zero;
269 avatar.lastKnownAllowedPosition.Z);
270 avatar.PhysicsActor.Velocity = new PhysicsVector(0, 0, 0);
271 } 269 }
272 else 270 else
273 { 271 {
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
index 5fd8369..285d36a 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs
@@ -98,27 +98,29 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
98 } 98 }
99 terrainRenderer.Initialise(m_scene, m_config); 99 terrainRenderer.Initialise(m_scene, m_config);
100 100
101 Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize); 101 using (Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize))
102 //long t = System.Environment.TickCount; 102 {
103 //for (int i = 0; i < 10; ++i) { 103 //long t = System.Environment.TickCount;
104 //for (int i = 0; i < 10; ++i) {
104 terrainRenderer.TerrainToBitmap(mapbmp); 105 terrainRenderer.TerrainToBitmap(mapbmp);
105 //} 106 //}
106 //t = System.Environment.TickCount - t; 107 //t = System.Environment.TickCount - t;
107 //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t); 108 //m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
108 109
109 110
110 if (drawPrimVolume) 111 if (drawPrimVolume)
111 { 112 {
112 DrawObjectVolume(m_scene, mapbmp); 113 DrawObjectVolume(m_scene, mapbmp);
113 } 114 }
114 115
115 try 116 try
116 { 117 {
117 imageData = OpenJPEG.EncodeFromImage(mapbmp, true); 118 imageData = OpenJPEG.EncodeFromImage(mapbmp, true);
118 } 119 }
119 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke 120 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
120 { 121 {
121 m_log.Error("Failed generating terrain map: " + e); 122 m_log.Error("Failed generating terrain map: " + e);
123 }
122 } 124 }
123 125
124 return imageData; 126 return imageData;
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 4e40084..f4b54aa 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
58 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 58 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59 59
60 private static readonly string DEFAULT_WORLD_MAP_EXPORT_PATH = "exportmap.jpg"; 60 private static readonly string DEFAULT_WORLD_MAP_EXPORT_PATH = "exportmap.jpg";
61 61 private static readonly UUID STOP_UUID = UUID.Random();
62 private static readonly string m_mapLayerPath = "0001/"; 62 private static readonly string m_mapLayerPath = "0001/";
63 63
64 private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>(); 64 private OpenSim.Framework.BlockingQueue<MapRequestState> requests = new OpenSim.Framework.BlockingQueue<MapRequestState>();
@@ -74,7 +74,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
74 private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>(); 74 private Dictionary<ulong, int> m_blacklistedregions = new Dictionary<ulong, int>();
75 private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>(); 75 private Dictionary<ulong, string> m_cachedRegionMapItemsAddress = new Dictionary<ulong, string>();
76 private List<UUID> m_rootAgents = new List<UUID>(); 76 private List<UUID> m_rootAgents = new List<UUID>();
77 private Thread mapItemReqThread;
78 private volatile bool threadrunning = false; 77 private volatile bool threadrunning = false;
79 78
80 //private int CacheRegionsDistance = 256; 79 //private int CacheRegionsDistance = 256;
@@ -338,13 +337,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
338 { 337 {
339 if (threadrunning) return; 338 if (threadrunning) return;
340 threadrunning = true; 339 threadrunning = true;
340
341 m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread"); 341 m_log.Debug("[WORLD MAP]: Starting remote MapItem request thread");
342 mapItemReqThread = new Thread(new ThreadStart(process)); 342
343 mapItemReqThread.IsBackground = true; 343 Watchdog.StartThread(process, "MapItemRequestThread", ThreadPriority.BelowNormal, true);
344 mapItemReqThread.Name = "MapItemRequestThread";
345 mapItemReqThread.Priority = ThreadPriority.BelowNormal;
346 mapItemReqThread.SetApartmentState(ApartmentState.MTA);
347 mapItemReqThread.Start();
348 } 344 }
349 345
350 /// <summary> 346 /// <summary>
@@ -353,7 +349,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
353 private void StopThread() 349 private void StopThread()
354 { 350 {
355 MapRequestState st = new MapRequestState(); 351 MapRequestState st = new MapRequestState();
356 st.agentID=UUID.Zero; 352 st.agentID=STOP_UUID;
357 st.EstateID=0; 353 st.EstateID=0;
358 st.flags=0; 354 st.flags=0;
359 st.godlike=false; 355 st.godlike=false;
@@ -441,26 +437,29 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
441 { 437 {
442 while (true) 438 while (true)
443 { 439 {
444 MapRequestState st = requests.Dequeue(); 440 MapRequestState st = requests.Dequeue(1000);
445 441
446 // end gracefully 442 // end gracefully
447 if (st.agentID == UUID.Zero) 443 if (st.agentID == STOP_UUID)
448 {
449 break; 444 break;
450 }
451 445
452 bool dorequest = true; 446 if (st.agentID != UUID.Zero)
453 lock (m_rootAgents)
454 { 447 {
455 if (!m_rootAgents.Contains(st.agentID)) 448 bool dorequest = true;
456 dorequest = false; 449 lock (m_rootAgents)
457 } 450 {
451 if (!m_rootAgents.Contains(st.agentID))
452 dorequest = false;
453 }
458 454
459 if (dorequest) 455 if (dorequest)
460 { 456 {
461 OSDMap response = RequestMapItemsAsync("", st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle); 457 OSDMap response = RequestMapItemsAsync("", st.agentID, st.flags, st.EstateID, st.godlike, st.itemtype, st.regionhandle);
462 RequestMapItemsCompleted(response); 458 RequestMapItemsCompleted(response);
459 }
463 } 460 }
461
462 Watchdog.UpdateThread();
464 } 463 }
465 } 464 }
466 catch (Exception e) 465 catch (Exception e)
@@ -469,6 +468,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
469 } 468 }
470 469
471 threadrunning = false; 470 threadrunning = false;
471 Watchdog.RemoveThread();
472 } 472 }
473 473
474 /// <summary> 474 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/AnimationSet.cs
index aa0c8b8..740d168 100644
--- a/OpenSim/Region/Framework/Scenes/AnimationSet.cs
+++ b/OpenSim/Region/Framework/Scenes/AnimationSet.cs
@@ -30,6 +30,8 @@ using System.Collections.Generic;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenMetaverse; 31using OpenMetaverse;
32 32
33using Animation = OpenSim.Framework.Animation;
34
33namespace OpenSim.Region.Framework.Scenes 35namespace OpenSim.Region.Framework.Scenes
34{ 36{
35 [Serializable] 37 [Serializable]
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index ac89f7b..1a91f0c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -394,7 +394,7 @@ namespace OpenSim.Region.Framework.Scenes
394 void ProcessViewerEffect(IClientAPI remoteClient, List<ViewerEffectEventHandlerArg> args) 394 void ProcessViewerEffect(IClientAPI remoteClient, List<ViewerEffectEventHandlerArg> args)
395 { 395 {
396 // TODO: don't create new blocks if recycling an old packet 396 // TODO: don't create new blocks if recycling an old packet
397 List<ViewerEffectPacket.EffectBlock> effectBlock = new List<ViewerEffectPacket.EffectBlock>(); 397 ViewerEffectPacket.EffectBlock[] effectBlockArray = new ViewerEffectPacket.EffectBlock[args.Count];
398 for (int i = 0; i < args.Count; i++) 398 for (int i = 0; i < args.Count; i++)
399 { 399 {
400 ViewerEffectPacket.EffectBlock effect = new ViewerEffectPacket.EffectBlock(); 400 ViewerEffectPacket.EffectBlock effect = new ViewerEffectPacket.EffectBlock();
@@ -404,11 +404,10 @@ namespace OpenSim.Region.Framework.Scenes
404 effect.ID = args[i].ID; 404 effect.ID = args[i].ID;
405 effect.Type = args[i].Type; 405 effect.Type = args[i].Type;
406 effect.TypeData = args[i].TypeData; 406 effect.TypeData = args[i].TypeData;
407 effectBlock.Add(effect); 407 effectBlockArray[i] = effect;
408 } 408 }
409 ViewerEffectPacket.EffectBlock[] effectBlockArray = effectBlock.ToArray();
410 409
411 ClientManager.ForEach( 410 ForEachClient(
412 delegate(IClientAPI client) 411 delegate(IClientAPI client)
413 { 412 {
414 if (client.AgentId != remoteClient.AgentId) 413 if (client.AgentId != remoteClient.AgentId)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 5005ac9..7c3875d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -61,6 +61,7 @@ namespace OpenSim.Region.Framework.Scenes
61 Time = 0, 61 Time = 0,
62 Distance = 1, 62 Distance = 1,
63 SimpleAngularDistance = 2, 63 SimpleAngularDistance = 2,
64 FrontBack = 3,
64 } 65 }
65 66
66 public delegate void SynchronizeSceneHandler(Scene scene); 67 public delegate void SynchronizeSceneHandler(Scene scene);
@@ -81,8 +82,6 @@ namespace OpenSim.Region.Framework.Scenes
81 82
82 protected Timer m_restartWaitTimer = new Timer(); 83 protected Timer m_restartWaitTimer = new Timer();
83 84
84 protected Thread m_updateEntitiesThread;
85
86 public SimStatsReporter StatsReporter; 85 public SimStatsReporter StatsReporter;
87 86
88 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 87 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
@@ -107,11 +106,11 @@ namespace OpenSim.Region.Framework.Scenes
107 public bool m_physicalPrim; 106 public bool m_physicalPrim;
108 public float m_maxNonphys = 256; 107 public float m_maxNonphys = 256;
109 public float m_maxPhys = 10; 108 public float m_maxPhys = 10;
110 public bool m_clampPrimSize = false; 109 public bool m_clampPrimSize;
111 public bool m_trustBinaries = false; 110 public bool m_trustBinaries;
112 public bool m_allowScriptCrossings = false; 111 public bool m_allowScriptCrossings;
113 public bool m_useFlySlow = false; 112 public bool m_useFlySlow;
114 public bool m_usePreJump = false; 113 public bool m_usePreJump;
115 public bool m_seeIntoRegionFromNeighbor; 114 public bool m_seeIntoRegionFromNeighbor;
116 // TODO: need to figure out how allow client agents but deny 115 // TODO: need to figure out how allow client agents but deny
117 // root agents when ACL denies access to root agent 116 // root agents when ACL denies access to root agent
@@ -119,11 +118,11 @@ namespace OpenSim.Region.Framework.Scenes
119 public int MaxUndoCount = 5; 118 public int MaxUndoCount = 5;
120 private int m_RestartTimerCounter; 119 private int m_RestartTimerCounter;
121 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing 120 private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
122 private int m_incrementsof15seconds = 0; 121 private int m_incrementsof15seconds;
123 private volatile bool m_backingup = false; 122 private volatile bool m_backingup;
123 private bool m_useAsyncWhenPossible;
124 124
125 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); 125 private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
126
127 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); 126 private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>();
128 127
129 protected string m_simulatorVersion = "OpenSimulator Server"; 128 protected string m_simulatorVersion = "OpenSimulator Server";
@@ -143,8 +142,8 @@ namespace OpenSim.Region.Framework.Scenes
143 142
144 public IXfer XferManager; 143 public IXfer XferManager;
145 144
146 protected IAssetService m_AssetService = null; 145 protected IAssetService m_AssetService;
147 protected IAuthorizationService m_AuthorizationService = null; 146 protected IAuthorizationService m_AuthorizationService;
148 147
149 private Object m_heartbeatLock = new Object(); 148 private Object m_heartbeatLock = new Object();
150 149
@@ -185,7 +184,7 @@ namespace OpenSim.Region.Framework.Scenes
185 } 184 }
186 } 185 }
187 186
188 protected IInventoryService m_InventoryService = null; 187 protected IInventoryService m_InventoryService;
189 188
190 public IInventoryService InventoryService 189 public IInventoryService InventoryService
191 { 190 {
@@ -205,7 +204,7 @@ namespace OpenSim.Region.Framework.Scenes
205 } 204 }
206 } 205 }
207 206
208 protected IGridService m_GridService = null; 207 protected IGridService m_GridService;
209 208
210 public IGridService GridService 209 public IGridService GridService
211 { 210 {
@@ -253,9 +252,9 @@ namespace OpenSim.Region.Framework.Scenes
253 // Central Update Loop 252 // Central Update Loop
254 253
255 protected int m_fps = 10; 254 protected int m_fps = 10;
256 protected int m_frame = 0; 255 protected int m_frame;
257 protected float m_timespan = 0.089f; 256 protected float m_timespan = 0.089f;
258 protected DateTime m_lastupdate = DateTime.Now; 257 protected DateTime m_lastupdate = DateTime.UtcNow;
259 258
260 private int m_update_physics = 1; 259 private int m_update_physics = 1;
261 private int m_update_entitymovement = 1; 260 private int m_update_entitymovement = 1;
@@ -266,26 +265,26 @@ namespace OpenSim.Region.Framework.Scenes
266 private int m_update_terrain = 50; 265 private int m_update_terrain = 50;
267 private int m_update_land = 1; 266 private int m_update_land = 1;
268 267
269 private int frameMS = 0; 268 private int frameMS;
270 private int physicsMS2 = 0; 269 private int physicsMS2;
271 private int physicsMS = 0; 270 private int physicsMS;
272 private int otherMS = 0; 271 private int otherMS;
273 272
274 private bool m_physics_enabled = true; 273 private bool m_physics_enabled = true;
275 private bool m_scripts_enabled = true; 274 private bool m_scripts_enabled = true;
276 private string m_defaultScriptEngine; 275 private string m_defaultScriptEngine;
277 private int m_LastLogin = 0; 276 private int m_LastLogin;
278 private Thread HeartbeatThread = null; 277 private Thread HeartbeatThread;
279 private volatile bool shuttingdown = false; 278 private volatile bool shuttingdown;
280 279
281 private int m_lastUpdate = Environment.TickCount; 280 private int m_lastUpdate = Environment.TickCount;
282 private bool m_firstHeartbeat = true; 281 private bool m_firstHeartbeat = true;
283 282
284 private UpdatePrioritizationSchemes m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time; 283 private UpdatePrioritizationSchemes m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
285 private bool m_reprioritization_enabled = true; 284 private bool m_reprioritization_enabled = true;
286 private double m_reprioritization_interval = 2000.0; 285 private double m_reprioritization_interval = 5000.0;
287 private double m_root_reprioritization_distance = 5.0; 286 private double m_root_reprioritization_distance = 10.0;
288 private double m_child_reprioritization_distance = 10.0; 287 private double m_child_reprioritization_distance = 20.0;
289 288
290 private object m_deleting_scene_object = new object(); 289 private object m_deleting_scene_object = new object();
291 290
@@ -480,6 +479,9 @@ namespace OpenSim.Region.Framework.Scenes
480 // 479 //
481 IConfig startupConfig = m_config.Configs["Startup"]; 480 IConfig startupConfig = m_config.Configs["Startup"];
482 481
482 // Should we try to run loops synchronously or asynchronously?
483 m_useAsyncWhenPossible = startupConfig.GetBoolean("use_async_when_possible", false);
484
483 //Animation states 485 //Animation states
484 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 486 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
485 // TODO: Change default to true once the feature is supported 487 // TODO: Change default to true once the feature is supported
@@ -542,6 +544,9 @@ namespace OpenSim.Region.Framework.Scenes
542 case "simpleangulardistance": 544 case "simpleangulardistance":
543 m_update_prioritization_scheme = UpdatePrioritizationSchemes.SimpleAngularDistance; 545 m_update_prioritization_scheme = UpdatePrioritizationSchemes.SimpleAngularDistance;
544 break; 546 break;
547 case "frontback":
548 m_update_prioritization_scheme = UpdatePrioritizationSchemes.FrontBack;
549 break;
545 default: 550 default:
546 m_log.Warn("[SCENE]: UpdatePrioritizationScheme was not recognized, setting to default settomg of Time"); 551 m_log.Warn("[SCENE]: UpdatePrioritizationScheme was not recognized, setting to default settomg of Time");
547 m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time; 552 m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
@@ -889,6 +894,9 @@ namespace OpenSim.Region.Framework.Scenes
889 { 894 {
890 m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName); 895 m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName);
891 896
897 m_restartTimer.Stop();
898 m_restartTimer.Close();
899
892 // Kick all ROOT agents with the message, 'The simulator is going down' 900 // Kick all ROOT agents with the message, 'The simulator is going down'
893 ForEachScenePresence(delegate(ScenePresence avatar) 901 ForEachScenePresence(delegate(ScenePresence avatar)
894 { 902 {
@@ -945,11 +953,8 @@ namespace OpenSim.Region.Framework.Scenes
945 HeartbeatThread = null; 953 HeartbeatThread = null;
946 } 954 }
947 m_lastUpdate = Environment.TickCount; 955 m_lastUpdate = Environment.TickCount;
948 HeartbeatThread = new Thread(new ParameterizedThreadStart(Heartbeat)); 956
949 HeartbeatThread.SetApartmentState(ApartmentState.MTA); 957 HeartbeatThread = Watchdog.StartThread(Heartbeat, "Heartbeat for region " + RegionInfo.RegionName, ThreadPriority.Normal, false);
950 HeartbeatThread.Name = string.Format("Heartbeat for region {0}", RegionInfo.RegionName);
951 HeartbeatThread.Priority = ThreadPriority.AboveNormal;
952 HeartbeatThread.Start();
953 } 958 }
954 959
955 /// <summary> 960 /// <summary>
@@ -976,12 +981,13 @@ namespace OpenSim.Region.Framework.Scenes
976 /// <summary> 981 /// <summary>
977 /// Performs per-frame updates regularly 982 /// Performs per-frame updates regularly
978 /// </summary> 983 /// </summary>
979 /// <param name="sender"></param> 984 private void Heartbeat()
980 /// <param name="e"></param>
981 private void Heartbeat(object sender)
982 { 985 {
983 if (!Monitor.TryEnter(m_heartbeatLock)) 986 if (!Monitor.TryEnter(m_heartbeatLock))
987 {
988 Watchdog.RemoveThread();
984 return; 989 return;
990 }
985 991
986 try 992 try
987 { 993 {
@@ -998,6 +1004,8 @@ namespace OpenSim.Region.Framework.Scenes
998 Monitor.Pulse(m_heartbeatLock); 1004 Monitor.Pulse(m_heartbeatLock);
999 Monitor.Exit(m_heartbeatLock); 1005 Monitor.Exit(m_heartbeatLock);
1000 } 1006 }
1007
1008 Watchdog.RemoveThread();
1001 } 1009 }
1002 1010
1003 /// <summary> 1011 /// <summary>
@@ -1016,10 +1024,11 @@ namespace OpenSim.Region.Framework.Scenes
1016//#endif 1024//#endif
1017 maintc = Environment.TickCount; 1025 maintc = Environment.TickCount;
1018 1026
1019 TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate; 1027 TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
1020 float physicsFPS = 0; 1028 float physicsFPS = 0;
1021 1029
1022 frameMS = Environment.TickCount; 1030 frameMS = Environment.TickCount;
1031
1023 try 1032 try
1024 { 1033 {
1025 // Increment the frame counter 1034 // Increment the frame counter
@@ -1101,6 +1110,11 @@ namespace OpenSim.Region.Framework.Scenes
1101 } 1110 }
1102 if (loginsdisabled && (m_frame > 20)) 1111 if (loginsdisabled && (m_frame > 20))
1103 { 1112 {
1113 // In 99.9% of cases it is a bad idea to manually force garbage collection. However,
1114 // this is a rare case where we know we have just went through a long cycle of heap
1115 // allocations, and there is no more work to be done until someone logs in
1116 GC.Collect();
1117
1104 m_log.Debug("[REGION]: Enabling Logins"); 1118 m_log.Debug("[REGION]: Enabling Logins");
1105 loginsdisabled = false; 1119 loginsdisabled = false;
1106 } 1120 }
@@ -1139,13 +1153,16 @@ namespace OpenSim.Region.Framework.Scenes
1139 } 1153 }
1140 m_timedilation = tmpval; 1154 m_timedilation = tmpval;
1141 1155
1142 m_lastupdate = DateTime.Now; 1156 m_lastupdate = DateTime.UtcNow;
1143 } 1157 }
1144 maintc = Environment.TickCount - maintc; 1158 maintc = Environment.TickCount - maintc;
1145 maintc = (int)(m_timespan * 1000) - maintc; 1159 maintc = (int)(m_timespan * 1000) - maintc;
1146 1160
1147 if ((maintc < (m_timespan * 1000)) && maintc > 0) 1161 if ((maintc < (m_timespan * 1000)) && maintc > 0)
1148 Thread.Sleep(maintc); 1162 Thread.Sleep(maintc);
1163
1164 // Tell the watchdog that this thread is still alive
1165 Watchdog.UpdateThread();
1149 } 1166 }
1150 } 1167 }
1151 1168
@@ -1219,10 +1236,7 @@ namespace OpenSim.Region.Framework.Scenes
1219 if (!m_backingup) 1236 if (!m_backingup)
1220 { 1237 {
1221 m_backingup = true; 1238 m_backingup = true;
1222 1239 Util.FireAndForget(BackupWaitCallback);
1223 System.ComponentModel.BackgroundWorker backupWorker = new System.ComponentModel.BackgroundWorker();
1224 backupWorker.DoWork += delegate(object sender, System.ComponentModel.DoWorkEventArgs e) { Backup(); };
1225 backupWorker.RunWorkerAsync();
1226 } 1240 }
1227 } 1241 }
1228 1242
@@ -1235,6 +1249,14 @@ namespace OpenSim.Region.Framework.Scenes
1235 } 1249 }
1236 1250
1237 /// <summary> 1251 /// <summary>
1252 /// Wrapper for Backup() that can be called with Util.FireAndForget()
1253 /// </summary>
1254 private void BackupWaitCallback(object o)
1255 {
1256 Backup();
1257 }
1258
1259 /// <summary>
1238 /// Backup the scene. This acts as the main method of the backup thread. 1260 /// Backup the scene. This acts as the main method of the backup thread.
1239 /// </summary> 1261 /// </summary>
1240 /// <returns></returns> 1262 /// <returns></returns>
@@ -2460,7 +2482,7 @@ namespace OpenSim.Region.Framework.Scenes
2460 /// <param name="client"></param> 2482 /// <param name="client"></param>
2461 public override void AddNewClient(IClientAPI client) 2483 public override void AddNewClient(IClientAPI client)
2462 { 2484 {
2463 ClientManager.Add(client); 2485 m_clientManager.Add(client);
2464 2486
2465 CheckHeartbeat(); 2487 CheckHeartbeat();
2466 SubscribeToClientEvents(client); 2488 SubscribeToClientEvents(client);
@@ -3099,7 +3121,7 @@ namespace OpenSim.Region.Framework.Scenes
3099 3121
3100 // Remove the avatar from the scene 3122 // Remove the avatar from the scene
3101 m_sceneGraph.RemoveScenePresence(agentID); 3123 m_sceneGraph.RemoveScenePresence(agentID);
3102 ClientManager.Remove(agentID); 3124 m_clientManager.Remove(agentID);
3103 3125
3104 try 3126 try
3105 { 3127 {
@@ -3496,9 +3518,7 @@ namespace OpenSim.Region.Framework.Scenes
3496 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) 3518 public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
3497 { 3519 {
3498 ScenePresence presence; 3520 ScenePresence presence;
3499 3521 m_sceneGraph.TryGetAvatar(agentID, out presence);
3500 lock (m_sceneGraph.ScenePresences)
3501 m_sceneGraph.ScenePresences.TryGetValue(agentID, out presence);
3502 3522
3503 if (presence != null) 3523 if (presence != null)
3504 { 3524 {
@@ -3709,8 +3729,7 @@ namespace OpenSim.Region.Framework.Scenes
3709 Vector3 lookAt, uint teleportFlags) 3729 Vector3 lookAt, uint teleportFlags)
3710 { 3730 {
3711 ScenePresence sp; 3731 ScenePresence sp;
3712 lock (m_sceneGraph.ScenePresences) 3732 m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp);
3713 m_sceneGraph.ScenePresences.TryGetValue(remoteClient.AgentId, out sp);
3714 3733
3715 if (sp != null) 3734 if (sp != null)
3716 { 3735 {
@@ -4112,7 +4131,7 @@ namespace OpenSim.Region.Framework.Scenes
4112 /// This list is a new object, so it can be iterated over without locking. 4131 /// This list is a new object, so it can be iterated over without locking.
4113 /// </summary> 4132 /// </summary>
4114 /// <returns></returns> 4133 /// <returns></returns>
4115 public List<ScenePresence> GetScenePresences() 4134 public ScenePresence[] GetScenePresences()
4116 { 4135 {
4117 return m_sceneGraph.GetScenePresences(); 4136 return m_sceneGraph.GetScenePresences();
4118 } 4137 }
@@ -4159,15 +4178,13 @@ namespace OpenSim.Region.Framework.Scenes
4159 public void ForEachScenePresence(Action<ScenePresence> action) 4178 public void ForEachScenePresence(Action<ScenePresence> action)
4160 { 4179 {
4161 // We don't want to try to send messages if there are no avatars. 4180 // We don't want to try to send messages if there are no avatars.
4162 if (m_sceneGraph != null && m_sceneGraph.ScenePresences != null) 4181 if (m_sceneGraph != null)
4163 { 4182 {
4164 try 4183 try
4165 { 4184 {
4166 List<ScenePresence> presenceList = GetScenePresences(); 4185 ScenePresence[] presences = GetScenePresences();
4167 foreach (ScenePresence presence in presenceList) 4186 for (int i = 0; i < presences.Length; i++)
4168 { 4187 action(presences[i]);
4169 action(presence);
4170 }
4171 } 4188 }
4172 catch (Exception e) 4189 catch (Exception e)
4173 { 4190 {
@@ -4239,7 +4256,30 @@ namespace OpenSim.Region.Framework.Scenes
4239 4256
4240 public void ForEachClient(Action<IClientAPI> action) 4257 public void ForEachClient(Action<IClientAPI> action)
4241 { 4258 {
4242 ClientManager.ForEach(action); 4259 ForEachClient(action, m_useAsyncWhenPossible);
4260 }
4261
4262 public void ForEachClient(Action<IClientAPI> action, bool doAsynchronous)
4263 {
4264 // FIXME: Asynchronous iteration is disabled until we have a threading model that
4265 // can support calling this function from an async packet handler without
4266 // potentially deadlocking
4267 m_clientManager.ForEachSync(action);
4268
4269 //if (doAsynchronous)
4270 // m_clientManager.ForEach(action);
4271 //else
4272 // m_clientManager.ForEachSync(action);
4273 }
4274
4275 public bool TryGetClient(UUID avatarID, out IClientAPI client)
4276 {
4277 return m_clientManager.TryGetValue(avatarID, out client);
4278 }
4279
4280 public bool TryGetClient(System.Net.IPEndPoint remoteEndPoint, out IClientAPI client)
4281 {
4282 return m_clientManager.TryGetValue(remoteEndPoint, out client);
4243 } 4283 }
4244 4284
4245 public void ForEachSOG(Action<SceneObjectGroup> action) 4285 public void ForEachSOG(Action<SceneObjectGroup> action)
@@ -4571,7 +4611,7 @@ namespace OpenSim.Region.Framework.Scenes
4571 { 4611 {
4572 case PhysicsJointType.Ball: 4612 case PhysicsJointType.Ball:
4573 { 4613 {
4574 PhysicsVector jointAnchor = PhysicsScene.GetJointAnchor(joint); 4614 Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint);
4575 Vector3 proxyPos = new Vector3(jointAnchor.X, jointAnchor.Y, jointAnchor.Z); 4615 Vector3 proxyPos = new Vector3(jointAnchor.X, jointAnchor.Y, jointAnchor.Z);
4576 jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update 4616 jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update
4577 } 4617 }
@@ -4579,7 +4619,7 @@ namespace OpenSim.Region.Framework.Scenes
4579 4619
4580 case PhysicsJointType.Hinge: 4620 case PhysicsJointType.Hinge:
4581 { 4621 {
4582 PhysicsVector jointAnchor = PhysicsScene.GetJointAnchor(joint); 4622 Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint);
4583 4623
4584 // Normally, we would just ask the physics scene to return the axis for the joint. 4624 // Normally, we would just ask the physics scene to return the axis for the joint.
4585 // Unfortunately, ODE sometimes returns <0,0,0> for the joint axis, which should 4625 // Unfortunately, ODE sometimes returns <0,0,0> for the joint axis, which should
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index cf5c3c8..82731d1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -102,12 +102,7 @@ namespace OpenSim.Region.Framework.Scenes
102 102
103 private readonly Mutex _primAllocateMutex = new Mutex(false); 103 private readonly Mutex _primAllocateMutex = new Mutex(false);
104 104
105 private readonly ClientManager m_clientManager = new ClientManager(); 105 protected readonly ClientManager m_clientManager = new ClientManager();
106
107 public ClientManager ClientManager
108 {
109 get { return m_clientManager; }
110 }
111 106
112 public float TimeDilation 107 public float TimeDilation
113 { 108 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index deee6c3..db055f9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -66,7 +66,9 @@ namespace OpenSim.Region.Framework.Scenes
66 66
67 #region Fields 67 #region Fields
68 68
69 protected internal Dictionary<UUID, ScenePresence> ScenePresences = new Dictionary<UUID, ScenePresence>(); 69 protected Dictionary<UUID, ScenePresence> m_scenePresences = new Dictionary<UUID, ScenePresence>();
70 protected ScenePresence[] m_scenePresenceArray = new ScenePresence[0];
71
70 // SceneObjects is not currently populated or used. 72 // SceneObjects is not currently populated or used.
71 //public Dictionary<UUID, SceneObjectGroup> SceneObjects; 73 //public Dictionary<UUID, SceneObjectGroup> SceneObjects;
72 protected internal EntityManager Entities = new EntityManager(); 74 protected internal EntityManager Entities = new EntityManager();
@@ -126,10 +128,12 @@ namespace OpenSim.Region.Framework.Scenes
126 128
127 protected internal void Close() 129 protected internal void Close()
128 { 130 {
129 lock (ScenePresences) 131 lock (m_scenePresences)
130 { 132 {
131 ScenePresences.Clear(); 133 m_scenePresences.Clear();
134 m_scenePresenceArray = new ScenePresence[0];
132 } 135 }
136
133 lock (m_dictionary_lock) 137 lock (m_dictionary_lock)
134 { 138 {
135 SceneObjectGroupsByFullID.Clear(); 139 SceneObjectGroupsByFullID.Clear();
@@ -157,11 +161,9 @@ namespace OpenSim.Region.Framework.Scenes
157 161
158 protected internal void UpdatePresences() 162 protected internal void UpdatePresences()
159 { 163 {
160 List<ScenePresence> updateScenePresences = GetScenePresences(); 164 ScenePresence[] updateScenePresences = GetScenePresences();
161 foreach (ScenePresence pres in updateScenePresences) 165 for (int i = 0; i < updateScenePresences.Length; i++)
162 { 166 updateScenePresences[i].Update();
163 pres.Update();
164 }
165 } 167 }
166 168
167 protected internal float UpdatePhysics(double elapsed) 169 protected internal float UpdatePhysics(double elapsed)
@@ -190,15 +192,9 @@ namespace OpenSim.Region.Framework.Scenes
190 192
191 protected internal void UpdateScenePresenceMovement() 193 protected internal void UpdateScenePresenceMovement()
192 { 194 {
193 List<ScenePresence> moveEntities = GetScenePresences(); 195 ScenePresence[] moveEntities = GetScenePresences();
194 196 for (int i = 0; i < moveEntities.Length; i++)
195 foreach (EntityBase entity in moveEntities) 197 moveEntities[i].UpdateMovement();
196 {
197 //cfk. This throws occaisional exceptions on a heavily used region
198 //and I added this null check to try to preclude the exception.
199 if (entity != null)
200 entity.UpdateMovement();
201 }
202 } 198 }
203 199
204 #endregion 200 #endregion
@@ -645,9 +641,34 @@ namespace OpenSim.Region.Framework.Scenes
645 641
646 Entities[presence.UUID] = presence; 642 Entities[presence.UUID] = presence;
647 643
648 lock (ScenePresences) 644 lock (m_scenePresences)
649 { 645 {
650 ScenePresences[presence.UUID] = presence; 646 if (!m_scenePresences.ContainsKey(presence.UUID))
647 {
648 m_scenePresences.Add(presence.UUID, presence);
649
650 // Create a new array of ScenePresence references
651 int oldLength = m_scenePresenceArray.Length;
652 ScenePresence[] newArray = new ScenePresence[oldLength + 1];
653 Array.Copy(m_scenePresenceArray, newArray, oldLength);
654 newArray[oldLength] = presence;
655 m_scenePresenceArray = newArray;
656 }
657 else
658 {
659 m_scenePresences[presence.UUID] = presence;
660
661 // Do a linear search through the array of ScenePresence references
662 // and update the modified entry
663 for (int i = 0; i < m_scenePresenceArray.Length; i++)
664 {
665 if (m_scenePresenceArray[i].UUID == presence.UUID)
666 {
667 m_scenePresenceArray[i] = presence;
668 break;
669 }
670 }
671 }
651 } 672 }
652 } 673 }
653 674
@@ -663,16 +684,30 @@ namespace OpenSim.Region.Framework.Scenes
663 agentID); 684 agentID);
664 } 685 }
665 686
666 lock (ScenePresences) 687 lock (m_scenePresences)
667 { 688 {
668 if (!ScenePresences.Remove(agentID)) 689 if (m_scenePresences.Remove(agentID))
690 {
691 // Copy all of the elements from the previous array
692 // into the new array except the removed element
693 int oldLength = m_scenePresenceArray.Length;
694 ScenePresence[] newArray = new ScenePresence[oldLength - 1];
695 int j = 0;
696 for (int i = 0; i < m_scenePresenceArray.Length; i++)
697 {
698 ScenePresence presence = m_scenePresenceArray[i];
699 if (presence.UUID != agentID)
700 {
701 newArray[j] = presence;
702 ++j;
703 }
704 }
705 m_scenePresenceArray = newArray;
706 }
707 else
669 { 708 {
670 m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); 709 m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
671 } 710 }
672// else
673// {
674// m_log.InfoFormat("[SCENE] Removed scene presence {0} from scene presences list", agentID);
675// }
676 } 711 }
677 } 712 }
678 713
@@ -704,20 +739,21 @@ namespace OpenSim.Region.Framework.Scenes
704 739
705 public void RecalculateStats() 740 public void RecalculateStats()
706 { 741 {
707 List<ScenePresence> SPList = GetScenePresences(); 742 ScenePresence[] presences = GetScenePresences();
708 int rootcount = 0; 743 int rootcount = 0;
709 int childcount = 0; 744 int childcount = 0;
710 745
711 foreach (ScenePresence user in SPList) 746 for (int i = 0; i < presences.Length; i++)
712 { 747 {
748 ScenePresence user = presences[i];
713 if (user.IsChildAgent) 749 if (user.IsChildAgent)
714 childcount++; 750 ++childcount;
715 else 751 else
716 rootcount++; 752 ++rootcount;
717 } 753 }
754
718 m_numRootAgents = rootcount; 755 m_numRootAgents = rootcount;
719 m_numChildAgents = childcount; 756 m_numChildAgents = childcount;
720
721 } 757 }
722 758
723 public int GetChildAgentCount() 759 public int GetChildAgentCount()
@@ -767,12 +803,9 @@ namespace OpenSim.Region.Framework.Scenes
767 /// locking is required to iterate over it. 803 /// locking is required to iterate over it.
768 /// </summary> 804 /// </summary>
769 /// <returns></returns> 805 /// <returns></returns>
770 protected internal List<ScenePresence> GetScenePresences() 806 protected internal ScenePresence[] GetScenePresences()
771 { 807 {
772 lock (ScenePresences) 808 return m_scenePresenceArray;
773 {
774 return new List<ScenePresence>(ScenePresences.Values);
775 }
776 } 809 }
777 810
778 protected internal List<ScenePresence> GetAvatars() 811 protected internal List<ScenePresence> GetAvatars()
@@ -817,14 +850,13 @@ namespace OpenSim.Region.Framework.Scenes
817 // No locking of scene presences here since we're passing back a list... 850 // No locking of scene presences here since we're passing back a list...
818 851
819 List<ScenePresence> result = new List<ScenePresence>(); 852 List<ScenePresence> result = new List<ScenePresence>();
820 List<ScenePresence> ScenePresencesList = GetScenePresences(); 853 ScenePresence[] scenePresences = GetScenePresences();
821 854
822 foreach (ScenePresence avatar in ScenePresencesList) 855 for (int i = 0; i < scenePresences.Length; i++)
823 { 856 {
857 ScenePresence avatar = scenePresences[i];
824 if (filter(avatar)) 858 if (filter(avatar))
825 {
826 result.Add(avatar); 859 result.Add(avatar);
827 }
828 } 860 }
829 861
830 return result; 862 return result;
@@ -839,9 +871,9 @@ namespace OpenSim.Region.Framework.Scenes
839 { 871 {
840 ScenePresence sp; 872 ScenePresence sp;
841 873
842 lock (ScenePresences) 874 lock (m_scenePresences)
843 { 875 {
844 ScenePresences.TryGetValue(agentID, out sp); 876 m_scenePresences.TryGetValue(agentID, out sp);
845 } 877 }
846 878
847 return sp; 879 return sp;
@@ -1000,48 +1032,24 @@ namespace OpenSim.Region.Framework.Scenes
1000 1032
1001 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) 1033 protected internal bool TryGetAvatar(UUID avatarId, out ScenePresence avatar)
1002 { 1034 {
1003 ScenePresence presence; 1035 lock (m_scenePresences)
1004 1036 return m_scenePresences.TryGetValue(avatarId, out avatar);
1005 lock (ScenePresences)
1006 {
1007 if (ScenePresences.TryGetValue(avatarId, out presence))
1008 {
1009 avatar = presence;
1010 return true;
1011
1012 //if (!presence.IsChildAgent)
1013 //{
1014 // avatar = presence;
1015 // return true;
1016 //}
1017 //else
1018 //{
1019 // m_log.WarnFormat(
1020 // "[INNER SCENE]: Requested avatar {0} could not be found in scene {1} since it is only registered as a child agent!",
1021 // avatarId, m_parentScene.RegionInfo.RegionName);
1022 //}
1023 }
1024 }
1025
1026 avatar = null;
1027 return false;
1028 } 1037 }
1029 1038
1030 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) 1039 protected internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
1031 { 1040 {
1032 lock (ScenePresences) 1041 ScenePresence[] presences = GetScenePresences();
1042
1043 for (int i = 0; i < presences.Length; i++)
1033 { 1044 {
1034 foreach (ScenePresence presence in ScenePresences.Values) 1045 ScenePresence presence = presences[i];
1046
1047 if (!presence.IsChildAgent)
1035 { 1048 {
1036 if (!presence.IsChildAgent) 1049 if (String.Compare(avatarName, presence.ControllingClient.Name, true) == 0)
1037 { 1050 {
1038 string name = presence.ControllingClient.Name; 1051 avatar = presence;
1039 1052 return true;
1040 if (String.Compare(avatarName, name, true) == 0)
1041 {
1042 avatar = presence;
1043 return true;
1044 }
1045 } 1053 }
1046 } 1054 }
1047 } 1055 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index 3097929..dfaa7ea 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -411,41 +411,46 @@ namespace OpenSim.Region.Framework.Scenes
411 /// <param name="newDebug"></param> 411 /// <param name="newDebug"></param>
412 public void SetDebugPacketLevelOnCurrentScene(int newDebug) 412 public void SetDebugPacketLevelOnCurrentScene(int newDebug)
413 { 413 {
414 ForEachCurrentScene(delegate(Scene scene) 414 ForEachCurrentScene(
415 { 415 delegate(Scene scene)
416 List<ScenePresence> scenePresences = scene.GetScenePresences(); 416 {
417 ScenePresence[] scenePresences = scene.GetScenePresences();
418
419 for (int i = 0; i < scenePresences.Length; i++)
420 {
421 ScenePresence scenePresence = scenePresences[i];
417 422
418 foreach (ScenePresence scenePresence in scenePresences) 423 if (!scenePresence.IsChildAgent)
419 { 424 {
420 if (!scenePresence.IsChildAgent) 425 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}",
421 { 426 scenePresence.Firstname,
422 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}", 427 scenePresence.Lastname,
423 scenePresence.Firstname, 428 newDebug);
424 scenePresence.Lastname,
425 newDebug);
426 429
427 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug); 430 scenePresence.ControllingClient.SetDebugPacketLevel(newDebug);
428 } 431 }
429 } 432 }
430 }); 433 }
434 );
431 } 435 }
432 436
433 public List<ScenePresence> GetCurrentSceneAvatars() 437 public List<ScenePresence> GetCurrentSceneAvatars()
434 { 438 {
435 List<ScenePresence> avatars = new List<ScenePresence>(); 439 List<ScenePresence> avatars = new List<ScenePresence>();
436 440
437 ForEachCurrentScene(delegate(Scene scene) 441 ForEachCurrentScene(
438 { 442 delegate(Scene scene)
439 List<ScenePresence> scenePresences = scene.GetScenePresences();
440
441 foreach (ScenePresence scenePresence in scenePresences)
442 { 443 {
443 if (!scenePresence.IsChildAgent) 444 ScenePresence[] scenePresences = scene.GetScenePresences();
445
446 for (int i = 0; i < scenePresences.Length; i++)
444 { 447 {
445 avatars.Add(scenePresence); 448 ScenePresence scenePresence = scenePresences[i];
449 if (!scenePresence.IsChildAgent)
450 avatars.Add(scenePresence);
446 } 451 }
447 } 452 }
448 }); 453 );
449 454
450 return avatars; 455 return avatars;
451 } 456 }
@@ -456,7 +461,7 @@ namespace OpenSim.Region.Framework.Scenes
456 461
457 ForEachCurrentScene(delegate(Scene scene) 462 ForEachCurrentScene(delegate(Scene scene)
458 { 463 {
459 List<ScenePresence> scenePresences = scene.GetScenePresences(); 464 ScenePresence[] scenePresences = scene.GetScenePresences();
460 presences.AddRange(scenePresences); 465 presences.AddRange(scenePresences);
461 }); 466 });
462 467
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fff807a..ab7abbe 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -493,8 +493,8 @@ namespace OpenSim.Region.Framework.Scenes
493 493
494 public Vector3 GroupScale() 494 public Vector3 GroupScale()
495 { 495 {
496 Vector3 minScale = new Vector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize); 496 Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
497 Vector3 maxScale = new Vector3(0f,0f,0f); 497 Vector3 maxScale = Vector3.Zero;
498 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); 498 Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
499 499
500 lock (m_parts) 500 lock (m_parts)
@@ -577,7 +577,6 @@ namespace OpenSim.Region.Framework.Scenes
577 { 577 {
578 foreach (SceneObjectPart part in m_parts.Values) 578 foreach (SceneObjectPart part in m_parts.Values)
579 { 579 {
580
581 Vector3 worldPos = part.GetWorldPosition(); 580 Vector3 worldPos = part.GetWorldPosition();
582 Vector3 offset = worldPos - AbsolutePosition; 581 Vector3 offset = worldPos - AbsolutePosition;
583 Quaternion worldRot; 582 Quaternion worldRot;
@@ -1182,8 +1181,8 @@ namespace OpenSim.Region.Framework.Scenes
1182 { 1181 {
1183// part.Inventory.RemoveScriptInstances(); 1182// part.Inventory.RemoveScriptInstances();
1184 1183
1185 List<ScenePresence> avatars = Scene.GetScenePresences(); 1184 ScenePresence[] avatars = Scene.GetScenePresences();
1186 for (int i = 0; i < avatars.Count; i++) 1185 for (int i = 0; i < avatars.Length; i++)
1187 { 1186 {
1188 if (avatars[i].ParentID == LocalId) 1187 if (avatars[i].ParentID == LocalId)
1189 { 1188 {
@@ -1335,7 +1334,7 @@ namespace OpenSim.Region.Framework.Scenes
1335 (parcel.LandData.GroupID != GroupID || 1334 (parcel.LandData.GroupID != GroupID ||
1336 parcel.LandData.GroupID == UUID.Zero)) 1335 parcel.LandData.GroupID == UUID.Zero))
1337 { 1336 {
1338 if ((DateTime.Now - RootPart.Rezzed).TotalMinutes > 1337 if ((DateTime.UtcNow - RootPart.Rezzed).TotalMinutes >
1339 parcel.LandData.OtherCleanTime) 1338 parcel.LandData.OtherCleanTime)
1340 { 1339 {
1341 DetachFromBackup(); 1340 DetachFromBackup();
@@ -1480,8 +1479,8 @@ namespace OpenSim.Region.Framework.Scenes
1480 dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( 1479 dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape(
1481 dupe.RootPart.Name, 1480 dupe.RootPart.Name,
1482 pbs, 1481 pbs,
1483 new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, dupe.RootPart.AbsolutePosition.Z), 1482 dupe.RootPart.AbsolutePosition,
1484 new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), 1483 dupe.RootPart.Scale,
1485 dupe.RootPart.RotationOffset, 1484 dupe.RootPart.RotationOffset,
1486 dupe.RootPart.PhysActor.IsPhysical); 1485 dupe.RootPart.PhysActor.IsPhysical);
1487 1486
@@ -1596,7 +1595,7 @@ namespace OpenSim.Region.Framework.Scenes
1596 */ 1595 */
1597 } 1596 }
1598 1597
1599 public void applyImpulse(PhysicsVector impulse) 1598 public void applyImpulse(Vector3 impulse)
1600 { 1599 {
1601 // We check if rootpart is null here because scripts don't delete if you delete the host. 1600 // We check if rootpart is null here because scripts don't delete if you delete the host.
1602 // This means that unfortunately, we can pass a null physics actor to Simulate! 1601 // This means that unfortunately, we can pass a null physics actor to Simulate!
@@ -1623,7 +1622,7 @@ namespace OpenSim.Region.Framework.Scenes
1623 } 1622 }
1624 } 1623 }
1625 1624
1626 public void applyAngularImpulse(PhysicsVector impulse) 1625 public void applyAngularImpulse(Vector3 impulse)
1627 { 1626 {
1628 // We check if rootpart is null here because scripts don't delete if you delete the host. 1627 // We check if rootpart is null here because scripts don't delete if you delete the host.
1629 // This means that unfortunately, we can pass a null physics actor to Simulate! 1628 // This means that unfortunately, we can pass a null physics actor to Simulate!
@@ -1642,7 +1641,7 @@ namespace OpenSim.Region.Framework.Scenes
1642 } 1641 }
1643 } 1642 }
1644 1643
1645 public void setAngularImpulse(PhysicsVector impulse) 1644 public void setAngularImpulse(Vector3 impulse)
1646 { 1645 {
1647 // We check if rootpart is null here because scripts don't delete if you delete the host. 1646 // We check if rootpart is null here because scripts don't delete if you delete the host.
1648 // This means that unfortunately, we can pass a null physics actor to Simulate! 1647 // This means that unfortunately, we can pass a null physics actor to Simulate!
@@ -1673,8 +1672,8 @@ namespace OpenSim.Region.Framework.Scenes
1673 { 1672 {
1674 if (!IsAttachment) 1673 if (!IsAttachment)
1675 { 1674 {
1676 PhysicsVector torque = rootpart.PhysActor.Torque; 1675 Vector3 torque = rootpart.PhysActor.Torque;
1677 return new Vector3(torque.X, torque.Y, torque.Z); 1676 return torque;
1678 } 1677 }
1679 } 1678 }
1680 } 1679 }
@@ -1707,7 +1706,7 @@ namespace OpenSim.Region.Framework.Scenes
1707 { 1706 {
1708 if (rootpart.PhysActor != null) 1707 if (rootpart.PhysActor != null)
1709 { 1708 {
1710 rootpart.PhysActor.PIDTarget = new PhysicsVector(target.X, target.Y, target.Z); 1709 rootpart.PhysActor.PIDTarget = target;
1711 rootpart.PhysActor.PIDTau = tau; 1710 rootpart.PhysActor.PIDTau = tau;
1712 rootpart.PhysActor.PIDActive = true; 1711 rootpart.PhysActor.PIDActive = true;
1713 } 1712 }
@@ -2414,7 +2413,7 @@ namespace OpenSim.Region.Framework.Scenes
2414 if (m_rootPart.PhysActor.IsPhysical) 2413 if (m_rootPart.PhysActor.IsPhysical)
2415 { 2414 {
2416 Vector3 llmoveforce = pos - AbsolutePosition; 2415 Vector3 llmoveforce = pos - AbsolutePosition;
2417 PhysicsVector grabforce = new PhysicsVector(llmoveforce.X, llmoveforce.Y, llmoveforce.Z); 2416 Vector3 grabforce = llmoveforce;
2418 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; 2417 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass;
2419 m_rootPart.PhysActor.AddForce(grabforce,true); 2418 m_rootPart.PhysActor.AddForce(grabforce,true);
2420 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2419 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
@@ -2519,7 +2518,7 @@ namespace OpenSim.Region.Framework.Scenes
2519 rotationAxis.Normalize(); 2518 rotationAxis.Normalize();
2520 2519
2521 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); 2520 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
2522 PhysicsVector spinforce = new PhysicsVector(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); 2521 Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z);
2523 spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor 2522 spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor
2524 m_rootPart.PhysActor.AddAngularForce(spinforce,true); 2523 m_rootPart.PhysActor.AddAngularForce(spinforce,true);
2525 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2524 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
@@ -2746,8 +2745,7 @@ namespace OpenSim.Region.Framework.Scenes
2746 if (scale.Z > m_scene.m_maxPhys) 2745 if (scale.Z > m_scene.m_maxPhys)
2747 scale.Z = m_scene.m_maxPhys; 2746 scale.Z = m_scene.m_maxPhys;
2748 } 2747 }
2749 part.PhysActor.Size = 2748 part.PhysActor.Size = scale;
2750 new PhysicsVector(scale.X, scale.Y, scale.Z);
2751 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2749 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2752 } 2750 }
2753 //if (part.UUID != m_rootPart.UUID) 2751 //if (part.UUID != m_rootPart.UUID)
@@ -2891,8 +2889,7 @@ namespace OpenSim.Region.Framework.Scenes
2891 2889
2892 if (part.PhysActor != null) 2890 if (part.PhysActor != null)
2893 { 2891 {
2894 part.PhysActor.Size = 2892 part.PhysActor.Size = prevScale;
2895 new PhysicsVector(prevScale.X, prevScale.Y, prevScale.Z);
2896 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2893 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2897 } 2894 }
2898 2895
@@ -3405,6 +3402,8 @@ namespace OpenSim.Region.Framework.Scenes
3405 return GetPriorityByDistance(client); 3402 return GetPriorityByDistance(client);
3406 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: 3403 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3407 return GetPriorityBySimpleAngularDistance(client); 3404 return GetPriorityBySimpleAngularDistance(client);
3405 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3406 return GetPriorityByFrontBack(client);
3408 default: 3407 default:
3409 throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); 3408 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3410 } 3409 }
@@ -3437,6 +3436,16 @@ namespace OpenSim.Region.Framework.Scenes
3437 return double.NaN; 3436 return double.NaN;
3438 } 3437 }
3439 3438
3439 private double GetPriorityByFrontBack(IClientAPI client)
3440 {
3441 ScenePresence presence = Scene.GetScenePresence(client.AgentId);
3442 if (presence != null)
3443 {
3444 return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis);
3445 }
3446 return double.NaN;
3447 }
3448
3440 public double GetPriorityByDistance(Vector3 position) 3449 public double GetPriorityByDistance(Vector3 position)
3441 { 3450 {
3442 return Vector3.Distance(AbsolutePosition, position); 3451 return Vector3.Distance(AbsolutePosition, position);
@@ -3466,5 +3475,21 @@ namespace OpenSim.Region.Framework.Scenes
3466 else 3475 else
3467 return double.MinValue; 3476 return double.MinValue;
3468 } 3477 }
3478
3479 public double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis)
3480 {
3481 // Distance
3482 double priority = Vector3.Distance(camPosition, AbsolutePosition);
3483
3484 // Scale
3485 //priority -= GroupScale().Length();
3486
3487 // Plane equation
3488 float d = -Vector3.Dot(camPosition, camAtAxis);
3489 float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d;
3490 if (p < 0.0f) priority *= 2.0f;
3491
3492 return priority;
3493 }
3469 } 3494 }
3470} 3495}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 5f46f6f..7d889ee 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -102,16 +102,16 @@ namespace OpenSim.Region.Framework.Scenes
102 102
103 #region Fields 103 #region Fields
104 104
105 public bool AllowedDrop = false; 105 public bool AllowedDrop;
106 106
107 [XmlIgnore] 107 [XmlIgnore]
108 public bool DIE_AT_EDGE = false; 108 public bool DIE_AT_EDGE;
109 109
110 // TODO: This needs to be persisted in next XML version update! 110 // TODO: This needs to be persisted in next XML version update!
111 [XmlIgnore] 111 [XmlIgnore]
112 public int[] PayPrice = {-2,-2,-2,-2,-2}; 112 public readonly int[] PayPrice = {-2,-2,-2,-2,-2};
113 [XmlIgnore] 113 [XmlIgnore]
114 public PhysicsActor PhysActor = null; 114 public PhysicsActor PhysActor;
115 115
116 //Xantor 20080528 Sound stuff: 116 //Xantor 20080528 Sound stuff:
117 // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. 117 // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet.
@@ -130,55 +130,56 @@ namespace OpenSim.Region.Framework.Scenes
130 public double SoundRadius; 130 public double SoundRadius;
131 131
132 [XmlIgnore] 132 [XmlIgnore]
133 public uint TimeStampFull = 0; 133 public uint TimeStampFull;
134 134
135 [XmlIgnore] 135 [XmlIgnore]
136 public uint TimeStampLastActivity = 0; // Will be used for AutoReturn 136 public uint TimeStampLastActivity; // Will be used for AutoReturn
137 137
138 [XmlIgnore] 138 [XmlIgnore]
139 public uint TimeStampTerse = 0; 139 public uint TimeStampTerse;
140 140
141 [XmlIgnore] 141 [XmlIgnore]
142 public UUID FromItemID = UUID.Zero; 142 public UUID FromItemID;
143 143
144 /// <value> 144 /// <value>
145 /// The UUID of the user inventory item from which this object was rezzed if this is a root part. 145 /// The UUID of the user inventory item from which this object was rezzed if this is a root part.
146 /// If UUID.Zero then either this is not a root part or there is no connection with a user inventory item. 146 /// If UUID.Zero then either this is not a root part or there is no connection with a user inventory item.
147 /// </value> 147 /// </value>
148 private UUID m_fromUserInventoryItemID = UUID.Zero; 148 private UUID m_fromUserInventoryItemID;
149 149
150 [XmlIgnore] 150 [XmlIgnore]
151 public UUID FromUserInventoryItemID 151 public UUID FromUserInventoryItemID
152 { 152 {
153 get { return m_fromUserInventoryItemID; } 153 get { return m_fromUserInventoryItemID; }
154 } 154 }
155 155
156 [XmlIgnore] 156 [XmlIgnore]
157 public bool IsAttachment = false; 157 public bool IsAttachment;
158 158
159 [XmlIgnore] 159 [XmlIgnore]
160 public scriptEvents AggregateScriptEvents = 0; 160 public scriptEvents AggregateScriptEvents;
161 161
162 [XmlIgnore] 162 [XmlIgnore]
163 public UUID AttachedAvatar = UUID.Zero; 163 public UUID AttachedAvatar;
164 164
165 [XmlIgnore] 165 [XmlIgnore]
166 public Vector3 AttachedPos = Vector3.Zero; 166 public Vector3 AttachedPos;
167 167
168 [XmlIgnore] 168 [XmlIgnore]
169 public uint AttachmentPoint = (byte)0; 169 public uint AttachmentPoint;
170 170
171 [XmlIgnore] 171 [XmlIgnore]
172 public PhysicsVector RotationAxis = new PhysicsVector(1f,1f,1f); 172 public Vector3 RotationAxis = Vector3.One;
173 173
174 [XmlIgnore] 174 [XmlIgnore]
175 public bool VolumeDetectActive = false; // XmlIgnore set to avoid problems with persistance until I come to care for this 175 public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this
176 // Certainly this must be a persistant setting finally 176 // Certainly this must be a persistant setting finally
177 177
178 [XmlIgnore] 178 [XmlIgnore]
179 public bool IsWaitingForFirstSpinUpdatePacket = false; 179 public bool IsWaitingForFirstSpinUpdatePacket;
180
180 [XmlIgnore] 181 [XmlIgnore]
181 public Quaternion SpinOldOrientation = new Quaternion(); 182 public Quaternion SpinOldOrientation = Quaternion.Identity;
182 183
183 /// <summary> 184 /// <summary>
184 /// This part's inventory 185 /// This part's inventory
@@ -191,34 +192,32 @@ namespace OpenSim.Region.Framework.Scenes
191 protected SceneObjectPartInventory m_inventory; 192 protected SceneObjectPartInventory m_inventory;
192 193
193 [XmlIgnore] 194 [XmlIgnore]
194 public bool Undoing = false; 195 public bool Undoing;
195 196
196 [XmlIgnore] 197 [XmlIgnore]
197 private PrimFlags LocalFlags = 0; 198 private PrimFlags LocalFlags;
198 [XmlIgnore] 199 [XmlIgnore]
199 private float m_damage = -1.0f; 200 private float m_damage = -1.0f;
200 private byte[] m_TextureAnimation; 201 private byte[] m_TextureAnimation;
201 private byte m_clickAction = 0; 202 private byte m_clickAction;
202 private Color m_color = Color.Black; 203 private Color m_color = Color.Black;
203 private string m_description = String.Empty; 204 private string m_description = String.Empty;
204 private readonly List<uint> m_lastColliders = new List<uint>(); 205 private readonly List<uint> m_lastColliders = new List<uint>();
205 // private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero; 206 private int m_linkNum;
206 private int m_linkNum = 0;
207 [XmlIgnore] 207 [XmlIgnore]
208 private int m_scriptAccessPin = 0; 208 private int m_scriptAccessPin;
209 [XmlIgnore] 209 [XmlIgnore]
210 private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); 210 private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>();
211 private string m_sitName = String.Empty; 211 private string m_sitName = String.Empty;
212 private Quaternion m_sitTargetOrientation = Quaternion.Identity; 212 private Quaternion m_sitTargetOrientation = Quaternion.Identity;
213 private Vector3 m_sitTargetPosition = Vector3.Zero; 213 private Vector3 m_sitTargetPosition;
214 private string m_sitAnimation = "SIT"; 214 private string m_sitAnimation = "SIT";
215 private string m_text = String.Empty; 215 private string m_text = String.Empty;
216 private string m_touchName = String.Empty; 216 private string m_touchName = String.Empty;
217 private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5); 217 private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5);
218 private UUID _creatorID; 218 private UUID _creatorID;
219 219
220 220 private bool m_passTouches;
221 private bool m_passTouches = false;
222 221
223 /// <summary> 222 /// <summary>
224 /// Only used internally to schedule client updates. 223 /// Only used internally to schedule client updates.
@@ -236,28 +235,34 @@ namespace OpenSim.Region.Framework.Scenes
236 //unkown if this will be kept, added as a way of removing the group position from the group class 235 //unkown if this will be kept, added as a way of removing the group position from the group class
237 protected Vector3 m_groupPosition; 236 protected Vector3 m_groupPosition;
238 protected uint m_localId; 237 protected uint m_localId;
239 protected Material m_material = (Material)3; // Wood 238 protected Material m_material = OpenMetaverse.Material.Wood;
240 protected string m_name; 239 protected string m_name;
241 protected Vector3 m_offsetPosition; 240 protected Vector3 m_offsetPosition;
242 241
243 // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out. 242 // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out.
244 protected SceneObjectGroup m_parentGroup; 243 protected SceneObjectGroup m_parentGroup;
245 protected byte[] m_particleSystem = new byte[0]; 244 protected byte[] m_particleSystem = Utils.EmptyBytes;
246 protected ulong m_regionHandle; 245 protected ulong m_regionHandle;
247 protected Quaternion m_rotationOffset; 246 protected Quaternion m_rotationOffset;
248 protected PrimitiveBaseShape m_shape = null; 247 protected PrimitiveBaseShape m_shape;
249 protected UUID m_uuid; 248 protected UUID m_uuid;
250 protected Vector3 m_velocity; 249 protected Vector3 m_velocity;
251 250
251 protected Vector3 m_lastPosition;
252 protected Quaternion m_lastRotation;
253 protected Vector3 m_lastVelocity;
254 protected Vector3 m_lastAcceleration;
255 protected Vector3 m_lastAngularVelocity;
256
252 // TODO: Those have to be changed into persistent properties at some later point, 257 // TODO: Those have to be changed into persistent properties at some later point,
253 // or sit-camera on vehicles will break on sim-crossing. 258 // or sit-camera on vehicles will break on sim-crossing.
254 private Vector3 m_cameraEyeOffset = new Vector3(0.0f, 0.0f, 0.0f); 259 private Vector3 m_cameraEyeOffset;
255 private Vector3 m_cameraAtOffset = new Vector3(0.0f, 0.0f, 0.0f); 260 private Vector3 m_cameraAtOffset;
256 private bool m_forceMouselook = false; 261 private bool m_forceMouselook;
257 262
258 // TODO: Collision sound should have default. 263 // TODO: Collision sound should have default.
259 private UUID m_collisionSound = UUID.Zero; 264 private UUID m_collisionSound;
260 private float m_collisionSoundVolume = 0.0f; 265 private float m_collisionSoundVolume;
261 266
262 #endregion Fields 267 #endregion Fields
263 268
@@ -269,9 +274,9 @@ namespace OpenSim.Region.Framework.Scenes
269 public SceneObjectPart() 274 public SceneObjectPart()
270 { 275 {
271 // It's not necessary to persist this 276 // It's not necessary to persist this
272 m_TextureAnimation = new byte[0]; 277 m_TextureAnimation = Utils.EmptyBytes;
273 m_particleSystem = new byte[0]; 278 m_particleSystem = Utils.EmptyBytes;
274 Rezzed = DateTime.Now; 279 Rezzed = DateTime.UtcNow;
275 280
276 m_inventory = new SceneObjectPartInventory(this); 281 m_inventory = new SceneObjectPartInventory(this);
277 } 282 }
@@ -290,8 +295,8 @@ namespace OpenSim.Region.Framework.Scenes
290 { 295 {
291 m_name = "Primitive"; 296 m_name = "Primitive";
292 297
293 Rezzed = DateTime.Now; 298 Rezzed = DateTime.UtcNow;
294 _creationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 299 _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
295 _ownerID = ownerID; 300 _ownerID = ownerID;
296 _creatorID = _ownerID; 301 _creatorID = _ownerID;
297 _lastOwnerID = UUID.Zero; 302 _lastOwnerID = UUID.Zero;
@@ -299,19 +304,19 @@ namespace OpenSim.Region.Framework.Scenes
299 Shape = shape; 304 Shape = shape;
300 // Todo: Add More Object Parameter from above! 305 // Todo: Add More Object Parameter from above!
301 _ownershipCost = 0; 306 _ownershipCost = 0;
302 _objectSaleType = (byte) 0; 307 _objectSaleType = 0;
303 _salePrice = 0; 308 _salePrice = 0;
304 _category = (uint) 0; 309 _category = 0;
305 _lastOwnerID = _creatorID; 310 _lastOwnerID = _creatorID;
306 // End Todo: /// 311 // End Todo: ///
307 GroupPosition = groupPosition; 312 GroupPosition = groupPosition;
308 OffsetPosition = offsetPosition; 313 OffsetPosition = offsetPosition;
309 RotationOffset = rotationOffset; 314 RotationOffset = rotationOffset;
310 Velocity = new Vector3(0, 0, 0); 315 Velocity = Vector3.Zero;
311 AngularVelocity = new Vector3(0, 0, 0); 316 AngularVelocity = Vector3.Zero;
312 Acceleration = new Vector3(0, 0, 0); 317 Acceleration = Vector3.Zero;
313 m_TextureAnimation = new byte[0]; 318 m_TextureAnimation = Utils.EmptyBytes;
314 m_particleSystem = new byte[0]; 319 m_particleSystem = Utils.EmptyBytes;
315 320
316 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, 321 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
317 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from 322 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
@@ -532,13 +537,13 @@ namespace OpenSim.Region.Framework.Scenes
532 // Root prim actually goes at Position 537 // Root prim actually goes at Position
533 if (_parentID == 0) 538 if (_parentID == 0)
534 { 539 {
535 PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); 540 PhysActor.Position = value;
536 } 541 }
537 else 542 else
538 { 543 {
539 // To move the child prim in respect to the group position and rotation we have to calculate 544 // To move the child prim in respect to the group position and rotation we have to calculate
540 Vector3 resultingposition = GetWorldPosition(); 545 Vector3 resultingposition = GetWorldPosition();
541 PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); 546 PhysActor.Position = resultingposition;
542 Quaternion resultingrot = GetWorldRotation(); 547 Quaternion resultingrot = GetWorldRotation();
543 PhysActor.Orientation = resultingrot; 548 PhysActor.Orientation = resultingrot;
544 } 549 }
@@ -580,7 +585,7 @@ namespace OpenSim.Region.Framework.Scenes
580 if (_parentID != 0 && PhysActor != null) 585 if (_parentID != 0 && PhysActor != null)
581 { 586 {
582 Vector3 resultingposition = GetWorldPosition(); 587 Vector3 resultingposition = GetWorldPosition();
583 PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); 588 PhysActor.Position = resultingposition;
584 Quaternion resultingrot = GetWorldRotation(); 589 Quaternion resultingrot = GetWorldRotation();
585 PhysActor.Orientation = resultingrot; 590 PhysActor.Orientation = resultingrot;
586 591
@@ -670,7 +675,7 @@ namespace OpenSim.Region.Framework.Scenes
670 { 675 {
671 if (PhysActor.IsPhysical) 676 if (PhysActor.IsPhysical)
672 { 677 {
673 PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); 678 PhysActor.Velocity = value;
674 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 679 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
675 } 680 }
676 } 681 }
@@ -812,7 +817,7 @@ if (m_shape != null) {
812 { 817 {
813 if (m_parentGroup.Scene.PhysicsScene != null) 818 if (m_parentGroup.Scene.PhysicsScene != null)
814 { 819 {
815 PhysActor.Size = new PhysicsVector(m_shape.Scale.X, m_shape.Scale.Y, m_shape.Scale.Z); 820 PhysActor.Size = m_shape.Scale;
816 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); 821 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
817 } 822 }
818 } 823 }
@@ -1077,8 +1082,8 @@ if (m_shape != null) {
1077 1082
1078 private void SendObjectPropertiesToClient(UUID AgentID) 1083 private void SendObjectPropertiesToClient(UUID AgentID)
1079 { 1084 {
1080 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 1085 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1081 for (int i = 0; i < avatars.Count; i++) 1086 for (int i = 0; i < avatars.Length; i++)
1082 { 1087 {
1083 // Ugly reference :( 1088 // Ugly reference :(
1084 if (avatars[i].UUID == AgentID) 1089 if (avatars[i].UUID == AgentID)
@@ -1140,8 +1145,8 @@ if (m_shape != null) {
1140 /// </summary> 1145 /// </summary>
1141 public void AddFullUpdateToAllAvatars() 1146 public void AddFullUpdateToAllAvatars()
1142 { 1147 {
1143 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 1148 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1144 for (int i = 0; i < avatars.Count; i++) 1149 for (int i = 0; i < avatars.Length; i++)
1145 { 1150 {
1146 avatars[i].SceneViewer.QueuePartForUpdate(this); 1151 avatars[i].SceneViewer.QueuePartForUpdate(this);
1147 } 1152 }
@@ -1165,8 +1170,8 @@ if (m_shape != null) {
1165 /// Terse updates 1170 /// Terse updates
1166 public void AddTerseUpdateToAllAvatars() 1171 public void AddTerseUpdateToAllAvatars()
1167 { 1172 {
1168 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 1173 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
1169 for (int i = 0; i < avatars.Count; i++) 1174 for (int i = 0; i < avatars.Length; i++)
1170 { 1175 {
1171 avatars[i].SceneViewer.QueuePartForUpdate(this); 1176 avatars[i].SceneViewer.QueuePartForUpdate(this);
1172 } 1177 }
@@ -1220,7 +1225,7 @@ if (m_shape != null) {
1220 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> 1225 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
1221 public void ApplyImpulse(Vector3 impulsei, bool localGlobalTF) 1226 public void ApplyImpulse(Vector3 impulsei, bool localGlobalTF)
1222 { 1227 {
1223 PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); 1228 Vector3 impulse = impulsei;
1224 1229
1225 if (localGlobalTF) 1230 if (localGlobalTF)
1226 { 1231 {
@@ -1228,7 +1233,7 @@ if (m_shape != null) {
1228 Quaternion AXgrot = grot; 1233 Quaternion AXgrot = grot;
1229 Vector3 AXimpulsei = impulsei; 1234 Vector3 AXimpulsei = impulsei;
1230 Vector3 newimpulse = AXimpulsei * AXgrot; 1235 Vector3 newimpulse = AXimpulsei * AXgrot;
1231 impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); 1236 impulse = newimpulse;
1232 } 1237 }
1233 1238
1234 if (m_parentGroup != null) 1239 if (m_parentGroup != null)
@@ -1246,7 +1251,7 @@ if (m_shape != null) {
1246 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> 1251 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
1247 public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF) 1252 public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF)
1248 { 1253 {
1249 PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); 1254 Vector3 impulse = impulsei;
1250 1255
1251 if (localGlobalTF) 1256 if (localGlobalTF)
1252 { 1257 {
@@ -1254,7 +1259,7 @@ if (m_shape != null) {
1254 Quaternion AXgrot = grot; 1259 Quaternion AXgrot = grot;
1255 Vector3 AXimpulsei = impulsei; 1260 Vector3 AXimpulsei = impulsei;
1256 Vector3 newimpulse = AXimpulsei * AXgrot; 1261 Vector3 newimpulse = AXimpulsei * AXgrot;
1257 impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); 1262 impulse = newimpulse;
1258 } 1263 }
1259 1264
1260 if (m_parentGroup != null) 1265 if (m_parentGroup != null)
@@ -1272,7 +1277,7 @@ if (m_shape != null) {
1272 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> 1277 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
1273 public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) 1278 public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF)
1274 { 1279 {
1275 PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); 1280 Vector3 impulse = impulsei;
1276 1281
1277 if (localGlobalTF) 1282 if (localGlobalTF)
1278 { 1283 {
@@ -1280,7 +1285,7 @@ if (m_shape != null) {
1280 Quaternion AXgrot = grot; 1285 Quaternion AXgrot = grot;
1281 Vector3 AXimpulsei = impulsei; 1286 Vector3 AXimpulsei = impulsei;
1282 Vector3 newimpulse = AXimpulsei * AXgrot; 1287 Vector3 newimpulse = AXimpulsei * AXgrot;
1283 impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); 1288 impulse = newimpulse;
1284 } 1289 }
1285 1290
1286 if (m_parentGroup != null) 1291 if (m_parentGroup != null)
@@ -1328,8 +1333,8 @@ if (m_shape != null) {
1328 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( 1333 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
1329 Name, 1334 Name,
1330 Shape, 1335 Shape,
1331 new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z), 1336 AbsolutePosition,
1332 new PhysicsVector(Scale.X, Scale.Y, Scale.Z), 1337 Scale,
1333 RotationOffset, 1338 RotationOffset,
1334 RigidBody); 1339 RigidBody);
1335 1340
@@ -1518,7 +1523,7 @@ if (m_shape != null) {
1518 PhysicsJoint joint; 1523 PhysicsJoint joint;
1519 1524
1520 joint = m_parentGroup.Scene.PhysicsScene.RequestJointCreation(Name, jointType, 1525 joint = m_parentGroup.Scene.PhysicsScene.RequestJointCreation(Name, jointType,
1521 new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z), 1526 AbsolutePosition,
1522 this.RotationOffset, 1527 this.RotationOffset,
1523 Description, 1528 Description,
1524 bodyNames, 1529 bodyNames,
@@ -1703,12 +1708,12 @@ if (m_shape != null) {
1703 } 1708 }
1704 } 1709 }
1705 1710
1706 public PhysicsVector GetForce() 1711 public Vector3 GetForce()
1707 { 1712 {
1708 if (PhysActor != null) 1713 if (PhysActor != null)
1709 return PhysActor.Force; 1714 return PhysActor.Force;
1710 else 1715 else
1711 return new PhysicsVector(); 1716 return Vector3.Zero;
1712 } 1717 }
1713 1718
1714 public void GetProperties(IClientAPI client) 1719 public void GetProperties(IClientAPI client)
@@ -1894,24 +1899,24 @@ if (m_shape != null) {
1894 } 1899 }
1895 else 1900 else
1896 { 1901 {
1897 List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); 1902 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences();
1898 if (avlist != null) 1903
1904 for (int i = 0; i < avlist.Length; i++)
1899 { 1905 {
1900 foreach (ScenePresence av in avlist) 1906 ScenePresence av = avlist[i];
1907
1908 if (av.LocalId == localId)
1901 { 1909 {
1902 if (av.LocalId == localId) 1910 DetectedObject detobj = new DetectedObject();
1903 { 1911 detobj.keyUUID = av.UUID;
1904 DetectedObject detobj = new DetectedObject(); 1912 detobj.nameStr = av.ControllingClient.Name;
1905 detobj.keyUUID = av.UUID; 1913 detobj.ownerUUID = av.UUID;
1906 detobj.nameStr = av.ControllingClient.Name; 1914 detobj.posVector = av.AbsolutePosition;
1907 detobj.ownerUUID = av.UUID; 1915 detobj.rotQuat = av.Rotation;
1908 detobj.posVector = av.AbsolutePosition; 1916 detobj.velVector = av.Velocity;
1909 detobj.rotQuat = av.Rotation; 1917 detobj.colliderType = 0;
1910 detobj.velVector = av.Velocity; 1918 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1911 detobj.colliderType = 0; 1919 colliding.Add(detobj);
1912 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1913 colliding.Add(detobj);
1914 }
1915 } 1920 }
1916 } 1921 }
1917 } 1922 }
@@ -1965,26 +1970,25 @@ if (m_shape != null) {
1965 } 1970 }
1966 else 1971 else
1967 { 1972 {
1968 List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); 1973 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences();
1969 if (avlist != null) 1974
1975 for (int i = 0; i < avlist.Length; i++)
1970 { 1976 {
1971 foreach (ScenePresence av in avlist) 1977 ScenePresence av = avlist[i];
1978
1979 if (av.LocalId == localId)
1972 { 1980 {
1973 if (av.LocalId == localId) 1981 DetectedObject detobj = new DetectedObject();
1974 { 1982 detobj.keyUUID = av.UUID;
1975 DetectedObject detobj = new DetectedObject(); 1983 detobj.nameStr = av.Name;
1976 detobj.keyUUID = av.UUID; 1984 detobj.ownerUUID = av.UUID;
1977 detobj.nameStr = av.Name; 1985 detobj.posVector = av.AbsolutePosition;
1978 detobj.ownerUUID = av.UUID; 1986 detobj.rotQuat = av.Rotation;
1979 detobj.posVector = av.AbsolutePosition; 1987 detobj.velVector = av.Velocity;
1980 detobj.rotQuat = av.Rotation; 1988 detobj.colliderType = 0;
1981 detobj.velVector = av.Velocity; 1989 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1982 detobj.colliderType = 0; 1990 colliding.Add(detobj);
1983 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
1984 colliding.Add(detobj);
1985 }
1986 } 1991 }
1987
1988 } 1992 }
1989 } 1993 }
1990 } 1994 }
@@ -2035,24 +2039,24 @@ if (m_shape != null) {
2035 } 2039 }
2036 else 2040 else
2037 { 2041 {
2038 List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); 2042 ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences();
2039 if (avlist != null) 2043
2044 for (int i = 0; i < avlist.Length; i++)
2040 { 2045 {
2041 foreach (ScenePresence av in avlist) 2046 ScenePresence av = avlist[i];
2047
2048 if (av.LocalId == localId)
2042 { 2049 {
2043 if (av.LocalId == localId) 2050 DetectedObject detobj = new DetectedObject();
2044 { 2051 detobj.keyUUID = av.UUID;
2045 DetectedObject detobj = new DetectedObject(); 2052 detobj.nameStr = av.Name;
2046 detobj.keyUUID = av.UUID; 2053 detobj.ownerUUID = av.UUID;
2047 detobj.nameStr = av.Name; 2054 detobj.posVector = av.AbsolutePosition;
2048 detobj.ownerUUID = av.UUID; 2055 detobj.rotQuat = av.Rotation;
2049 detobj.posVector = av.AbsolutePosition; 2056 detobj.velVector = av.Velocity;
2050 detobj.rotQuat = av.Rotation; 2057 detobj.colliderType = 0;
2051 detobj.velVector = av.Velocity; 2058 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
2052 detobj.colliderType = 0; 2059 colliding.Add(detobj);
2053 detobj.groupUUID = av.ControllingClient.ActiveGroupId;
2054 colliding.Add(detobj);
2055 }
2056 } 2060 }
2057 } 2061 }
2058 } 2062 }
@@ -2074,7 +2078,7 @@ if (m_shape != null) {
2074 } 2078 }
2075 } 2079 }
2076 2080
2077 public void PhysicsOutOfBounds(PhysicsVector pos) 2081 public void PhysicsOutOfBounds(Vector3 pos)
2078 { 2082 {
2079 m_log.Error("[PHYSICS]: Physical Object went out of bounds."); 2083 m_log.Error("[PHYSICS]: Physical Object went out of bounds.");
2080 2084
@@ -2317,8 +2321,8 @@ if (m_shape != null) {
2317 /// </summary> 2321 /// </summary>
2318 public void SendFullUpdateToAllClients() 2322 public void SendFullUpdateToAllClients()
2319 { 2323 {
2320 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2324 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2321 for (int i = 0; i < avatars.Count; i++) 2325 for (int i = 0; i < avatars.Length; i++)
2322 { 2326 {
2323 // Ugly reference :( 2327 // Ugly reference :(
2324 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, 2328 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
@@ -2328,8 +2332,8 @@ if (m_shape != null) {
2328 2332
2329 public void SendFullUpdateToAllClientsExcept(UUID agentID) 2333 public void SendFullUpdateToAllClientsExcept(UUID agentID)
2330 { 2334 {
2331 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2335 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2332 for (int i = 0; i < avatars.Count; i++) 2336 for (int i = 0; i < avatars.Length; i++)
2333 { 2337 {
2334 // Ugly reference :( 2338 // Ugly reference :(
2335 if (avatars[i].UUID != agentID) 2339 if (avatars[i].UUID != agentID)
@@ -2394,18 +2398,36 @@ if (m_shape != null) {
2394 /// </summary> 2398 /// </summary>
2395 public void SendScheduledUpdates() 2399 public void SendScheduledUpdates()
2396 { 2400 {
2397 if (m_updateFlag == 1) //some change has been made so update the clients 2401 const float VELOCITY_TOLERANCE = 0.01f;
2402 const float POSITION_TOLERANCE = 0.1f;
2403
2404 if (m_updateFlag == 1)
2398 { 2405 {
2399 AddTerseUpdateToAllAvatars(); 2406 // Throw away duplicate or insignificant updates
2400 ClearUpdateSchedule(); 2407 if (RotationOffset != m_lastRotation ||
2408 Acceleration != m_lastAcceleration ||
2409 (Velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE ||
2410 (RotationalVelocity - m_lastAngularVelocity).Length() > VELOCITY_TOLERANCE ||
2411 (OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE)
2412 {
2413 AddTerseUpdateToAllAvatars();
2414 ClearUpdateSchedule();
2401 2415
2402 // This causes the Scene to 'poll' physical objects every couple of frames 2416 // This causes the Scene to 'poll' physical objects every couple of frames
2403 // bad, so it's been replaced by an event driven method. 2417 // bad, so it's been replaced by an event driven method.
2404 //if ((ObjectFlags & (uint)PrimFlags.Physics) != 0) 2418 //if ((ObjectFlags & (uint)PrimFlags.Physics) != 0)
2405 //{ 2419 //{
2406 // Only send the constant terse updates on physical objects! 2420 // Only send the constant terse updates on physical objects!
2407 //ScheduleTerseUpdate(); 2421 //ScheduleTerseUpdate();
2408 //} 2422 //}
2423
2424 // Update the "last" values
2425 m_lastPosition = OffsetPosition;
2426 m_lastRotation = RotationOffset;
2427 m_lastVelocity = Velocity;
2428 m_lastAcceleration = Acceleration;
2429 m_lastAngularVelocity = RotationalVelocity;
2430 }
2409 } 2431 }
2410 else 2432 else
2411 { 2433 {
@@ -2472,8 +2494,8 @@ if (m_shape != null) {
2472 /// </summary> 2494 /// </summary>
2473 public void SendTerseUpdateToAllClients() 2495 public void SendTerseUpdateToAllClients()
2474 { 2496 {
2475 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2497 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2476 for (int i = 0; i < avatars.Count; i++) 2498 for (int i = 0; i < avatars.Length; i++)
2477 { 2499 {
2478 SendTerseUpdateToClient(avatars[i].ControllingClient); 2500 SendTerseUpdateToClient(avatars[i].ControllingClient);
2479 } 2501 }
@@ -2547,7 +2569,7 @@ if (m_shape != null) {
2547 } 2569 }
2548 } 2570 }
2549 2571
2550 public void SetForce(PhysicsVector force) 2572 public void SetForce(Vector3 force)
2551 { 2573 {
2552 if (PhysActor != null) 2574 if (PhysActor != null)
2553 { 2575 {
@@ -2571,7 +2593,7 @@ if (m_shape != null) {
2571 } 2593 }
2572 } 2594 }
2573 2595
2574 public void SetVehicleVectorParam(int param, PhysicsVector value) 2596 public void SetVehicleVectorParam(int param, Vector3 value)
2575 { 2597 {
2576 if (PhysActor != null) 2598 if (PhysActor != null)
2577 { 2599 {
@@ -3420,8 +3442,8 @@ if (m_shape != null) {
3420 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( 3442 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
3421 Name, 3443 Name,
3422 Shape, 3444 Shape,
3423 new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z), 3445 AbsolutePosition,
3424 new PhysicsVector(Scale.X, Scale.Y, Scale.Z), 3446 Scale,
3425 RotationOffset, 3447 RotationOffset,
3426 UsePhysics); 3448 UsePhysics);
3427 3449
@@ -3561,7 +3583,7 @@ if (m_shape != null) {
3561 // in SL. 3583 // in SL.
3562 // 3584 //
3563 if (ParentGroup.RootPart != this) 3585 if (ParentGroup.RootPart != this)
3564 ParentGroup.RootPart.Rezzed = DateTime.Now; 3586 ParentGroup.RootPart.Rezzed = DateTime.UtcNow;
3565 3587
3566 ParentGroup.HasGroupChanged = true; 3588 ParentGroup.HasGroupChanged = true;
3567 ScheduleFullUpdate(); 3589 ScheduleFullUpdate();
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index d7113bf..87fac0c 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -93,12 +93,13 @@ namespace OpenSim.Region.Framework.Scenes
93 public Vector3 lastKnownAllowedPosition; 93 public Vector3 lastKnownAllowedPosition;
94 public bool sentMessageAboutRestrictedParcelFlyingDown; 94 public bool sentMessageAboutRestrictedParcelFlyingDown;
95 95
96 96 private Vector3 m_lastPosition;
97 private Quaternion m_lastRotation;
98 private Vector3 m_lastVelocity;
97 99
98 private bool m_updateflag; 100 private bool m_updateflag;
99 private byte m_movementflag; 101 private byte m_movementflag;
100 private readonly List<NewForce> m_forcesList = new List<NewForce>(); 102 private readonly List<NewForce> m_forcesList = new List<NewForce>();
101 private short m_updateCount;
102 private uint m_requestedSitTargetID; 103 private uint m_requestedSitTargetID;
103 private UUID m_requestedSitTargetUUID = UUID.Zero; 104 private UUID m_requestedSitTargetUUID = UUID.Zero;
104 private SendCourseLocationsMethod m_sendCourseLocationsMethod; 105 private SendCourseLocationsMethod m_sendCourseLocationsMethod;
@@ -145,12 +146,9 @@ namespace OpenSim.Region.Framework.Scenes
145 public string JID = string.Empty; 146 public string JID = string.Empty;
146 147
147 // Agent moves with a PID controller causing a force to be exerted. 148 // Agent moves with a PID controller causing a force to be exerted.
148 private bool m_newForce;
149 private bool m_newCoarseLocations = true; 149 private bool m_newCoarseLocations = true;
150 private float m_health = 100f; 150 private float m_health = 100f;
151 151
152 private Vector3 m_lastVelocity = Vector3.Zero;
153
154 // Default AV Height 152 // Default AV Height
155 private float m_avHeight = 127.0f; 153 private float m_avHeight = 127.0f;
156 154
@@ -158,16 +156,6 @@ namespace OpenSim.Region.Framework.Scenes
158 protected ulong crossingFromRegion; 156 protected ulong crossingFromRegion;
159 157
160 private readonly Vector3[] Dir_Vectors = new Vector3[6]; 158 private readonly Vector3[] Dir_Vectors = new Vector3[6];
161
162 /// <value>
163 /// The avatar position last sent to clients
164 /// </value>
165 private Vector3 lastPhysPos = Vector3.Zero;
166
167 /// <value>
168 /// The avatar body rotation last sent to clients
169 /// </value>
170 private Quaternion lastPhysRot = Quaternion.Identity;
171 159
172 // Position of agent's camera in world (region cordinates) 160 // Position of agent's camera in world (region cordinates)
173 protected Vector3 m_CameraCenter = Vector3.Zero; 161 protected Vector3 m_CameraCenter = Vector3.Zero;
@@ -297,6 +285,21 @@ namespace OpenSim.Region.Framework.Scenes
297 get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } 285 get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); }
298 } 286 }
299 287
288 public Vector3 CameraAtAxis
289 {
290 get { return m_CameraAtAxis; }
291 }
292
293 public Vector3 CameraLeftAxis
294 {
295 get { return m_CameraLeftAxis; }
296 }
297
298 public Vector3 CameraUpAxis
299 {
300 get { return m_CameraUpAxis; }
301 }
302
300 public Vector3 Lookat 303 public Vector3 Lookat
301 { 304 {
302 get 305 get
@@ -431,7 +434,7 @@ namespace OpenSim.Region.Framework.Scenes
431 { 434 {
432 lock (m_scene.SyncRoot) 435 lock (m_scene.SyncRoot)
433 { 436 {
434 m_physicsActor.Position = new PhysicsVector(value.X, value.Y, value.Z); 437 m_physicsActor.Position = value;
435 } 438 }
436 } 439 }
437 catch (Exception e) 440 catch (Exception e)
@@ -471,7 +474,7 @@ namespace OpenSim.Region.Framework.Scenes
471 { 474 {
472 lock (m_scene.SyncRoot) 475 lock (m_scene.SyncRoot)
473 { 476 {
474 m_physicsActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); 477 m_physicsActor.Velocity = value;
475 } 478 }
476 } 479 }
477 catch (Exception e) 480 catch (Exception e)
@@ -869,14 +872,16 @@ namespace OpenSim.Region.Framework.Scenes
869 872
870 m_isChildAgent = false; 873 m_isChildAgent = false;
871 874
872 List<ScenePresence> AnimAgents = m_scene.GetScenePresences(); 875 ScenePresence[] animAgents = m_scene.GetScenePresences();
873 foreach (ScenePresence p in AnimAgents) 876 for (int i = 0; i < animAgents.Length; i++)
874 { 877 {
875 if (p != this) 878 ScenePresence presence = animAgents[i];
876 p.SendAnimPackToClient(ControllingClient); 879
880 if (presence != this)
881 presence.SendAnimPackToClient(ControllingClient);
877 } 882 }
878 m_scene.EventManager.TriggerOnMakeRootAgent(this);
879 883
884 m_scene.EventManager.TriggerOnMakeRootAgent(this);
880 } 885 }
881 886
882 /// <summary> 887 /// <summary>
@@ -1041,7 +1046,7 @@ namespace OpenSim.Region.Framework.Scenes
1041 m_avHeight = height; 1046 m_avHeight = height;
1042 if (PhysicsActor != null && !IsChildAgent) 1047 if (PhysicsActor != null && !IsChildAgent)
1043 { 1048 {
1044 PhysicsVector SetSize = new PhysicsVector(0.45f, 0.6f, m_avHeight); 1049 Vector3 SetSize = new Vector3(0.45f, 0.6f, m_avHeight);
1045 PhysicsActor.Size = SetSize; 1050 PhysicsActor.Size = SetSize;
1046 } 1051 }
1047 } 1052 }
@@ -1106,18 +1111,18 @@ namespace OpenSim.Region.Framework.Scenes
1106 CameraConstraintActive = true; 1111 CameraConstraintActive = true;
1107 //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); 1112 //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance);
1108 1113
1109 Vector3 normal = Vector3.Normalize(new Vector3(0,0,collisionPoint.Z) - collisionPoint); 1114 Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint);
1110 ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); 1115 ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint)));
1111 } 1116 }
1112 else 1117 else
1113 { 1118 {
1114 if (((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) 1119 if ((m_pos - m_lastPosition).Length() > 0.02f ||
1115 || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02) 1120 (m_velocity - m_lastVelocity).Length() > 0.02f ||
1116 || lastPhysRot != m_bodyRot)) 1121 m_bodyRot != m_lastRotation)
1117 { 1122 {
1118 if (CameraConstraintActive) 1123 if (CameraConstraintActive)
1119 { 1124 {
1120 ControllingClient.SendCameraConstraint(new Vector4(0, 0.5f, 0.9f, -3000f)); 1125 ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f));
1121 CameraConstraintActive = false; 1126 CameraConstraintActive = false;
1122 } 1127 }
1123 } 1128 }
@@ -2356,6 +2361,9 @@ namespace OpenSim.Region.Framework.Scenes
2356 2361
2357 public override void Update() 2362 public override void Update()
2358 { 2363 {
2364 const float VELOCITY_TOLERANCE = 0.01f;
2365 const float POSITION_TOLERANCE = 10.0f;
2366
2359 SendPrimUpdates(); 2367 SendPrimUpdates();
2360 2368
2361 if (m_newCoarseLocations) 2369 if (m_newCoarseLocations)
@@ -2366,28 +2374,17 @@ namespace OpenSim.Region.Framework.Scenes
2366 2374
2367 if (m_isChildAgent == false) 2375 if (m_isChildAgent == false)
2368 { 2376 {
2369 if (m_newForce) // user movement 'forces' (ie commands to move) 2377 // Throw away duplicate or insignificant updates
2370 { 2378 if (m_bodyRot != m_lastRotation ||
2371 SendTerseUpdateToAllClients(); 2379 (m_velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE ||
2372 m_updateCount = 0; 2380 (m_pos - m_lastPosition).Length() > POSITION_TOLERANCE)
2373 }
2374 else if (m_movementflag != 0) // scripted movement (?)
2375 {
2376 m_updateCount++;
2377 if (m_updateCount > 3)
2378 {
2379 SendTerseUpdateToAllClients();
2380 m_updateCount = 0;
2381 }
2382 }
2383 else if ((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02)
2384 || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02)
2385 || lastPhysRot != m_bodyRot)
2386 { 2381 {
2387 // Send Terse Update to all clients updates lastPhysPos and m_lastVelocity
2388 // doing the above assures us that we know what we sent the clients last
2389 SendTerseUpdateToAllClients(); 2382 SendTerseUpdateToAllClients();
2390 m_updateCount = 0; 2383
2384 // Update the "last" values
2385 m_lastPosition = m_pos;
2386 m_lastRotation = m_bodyRot;
2387 m_lastVelocity = m_velocity;
2391 } 2388 }
2392 2389
2393 // followed suggestion from mic bowman. reversed the two lines below. 2390 // followed suggestion from mic bowman. reversed the two lines below.
@@ -2417,7 +2414,7 @@ namespace OpenSim.Region.Framework.Scenes
2417 pos.Z -= m_appearance.HipOffset; 2414 pos.Z -= m_appearance.HipOffset;
2418 2415
2419 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, 2416 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
2420 pos, m_velocity, Vector3.Zero, m_rotation, Vector4.Zero, m_uuid, null, GetUpdatePriority(remoteClient))); 2417 pos, m_velocity, Vector3.Zero, m_bodyRot, Vector4.UnitW, m_uuid, null, GetUpdatePriority(remoteClient)));
2421 2418
2422 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2419 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2423 m_scene.StatsReporter.AddAgentUpdates(1); 2420 m_scene.StatsReporter.AddAgentUpdates(1);
@@ -2430,15 +2427,10 @@ namespace OpenSim.Region.Framework.Scenes
2430 public void SendTerseUpdateToAllClients() 2427 public void SendTerseUpdateToAllClients()
2431 { 2428 {
2432 m_perfMonMS = Environment.TickCount; 2429 m_perfMonMS = Environment.TickCount;
2433 2430
2434 m_scene.ForEachClient(SendTerseUpdateToClient); 2431 m_scene.ForEachClient(SendTerseUpdateToClient);
2435 2432
2436 m_lastVelocity = m_velocity;
2437 lastPhysPos = AbsolutePosition;
2438 lastPhysRot = m_bodyRot;
2439
2440 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2433 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2441
2442 } 2434 }
2443 2435
2444 public void SendCoarseLocations() 2436 public void SendCoarseLocations()
@@ -2517,15 +2509,12 @@ namespace OpenSim.Region.Framework.Scenes
2517 if (m_appearance.Texture == null) 2509 if (m_appearance.Texture == null)
2518 return; 2510 return;
2519 2511
2520 // Note: because Quaternion is a struct, it can't be null
2521 Quaternion rot = m_bodyRot;
2522
2523 Vector3 pos = m_pos; 2512 Vector3 pos = m_pos;
2524 pos.Z -= m_appearance.HipOffset; 2513 pos.Z -= m_appearance.HipOffset;
2525 2514
2526 remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, 2515 remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid,
2527 LocalId, m_pos, m_appearance.Texture.GetBytes(), 2516 LocalId, pos, m_appearance.Texture.GetBytes(),
2528 m_parentID, rot)); 2517 m_parentID, m_bodyRot));
2529 m_scene.StatsReporter.AddAgentUpdates(1); 2518 m_scene.StatsReporter.AddAgentUpdates(1);
2530 } 2519 }
2531 2520
@@ -2536,9 +2525,12 @@ namespace OpenSim.Region.Framework.Scenes
2536 { 2525 {
2537 m_perfMonMS = Environment.TickCount; 2526 m_perfMonMS = Environment.TickCount;
2538 2527
2539 List<ScenePresence> avatars = m_scene.GetScenePresences(); 2528 ScenePresence[] avatars = m_scene.GetScenePresences();
2540 foreach (ScenePresence avatar in avatars) 2529
2530 for (int i = 0; i < avatars.Length; i++)
2541 { 2531 {
2532 ScenePresence avatar = avatars[i];
2533
2542 // only send if this is the root (children are only "listening posts" in a foreign region) 2534 // only send if this is the root (children are only "listening posts" in a foreign region)
2543 if (!IsChildAgent) 2535 if (!IsChildAgent)
2544 { 2536 {
@@ -2556,7 +2548,7 @@ namespace OpenSim.Region.Framework.Scenes
2556 } 2548 }
2557 } 2549 }
2558 2550
2559 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2551 m_scene.StatsReporter.AddAgentUpdates(avatars.Length);
2560 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2552 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2561 2553
2562 //SendAnimPack(); 2554 //SendAnimPack();
@@ -2588,14 +2580,11 @@ namespace OpenSim.Region.Framework.Scenes
2588 // the inventory arrives 2580 // the inventory arrives
2589 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); 2581 // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
2590 2582
2591 // Note: because Quaternion is a struct, it can't be null
2592 Quaternion rot = m_bodyRot;
2593
2594 Vector3 pos = m_pos; 2583 Vector3 pos = m_pos;
2595 pos.Z -= m_appearance.HipOffset; 2584 pos.Z -= m_appearance.HipOffset;
2596 2585
2597 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2586 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2598 m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot)); 2587 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2599 2588
2600 if (!m_isChildAgent) 2589 if (!m_isChildAgent)
2601 { 2590 {
@@ -2679,7 +2668,7 @@ namespace OpenSim.Region.Framework.Scenes
2679 { 2668 {
2680 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) 2669 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
2681 { 2670 {
2682 m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + (AppearanceManager.TextureIndex)j + ") for avatar " + this.Name); 2671 m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name);
2683 this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); 2672 this.ControllingClient.SendRebakeAvatarTextures(face.TextureID);
2684 } 2673 }
2685 } 2674 }
@@ -2700,9 +2689,11 @@ namespace OpenSim.Region.Framework.Scenes
2700 m_startAnimationSet = true; 2689 m_startAnimationSet = true;
2701 } 2690 }
2702 2691
2703 Quaternion rot = m_bodyRot; 2692 Vector3 pos = m_pos;
2693 pos.Z -= m_appearance.HipOffset;
2694
2704 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2695 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2705 m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot)); 2696 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2706 2697
2707 } 2698 }
2708 2699
@@ -3300,7 +3291,6 @@ namespace OpenSim.Region.Framework.Scenes
3300 /// </summary> 3291 /// </summary>
3301 public override void UpdateMovement() 3292 public override void UpdateMovement()
3302 { 3293 {
3303 m_newForce = false;
3304 lock (m_forcesList) 3294 lock (m_forcesList)
3305 { 3295 {
3306 if (m_forcesList.Count > 0) 3296 if (m_forcesList.Count > 0)
@@ -3322,7 +3312,6 @@ namespace OpenSim.Region.Framework.Scenes
3322 // Ignoring this causes no movement to be sent to the physics engine... 3312 // Ignoring this causes no movement to be sent to the physics engine...
3323 // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter! 3313 // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter!
3324 } 3314 }
3325 m_newForce = true;
3326 3315
3327 m_forcesList.Clear(); 3316 m_forcesList.Clear();
3328 } 3317 }
@@ -3356,20 +3345,18 @@ namespace OpenSim.Region.Framework.Scenes
3356 3345
3357 PhysicsScene scene = m_scene.PhysicsScene; 3346 PhysicsScene scene = m_scene.PhysicsScene;
3358 3347
3359 PhysicsVector pVec = 3348 Vector3 pVec = AbsolutePosition;
3360 new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
3361 AbsolutePosition.Z);
3362 3349
3363 // Old bug where the height was in centimeters instead of meters 3350 // Old bug where the height was in centimeters instead of meters
3364 if (m_avHeight == 127.0f) 3351 if (m_avHeight == 127.0f)
3365 { 3352 {
3366 m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new PhysicsVector(0, 0, 1.56f), 3353 m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new Vector3(0f, 0f, 1.56f),
3367 isFlying); 3354 isFlying);
3368 } 3355 }
3369 else 3356 else
3370 { 3357 {
3371 m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, 3358 m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec,
3372 new PhysicsVector(0, 0, m_avHeight), isFlying); 3359 new Vector3(0f, 0f, m_avHeight), isFlying);
3373 } 3360 }
3374 scene.AddPhysicsActorTaint(m_physicsActor); 3361 scene.AddPhysicsActorTaint(m_physicsActor);
3375 //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; 3362 //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
@@ -3380,7 +3367,7 @@ namespace OpenSim.Region.Framework.Scenes
3380 3367
3381 } 3368 }
3382 3369
3383 private void OutOfBoundsCall(PhysicsVector pos) 3370 private void OutOfBoundsCall(Vector3 pos)
3384 { 3371 {
3385 //bool flying = m_physicsActor.Flying; 3372 //bool flying = m_physicsActor.Flying;
3386 //RemoveFromPhysicalScene(); 3373 //RemoveFromPhysicalScene();
@@ -3603,7 +3590,7 @@ namespace OpenSim.Region.Framework.Scenes
3603 */ 3590 */
3604 } 3591 }
3605 3592
3606 internal void PushForce(PhysicsVector impulse) 3593 internal void PushForce(Vector3 impulse)
3607 { 3594 {
3608 if (PhysicsActor != null) 3595 if (PhysicsActor != null)
3609 { 3596 {
@@ -3866,6 +3853,8 @@ namespace OpenSim.Region.Framework.Scenes
3866 return GetPriorityByDistance(client); 3853 return GetPriorityByDistance(client);
3867 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: 3854 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3868 return GetPriorityByDistance(client); 3855 return GetPriorityByDistance(client);
3856 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3857 return GetPriorityByFrontBack(client);
3869 default: 3858 default:
3870 throw new InvalidOperationException("UpdatePrioritizationScheme not defined."); 3859 throw new InvalidOperationException("UpdatePrioritizationScheme not defined.");
3871 } 3860 }
@@ -3887,11 +3876,34 @@ namespace OpenSim.Region.Framework.Scenes
3887 return double.NaN; 3876 return double.NaN;
3888 } 3877 }
3889 3878
3879 private double GetPriorityByFrontBack(IClientAPI client)
3880 {
3881 ScenePresence presence = Scene.GetScenePresence(client.AgentId);
3882 if (presence != null)
3883 {
3884 return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis);
3885 }
3886 return double.NaN;
3887 }
3888
3890 private double GetPriorityByDistance(Vector3 position) 3889 private double GetPriorityByDistance(Vector3 position)
3891 { 3890 {
3892 return Vector3.Distance(AbsolutePosition, position); 3891 return Vector3.Distance(AbsolutePosition, position);
3893 } 3892 }
3894 3893
3894 private double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis)
3895 {
3896 // Distance
3897 double priority = Vector3.Distance(camPosition, AbsolutePosition);
3898
3899 // Plane equation
3900 float d = -Vector3.Dot(camPosition, camAtAxis);
3901 float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d;
3902 if (p < 0.0f) priority *= 2.0f;
3903
3904 return priority;
3905 }
3906
3895 private double GetSOGUpdatePriority(SceneObjectGroup sog) 3907 private double GetSOGUpdatePriority(SceneObjectGroup sog)
3896 { 3908 {
3897 switch (Scene.UpdatePrioritizationScheme) 3909 switch (Scene.UpdatePrioritizationScheme)
@@ -3902,6 +3914,8 @@ namespace OpenSim.Region.Framework.Scenes
3902 return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); 3914 return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3903 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: 3915 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3904 return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); 3916 return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3917 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3918 return sog.GetPriorityByFrontBack(CameraPosition, CameraAtAxis);
3905 default: 3919 default:
3906 throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); 3920 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3907 } 3921 }
@@ -3928,6 +3942,8 @@ namespace OpenSim.Region.Framework.Scenes
3928 case Scene.UpdatePrioritizationSchemes.Distance: 3942 case Scene.UpdatePrioritizationSchemes.Distance:
3929 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: 3943 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3930 return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); 3944 return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3945 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3946 return GetPriorityByFrontBack(CameraPosition, CameraAtAxis);
3931 default: 3947 default:
3932 throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); 3948 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3933 } 3949 }
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index df03b8d..4b0d01a 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -67,9 +67,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
67 { 67 {
68 m_client = client; 68 m_client = client;
69 m_scene = scene; 69 m_scene = scene;
70 70
71 Thread loopThread = new Thread(InternalLoop); 71 Watchdog.StartThread(InternalLoop, "IRCClientView", ThreadPriority.Normal, false);
72 loopThread.Start();
73 } 72 }
74 73
75 private void SendServerCommand(string command) 74 private void SendServerCommand(string command)
@@ -102,7 +101,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
102 { 101 {
103 try 102 try
104 { 103 {
105 string strbuf = ""; 104 string strbuf = String.Empty;
106 105
107 while (m_connected && m_client.Connected) 106 while (m_connected && m_client.Connected)
108 { 107 {
@@ -140,6 +139,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
140 } 139 }
141 140
142 Thread.Sleep(0); 141 Thread.Sleep(0);
142 Watchdog.UpdateThread();
143 } 143 }
144 } 144 }
145 catch (IOException) 145 catch (IOException)
@@ -156,6 +156,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
156 156
157 m_log.Warn("[IRCd] Disconnected client."); 157 m_log.Warn("[IRCd] Disconnected client.");
158 } 158 }
159
160 Watchdog.RemoveThread();
159 } 161 }
160 162
161 private void ProcessInMessage(string message, string command) 163 private void ProcessInMessage(string message, string command)
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs
index 91ce9f1..eb39026 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs
@@ -33,6 +33,7 @@ using System.Reflection;
33using System.Text; 33using System.Text;
34using System.Threading; 34using System.Threading;
35using log4net; 35using log4net;
36using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
37 38
38namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server 39namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
@@ -56,8 +57,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
56 57
57 m_listener.Start(50); 58 m_listener.Start(50);
58 59
59 Thread thread = new Thread(ListenLoop); 60 Watchdog.StartThread(ListenLoop, "IRCServer", ThreadPriority.Normal, false);
60 thread.Start();
61 m_baseScene = baseScene; 61 m_baseScene = baseScene;
62 } 62 }
63 63
@@ -72,7 +72,10 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
72 while (m_running) 72 while (m_running)
73 { 73 {
74 AcceptClient(m_listener.AcceptTcpClient()); 74 AcceptClient(m_listener.AcceptTcpClient());
75 Watchdog.UpdateThread();
75 } 76 }
77
78 Watchdog.RemoveThread();
76 } 79 }
77 80
78 private void AcceptClient(TcpClient client) 81 private void AcceptClient(TcpClient client)
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index b2544fa..f24869b 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -94,7 +94,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
94 } 94 }
95 private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>(); 95 private Dictionary<UUID, GroupRequestIDInfo> m_clientRequestIDInfo = new Dictionary<UUID, GroupRequestIDInfo>();
96 private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes 96 private const int m_clientRequestIDFlushTimeOut = 300000; // Every 5 minutes
97 private Timer m_clientRequestIDFlushTimer = new Timer(); 97 private Timer m_clientRequestIDFlushTimer;
98 98
99 99
100 // Configuration settings 100 // Configuration settings
@@ -133,6 +133,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
133 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true); 133 m_groupNoticesEnabled = groupsConfig.GetBoolean("NoticesEnabled", true);
134 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 134 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
135 135
136 m_clientRequestIDFlushTimer = new Timer();
136 m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut; 137 m_clientRequestIDFlushTimer.Interval = m_clientRequestIDFlushTimeOut;
137 m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache; 138 m_clientRequestIDFlushTimer.Elapsed += FlushClientRequestIDInfoCache;
138 m_clientRequestIDFlushTimer.AutoReset = true; 139 m_clientRequestIDFlushTimer.AutoReset = true;
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs
index 16fe9e9..8d6c41d 100644
--- a/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs
+++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/CMController.cs
@@ -86,7 +86,6 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
86 /// </value> 86 /// </value>
87 Hashtable m_sceneList = Hashtable.Synchronized(new Hashtable()); 87 Hashtable m_sceneList = Hashtable.Synchronized(new Hashtable());
88 State m_state = State.NONE; 88 State m_state = State.NONE;
89 Thread m_thread = null;
90 CMView m_view = null; 89 CMView m_view = null;
91 90
92 #endregion Fields 91 #endregion Fields
@@ -148,10 +147,7 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
148 lock (this) 147 lock (this)
149 { 148 {
150 m_estateModule = scene.RequestModuleInterface<IEstateModule>(); 149 m_estateModule = scene.RequestModuleInterface<IEstateModule>();
151 m_thread = new Thread(MainLoop); 150 Watchdog.StartThread(MainLoop, "Content Management", ThreadPriority.Normal, true);
152 m_thread.Name = "Content Management";
153 m_thread.IsBackground = true;
154 m_thread.Start();
155 m_state = State.NONE; 151 m_state = State.NONE;
156 } 152 }
157 } 153 }
@@ -200,6 +196,8 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
200 m_log.Debug("[CONTENT MANAGEMENT] MAIN LOOP -- uuuuuuuuuh, what?"); 196 m_log.Debug("[CONTENT MANAGEMENT] MAIN LOOP -- uuuuuuuuuh, what?");
201 break; 197 break;
202 } 198 }
199
200 Watchdog.UpdateThread();
203 } 201 }
204 } 202 }
205 catch (Exception e) 203 catch (Exception e)
@@ -209,6 +207,8 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
209 "[CONTENT MANAGEMENT]: Content management thread terminating with exception. PLEASE REBOOT YOUR SIM - CONTENT MANAGEMENT WILL NOT BE AVAILABLE UNTIL YOU DO. Exception is {0}", 207 "[CONTENT MANAGEMENT]: Content management thread terminating with exception. PLEASE REBOOT YOUR SIM - CONTENT MANAGEMENT WILL NOT BE AVAILABLE UNTIL YOU DO. Exception is {0}",
210 e); 208 e);
211 } 209 }
210
211 Watchdog.RemoveThread();
212 } 212 }
213 213
214 /// <summary> 214 /// <summary>
diff --git a/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs b/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs
index b6513e2..1a72971 100644
--- a/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs
+++ b/OpenSim/Region/OptionalModules/ContentManagementSystem/MetaEntity.cs
@@ -183,10 +183,12 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
183 public virtual void HideFromAll() 183 public virtual void HideFromAll()
184 { 184 {
185 foreach (SceneObjectPart part in m_Entity.Children.Values) 185 foreach (SceneObjectPart part in m_Entity.Children.Values)
186 m_Entity.Scene.ClientManager.ForEach( 186 {
187 m_Entity.Scene.ForEachClient(
187 delegate(IClientAPI controller) 188 delegate(IClientAPI controller)
188 { controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); } 189 { controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); }
189 ); 190 );
191 }
190 } 192 }
191 193
192 public void SendFullUpdate(IClientAPI client) 194 public void SendFullUpdate(IClientAPI client)
@@ -202,7 +204,7 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
202 204
203 public void SendFullUpdateToAll() 205 public void SendFullUpdateToAll()
204 { 206 {
205 m_Entity.Scene.ClientManager.ForEach( 207 m_Entity.Scene.ForEachClient(
206 delegate(IClientAPI controller) 208 delegate(IClientAPI controller)
207 { m_Entity.SendFullUpdateToClient(controller); } 209 { m_Entity.SendFullUpdateToClient(controller); }
208 ); 210 );
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
index 292e345..1f1ebae 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
@@ -525,8 +525,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
525 { 525 {
526 get 526 get
527 { 527 {
528 PhysicsVector tmp = GetSOP().PhysActor.GeometricCenter; 528 Vector3 tmp = GetSOP().PhysActor.GeometricCenter;
529 return new Vector3(tmp.X, tmp.Y, tmp.Z); 529 return tmp;
530 } 530 }
531 } 531 }
532 532
@@ -534,8 +534,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
534 { 534 {
535 get 535 get
536 { 536 {
537 PhysicsVector tmp = GetSOP().PhysActor.CenterOfMass; 537 Vector3 tmp = GetSOP().PhysActor.CenterOfMass;
538 return new Vector3(tmp.X, tmp.Y, tmp.Z); 538 return tmp;
539 } 539 }
540 } 540 }
541 541
@@ -543,15 +543,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
543 { 543 {
544 get 544 get
545 { 545 {
546 PhysicsVector tmp = GetSOP().PhysActor.RotationalVelocity; 546 Vector3 tmp = GetSOP().PhysActor.RotationalVelocity;
547 return new Vector3(tmp.X, tmp.Y, tmp.Z); 547 return tmp;
548 } 548 }
549 set 549 set
550 { 550 {
551 if (!CanEdit()) 551 if (!CanEdit())
552 return; 552 return;
553 553
554 GetSOP().PhysActor.RotationalVelocity = new PhysicsVector(value.X, value.Y, value.Z); 554 GetSOP().PhysActor.RotationalVelocity = value;
555 } 555 }
556 } 556 }
557 557
@@ -559,15 +559,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
559 { 559 {
560 get 560 get
561 { 561 {
562 PhysicsVector tmp = GetSOP().PhysActor.Velocity; 562 Vector3 tmp = GetSOP().PhysActor.Velocity;
563 return new Vector3(tmp.X, tmp.Y, tmp.Z); 563 return tmp;
564 } 564 }
565 set 565 set
566 { 566 {
567 if (!CanEdit()) 567 if (!CanEdit())
568 return; 568 return;
569 569
570 GetSOP().PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); 570 GetSOP().PhysActor.Velocity = value;
571 } 571 }
572 } 572 }
573 573
@@ -575,15 +575,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
575 { 575 {
576 get 576 get
577 { 577 {
578 PhysicsVector tmp = GetSOP().PhysActor.Torque; 578 Vector3 tmp = GetSOP().PhysActor.Torque;
579 return new Vector3(tmp.X, tmp.Y, tmp.Z); 579 return tmp;
580 } 580 }
581 set 581 set
582 { 582 {
583 if (!CanEdit()) 583 if (!CanEdit())
584 return; 584 return;
585 585
586 GetSOP().PhysActor.Torque = new PhysicsVector(value.X, value.Y, value.Z); 586 GetSOP().PhysActor.Torque = value;
587 } 587 }
588 } 588 }
589 589
@@ -591,8 +591,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
591 { 591 {
592 get 592 get
593 { 593 {
594 PhysicsVector tmp = GetSOP().PhysActor.Acceleration; 594 Vector3 tmp = GetSOP().PhysActor.Acceleration;
595 return new Vector3(tmp.X, tmp.Y, tmp.Z); 595 return tmp;
596 } 596 }
597 } 597 }
598 598
@@ -600,15 +600,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
600 { 600 {
601 get 601 get
602 { 602 {
603 PhysicsVector tmp = GetSOP().PhysActor.Force; 603 Vector3 tmp = GetSOP().PhysActor.Force;
604 return new Vector3(tmp.X, tmp.Y, tmp.Z); 604 return tmp;
605 } 605 }
606 set 606 set
607 { 607 {
608 if (!CanEdit()) 608 if (!CanEdit())
609 return; 609 return;
610 610
611 GetSOP().PhysActor.Force = new PhysicsVector(value.X, value.Y, value.Z); 611 GetSOP().PhysActor.Force = value;
612 } 612 }
613 } 613 }
614 614
@@ -627,7 +627,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
627 if (!CanEdit()) 627 if (!CanEdit())
628 return; 628 return;
629 629
630 GetSOP().PhysActor.AddForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); 630 GetSOP().PhysActor.AddForce(force, pushforce);
631 } 631 }
632 632
633 public void AddAngularForce(Vector3 force, bool pushforce) 633 public void AddAngularForce(Vector3 force, bool pushforce)
@@ -635,7 +635,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
635 if (!CanEdit()) 635 if (!CanEdit())
636 return; 636 return;
637 637
638 GetSOP().PhysActor.AddAngularForce(new PhysicsVector(force.X, force.Y, force.Z), pushforce); 638 GetSOP().PhysActor.AddAngularForce(force, pushforce);
639 } 639 }
640 640
641 public void SetMomentum(Vector3 momentum) 641 public void SetMomentum(Vector3 momentum)
@@ -643,7 +643,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
643 if (!CanEdit()) 643 if (!CanEdit())
644 return; 644 return;
645 645
646 GetSOP().PhysActor.SetMomentum(new PhysicsVector(momentum.X, momentum.Y, momentum.Z)); 646 GetSOP().PhysActor.SetMomentum(momentum);
647 } 647 }
648 648
649 #endregion 649 #endregion
diff --git a/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs b/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs
index fc1c608..3490a8b 100644
--- a/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs
+++ b/OpenSim/Region/OptionalModules/SvnSerialiser/SvnBackupModule.cs
@@ -45,13 +45,13 @@ namespace OpenSim.Region.Modules.SvnSerialiser
45 public class SvnBackupModule : IRegionModule 45 public class SvnBackupModule : IRegionModule
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private readonly List<Scene> m_scenes = new List<Scene>();
49 private readonly Timer m_timer = new Timer();
50 48
51 private bool m_enabled = false; 49 private List<Scene> m_scenes;
52 private bool m_installBackupOnLoad = false; 50 private Timer m_timer;
51 private bool m_enabled;
52 private bool m_installBackupOnLoad;
53 private IRegionSerialiserModule m_serialiser; 53 private IRegionSerialiserModule m_serialiser;
54 private bool m_svnAutoSave = false; 54 private bool m_svnAutoSave;
55 private SvnClient m_svnClient; 55 private SvnClient m_svnClient;
56 private string m_svndir = "SVNmodule" + Slash.DirectorySeparatorChar + "repo"; 56 private string m_svndir = "SVNmodule" + Slash.DirectorySeparatorChar + "repo";
57 private string m_svnpass = "password"; 57 private string m_svnpass = "password";
@@ -204,6 +204,9 @@ namespace OpenSim.Region.Modules.SvnSerialiser
204 204
205 public void Initialise(Scene scene, IConfigSource source) 205 public void Initialise(Scene scene, IConfigSource source)
206 { 206 {
207 m_scenes = new List<Scene>();
208 m_timer = new Timer();
209
207 try 210 try
208 { 211 {
209 if (!source.Configs["SVN"].GetBoolean("Enabled", false)) 212 if (!source.Configs["SVN"].GetBoolean("Enabled", false))
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 41a6255..ac39a53 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -41,12 +41,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
41 { 41 {
42 // private const bool m_enabled = false; 42 // private const bool m_enabled = false;
43 43
44 private Mutex m_createMutex = new Mutex(false); 44 private Mutex m_createMutex;
45 45 private Timer m_timer;
46 private Timer m_timer = new Timer(500);
47 46
48 private Dictionary<UUID,NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>(); 47 private Dictionary<UUID,NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
49
50 private Dictionary<UUID,AvatarAppearance> m_appearanceCache = new Dictionary<UUID, AvatarAppearance>(); 48 private Dictionary<UUID,AvatarAppearance> m_appearanceCache = new Dictionary<UUID, AvatarAppearance>();
51 49
52 // Timer vars. 50 // Timer vars.
@@ -138,10 +136,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
138 136
139 public void Initialise(Scene scene, IConfigSource source) 137 public void Initialise(Scene scene, IConfigSource source)
140 { 138 {
141 scene.RegisterModuleInterface<INPCModule>(this); 139 m_createMutex = new Mutex(false);
142 140
141 m_timer = new Timer(500);
143 m_timer.Elapsed += m_timer_Elapsed; 142 m_timer.Elapsed += m_timer_Elapsed;
144 m_timer.Start(); 143 m_timer.Start();
144
145 scene.RegisterModuleInterface<INPCModule>(this);
145 } 146 }
146 147
147 void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) 148 void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
index 2b905b6..f411dd7 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsActor.cs
@@ -36,20 +36,16 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
36{ 36{
37 public class BasicActor : PhysicsActor 37 public class BasicActor : PhysicsActor
38 { 38 {
39 private PhysicsVector _position; 39 private Vector3 _position;
40 private PhysicsVector _velocity; 40 private Vector3 _velocity;
41 private PhysicsVector _acceleration; 41 private Vector3 _acceleration;
42 private PhysicsVector _size; 42 private Vector3 _size;
43 private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; 43 private Vector3 m_rotationalVelocity;
44 private bool flying; 44 private bool flying;
45 private bool iscolliding; 45 private bool iscolliding;
46 46
47 public BasicActor() 47 public BasicActor()
48 { 48 {
49 _velocity = new PhysicsVector();
50 _position = new PhysicsVector();
51 _acceleration = new PhysicsVector();
52 _size = new PhysicsVector();
53 } 49 }
54 50
55 public override int PhysicsActorType 51 public override int PhysicsActorType
@@ -58,7 +54,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
58 set { return; } 54 set { return; }
59 } 55 }
60 56
61 public override PhysicsVector RotationalVelocity 57 public override Vector3 RotationalVelocity
62 { 58 {
63 get { return m_rotationalVelocity; } 59 get { return m_rotationalVelocity; }
64 set { m_rotationalVelocity = value; } 60 set { m_rotationalVelocity = value; }
@@ -137,13 +133,13 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
137 get { return false; } 133 get { return false; }
138 } 134 }
139 135
140 public override PhysicsVector Position 136 public override Vector3 Position
141 { 137 {
142 get { return _position; } 138 get { return _position; }
143 set { _position = value; } 139 set { _position = value; }
144 } 140 }
145 141
146 public override PhysicsVector Size 142 public override Vector3 Size
147 { 143 {
148 get { return _size; } 144 get { return _size; }
149 set { 145 set {
@@ -162,9 +158,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
162 get { return 0f; } 158 get { return 0f; }
163 } 159 }
164 160
165 public override PhysicsVector Force 161 public override Vector3 Force
166 { 162 {
167 get { return PhysicsVector.Zero; } 163 get { return Vector3.Zero; }
168 set { return; } 164 set { return; }
169 } 165 }
170 166
@@ -179,7 +175,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
179 175
180 } 176 }
181 177
182 public override void VehicleVectorParam(int param, PhysicsVector value) 178 public override void VehicleVectorParam(int param, Vector3 value)
183 { 179 {
184 180
185 } 181 }
@@ -194,25 +190,25 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
194 190
195 } 191 }
196 192
197 public override PhysicsVector CenterOfMass 193 public override Vector3 CenterOfMass
198 { 194 {
199 get { return PhysicsVector.Zero; } 195 get { return Vector3.Zero; }
200 } 196 }
201 197
202 public override PhysicsVector GeometricCenter 198 public override Vector3 GeometricCenter
203 { 199 {
204 get { return PhysicsVector.Zero; } 200 get { return Vector3.Zero; }
205 } 201 }
206 202
207 public override PhysicsVector Velocity 203 public override Vector3 Velocity
208 { 204 {
209 get { return _velocity; } 205 get { return _velocity; }
210 set { _velocity = value; } 206 set { _velocity = value; }
211 } 207 }
212 208
213 public override PhysicsVector Torque 209 public override Vector3 Torque
214 { 210 {
215 get { return PhysicsVector.Zero; } 211 get { return Vector3.Zero; }
216 set { return; } 212 set { return; }
217 } 213 }
218 214
@@ -228,7 +224,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
228 set { } 224 set { }
229 } 225 }
230 226
231 public override PhysicsVector Acceleration 227 public override Vector3 Acceleration
232 { 228 {
233 get { return _acceleration; } 229 get { return _acceleration; }
234 } 230 }
@@ -247,24 +243,24 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
247 { 243 {
248 } 244 }
249 245
250 public override void LockAngularMotion(PhysicsVector axis) 246 public override void LockAngularMotion(Vector3 axis)
251 { 247 {
252 } 248 }
253 249
254 public void SetAcceleration(PhysicsVector accel) 250 public void SetAcceleration(Vector3 accel)
255 { 251 {
256 _acceleration = accel; 252 _acceleration = accel;
257 } 253 }
258 254
259 public override void AddForce(PhysicsVector force, bool pushforce) 255 public override void AddForce(Vector3 force, bool pushforce)
260 { 256 {
261 } 257 }
262 258
263 public override void AddAngularForce(PhysicsVector force, bool pushforce) 259 public override void AddAngularForce(Vector3 force, bool pushforce)
264 { 260 {
265 } 261 }
266 262
267 public override void SetMomentum(PhysicsVector momentum) 263 public override void SetMomentum(Vector3 momentum)
268 { 264 {
269 } 265 }
270 266
@@ -272,7 +268,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
272 { 268 {
273 } 269 }
274 270
275 public override PhysicsVector PIDTarget 271 public override Vector3 PIDTarget
276 { 272 {
277 set { return; } 273 set { return; }
278 } 274 }
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
index 66bd099..b6e1cb4 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsScene.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
54 { 54 {
55 55
56 } 56 }
57 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 57 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
58 { 58 {
59 BasicActor act = new BasicActor(); 59 BasicActor act = new BasicActor();
60 act.Position = position; 60 act.Position = position;
@@ -77,20 +77,20 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
77 } 77 }
78 78
79/* 79/*
80 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) 80 public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
81 { 81 {
82 return null; 82 return null;
83 } 83 }
84*/ 84*/
85 85
86 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 86 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
87 PhysicsVector size, Quaternion rotation) 87 Vector3 size, Quaternion rotation)
88 { 88 {
89 return AddPrimShape(primName, pbs, position, size, rotation, false); 89 return AddPrimShape(primName, pbs, position, size, rotation, false);
90 } 90 }
91 91
92 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 92 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
93 PhysicsVector size, Quaternion rotation, bool isPhysical) 93 Vector3 size, Quaternion rotation, bool isPhysical)
94 { 94 {
95 return null; 95 return null;
96 } 96 }
@@ -105,26 +105,28 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
105 for (int i = 0; i < _actors.Count; ++i) 105 for (int i = 0; i < _actors.Count; ++i)
106 { 106 {
107 BasicActor actor = _actors[i]; 107 BasicActor actor = _actors[i];
108 Vector3 actorPosition = actor.Position;
109 Vector3 actorVelocity = actor.Velocity;
108 110
109 actor.Position.X += actor.Velocity.X*timeStep; 111 actorPosition.X += actor.Velocity.X*timeStep;
110 actor.Position.Y += actor.Velocity.Y*timeStep; 112 actorPosition.Y += actor.Velocity.Y*timeStep;
111 113
112 if (actor.Position.Y < 0) 114 if (actor.Position.Y < 0)
113 { 115 {
114 actor.Position.Y = 0.1F; 116 actorPosition.Y = 0.1F;
115 } 117 }
116 else if (actor.Position.Y >= Constants.RegionSize) 118 else if (actor.Position.Y >= Constants.RegionSize)
117 { 119 {
118 actor.Position.Y = ((int)Constants.RegionSize - 0.1f); 120 actorPosition.Y = ((int)Constants.RegionSize - 0.1f);
119 } 121 }
120 122
121 if (actor.Position.X < 0) 123 if (actor.Position.X < 0)
122 { 124 {
123 actor.Position.X = 0.1F; 125 actorPosition.X = 0.1F;
124 } 126 }
125 else if (actor.Position.X >= Constants.RegionSize) 127 else if (actor.Position.X >= Constants.RegionSize)
126 { 128 {
127 actor.Position.X = ((int)Constants.RegionSize - 0.1f); 129 actorPosition.X = ((int)Constants.RegionSize - 0.1f);
128 } 130 }
129 131
130 float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + actor.Size.Z; 132 float height = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + actor.Size.Z;
@@ -133,23 +135,27 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
133 if (actor.Position.Z + (actor.Velocity.Z*timeStep) < 135 if (actor.Position.Z + (actor.Velocity.Z*timeStep) <
134 _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + 2) 136 _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X] + 2)
135 { 137 {
136 actor.Position.Z = height; 138 actorPosition.Z = height;
137 actor.Velocity.Z = 0; 139 actorVelocity.Z = 0;
138 actor.IsColliding = true; 140 actor.IsColliding = true;
139 } 141 }
140 else 142 else
141 { 143 {
142 actor.Position.Z += actor.Velocity.Z*timeStep; 144 actorPosition.Z += actor.Velocity.Z*timeStep;
143 actor.IsColliding = false; 145 actor.IsColliding = false;
144 } 146 }
145 } 147 }
146 else 148 else
147 { 149 {
148 actor.Position.Z = height; 150 actorPosition.Z = height;
149 actor.Velocity.Z = 0; 151 actorVelocity.Z = 0;
150 actor.IsColliding = true; 152 actor.IsColliding = true;
151 } 153 }
154
155 actor.Position = actorPosition;
156 actor.Velocity = actorVelocity;
152 } 157 }
158
153 return fps; 159 return fps;
154 } 160 }
155 161
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
index d7aed3c..98681d6 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETCharacter.cs
@@ -60,15 +60,15 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
60 private btQuaternion m_bodyOrientation; 60 private btQuaternion m_bodyOrientation;
61 private btDefaultMotionState m_bodyMotionState; 61 private btDefaultMotionState m_bodyMotionState;
62 private btGeneric6DofConstraint m_aMotor; 62 private btGeneric6DofConstraint m_aMotor;
63 // private PhysicsVector m_movementComparision; 63 // private Vector3 m_movementComparision;
64 private PhysicsVector m_position; 64 private Vector3 m_position;
65 private PhysicsVector m_zeroPosition; 65 private Vector3 m_zeroPosition;
66 private bool m_zeroFlag = false; 66 private bool m_zeroFlag = false;
67 private bool m_lastUpdateSent = false; 67 private bool m_lastUpdateSent = false;
68 private PhysicsVector m_velocity; 68 private Vector3 m_velocity;
69 private PhysicsVector m_target_velocity; 69 private Vector3 m_target_velocity;
70 private PhysicsVector m_acceleration; 70 private Vector3 m_acceleration;
71 private PhysicsVector m_rotationalVelocity; 71 private Vector3 m_rotationalVelocity;
72 private bool m_pidControllerActive = true; 72 private bool m_pidControllerActive = true;
73 public float PID_D = 80.0f; 73 public float PID_D = 80.0f;
74 public float PID_P = 90.0f; 74 public float PID_P = 90.0f;
@@ -96,8 +96,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
96 private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes. 96 private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes.
97 private bool m_taintRemove = false; 97 private bool m_taintRemove = false;
98 // private bool m_taintedPosition = false; 98 // private bool m_taintedPosition = false;
99 // private PhysicsVector m_taintedPosition_value; 99 // private Vector3 m_taintedPosition_value;
100 private PhysicsVector m_taintedForce; 100 private Vector3 m_taintedForce;
101 101
102 private float m_buoyancy = 0f; 102 private float m_buoyancy = 0f;
103 103
@@ -115,14 +115,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
115 public int m_eventsubscription = 0; 115 public int m_eventsubscription = 0;
116 // private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); 116 // private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
117 117
118 public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) 118 public BulletDotNETCharacter(string avName, BulletDotNETScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor)
119 { 119 {
120 m_taintedForce = new PhysicsVector();
121 m_velocity = new PhysicsVector();
122 m_target_velocity = new PhysicsVector();
123 m_position = pos; 120 m_position = pos;
124 m_zeroPosition = new PhysicsVector(pos.X, pos.Y, pos.Z); // this is a class, not a struct. Must make new, or m_zeroPosition will == position regardless 121 m_zeroPosition = pos;
125 m_acceleration = new PhysicsVector();
126 m_parent_scene = parent_scene; 122 m_parent_scene = parent_scene;
127 PID_D = pid_d; 123 PID_D = pid_d;
128 PID_P = pid_p; 124 PID_P = pid_p;
@@ -161,9 +157,6 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
161 tempTrans1 = new btTransform(tempQuat1, tempVector1); 157 tempTrans1 = new btTransform(tempQuat1, tempVector1);
162 // m_movementComparision = new PhysicsVector(0, 0, 0); 158 // m_movementComparision = new PhysicsVector(0, 0, 0);
163 m_CapsuleOrientationAxis = new btVector3(1, 0, 1); 159 m_CapsuleOrientationAxis = new btVector3(1, 0, 1);
164
165
166
167 } 160 }
168 161
169 /// <summary> 162 /// <summary>
@@ -254,18 +247,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
254 get { return m_zeroFlag; } 247 get { return m_zeroFlag; }
255 } 248 }
256 249
257 public override PhysicsVector Size 250 public override Vector3 Size
258 { 251 {
259 get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } 252 get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
260 set 253 set
261 { 254 {
262 m_pidControllerActive = true; 255 m_pidControllerActive = true;
263 256
264 PhysicsVector SetSize = value; 257 Vector3 SetSize = value;
265 m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f; 258 m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f;
266 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); 259 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
267 260
268 Velocity = new PhysicsVector(0f, 0f, 0f); 261 Velocity = Vector3.Zero;
269 262
270 m_parent_scene.AddPhysicsActorTaint(this); 263 m_parent_scene.AddPhysicsActorTaint(this);
271 } 264 }
@@ -317,12 +310,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
317 310
318 } 311 }
319 312
320 public override void LockAngularMotion(PhysicsVector axis) 313 public override void LockAngularMotion(Vector3 axis)
321 { 314 {
322 315
323 } 316 }
324 317
325 public override PhysicsVector Position 318 public override Vector3 Position
326 { 319 {
327 get { return m_position; } 320 get { return m_position; }
328 set 321 set
@@ -342,9 +335,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
342 } 335 }
343 } 336 }
344 337
345 public override PhysicsVector Force 338 public override Vector3 Force
346 { 339 {
347 get { return new PhysicsVector(m_target_velocity.X, m_target_velocity.Y, m_target_velocity.Z); } 340 get { return m_target_velocity; }
348 set { return; } 341 set { return; }
349 } 342 }
350 343
@@ -359,7 +352,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
359 352
360 } 353 }
361 354
362 public override void VehicleVectorParam(int param, PhysicsVector value) 355 public override void VehicleVectorParam(int param, Vector3 value)
363 { 356 {
364 357
365 } 358 }
@@ -374,23 +367,22 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
374 367
375 } 368 }
376 369
377 public override PhysicsVector GeometricCenter 370 public override Vector3 GeometricCenter
378 { 371 {
379 get { return PhysicsVector.Zero; } 372 get { return Vector3.Zero; }
380 } 373 }
381 374
382 public override PhysicsVector CenterOfMass 375 public override Vector3 CenterOfMass
383 { 376 {
384 get { return PhysicsVector.Zero; } 377 get { return Vector3.Zero; }
385 } 378 }
386 379
387 public override PhysicsVector Velocity 380 public override Vector3 Velocity
388 { 381 {
389 get 382 get
390 { 383 {
391 // There's a problem with PhysicsVector.Zero! Don't Use it Here!
392 if (m_zeroFlag) 384 if (m_zeroFlag)
393 return new PhysicsVector(0f, 0f, 0f); 385 return Vector3.Zero;
394 m_lastUpdateSent = false; 386 m_lastUpdateSent = false;
395 return m_velocity; 387 return m_velocity;
396 } 388 }
@@ -401,9 +393,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
401 } 393 }
402 } 394 }
403 395
404 public override PhysicsVector Torque 396 public override Vector3 Torque
405 { 397 {
406 get { return PhysicsVector.Zero; } 398 get { return Vector3.Zero; }
407 set { return; } 399 set { return; }
408 } 400 }
409 401
@@ -413,7 +405,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
413 set { } 405 set { }
414 } 406 }
415 407
416 public override PhysicsVector Acceleration 408 public override Vector3 Acceleration
417 { 409 {
418 get { return m_acceleration; } 410 get { return m_acceleration; }
419 } 411 }
@@ -586,7 +578,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
586 set { return; } 578 set { return; }
587 } 579 }
588 580
589 public override PhysicsVector RotationalVelocity 581 public override Vector3 RotationalVelocity
590 { 582 {
591 get { return m_rotationalVelocity; } 583 get { return m_rotationalVelocity; }
592 set { m_rotationalVelocity = value; } 584 set { m_rotationalVelocity = value; }
@@ -604,7 +596,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
604 set { m_buoyancy = value; } 596 set { m_buoyancy = value; }
605 } 597 }
606 598
607 public override PhysicsVector PIDTarget { set { return; } } 599 public override Vector3 PIDTarget { set { return; } }
608 public override bool PIDActive { set { return; } } 600 public override bool PIDActive { set { return; } }
609 public override float PIDTau { set { return; } } 601 public override float PIDTau { set { return; } }
610 602
@@ -640,7 +632,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
640 /// </summary> 632 /// </summary>
641 /// <param name="force"></param> 633 /// <param name="force"></param>
642 /// <param name="pushforce">Is this a push by a script?</param> 634 /// <param name="pushforce">Is this a push by a script?</param>
643 public override void AddForce(PhysicsVector force, bool pushforce) 635 public override void AddForce(Vector3 force, bool pushforce)
644 { 636 {
645 if (pushforce) 637 if (pushforce)
646 { 638 {
@@ -662,7 +654,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
662 //m_lastUpdateSent = false; 654 //m_lastUpdateSent = false;
663 } 655 }
664 656
665 public void doForce(PhysicsVector force, bool now) 657 public void doForce(Vector3 force, bool now)
666 { 658 {
667 659
668 tempVector3.setValue(force.X, force.Y, force.Z); 660 tempVector3.setValue(force.X, force.Y, force.Z);
@@ -677,7 +669,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
677 } 669 }
678 } 670 }
679 671
680 public void doImpulse(PhysicsVector force, bool now) 672 public void doImpulse(Vector3 force, bool now)
681 { 673 {
682 674
683 tempVector3.setValue(force.X, force.Y, force.Z); 675 tempVector3.setValue(force.X, force.Y, force.Z);
@@ -692,12 +684,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
692 } 684 }
693 } 685 }
694 686
695 public override void AddAngularForce(PhysicsVector force, bool pushforce) 687 public override void AddAngularForce(Vector3 force, bool pushforce)
696 { 688 {
697 689
698 } 690 }
699 691
700 public override void SetMomentum(PhysicsVector momentum) 692 public override void SetMomentum(Vector3 momentum)
701 { 693 {
702 694
703 } 695 }
@@ -814,7 +806,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
814 806
815 AvatarGeomAndBodyCreation(m_position.X, m_position.Y, 807 AvatarGeomAndBodyCreation(m_position.X, m_position.Y,
816 m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2)); 808 m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2));
817 Velocity = new PhysicsVector(0f, 0f, 0f); 809 Velocity = Vector3.Zero;
818 810
819 } 811 }
820 else 812 else
@@ -858,9 +850,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
858 } 850 }
859 //PidStatus = true; 851 //PidStatus = true;
860 852
861 PhysicsVector vec = new PhysicsVector(); 853 Vector3 vec = Vector3.Zero;
862 854
863 PhysicsVector vel = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); 855 Vector3 vel = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
864 856
865 float movementdivisor = 1f; 857 float movementdivisor = 1f;
866 858
@@ -891,7 +883,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
891 // Avatar to Avatar collisions 883 // Avatar to Avatar collisions
892 // Prim to avatar collisions 884 // Prim to avatar collisions
893 885
894 PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); 886 Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
895 vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2); 887 vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2);
896 vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2); 888 vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2);
897 if (m_flying) 889 if (m_flying)
@@ -933,7 +925,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
933 { 925 {
934 // We're colliding with something and we're not flying but we're moving 926 // We're colliding with something and we're not flying but we're moving
935 // This means we're walking or running. 927 // This means we're walking or running.
936 PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); 928 Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
937 vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P; 929 vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P;
938 if (m_target_velocity.X > 0) 930 if (m_target_velocity.X > 0)
939 { 931 {
@@ -1022,7 +1014,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1022 tempVector2 = Body.getInterpolationLinearVelocity(); 1014 tempVector2 = Body.getInterpolationLinearVelocity();
1023 1015
1024 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 1016 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
1025 PhysicsVector vec = new PhysicsVector(tempVector1.getX(),tempVector1.getY(),tempVector1.getZ()); 1017 Vector3 vec = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
1026 1018
1027 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 1019 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
1028 if (vec.X < -10.0f) vec.X = 0.0f; 1020 if (vec.X < -10.0f) vec.X = 0.0f;
@@ -1054,7 +1046,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1054 else 1046 else
1055 { 1047 {
1056 m_lastUpdateSent = false; 1048 m_lastUpdateSent = false;
1057 vec = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); 1049 vec = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
1058 m_velocity.X = (vec.X); 1050 m_velocity.X = (vec.X);
1059 m_velocity.Y = (vec.Y); 1051 m_velocity.Y = (vec.Y);
1060 1052
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
index 977b463..d931f126 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
@@ -43,44 +43,43 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
43 { 43 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private PhysicsVector _position; 46 private Vector3 _position;
47 private PhysicsVector m_zeroPosition; 47 private Vector3 m_zeroPosition;
48 private PhysicsVector _velocity; 48 private Vector3 _velocity;
49 private PhysicsVector _torque = new PhysicsVector(0, 0, 0); 49 private Vector3 _torque;
50 private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); 50 private Vector3 m_lastVelocity;
51 private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); 51 private Vector3 m_lastposition;
52 private Quaternion m_lastorientation = new Quaternion(); 52 private Quaternion m_lastorientation = Quaternion.Identity;
53 private PhysicsVector m_rotationalVelocity; 53 private Vector3 m_rotationalVelocity;
54 private PhysicsVector _size; 54 private Vector3 _size;
55 private PhysicsVector _acceleration; 55 private Vector3 _acceleration;
56 // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f); 56 // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f);
57 private Quaternion _orientation; 57 private Quaternion _orientation;
58 private PhysicsVector m_taintposition; 58 private Vector3 m_taintposition;
59 private PhysicsVector m_taintsize; 59 private Vector3 m_taintsize;
60 private PhysicsVector m_taintVelocity = new PhysicsVector(0, 0, 0); 60 private Vector3 m_taintVelocity;
61 private PhysicsVector m_taintTorque = new PhysicsVector(0, 0, 0); 61 private Vector3 m_taintTorque;
62 private Quaternion m_taintrot; 62 private Quaternion m_taintrot;
63 private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); 63 private Vector3 m_angularlock = Vector3.One;
64 private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); 64 private Vector3 m_taintAngularLock = Vector3.One;
65 // private btGeneric6DofConstraint Amotor; 65 // private btGeneric6DofConstraint Amotor;
66 66
67 private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0); 67 private Vector3 m_PIDTarget;
68 private float m_PIDTau = 0f; 68 private float m_PIDTau;
69 private float m_PIDHoverHeight = 0f; 69 private float m_PIDHoverHeight;
70 private float m_PIDHoverTau = 0f; 70 private float m_PIDHoverTau;
71 private bool m_useHoverPID = false; 71 private bool m_useHoverPID;
72 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground; 72 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground;
73 private float m_targetHoverHeight = 0f; 73 private float m_targetHoverHeight;
74 private float m_groundHeight = 0f; 74 private float m_groundHeight;
75 private float m_waterHeight = 0f; 75 private float m_waterHeight;
76 private float PID_D = 35f; 76 private float PID_D = 35f;
77 private float PID_G = 25f; 77 private float PID_G = 25f;
78 // private float m_tensor = 5f; 78 // private float m_tensor = 5f;
79 // private int body_autodisable_frames = 20; 79 // private int body_autodisable_frames = 20;
80 private IMesh primMesh = null; 80 private IMesh primMesh;
81
82 private bool m_usePID = false;
83 81
82 private bool m_usePID;
84 83
85 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom 84 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
86 | CollisionCategories.Space 85 | CollisionCategories.Space
@@ -88,11 +87,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
88 | CollisionCategories.Character 87 | CollisionCategories.Character
89 ); 88 );
90 89
91 private bool m_taintshape = false; 90 private bool m_taintshape;
92 private bool m_taintPhysics = false; 91 private bool m_taintPhysics;
93 // private bool m_collidesLand = true; 92 // private bool m_collidesLand = true;
94 private bool m_collidesWater = false; 93 private bool m_collidesWater;
95 public bool m_returnCollisions = false; 94 public bool m_returnCollisions;
96 95
97 // Default we're a Geometry 96 // Default we're a Geometry
98 // private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); 97 // private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
@@ -100,23 +99,23 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
100 // Default, Collide with Other Geometries, spaces and Bodies 99 // Default, Collide with Other Geometries, spaces and Bodies
101 // private CollisionCategories m_collisionFlags = m_default_collisionFlags; 100 // private CollisionCategories m_collisionFlags = m_default_collisionFlags;
102 101
103 public bool m_taintremove = false; 102 public bool m_taintremove;
104 public bool m_taintdisable = false; 103 public bool m_taintdisable;
105 public bool m_disabled = false; 104 public bool m_disabled;
106 public bool m_taintadd = false; 105 public bool m_taintadd;
107 public bool m_taintselected = false; 106 public bool m_taintselected;
108 public bool m_taintCollidesWater = false; 107 public bool m_taintCollidesWater;
109 108
110 public uint m_localID = 0; 109 public uint m_localID;
111 110
112 //public GCHandle gc; 111 //public GCHandle gc;
113 // private CollisionLocker ode; 112 // private CollisionLocker ode;
114 113
115 private bool m_taintforce = false; 114 private bool m_taintforce;
116 private bool m_taintaddangularforce = false; 115 private bool m_taintaddangularforce;
117 private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); 116 private Vector3 m_force;
118 private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); 117 private List<Vector3> m_forcelist = new List<Vector3>();
119 private List<PhysicsVector> m_angularforcelist = new List<PhysicsVector>(); 118 private List<Vector3> m_angularforcelist = new List<Vector3>();
120 119
121 private IMesh _mesh; 120 private IMesh _mesh;
122 private PrimitiveBaseShape _pbs; 121 private PrimitiveBaseShape _pbs;
@@ -124,40 +123,40 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
124 public btCollisionShape prim_geom; 123 public btCollisionShape prim_geom;
125 public IntPtr _triMeshData; 124 public IntPtr _triMeshData;
126 125
127 private PhysicsActor _parent = null; 126 private PhysicsActor _parent;
128 private PhysicsActor m_taintparent = null; 127 private PhysicsActor m_taintparent;
129 128
130 private List<BulletDotNETPrim> childrenPrim = new List<BulletDotNETPrim>(); 129 private List<BulletDotNETPrim> childrenPrim = new List<BulletDotNETPrim>();
131 130
132 private bool iscolliding = false; 131 private bool iscolliding;
133 private bool m_isphysical = false; 132 private bool m_isphysical;
134 private bool m_isSelected = false; 133 private bool m_isSelected;
135 134
136 internal bool m_isVolumeDetect = false; // If true, this prim only detects collisions but doesn't collide actively 135 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
137 136
138 private bool m_throttleUpdates = false; 137 private bool m_throttleUpdates;
139 // private int throttleCounter = 0; 138 // private int throttleCounter;
140 public int m_interpenetrationcount = 0; 139 public int m_interpenetrationcount;
141 public float m_collisionscore = 0; 140 public float m_collisionscore;
142 public int m_roundsUnderMotionThreshold = 0; 141 public int m_roundsUnderMotionThreshold;
143 private int m_crossingfailures = 0; 142 private int m_crossingfailures;
144 143
145 public float m_buoyancy = 0f; 144 public float m_buoyancy;
146 145
147 public bool outofBounds = false; 146 public bool outofBounds;
148 private float m_density = 10.000006836f; // Aluminum g/cm3; 147 private float m_density = 10.000006836f; // Aluminum g/cm3;
149 148
150 public bool _zeroFlag = false; 149 public bool _zeroFlag;
151 private bool m_lastUpdateSent = false; 150 private bool m_lastUpdateSent;
152 151
153 152
154 private String m_primName; 153 private String m_primName;
155 private PhysicsVector _target_velocity; 154 private Vector3 _target_velocity;
156 155
157 public int m_eventsubscription = 0; 156 public int m_eventsubscription;
158 // private CollisionEventUpdate CollisionEventsThisFrame = null; 157 // private CollisionEventUpdate CollisionEventsThisFrame = null;
159 158
160 public volatile bool childPrim = false; 159 public volatile bool childPrim;
161 160
162 private btVector3 tempPosition1; 161 private btVector3 tempPosition1;
163 private btVector3 tempPosition2; 162 private btVector3 tempPosition2;
@@ -190,7 +189,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
190 189
191 public btRigidBody Body; 190 public btRigidBody Body;
192 191
193 public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, 192 public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, Vector3 pos, Vector3 size,
194 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical) 193 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical)
195 { 194 {
196 tempPosition1 = new btVector3(0, 0, 0); 195 tempPosition1 = new btVector3(0, 0, 0);
@@ -225,8 +224,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
225 224
226 AxisLockLinearHigh = new btVector3((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionSize); 225 AxisLockLinearHigh = new btVector3((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionSize);
227 226
228 _target_velocity = new PhysicsVector(0, 0, 0); 227 _target_velocity = Vector3.Zero;
229 _velocity = new PhysicsVector(); 228 _velocity = Vector3.Zero;
230 _position = pos; 229 _position = pos;
231 m_taintposition = pos; 230 m_taintposition = pos;
232 PID_D = parent_scene.bodyPIDD; 231 PID_D = parent_scene.bodyPIDD;
@@ -244,8 +243,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
244 243
245 _size = size; 244 _size = size;
246 m_taintsize = _size; 245 m_taintsize = _size;
247 _acceleration = new PhysicsVector(); 246 _acceleration = Vector3.Zero;
248 m_rotationalVelocity = PhysicsVector.Zero; 247 m_rotationalVelocity = Vector3.Zero;
249 _orientation = rotation; 248 _orientation = rotation;
250 m_taintrot = _orientation; 249 m_taintrot = _orientation;
251 _mesh = mesh; 250 _mesh = mesh;
@@ -274,7 +273,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
274 get { return _zeroFlag; } 273 get { return _zeroFlag; }
275 } 274 }
276 275
277 public override PhysicsVector Size 276 public override Vector3 Size
278 { 277 {
279 get { return _size; } 278 get { return _size; }
280 set { _size = value; } 279 set { _size = value; }
@@ -348,13 +347,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
348 m_taintparent = null; 347 m_taintparent = null;
349 } 348 }
350 349
351 public override void LockAngularMotion(PhysicsVector axis) 350 public override void LockAngularMotion(Vector3 axis)
352 { 351 {
353 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); 352 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z);
354 m_taintAngularLock = new PhysicsVector(axis.X, axis.Y, axis.Z); 353 m_taintAngularLock = axis;
355 } 354 }
356 355
357 public override PhysicsVector Position 356 public override Vector3 Position
358 { 357 {
359 get { return _position; } 358 get { return _position; }
360 359
@@ -370,9 +369,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
370 get { return CalculateMass(); } 369 get { return CalculateMass(); }
371 } 370 }
372 371
373 public override PhysicsVector Force 372 public override Vector3 Force
374 { 373 {
375 //get { return PhysicsVector.Zero; } 374 //get { return Vector3.Zero; }
376 get { return m_force; } 375 get { return m_force; }
377 set { m_force = value; } 376 set { m_force = value; }
378 } 377 }
@@ -388,7 +387,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
388 //TODO: 387 //TODO:
389 } 388 }
390 389
391 public override void VehicleVectorParam(int param, PhysicsVector value) 390 public override void VehicleVectorParam(int param, Vector3 value)
392 { 391 {
393 //TODO: 392 //TODO:
394 } 393 }
@@ -405,23 +404,23 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
405 404
406 } 405 }
407 406
408 public override PhysicsVector GeometricCenter 407 public override Vector3 GeometricCenter
409 { 408 {
410 get { return PhysicsVector.Zero; } 409 get { return Vector3.Zero; }
411 } 410 }
412 411
413 public override PhysicsVector CenterOfMass 412 public override Vector3 CenterOfMass
414 { 413 {
415 get { return PhysicsVector.Zero; } 414 get { return Vector3.Zero; }
416 } 415 }
417 416
418 public override PhysicsVector Velocity 417 public override Vector3 Velocity
419 { 418 {
420 get 419 get
421 { 420 {
422 // Averate previous velocity with the new one so 421 // Averate previous velocity with the new one so
423 // client object interpolation works a 'little' better 422 // client object interpolation works a 'little' better
424 PhysicsVector returnVelocity = new PhysicsVector(); 423 Vector3 returnVelocity;
425 returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2; 424 returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2;
426 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2; 425 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2;
427 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2; 426 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2;
@@ -436,12 +435,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
436 } 435 }
437 } 436 }
438 437
439 public override PhysicsVector Torque 438 public override Vector3 Torque
440 { 439 {
441 get 440 get
442 { 441 {
443 if (!m_isphysical || Body.Handle == IntPtr.Zero) 442 if (!m_isphysical || Body.Handle == IntPtr.Zero)
444 return new PhysicsVector(0, 0, 0); 443 return Vector3.Zero;
445 444
446 return _torque; 445 return _torque;
447 } 446 }
@@ -459,7 +458,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
459 set { m_collisionscore = value; } 458 set { m_collisionscore = value; }
460 } 459 }
461 460
462 public override PhysicsVector Acceleration 461 public override Vector3 Acceleration
463 { 462 {
464 get { return _acceleration; } 463 get { return _acceleration; }
465 } 464 }
@@ -528,16 +527,16 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
528 } 527 }
529 } 528 }
530 529
531 public override PhysicsVector RotationalVelocity 530 public override Vector3 RotationalVelocity
532 { 531 {
533 get 532 get
534 { 533 {
535 PhysicsVector pv = new PhysicsVector(0, 0, 0); 534 Vector3 pv = Vector3.Zero;
536 if (_zeroFlag) 535 if (_zeroFlag)
537 return pv; 536 return pv;
538 m_lastUpdateSent = false; 537 m_lastUpdateSent = false;
539 538
540 if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) 539 if (m_rotationalVelocity.ApproxEquals(pv, 0.2f))
541 return pv; 540 return pv;
542 541
543 return m_rotationalVelocity; 542 return m_rotationalVelocity;
@@ -557,7 +556,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
557 set { m_buoyancy = value; } 556 set { m_buoyancy = value; }
558 } 557 }
559 558
560 public override PhysicsVector PIDTarget { set { m_PIDTarget = value; ; } } 559 public override Vector3 PIDTarget { set { m_PIDTarget = value; ; } }
561 public override bool PIDActive { set { m_usePID = value; } } 560 public override bool PIDActive { set { m_usePID = value; } }
562 public override float PIDTau { set { m_PIDTau = value; } } 561 public override float PIDTau { set { m_PIDTau = value; } }
563 562
@@ -572,20 +571,20 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
572 public override float APIDDamping { set { return; } } 571 public override float APIDDamping { set { return; } }
573 572
574 573
575 public override void AddForce(PhysicsVector force, bool pushforce) 574 public override void AddForce(Vector3 force, bool pushforce)
576 { 575 {
577 m_forcelist.Add(force); 576 m_forcelist.Add(force);
578 m_taintforce = true; 577 m_taintforce = true;
579 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); 578 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
580 } 579 }
581 580
582 public override void AddAngularForce(PhysicsVector force, bool pushforce) 581 public override void AddAngularForce(Vector3 force, bool pushforce)
583 { 582 {
584 m_angularforcelist.Add(force); 583 m_angularforcelist.Add(force);
585 m_taintaddangularforce = true; 584 m_taintaddangularforce = true;
586 } 585 }
587 586
588 public override void SetMomentum(PhysicsVector momentum) 587 public override void SetMomentum(Vector3 momentum)
589 { 588 {
590 } 589 }
591 590
@@ -783,7 +782,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
783 782
784 } 783 }
785 784
786 if (!_position.IsIdentical(m_taintposition, 0f)) 785 if (!_position.ApproxEquals(m_taintposition, 0f))
787 { 786 {
788 m_log.Debug("[PHYSICS]: TaintMove"); 787 m_log.Debug("[PHYSICS]: TaintMove");
789 changemove(timestep); 788 changemove(timestep);
@@ -801,7 +800,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
801 } 800 }
802 // 801 //
803 802
804 if (!_size.IsIdentical(m_taintsize, 0)) 803 if (!_size.ApproxEquals(m_taintsize, 0f))
805 { 804 {
806 m_log.Debug("[PHYSICS]: TaintSize"); 805 m_log.Debug("[PHYSICS]: TaintSize");
807 changesize(timestep); 806 changesize(timestep);
@@ -825,7 +824,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
825 m_log.Debug("[PHYSICS]: TaintAngularForce"); 824 m_log.Debug("[PHYSICS]: TaintAngularForce");
826 changeAddAngularForce(timestep); 825 changeAddAngularForce(timestep);
827 } 826 }
828 if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) 827 if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
829 { 828 {
830 m_log.Debug("[PHYSICS]: TaintTorque"); 829 m_log.Debug("[PHYSICS]: TaintTorque");
831 changeSetTorque(timestep); 830 changeSetTorque(timestep);
@@ -840,7 +839,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
840 m_log.Debug("[PHYSICS]: TaintSelected"); 839 m_log.Debug("[PHYSICS]: TaintSelected");
841 changeSelectedStatus(timestep); 840 changeSelectedStatus(timestep);
842 } 841 }
843 if (!m_taintVelocity.IsIdentical(PhysicsVector.Zero, 0.001f)) 842 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
844 { 843 {
845 m_log.Debug("[PHYSICS]: TaintVelocity"); 844 m_log.Debug("[PHYSICS]: TaintVelocity");
846 changevelocity(timestep); 845 changevelocity(timestep);
@@ -854,7 +853,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
854 { 853 {
855 changefloatonwater(timestep); 854 changefloatonwater(timestep);
856 } 855 }
857 if (!m_angularlock.IsIdentical(m_taintAngularLock, 0)) 856 if (!m_angularlock.ApproxEquals(m_taintAngularLock, 0))
858 { 857 {
859 m_log.Debug("[PHYSICS]: TaintAngularLock"); 858 m_log.Debug("[PHYSICS]: TaintAngularLock");
860 changeAngularLock(timestep); 859 changeAngularLock(timestep);
@@ -1017,7 +1016,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1017 { 1016 {
1018 if (_parent_scene.needsMeshing(_pbs)) 1017 if (_parent_scene.needsMeshing(_pbs))
1019 { 1018 {
1020 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); 1019 ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
1021 // createmesh returns null when it doesn't mesh. 1020 // createmesh returns null when it doesn't mesh.
1022 CreateGeom(IntPtr.Zero, _mesh); 1021 CreateGeom(IntPtr.Zero, _mesh);
1023 } 1022 }
@@ -1034,7 +1033,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1034 return _parent_scene.needsMeshing(_pbs); 1033 return _parent_scene.needsMeshing(_pbs);
1035 } 1034 }
1036 1035
1037 internal void ProcessGeomCreationAsTriMesh(PhysicsVector positionOffset, Quaternion orientation) 1036 internal void ProcessGeomCreationAsTriMesh(Vector3 positionOffset, Quaternion orientation)
1038 { 1037 {
1039 // Don't need to re-enable body.. it's done in SetMesh 1038 // Don't need to re-enable body.. it's done in SetMesh
1040 float meshlod = _parent_scene.meshSculptLOD; 1039 float meshlod = _parent_scene.meshSculptLOD;
@@ -1043,7 +1042,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1043 meshlod = _parent_scene.MeshSculptphysicalLOD; 1042 meshlod = _parent_scene.MeshSculptphysicalLOD;
1044 1043
1045 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical); 1044 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical);
1046 if (!positionOffset.IsIdentical(PhysicsVector.Zero, 0.001f) || orientation != Quaternion.Identity) 1045 if (!positionOffset.ApproxEquals(Vector3.Zero, 0.001f) || orientation != Quaternion.Identity)
1047 { 1046 {
1048 1047
1049 float[] xyz = new float[3]; 1048 float[] xyz = new float[3];
@@ -1207,7 +1206,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1207 //m_log.Info("[PHYSICS]: dequeing forcelist"); 1206 //m_log.Info("[PHYSICS]: dequeing forcelist");
1208 if (IsPhysical) 1207 if (IsPhysical)
1209 { 1208 {
1210 PhysicsVector iforce = new PhysicsVector(); 1209 Vector3 iforce = Vector3.Zero;
1211 for (int i = 0; i < m_forcelist.Count; i++) 1210 for (int i = 0; i < m_forcelist.Count; i++)
1212 { 1211 {
1213 iforce = iforce + m_forcelist[i]; 1212 iforce = iforce + m_forcelist[i];
@@ -1242,7 +1241,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1242 //m_log.Info("[PHYSICS]: dequeing forcelist"); 1241 //m_log.Info("[PHYSICS]: dequeing forcelist");
1243 if (IsPhysical) 1242 if (IsPhysical)
1244 { 1243 {
1245 PhysicsVector iforce = new PhysicsVector(); 1244 Vector3 iforce = Vector3.Zero;
1246 for (int i = 0; i < m_angularforcelist.Count; i++) 1245 for (int i = 0; i < m_angularforcelist.Count; i++)
1247 { 1246 {
1248 iforce = iforce + m_angularforcelist[i]; 1247 iforce = iforce + m_angularforcelist[i];
@@ -1281,7 +1280,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1281 } 1280 }
1282 } 1281 }
1283 } 1282 }
1284 m_taintTorque = new PhysicsVector(0, 0, 0); 1283 m_taintTorque = Vector3.Zero;
1285 } 1284 }
1286 1285
1287 private void changedisable(float timestep) 1286 private void changedisable(float timestep)
@@ -1322,7 +1321,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1322 1321
1323 //resetCollisionAccounting(); 1322 //resetCollisionAccounting();
1324 } 1323 }
1325 m_taintVelocity = PhysicsVector.Zero; 1324 m_taintVelocity = Vector3.Zero;
1326 } 1325 }
1327 1326
1328 private void changelink(float timestep) 1327 private void changelink(float timestep)
@@ -1366,7 +1365,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1366 1365
1367 if (m_taintparent != null) 1366 if (m_taintparent != null)
1368 { 1367 {
1369 m_taintparent.Position.Z = m_taintparent.Position.Z + 0.02f; 1368 Vector3 taintparentPosition = m_taintparent.Position;
1369 taintparentPosition.Z = m_taintparent.Position.Z + 0.02f;
1370 m_taintparent.Position = taintparentPosition;
1370 _parent_scene.AddPhysicsActorTaint(m_taintparent); 1371 _parent_scene.AddPhysicsActorTaint(m_taintparent);
1371 } 1372 }
1372 } 1373 }
@@ -1387,7 +1388,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1387 { 1388 {
1388 if (_parent == null) 1389 if (_parent == null)
1389 { 1390 {
1390 if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f, 1f, 1f), 0)) 1391 if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
1391 { 1392 {
1392 //d.BodySetFiniteRotationMode(Body, 0); 1393 //d.BodySetFiniteRotationMode(Body, 0);
1393 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z); 1394 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
@@ -1400,7 +1401,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1400 } 1401 }
1401 1402
1402 } 1403 }
1403 m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); 1404 m_angularlock = m_taintAngularLock;
1404 1405
1405 } 1406 }
1406 #endregion 1407 #endregion
@@ -1465,17 +1466,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1465 // TODO: NEED btVector3 for Linear Velocity 1466 // TODO: NEED btVector3 for Linear Velocity
1466 // NEED btVector3 for Position 1467 // NEED btVector3 for Position
1467 1468
1468 PhysicsVector pos = new PhysicsVector(_position.X, _position.Y, _position.Z); //TODO: Insert values gotten from bullet 1469 Vector3 pos = _position; //TODO: Insert values gotten from bullet
1469 PhysicsVector vel = new PhysicsVector(_velocity.X, _velocity.Y, _velocity.Z); 1470 Vector3 vel = _velocity;
1470 1471
1471 _target_velocity = 1472 _target_velocity =
1472 new PhysicsVector( 1473 new Vector3(
1473 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), 1474 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1474 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), 1475 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1475 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep) 1476 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
1476 ); 1477 );
1477 1478
1478 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1479 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1479 { 1480 {
1480 1481
1481 /* TODO: Do Bullet equiv 1482 /* TODO: Do Bullet equiv
@@ -1517,8 +1518,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1517 { 1518 {
1518 PID_G = m_PIDTau + 1; 1519 PID_G = m_PIDTau + 1;
1519 } 1520 }
1520 PhysicsVector pos = new PhysicsVector(0, 0, 0); //TODO: Insert values gotten from bullet 1521 Vector3 pos = Vector3.Zero; //TODO: Insert values gotten from bullet
1521 PhysicsVector vel = new PhysicsVector(0, 0, 0); 1522 Vector3 vel = Vector3.Zero;
1522 1523
1523 // determine what our target height really is based on HoverType 1524 // determine what our target height really is based on HoverType
1524 switch (m_PIDHoverType) 1525 switch (m_PIDHoverType)
@@ -1550,13 +1551,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1550 1551
1551 1552
1552 _target_velocity = 1553 _target_velocity =
1553 new PhysicsVector(0.0f, 0.0f, 1554 new Vector3(0.0f, 0.0f,
1554 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep) 1555 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1555 ); 1556 );
1556 1557
1557 // if velocity is zero, use position control; otherwise, velocity control 1558 // if velocity is zero, use position control; otherwise, velocity control
1558 1559
1559 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1560 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1560 { 1561 {
1561 1562
1562 /* TODO: Do Bullet Equiv 1563 /* TODO: Do Bullet Equiv
@@ -1631,8 +1632,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1631 else 1632 else
1632 { 1633 {
1633 if (m_zeroPosition == null) 1634 if (m_zeroPosition == null)
1634 m_zeroPosition = new PhysicsVector(0, 0, 0); 1635 m_zeroPosition = Vector3.Zero;
1635 m_zeroPosition.setValues(_position.X, _position.Y, _position.Z); 1636 m_zeroPosition = _position;
1636 return; 1637 return;
1637 } 1638 }
1638 } 1639 }
@@ -2182,7 +2183,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2182 2183
2183 //if (hasTrimesh) 2184 //if (hasTrimesh)
2184 //{ 2185 //{
2185 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); 2186 ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
2186 // createmesh returns null when it doesn't mesh. 2187 // createmesh returns null when it doesn't mesh.
2187 2188
2188 /* 2189 /*
@@ -2202,11 +2203,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2202 { 2203 {
2203 if (chld == null) 2204 if (chld == null)
2204 continue; 2205 continue;
2205 PhysicsVector offset = chld.Position - Position; 2206 Vector3 offset = chld.Position - Position;
2206 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); 2207 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z);
2207 pos *= Quaternion.Inverse(Orientation); 2208 pos *= Quaternion.Inverse(Orientation);
2208 //pos *= Orientation; 2209 //pos *= Orientation;
2209 offset.setValues(pos.X, pos.Y, pos.Z); 2210 offset = pos;
2210 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation); 2211 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
2211 2212
2212 _mesh.Append(chld._mesh); 2213 _mesh.Append(chld._mesh);
@@ -2438,7 +2439,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2438 m_collisionscore = 0; 2439 m_collisionscore = 0;
2439 m_disabled = false; 2440 m_disabled = false;
2440 // The body doesn't already have a finite rotation mode set here 2441 // The body doesn't already have a finite rotation mode set here
2441 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 2442 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
2442 { 2443 {
2443 // TODO: Create Angular Motor on Axis Lock! 2444 // TODO: Create Angular Motor on Axis Lock!
2444 } 2445 }
@@ -2452,7 +2453,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2452 { 2453 {
2453 if (_parent == null) 2454 if (_parent == null)
2454 { 2455 {
2455 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2456 Vector3 pv = Vector3.Zero;
2456 bool lastZeroFlag = _zeroFlag; 2457 bool lastZeroFlag = _zeroFlag;
2457 if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero) 2458 if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero)
2458 tempPosition3.Dispose(); 2459 tempPosition3.Dispose();
@@ -2476,10 +2477,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2476 tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel 2477 tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel
2477 tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel 2478 tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel
2478 2479
2479 _torque.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(), 2480 _torque = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(),
2480 tempAngularVelocity1.getZ()); 2481 tempAngularVelocity1.getZ());
2481 PhysicsVector l_position = new PhysicsVector(); 2482 Vector3 l_position = Vector3.Zero;
2482 Quaternion l_orientation = new Quaternion(); 2483 Quaternion l_orientation = Quaternion.Identity;
2483 m_lastposition = _position; 2484 m_lastposition = _position;
2484 m_lastorientation = _orientation; 2485 m_lastorientation = _orientation;
2485 2486
@@ -2603,20 +2604,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2603 _velocity.Z = tempLinearVelocity1.getZ(); 2604 _velocity.Z = tempLinearVelocity1.getZ();
2604 2605
2605 _acceleration = ((_velocity - m_lastVelocity) / 0.1f); 2606 _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
2606 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, 2607 _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f,
2607 _velocity.Y - m_lastVelocity.Y / 0.1f, 2608 _velocity.Y - m_lastVelocity.Y / 0.1f,
2608 _velocity.Z - m_lastVelocity.Z / 0.1f); 2609 _velocity.Z - m_lastVelocity.Z / 0.1f);
2609 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); 2610 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
2610 2611
2611 if (_velocity.IsIdentical(pv, 0.5f)) 2612 if (_velocity.ApproxEquals(pv, 0.5f))
2612 { 2613 {
2613 m_rotationalVelocity = pv; 2614 m_rotationalVelocity = pv;
2614 } 2615 }
2615 else 2616 else
2616 { 2617 {
2617 2618 m_rotationalVelocity = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(), tempAngularVelocity1.getZ());
2618 m_rotationalVelocity.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(),
2619 tempAngularVelocity1.getZ());
2620 } 2619 }
2621 2620
2622 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString()); 2621 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
@@ -2670,7 +2669,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2670 m_taintremove = true; 2669 m_taintremove = true;
2671 } 2670 }
2672 2671
2673 internal void EnableAxisMotor(PhysicsVector axislock) 2672 internal void EnableAxisMotor(Vector3 axislock)
2674 { 2673 {
2675 if (m_aMotor != null) 2674 if (m_aMotor != null)
2676 DisableAxisMotor(); 2675 DisableAxisMotor();
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs
index 18d4bab..9e048ab 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETScene.cs
@@ -139,7 +139,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
139 139
140 } 140 }
141 141
142 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 142 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
143 { 143 {
144 BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP, 144 BulletDotNETCharacter chr = new BulletDotNETCharacter(avName, this, position, size, avPIDD, avPIDP,
145 avCapRadius, avStandupTensor, avDensity, 145 avCapRadius, avStandupTensor, avDensity,
@@ -177,14 +177,14 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
177 } 177 }
178 } 178 }
179 179
180 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, 180 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
181 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) 181 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
182 { 182 {
183 PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z); 183 Vector3 pos = position;
184 //pos.X = position.X; 184 //pos.X = position.X;
185 //pos.Y = position.Y; 185 //pos.Y = position.Y;
186 //pos.Z = position.Z; 186 //pos.Z = position.Z;
187 PhysicsVector siz = new PhysicsVector(); 187 Vector3 siz = Vector3.Zero;
188 siz.X = size.X; 188 siz.X = size.X;
189 siz.Y = size.Y; 189 siz.Y = size.Y;
190 siz.Z = size.Z; 190 siz.Z = size.Z;
@@ -201,12 +201,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
201 return newPrim; 201 return newPrim;
202 } 202 }
203 203
204 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation) 204 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation)
205 { 205 {
206 return AddPrimShape(primName, pbs, position, size, rotation, false); 206 return AddPrimShape(primName, pbs, position, size, rotation, false);
207 } 207 }
208 208
209 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, PhysicsVector size, Quaternion rotation, bool isPhysical) 209 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position, Vector3 size, Quaternion rotation, bool isPhysical)
210 { 210 {
211 PhysicsActor result; 211 PhysicsActor result;
212 IMesh mesh = null; 212 IMesh mesh = null;
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 14b8f39..0b3cee7 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -52,14 +52,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin
52 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 52 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 //Vector3 54 //Vector3
55 public static Vector3 PhysicsVectorToXnaVector3(PhysicsVector physicsVector) 55 public static Vector3 PhysicsVectorToXnaVector3(OpenMetaverse.Vector3 physicsVector)
56 { 56 {
57 return new Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z); 57 return new Vector3(physicsVector.X, physicsVector.Y, physicsVector.Z);
58 } 58 }
59 59
60 public static PhysicsVector XnaVector3ToPhysicsVector(Vector3 xnaVector3) 60 public static OpenMetaverse.Vector3 XnaVector3ToPhysicsVector(Vector3 xnaVector3)
61 { 61 {
62 return new PhysicsVector(xnaVector3.X, xnaVector3.Y, xnaVector3.Z); 62 return new OpenMetaverse.Vector3(xnaVector3.X, xnaVector3.Y, xnaVector3.Z);
63 } 63 }
64 64
65 //Quaternion 65 //Quaternion
@@ -349,7 +349,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
349 vertexBase = new Vector3[iVertexCount]; 349 vertexBase = new Vector3[iVertexCount];
350 for (int i = 0; i < iVertexCount; i++) 350 for (int i = 0; i < iVertexCount; i++)
351 { 351 {
352 PhysicsVector v = mesh.getVertexList()[i]; 352 OpenMetaverse.Vector3 v = mesh.getVertexList()[i];
353 if (v != null) // Note, null has special meaning. See meshing code for details 353 if (v != null) // Note, null has special meaning. See meshing code for details
354 vertexBase[i] = BulletXMaths.PhysicsVectorToXnaVector3(v); 354 vertexBase[i] = BulletXMaths.PhysicsVectorToXnaVector3(v);
355 else 355 else
@@ -392,7 +392,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
392 private int preCheckCollision(BulletXActor actA, Vector3 vNormal, float fDist) 392 private int preCheckCollision(BulletXActor actA, Vector3 vNormal, float fDist)
393 { 393 {
394 float fstartSide; 394 float fstartSide;
395 PhysicsVector v = actA.Position; 395 OpenMetaverse.Vector3 v = actA.Position;
396 Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v); 396 Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v);
397 397
398 fstartSide = Vector3.Dot(vNormal, v3) - fDist; 398 fstartSide = Vector3.Dot(vNormal, v3) - fDist;
@@ -404,7 +404,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
404 { 404 {
405 Vector3 perPlaneNormal; 405 Vector3 perPlaneNormal;
406 float fPerPlaneDist; 406 float fPerPlaneDist;
407 PhysicsVector v = actA.Position; 407 OpenMetaverse.Vector3 v = actA.Position;
408 Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v); 408 Vector3 v3 = BulletXMaths.PhysicsVectorToXnaVector3(v);
409 //check AB 409 //check AB
410 Vector3 v1; 410 Vector3 v1;
@@ -573,9 +573,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
573 573
574 } 574 }
575 575
576 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 576 public override PhysicsActor AddAvatar(string avName, OpenMetaverse.Vector3 position, OpenMetaverse.Vector3 size, bool isFlying)
577 { 577 {
578 PhysicsVector pos = new PhysicsVector(); 578 OpenMetaverse.Vector3 pos = OpenMetaverse.Vector3.Zero;
579 pos.X = position.X; 579 pos.X = position.X;
580 pos.Y = position.Y; 580 pos.Y = position.Y;
581 pos.Z = position.Z + 20; 581 pos.Z = position.Z + 20;
@@ -611,14 +611,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin
611 } 611 }
612 } 612 }
613 613
614 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 614 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position,
615 PhysicsVector size, OpenMetaverse.Quaternion rotation) 615 OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation)
616 { 616 {
617 return AddPrimShape(primName, pbs, position, size, rotation, false); 617 return AddPrimShape(primName, pbs, position, size, rotation, false);
618 } 618 }
619 619
620 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 620 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, OpenMetaverse.Vector3 position,
621 PhysicsVector size, OpenMetaverse.Quaternion rotation, bool isPhysical) 621 OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation, bool isPhysical)
622 { 622 {
623 PhysicsActor result; 623 PhysicsActor result;
624 624
@@ -645,7 +645,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
645 return result; 645 return result;
646 } 646 }
647 647
648 public PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, OpenMetaverse.Quaternion rotation, 648 public PhysicsActor AddPrim(String name, OpenMetaverse.Vector3 position, OpenMetaverse.Vector3 size, OpenMetaverse.Quaternion rotation,
649 IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) 649 IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical)
650 { 650 {
651 BulletXPrim newPrim = null; 651 BulletXPrim newPrim = null;
@@ -879,12 +879,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
879 { 879 {
880 protected bool flying = false; 880 protected bool flying = false;
881 protected bool _physical = false; 881 protected bool _physical = false;
882 protected PhysicsVector _position; 882 protected OpenMetaverse.Vector3 _position;
883 protected PhysicsVector _velocity; 883 protected OpenMetaverse.Vector3 _velocity;
884 protected PhysicsVector _size; 884 protected OpenMetaverse.Vector3 _size;
885 protected PhysicsVector _acceleration; 885 protected OpenMetaverse.Vector3 _acceleration;
886 protected OpenMetaverse.Quaternion _orientation; 886 protected OpenMetaverse.Quaternion _orientation;
887 protected PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; 887 protected OpenMetaverse.Vector3 m_rotationalVelocity;
888 protected RigidBody rigidBody; 888 protected RigidBody rigidBody;
889 protected int m_PhysicsActorType; 889 protected int m_PhysicsActorType;
890 private Boolean iscolliding = false; 890 private Boolean iscolliding = false;
@@ -900,7 +900,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
900 get { return false; } 900 get { return false; }
901 } 901 }
902 902
903 public override PhysicsVector Position 903 public override OpenMetaverse.Vector3 Position
904 { 904 {
905 get { return _position; } 905 get { return _position; }
906 set 906 set
@@ -913,13 +913,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin
913 } 913 }
914 } 914 }
915 915
916 public override PhysicsVector RotationalVelocity 916 public override OpenMetaverse.Vector3 RotationalVelocity
917 { 917 {
918 get { return m_rotationalVelocity; } 918 get { return m_rotationalVelocity; }
919 set { m_rotationalVelocity = value; } 919 set { m_rotationalVelocity = value; }
920 } 920 }
921 921
922 public override PhysicsVector Velocity 922 public override OpenMetaverse.Vector3 Velocity
923 { 923 {
924 get { return _velocity; } 924 get { return _velocity; }
925 set 925 set
@@ -934,7 +934,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
934 } 934 }
935 else 935 else
936 { 936 {
937 _velocity = new PhysicsVector(); 937 _velocity = OpenMetaverse.Vector3.Zero;
938 } 938 }
939 } 939 }
940 } 940 }
@@ -944,7 +944,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
944 get { return 0f; } 944 get { return 0f; }
945 set { } 945 set { }
946 } 946 }
947 public override PhysicsVector Size 947 public override OpenMetaverse.Vector3 Size
948 { 948 {
949 get { return _size; } 949 get { return _size; }
950 set 950 set
@@ -956,9 +956,9 @@ namespace OpenSim.Region.Physics.BulletXPlugin
956 } 956 }
957 } 957 }
958 958
959 public override PhysicsVector Force 959 public override OpenMetaverse.Vector3 Force
960 { 960 {
961 get { return PhysicsVector.Zero; } 961 get { return OpenMetaverse.Vector3.Zero; }
962 set { return; } 962 set { return; }
963 } 963 }
964 964
@@ -973,7 +973,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
973 973
974 } 974 }
975 975
976 public override void VehicleVectorParam(int param, PhysicsVector value) 976 public override void VehicleVectorParam(int param, OpenMetaverse.Vector3 value)
977 { 977 {
978 978
979 } 979 }
@@ -988,14 +988,14 @@ namespace OpenSim.Region.Physics.BulletXPlugin
988 988
989 } 989 }
990 990
991 public override PhysicsVector CenterOfMass 991 public override OpenMetaverse.Vector3 CenterOfMass
992 { 992 {
993 get { return PhysicsVector.Zero; } 993 get { return OpenMetaverse.Vector3.Zero; }
994 } 994 }
995 995
996 public override PhysicsVector GeometricCenter 996 public override OpenMetaverse.Vector3 GeometricCenter
997 { 997 {
998 get { return PhysicsVector.Zero; } 998 get { return OpenMetaverse.Vector3.Zero; }
999 } 999 }
1000 1000
1001 public override PrimitiveBaseShape Shape 1001 public override PrimitiveBaseShape Shape
@@ -1009,7 +1009,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1009 set { return; } 1009 set { return; }
1010 } 1010 }
1011 1011
1012 public override PhysicsVector Acceleration 1012 public override OpenMetaverse.Vector3 Acceleration
1013 { 1013 {
1014 get { return _acceleration; } 1014 get { return _acceleration; }
1015 } 1015 }
@@ -1036,7 +1036,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1036 1036
1037 } 1037 }
1038 1038
1039 public override void LockAngularMotion(PhysicsVector axis) 1039 public override void LockAngularMotion(OpenMetaverse.Vector3 axis)
1040 { 1040 {
1041 1041
1042 } 1042 }
@@ -1129,7 +1129,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1129 set { return; } 1129 set { return; }
1130 } 1130 }
1131 1131
1132 public virtual void SetAcceleration(PhysicsVector accel) 1132 public virtual void SetAcceleration(OpenMetaverse.Vector3 accel)
1133 { 1133 {
1134 lock (BulletXScene.BulletXLock) 1134 lock (BulletXScene.BulletXLock)
1135 { 1135 {
@@ -1143,19 +1143,19 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1143 set { } 1143 set { }
1144 } 1144 }
1145 1145
1146 public override void AddForce(PhysicsVector force, bool pushforce) 1146 public override void AddForce(OpenMetaverse.Vector3 force, bool pushforce)
1147 { 1147 {
1148 } 1148 }
1149 public override PhysicsVector Torque 1149 public override OpenMetaverse.Vector3 Torque
1150 { 1150 {
1151 get { return PhysicsVector.Zero; } 1151 get { return OpenMetaverse.Vector3.Zero; }
1152 set { return; } 1152 set { return; }
1153 } 1153 }
1154 public override void AddAngularForce(PhysicsVector force, bool pushforce) 1154 public override void AddAngularForce(OpenMetaverse.Vector3 force, bool pushforce)
1155 { 1155 {
1156 } 1156 }
1157 1157
1158 public override void SetMomentum(PhysicsVector momentum) 1158 public override void SetMomentum(OpenMetaverse.Vector3 momentum)
1159 { 1159 {
1160 } 1160 }
1161 1161
@@ -1174,7 +1174,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1174 Translate(_position); 1174 Translate(_position);
1175 } 1175 }
1176 1176
1177 protected internal void Translate(PhysicsVector _newPos) 1177 protected internal void Translate(OpenMetaverse.Vector3 _newPos)
1178 { 1178 {
1179 Vector3 _translation; 1179 Vector3 _translation;
1180 _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition; 1180 _translation = BulletXMaths.PhysicsVectorToXnaVector3(_newPos) - rigidBody.CenterOfMassPosition;
@@ -1186,7 +1186,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1186 Speed(_velocity); 1186 Speed(_velocity);
1187 } 1187 }
1188 1188
1189 protected internal void Speed(PhysicsVector _newSpeed) 1189 protected internal void Speed(OpenMetaverse.Vector3 _newSpeed)
1190 { 1190 {
1191 Vector3 _speed; 1191 Vector3 _speed;
1192 _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed); 1192 _speed = BulletXMaths.PhysicsVectorToXnaVector3(_newSpeed);
@@ -1212,7 +1212,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1212 ReSize(_size); 1212 ReSize(_size);
1213 } 1213 }
1214 1214
1215 protected internal virtual void ReSize(PhysicsVector _newSize) 1215 protected internal virtual void ReSize(OpenMetaverse.Vector3 _newSize)
1216 { 1216 {
1217 } 1217 }
1218 1218
@@ -1227,7 +1227,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1227 { 1227 {
1228 1228
1229 } 1229 }
1230 public override PhysicsVector PIDTarget { set { return; } } 1230 public override OpenMetaverse.Vector3 PIDTarget { set { return; } }
1231 public override bool PIDActive { set { return; } } 1231 public override bool PIDActive { set { return; } }
1232 public override float PIDTau { set { return; } } 1232 public override float PIDTau { set { return; } }
1233 1233
@@ -1276,19 +1276,19 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1276 /// </summary> 1276 /// </summary>
1277 public class BulletXCharacter : BulletXActor 1277 public class BulletXCharacter : BulletXActor
1278 { 1278 {
1279 public BulletXCharacter(BulletXScene parent_scene, PhysicsVector pos) 1279 public BulletXCharacter(BulletXScene parent_scene, OpenMetaverse.Vector3 pos)
1280 : this(String.Empty, parent_scene, pos) 1280 : this(String.Empty, parent_scene, pos)
1281 { 1281 {
1282 } 1282 }
1283 1283
1284 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos) 1284 public BulletXCharacter(String avName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos)
1285 : this(avName, parent_scene, pos, new PhysicsVector(), new PhysicsVector(), new PhysicsVector(), 1285 : this(avName, parent_scene, pos, OpenMetaverse.Vector3.Zero, OpenMetaverse.Vector3.Zero, OpenMetaverse.Vector3.Zero,
1286 OpenMetaverse.Quaternion.Identity) 1286 OpenMetaverse.Quaternion.Identity)
1287 { 1287 {
1288 } 1288 }
1289 1289
1290 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, 1290 public BulletXCharacter(String avName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos, OpenMetaverse.Vector3 velocity,
1291 PhysicsVector size, PhysicsVector acceleration, OpenMetaverse.Quaternion orientation) 1291 OpenMetaverse.Vector3 size, OpenMetaverse.Vector3 acceleration, OpenMetaverse.Quaternion orientation)
1292 : base(avName) 1292 : base(avName)
1293 { 1293 {
1294 //This fields will be removed. They're temporal 1294 //This fields will be removed. They're temporal
@@ -1343,25 +1343,25 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1343 set { return; } 1343 set { return; }
1344 } 1344 }
1345 1345
1346 public override PhysicsVector Position 1346 public override OpenMetaverse.Vector3 Position
1347 { 1347 {
1348 get { return base.Position; } 1348 get { return base.Position; }
1349 set { base.Position = value; } 1349 set { base.Position = value; }
1350 } 1350 }
1351 1351
1352 public override PhysicsVector Velocity 1352 public override OpenMetaverse.Vector3 Velocity
1353 { 1353 {
1354 get { return base.Velocity; } 1354 get { return base.Velocity; }
1355 set { base.Velocity = value; } 1355 set { base.Velocity = value; }
1356 } 1356 }
1357 1357
1358 public override PhysicsVector Size 1358 public override OpenMetaverse.Vector3 Size
1359 { 1359 {
1360 get { return base.Size; } 1360 get { return base.Size; }
1361 set { base.Size = value; } 1361 set { base.Size = value; }
1362 } 1362 }
1363 1363
1364 public override PhysicsVector Acceleration 1364 public override OpenMetaverse.Vector3 Acceleration
1365 { 1365 {
1366 get { return base.Acceleration; } 1366 get { return base.Acceleration; }
1367 } 1367 }
@@ -1390,17 +1390,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1390 set { base.Kinematic = value; } 1390 set { base.Kinematic = value; }
1391 } 1391 }
1392 1392
1393 public override void SetAcceleration(PhysicsVector accel) 1393 public override void SetAcceleration(OpenMetaverse.Vector3 accel)
1394 { 1394 {
1395 base.SetAcceleration(accel); 1395 base.SetAcceleration(accel);
1396 } 1396 }
1397 1397
1398 public override void AddForce(PhysicsVector force, bool pushforce) 1398 public override void AddForce(OpenMetaverse.Vector3 force, bool pushforce)
1399 { 1399 {
1400 base.AddForce(force, pushforce); 1400 base.AddForce(force, pushforce);
1401 } 1401 }
1402 1402
1403 public override void SetMomentum(PhysicsVector momentum) 1403 public override void SetMomentum(OpenMetaverse.Vector3 momentum)
1404 { 1404 {
1405 base.SetMomentum(momentum); 1405 base.SetMomentum(momentum);
1406 } 1406 }
@@ -1450,7 +1450,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1450 m.Translation = v3; 1450 m.Translation = v3;
1451 rigidBody.WorldTransform = m; 1451 rigidBody.WorldTransform = m;
1452 //When an Avie touch the ground it's vertical velocity it's reduced to ZERO 1452 //When an Avie touch the ground it's vertical velocity it's reduced to ZERO
1453 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); 1453 Speed(new OpenMetaverse.Vector3(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
1454 } 1454 }
1455 } 1455 }
1456 1456
@@ -1472,7 +1472,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1472 //For now all prims have the same density, all prims are made of water. Be water my friend! :D 1472 //For now all prims have the same density, all prims are made of water. Be water my friend! :D
1473 private const float _density = 1000.0f; 1473 private const float _density = 1000.0f;
1474 private BulletXScene _parent_scene; 1474 private BulletXScene _parent_scene;
1475 private PhysicsVector m_prev_position = new PhysicsVector(0, 0, 0); 1475 private OpenMetaverse.Vector3 m_prev_position;
1476 private bool m_lastUpdateSent = false; 1476 private bool m_lastUpdateSent = false;
1477 //added by jed zhu 1477 //added by jed zhu
1478 private IMesh _mesh; 1478 private IMesh _mesh;
@@ -1480,17 +1480,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1480 1480
1481 1481
1482 1482
1483 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, 1483 public BulletXPrim(String primName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos, OpenMetaverse.Vector3 size,
1484 OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) 1484 OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical)
1485 : this( 1485 : this(
1486 primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs, 1486 primName, parent_scene, pos, OpenMetaverse.Vector3.Zero, size, OpenMetaverse.Vector3.Zero, rotation, mesh, pbs,
1487 isPhysical) 1487 isPhysical)
1488 { 1488 {
1489 } 1489 }
1490 1490
1491 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, 1491 public BulletXPrim(String primName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos, OpenMetaverse.Vector3 velocity,
1492 PhysicsVector size, 1492 OpenMetaverse.Vector3 size,
1493 PhysicsVector acceleration, OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, 1493 OpenMetaverse.Vector3 acceleration, OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs,
1494 bool isPhysical) 1494 bool isPhysical)
1495 : base(primName) 1495 : base(primName)
1496 { 1496 {
@@ -1501,7 +1501,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1501 1501
1502 _position = pos; 1502 _position = pos;
1503 _physical = isPhysical; 1503 _physical = isPhysical;
1504 _velocity = _physical ? velocity : new PhysicsVector(); 1504 _velocity = _physical ? velocity : OpenMetaverse.Vector3.Zero;
1505 _size = size; 1505 _size = size;
1506 _acceleration = acceleration; 1506 _acceleration = acceleration;
1507 _orientation = rotation; 1507 _orientation = rotation;
@@ -1517,19 +1517,19 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1517 set { return; } 1517 set { return; }
1518 } 1518 }
1519 1519
1520 public override PhysicsVector Position 1520 public override OpenMetaverse.Vector3 Position
1521 { 1521 {
1522 get { return base.Position; } 1522 get { return base.Position; }
1523 set { base.Position = value; } 1523 set { base.Position = value; }
1524 } 1524 }
1525 1525
1526 public override PhysicsVector Velocity 1526 public override OpenMetaverse.Vector3 Velocity
1527 { 1527 {
1528 get { return base.Velocity; } 1528 get { return base.Velocity; }
1529 set { base.Velocity = value; } 1529 set { base.Velocity = value; }
1530 } 1530 }
1531 1531
1532 public override PhysicsVector Size 1532 public override OpenMetaverse.Vector3 Size
1533 { 1533 {
1534 get { return _size; } 1534 get { return _size; }
1535 set 1535 set
@@ -1542,7 +1542,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1542 } 1542 }
1543 } 1543 }
1544 1544
1545 public override PhysicsVector Acceleration 1545 public override OpenMetaverse.Vector3 Acceleration
1546 { 1546 {
1547 get { return base.Acceleration; } 1547 get { return base.Acceleration; }
1548 } 1548 }
@@ -1603,7 +1603,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1603 set { base.Kinematic = value; } 1603 set { base.Kinematic = value; }
1604 } 1604 }
1605 1605
1606 public override void SetAcceleration(PhysicsVector accel) 1606 public override void SetAcceleration(OpenMetaverse.Vector3 accel)
1607 { 1607 {
1608 lock (BulletXScene.BulletXLock) 1608 lock (BulletXScene.BulletXLock)
1609 { 1609 {
@@ -1611,12 +1611,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1611 } 1611 }
1612 } 1612 }
1613 1613
1614 public override void AddForce(PhysicsVector force, bool pushforce) 1614 public override void AddForce(OpenMetaverse.Vector3 force, bool pushforce)
1615 { 1615 {
1616 base.AddForce(force,pushforce); 1616 base.AddForce(force,pushforce);
1617 } 1617 }
1618 1618
1619 public override void SetMomentum(PhysicsVector momentum) 1619 public override void SetMomentum(OpenMetaverse.Vector3 momentum)
1620 { 1620 {
1621 base.SetMomentum(momentum); 1621 base.SetMomentum(momentum);
1622 } 1622 }
@@ -1633,7 +1633,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1633 //When a Prim touch the ground it's vertical velocity it's reduced to ZERO 1633 //When a Prim touch the ground it's vertical velocity it's reduced to ZERO
1634 //Static objects don't have linear velocity 1634 //Static objects don't have linear velocity
1635 if (_physical) 1635 if (_physical)
1636 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); 1636 Speed(new OpenMetaverse.Vector3(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
1637 } 1637 }
1638 } 1638 }
1639 1639
@@ -1652,7 +1652,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1652 { 1652 {
1653 if (!m_lastUpdateSent) 1653 if (!m_lastUpdateSent)
1654 { 1654 {
1655 _velocity = new PhysicsVector(0, 0, 0); 1655 _velocity = OpenMetaverse.Vector3.Zero;
1656 base.ScheduleTerseUpdate(); 1656 base.ScheduleTerseUpdate();
1657 m_lastUpdateSent = true; 1657 m_lastUpdateSent = true;
1658 } 1658 }
@@ -1674,8 +1674,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1674 1674
1675 #region Methods for updating values of RigidBody 1675 #region Methods for updating values of RigidBody
1676 1676
1677 protected internal void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos, 1677 protected internal void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, OpenMetaverse.Vector3 pos,
1678 PhysicsVector size) 1678 OpenMetaverse.Vector3 size)
1679 { 1679 {
1680 //For RigidBody Constructor. The next values might change 1680 //For RigidBody Constructor. The next values might change
1681 float _linearDamping = 0.0f; 1681 float _linearDamping = 0.0f;
@@ -1703,7 +1703,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1703 Vector3[] v3Vertices = new Vector3[iVertexCount]; 1703 Vector3[] v3Vertices = new Vector3[iVertexCount];
1704 for (int i = 0; i < iVertexCount; i++) 1704 for (int i = 0; i < iVertexCount; i++)
1705 { 1705 {
1706 PhysicsVector v = mesh.getVertexList()[i]; 1706 OpenMetaverse.Vector3 v = mesh.getVertexList()[i];
1707 if (v != null) // Note, null has special meaning. See meshing code for details 1707 if (v != null) // Note, null has special meaning. See meshing code for details
1708 v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v); 1708 v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v);
1709 else 1709 else
@@ -1729,7 +1729,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1729 } 1729 }
1730 } 1730 }
1731 1731
1732 protected internal void ReCreateRigidBody(PhysicsVector size) 1732 protected internal void ReCreateRigidBody(OpenMetaverse.Vector3 size)
1733 { 1733 {
1734 //There is a bug when trying to remove a rigidBody that is colliding with something.. 1734 //There is a bug when trying to remove a rigidBody that is colliding with something..
1735 try 1735 try
@@ -1749,7 +1749,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1749 GC.Collect(); 1749 GC.Collect();
1750 } 1750 }
1751 1751
1752 protected internal override void ReSize(PhysicsVector _newSize) 1752 protected internal override void ReSize(OpenMetaverse.Vector3 _newSize)
1753 { 1753 {
1754 //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't 1754 //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't
1755 //so i have to do it manually. That's recreating rigidbody 1755 //so i have to do it manually. That's recreating rigidbody
@@ -1764,8 +1764,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1764 /// </summary> 1764 /// </summary>
1765 internal class BulletXPlanet 1765 internal class BulletXPlanet
1766 { 1766 {
1767 private PhysicsVector _staticPosition; 1767 private OpenMetaverse.Vector3 _staticPosition;
1768// private PhysicsVector _staticVelocity; 1768// private Vector3 _staticVelocity;
1769// private OpenMetaverse.Quaternion _staticOrientation; 1769// private OpenMetaverse.Quaternion _staticOrientation;
1770 private float _mass; 1770 private float _mass;
1771 // private BulletXScene _parentscene; 1771 // private BulletXScene _parentscene;
@@ -1779,7 +1779,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1779 1779
1780 internal BulletXPlanet(BulletXScene parent_scene, float[] heightField) 1780 internal BulletXPlanet(BulletXScene parent_scene, float[] heightField)
1781 { 1781 {
1782 _staticPosition = new PhysicsVector(BulletXScene.MaxXY/2, BulletXScene.MaxXY/2, 0); 1782 _staticPosition = new OpenMetaverse.Vector3(BulletXScene.MaxXY / 2, BulletXScene.MaxXY / 2, 0);
1783// _staticVelocity = new PhysicsVector(); 1783// _staticVelocity = new PhysicsVector();
1784// _staticOrientation = OpenMetaverse.Quaternion.Identity; 1784// _staticOrientation = OpenMetaverse.Quaternion.Identity;
1785 _mass = 0; //No active 1785 _mass = 0; //No active
diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/Physics/Manager/IMesher.cs
index 1a8c948..1181b8d 100644
--- a/OpenSim/Region/Physics/Manager/IMesher.cs
+++ b/OpenSim/Region/Physics/Manager/IMesher.cs
@@ -28,13 +28,14 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenMetaverse;
31 32
32namespace OpenSim.Region.Physics.Manager 33namespace OpenSim.Region.Physics.Manager
33{ 34{
34 public interface IMesher 35 public interface IMesher
35 { 36 {
36 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod); 37 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod);
37 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical); 38 IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical);
38 } 39 }
39 40
40 public interface IVertex 41 public interface IVertex
@@ -43,7 +44,7 @@ namespace OpenSim.Region.Physics.Manager
43 44
44 public interface IMesh 45 public interface IMesh
45 { 46 {
46 List<PhysicsVector> getVertexList(); 47 List<Vector3> getVertexList();
47 int[] getIndexListAsInt(); 48 int[] getIndexListAsInt();
48 int[] getIndexListAsIntLocked(); 49 int[] getIndexListAsIntLocked();
49 float[] getVertexListAsFloatLocked(); 50 float[] getVertexListAsFloatLocked();
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 566746a..ea4db70 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -32,8 +32,8 @@ using OpenMetaverse;
32 32
33namespace OpenSim.Region.Physics.Manager 33namespace OpenSim.Region.Physics.Manager
34{ 34{
35 public delegate void PositionUpdate(PhysicsVector position); 35 public delegate void PositionUpdate(Vector3 position);
36 public delegate void VelocityUpdate(PhysicsVector velocity); 36 public delegate void VelocityUpdate(Vector3 velocity);
37 public delegate void OrientationUpdate(Quaternion orientation); 37 public delegate void OrientationUpdate(Quaternion orientation);
38 38
39 public enum ActorTypes : int 39 public enum ActorTypes : int
@@ -106,7 +106,7 @@ namespace OpenSim.Region.Physics.Manager
106 { 106 {
107 public delegate void RequestTerseUpdate(); 107 public delegate void RequestTerseUpdate();
108 public delegate void CollisionUpdate(EventArgs e); 108 public delegate void CollisionUpdate(EventArgs e);
109 public delegate void OutOfBounds(PhysicsVector pos); 109 public delegate void OutOfBounds(Vector3 pos);
110 110
111// disable warning: public events 111// disable warning: public events
112#pragma warning disable 67 112#pragma warning disable 67
@@ -125,7 +125,7 @@ namespace OpenSim.Region.Physics.Manager
125 125
126 public abstract bool Stopped { get; } 126 public abstract bool Stopped { get; }
127 127
128 public abstract PhysicsVector Size { get; set; } 128 public abstract Vector3 Size { get; set; }
129 129
130 public abstract PrimitiveBaseShape Shape { set; } 130 public abstract PrimitiveBaseShape Shape { set; }
131 131
@@ -144,7 +144,7 @@ namespace OpenSim.Region.Physics.Manager
144 144
145 public abstract void delink(); 145 public abstract void delink();
146 146
147 public abstract void LockAngularMotion(PhysicsVector axis); 147 public abstract void LockAngularMotion(Vector3 axis);
148 148
149 public virtual void RequestPhysicsterseUpdate() 149 public virtual void RequestPhysicsterseUpdate()
150 { 150 {
@@ -159,7 +159,7 @@ namespace OpenSim.Region.Physics.Manager
159 } 159 }
160 } 160 }
161 161
162 public virtual void RaiseOutOfBounds(PhysicsVector pos) 162 public virtual void RaiseOutOfBounds(Vector3 pos)
163 { 163 {
164 // Make a temporary copy of the event to avoid possibility of 164 // Make a temporary copy of the event to avoid possibility of
165 // a race condition if the last subscriber unsubscribes 165 // a race condition if the last subscriber unsubscribes
@@ -187,23 +187,23 @@ namespace OpenSim.Region.Physics.Manager
187 187
188 } 188 }
189 189
190 public abstract PhysicsVector Position { get; set; } 190 public abstract Vector3 Position { get; set; }
191 public abstract float Mass { get; } 191 public abstract float Mass { get; }
192 public abstract PhysicsVector Force { get; set; } 192 public abstract Vector3 Force { get; set; }
193 193
194 public abstract int VehicleType { get; set; } 194 public abstract int VehicleType { get; set; }
195 public abstract void VehicleFloatParam(int param, float value); 195 public abstract void VehicleFloatParam(int param, float value);
196 public abstract void VehicleVectorParam(int param, PhysicsVector value); 196 public abstract void VehicleVectorParam(int param, Vector3 value);
197 public abstract void VehicleRotationParam(int param, Quaternion rotation); 197 public abstract void VehicleRotationParam(int param, Quaternion rotation);
198 198
199 public abstract void SetVolumeDetect(int param); // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more 199 public abstract void SetVolumeDetect(int param); // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
200 200
201 public abstract PhysicsVector GeometricCenter { get; } 201 public abstract Vector3 GeometricCenter { get; }
202 public abstract PhysicsVector CenterOfMass { get; } 202 public abstract Vector3 CenterOfMass { get; }
203 public abstract PhysicsVector Velocity { get; set; } 203 public abstract Vector3 Velocity { get; set; }
204 public abstract PhysicsVector Torque { get; set; } 204 public abstract Vector3 Torque { get; set; }
205 public abstract float CollisionScore { get; set;} 205 public abstract float CollisionScore { get; set;}
206 public abstract PhysicsVector Acceleration { get; } 206 public abstract Vector3 Acceleration { get; }
207 public abstract Quaternion Orientation { get; set; } 207 public abstract Quaternion Orientation { get; set; }
208 public abstract int PhysicsActorType { get; set; } 208 public abstract int PhysicsActorType { get; set; }
209 public abstract bool IsPhysical { get; set; } 209 public abstract bool IsPhysical { get; set; }
@@ -214,12 +214,12 @@ namespace OpenSim.Region.Physics.Manager
214 public abstract bool CollidingGround { get; set; } 214 public abstract bool CollidingGround { get; set; }
215 public abstract bool CollidingObj { get; set; } 215 public abstract bool CollidingObj { get; set; }
216 public abstract bool FloatOnWater { set; } 216 public abstract bool FloatOnWater { set; }
217 public abstract PhysicsVector RotationalVelocity { get; set; } 217 public abstract Vector3 RotationalVelocity { get; set; }
218 public abstract bool Kinematic { get; set; } 218 public abstract bool Kinematic { get; set; }
219 public abstract float Buoyancy { get; set; } 219 public abstract float Buoyancy { get; set; }
220 220
221 // Used for MoveTo 221 // Used for MoveTo
222 public abstract PhysicsVector PIDTarget { set;} 222 public abstract Vector3 PIDTarget { set; }
223 public abstract bool PIDActive { set;} 223 public abstract bool PIDActive { set;}
224 public abstract float PIDTau { set; } 224 public abstract float PIDTau { set; }
225 225
@@ -251,9 +251,9 @@ namespace OpenSim.Region.Physics.Manager
251 get{ return false; } 251 get{ return false; }
252 } 252 }
253 253
254 public override PhysicsVector Position 254 public override Vector3 Position
255 { 255 {
256 get { return PhysicsVector.Zero; } 256 get { return Vector3.Zero; }
257 set { return; } 257 set { return; }
258 } 258 }
259 259
@@ -301,9 +301,9 @@ namespace OpenSim.Region.Physics.Manager
301 set { return; } 301 set { return; }
302 } 302 }
303 303
304 public override PhysicsVector Size 304 public override Vector3 Size
305 { 305 {
306 get { return PhysicsVector.Zero; } 306 get { return Vector3.Zero; }
307 set { return; } 307 set { return; }
308 } 308 }
309 309
@@ -312,9 +312,9 @@ namespace OpenSim.Region.Physics.Manager
312 get { return 0f; } 312 get { return 0f; }
313 } 313 }
314 314
315 public override PhysicsVector Force 315 public override Vector3 Force
316 { 316 {
317 get { return PhysicsVector.Zero; } 317 get { return Vector3.Zero; }
318 set { return; } 318 set { return; }
319 } 319 }
320 320
@@ -329,7 +329,7 @@ namespace OpenSim.Region.Physics.Manager
329 329
330 } 330 }
331 331
332 public override void VehicleVectorParam(int param, PhysicsVector value) 332 public override void VehicleVectorParam(int param, Vector3 value)
333 { 333 {
334 334
335 } 335 }
@@ -349,14 +349,14 @@ namespace OpenSim.Region.Physics.Manager
349 349
350 } 350 }
351 351
352 public override PhysicsVector CenterOfMass 352 public override Vector3 CenterOfMass
353 { 353 {
354 get { return PhysicsVector.Zero; } 354 get { return Vector3.Zero; }
355 } 355 }
356 356
357 public override PhysicsVector GeometricCenter 357 public override Vector3 GeometricCenter
358 { 358 {
359 get { return PhysicsVector.Zero; } 359 get { return Vector3.Zero; }
360 } 360 }
361 361
362 public override PrimitiveBaseShape Shape 362 public override PrimitiveBaseShape Shape
@@ -364,15 +364,15 @@ namespace OpenSim.Region.Physics.Manager
364 set { return; } 364 set { return; }
365 } 365 }
366 366
367 public override PhysicsVector Velocity 367 public override Vector3 Velocity
368 { 368 {
369 get { return PhysicsVector.Zero; } 369 get { return Vector3.Zero; }
370 set { return; } 370 set { return; }
371 } 371 }
372 372
373 public override PhysicsVector Torque 373 public override Vector3 Torque
374 { 374 {
375 get { return PhysicsVector.Zero; } 375 get { return Vector3.Zero; }
376 set { return; } 376 set { return; }
377 } 377 }
378 378
@@ -392,9 +392,9 @@ namespace OpenSim.Region.Physics.Manager
392 set { } 392 set { }
393 } 393 }
394 394
395 public override PhysicsVector Acceleration 395 public override Vector3 Acceleration
396 { 396 {
397 get { return PhysicsVector.Zero; } 397 get { return Vector3.Zero; }
398 } 398 }
399 399
400 public override bool IsPhysical 400 public override bool IsPhysical
@@ -441,26 +441,26 @@ namespace OpenSim.Region.Physics.Manager
441 { 441 {
442 } 442 }
443 443
444 public override void LockAngularMotion(PhysicsVector axis) 444 public override void LockAngularMotion(Vector3 axis)
445 { 445 {
446 } 446 }
447 447
448 public override void AddForce(PhysicsVector force, bool pushforce) 448 public override void AddForce(Vector3 force, bool pushforce)
449 { 449 {
450 } 450 }
451 451
452 public override void AddAngularForce(PhysicsVector force, bool pushforce) 452 public override void AddAngularForce(Vector3 force, bool pushforce)
453 { 453 {
454 454
455 } 455 }
456 456
457 public override PhysicsVector RotationalVelocity 457 public override Vector3 RotationalVelocity
458 { 458 {
459 get { return PhysicsVector.Zero; } 459 get { return Vector3.Zero; }
460 set { return; } 460 set { return; }
461 } 461 }
462 462
463 public override PhysicsVector PIDTarget { set { return; } } 463 public override Vector3 PIDTarget { set { return; } }
464 public override bool PIDActive { set { return; } } 464 public override bool PIDActive { set { return; } }
465 public override float PIDTau { set { return; } } 465 public override float PIDTau { set { return; } }
466 466
@@ -475,7 +475,7 @@ namespace OpenSim.Region.Physics.Manager
475 public override float APIDDamping { set { return; } } 475 public override float APIDDamping { set { return; } }
476 476
477 477
478 public override void SetMomentum(PhysicsVector momentum) 478 public override void SetMomentum(Vector3 momentum)
479 { 479 {
480 } 480 }
481 481
diff --git a/OpenSim/Region/Physics/Manager/PhysicsJoint.cs b/OpenSim/Region/Physics/Manager/PhysicsJoint.cs
index f463597..b685d04 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsJoint.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsJoint.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Region.Physics.Manager
44 public PhysicsJointType Type; 44 public PhysicsJointType Type;
45 public string RawParams; 45 public string RawParams;
46 public List<string> BodyNames = new List<string>(); 46 public List<string> BodyNames = new List<string>();
47 public PhysicsVector Position; // global coords 47 public Vector3 Position; // global coords
48 public Quaternion Rotation; // global coords 48 public Quaternion Rotation; // global coords
49 public string ObjectNameInScene; // proxy object in scene that represents the joint position/orientation 49 public string ObjectNameInScene; // proxy object in scene that represents the joint position/orientation
50 public string TrackedBodyName; // body name that this joint is attached to (ObjectNameInScene will follow TrackedBodyName) 50 public string TrackedBodyName; // body name that this joint is attached to (ObjectNameInScene will follow TrackedBodyName)
diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
index 6dd26bb..bb0d18e 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs
@@ -64,23 +64,23 @@ namespace OpenSim.Region.Physics.Manager
64 64
65 public abstract void Initialise(IMesher meshmerizer, IConfigSource config); 65 public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
66 66
67 public abstract PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying); 67 public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying);
68 68
69 public abstract void RemoveAvatar(PhysicsActor actor); 69 public abstract void RemoveAvatar(PhysicsActor actor);
70 70
71 public abstract void RemovePrim(PhysicsActor prim); 71 public abstract void RemovePrim(PhysicsActor prim);
72 72
73 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 73 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
74 PhysicsVector size, Quaternion rotation); //To be removed 74 Vector3 size, Quaternion rotation); //To be removed
75 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 75 public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
76 PhysicsVector size, Quaternion rotation, bool isPhysical); 76 Vector3 size, Quaternion rotation, bool isPhysical);
77 77
78 public virtual bool SupportsNINJAJoints 78 public virtual bool SupportsNINJAJoints
79 { 79 {
80 get { return false; } 80 get { return false; }
81 } 81 }
82 82
83 public virtual PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, PhysicsVector position, 83 public virtual PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position,
84 Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation) 84 Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation)
85 { return null; } 85 { return null; }
86 86
@@ -129,11 +129,11 @@ namespace OpenSim.Region.Physics.Manager
129 } 129 }
130 } 130 }
131 131
132 public virtual PhysicsVector GetJointAnchor(PhysicsJoint joint) 132 public virtual Vector3 GetJointAnchor(PhysicsJoint joint)
133 { return null; } 133 { return Vector3.Zero; }
134 134
135 public virtual PhysicsVector GetJointAxis(PhysicsJoint joint) 135 public virtual Vector3 GetJointAxis(PhysicsJoint joint)
136 { return null; } 136 { return Vector3.Zero; }
137 137
138 138
139 public abstract void AddPhysicsActorTaint(PhysicsActor prim); 139 public abstract void AddPhysicsActorTaint(PhysicsActor prim);
@@ -212,7 +212,7 @@ namespace OpenSim.Region.Physics.Manager
212 // Does nothing right now 212 // Does nothing right now
213 } 213 }
214 214
215 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 215 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
216 { 216 {
217 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddAvatar({0})", position); 217 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddAvatar({0})", position);
218 return PhysicsActor.Null; 218 return PhysicsActor.Null;
@@ -231,21 +231,21 @@ namespace OpenSim.Region.Physics.Manager
231 } 231 }
232 232
233/* 233/*
234 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) 234 public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
235 { 235 {
236 m_log.InfoFormat("NullPhysicsScene : AddPrim({0},{1})", position, size); 236 m_log.InfoFormat("NullPhysicsScene : AddPrim({0},{1})", position, size);
237 return PhysicsActor.Null; 237 return PhysicsActor.Null;
238 } 238 }
239*/ 239*/
240 240
241 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 241 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
242 PhysicsVector size, Quaternion rotation) //To be removed 242 Vector3 size, Quaternion rotation) //To be removed
243 { 243 {
244 return AddPrimShape(primName, pbs, position, size, rotation, false); 244 return AddPrimShape(primName, pbs, position, size, rotation, false);
245 } 245 }
246 246
247 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 247 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
248 PhysicsVector size, Quaternion rotation, bool isPhysical) 248 Vector3 size, Quaternion rotation, bool isPhysical)
249 { 249 {
250 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size); 250 m_log.InfoFormat("[PHYSICS]: NullPhysicsScene : AddPrim({0},{1})", position, size);
251 return PhysicsActor.Null; 251 return PhysicsActor.Null;
diff --git a/OpenSim/Region/Physics/Manager/PhysicsSensor.cs b/OpenSim/Region/Physics/Manager/PhysicsSensor.cs
index 090ad52..f480d71 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsSensor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsSensor.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Timers; 29using System.Timers;
30using OpenMetaverse;
30 31
31namespace OpenSim.Region.Physics.Manager 32namespace OpenSim.Region.Physics.Manager
32{ 33{
@@ -46,7 +47,7 @@ namespace OpenSim.Region.Physics.Manager
46 { 47 {
47 get { return new NullPhysicsSensor(); } 48 get { return new NullPhysicsSensor(); }
48 } 49 }
49 public abstract PhysicsVector Position {get; set;} 50 public abstract Vector3 Position { get; set; }
50 public abstract void TimerCallback (object obj, ElapsedEventArgs eea); 51 public abstract void TimerCallback (object obj, ElapsedEventArgs eea);
51 public abstract float radianarc {get; set;} 52 public abstract float radianarc {get; set;}
52 public abstract string targetname {get; set;} 53 public abstract string targetname {get; set;}
@@ -58,9 +59,9 @@ namespace OpenSim.Region.Physics.Manager
58 59
59 public class NullPhysicsSensor : PhysicsSensor 60 public class NullPhysicsSensor : PhysicsSensor
60 { 61 {
61 public override PhysicsVector Position 62 public override Vector3 Position
62 { 63 {
63 get { return PhysicsVector.Zero; } 64 get { return Vector3.Zero; }
64 set { return; } 65 set { return; }
65 } 66 }
66 public override void TimerCallback(object obj, ElapsedEventArgs eea) 67 public override void TimerCallback(object obj, ElapsedEventArgs eea)
diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
index d6f4d0d..f60a636 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsVector.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
@@ -29,24 +29,24 @@ using System;
29 29
30namespace OpenSim.Region.Physics.Manager 30namespace OpenSim.Region.Physics.Manager
31{ 31{
32 public class PhysicsVector 32 /*public class PhysicsVector
33 { 33 {
34 public float X; 34 public float X;
35 public float Y; 35 public float Y;
36 public float Z; 36 public float Z;
37 37
38 public PhysicsVector() 38 public Vector3()
39 { 39 {
40 } 40 }
41 41
42 public PhysicsVector(float x, float y, float z) 42 public Vector3(float x, float y, float z)
43 { 43 {
44 X = x; 44 X = x;
45 Y = y; 45 Y = y;
46 Z = z; 46 Z = z;
47 } 47 }
48 48
49 public PhysicsVector(PhysicsVector pv) : this(pv.X, pv.Y, pv.Z) 49 public Vector3(Vector3 pv) : this(pv.X, pv.Y, pv.Z)
50 { 50 {
51 } 51 }
52 52
@@ -115,17 +115,17 @@ namespace OpenSim.Region.Physics.Manager
115 } 115 }
116 116
117 // Operations 117 // Operations
118 public static PhysicsVector operator +(PhysicsVector a, PhysicsVector b) 118 public static PhysicsVector operator +(Vector3 a, Vector3 b)
119 { 119 {
120 return new PhysicsVector(a.X + b.X, a.Y + b.Y, a.Z + b.Z); 120 return new PhysicsVector(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
121 } 121 }
122 122
123 public static PhysicsVector operator -(PhysicsVector a, PhysicsVector b) 123 public static PhysicsVector operator -(Vector3 a, Vector3 b)
124 { 124 {
125 return new PhysicsVector(a.X - b.X, a.Y - b.Y, a.Z - b.Z); 125 return new PhysicsVector(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
126 } 126 }
127 127
128 public static PhysicsVector cross(PhysicsVector a, PhysicsVector b) 128 public static PhysicsVector cross(Vector3 a, Vector3 b)
129 { 129 {
130 return new PhysicsVector(a.Y*b.Z - a.Z*b.Y, a.Z*b.X - a.X*b.Z, a.X*b.Y - a.Y*b.X); 130 return new PhysicsVector(a.Y*b.Z - a.Z*b.Y, a.Z*b.X - a.X*b.Z, a.X*b.Y - a.Y*b.X);
131 } 131 }
@@ -135,7 +135,7 @@ namespace OpenSim.Region.Physics.Manager
135 return (float) Math.Sqrt(X*X + Y*Y + Z*Z); 135 return (float) Math.Sqrt(X*X + Y*Y + Z*Z);
136 } 136 }
137 137
138 public static float GetDistanceTo(PhysicsVector a, PhysicsVector b) 138 public static float GetDistanceTo(Vector3 a, Vector3 b)
139 { 139 {
140 float dx = a.X - b.X; 140 float dx = a.X - b.X;
141 float dy = a.Y - b.Y; 141 float dy = a.Y - b.Y;
@@ -143,22 +143,22 @@ namespace OpenSim.Region.Physics.Manager
143 return (float) Math.Sqrt(dx * dx + dy * dy + dz * dz); 143 return (float) Math.Sqrt(dx * dx + dy * dy + dz * dz);
144 } 144 }
145 145
146 public static PhysicsVector operator /(PhysicsVector v, float f) 146 public static PhysicsVector operator /(Vector3 v, float f)
147 { 147 {
148 return new PhysicsVector(v.X/f, v.Y/f, v.Z/f); 148 return new PhysicsVector(v.X/f, v.Y/f, v.Z/f);
149 } 149 }
150 150
151 public static PhysicsVector operator *(PhysicsVector v, float f) 151 public static PhysicsVector operator *(Vector3 v, float f)
152 { 152 {
153 return new PhysicsVector(v.X*f, v.Y*f, v.Z*f); 153 return new PhysicsVector(v.X*f, v.Y*f, v.Z*f);
154 } 154 }
155 155
156 public static PhysicsVector operator *(float f, PhysicsVector v) 156 public static PhysicsVector operator *(float f, Vector3 v)
157 { 157 {
158 return v*f; 158 return v*f;
159 } 159 }
160 160
161 public static bool isFinite(PhysicsVector v) 161 public static bool isFinite(Vector3 v)
162 { 162 {
163 if (v == null) 163 if (v == null)
164 return false; 164 return false;
@@ -172,7 +172,7 @@ namespace OpenSim.Region.Physics.Manager
172 return true; 172 return true;
173 } 173 }
174 174
175 public virtual bool IsIdentical(PhysicsVector v, float tolerance) 175 public virtual bool IsIdentical(Vector3 v, float tolerance)
176 { 176 {
177 PhysicsVector diff = this - v; 177 PhysicsVector diff = this - v;
178 float d = diff.length(); 178 float d = diff.length();
@@ -182,5 +182,5 @@ namespace OpenSim.Region.Physics.Manager
182 return false; 182 return false;
183 } 183 }
184 184
185 } 185 }*/
186} 186}
diff --git a/OpenSim/Region/Physics/Manager/ZeroMesher.cs b/OpenSim/Region/Physics/Manager/ZeroMesher.cs
index f9d0f2a..e6e75f9 100644
--- a/OpenSim/Region/Physics/Manager/ZeroMesher.cs
+++ b/OpenSim/Region/Physics/Manager/ZeroMesher.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenMetaverse;
30 31
31/* 32/*
32 * This is the zero mesher. 33 * This is the zero mesher.
@@ -60,13 +61,16 @@ namespace OpenSim.Region.Physics.Manager
60 61
61 public class ZeroMesher : IMesher 62 public class ZeroMesher : IMesher
62 { 63 {
63 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) 64 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
64 { 65 {
65 return CreateMesh(primName, primShape, size, lod, false); 66 return CreateMesh(primName, primShape, size, lod, false);
66 } 67 }
67 68
68 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) 69 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
69 { 70 {
71 // Remove the reference to the encoded JPEG2000 data so it can be GCed
72 primShape.SculptData = OpenMetaverse.Utils.EmptyBytes;
73
70 return null; 74 return null;
71 } 75 }
72 } 76 }
diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/Meshing/HelperTypes.cs
index 232245f..8cd8dcf 100644
--- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs
+++ b/OpenSim/Region/Physics/Meshing/HelperTypes.cs
@@ -33,30 +33,52 @@ using OpenMetaverse;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.Physics.Manager;
34using OpenSim.Region.Physics.Meshing; 34using OpenSim.Region.Physics.Meshing;
35 35
36public class Vertex : PhysicsVector, IComparable<Vertex> 36public class Vertex : IComparable<Vertex>
37{ 37{
38 Vector3 vector;
39
40 public float X
41 {
42 get { return vector.X; }
43 set { vector.X = value; }
44 }
45
46 public float Y
47 {
48 get { return vector.Y; }
49 set { vector.Y = value; }
50 }
51
52 public float Z
53 {
54 get { return vector.Z; }
55 set { vector.Z = value; }
56 }
57
38 public Vertex(float x, float y, float z) 58 public Vertex(float x, float y, float z)
39 : base(x, y, z)
40 { 59 {
60 vector.X = x;
61 vector.Y = y;
62 vector.Z = z;
41 } 63 }
42 64
43 public Vertex normalize() 65 public Vertex normalize()
44 { 66 {
45 float tlength = length(); 67 float tlength = vector.Length();
46 if (tlength != 0) 68 if (tlength != 0f)
47 { 69 {
48 float mul = 1.0f / tlength; 70 float mul = 1.0f / tlength;
49 return new Vertex(X * mul, Y * mul, Z * mul); 71 return new Vertex(vector.X * mul, vector.Y * mul, vector.Z * mul);
50 } 72 }
51 else 73 else
52 { 74 {
53 return new Vertex(0, 0, 0); 75 return new Vertex(0f, 0f, 0f);
54 } 76 }
55 } 77 }
56 78
57 public Vertex cross(Vertex v) 79 public Vertex cross(Vertex v)
58 { 80 {
59 return new Vertex(Y * v.Z - Z * v.Y, Z * v.X - X * v.Z, X * v.Y - Y * v.X); 81 return new Vertex(vector.Y * v.Z - vector.Z * v.Y, vector.Z * v.X - vector.X * v.Z, vector.X * v.Y - vector.Y * v.X);
60 } 82 }
61 83
62 // disable warning: mono compiler moans about overloading 84 // disable warning: mono compiler moans about overloading
@@ -160,9 +182,9 @@ public class Vertex : PhysicsVector, IComparable<Vertex>
160 return X * v.X + Y * v.Y + Z * v.Z; 182 return X * v.X + Y * v.Y + Z * v.Z;
161 } 183 }
162 184
163 public Vertex(PhysicsVector v) 185 public Vertex(Vector3 v)
164 : base(v.X, v.Y, v.Z)
165 { 186 {
187 vector = v;
166 } 188 }
167 189
168 public Vertex Clone() 190 public Vertex Clone()
@@ -175,11 +197,15 @@ public class Vertex : PhysicsVector, IComparable<Vertex>
175 return new Vertex((float) Math.Cos(angle), (float) Math.Sin(angle), 0.0f); 197 return new Vertex((float) Math.Cos(angle), (float) Math.Sin(angle), 0.0f);
176 } 198 }
177 199
200 public float Length()
201 {
202 return vector.Length();
203 }
178 204
179 public virtual bool Equals(Vertex v, float tolerance) 205 public virtual bool Equals(Vertex v, float tolerance)
180 { 206 {
181 PhysicsVector diff = this - v; 207 Vertex diff = this - v;
182 float d = diff.length(); 208 float d = diff.Length();
183 if (d < tolerance) 209 if (d < tolerance)
184 return true; 210 return true;
185 211
@@ -369,22 +395,22 @@ public class Triangle
369 return s1 + ";" + s2 + ";" + s3; 395 return s1 + ";" + s2 + ";" + s3;
370 } 396 }
371 397
372 public PhysicsVector getNormal() 398 public Vector3 getNormal()
373 { 399 {
374 // Vertices 400 // Vertices
375 401
376 // Vectors for edges 402 // Vectors for edges
377 PhysicsVector e1; 403 Vector3 e1;
378 PhysicsVector e2; 404 Vector3 e2;
379 405
380 e1 = new PhysicsVector(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z); 406 e1 = new Vector3(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
381 e2 = new PhysicsVector(v1.X - v3.X, v1.Y - v3.Y, v1.Z - v3.Z); 407 e2 = new Vector3(v1.X - v3.X, v1.Y - v3.Y, v1.Z - v3.Z);
382 408
383 // Cross product for normal 409 // Cross product for normal
384 PhysicsVector n = PhysicsVector.cross(e1, e2); 410 Vector3 n = Vector3.Cross(e1, e2);
385 411
386 // Length 412 // Length
387 float l = n.length(); 413 float l = n.Length();
388 414
389 // Normalized "normal" 415 // Normalized "normal"
390 n = n/l; 416 n = n/l;
diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs
index 4c3cf33..f781ff9 100644
--- a/OpenSim/Region/Physics/Meshing/Mesh.cs
+++ b/OpenSim/Region/Physics/Meshing/Mesh.cs
@@ -31,6 +31,7 @@ using System.IO;
31using System.Runtime.InteropServices; 31using System.Runtime.InteropServices;
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.Physics.Manager;
33using PrimMesher; 33using PrimMesher;
34using OpenMetaverse;
34 35
35namespace OpenSim.Region.Physics.Meshing 36namespace OpenSim.Region.Physics.Meshing
36{ 37{
@@ -141,12 +142,12 @@ namespace OpenSim.Region.Physics.Meshing
141 } 142 }
142 } 143 }
143 144
144 public List<PhysicsVector> getVertexList() 145 public List<Vector3> getVertexList()
145 { 146 {
146 List<PhysicsVector> result = new List<PhysicsVector>(); 147 List<Vector3> result = new List<Vector3>();
147 foreach (Vertex v in m_vertices.Keys) 148 foreach (Vertex v in m_vertices.Keys)
148 { 149 {
149 result.Add(v); 150 result.Add(new Vector3(v.X, v.Y, v.Z));
150 } 151 }
151 return result; 152 return result;
152 } 153 }
@@ -174,6 +175,9 @@ namespace OpenSim.Region.Physics.Meshing
174 175
175 float[] result = getVertexListAsFloat(); 176 float[] result = getVertexListAsFloat();
176 m_pinnedVertexes = GCHandle.Alloc(result, GCHandleType.Pinned); 177 m_pinnedVertexes = GCHandle.Alloc(result, GCHandleType.Pinned);
178 // Inform the garbage collector of this unmanaged allocation so it can schedule
179 // the next GC round more intelligently
180 GC.AddMemoryPressure(Buffer.ByteLength(result));
177 181
178 return result; 182 return result;
179 } 183 }
@@ -223,6 +227,9 @@ namespace OpenSim.Region.Physics.Meshing
223 227
224 int[] result = getIndexListAsInt(); 228 int[] result = getIndexListAsInt();
225 m_pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); 229 m_pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned);
230 // Inform the garbage collector of this unmanaged allocation so it can schedule
231 // the next GC round more intelligently
232 GC.AddMemoryPressure(Buffer.ByteLength(result));
226 233
227 return result; 234 return result;
228 } 235 }
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index f609e73..fbe1949 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.Physics.Manager;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenMetaverse.Imaging;
35using System.Drawing; 34using System.Drawing;
36using System.Drawing.Imaging; 35using System.Drawing.Imaging;
37using PrimMesher; 36using PrimMesher;
@@ -61,7 +60,6 @@ namespace OpenSim.Region.Physics.Meshing
61 public class Meshmerizer : IMesher 60 public class Meshmerizer : IMesher
62 { 61 {
63 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 62 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
64 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
65 63
66 // Setting baseDir to a path will enable the dumping of raw files 64 // Setting baseDir to a path will enable the dumping of raw files
67 // raw files can be imported by blender so a visual inspection of the results can be done 65 // raw files can be imported by blender so a visual inspection of the results can be done
@@ -160,7 +158,7 @@ namespace OpenSim.Region.Physics.Meshing
160 float minZ = float.MaxValue; 158 float minZ = float.MaxValue;
161 float maxZ = float.MinValue; 159 float maxZ = float.MinValue;
162 160
163 foreach (Vertex v in meshIn.getVertexList()) 161 foreach (Vector3 v in meshIn.getVertexList())
164 { 162 {
165 if (v != null) 163 if (v != null)
166 { 164 {
@@ -185,7 +183,7 @@ namespace OpenSim.Region.Physics.Meshing
185 183
186 } 184 }
187 185
188 private ulong GetMeshKey(PrimitiveBaseShape pbs, PhysicsVector size, float lod) 186 private ulong GetMeshKey(PrimitiveBaseShape pbs, Vector3 size, float lod)
189 { 187 {
190 ulong hash = 5381; 188 ulong hash = 5381;
191 189
@@ -245,9 +243,9 @@ namespace OpenSim.Region.Physics.Meshing
245 hash = ((hash << 5) + hash) + (ulong)((byte)c); 243 hash = ((hash << 5) + hash) + (ulong)((byte)c);
246 return ((hash << 5) + hash) + (ulong)(c >> 8); 244 return ((hash << 5) + hash) + (ulong)(c >> 8);
247 } 245 }
248
249 246
250 private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) 247
248 private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
251 { 249 {
252 PrimMesh primMesh; 250 PrimMesh primMesh;
253 PrimMesher.SculptMesh sculptMesh; 251 PrimMesher.SculptMesh sculptMesh;
@@ -281,16 +279,12 @@ namespace OpenSim.Region.Physics.Meshing
281 279
282 if (idata == null) 280 if (idata == null)
283 { 281 {
284 if (primShape.SculptData.Length == 0) 282 if (primShape.SculptData == null || primShape.SculptData.Length == 0)
285 return null; 283 return null;
286 284
287 try 285 try
288 { 286 {
289 ManagedImage managedImage; // we never use this 287 idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData);
290 OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata);
291
292 // Remove the reference to the encoded JPEG2000 data so it can be GCed
293 primShape.SculptData = Utils.EmptyBytes;
294 288
295 if (cacheSculptMaps) 289 if (cacheSculptMaps)
296 { 290 {
@@ -315,8 +309,6 @@ namespace OpenSim.Region.Physics.Meshing
315 } 309 }
316 } 310 }
317 311
318
319
320 PrimMesher.SculptMesh.SculptType sculptType; 312 PrimMesher.SculptMesh.SculptType sculptType;
321 switch ((OpenMetaverse.SculptType)primShape.SculptType) 313 switch ((OpenMetaverse.SculptType)primShape.SculptType)
322 { 314 {
@@ -351,7 +343,6 @@ namespace OpenSim.Region.Physics.Meshing
351 coords = sculptMesh.coords; 343 coords = sculptMesh.coords;
352 faces = sculptMesh.faces; 344 faces = sculptMesh.faces;
353 } 345 }
354
355 else 346 else
356 { 347 {
357 float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f; 348 float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f;
@@ -466,6 +457,8 @@ namespace OpenSim.Region.Physics.Meshing
466 faces = primMesh.faces; 457 faces = primMesh.faces;
467 } 458 }
468 459
460 // Remove the reference to any JPEG2000 sculpt data so it can be GCed
461 primShape.SculptData = Utils.EmptyBytes;
469 462
470 int numCoords = coords.Count; 463 int numCoords = coords.Count;
471 int numFaces = faces.Count; 464 int numFaces = faces.Count;
@@ -488,12 +481,12 @@ namespace OpenSim.Region.Physics.Meshing
488 return mesh; 481 return mesh;
489 } 482 }
490 483
491 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) 484 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
492 { 485 {
493 return CreateMesh(primName, primShape, size, lod, false); 486 return CreateMesh(primName, primShape, size, lod, false);
494 } 487 }
495 488
496 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) 489 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
497 { 490 {
498 Mesh mesh = null; 491 Mesh mesh = null;
499 ulong key = 0; 492 ulong key = 0;
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 8272083..e344f97 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -68,15 +68,15 @@ namespace OpenSim.Region.Physics.OdePlugin
68 { 68 {
69 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 69 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
70 70
71 private PhysicsVector _position; 71 private Vector3 _position;
72 private d.Vector3 _zeroPosition; 72 private d.Vector3 _zeroPosition;
73 // private d.Matrix3 m_StandUpRotation; 73 // private d.Matrix3 m_StandUpRotation;
74 private bool _zeroFlag = false; 74 private bool _zeroFlag = false;
75 private bool m_lastUpdateSent = false; 75 private bool m_lastUpdateSent = false;
76 private PhysicsVector _velocity; 76 private Vector3 _velocity;
77 private PhysicsVector _target_velocity; 77 private Vector3 _target_velocity;
78 private PhysicsVector _acceleration; 78 private Vector3 _acceleration;
79 private PhysicsVector m_rotationalVelocity; 79 private Vector3 m_rotationalVelocity;
80 private float m_mass = 80f; 80 private float m_mass = 80f;
81 public float m_density = 60f; 81 public float m_density = 60f;
82 private bool m_pidControllerActive = true; 82 private bool m_pidControllerActive = true;
@@ -99,7 +99,7 @@ namespace OpenSim.Region.Physics.OdePlugin
99 private bool m_hackSentFall = false; 99 private bool m_hackSentFall = false;
100 private bool m_hackSentFly = false; 100 private bool m_hackSentFly = false;
101 private int m_requestedUpdateFrequency = 0; 101 private int m_requestedUpdateFrequency = 0;
102 private PhysicsVector m_taintPosition = new PhysicsVector(0, 0, 0); 102 private Vector3 m_taintPosition = Vector3.Zero;
103 public uint m_localID = 0; 103 public uint m_localID = 0;
104 public bool m_returnCollisions = false; 104 public bool m_returnCollisions = false;
105 // taints and their non-tainted counterparts 105 // taints and their non-tainted counterparts
@@ -143,22 +143,17 @@ namespace OpenSim.Region.Physics.OdePlugin
143 public UUID m_uuid; 143 public UUID m_uuid;
144 public bool bad = false; 144 public bool bad = false;
145 145
146 public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode, PhysicsVector size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor) 146 public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, CollisionLocker dode, Vector3 size, float pid_d, float pid_p, float capsule_radius, float tensor, float density, float height_fudge_factor, float walk_divisor, float rundivisor)
147 { 147 {
148 m_uuid = UUID.Random(); 148 m_uuid = UUID.Random();
149 149
150 // ode = dode; 150 if (pos.IsFinite())
151 _velocity = new PhysicsVector();
152 _target_velocity = new PhysicsVector();
153
154
155 if (PhysicsVector.isFinite(pos))
156 { 151 {
157 if (pos.Z > 9999999) 152 if (pos.Z > 9999999f)
158 { 153 {
159 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 154 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
160 } 155 }
161 if (pos.Z < -90000) 156 if (pos.Z < -90000f)
162 { 157 {
163 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 158 pos.Z = parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
164 } 159 }
@@ -169,15 +164,13 @@ namespace OpenSim.Region.Physics.OdePlugin
169 } 164 }
170 else 165 else
171 { 166 {
172 _position = new PhysicsVector(((int)_parent_scene.WorldExtents.X * 0.5f), ((int)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128, 128) + 10); 167 _position = new Vector3(((float)_parent_scene.WorldExtents.X * 0.5f), ((float)_parent_scene.WorldExtents.Y * 0.5f), parent_scene.GetTerrainHeightAtXY(128f, 128f) + 10f);
173 m_taintPosition.X = _position.X; 168 m_taintPosition.X = _position.X;
174 m_taintPosition.Y = _position.Y; 169 m_taintPosition.Y = _position.Y;
175 m_taintPosition.Z = _position.Z; 170 m_taintPosition.Z = _position.Z;
176 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create"); 171 m_log.Warn("[PHYSICS]: Got NaN Position on Character Create");
177 } 172 }
178 173
179
180 _acceleration = new PhysicsVector();
181 _parent_scene = parent_scene; 174 _parent_scene = parent_scene;
182 175
183 PID_D = pid_d; 176 PID_D = pid_d;
@@ -189,7 +182,6 @@ namespace OpenSim.Region.Physics.OdePlugin
189 walkDivisor = walk_divisor; 182 walkDivisor = walk_divisor;
190 runDivisor = rundivisor; 183 runDivisor = rundivisor;
191 184
192
193 // m_StandUpRotation = 185 // m_StandUpRotation =
194 // new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f, 186 // new d.Matrix3(0.5f, 0.7071068f, 0.5f, -0.7071068f, 0f, 0.7071068f, 0.5f, -0.7071068f,
195 // 0.5f); 187 // 0.5f);
@@ -205,7 +197,6 @@ namespace OpenSim.Region.Physics.OdePlugin
205 m_isPhysical = false; // current status: no ODE information exists 197 m_isPhysical = false; // current status: no ODE information exists
206 m_tainted_isPhysical = true; // new tainted status: need to create ODE information 198 m_tainted_isPhysical = true; // new tainted status: need to create ODE information
207 199
208
209 _parent_scene.AddPhysicsActorTaint(this); 200 _parent_scene.AddPhysicsActorTaint(this);
210 201
211 m_name = avName; 202 m_name = avName;
@@ -412,20 +403,20 @@ namespace OpenSim.Region.Physics.OdePlugin
412 /// Not really a good choice unless you 'know' it's a good 403 /// Not really a good choice unless you 'know' it's a good
413 /// spot otherwise you're likely to orbit the avatar. 404 /// spot otherwise you're likely to orbit the avatar.
414 /// </summary> 405 /// </summary>
415 public override PhysicsVector Position 406 public override Vector3 Position
416 { 407 {
417 get { return _position; } 408 get { return _position; }
418 set 409 set
419 { 410 {
420 if (Body == IntPtr.Zero || Shell == IntPtr.Zero) 411 if (Body == IntPtr.Zero || Shell == IntPtr.Zero)
421 { 412 {
422 if (PhysicsVector.isFinite(value)) 413 if (value.IsFinite())
423 { 414 {
424 if (value.Z > 9999999) 415 if (value.Z > 9999999f)
425 { 416 {
426 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 417 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
427 } 418 }
428 if (value.Z < -90000) 419 if (value.Z < -90000f)
429 { 420 {
430 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5; 421 value.Z = _parent_scene.GetTerrainHeightAtXY(127, 127) + 5;
431 } 422 }
@@ -447,7 +438,7 @@ namespace OpenSim.Region.Physics.OdePlugin
447 } 438 }
448 } 439 }
449 440
450 public override PhysicsVector RotationalVelocity 441 public override Vector3 RotationalVelocity
451 { 442 {
452 get { return m_rotationalVelocity; } 443 get { return m_rotationalVelocity; }
453 set { m_rotationalVelocity = value; } 444 set { m_rotationalVelocity = value; }
@@ -457,20 +448,20 @@ namespace OpenSim.Region.Physics.OdePlugin
457 /// This property sets the height of the avatar only. We use the height to make sure the avatar stands up straight 448 /// This property sets the height of the avatar only. We use the height to make sure the avatar stands up straight
458 /// and use it to offset landings properly 449 /// and use it to offset landings properly
459 /// </summary> 450 /// </summary>
460 public override PhysicsVector Size 451 public override Vector3 Size
461 { 452 {
462 get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); } 453 get { return new Vector3(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); }
463 set 454 set
464 { 455 {
465 if (PhysicsVector.isFinite(value)) 456 if (value.IsFinite())
466 { 457 {
467 m_pidControllerActive = true; 458 m_pidControllerActive = true;
468 459
469 PhysicsVector SetSize = value; 460 Vector3 SetSize = value;
470 m_tainted_CAPSULE_LENGTH = (SetSize.Z*1.15f) - CAPSULE_RADIUS*2.0f; 461 m_tainted_CAPSULE_LENGTH = (SetSize.Z*1.15f) - CAPSULE_RADIUS*2.0f;
471 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); 462 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
472 463
473 Velocity = new PhysicsVector(0f, 0f, 0f); 464 Velocity = Vector3.Zero;
474 465
475 _parent_scene.AddPhysicsActorTaint(this); 466 _parent_scene.AddPhysicsActorTaint(this);
476 } 467 }
@@ -481,7 +472,7 @@ namespace OpenSim.Region.Physics.OdePlugin
481 } 472 }
482 } 473 }
483 474
484 private void AlignAvatarTiltWithCurrentDirectionOfMovement(PhysicsVector movementVector) 475 private void AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3 movementVector)
485 { 476 {
486 movementVector.Z = 0f; 477 movementVector.Z = 0f;
487 float magnitude = (float)Math.Sqrt((double)(movementVector.X * movementVector.X + movementVector.Y * movementVector.Y)); 478 float magnitude = (float)Math.Sqrt((double)(movementVector.X * movementVector.X + movementVector.Y * movementVector.Y));
@@ -643,7 +634,7 @@ namespace OpenSim.Region.Physics.OdePlugin
643 // (with -0..0 motor stops) falls into the terrain for reasons yet 634 // (with -0..0 motor stops) falls into the terrain for reasons yet
644 // to be comprehended in their entirety. 635 // to be comprehended in their entirety.
645 #endregion 636 #endregion
646 AlignAvatarTiltWithCurrentDirectionOfMovement(new PhysicsVector(0,0,0)); 637 AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero);
647 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f); 638 d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f);
648 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f); 639 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f);
649 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f); 640 d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f);
@@ -688,7 +679,7 @@ namespace OpenSim.Region.Physics.OdePlugin
688 679
689 } 680 }
690 681
691 public override void LockAngularMotion(PhysicsVector axis) 682 public override void LockAngularMotion(Vector3 axis)
692 { 683 {
693 684
694 } 685 }
@@ -716,9 +707,9 @@ namespace OpenSim.Region.Physics.OdePlugin
716// //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); 707// //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22);
717// } 708// }
718 709
719 public override PhysicsVector Force 710 public override Vector3 Force
720 { 711 {
721 get { return new PhysicsVector(_target_velocity.X, _target_velocity.Y, _target_velocity.Z); } 712 get { return _target_velocity; }
722 set { return; } 713 set { return; }
723 } 714 }
724 715
@@ -733,7 +724,7 @@ namespace OpenSim.Region.Physics.OdePlugin
733 724
734 } 725 }
735 726
736 public override void VehicleVectorParam(int param, PhysicsVector value) 727 public override void VehicleVectorParam(int param, Vector3 value)
737 { 728 {
738 729
739 } 730 }
@@ -748,14 +739,14 @@ namespace OpenSim.Region.Physics.OdePlugin
748 739
749 } 740 }
750 741
751 public override PhysicsVector CenterOfMass 742 public override Vector3 CenterOfMass
752 { 743 {
753 get { return PhysicsVector.Zero; } 744 get { return Vector3.Zero; }
754 } 745 }
755 746
756 public override PhysicsVector GeometricCenter 747 public override Vector3 GeometricCenter
757 { 748 {
758 get { return PhysicsVector.Zero; } 749 get { return Vector3.Zero; }
759 } 750 }
760 751
761 public override PrimitiveBaseShape Shape 752 public override PrimitiveBaseShape Shape
@@ -763,18 +754,18 @@ namespace OpenSim.Region.Physics.OdePlugin
763 set { return; } 754 set { return; }
764 } 755 }
765 756
766 public override PhysicsVector Velocity 757 public override Vector3 Velocity
767 { 758 {
768 get { 759 get {
769 // There's a problem with PhysicsVector.Zero! Don't Use it Here! 760 // There's a problem with Vector3.Zero! Don't Use it Here!
770 if (_zeroFlag) 761 if (_zeroFlag)
771 return new PhysicsVector(0f, 0f, 0f); 762 return Vector3.Zero;
772 m_lastUpdateSent = false; 763 m_lastUpdateSent = false;
773 return _velocity; 764 return _velocity;
774 } 765 }
775 set 766 set
776 { 767 {
777 if (PhysicsVector.isFinite(value)) 768 if (value.IsFinite())
778 { 769 {
779 m_pidControllerActive = true; 770 m_pidControllerActive = true;
780 _target_velocity = value; 771 _target_velocity = value;
@@ -786,9 +777,9 @@ namespace OpenSim.Region.Physics.OdePlugin
786 } 777 }
787 } 778 }
788 779
789 public override PhysicsVector Torque 780 public override Vector3 Torque
790 { 781 {
791 get { return PhysicsVector.Zero; } 782 get { return Vector3.Zero; }
792 set { return; } 783 set { return; }
793 } 784 }
794 785
@@ -814,12 +805,12 @@ namespace OpenSim.Region.Physics.OdePlugin
814 } 805 }
815 } 806 }
816 807
817 public override PhysicsVector Acceleration 808 public override Vector3 Acceleration
818 { 809 {
819 get { return _acceleration; } 810 get { return _acceleration; }
820 } 811 }
821 812
822 public void SetAcceleration(PhysicsVector accel) 813 public void SetAcceleration(Vector3 accel)
823 { 814 {
824 m_pidControllerActive = true; 815 m_pidControllerActive = true;
825 _acceleration = accel; 816 _acceleration = accel;
@@ -830,9 +821,9 @@ namespace OpenSim.Region.Physics.OdePlugin
830 /// The PID controller takes this target velocity and tries to make it a reality 821 /// The PID controller takes this target velocity and tries to make it a reality
831 /// </summary> 822 /// </summary>
832 /// <param name="force"></param> 823 /// <param name="force"></param>
833 public override void AddForce(PhysicsVector force, bool pushforce) 824 public override void AddForce(Vector3 force, bool pushforce)
834 { 825 {
835 if (PhysicsVector.isFinite(force)) 826 if (force.IsFinite())
836 { 827 {
837 if (pushforce) 828 if (pushforce)
838 { 829 {
@@ -861,7 +852,7 @@ namespace OpenSim.Region.Physics.OdePlugin
861 //m_lastUpdateSent = false; 852 //m_lastUpdateSent = false;
862 } 853 }
863 854
864 public override void AddAngularForce(PhysicsVector force, bool pushforce) 855 public override void AddAngularForce(Vector3 force, bool pushforce)
865 { 856 {
866 857
867 } 858 }
@@ -870,7 +861,7 @@ namespace OpenSim.Region.Physics.OdePlugin
870 /// After all of the forces add up with 'add force' we apply them with doForce 861 /// After all of the forces add up with 'add force' we apply them with doForce
871 /// </summary> 862 /// </summary>
872 /// <param name="force"></param> 863 /// <param name="force"></param>
873 public void doForce(PhysicsVector force) 864 public void doForce(Vector3 force)
874 { 865 {
875 if (!collidelock) 866 if (!collidelock)
876 { 867 {
@@ -881,7 +872,7 @@ namespace OpenSim.Region.Physics.OdePlugin
881 } 872 }
882 } 873 }
883 874
884 public override void SetMomentum(PhysicsVector momentum) 875 public override void SetMomentum(Vector3 momentum)
885 { 876 {
886 } 877 }
887 878
@@ -908,9 +899,9 @@ namespace OpenSim.Region.Physics.OdePlugin
908 //PidStatus = true; 899 //PidStatus = true;
909 900
910 d.Vector3 localpos = d.BodyGetPosition(Body); 901 d.Vector3 localpos = d.BodyGetPosition(Body);
911 PhysicsVector localPos = new PhysicsVector(localpos.X, localpos.Y, localpos.Z); 902 Vector3 localPos = new Vector3(localpos.X, localpos.Y, localpos.Z);
912 903
913 if (!PhysicsVector.isFinite(localPos)) 904 if (!localPos.IsFinite())
914 { 905 {
915 906
916 m_log.Warn("[PHYSICS]: Avatar Position is non-finite!"); 907 m_log.Warn("[PHYSICS]: Avatar Position is non-finite!");
@@ -946,7 +937,7 @@ namespace OpenSim.Region.Physics.OdePlugin
946 return; 937 return;
947 } 938 }
948 939
949 PhysicsVector vec = new PhysicsVector(); 940 Vector3 vec = Vector3.Zero;
950 d.Vector3 vel = d.BodyGetLinearVel(Body); 941 d.Vector3 vel = d.BodyGetLinearVel(Body);
951 942
952 float movementdivisor = 1f; 943 float movementdivisor = 1f;
@@ -1059,12 +1050,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1059 } 1050 }
1060 // end add Kitto Flora 1051 // end add Kitto Flora
1061 } 1052 }
1062 if (PhysicsVector.isFinite(vec)) 1053 if (vec.IsFinite())
1063 { 1054 {
1064 doForce(vec); 1055 doForce(vec);
1065 if (!_zeroFlag) 1056 if (!_zeroFlag)
1066 { 1057 {
1067 AlignAvatarTiltWithCurrentDirectionOfMovement(new PhysicsVector(vec.X, vec.Y, vec.Z)); 1058 AlignAvatarTiltWithCurrentDirectionOfMovement(vec);
1068 } 1059 }
1069 } 1060 }
1070 else 1061 else
@@ -1197,7 +1188,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1197 { 1188 {
1198 } 1189 }
1199 1190
1200 public override PhysicsVector PIDTarget { set { return; } } 1191 public override Vector3 PIDTarget { set { return; } }
1201 public override bool PIDActive { set { return; } } 1192 public override bool PIDActive { set { return; } }
1202 public override float PIDTau { set { return; } } 1193 public override float PIDTau { set { return; } }
1203 1194
@@ -1333,7 +1324,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1333 d.GeomDestroy(Shell); 1324 d.GeomDestroy(Shell);
1334 AvatarGeomAndBodyCreation(_position.X, _position.Y, 1325 AvatarGeomAndBodyCreation(_position.X, _position.Y,
1335 _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); 1326 _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
1336 Velocity = new PhysicsVector(0f, 0f, 0f); 1327 Velocity = Vector3.Zero;
1337 1328
1338 _parent_scene.geom_name_map[Shell] = m_name; 1329 _parent_scene.geom_name_map[Shell] = m_name;
1339 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 1330 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
@@ -1347,7 +1338,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1347 } 1338 }
1348 } 1339 }
1349 1340
1350 if (!m_taintPosition.IsIdentical(_position, 0.05f)) 1341 if (!m_taintPosition.ApproxEquals(_position, 0.05f))
1351 { 1342 {
1352 if (Body != IntPtr.Zero) 1343 if (Body != IntPtr.Zero)
1353 { 1344 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
index 0c168c6..345112d 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
@@ -38,6 +38,19 @@
38 * 38 *
39 */ 39 */
40 40
41/* Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
42 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
43 * ODEPrim.cs contains methods dealing with Prim editing, Prim
44 * characteristics and Kinetic motion.
45 * ODEDynamics.cs contains methods dealing with Prim Physical motion
46 * (dynamics) and the associated settings. Old Linear and angular
47 * motors for dynamic motion have been replace with MoveLinear()
48 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
49 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
50 * switch between 'VEHICLE' parameter use and general dynamics
51 * settings use.
52 */
53
41using System; 54using System;
42using System.Collections.Generic; 55using System.Collections.Generic;
43using System.Reflection; 56using System.Reflection;
@@ -232,7 +245,7 @@ namespace OpenSim.Region.Physics.OdePlugin
232 245
233 }//end ProcessFloatVehicleParam 246 }//end ProcessFloatVehicleParam
234 247
235 internal void ProcessVectorVehicleParam(Vehicle pParam, PhysicsVector pValue) 248 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue)
236 { 249 {
237 switch (pParam) 250 switch (pParam)
238 { 251 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 93c9a44..62c5c81 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -1,7 +1,5 @@
1/* 1/* Copyright (c) Contributors, http://opensimulator.org/
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 2 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without 3 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 4 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 5 * * Redistributions of source code must retain the above copyright
@@ -36,6 +34,20 @@
36 * switch between 'VEHICLE' parameter use and general dynamics 34 * switch between 'VEHICLE' parameter use and general dynamics
37 * settings use. 35 * settings use.
38 */ 36 */
37
38/*
39 * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
40 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
41 * ODEPrim.cs contains methods dealing with Prim editing, Prim
42 * characteristics and Kinetic motion.
43 * ODEDynamics.cs contains methods dealing with Prim Physical motion
44 * (dynamics) and the associated settings. Old Linear and angular
45 * motors for dynamic motion have been replace with MoveLinear()
46 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
47 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
48 * switch between 'VEHICLE' parameter use and general dynamics
49 * settings use.
50 */
39using System; 51using System;
40using System.Collections.Generic; 52using System.Collections.Generic;
41using System.Reflection; 53using System.Reflection;
@@ -57,29 +69,28 @@ namespace OpenSim.Region.Physics.OdePlugin
57 { 69 {
58 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 70 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
59 71
60 private PhysicsVector _position; 72 private Vector3 _position;
61 private PhysicsVector _velocity; 73 private Vector3 _velocity;
62 private PhysicsVector _torque = new PhysicsVector(0,0,0); 74 private Vector3 _torque;
63 private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); 75 private Vector3 m_lastVelocity;
64 private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); 76 private Vector3 m_lastposition;
65 private Quaternion m_lastorientation = new Quaternion(); 77 private Quaternion m_lastorientation = new Quaternion();
66 private PhysicsVector m_rotationalVelocity; 78 private Vector3 m_rotationalVelocity;
67 private PhysicsVector _size; 79 private Vector3 _size;
68 private PhysicsVector _acceleration; 80 private Vector3 _acceleration;
69 // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f); 81 // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f);
70 private Quaternion _orientation; 82 private Quaternion _orientation;
71 private PhysicsVector m_taintposition; 83 private Vector3 m_taintposition;
72 private PhysicsVector m_taintsize; 84 private Vector3 m_taintsize;
73 private PhysicsVector m_taintVelocity = new PhysicsVector(0, 0, 0); 85 private Vector3 m_taintVelocity;
74 private PhysicsVector m_taintTorque = new PhysicsVector(0, 0, 0); 86 private Vector3 m_taintTorque;
75 private Quaternion m_taintrot; 87 private Quaternion m_taintrot;
76 private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); 88 private Vector3 m_angularlock = Vector3.One;
77 private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); 89 private Vector3 m_taintAngularLock = Vector3.One;
78 private IntPtr Amotor = IntPtr.Zero; 90 private IntPtr Amotor = IntPtr.Zero;
79 91
80 private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0); 92 private Vector3 m_PIDTarget;
81 // private PhysicsVector m_taintPIDTarget = new PhysicsVector(0, 0, 0); 93 private float m_PIDTau;
82 private float m_PIDTau = 0f;
83 private float PID_D = 35f; 94 private float PID_D = 35f;
84 private float PID_G = 25f; 95 private float PID_G = 25f;
85 private bool m_usePID = false; 96 private bool m_usePID = false;
@@ -91,15 +102,22 @@ namespace OpenSim.Region.Physics.OdePlugin
91 102
92 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), 103 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
93 // and are for non-VEHICLES only. 104 // and are for non-VEHICLES only.
94 105
95 private float m_PIDHoverHeight = 0f; 106 private float m_PIDHoverHeight;
96 private float m_PIDHoverTau = 0f; 107 private float m_PIDHoverTau;
97 private bool m_useHoverPID = false; 108 private bool m_useHoverPID;
98 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground; 109 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground;
110<<<<<<< HEAD:OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
99 private float m_targetHoverHeight = 0f; 111 private float m_targetHoverHeight = 0f;
100 private float m_groundHeight = 0f; 112 private float m_groundHeight = 0f;
101 private float m_waterHeight = 0f; 113 private float m_waterHeight = 0f;
102 private float m_buoyancy = 0f; //Set by llSetBuoyancy(), for non-vehicles. 114 private float m_buoyancy = 0f; //Set by llSetBuoyancy(), for non-vehicles.
115=======
116 private float m_targetHoverHeight;
117 private float m_groundHeight;
118 private float m_waterHeight;
119 private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
120>>>>>>> vehicles:OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
103 121
104 // private float m_tensor = 5f; 122 // private float m_tensor = 5f;
105 private int body_autodisable_frames = 20; 123 private int body_autodisable_frames = 20;
@@ -110,11 +128,11 @@ namespace OpenSim.Region.Physics.OdePlugin
110 | CollisionCategories.Body 128 | CollisionCategories.Body
111 | CollisionCategories.Character 129 | CollisionCategories.Character
112 ); 130 );
113 private bool m_taintshape = false; 131 private bool m_taintshape;
114 private bool m_taintPhysics = false; 132 private bool m_taintPhysics;
115 private bool m_collidesLand = true; 133 private bool m_collidesLand = true;
116 private bool m_collidesWater = false; 134 private bool m_collidesWater;
117 public bool m_returnCollisions = false; 135 public bool m_returnCollisions;
118 136
119 // Default we're a Geometry 137 // Default we're a Geometry
120 private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); 138 private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
@@ -122,69 +140,68 @@ namespace OpenSim.Region.Physics.OdePlugin
122 // Default, Collide with Other Geometries, spaces and Bodies 140 // Default, Collide with Other Geometries, spaces and Bodies
123 private CollisionCategories m_collisionFlags = m_default_collisionFlags; 141 private CollisionCategories m_collisionFlags = m_default_collisionFlags;
124 142
125 public bool m_taintremove = false; 143 public bool m_taintremove;
126 public bool m_taintdisable = false; 144 public bool m_taintdisable;
127 public bool m_disabled = false; 145 public bool m_disabled;
128 public bool m_taintadd = false; 146 public bool m_taintadd;
129 public bool m_taintselected = false; 147 public bool m_taintselected;
130 public bool m_taintCollidesWater = false; 148 public bool m_taintCollidesWater;
131 149
132 public uint m_localID = 0; 150 public uint m_localID;
133 151
134 //public GCHandle gc; 152 //public GCHandle gc;
135 private CollisionLocker ode; 153 private CollisionLocker ode;
136 154
137 private bool m_taintforce = false; 155 private bool m_taintforce = false;
138 private bool m_taintaddangularforce = false; 156 private bool m_taintaddangularforce = false;
139 private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); 157 private Vector3 m_force;
140 private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); 158 private List<Vector3> m_forcelist = new List<Vector3>();
141 private List<PhysicsVector> m_angularforcelist = new List<PhysicsVector>(); 159 private List<Vector3> m_angularforcelist = new List<Vector3>();
142 160
143 private IMesh _mesh; 161 private IMesh _mesh;
144 private PrimitiveBaseShape _pbs; 162 private PrimitiveBaseShape _pbs;
145 private OdeScene _parent_scene; 163 private OdeScene _parent_scene;
146 public IntPtr m_targetSpace = (IntPtr) 0; 164 public IntPtr m_targetSpace = IntPtr.Zero;
147 public IntPtr prim_geom; 165 public IntPtr prim_geom;
148 public IntPtr prev_geom; 166 public IntPtr prev_geom;
149 public IntPtr _triMeshData; 167 public IntPtr _triMeshData;
150 168
151 private IntPtr _linkJointGroup = (IntPtr)0; 169 private IntPtr _linkJointGroup = IntPtr.Zero;
152 private PhysicsActor _parent = null; 170 private PhysicsActor _parent;
153 private PhysicsActor m_taintparent = null; 171 private PhysicsActor m_taintparent;
154 172
155 private List<OdePrim> childrenPrim = new List<OdePrim>(); 173 private List<OdePrim> childrenPrim = new List<OdePrim>();
156 174
157 private bool iscolliding = false; 175 private bool iscolliding;
158 private bool m_isphysical = false; 176 private bool m_isphysical;
159 private bool m_isSelected = false; 177 private bool m_isSelected;
160 178
161 internal bool m_isVolumeDetect = false; // If true, this prim only detects collisions but doesn't collide actively 179 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
162 180
163 private bool m_throttleUpdates = false; 181 private bool m_throttleUpdates;
164 private int throttleCounter = 0; 182 private int throttleCounter;
165 public int m_interpenetrationcount = 0; 183 public int m_interpenetrationcount;
166 public float m_collisionscore = 0; 184 public float m_collisionscore;
167 public int m_roundsUnderMotionThreshold = 0; 185 public int m_roundsUnderMotionThreshold;
168 private int m_crossingfailures = 0; 186 private int m_crossingfailures;
169 187
170 public bool outofBounds = false; 188 public bool outofBounds;
171 private float m_density = 10.000006836f; // Aluminum g/cm3; 189 private float m_density = 10.000006836f; // Aluminum g/cm3;
172 190
173 public bool _zeroFlag = false; 191 public bool _zeroFlag;
174 private bool m_lastUpdateSent = false; 192 private bool m_lastUpdateSent;
175 193
176 public IntPtr Body = (IntPtr) 0; 194 public IntPtr Body = IntPtr.Zero;
177 public String m_primName; 195 public String m_primName;
178// private String m_primName; 196 private Vector3 _target_velocity;
179 private PhysicsVector _target_velocity;
180 public d.Mass pMass; 197 public d.Mass pMass;
181 198
182 public int m_eventsubscription = 0; 199 public int m_eventsubscription;
183 private CollisionEventUpdate CollisionEventsThisFrame = null; 200 private CollisionEventUpdate CollisionEventsThisFrame;
184 201
185 private IntPtr m_linkJoint = (IntPtr)0; 202 private IntPtr m_linkJoint = IntPtr.Zero;
186 203
187 public volatile bool childPrim = false; 204 public volatile bool childPrim;
188 205
189 private ODEDynamics m_vehicle; 206 private ODEDynamics m_vehicle;
190 207
@@ -193,17 +210,16 @@ namespace OpenSim.Region.Physics.OdePlugin
193 private int frcount = 0; // Used to limit dynamics debug output to 210 private int frcount = 0; // Used to limit dynamics debug output to
194 211
195 212
196 public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, 213 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
197 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) 214 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
198 { 215 {
199 _target_velocity = new PhysicsVector(0, 0, 0);
200 m_vehicle = new ODEDynamics(); 216 m_vehicle = new ODEDynamics();
201 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); 217 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
202 ode = dode; 218 ode = dode;
203 _velocity = new PhysicsVector(); 219 if (!pos.IsFinite())
204 if (!PhysicsVector.isFinite(pos))
205 { 220 {
206 pos = new PhysicsVector(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), parent_scene.GetTerrainHeightAtXY(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f)) + 0.5f); 221 pos = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f),
222 parent_scene.GetTerrainHeightAtXY(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f)) + 0.5f);
207 m_log.Warn("[PHYSICS]: Got nonFinite Object create Position"); 223 m_log.Warn("[PHYSICS]: Got nonFinite Object create Position");
208 } 224 }
209 _position = pos; 225 _position = pos;
@@ -218,9 +234,9 @@ namespace OpenSim.Region.Physics.OdePlugin
218 prim_geom = IntPtr.Zero; 234 prim_geom = IntPtr.Zero;
219 prev_geom = IntPtr.Zero; 235 prev_geom = IntPtr.Zero;
220 236
221 if (!PhysicsVector.isFinite(pos)) 237 if (!pos.IsFinite())
222 { 238 {
223 size = new PhysicsVector(0.5f, 0.5f, 0.5f); 239 size = new Vector3(0.5f, 0.5f, 0.5f);
224 m_log.Warn("[PHYSICS]: Got nonFinite Object create Size"); 240 m_log.Warn("[PHYSICS]: Got nonFinite Object create Size");
225 } 241 }
226 242
@@ -230,8 +246,6 @@ namespace OpenSim.Region.Physics.OdePlugin
230 246
231 _size = size; 247 _size = size;
232 m_taintsize = _size; 248 m_taintsize = _size;
233 _acceleration = new PhysicsVector();
234 m_rotationalVelocity = PhysicsVector.Zero;
235 249
236 if (!QuaternionIsFinite(rotation)) 250 if (!QuaternionIsFinite(rotation))
237 { 251 {
@@ -396,7 +410,7 @@ namespace OpenSim.Region.Physics.OdePlugin
396 m_disabled = false; 410 m_disabled = false;
397 411
398 // The body doesn't already have a finite rotation mode set here 412 // The body doesn't already have a finite rotation mode set here
399 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 413 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0.0f)) && _parent == null)
400 { 414 {
401 createAMotor(m_angularlock); 415 createAMotor(m_angularlock);
402 } 416 }
@@ -809,6 +823,8 @@ namespace OpenSim.Region.Physics.OdePlugin
809 m_collisionscore = 0; 823 m_collisionscore = 0;
810 } 824 }
811 825
826 private static Dictionary<IMesh, IntPtr> m_MeshToTriMeshMap = new Dictionary<IMesh, IntPtr>();
827
812 public void setMesh(OdeScene parent_scene, IMesh mesh) 828 public void setMesh(OdeScene parent_scene, IMesh mesh)
813 { 829 {
814 // This sleeper is there to moderate how long it takes between 830 // This sleeper is there to moderate how long it takes between
@@ -840,19 +856,24 @@ namespace OpenSim.Region.Physics.OdePlugin
840 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage 856 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
841 857
842 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory 858 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
859 if (m_MeshToTriMeshMap.ContainsKey(mesh))
860 {
861 _triMeshData = m_MeshToTriMeshMap[mesh];
862 }
863 else
864 {
865 _triMeshData = d.GeomTriMeshDataCreate();
843 866
844 _triMeshData = d.GeomTriMeshDataCreate(); 867 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
845 868 d.GeomTriMeshDataPreprocess(_triMeshData);
846 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); 869 m_MeshToTriMeshMap[mesh] = _triMeshData;
847 d.GeomTriMeshDataPreprocess(_triMeshData); 870 }
848 871
849 _parent_scene.waitForSpaceUnlock(m_targetSpace); 872 _parent_scene.waitForSpaceUnlock(m_targetSpace);
850
851 try 873 try
852 { 874 {
853 if (prim_geom == IntPtr.Zero) 875 if (prim_geom == IntPtr.Zero)
854 { 876 {
855//Console.WriteLine(" setMesh 1");
856 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); 877 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
857 } 878 }
858 } 879 }
@@ -862,6 +883,7 @@ namespace OpenSim.Region.Physics.OdePlugin
862 return; 883 return;
863 } 884 }
864 885
886
865 // if (IsPhysical && Body == (IntPtr) 0) 887 // if (IsPhysical && Body == (IntPtr) 0)
866 // { 888 // {
867 // Recreate the body 889 // Recreate the body
@@ -882,7 +904,7 @@ namespace OpenSim.Region.Physics.OdePlugin
882 904
883 if (prim_geom != IntPtr.Zero) 905 if (prim_geom != IntPtr.Zero)
884 { 906 {
885 if (!_position.IsIdentical(m_taintposition,0f)) 907 if (!_position.ApproxEquals(m_taintposition, 0f))
886 changemove(timestep); 908 changemove(timestep);
887 909
888 if (m_taintrot != _orientation) 910 if (m_taintrot != _orientation)
@@ -907,7 +929,7 @@ namespace OpenSim.Region.Physics.OdePlugin
907 changePhysicsStatus(timestep); 929 changePhysicsStatus(timestep);
908 // 930 //
909 931
910 if (!_size.IsIdentical(m_taintsize,0)) 932 if (!_size.ApproxEquals(m_taintsize,0f))
911 changesize(timestep); 933 changesize(timestep);
912 // 934 //
913 935
@@ -921,7 +943,7 @@ namespace OpenSim.Region.Physics.OdePlugin
921 if (m_taintaddangularforce) 943 if (m_taintaddangularforce)
922 changeAddAngularForce(timestep); 944 changeAddAngularForce(timestep);
923 945
924 if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) 946 if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
925 changeSetTorque(timestep); 947 changeSetTorque(timestep);
926 948
927 if (m_taintdisable) 949 if (m_taintdisable)
@@ -930,7 +952,7 @@ namespace OpenSim.Region.Physics.OdePlugin
930 if (m_taintselected != m_isSelected) 952 if (m_taintselected != m_isSelected)
931 changeSelectedStatus(timestep); 953 changeSelectedStatus(timestep);
932 954
933 if (!m_taintVelocity.IsIdentical(PhysicsVector.Zero, 0.001f)) 955 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
934 changevelocity(timestep); 956 changevelocity(timestep);
935 957
936 if (m_taintparent != _parent) 958 if (m_taintparent != _parent)
@@ -939,7 +961,7 @@ namespace OpenSim.Region.Physics.OdePlugin
939 if (m_taintCollidesWater != m_collidesWater) 961 if (m_taintCollidesWater != m_collidesWater)
940 changefloatonwater(timestep); 962 changefloatonwater(timestep);
941 963
942 if (!m_angularlock.IsIdentical(m_taintAngularLock,0)) 964 if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f))
943 changeAngularLock(timestep); 965 changeAngularLock(timestep);
944 966
945 } 967 }
@@ -959,7 +981,7 @@ namespace OpenSim.Region.Physics.OdePlugin
959 //If we have a parent then we're not authorative here 981 //If we have a parent then we're not authorative here
960 if (_parent == null) 982 if (_parent == null)
961 { 983 {
962 if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f,1f,1f), 0)) 984 if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
963 { 985 {
964 //d.BodySetFiniteRotationMode(Body, 0); 986 //d.BodySetFiniteRotationMode(Body, 0);
965 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z); 987 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
@@ -976,7 +998,7 @@ namespace OpenSim.Region.Physics.OdePlugin
976 } 998 }
977 } 999 }
978 // Store this for later in case we get turned into a separate body 1000 // Store this for later in case we get turned into a separate body
979 m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); 1001 m_angularlock = m_taintAngularLock;
980 1002
981 } 1003 }
982 1004
@@ -1120,7 +1142,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1120 prm.m_disabled = false; 1142 prm.m_disabled = false;
1121 1143
1122 // The body doesn't already have a finite rotation mode set here 1144 // The body doesn't already have a finite rotation mode set here
1123 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 1145 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
1124 { 1146 {
1125 prm.createAMotor(m_angularlock); 1147 prm.createAMotor(m_angularlock);
1126 } 1148 }
@@ -1163,7 +1185,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1163 m_disabled = false; 1185 m_disabled = false;
1164 1186
1165 // The body doesn't already have a finite rotation mode set here 1187 // The body doesn't already have a finite rotation mode set here
1166 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 1188 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
1167 { 1189 {
1168 createAMotor(m_angularlock); 1190 createAMotor(m_angularlock);
1169 } 1191 }
@@ -1347,7 +1369,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1347 m_taintshape = false; 1369 m_taintshape = false;
1348 m_taintforce = false; 1370 m_taintforce = false;
1349 m_taintdisable = false; 1371 m_taintdisable = false;
1350 m_taintVelocity = PhysicsVector.Zero; 1372 m_taintVelocity = Vector3.Zero;
1351 } 1373 }
1352 1374
1353 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) 1375 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh)
@@ -1580,7 +1602,7 @@ if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle
1580 { 1602 {
1581 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009 1603 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
1582 // NON-'VEHICLES' are dealt with here 1604 // NON-'VEHICLES' are dealt with here
1583 if (d.BodyIsEnabled(Body) && !m_angularlock.IsIdentical(PhysicsVector.Zero, 0.003f)) 1605 if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f))
1584 { 1606 {
1585 d.Vector3 avel2 = d.BodyGetAngularVel(Body); 1607 d.Vector3 avel2 = d.BodyGetAngularVel(Body);
1586 if (m_angularlock.X == 1) 1608 if (m_angularlock.X == 1)
@@ -1634,7 +1656,7 @@ if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle
1634 1656
1635 d.Vector3 pos = d.BodyGetPosition(Body); 1657 d.Vector3 pos = d.BodyGetPosition(Body);
1636 _target_velocity = 1658 _target_velocity =
1637 new PhysicsVector( 1659 new Vector3(
1638 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), 1660 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1639 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), 1661 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1640 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep) 1662 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
@@ -1642,7 +1664,7 @@ if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle
1642 1664
1643 // if velocity is zero, use position control; otherwise, velocity control 1665 // if velocity is zero, use position control; otherwise, velocity control
1644 1666
1645 if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f)) 1667 if (_target_velocity.ApproxEquals(Vector3.Zero,0.1f))
1646 { 1668 {
1647 // keep track of where we stopped. No more slippin' & slidin' 1669 // keep track of where we stopped. No more slippin' & slidin'
1648 1670
@@ -1727,13 +1749,13 @@ if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle
1727 1749
1728 1750
1729 _target_velocity = 1751 _target_velocity =
1730 new PhysicsVector(0.0f, 0.0f, 1752 new Vector3(0.0f, 0.0f,
1731 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep) 1753 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1732 ); 1754 );
1733 1755
1734 // if velocity is zero, use position control; otherwise, velocity control 1756 // if velocity is zero, use position control; otherwise, velocity control
1735 1757
1736 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1758 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1737 { 1759 {
1738 // keep track of where we stopped. No more slippin' & slidin' 1760 // keep track of where we stopped. No more slippin' & slidin'
1739 1761
@@ -1860,7 +1882,7 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
1860 d.BodySetQuaternion(Body, ref myrot); 1882 d.BodySetQuaternion(Body, ref myrot);
1861 if (m_isphysical) 1883 if (m_isphysical)
1862 { 1884 {
1863 if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0)) 1885 if (!m_angularlock.ApproxEquals(Vector3.One, 0f))
1864 createAMotor(m_angularlock); 1886 createAMotor(m_angularlock);
1865 } 1887 }
1866 } 1888 }
@@ -2169,7 +2191,7 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2169 //m_log.Info("[PHYSICS]: dequeing forcelist"); 2191 //m_log.Info("[PHYSICS]: dequeing forcelist");
2170 if (IsPhysical) 2192 if (IsPhysical)
2171 { 2193 {
2172 PhysicsVector iforce = new PhysicsVector(); 2194 Vector3 iforce = Vector3.Zero;
2173 for (int i = 0; i < m_forcelist.Count; i++) 2195 for (int i = 0; i < m_forcelist.Count; i++)
2174 { 2196 {
2175 iforce = iforce + (m_forcelist[i] * 100); 2197 iforce = iforce + (m_forcelist[i] * 100);
@@ -2199,8 +2221,8 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2199 d.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z); 2221 d.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z);
2200 } 2222 }
2201 } 2223 }
2202 2224
2203 m_taintTorque = new PhysicsVector(0, 0, 0); 2225 m_taintTorque = Vector3.Zero;
2204 } 2226 }
2205 2227
2206 public void changeAddAngularForce(float timestamp) 2228 public void changeAddAngularForce(float timestamp)
@@ -2212,7 +2234,7 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2212 //m_log.Info("[PHYSICS]: dequeing forcelist"); 2234 //m_log.Info("[PHYSICS]: dequeing forcelist");
2213 if (IsPhysical) 2235 if (IsPhysical)
2214 { 2236 {
2215 PhysicsVector iforce = new PhysicsVector(); 2237 Vector3 iforce = Vector3.Zero;
2216 for (int i = 0; i < m_angularforcelist.Count; i++) 2238 for (int i = 0; i < m_angularforcelist.Count; i++)
2217 { 2239 {
2218 iforce = iforce + (m_angularforcelist[i] * 100); 2240 iforce = iforce + (m_angularforcelist[i] * 100);
@@ -2246,7 +2268,7 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2246 2268
2247 //resetCollisionAccounting(); 2269 //resetCollisionAccounting();
2248 } 2270 }
2249 m_taintVelocity = PhysicsVector.Zero; 2271 m_taintVelocity = Vector3.Zero;
2250 } 2272 }
2251 2273
2252 public override bool IsPhysical 2274 public override bool IsPhysical
@@ -2255,7 +2277,7 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2255 set { 2277 set {
2256 m_isphysical = value; 2278 m_isphysical = value;
2257 if (!m_isphysical) // Zero the remembered last velocity 2279 if (!m_isphysical) // Zero the remembered last velocity
2258 m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); 2280 m_lastVelocity = Vector3.Zero;
2259 } 2281 }
2260 } 2282 }
2261 2283
@@ -2300,7 +2322,7 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2300 get { return _zeroFlag; } 2322 get { return _zeroFlag; }
2301 } 2323 }
2302 2324
2303 public override PhysicsVector Position 2325 public override Vector3 Position
2304 { 2326 {
2305 get { return _position; } 2327 get { return _position; }
2306 2328
@@ -2309,12 +2331,12 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2309 } 2331 }
2310 } 2332 }
2311 2333
2312 public override PhysicsVector Size 2334 public override Vector3 Size
2313 { 2335 {
2314 get { return _size; } 2336 get { return _size; }
2315 set 2337 set
2316 { 2338 {
2317 if (PhysicsVector.isFinite(value)) 2339 if (value.IsFinite())
2318 { 2340 {
2319 _size = value; 2341 _size = value;
2320 } 2342 }
@@ -2330,13 +2352,13 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2330 get { return CalculateMass(); } 2352 get { return CalculateMass(); }
2331 } 2353 }
2332 2354
2333 public override PhysicsVector Force 2355 public override Vector3 Force
2334 { 2356 {
2335 //get { return PhysicsVector.Zero; } 2357 //get { return Vector3.Zero; }
2336 get { return m_force; } 2358 get { return m_force; }
2337 set 2359 set
2338 { 2360 {
2339 if (PhysicsVector.isFinite(value)) 2361 if (value.IsFinite())
2340 { 2362 {
2341 m_force = value; 2363 m_force = value;
2342 } 2364 }
@@ -2358,7 +2380,7 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2358 m_vehicle.ProcessFloatVehicleParam((Vehicle) param, value); 2380 m_vehicle.ProcessFloatVehicleParam((Vehicle) param, value);
2359 } 2381 }
2360 2382
2361 public override void VehicleVectorParam(int param, PhysicsVector value) 2383 public override void VehicleVectorParam(int param, Vector3 value)
2362 { 2384 {
2363 m_vehicle.ProcessVectorVehicleParam((Vehicle) param, value); 2385 m_vehicle.ProcessVectorVehicleParam((Vehicle) param, value);
2364 } 2386 }
@@ -2376,14 +2398,14 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2376 } 2398 }
2377 } 2399 }
2378 2400
2379 public override PhysicsVector CenterOfMass 2401 public override Vector3 CenterOfMass
2380 { 2402 {
2381 get { return PhysicsVector.Zero; } 2403 get { return Vector3.Zero; }
2382 } 2404 }
2383 2405
2384 public override PhysicsVector GeometricCenter 2406 public override Vector3 GeometricCenter
2385 { 2407 {
2386 get { return PhysicsVector.Zero; } 2408 get { return Vector3.Zero; }
2387 } 2409 }
2388 2410
2389 public override PrimitiveBaseShape Shape 2411 public override PrimitiveBaseShape Shape
@@ -2395,13 +2417,13 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2395 } 2417 }
2396 } 2418 }
2397 2419
2398 public override PhysicsVector Velocity 2420 public override Vector3 Velocity
2399 { 2421 {
2400 get 2422 get
2401 { 2423 {
2402 // Averate previous velocity with the new one so 2424 // Averate previous velocity with the new one so
2403 // client object interpolation works a 'little' better 2425 // client object interpolation works a 'little' better
2404 PhysicsVector returnVelocity = new PhysicsVector(); 2426 Vector3 returnVelocity = Vector3.Zero;
2405 returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2; 2427 returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2;
2406 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2; 2428 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2;
2407 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2; 2429 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2;
@@ -2409,7 +2431,7 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2409 } 2431 }
2410 set 2432 set
2411 { 2433 {
2412 if (PhysicsVector.isFinite(value)) 2434 if (value.IsFinite())
2413 { 2435 {
2414 _velocity = value; 2436 _velocity = value;
2415 2437
@@ -2424,19 +2446,19 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2424 } 2446 }
2425 } 2447 }
2426 2448
2427 public override PhysicsVector Torque 2449 public override Vector3 Torque
2428 { 2450 {
2429 get 2451 get
2430 { 2452 {
2431 if (!m_isphysical || Body == IntPtr.Zero) 2453 if (!m_isphysical || Body == IntPtr.Zero)
2432 return new PhysicsVector(0,0,0); 2454 return Vector3.Zero;
2433 2455
2434 return _torque; 2456 return _torque;
2435 } 2457 }
2436 2458
2437 set 2459 set
2438 { 2460 {
2439 if (PhysicsVector.isFinite(value)) 2461 if (value.IsFinite())
2440 { 2462 {
2441 m_taintTorque = value; 2463 m_taintTorque = value;
2442 _parent_scene.AddPhysicsActorTaint(this); 2464 _parent_scene.AddPhysicsActorTaint(this);
@@ -2488,20 +2510,20 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2488 return true; 2510 return true;
2489 } 2511 }
2490 2512
2491 public override PhysicsVector Acceleration 2513 public override Vector3 Acceleration
2492 { 2514 {
2493 get { return _acceleration; } 2515 get { return _acceleration; }
2494 } 2516 }
2495 2517
2496 2518
2497 public void SetAcceleration(PhysicsVector accel) 2519 public void SetAcceleration(Vector3 accel)
2498 { 2520 {
2499 _acceleration = accel; 2521 _acceleration = accel;
2500 } 2522 }
2501 2523
2502 public override void AddForce(PhysicsVector force, bool pushforce) 2524 public override void AddForce(Vector3 force, bool pushforce)
2503 { 2525 {
2504 if (PhysicsVector.isFinite(force)) 2526 if (force.IsFinite())
2505 { 2527 {
2506 m_forcelist.Add(force); 2528 m_forcelist.Add(force);
2507 m_taintforce = true; 2529 m_taintforce = true;
@@ -2513,9 +2535,9 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2513 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); 2535 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
2514 } 2536 }
2515 2537
2516 public override void AddAngularForce(PhysicsVector force, bool pushforce) 2538 public override void AddAngularForce(Vector3 force, bool pushforce)
2517 { 2539 {
2518 if (PhysicsVector.isFinite(force)) 2540 if (force.IsFinite())
2519 { 2541 {
2520 m_angularforcelist.Add(force); 2542 m_angularforcelist.Add(force);
2521 m_taintaddangularforce = true; 2543 m_taintaddangularforce = true;
@@ -2526,23 +2548,23 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2526 } 2548 }
2527 } 2549 }
2528 2550
2529 public override PhysicsVector RotationalVelocity 2551 public override Vector3 RotationalVelocity
2530 { 2552 {
2531 get 2553 get
2532 { 2554 {
2533 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2555 Vector3 pv = Vector3.Zero;
2534 if (_zeroFlag) 2556 if (_zeroFlag)
2535 return pv; 2557 return pv;
2536 m_lastUpdateSent = false; 2558 m_lastUpdateSent = false;
2537 2559
2538 if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) 2560 if (m_rotationalVelocity.ApproxEquals(pv, 0.2f))
2539 return pv; 2561 return pv;
2540 2562
2541 return m_rotationalVelocity; 2563 return m_rotationalVelocity;
2542 } 2564 }
2543 set 2565 set
2544 { 2566 {
2545 if (PhysicsVector.isFinite(value)) 2567 if (value.IsFinite())
2546 { 2568 {
2547 m_rotationalVelocity = value; 2569 m_rotationalVelocity = value;
2548 } 2570 }
@@ -2583,16 +2605,16 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2583 m_taintparent = null; 2605 m_taintparent = null;
2584 } 2606 }
2585 2607
2586 public override void LockAngularMotion(PhysicsVector axis) 2608 public override void LockAngularMotion(Vector3 axis)
2587 { 2609 {
2588 // reverse the zero/non zero values for ODE. 2610 // reverse the zero/non zero values for ODE.
2589 if (PhysicsVector.isFinite(axis)) 2611 if (axis.IsFinite())
2590 { 2612 {
2591 axis.X = (axis.X > 0) ? 1f : 0f; 2613 axis.X = (axis.X > 0) ? 1f : 0f;
2592 axis.Y = (axis.Y > 0) ? 1f : 0f; 2614 axis.Y = (axis.Y > 0) ? 1f : 0f;
2593 axis.Z = (axis.Z > 0) ? 1f : 0f; 2615 axis.Z = (axis.Z > 0) ? 1f : 0f;
2594 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); 2616 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z);
2595 m_taintAngularLock = new PhysicsVector(axis.X, axis.Y, axis.Z); 2617 m_taintAngularLock = axis;
2596 } 2618 }
2597 else 2619 else
2598 { 2620 {
@@ -2605,7 +2627,7 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2605 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 2627 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
2606 if (_parent == null) 2628 if (_parent == null)
2607 { 2629 {
2608 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2630 Vector3 pv = Vector3.Zero;
2609 bool lastZeroFlag = _zeroFlag; 2631 bool lastZeroFlag = _zeroFlag;
2610 if (Body != (IntPtr)0) // FIXME -> or if it is a joint 2632 if (Body != (IntPtr)0) // FIXME -> or if it is a joint
2611 { 2633 {
@@ -2614,9 +2636,9 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2614 d.Vector3 vel = d.BodyGetLinearVel(Body); 2636 d.Vector3 vel = d.BodyGetLinearVel(Body);
2615 d.Vector3 rotvel = d.BodyGetAngularVel(Body); 2637 d.Vector3 rotvel = d.BodyGetAngularVel(Body);
2616 d.Vector3 torque = d.BodyGetTorque(Body); 2638 d.Vector3 torque = d.BodyGetTorque(Body);
2617 _torque.setValues(torque.X, torque.Y, torque.Z); 2639 _torque = new Vector3(torque.X, torque.Y, torque.Z);
2618 PhysicsVector l_position = new PhysicsVector(); 2640 Vector3 l_position = Vector3.Zero;
2619 Quaternion l_orientation = new Quaternion(); 2641 Quaternion l_orientation = Quaternion.Identity;
2620 2642
2621 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 2643 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
2622 //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } 2644 //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
@@ -2751,16 +2773,16 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2751 _velocity.Z = vel.Z; 2773 _velocity.Z = vel.Z;
2752 2774
2753 _acceleration = ((_velocity - m_lastVelocity) / 0.1f); 2775 _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
2754 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f); 2776 _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f);
2755 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); 2777 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
2756 2778
2757 if (_velocity.IsIdentical(pv, 0.5f)) 2779 if (_velocity.ApproxEquals(pv, 0.5f))
2758 { 2780 {
2759 m_rotationalVelocity = pv; 2781 m_rotationalVelocity = pv;
2760 } 2782 }
2761 else 2783 else
2762 { 2784 {
2763 m_rotationalVelocity.setValues(rotvel.X, rotvel.Y, rotvel.Z); 2785 m_rotationalVelocity = new Vector3(rotvel.X, rotvel.Y, rotvel.Z);
2764 } 2786 }
2765 2787
2766 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString()); 2788 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
@@ -2808,15 +2830,15 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2808 } 2830 }
2809 } 2831 }
2810 2832
2811 public override void SetMomentum(PhysicsVector momentum) 2833 public override void SetMomentum(Vector3 momentum)
2812 { 2834 {
2813 } 2835 }
2814 2836
2815 public override PhysicsVector PIDTarget 2837 public override Vector3 PIDTarget
2816 { 2838 {
2817 set 2839 set
2818 { 2840 {
2819 if (PhysicsVector.isFinite(value)) 2841 if (value.IsFinite())
2820 { 2842 {
2821 m_PIDTarget = value; 2843 m_PIDTarget = value;
2822 } 2844 }
@@ -2838,7 +2860,7 @@ if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo +
2838 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } } 2860 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
2839 public override float PIDHoverTau { set { m_PIDHoverTau = value; } } 2861 public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
2840 2862
2841 private void createAMotor(PhysicsVector axis) 2863 private void createAMotor(Vector3 axis)
2842 { 2864 {
2843 if (Body == IntPtr.Zero) 2865 if (Body == IntPtr.Zero)
2844 return; 2866 return;
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 0a065be..2f42646 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -239,6 +239,7 @@ namespace OpenSim.Region.Physics.OdePlugin
239 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>(); 239 private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
240 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>(); 240 private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
241 private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>(); 241 private readonly HashSet<OdePrim> _taintedPrimH = new HashSet<OdePrim>();
242 private readonly Object _taintedPrimLock = new Object();
242 private readonly List<OdePrim> _taintedPrimL = new List<OdePrim>(); 243 private readonly List<OdePrim> _taintedPrimL = new List<OdePrim>();
243 private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>(); 244 private readonly HashSet<OdeCharacter> _taintedActors = new HashSet<OdeCharacter>();
244 private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>(); 245 private readonly List<d.ContactGeom> _perloopContact = new List<d.ContactGeom>();
@@ -683,7 +684,7 @@ namespace OpenSim.Region.Physics.OdePlugin
683 /// </summary> 684 /// </summary>
684 /// <param name="pos"></param> 685 /// <param name="pos"></param>
685 /// <returns>Returns which split up space the given position is in.</returns> 686 /// <returns>Returns which split up space the given position is in.</returns>
686 public string whichspaceamIin(PhysicsVector pos) 687 public string whichspaceamIin(Vector3 pos)
687 { 688 {
688 return calculateSpaceForGeom(pos).ToString(); 689 return calculateSpaceForGeom(pos).ToString();
689 } 690 }
@@ -962,7 +963,7 @@ namespace OpenSim.Region.Physics.OdePlugin
962 963
963 //p2.CollidingObj = true; 964 //p2.CollidingObj = true;
964 contacts[i].depth = 0.00000003f; 965 contacts[i].depth = 0.00000003f;
965 p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 0.5f); 966 p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f);
966 contacts[i].pos = 967 contacts[i].pos =
967 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), 968 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
968 contacts[i].pos.Y + (p1.Size.Y/2), 969 contacts[i].pos.Y + (p1.Size.Y/2),
@@ -980,7 +981,7 @@ namespace OpenSim.Region.Physics.OdePlugin
980 981
981 //p2.CollidingObj = true; 982 //p2.CollidingObj = true;
982 contacts[i].depth = 0.00000003f; 983 contacts[i].depth = 0.00000003f;
983 p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 0.5f); 984 p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f);
984 contacts[i].pos = 985 contacts[i].pos =
985 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2), 986 new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
986 contacts[i].pos.Y + (p1.Size.Y/2), 987 contacts[i].pos.Y + (p1.Size.Y/2),
@@ -1645,9 +1646,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1645 1646
1646 #region Add/Remove Entities 1647 #region Add/Remove Entities
1647 1648
1648 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 1649 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
1649 { 1650 {
1650 PhysicsVector pos = new PhysicsVector(); 1651 Vector3 pos;
1651 pos.X = position.X; 1652 pos.X = position.X;
1652 pos.Y = position.Y; 1653 pos.Y = position.Y;
1653 pos.Z = position.Z; 1654 pos.Z = position.Z;
@@ -1697,18 +1698,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1697 1698
1698 } 1699 }
1699 1700
1700 private PhysicsActor AddPrim(String name, PhysicsVector position, PhysicsVector size, Quaternion rotation, 1701 private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation,
1701 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical) 1702 IMesh mesh, PrimitiveBaseShape pbs, bool isphysical)
1702 { 1703 {
1703 1704
1704 PhysicsVector pos = new PhysicsVector(position.X, position.Y, position.Z); 1705 Vector3 pos = position;
1705 //pos.X = position.X; 1706 Vector3 siz = size;
1706 //pos.Y = position.Y;
1707 //pos.Z = position.Z;
1708 PhysicsVector siz = new PhysicsVector();
1709 siz.X = size.X;
1710 siz.Y = size.Y;
1711 siz.Z = size.Z;
1712 Quaternion rot = rotation; 1707 Quaternion rot = rotation;
1713 1708
1714 OdePrim newPrim; 1709 OdePrim newPrim;
@@ -1735,14 +1730,14 @@ namespace OpenSim.Region.Physics.OdePlugin
1735 } 1730 }
1736 } 1731 }
1737 1732
1738 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 1733 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1739 PhysicsVector size, Quaternion rotation) //To be removed 1734 Vector3 size, Quaternion rotation) //To be removed
1740 { 1735 {
1741 return AddPrimShape(primName, pbs, position, size, rotation, false); 1736 return AddPrimShape(primName, pbs, position, size, rotation, false);
1742 } 1737 }
1743 1738
1744 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 1739 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
1745 PhysicsVector size, Quaternion rotation, bool isPhysical) 1740 Vector3 size, Quaternion rotation, bool isPhysical)
1746 { 1741 {
1747 PhysicsActor result; 1742 PhysicsActor result;
1748 IMesh mesh = null; 1743 IMesh mesh = null;
@@ -1975,7 +1970,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1975 // this joint will just be added to a waiting list that is NOT processed during the main 1970 // this joint will just be added to a waiting list that is NOT processed during the main
1976 // Simulate() loop (to avoid deadlocks). After Simulate() is finished, we handle unprocessed joint requests. 1971 // Simulate() loop (to avoid deadlocks). After Simulate() is finished, we handle unprocessed joint requests.
1977 1972
1978 public override PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, PhysicsVector position, 1973 public override PhysicsJoint RequestJointCreation(string objectNameInScene, PhysicsJointType jointType, Vector3 position,
1979 Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation) 1974 Quaternion rotation, string parms, List<string> bodyNames, string trackedBodyName, Quaternion localRotation)
1980 1975
1981 { 1976 {
@@ -1983,7 +1978,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1983 OdePhysicsJoint joint = new OdePhysicsJoint(); 1978 OdePhysicsJoint joint = new OdePhysicsJoint();
1984 joint.ObjectNameInScene = objectNameInScene; 1979 joint.ObjectNameInScene = objectNameInScene;
1985 joint.Type = jointType; 1980 joint.Type = jointType;
1986 joint.Position = new PhysicsVector(position.X, position.Y, position.Z); 1981 joint.Position = position;
1987 joint.Rotation = rotation; 1982 joint.Rotation = rotation;
1988 joint.RawParams = parms; 1983 joint.RawParams = parms;
1989 joint.BodyNames = new List<string>(bodyNames); 1984 joint.BodyNames = new List<string>(bodyNames);
@@ -2035,7 +2030,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2035 } 2030 }
2036 2031
2037 // normally called from within OnJointMoved, which is called from within a lock (OdeLock) 2032 // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
2038 public override PhysicsVector GetJointAnchor(PhysicsJoint joint) 2033 public override Vector3 GetJointAnchor(PhysicsJoint joint)
2039 { 2034 {
2040 Debug.Assert(joint.IsInPhysicsEngine); 2035 Debug.Assert(joint.IsInPhysicsEngine);
2041 d.Vector3 pos = new d.Vector3(); 2036 d.Vector3 pos = new d.Vector3();
@@ -2057,14 +2052,14 @@ namespace OpenSim.Region.Physics.OdePlugin
2057 break; 2052 break;
2058 } 2053 }
2059 } 2054 }
2060 return new PhysicsVector(pos.X, pos.Y, pos.Z); 2055 return new Vector3(pos.X, pos.Y, pos.Z);
2061 } 2056 }
2062 2057
2063 // normally called from within OnJointMoved, which is called from within a lock (OdeLock) 2058 // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
2064 // WARNING: ODE sometimes returns <0,0,0> as the joint axis! Therefore this function 2059 // WARNING: ODE sometimes returns <0,0,0> as the joint axis! Therefore this function
2065 // appears to be unreliable. Fortunately we can compute the joint axis ourselves by 2060 // appears to be unreliable. Fortunately we can compute the joint axis ourselves by
2066 // keeping track of the joint's original orientation relative to one of the involved bodies. 2061 // keeping track of the joint's original orientation relative to one of the involved bodies.
2067 public override PhysicsVector GetJointAxis(PhysicsJoint joint) 2062 public override Vector3 GetJointAxis(PhysicsJoint joint)
2068 { 2063 {
2069 Debug.Assert(joint.IsInPhysicsEngine); 2064 Debug.Assert(joint.IsInPhysicsEngine);
2070 d.Vector3 axis = new d.Vector3(); 2065 d.Vector3 axis = new d.Vector3();
@@ -2086,7 +2081,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2086 break; 2081 break;
2087 } 2082 }
2088 } 2083 }
2089 return new PhysicsVector(axis.X, axis.Y, axis.Z); 2084 return new Vector3(axis.X, axis.Y, axis.Z);
2090 } 2085 }
2091 2086
2092 2087
@@ -2254,7 +2249,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2254 /// <param name="pos">the position that the geom moved to</param> 2249 /// <param name="pos">the position that the geom moved to</param>
2255 /// <param name="currentspace">a pointer to the space it was in before it was moved.</param> 2250 /// <param name="currentspace">a pointer to the space it was in before it was moved.</param>
2256 /// <returns>a pointer to the new space it's in</returns> 2251 /// <returns>a pointer to the new space it's in</returns>
2257 public IntPtr recalculateSpaceForGeom(IntPtr geom, PhysicsVector pos, IntPtr currentspace) 2252 public IntPtr recalculateSpaceForGeom(IntPtr geom, Vector3 pos, IntPtr currentspace)
2258 { 2253 {
2259 // Called from setting the Position and Size of an ODEPrim so 2254 // Called from setting the Position and Size of an ODEPrim so
2260 // it's already in locked space. 2255 // it's already in locked space.
@@ -2401,7 +2396,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2401 /// </summary> 2396 /// </summary>
2402 /// <param name="pos"></param> 2397 /// <param name="pos"></param>
2403 /// <returns>a pointer to the space. This could be a new space or reused space.</returns> 2398 /// <returns>a pointer to the space. This could be a new space or reused space.</returns>
2404 public IntPtr calculateSpaceForGeom(PhysicsVector pos) 2399 public IntPtr calculateSpaceForGeom(Vector3 pos)
2405 { 2400 {
2406 int[] xyspace = calculateSpaceArrayItemFromPos(pos); 2401 int[] xyspace = calculateSpaceArrayItemFromPos(pos);
2407 //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); 2402 //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString());
@@ -2413,7 +2408,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2413 /// </summary> 2408 /// </summary>
2414 /// <param name="pos"></param> 2409 /// <param name="pos"></param>
2415 /// <returns>an array item based on the position</returns> 2410 /// <returns>an array item based on the position</returns>
2416 public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos) 2411 public int[] calculateSpaceArrayItemFromPos(Vector3 pos)
2417 { 2412 {
2418 int[] returnint = new int[2]; 2413 int[] returnint = new int[2];
2419 2414
@@ -2572,7 +2567,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2572 if (prim is OdePrim) 2567 if (prim is OdePrim)
2573 { 2568 {
2574 OdePrim taintedprim = ((OdePrim) prim); 2569 OdePrim taintedprim = ((OdePrim) prim);
2575 lock (_taintedPrimH) 2570 lock (_taintedPrimLock)
2576 { 2571 {
2577 if (!(_taintedPrimH.Contains(taintedprim))) 2572 if (!(_taintedPrimH.Contains(taintedprim)))
2578 { 2573 {
@@ -2700,24 +2695,28 @@ namespace OpenSim.Region.Physics.OdePlugin
2700 // Modify other objects in the scene. 2695 // Modify other objects in the scene.
2701 processedtaints = false; 2696 processedtaints = false;
2702 2697
2703 lock (_taintedPrimL) 2698 lock (_taintedPrimLock)
2704 { 2699 {
2705 foreach (OdePrim prim in _taintedPrimL) 2700 foreach (OdePrim prim in _taintedPrimL)
2706 { 2701 {
2707
2708
2709 if (prim.m_taintremove) 2702 if (prim.m_taintremove)
2710 { 2703 {
2711//Console.WriteLine("Simulate calls RemovePrimThreadLocked"); 2704 //Console.WriteLine("Simulate calls RemovePrimThreadLocked");
2712 RemovePrimThreadLocked(prim); 2705 RemovePrimThreadLocked(prim);
2713 } 2706 }
2714 else 2707 else
2715 { 2708 {
2716//Console.WriteLine("Simulate calls ProcessTaints"); 2709 //Console.WriteLine("Simulate calls ProcessTaints");
2717 prim.ProcessTaints(timeStep); 2710 prim.ProcessTaints(timeStep);
2718 } 2711 }
2719 processedtaints = true; 2712 processedtaints = true;
2720 prim.m_collisionscore = 0; 2713 prim.m_collisionscore = 0;
2714
2715 // This loop can block up the Heartbeat for a very long time on large regions.
2716 // We need to let the Watchdog know that the Heartbeat is not dead
2717 // NOTE: This is currently commented out, but if things like OAR loading are
2718 // timing the heartbeat out we will need to uncomment it
2719 //Watchdog.UpdateThread();
2721 } 2720 }
2722 2721
2723 if (SupportsNINJAJoints) 2722 if (SupportsNINJAJoints)
diff --git a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
index cdd38c4..69e2d03 100644
--- a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
+++ b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs
@@ -76,8 +76,8 @@ namespace OpenSim.Region.Physics.OdePlugin
76 public void CreateAndDropPhysicalCube() 76 public void CreateAndDropPhysicalCube()
77 { 77 {
78 PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox(); 78 PrimitiveBaseShape newcube = PrimitiveBaseShape.CreateBox();
79 PhysicsVector position = new PhysicsVector(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); 79 Vector3 position = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 128f);
80 PhysicsVector size = new PhysicsVector(0.5f, 0.5f, 0.5f); 80 Vector3 size = new Vector3(0.5f, 0.5f, 0.5f);
81 Quaternion rot = Quaternion.Identity; 81 Quaternion rot = Quaternion.Identity;
82 PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true); 82 PhysicsActor prim = ps.AddPrimShape("CoolShape", newcube, position, size, rot, true);
83 OdePrim oprim = (OdePrim)prim; 83 OdePrim oprim = (OdePrim)prim;
diff --git a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
index 135f49e..566b4e7 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
@@ -36,20 +36,17 @@ namespace OpenSim.Region.Physics.POSPlugin
36{ 36{
37 public class POSCharacter : PhysicsActor 37 public class POSCharacter : PhysicsActor
38 { 38 {
39 private PhysicsVector _position; 39 private Vector3 _position;
40 public PhysicsVector _velocity; 40 public Vector3 _velocity;
41 public PhysicsVector _target_velocity = PhysicsVector.Zero; 41 public Vector3 _target_velocity = Vector3.Zero;
42 public PhysicsVector _size = PhysicsVector.Zero; 42 public Vector3 _size = Vector3.Zero;
43 private PhysicsVector _acceleration; 43 private Vector3 _acceleration;
44 private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; 44 private Vector3 m_rotationalVelocity = Vector3.Zero;
45 private bool flying; 45 private bool flying;
46 private bool isColliding; 46 private bool isColliding;
47 47
48 public POSCharacter() 48 public POSCharacter()
49 { 49 {
50 _velocity = new PhysicsVector();
51 _position = new PhysicsVector();
52 _acceleration = new PhysicsVector();
53 } 50 }
54 51
55 public override int PhysicsActorType 52 public override int PhysicsActorType
@@ -58,7 +55,7 @@ namespace OpenSim.Region.Physics.POSPlugin
58 set { return; } 55 set { return; }
59 } 56 }
60 57
61 public override PhysicsVector RotationalVelocity 58 public override Vector3 RotationalVelocity
62 { 59 {
63 get { return m_rotationalVelocity; } 60 get { return m_rotationalVelocity; }
64 set { m_rotationalVelocity = value; } 61 set { m_rotationalVelocity = value; }
@@ -137,13 +134,13 @@ namespace OpenSim.Region.Physics.POSPlugin
137 get { return false; } 134 get { return false; }
138 } 135 }
139 136
140 public override PhysicsVector Position 137 public override Vector3 Position
141 { 138 {
142 get { return _position; } 139 get { return _position; }
143 set { _position = value; } 140 set { _position = value; }
144 } 141 }
145 142
146 public override PhysicsVector Size 143 public override Vector3 Size
147 { 144 {
148 get { return _size; } 145 get { return _size; }
149 set 146 set
@@ -158,9 +155,9 @@ namespace OpenSim.Region.Physics.POSPlugin
158 get { return 0f; } 155 get { return 0f; }
159 } 156 }
160 157
161 public override PhysicsVector Force 158 public override Vector3 Force
162 { 159 {
163 get { return PhysicsVector.Zero; } 160 get { return Vector3.Zero; }
164 set { return; } 161 set { return; }
165 } 162 }
166 163
@@ -175,7 +172,7 @@ namespace OpenSim.Region.Physics.POSPlugin
175 172
176 } 173 }
177 174
178 public override void VehicleVectorParam(int param, PhysicsVector value) 175 public override void VehicleVectorParam(int param, Vector3 value)
179 { 176 {
180 177
181 } 178 }
@@ -190,14 +187,14 @@ namespace OpenSim.Region.Physics.POSPlugin
190 187
191 } 188 }
192 189
193 public override PhysicsVector CenterOfMass 190 public override Vector3 CenterOfMass
194 { 191 {
195 get { return PhysicsVector.Zero; } 192 get { return Vector3.Zero; }
196 } 193 }
197 194
198 public override PhysicsVector GeometricCenter 195 public override Vector3 GeometricCenter
199 { 196 {
200 get { return PhysicsVector.Zero; } 197 get { return Vector3.Zero; }
201 } 198 }
202 199
203 public override PrimitiveBaseShape Shape 200 public override PrimitiveBaseShape Shape
@@ -205,15 +202,15 @@ namespace OpenSim.Region.Physics.POSPlugin
205 set { return; } 202 set { return; }
206 } 203 }
207 204
208 public override PhysicsVector Velocity 205 public override Vector3 Velocity
209 { 206 {
210 get { return _velocity; } 207 get { return _velocity; }
211 set { _target_velocity = value; } 208 set { _target_velocity = value; }
212 } 209 }
213 210
214 public override PhysicsVector Torque 211 public override Vector3 Torque
215 { 212 {
216 get { return PhysicsVector.Zero; } 213 get { return Vector3.Zero; }
217 set { return; } 214 set { return; }
218 } 215 }
219 216
@@ -229,7 +226,7 @@ namespace OpenSim.Region.Physics.POSPlugin
229 set { } 226 set { }
230 } 227 }
231 228
232 public override PhysicsVector Acceleration 229 public override Vector3 Acceleration
233 { 230 {
234 get { return _acceleration; } 231 get { return _acceleration; }
235 } 232 }
@@ -248,24 +245,24 @@ namespace OpenSim.Region.Physics.POSPlugin
248 { 245 {
249 } 246 }
250 247
251 public override void LockAngularMotion(PhysicsVector axis) 248 public override void LockAngularMotion(Vector3 axis)
252 { 249 {
253 } 250 }
254 251
255 public void SetAcceleration(PhysicsVector accel) 252 public void SetAcceleration(Vector3 accel)
256 { 253 {
257 _acceleration = accel; 254 _acceleration = accel;
258 } 255 }
259 256
260 public override void AddForce(PhysicsVector force, bool pushforce) 257 public override void AddForce(Vector3 force, bool pushforce)
261 { 258 {
262 } 259 }
263 260
264 public override void AddAngularForce(PhysicsVector force, bool pushforce) 261 public override void AddAngularForce(Vector3 force, bool pushforce)
265 { 262 {
266 } 263 }
267 264
268 public override void SetMomentum(PhysicsVector momentum) 265 public override void SetMomentum(Vector3 momentum)
269 { 266 {
270 } 267 }
271 268
@@ -273,7 +270,7 @@ namespace OpenSim.Region.Physics.POSPlugin
273 { 270 {
274 } 271 }
275 272
276 public override PhysicsVector PIDTarget 273 public override Vector3 PIDTarget
277 { 274 {
278 set { return; } 275 set { return; }
279 } 276 }
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
index 4521dce..847b634 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
@@ -36,19 +36,16 @@ namespace OpenSim.Region.Physics.POSPlugin
36{ 36{
37 public class POSPrim : PhysicsActor 37 public class POSPrim : PhysicsActor
38 { 38 {
39 private PhysicsVector _position; 39 private Vector3 _position;
40 private PhysicsVector _velocity; 40 private Vector3 _velocity;
41 private PhysicsVector _acceleration; 41 private Vector3 _acceleration;
42 private PhysicsVector _size; 42 private Vector3 _size;
43 private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; 43 private Vector3 m_rotationalVelocity = Vector3.Zero;
44 private Quaternion _orientation; 44 private Quaternion _orientation;
45 private bool iscolliding; 45 private bool iscolliding;
46 46
47 public POSPrim() 47 public POSPrim()
48 { 48 {
49 _velocity = new PhysicsVector();
50 _position = new PhysicsVector();
51 _acceleration = new PhysicsVector();
52 } 49 }
53 50
54 public override int PhysicsActorType 51 public override int PhysicsActorType
@@ -57,7 +54,7 @@ namespace OpenSim.Region.Physics.POSPlugin
57 set { return; } 54 set { return; }
58 } 55 }
59 56
60 public override PhysicsVector RotationalVelocity 57 public override Vector3 RotationalVelocity
61 { 58 {
62 get { return m_rotationalVelocity; } 59 get { return m_rotationalVelocity; }
63 set { m_rotationalVelocity = value; } 60 set { m_rotationalVelocity = value; }
@@ -98,13 +95,13 @@ namespace OpenSim.Region.Physics.POSPlugin
98 get { return false; } 95 get { return false; }
99 } 96 }
100 97
101 public override PhysicsVector Position 98 public override Vector3 Position
102 { 99 {
103 get { return _position; } 100 get { return _position; }
104 set { _position = value; } 101 set { _position = value; }
105 } 102 }
106 103
107 public override PhysicsVector Size 104 public override Vector3 Size
108 { 105 {
109 get { return _size; } 106 get { return _size; }
110 set { _size = value; } 107 set { _size = value; }
@@ -115,9 +112,9 @@ namespace OpenSim.Region.Physics.POSPlugin
115 get { return 0f; } 112 get { return 0f; }
116 } 113 }
117 114
118 public override PhysicsVector Force 115 public override Vector3 Force
119 { 116 {
120 get { return PhysicsVector.Zero; } 117 get { return Vector3.Zero; }
121 set { return; } 118 set { return; }
122 } 119 }
123 120
@@ -132,7 +129,7 @@ namespace OpenSim.Region.Physics.POSPlugin
132 129
133 } 130 }
134 131
135 public override void VehicleVectorParam(int param, PhysicsVector value) 132 public override void VehicleVectorParam(int param, Vector3 value)
136 { 133 {
137 134
138 } 135 }
@@ -147,14 +144,14 @@ namespace OpenSim.Region.Physics.POSPlugin
147 144
148 } 145 }
149 146
150 public override PhysicsVector CenterOfMass 147 public override Vector3 CenterOfMass
151 { 148 {
152 get { return PhysicsVector.Zero; } 149 get { return Vector3.Zero; }
153 } 150 }
154 151
155 public override PhysicsVector GeometricCenter 152 public override Vector3 GeometricCenter
156 { 153 {
157 get { return PhysicsVector.Zero; } 154 get { return Vector3.Zero; }
158 } 155 }
159 156
160 public override PrimitiveBaseShape Shape 157 public override PrimitiveBaseShape Shape
@@ -173,7 +170,7 @@ namespace OpenSim.Region.Physics.POSPlugin
173 set { return; } 170 set { return; }
174 } 171 }
175 172
176 public override PhysicsVector Velocity 173 public override Vector3 Velocity
177 { 174 {
178 get { return _velocity; } 175 get { return _velocity; }
179 set { _velocity = value; } 176 set { _velocity = value; }
@@ -191,7 +188,7 @@ namespace OpenSim.Region.Physics.POSPlugin
191 set { _orientation = value; } 188 set { _orientation = value; }
192 } 189 }
193 190
194 public override PhysicsVector Acceleration 191 public override Vector3 Acceleration
195 { 192 {
196 get { return _acceleration; } 193 get { return _acceleration; }
197 } 194 }
@@ -202,26 +199,26 @@ namespace OpenSim.Region.Physics.POSPlugin
202 set { } 199 set { }
203 } 200 }
204 201
205 public void SetAcceleration(PhysicsVector accel) 202 public void SetAcceleration(Vector3 accel)
206 { 203 {
207 _acceleration = accel; 204 _acceleration = accel;
208 } 205 }
209 206
210 public override void AddForce(PhysicsVector force, bool pushforce) 207 public override void AddForce(Vector3 force, bool pushforce)
211 { 208 {
212 } 209 }
213 210
214 public override void AddAngularForce(PhysicsVector force, bool pushforce) 211 public override void AddAngularForce(Vector3 force, bool pushforce)
215 { 212 {
216 } 213 }
217 214
218 public override PhysicsVector Torque 215 public override Vector3 Torque
219 { 216 {
220 get { return PhysicsVector.Zero; } 217 get { return Vector3.Zero; }
221 set { return; } 218 set { return; }
222 } 219 }
223 220
224 public override void SetMomentum(PhysicsVector momentum) 221 public override void SetMomentum(Vector3 momentum)
225 { 222 {
226 } 223 }
227 224
@@ -255,7 +252,7 @@ namespace OpenSim.Region.Physics.POSPlugin
255 { 252 {
256 } 253 }
257 254
258 public override void LockAngularMotion(PhysicsVector axis) 255 public override void LockAngularMotion(Vector3 axis)
259 { 256 {
260 } 257 }
261 258
@@ -268,7 +265,7 @@ namespace OpenSim.Region.Physics.POSPlugin
268 { 265 {
269 } 266 }
270 267
271 public override PhysicsVector PIDTarget 268 public override Vector3 PIDTarget
272 { 269 {
273 set { return; } 270 set { return; }
274 } 271 }
diff --git a/OpenSim/Region/Physics/POSPlugin/POSScene.cs b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
index fa8cc70..c3f5040 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSScene.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSScene.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Region.Physics.POSPlugin
56 { 56 {
57 } 57 }
58 58
59 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 59 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
60 { 60 {
61 POSCharacter act = new POSCharacter(); 61 POSCharacter act = new POSCharacter();
62 act.Position = position; 62 act.Position = position;
@@ -84,20 +84,20 @@ namespace OpenSim.Region.Physics.POSPlugin
84 } 84 }
85 85
86/* 86/*
87 public override PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) 87 public override PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
88 { 88 {
89 return null; 89 return null;
90 } 90 }
91*/ 91*/
92 92
93 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 93 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
94 PhysicsVector size, Quaternion rotation) 94 Vector3 size, Quaternion rotation)
95 { 95 {
96 return AddPrimShape(primName, pbs, position, size, rotation, false); 96 return AddPrimShape(primName, pbs, position, size, rotation, false);
97 } 97 }
98 98
99 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 99 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
100 PhysicsVector size, Quaternion rotation, bool isPhysical) 100 Vector3 size, Quaternion rotation, bool isPhysical)
101 { 101 {
102 POSPrim prim = new POSPrim(); 102 POSPrim prim = new POSPrim();
103 prim.Position = position; 103 prim.Position = position;
@@ -152,23 +152,25 @@ namespace OpenSim.Region.Physics.POSPlugin
152 character._target_velocity.Z += gravity * timeStep; 152 character._target_velocity.Z += gravity * timeStep;
153 } 153 }
154 154
155 character.Position.X += character._target_velocity.X * timeStep; 155 Vector3 characterPosition = character.Position;
156 character.Position.Y += character._target_velocity.Y * timeStep;
157 156
158 character.Position.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f); 157 characterPosition.X += character._target_velocity.X * timeStep;
159 character.Position.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f); 158 characterPosition.Y += character._target_velocity.Y * timeStep;
159
160 characterPosition.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f);
161 characterPosition.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f);
160 162
161 bool forcedZ = false; 163 bool forcedZ = false;
162 164
163 float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X]; 165 float terrainheight = _heightMap[(int)character.Position.Y * Constants.RegionSize + (int)character.Position.X];
164 if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2) 166 if (character.Position.Z + (character._target_velocity.Z * timeStep) < terrainheight + 2)
165 { 167 {
166 character.Position.Z = terrainheight + character.Size.Z; 168 characterPosition.Z = terrainheight + character.Size.Z;
167 forcedZ = true; 169 forcedZ = true;
168 } 170 }
169 else 171 else
170 { 172 {
171 character.Position.Z += character._target_velocity.Z*timeStep; 173 characterPosition.Z += character._target_velocity.Z*timeStep;
172 } 174 }
173 175
174 /// this is it -- the magic you've all been waiting for! Ladies and gentlemen -- 176 /// this is it -- the magic you've all been waiting for! Ladies and gentlemen --
@@ -177,29 +179,29 @@ namespace OpenSim.Region.Physics.POSPlugin
177 179
178 if (isCollidingWithPrim(character)) 180 if (isCollidingWithPrim(character))
179 { 181 {
180 character.Position.Z = oldposZ; // first try Z axis 182 characterPosition.Z = oldposZ; // first try Z axis
181 if (isCollidingWithPrim(character)) 183 if (isCollidingWithPrim(character))
182 { 184 {
183 character.Position.Z = oldposZ + character.Size.Z / 4.4f; // try harder 185 characterPosition.Z = oldposZ + character.Size.Z / 4.4f; // try harder
184 if (isCollidingWithPrim(character)) 186 if (isCollidingWithPrim(character))
185 { 187 {
186 character.Position.Z = oldposZ + character.Size.Z / 2.2f; // try very hard 188 characterPosition.Z = oldposZ + character.Size.Z / 2.2f; // try very hard
187 if (isCollidingWithPrim(character)) 189 if (isCollidingWithPrim(character))
188 { 190 {
189 character.Position.X = oldposX; 191 characterPosition.X = oldposX;
190 character.Position.Y = oldposY; 192 characterPosition.Y = oldposY;
191 character.Position.Z = oldposZ; 193 characterPosition.Z = oldposZ;
192 194
193 character.Position.X += character._target_velocity.X * timeStep; 195 characterPosition.X += character._target_velocity.X * timeStep;
194 if (isCollidingWithPrim(character)) 196 if (isCollidingWithPrim(character))
195 { 197 {
196 character.Position.X = oldposX; 198 characterPosition.X = oldposX;
197 } 199 }
198 200
199 character.Position.Y += character._target_velocity.Y * timeStep; 201 characterPosition.Y += character._target_velocity.Y * timeStep;
200 if (isCollidingWithPrim(character)) 202 if (isCollidingWithPrim(character))
201 { 203 {
202 character.Position.Y = oldposY; 204 characterPosition.Y = oldposY;
203 } 205 }
204 } 206 }
205 else 207 else
@@ -218,8 +220,10 @@ namespace OpenSim.Region.Physics.POSPlugin
218 } 220 }
219 } 221 }
220 222
221 character.Position.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f); 223 characterPosition.X = Util.Clamp(character.Position.X, 0.01f, Constants.RegionSize - 0.01f);
222 character.Position.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f); 224 characterPosition.Y = Util.Clamp(character.Position.Y, 0.01f, Constants.RegionSize - 0.01f);
225
226 character.Position = characterPosition;
223 227
224 character._velocity.X = (character.Position.X - oldposX)/timeStep; 228 character._velocity.X = (character.Position.X - oldposX)/timeStep;
225 character._velocity.Y = (character.Position.Y - oldposY)/timeStep; 229 character._velocity.Y = (character.Position.Y - oldposY)/timeStep;
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index b3bf70b..24eb6b1 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -34,6 +34,7 @@ using PhysXWrapper;
34using Quaternion=OpenMetaverse.Quaternion; 34using Quaternion=OpenMetaverse.Quaternion;
35using System.Reflection; 35using System.Reflection;
36using log4net; 36using log4net;
37using OpenMetaverse;
37 38
38namespace OpenSim.Region.Physics.PhysXPlugin 39namespace OpenSim.Region.Physics.PhysXPlugin
39{ 40{
@@ -106,7 +107,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
106 107
107 } 108 }
108 109
109 public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size, bool isFlying) 110 public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying)
110 { 111 {
111 Vec3 pos = new Vec3(); 112 Vec3 pos = new Vec3();
112 pos.X = position.X; 113 pos.X = position.X;
@@ -127,7 +128,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
127 { 128 {
128 } 129 }
129 130
130 private PhysicsActor AddPrim(PhysicsVector position, PhysicsVector size, Quaternion rotation) 131 private PhysicsActor AddPrim(Vector3 position, Vector3 size, Quaternion rotation)
131 { 132 {
132 Vec3 pos = new Vec3(); 133 Vec3 pos = new Vec3();
133 pos.X = position.X; 134 pos.X = position.X;
@@ -142,14 +143,14 @@ namespace OpenSim.Region.Physics.PhysXPlugin
142 return act; 143 return act;
143 } 144 }
144 145
145 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 146 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
146 PhysicsVector size, Quaternion rotation) //To be removed 147 Vector3 size, Quaternion rotation) //To be removed
147 { 148 {
148 return AddPrimShape(primName, pbs, position, size, rotation, false); 149 return AddPrimShape(primName, pbs, position, size, rotation, false);
149 } 150 }
150 151
151 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, PhysicsVector position, 152 public override PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
152 PhysicsVector size, Quaternion rotation, bool isPhysical) 153 Vector3 size, Quaternion rotation, bool isPhysical)
153 { 154 {
154 return AddPrim(position, size, rotation); 155 return AddPrim(position, size, rotation);
155 } 156 }
@@ -219,10 +220,10 @@ namespace OpenSim.Region.Physics.PhysXPlugin
219 220
220 public class PhysXCharacter : PhysicsActor 221 public class PhysXCharacter : PhysicsActor
221 { 222 {
222 private PhysicsVector _position; 223 private Vector3 _position;
223 private PhysicsVector _velocity; 224 private Vector3 _velocity;
224 private PhysicsVector m_rotationalVelocity = PhysicsVector.Zero; 225 private Vector3 m_rotationalVelocity = Vector3.Zero;
225 private PhysicsVector _acceleration; 226 private Vector3 _acceleration;
226 private NxCharacter _character; 227 private NxCharacter _character;
227 private bool flying; 228 private bool flying;
228 private bool iscolliding = false; 229 private bool iscolliding = false;
@@ -230,9 +231,6 @@ namespace OpenSim.Region.Physics.PhysXPlugin
230 231
231 public PhysXCharacter(NxCharacter character) 232 public PhysXCharacter(NxCharacter character)
232 { 233 {
233 _velocity = new PhysicsVector();
234 _position = new PhysicsVector();
235 _acceleration = new PhysicsVector();
236 _character = character; 234 _character = character;
237 } 235 }
238 236
@@ -310,7 +308,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
310 set { return; } 308 set { return; }
311 } 309 }
312 310
313 public override PhysicsVector RotationalVelocity 311 public override Vector3 RotationalVelocity
314 { 312 {
315 get { return m_rotationalVelocity; } 313 get { return m_rotationalVelocity; }
316 set { m_rotationalVelocity = value; } 314 set { m_rotationalVelocity = value; }
@@ -321,7 +319,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
321 get { return false; } 319 get { return false; }
322 } 320 }
323 321
324 public override PhysicsVector Position 322 public override Vector3 Position
325 { 323 {
326 get { return _position; } 324 get { return _position; }
327 set 325 set
@@ -335,9 +333,9 @@ namespace OpenSim.Region.Physics.PhysXPlugin
335 } 333 }
336 } 334 }
337 335
338 public override PhysicsVector Size 336 public override Vector3 Size
339 { 337 {
340 get { return PhysicsVector.Zero; } 338 get { return Vector3.Zero; }
341 set { } 339 set { }
342 } 340 }
343 341
@@ -346,9 +344,9 @@ namespace OpenSim.Region.Physics.PhysXPlugin
346 get { return 0f; } 344 get { return 0f; }
347 } 345 }
348 346
349 public override PhysicsVector Force 347 public override Vector3 Force
350 { 348 {
351 get { return PhysicsVector.Zero; } 349 get { return Vector3.Zero; }
352 set { return; } 350 set { return; }
353 } 351 }
354 352
@@ -363,7 +361,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
363 361
364 } 362 }
365 363
366 public override void VehicleVectorParam(int param, PhysicsVector value) 364 public override void VehicleVectorParam(int param, Vector3 value)
367 { 365 {
368 366
369 } 367 }
@@ -379,17 +377,17 @@ namespace OpenSim.Region.Physics.PhysXPlugin
379 } 377 }
380 378
381 379
382 public override PhysicsVector CenterOfMass 380 public override Vector3 CenterOfMass
383 { 381 {
384 get { return PhysicsVector.Zero; } 382 get { return Vector3.Zero; }
385 } 383 }
386 384
387 public override PhysicsVector GeometricCenter 385 public override Vector3 GeometricCenter
388 { 386 {
389 get { return PhysicsVector.Zero; } 387 get { return Vector3.Zero; }
390 } 388 }
391 389
392 public override PhysicsVector Velocity 390 public override Vector3 Velocity
393 { 391 {
394 get { return _velocity; } 392 get { return _velocity; }
395 set { _velocity = value; } 393 set { _velocity = value; }
@@ -413,25 +411,25 @@ namespace OpenSim.Region.Physics.PhysXPlugin
413 set { } 411 set { }
414 } 412 }
415 413
416 public override PhysicsVector Acceleration 414 public override Vector3 Acceleration
417 { 415 {
418 get { return _acceleration; } 416 get { return _acceleration; }
419 } 417 }
420 418
421 public void SetAcceleration(PhysicsVector accel) 419 public void SetAcceleration(Vector3 accel)
422 { 420 {
423 _acceleration = accel; 421 _acceleration = accel;
424 } 422 }
425 423
426 public override void AddForce(PhysicsVector force, bool pushforce) 424 public override void AddForce(Vector3 force, bool pushforce)
427 { 425 {
428 } 426 }
429 public override PhysicsVector Torque 427 public override Vector3 Torque
430 { 428 {
431 get { return PhysicsVector.Zero; } 429 get { return Vector3.Zero; }
432 set { return; } 430 set { return; }
433 } 431 }
434 public override void AddAngularForce(PhysicsVector force, bool pushforce) 432 public override void AddAngularForce(Vector3 force, bool pushforce)
435 { 433 {
436 } 434 }
437 435
@@ -445,12 +443,12 @@ namespace OpenSim.Region.Physics.PhysXPlugin
445 443
446 } 444 }
447 445
448 public override void LockAngularMotion(PhysicsVector axis) 446 public override void LockAngularMotion(Vector3 axis)
449 { 447 {
450 448
451 } 449 }
452 450
453 public override void SetMomentum(PhysicsVector momentum) 451 public override void SetMomentum(Vector3 momentum)
454 { 452 {
455 } 453 }
456 454
@@ -492,7 +490,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
492 490
493 } 491 }
494 492
495 public override PhysicsVector PIDTarget { set { return; } } 493 public override Vector3 PIDTarget { set { return; } }
496 public override bool PIDActive { set { return; } } 494 public override bool PIDActive { set { return; } }
497 public override float PIDTau { set { return; } } 495 public override float PIDTau { set { return; } }
498 496
@@ -540,15 +538,15 @@ namespace OpenSim.Region.Physics.PhysXPlugin
540 538
541 public class PhysXPrim : PhysicsActor 539 public class PhysXPrim : PhysicsActor
542 { 540 {
543 private PhysicsVector _velocity; 541 private Vector3 _velocity;
544 private PhysicsVector _acceleration; 542 private Vector3 _acceleration;
545 private PhysicsVector m_rotationalVelocity; 543 private Vector3 m_rotationalVelocity;
546 private NxActor _prim; 544 private NxActor _prim;
547 545
548 public PhysXPrim(NxActor prim) 546 public PhysXPrim(NxActor prim)
549 { 547 {
550 _velocity = new PhysicsVector(); 548 _velocity = Vector3.Zero;
551 _acceleration = new PhysicsVector(); 549 _acceleration = Vector3.Zero;
552 _prim = prim; 550 _prim = prim;
553 } 551 }
554 552
@@ -602,7 +600,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
602 set { return; } 600 set { return; }
603 } 601 }
604 602
605 public override PhysicsVector RotationalVelocity 603 public override Vector3 RotationalVelocity
606 { 604 {
607 get { return m_rotationalVelocity; } 605 get { return m_rotationalVelocity; }
608 set { m_rotationalVelocity = value; } 606 set { m_rotationalVelocity = value; }
@@ -638,11 +636,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin
638 get { return false; } 636 get { return false; }
639 } 637 }
640 638
641 public override PhysicsVector Position 639 public override Vector3 Position
642 { 640 {
643 get 641 get
644 { 642 {
645 PhysicsVector pos = new PhysicsVector(); 643 Vector3 pos = Vector3.Zero;
646 Vec3 vec = _prim.Position; 644 Vec3 vec = _prim.Position;
647 pos.X = vec.X; 645 pos.X = vec.X;
648 pos.Y = vec.Y; 646 pos.Y = vec.Y;
@@ -651,7 +649,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
651 } 649 }
652 set 650 set
653 { 651 {
654 PhysicsVector vec = value; 652 Vector3 vec = value;
655 Vec3 pos = new Vec3(); 653 Vec3 pos = new Vec3();
656 pos.X = vec.X; 654 pos.X = vec.X;
657 pos.Y = vec.Y; 655 pos.Y = vec.Y;
@@ -665,15 +663,15 @@ namespace OpenSim.Region.Physics.PhysXPlugin
665 set { return; } 663 set { return; }
666 } 664 }
667 665
668 public override PhysicsVector Velocity 666 public override Vector3 Velocity
669 { 667 {
670 get { return _velocity; } 668 get { return _velocity; }
671 set { _velocity = value; } 669 set { _velocity = value; }
672 } 670 }
673 671
674 public override PhysicsVector Torque 672 public override Vector3 Torque
675 { 673 {
676 get { return PhysicsVector.Zero; } 674 get { return Vector3.Zero; }
677 set { return; } 675 set { return; }
678 } 676 }
679 677
@@ -704,31 +702,31 @@ namespace OpenSim.Region.Physics.PhysXPlugin
704 set { } 702 set { }
705 } 703 }
706 704
707 public override PhysicsVector Acceleration 705 public override Vector3 Acceleration
708 { 706 {
709 get { return _acceleration; } 707 get { return _acceleration; }
710 } 708 }
711 709
712 public void SetAcceleration(PhysicsVector accel) 710 public void SetAcceleration(Vector3 accel)
713 { 711 {
714 _acceleration = accel; 712 _acceleration = accel;
715 } 713 }
716 714
717 public override void AddForce(PhysicsVector force, bool pushforce) 715 public override void AddForce(Vector3 force, bool pushforce)
718 { 716 {
719 } 717 }
720 718
721 public override void AddAngularForce(PhysicsVector force, bool pushforce) 719 public override void AddAngularForce(Vector3 force, bool pushforce)
722 { 720 {
723 } 721 }
724 722
725 public override void SetMomentum(PhysicsVector momentum) 723 public override void SetMomentum(Vector3 momentum)
726 { 724 {
727 } 725 }
728 726
729 public override PhysicsVector Size 727 public override Vector3 Size
730 { 728 {
731 get { return PhysicsVector.Zero; } 729 get { return Vector3.Zero; }
732 set { } 730 set { }
733 } 731 }
734 732
@@ -740,7 +738,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
740 { 738 {
741 } 739 }
742 740
743 public override void LockAngularMotion(PhysicsVector axis) 741 public override void LockAngularMotion(Vector3 axis)
744 { 742 {
745 743
746 } 744 }
@@ -750,9 +748,9 @@ namespace OpenSim.Region.Physics.PhysXPlugin
750 get { return 0f; } 748 get { return 0f; }
751 } 749 }
752 750
753 public override PhysicsVector Force 751 public override Vector3 Force
754 { 752 {
755 get { return PhysicsVector.Zero; } 753 get { return Vector3.Zero; }
756 set { return; } 754 set { return; }
757 } 755 }
758 756
@@ -767,7 +765,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
767 765
768 } 766 }
769 767
770 public override void VehicleVectorParam(int param, PhysicsVector value) 768 public override void VehicleVectorParam(int param, Vector3 value)
771 { 769 {
772 770
773 } 771 }
@@ -782,21 +780,21 @@ namespace OpenSim.Region.Physics.PhysXPlugin
782 780
783 } 781 }
784 782
785 public override PhysicsVector CenterOfMass 783 public override Vector3 CenterOfMass
786 { 784 {
787 get { return PhysicsVector.Zero; } 785 get { return Vector3.Zero; }
788 } 786 }
789 787
790 public override PhysicsVector GeometricCenter 788 public override Vector3 GeometricCenter
791 { 789 {
792 get { return PhysicsVector.Zero; } 790 get { return Vector3.Zero; }
793 } 791 }
794 792
795 public override void CrossingFailure() 793 public override void CrossingFailure()
796 { 794 {
797 } 795 }
798 796
799 public override PhysicsVector PIDTarget { set { return; } } 797 public override Vector3 PIDTarget { set { return; } }
800 public override bool PIDActive { set { return; } } 798 public override bool PIDActive { set { return; } }
801 public override float PIDTau { set { return; } } 799 public override float PIDTau { set { return; } }
802 800
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs
deleted file mode 100644
index 7116512..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs
+++ /dev/null
@@ -1,234 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Security;
33using System.Security.Policy;
34using System.Security.Permissions;
35using OpenSim.Region.ScriptEngine.Interfaces;
36using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
37using log4net;
38
39namespace OpenSim.Region.ScriptEngine.DotNetEngine
40{
41 public class AppDomainManager
42 {
43 //
44 // This class does AppDomain handling and loading/unloading of
45 // scripts in it. It is instanced in "ScriptEngine" and controlled
46 // from "ScriptManager"
47 //
48 // 1. Create a new AppDomain if old one is full (or doesn't exist)
49 // 2. Load scripts into AppDomain
50 // 3. Unload scripts from AppDomain (stopping them and marking
51 // them as inactive)
52 // 4. Unload AppDomain completely when all scripts in it has stopped
53 //
54
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 private int maxScriptsPerAppDomain = 1;
58
59 // Internal list of all AppDomains
60 private List<AppDomainStructure> appDomains =
61 new List<AppDomainStructure>();
62
63 // Structure to keep track of data around AppDomain
64 private class AppDomainStructure
65 {
66 // The AppDomain itself
67 public AppDomain CurrentAppDomain;
68
69 // Number of scripts loaded into AppDomain
70 public int ScriptsLoaded;
71
72 // Number of dead scripts
73 public int ScriptsWaitingUnload;
74 }
75
76 // Current AppDomain
77 private AppDomainStructure currentAD;
78
79 private object getLock = new object(); // Mutex
80 private object freeLock = new object(); // Mutex
81
82 private ScriptEngine m_scriptEngine;
83 //public AppDomainManager(ScriptEngine scriptEngine)
84 public AppDomainManager(ScriptEngine scriptEngine)
85 {
86 m_scriptEngine = scriptEngine;
87 ReadConfig();
88 }
89
90 public void ReadConfig()
91 {
92 maxScriptsPerAppDomain = m_scriptEngine.ScriptConfigSource.GetInt(
93 "ScriptsPerAppDomain", 1);
94 }
95
96 // Find a free AppDomain, creating one if necessary
97 private AppDomainStructure GetFreeAppDomain()
98 {
99 lock (getLock)
100 {
101 // Current full?
102 if (currentAD != null &&
103 currentAD.ScriptsLoaded >= maxScriptsPerAppDomain)
104 {
105 // Add it to AppDomains list and empty current
106 appDomains.Add(currentAD);
107 currentAD = null;
108 }
109 // No current
110 if (currentAD == null)
111 {
112 // Create a new current AppDomain
113 currentAD = new AppDomainStructure();
114 currentAD.CurrentAppDomain = PrepareNewAppDomain();
115 }
116
117 return currentAD;
118 }
119 }
120
121 private int AppDomainNameCount;
122
123 // Create and prepare a new AppDomain for scripts
124 private AppDomain PrepareNewAppDomain()
125 {
126 // Create and prepare a new AppDomain
127 AppDomainNameCount++;
128
129 // TODO: Currently security match current appdomain
130
131 // Construct and initialize settings for a second AppDomain.
132 AppDomainSetup ads = new AppDomainSetup();
133 ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
134 ads.DisallowBindingRedirects = true;
135 ads.DisallowCodeDownload = true;
136 ads.LoaderOptimization = LoaderOptimization.MultiDomainHost;
137 ads.ShadowCopyFiles = "false"; // Disable shadowing
138 ads.ConfigurationFile =
139 AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
140
141 AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" +
142 AppDomainNameCount, null, ads);
143
144 m_log.Info("[" + m_scriptEngine.ScriptEngineName +
145 "]: AppDomain Loading: " +
146 AssemblyName.GetAssemblyName(
147 "OpenSim.Region.ScriptEngine.Shared.dll").ToString());
148 AD.Load(AssemblyName.GetAssemblyName(
149 "OpenSim.Region.ScriptEngine.Shared.dll"));
150
151 // Return the new AppDomain
152 return AD;
153 }
154
155 // Unload appdomains that are full and have only dead scripts
156 private void UnloadAppDomains()
157 {
158 lock (freeLock)
159 {
160 // Go through all
161 foreach (AppDomainStructure ads in new ArrayList(appDomains))
162 {
163 // Don't process current AppDomain
164 if (ads.CurrentAppDomain != currentAD.CurrentAppDomain)
165 {
166 // Not current AppDomain
167 // Is number of unloaded bigger or equal to number of loaded?
168 if (ads.ScriptsLoaded <= ads.ScriptsWaitingUnload)
169 {
170 // Remove from internal list
171 appDomains.Remove(ads);
172
173 // Unload
174 AppDomain.Unload(ads.CurrentAppDomain);
175 }
176 }
177 }
178 }
179 }
180
181 public IScript LoadScript(string FileName, out AppDomain ad)
182 {
183 // Find next available AppDomain to put it in
184 AppDomainStructure FreeAppDomain = GetFreeAppDomain();
185
186 IScript mbrt = (IScript)
187 FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(
188 FileName, "SecondLife.Script");
189
190 FreeAppDomain.ScriptsLoaded++;
191 ad = FreeAppDomain.CurrentAppDomain;
192
193 return mbrt;
194 }
195
196
197 // Increase "dead script" counter for an AppDomain
198 public void StopScript(AppDomain ad)
199 {
200 lock (freeLock)
201 {
202 // Check if it is current AppDomain
203 if (currentAD.CurrentAppDomain == ad)
204 {
205 // Yes - increase
206 currentAD.ScriptsWaitingUnload++;
207 return;
208 }
209
210 // Lopp through all AppDomains
211 foreach (AppDomainStructure ads in new ArrayList(appDomains))
212 {
213 if (ads.CurrentAppDomain == ad)
214 {
215 // Found it
216 ads.ScriptsWaitingUnload++;
217 break;
218 }
219 }
220 }
221
222 UnloadAppDomains(); // Outsite lock, has its own GetLock
223 }
224
225 // If set to true then threads and stuff should try
226 // to make a graceful exit
227 public bool PleaseShutdown
228 {
229 get { return _PleaseShutdown; }
230 set { _PleaseShutdown = value; }
231 }
232 private bool _PleaseShutdown = false;
233 }
234}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs
deleted file mode 100644
index 1cd60e3..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using log4net;
30
31namespace OpenSim.Region.ScriptEngine.DotNetEngine
32{
33 public static class Common
34 {
35 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
36
37 public static ScriptEngine mySE;
38
39 // This class just contains some static log stuff used for debugging.
40
41 public static void SendToDebug(string message)
42 {
43 m_log.Info("[" + mySE.ScriptEngineName + "]: Debug: " + message);
44 }
45
46 public static void SendToLog(string message)
47 {
48 m_log.Info("[" + mySE.ScriptEngineName + "]: LOG: " + message);
49 }
50 }
51}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
deleted file mode 100644
index 4e13fb3..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
+++ /dev/null
@@ -1,544 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Region.CoreModules;
34using OpenSim.Region;
35using OpenSim.Region.Framework.Scenes;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.ScriptEngine.Shared;
38using log4net;
39
40namespace OpenSim.Region.ScriptEngine.DotNetEngine
41{
42 /// <summary>
43 /// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it.
44 /// </summary>
45 [Serializable]
46 public class EventManager
47 {
48 //
49 // Class is instanced in "ScriptEngine" and Uses "EventQueueManager"
50 // that is also instanced in "ScriptEngine".
51 // This class needs a bit of explaining:
52 //
53 // This class it the link between an event inside OpenSim and
54 // the corresponding event in a user script being executed.
55 //
56 // For example when an user touches an object then the
57 // "myScriptEngine.World.EventManager.OnObjectGrab" event is fired
58 // inside OpenSim.
59 // We hook up to this event and queue a touch_start in
60 // EventQueueManager with the proper LSL parameters.
61 // It will then be delivered to the script by EventQueueManager.
62 //
63 // You can check debug C# dump of an LSL script if you need to
64 // verify what exact parameters are needed.
65 //
66
67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
68
69 private ScriptEngine myScriptEngine;
70
71 public EventManager(ScriptEngine _ScriptEngine, bool performHookUp)
72 {
73 myScriptEngine = _ScriptEngine;
74 ReadConfig();
75
76 if (performHookUp)
77 {
78 myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
79 }
80 }
81
82 public void HookUpEvents()
83 {
84 m_log.Info("[" + myScriptEngine.ScriptEngineName +
85 "]: Hooking up to server events");
86
87 myScriptEngine.World.EventManager.OnObjectGrab +=
88 touch_start;
89 myScriptEngine.World.EventManager.OnObjectDeGrab +=
90 touch_end;
91 myScriptEngine.World.EventManager.OnRemoveScript +=
92 OnRemoveScript;
93 myScriptEngine.World.EventManager.OnScriptChangedEvent +=
94 changed;
95 myScriptEngine.World.EventManager.OnScriptAtTargetEvent +=
96 at_target;
97 myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent +=
98 not_at_target;
99 myScriptEngine.World.EventManager.OnScriptControlEvent +=
100 control;
101 myScriptEngine.World.EventManager.OnScriptColliderStart +=
102 collision_start;
103 myScriptEngine.World.EventManager.OnScriptColliding +=
104 collision;
105 myScriptEngine.World.EventManager.OnScriptCollidingEnd +=
106 collision_end;
107
108 IMoneyModule money =
109 myScriptEngine.World.RequestModuleInterface<IMoneyModule>();
110 if (money != null)
111 money.OnObjectPaid+=HandleObjectPaid;
112 }
113
114 public void ReadConfig()
115 {
116 }
117
118 private void HandleObjectPaid(UUID objectID, UUID agentID, int amount)
119 {
120 SceneObjectPart part =
121 myScriptEngine.World.GetSceneObjectPart(objectID);
122
123 if (part != null)
124 {
125 money(part.LocalId, agentID, amount);
126 }
127 }
128
129 public void changed(uint localID, uint change)
130 {
131 // Add to queue for all scripts in localID, Object pass change.
132 myScriptEngine.PostObjectEvent(localID, new EventParams(
133 "changed",new object[] { new LSL_Types.LSLInteger(change) },
134 new DetectParams[0]));
135 }
136
137 public void state_entry(uint localID)
138 {
139 // Add to queue for all scripts in ObjectID object
140 myScriptEngine.PostObjectEvent(localID, new EventParams(
141 "state_entry",new object[] { },
142 new DetectParams[0]));
143 }
144
145 public void touch_start(uint localID, uint originalID,
146 Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
147 {
148 // Add to queue for all scripts in ObjectID object
149 DetectParams[] det = new DetectParams[1];
150 det[0] = new DetectParams();
151 det[0].Key = remoteClient.AgentId;
152 det[0].Populate(myScriptEngine.World);
153
154 if (originalID == 0)
155 {
156 SceneObjectPart part =
157 myScriptEngine.World.GetSceneObjectPart(localID);
158
159 if (part == null)
160 return;
161
162 det[0].LinkNum = part.LinkNum;
163 }
164 else
165 {
166 SceneObjectPart originalPart =
167 myScriptEngine.World.GetSceneObjectPart(originalID);
168 det[0].LinkNum = originalPart.LinkNum;
169 }
170 if (surfaceArgs != null)
171 {
172 det[0].SurfaceTouchArgs = surfaceArgs;
173 }
174
175 myScriptEngine.PostObjectEvent(localID, new EventParams(
176 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
177 det));
178 }
179
180 public void touch(uint localID, uint originalID, Vector3 offsetPos,
181 IClientAPI remoteClient)
182 {
183 // Add to queue for all scripts in ObjectID object
184 DetectParams[] det = new DetectParams[1];
185 det[0] = new DetectParams();
186 det[0].Key = remoteClient.AgentId;
187 det[0].Populate(myScriptEngine.World);
188 det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X,
189 offsetPos.Y,
190 offsetPos.Z);
191
192 if (originalID == 0)
193 {
194 SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID);
195 if (part == null)
196 return;
197
198 det[0].LinkNum = part.LinkNum;
199 }
200 else
201 {
202 SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
203 det[0].LinkNum = originalPart.LinkNum;
204 }
205
206 myScriptEngine.PostObjectEvent(localID, new EventParams(
207 "touch", new Object[] { new LSL_Types.LSLInteger(1) },
208 det));
209 }
210
211 public void touch_end(uint localID, uint originalID, IClientAPI remoteClient,
212 SurfaceTouchEventArgs surfaceArgs)
213 {
214 // Add to queue for all scripts in ObjectID object
215 DetectParams[] det = new DetectParams[1];
216 det[0] = new DetectParams();
217 det[0].Key = remoteClient.AgentId;
218 det[0].Populate(myScriptEngine.World);
219
220 if (originalID == 0)
221 {
222 SceneObjectPart part =
223 myScriptEngine.World.GetSceneObjectPart(localID);
224 if (part == null)
225 return;
226
227 det[0].LinkNum = part.LinkNum;
228 }
229 else
230 {
231 SceneObjectPart originalPart =
232 myScriptEngine.World.GetSceneObjectPart(originalID);
233 det[0].LinkNum = originalPart.LinkNum;
234 }
235
236 if (surfaceArgs != null)
237 {
238 det[0].SurfaceTouchArgs = surfaceArgs;
239 }
240
241 myScriptEngine.PostObjectEvent(localID, new EventParams(
242 "touch_end", new Object[] { new LSL_Types.LSLInteger(1) },
243 det));
244 }
245
246 public void OnRezScript(uint localID, UUID itemID, string script,
247 int startParam, bool postOnRez, string engine, int stateSource)
248 {
249 if (script.StartsWith("//MRM:"))
250 return;
251
252 List<IScriptModule> engines =
253 new List<IScriptModule>(
254 myScriptEngine.World.RequestModuleInterfaces<IScriptModule>());
255
256 List<string> names = new List<string>();
257 foreach (IScriptModule m in engines)
258 names.Add(m.ScriptEngineName);
259
260 int lineEnd = script.IndexOf('\n');
261
262 if (lineEnd > 1)
263 {
264 string firstline = script.Substring(0, lineEnd).Trim();
265
266 int colon = firstline.IndexOf(':');
267 if (firstline.Length > 2 &&
268 firstline.Substring(0, 2) == "//" && colon != -1)
269 {
270 string engineName = firstline.Substring(2, colon-2);
271
272 if (names.Contains(engineName))
273 {
274 engine = engineName;
275 script = "//" + script.Substring(script.IndexOf(':')+1);
276 }
277 else
278 {
279 if (engine == myScriptEngine.ScriptEngineName)
280 {
281 SceneObjectPart part =
282 myScriptEngine.World.GetSceneObjectPart(
283 localID);
284
285 TaskInventoryItem item =
286 part.Inventory.GetInventoryItem(itemID);
287
288 ScenePresence presence =
289 myScriptEngine.World.GetScenePresence(
290 item.OwnerID);
291
292 if (presence != null)
293 {
294 presence.ControllingClient.SendAgentAlertMessage(
295 "Selected engine unavailable. "+
296 "Running script on "+
297 myScriptEngine.ScriptEngineName,
298 false);
299 }
300 }
301 }
302 }
303 }
304
305 if (engine != myScriptEngine.ScriptEngineName)
306 return;
307
308 // m_log.Debug("OnRezScript localID: " + localID +
309 // " LLUID: " + itemID.ToString() + " Size: " +
310 // script.Length);
311
312 myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script,
313 startParam, postOnRez);
314 }
315
316 public void OnRemoveScript(uint localID, UUID itemID)
317 {
318 // m_log.Debug("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
319 myScriptEngine.m_ScriptManager.StopScript(
320 localID,
321 itemID
322 );
323 }
324
325 public void money(uint localID, UUID agentID, int amount)
326 {
327 myScriptEngine.PostObjectEvent(localID, new EventParams(
328 "money", new object[] {
329 new LSL_Types.LSLString(agentID.ToString()),
330 new LSL_Types.LSLInteger(amount) },
331 new DetectParams[0]));
332 }
333
334 // TODO: Replace placeholders below
335 // NOTE! THE PARAMETERS FOR THESE FUNCTIONS ARE NOT CORRECT!
336 // These needs to be hooked up to OpenSim during init of this class
337 // then queued in EventQueueManager.
338 // When queued in EventQueueManager they need to be LSL compatible (name and params)
339
340 public void state_exit(uint localID)
341 {
342 myScriptEngine.PostObjectEvent(localID, new EventParams(
343 "state_exit", new object[] { },
344 new DetectParams[0]));
345 }
346
347 public void collision_start(uint localID, ColliderArgs col)
348 {
349 // Add to queue for all scripts in ObjectID object
350 List<DetectParams> det = new List<DetectParams>();
351
352 foreach (DetectedObject detobj in col.Colliders)
353 {
354 DetectParams d = new DetectParams();
355 d.Key =detobj.keyUUID;
356 d.Populate(myScriptEngine.World);
357 det.Add(d);
358 }
359
360 if (det.Count > 0)
361 myScriptEngine.PostObjectEvent(localID, new EventParams(
362 "collision_start",
363 new Object[] { new LSL_Types.LSLInteger(det.Count) },
364 det.ToArray()));
365 }
366
367 public void collision(uint localID, ColliderArgs col)
368 {
369 // Add to queue for all scripts in ObjectID object
370 List<DetectParams> det = new List<DetectParams>();
371
372 foreach (DetectedObject detobj in col.Colliders)
373 {
374 DetectParams d = new DetectParams();
375 d.Key =detobj.keyUUID;
376 d.Populate(myScriptEngine.World);
377 det.Add(d);
378 }
379
380 if (det.Count > 0)
381 myScriptEngine.PostObjectEvent(localID, new EventParams(
382 "collision", new Object[] { new LSL_Types.LSLInteger(det.Count) },
383 det.ToArray()));
384 }
385
386 public void collision_end(uint localID, ColliderArgs col)
387 {
388 // Add to queue for all scripts in ObjectID object
389 List<DetectParams> det = new List<DetectParams>();
390
391 foreach (DetectedObject detobj in col.Colliders)
392 {
393 DetectParams d = new DetectParams();
394 d.Key =detobj.keyUUID;
395 d.Populate(myScriptEngine.World);
396 det.Add(d);
397 }
398
399 if (det.Count > 0)
400 myScriptEngine.PostObjectEvent(localID, new EventParams(
401 "collision_end",
402 new Object[] { new LSL_Types.LSLInteger(det.Count) },
403 det.ToArray()));
404 }
405
406 public void land_collision_start(uint localID, UUID itemID)
407 {
408 myScriptEngine.PostObjectEvent(localID, new EventParams(
409 "land_collision_start",
410 new object[0],
411 new DetectParams[0]));
412 }
413
414 public void land_collision(uint localID, UUID itemID)
415 {
416 myScriptEngine.PostObjectEvent(localID, new EventParams(
417 "land_collision",
418 new object[0],
419 new DetectParams[0]));
420 }
421
422 public void land_collision_end(uint localID, UUID itemID)
423 {
424 myScriptEngine.PostObjectEvent(localID, new EventParams(
425 "land_collision_end",
426 new object[0],
427 new DetectParams[0]));
428 }
429
430 // Handled by long commands
431 public void timer(uint localID, UUID itemID)
432 {
433 }
434
435 public void listen(uint localID, UUID itemID)
436 {
437 }
438
439 public void control(uint localID, UUID itemID, UUID agentID, uint held, uint change)
440 {
441 if ((change == 0) && (myScriptEngine.m_EventQueueManager.CheckEeventQueueForEvent(localID,"control"))) return;
442 myScriptEngine.PostObjectEvent(localID, new EventParams(
443 "control",new object[] {
444 new LSL_Types.LSLString(agentID.ToString()),
445 new LSL_Types.LSLInteger(held),
446 new LSL_Types.LSLInteger(change)},
447 new DetectParams[0]));
448 }
449
450 public void email(uint localID, UUID itemID, string timeSent,
451 string address, string subject, string message, int numLeft)
452 {
453 myScriptEngine.PostObjectEvent(localID, new EventParams(
454 "email",new object[] {
455 new LSL_Types.LSLString(timeSent),
456 new LSL_Types.LSLString(address),
457 new LSL_Types.LSLString(subject),
458 new LSL_Types.LSLString(message),
459 new LSL_Types.LSLInteger(numLeft)},
460 new DetectParams[0]));
461 }
462
463 public void at_target(uint localID, uint handle, Vector3 targetpos,
464 Vector3 atpos)
465 {
466 myScriptEngine.PostObjectEvent(localID, new EventParams(
467 "at_target", new object[] {
468 new LSL_Types.LSLInteger(handle),
469 new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z),
470 new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) },
471 new DetectParams[0]));
472 }
473
474 public void not_at_target(uint localID)
475 {
476 myScriptEngine.PostObjectEvent(localID, new EventParams(
477 "not_at_target",new object[0],
478 new DetectParams[0]));
479 }
480
481 public void at_rot_target(uint localID, UUID itemID)
482 {
483 myScriptEngine.PostObjectEvent(localID, new EventParams(
484 "at_rot_target",new object[0],
485 new DetectParams[0]));
486 }
487
488 public void not_at_rot_target(uint localID, UUID itemID)
489 {
490 myScriptEngine.PostObjectEvent(localID, new EventParams(
491 "not_at_rot_target",new object[0],
492 new DetectParams[0]));
493 }
494
495 public void attach(uint localID, UUID itemID)
496 {
497 }
498
499 public void dataserver(uint localID, UUID itemID)
500 {
501 }
502
503 public void link_message(uint localID, UUID itemID)
504 {
505 }
506
507 public void moving_start(uint localID, UUID itemID)
508 {
509 myScriptEngine.PostObjectEvent(localID, new EventParams(
510 "moving_start",new object[0],
511 new DetectParams[0]));
512 }
513
514 public void moving_end(uint localID, UUID itemID)
515 {
516 myScriptEngine.PostObjectEvent(localID, new EventParams(
517 "moving_end",new object[0],
518 new DetectParams[0]));
519 }
520
521 public void object_rez(uint localID, UUID itemID)
522 {
523 }
524
525 public void remote_data(uint localID, UUID itemID)
526 {
527 }
528
529 // Handled by long commands
530 public void http_response(uint localID, UUID itemID)
531 {
532 }
533
534 /// <summary>
535 /// If set to true then threads and stuff should try to make a graceful exit
536 /// </summary>
537 public bool PleaseShutdown
538 {
539 get { return _PleaseShutdown; }
540 set { _PleaseShutdown = value; }
541 }
542 private bool _PleaseShutdown = false;
543 }
544}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
deleted file mode 100644
index 5865452..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
+++ /dev/null
@@ -1,460 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using OpenMetaverse;
33using OpenSim.Region.ScriptEngine.Shared;
34using log4net;
35
36namespace OpenSim.Region.ScriptEngine.DotNetEngine
37{
38 /// <summary>
39 /// EventQueueManager handles event queues
40 /// Events are queued and executed in separate thread
41 /// </summary>
42 [Serializable]
43 public class EventQueueManager
44 {
45 //
46 // Class is instanced in "ScriptEngine" and used by "EventManager" which is also instanced in "ScriptEngine".
47 //
48 // Class purpose is to queue and execute functions that are received by "EventManager":
49 // - allowing "EventManager" to release its event thread immediately, thus not interrupting server execution.
50 // - allowing us to prioritize and control execution of script functions.
51 // Class can use multiple threads for simultaneous execution. Mutexes are used for thread safety.
52 //
53 // 1. Hold an execution queue for scripts
54 // 2. Use threads to process queue, each thread executes one script function on each pass.
55 // 3. Catch any script error and process it
56 //
57 //
58 // Notes:
59 // * Current execution load balancing is optimized for 1 thread, and can cause unfair execute balancing between scripts.
60 // Not noticeable unless server is under high load.
61 //
62
63 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
64
65 public ScriptEngine m_ScriptEngine;
66
67 /// <summary>
68 /// List of threads (classes) processing event queue
69 /// Note that this may or may not be a reference to a static object depending on PrivateRegionThreads config setting.
70 /// </summary>
71 internal static List<EventQueueThreadClass> eventQueueThreads = new List<EventQueueThreadClass>(); // Thread pool that we work on
72 /// <summary>
73 /// Locking access to eventQueueThreads AND staticGlobalEventQueueThreads.
74 /// </summary>
75// private object eventQueueThreadsLock = new object();
76 // Static objects for referencing the objects above if we don't have private threads:
77 //internal static List<EventQueueThreadClass> staticEventQueueThreads; // A static reference used if we don't use private threads
78// internal static object staticEventQueueThreadsLock; // Statick lock object reference for same reason
79
80 /// <summary>
81 /// Global static list of all threads (classes) processing event queue -- used by max enforcment thread
82 /// </summary>
83 //private List<EventQueueThreadClass> staticGlobalEventQueueThreads = new List<EventQueueThreadClass>();
84
85 /// <summary>
86 /// Used internally to specify how many threads should exit gracefully
87 /// </summary>
88 public static int ThreadsToExit;
89 public static object ThreadsToExitLock = new object();
90
91
92 //public object queueLock = new object(); // Mutex lock object
93
94 /// <summary>
95 /// How many threads to process queue with
96 /// </summary>
97 internal static int numberOfThreads;
98
99 internal static int EventExecutionMaxQueueSize;
100
101 /// <summary>
102 /// Maximum time one function can use for execution before we perform a thread kill.
103 /// </summary>
104 private static int maxFunctionExecutionTimems
105 {
106 get { return (int)(maxFunctionExecutionTimens / 10000); }
107 set { maxFunctionExecutionTimens = value * 10000; }
108 }
109
110 /// <summary>
111 /// Contains nanoseconds version of maxFunctionExecutionTimems so that it matches time calculations better (performance reasons).
112 /// WARNING! ONLY UPDATE maxFunctionExecutionTimems, NEVER THIS DIRECTLY.
113 /// </summary>
114 public static long maxFunctionExecutionTimens;
115
116 /// <summary>
117 /// Enforce max execution time
118 /// </summary>
119 public static bool EnforceMaxExecutionTime;
120
121 /// <summary>
122 /// Kill script (unload) when it exceeds execution time
123 /// </summary>
124 private static bool KillScriptOnMaxFunctionExecutionTime;
125
126 /// <summary>
127 /// List of localID locks for mutex processing of script events
128 /// </summary>
129 private List<uint> objectLocks = new List<uint>();
130 private object tryLockLock = new object(); // Mutex lock object
131
132 /// <summary>
133 /// Queue containing events waiting to be executed
134 /// </summary>
135 public Queue<QueueItemStruct> eventQueue = new Queue<QueueItemStruct>();
136
137 #region " Queue structures "
138 /// <summary>
139 /// Queue item structure
140 /// </summary>
141 public struct QueueItemStruct
142 {
143 public uint localID;
144 public UUID itemID;
145 public string functionName;
146 public DetectParams[] llDetectParams;
147 public object[] param;
148 public Dictionary<KeyValuePair<int,int>,KeyValuePair<int,int>>
149 LineMap;
150 }
151
152 #endregion
153
154 #region " Initialization / Startup "
155 public EventQueueManager(ScriptEngine _ScriptEngine)
156 {
157 m_ScriptEngine = _ScriptEngine;
158
159 ReadConfig();
160 AdjustNumberOfScriptThreads();
161 }
162
163 public void ReadConfig()
164 {
165 // Refresh config
166 numberOfThreads = m_ScriptEngine.ScriptConfigSource.GetInt("NumberOfScriptThreads", 2);
167 maxFunctionExecutionTimems = m_ScriptEngine.ScriptConfigSource.GetInt("MaxEventExecutionTimeMs", 5000);
168 EnforceMaxExecutionTime = m_ScriptEngine.ScriptConfigSource.GetBoolean("EnforceMaxEventExecutionTime", true);
169 KillScriptOnMaxFunctionExecutionTime = m_ScriptEngine.ScriptConfigSource.GetBoolean("DeactivateScriptOnTimeout", false);
170 EventExecutionMaxQueueSize = m_ScriptEngine.ScriptConfigSource.GetInt("EventExecutionMaxQueueSize", 300);
171
172 // Now refresh config in all threads
173 lock (eventQueueThreads)
174 {
175 foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
176 {
177 EventQueueThread.ReadConfig();
178 }
179 }
180 }
181
182 #endregion
183
184 #region " Shutdown all threads "
185 ~EventQueueManager()
186 {
187 Stop();
188 }
189
190 private void Stop()
191 {
192 if (eventQueueThreads != null)
193 {
194 // Kill worker threads
195 lock (eventQueueThreads)
196 {
197 foreach (EventQueueThreadClass EventQueueThread in new ArrayList(eventQueueThreads))
198 {
199 AbortThreadClass(EventQueueThread);
200 }
201 //eventQueueThreads.Clear();
202 //staticGlobalEventQueueThreads.Clear();
203 }
204 }
205
206 // Remove all entries from our event queue
207 lock (eventQueue)
208 {
209 eventQueue.Clear();
210 }
211 }
212
213 #endregion
214
215 #region " Start / stop script execution threads (ThreadClasses) "
216 private void StartNewThreadClass()
217 {
218 EventQueueThreadClass eqtc = new EventQueueThreadClass();
219 eventQueueThreads.Add(eqtc);
220 //m_log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: Started new script execution thread. Current thread count: " + eventQueueThreads.Count);
221 }
222
223 private void AbortThreadClass(EventQueueThreadClass threadClass)
224 {
225 if (eventQueueThreads.Contains(threadClass))
226 eventQueueThreads.Remove(threadClass);
227
228 try
229 {
230 threadClass.Stop();
231 }
232 catch (Exception)
233 {
234 //m_log.Error("[" + m_ScriptEngine.ScriptEngineName + ":EventQueueManager]: If you see this, could you please report it to Tedd:");
235 //m_log.Error("[" + m_ScriptEngine.ScriptEngineName + ":EventQueueManager]: Script thread execution timeout kill ended in exception: " + ex.ToString());
236 }
237 //m_log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: Killed script execution thread. Remaining thread count: " + eventQueueThreads.Count);
238 }
239 #endregion
240
241 #region " Mutex locks for queue access "
242 /// <summary>
243 /// Try to get a mutex lock on localID
244 /// </summary>
245 /// <param name="localID"></param>
246 /// <returns></returns>
247 public bool TryLock(uint localID)
248 {
249 lock (tryLockLock)
250 {
251 if (objectLocks.Contains(localID) == true)
252 {
253 return false;
254 }
255 else
256 {
257 objectLocks.Add(localID);
258 return true;
259 }
260 }
261 }
262
263 /// <summary>
264 /// Release mutex lock on localID
265 /// </summary>
266 /// <param name="localID"></param>
267 public void ReleaseLock(uint localID)
268 {
269 lock (tryLockLock)
270 {
271 if (objectLocks.Contains(localID) == true)
272 {
273 objectLocks.Remove(localID);
274 }
275 }
276 }
277 #endregion
278
279 #region " Check execution queue for a specified Event"
280 /// <summary>
281 /// checks to see if a specified event type is already in the queue
282 /// </summary>
283 /// <param name="localID">Region object ID</param>
284 /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
285 /// <returns>true if event is found , false if not found</returns>
286 ///
287 public bool CheckEeventQueueForEvent(uint localID, string FunctionName)
288 {
289 if (eventQueue.Count > 0)
290 {
291 lock (eventQueue)
292 {
293 foreach (EventQueueManager.QueueItemStruct QIS in eventQueue)
294 {
295 if ((QIS.functionName == FunctionName) && (QIS.localID == localID))
296 return true;
297 }
298 }
299 }
300 return false;
301 }
302 #endregion
303
304 #region " Add events to execution queue "
305 /// <summary>
306 /// Add event to event execution queue
307 /// </summary>
308 /// <param name="localID">Region object ID</param>
309 /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
310 /// <param name="param">Array of parameters to match event mask</param>
311 public bool AddToObjectQueue(uint localID, string FunctionName, DetectParams[] qParams, params object[] param)
312 {
313 // Determine all scripts in Object and add to their queue
314 //myScriptEngine.log.Info("[" + ScriptEngineName + "]: EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
315
316 // Do we have any scripts in this object at all? If not, return
317 if (m_ScriptEngine.m_ScriptManager.Scripts.ContainsKey(localID) == false)
318 {
319 //m_log.Debug("Event \String.Empty + FunctionName + "\" for localID: " + localID + ". No scripts found on this localID.");
320 return false;
321 }
322
323 List<UUID> scriptKeys =
324 m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
325
326 foreach (UUID itemID in scriptKeys)
327 {
328 // Add to each script in that object
329 // TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter?
330 AddToScriptQueue(localID, itemID, FunctionName, qParams, param);
331 }
332 return true;
333 }
334
335 /// <summary>
336 /// Add event to event execution queue
337 /// </summary>
338 /// <param name="localID">Region object ID</param>
339 /// <param name="itemID">Region script ID</param>
340 /// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
341 /// <param name="param">Array of parameters to match event mask</param>
342 public bool AddToScriptQueue(uint localID, UUID itemID, string FunctionName, DetectParams[] qParams, params object[] param)
343 {
344 List<UUID> keylist = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
345
346 if (!keylist.Contains(itemID)) // We don't manage that script
347 {
348 return false;
349 }
350
351 lock (eventQueue)
352 {
353 if (eventQueue.Count >= EventExecutionMaxQueueSize)
354 {
355 m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: ERROR: Event execution queue item count is at " + eventQueue.Count + ". Config variable \"EventExecutionMaxQueueSize\" is set to " + EventExecutionMaxQueueSize + ", so ignoring new event.");
356 m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Event ignored: localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
357 return false;
358 }
359
360 InstanceData id = m_ScriptEngine.m_ScriptManager.GetScript(
361 localID, itemID);
362
363 // Create a structure and add data
364 QueueItemStruct QIS = new QueueItemStruct();
365 QIS.localID = localID;
366 QIS.itemID = itemID;
367 QIS.functionName = FunctionName;
368 QIS.llDetectParams = qParams;
369 QIS.param = param;
370 if (id != null)
371 QIS.LineMap = id.LineMap;
372
373 // Add it to queue
374 eventQueue.Enqueue(QIS);
375 }
376 return true;
377 }
378 #endregion
379
380 #region " Maintenance thread "
381
382 /// <summary>
383 /// Adjust number of script thread classes. It can start new, but if it needs to stop it will just set number of threads in "ThreadsToExit" and threads will have to exit themselves.
384 /// Called from MaintenanceThread
385 /// </summary>
386 public void AdjustNumberOfScriptThreads()
387 {
388 // Is there anything here for us to do?
389 if (eventQueueThreads.Count == numberOfThreads)
390 return;
391
392 lock (eventQueueThreads)
393 {
394 int diff = numberOfThreads - eventQueueThreads.Count;
395 // Positive number: Start
396 // Negative number: too many are running
397 if (diff > 0)
398 {
399 // We need to add more threads
400 for (int ThreadCount = eventQueueThreads.Count; ThreadCount < numberOfThreads; ThreadCount++)
401 {
402 StartNewThreadClass();
403 }
404 }
405 if (diff < 0)
406 {
407 // We need to kill some threads
408 lock (ThreadsToExitLock)
409 {
410 ThreadsToExit = Math.Abs(diff);
411 }
412 }
413 }
414 }
415
416 /// <summary>
417 /// Check if any thread class has been executing an event too long
418 /// </summary>
419 public void CheckScriptMaxExecTime()
420 {
421 // Iterate through all ScriptThreadClasses and check how long their current function has been executing
422 lock (eventQueueThreads)
423 {
424 foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
425 {
426 // Is thread currently executing anything?
427 if (EventQueueThread.InExecution)
428 {
429 // Has execution time expired?
430 if (DateTime.Now.Ticks - EventQueueThread.LastExecutionStarted >
431 maxFunctionExecutionTimens)
432 {
433 // Yes! We need to kill this thread!
434
435 // Set flag if script should be removed or not
436 EventQueueThread.KillCurrentScript = KillScriptOnMaxFunctionExecutionTime;
437
438 // Abort this thread
439 AbortThreadClass(EventQueueThread);
440
441 // We do not need to start another, MaintenenceThread will do that for us
442 //StartNewThreadClass();
443 }
444 }
445 }
446 }
447 }
448 #endregion
449
450 ///// <summary>
451 ///// If set to true then threads and stuff should try to make a graceful exit
452 ///// </summary>
453 //public bool PleaseShutdown
454 //{
455 // get { return _PleaseShutdown; }
456 // set { _PleaseShutdown = value; }
457 //}
458 //private bool _PleaseShutdown = false;
459 }
460}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
deleted file mode 100644
index 583d2ff..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
+++ /dev/null
@@ -1,428 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Text.RegularExpressions;
33using System.Threading;
34using System.Globalization;
35using OpenMetaverse;
36using log4net;
37using OpenSim.Framework;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Region.Framework.Scenes.Scripting;
40using OpenSim.Region.ScriptEngine.Shared;
41using OpenSim.Region.ScriptEngine.Shared.CodeTools;
42
43namespace OpenSim.Region.ScriptEngine.DotNetEngine
44{
45 // Because every thread needs some data set for it
46 // (time started to execute current function), it will do its work
47 // within a class
48 public class EventQueueThreadClass
49 {
50 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51
52 // How many ms to sleep if queue is empty
53 private static int nothingToDoSleepms;// = 50;
54 private static ThreadPriority MyThreadPriority;
55
56 public long LastExecutionStarted;
57 public bool InExecution = false;
58 public bool KillCurrentScript = false;
59
60 //private EventQueueManager eventQueueManager;
61 public Thread EventQueueThread;
62 private static int ThreadCount = 0;
63
64 private string ScriptEngineName = "ScriptEngine.Common";
65
66 public EventQueueThreadClass()//EventQueueManager eqm
67 {
68 CultureInfo USCulture = new CultureInfo("en-US");
69 Thread.CurrentThread.CurrentCulture = USCulture;
70
71 //eventQueueManager = eqm;
72 ReadConfig();
73 Start();
74 }
75
76 ~EventQueueThreadClass()
77 {
78 Stop();
79 }
80
81 public void ReadConfig()
82 {
83 lock (ScriptEngine.ScriptEngines)
84 {
85 foreach (ScriptEngine m_ScriptEngine in
86 ScriptEngine.ScriptEngines)
87 {
88 ScriptEngineName = m_ScriptEngine.ScriptEngineName;
89 nothingToDoSleepms =
90 m_ScriptEngine.ScriptConfigSource.GetInt(
91 "SleepTimeIfNoScriptExecutionMs", 50);
92
93 string pri = m_ScriptEngine.ScriptConfigSource.GetString(
94 "ScriptThreadPriority", "BelowNormal");
95
96 switch (pri.ToLower())
97 {
98 case "lowest":
99 MyThreadPriority = ThreadPriority.Lowest;
100 break;
101 case "belownormal":
102 MyThreadPriority = ThreadPriority.BelowNormal;
103 break;
104 case "normal":
105 MyThreadPriority = ThreadPriority.Normal;
106 break;
107 case "abovenormal":
108 MyThreadPriority = ThreadPriority.AboveNormal;
109 break;
110 case "highest":
111 MyThreadPriority = ThreadPriority.Highest;
112 break;
113 default:
114 MyThreadPriority = ThreadPriority.BelowNormal;
115 m_log.Error(
116 "[ScriptEngine.DotNetEngine]: Unknown "+
117 "priority type \"" + pri +
118 "\" in config file. Defaulting to "+
119 "\"BelowNormal\".");
120 break;
121 }
122 }
123 }
124 // Now set that priority
125 if (EventQueueThread != null)
126 if (EventQueueThread.IsAlive)
127 EventQueueThread.Priority = MyThreadPriority;
128 }
129
130 /// <summary>
131 /// Start thread
132 /// </summary>
133 private void Start()
134 {
135 EventQueueThread = new Thread(EventQueueThreadLoop);
136 EventQueueThread.IsBackground = true;
137
138 EventQueueThread.Priority = MyThreadPriority;
139 EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount;
140 EventQueueThread.Start();
141
142 // Look at this... Don't you wish everyone did that solid
143 // coding everywhere? :P
144
145 if (ThreadCount == int.MaxValue)
146 ThreadCount = 0;
147
148 ThreadCount++;
149 }
150
151 public void Stop()
152 {
153 if (EventQueueThread != null && EventQueueThread.IsAlive == true)
154 {
155 try
156 {
157 EventQueueThread.Abort(); // Send abort
158 }
159 catch (Exception)
160 {
161 }
162 }
163 }
164
165 private EventQueueManager.QueueItemStruct BlankQIS =
166 new EventQueueManager.QueueItemStruct();
167
168 private ScriptEngine lastScriptEngine;
169 private uint lastLocalID;
170 private UUID lastItemID;
171
172 // Queue processing thread loop
173 private void EventQueueThreadLoop()
174 {
175 CultureInfo USCulture = new CultureInfo("en-US");
176 Thread.CurrentThread.CurrentCulture = USCulture;
177
178 try
179 {
180 while (true)
181 {
182 try
183 {
184 while (true)
185 {
186 DoProcessQueue();
187 }
188 }
189 catch (ThreadAbortException)
190 {
191 m_log.Info("[" + ScriptEngineName +
192 "]: ThreadAbortException while executing "+
193 "function.");
194 }
195 catch (SelfDeleteException) // Must delete SOG
196 {
197 SceneObjectPart part =
198 lastScriptEngine.World.GetSceneObjectPart(
199 lastLocalID);
200 if (part != null && part.ParentGroup != null)
201 lastScriptEngine.World.DeleteSceneObject(
202 part.ParentGroup, false);
203 }
204 catch (ScriptDeleteException) // Must delete item
205 {
206 SceneObjectPart part =
207 lastScriptEngine.World.GetSceneObjectPart(
208 lastLocalID);
209 if (part != null && part.ParentGroup != null)
210 part.Inventory.RemoveInventoryItem(lastItemID);
211 }
212 catch (Exception e)
213 {
214 m_log.ErrorFormat("[{0}]: Exception {1} thrown", ScriptEngineName, e.GetType().ToString());
215 throw e;
216 }
217 }
218 }
219 catch (ThreadAbortException)
220 {
221 }
222 catch (Exception e)
223 {
224 // TODO: Let users in the sim and those entering it and possibly an external watchdog know what has happened
225 m_log.ErrorFormat(
226 "[{0}]: Event queue thread terminating with exception. PLEASE REBOOT YOUR SIM - SCRIPT EVENTS WILL NOT WORK UNTIL YOU DO. Exception is {1}",
227 ScriptEngineName, e);
228 }
229 }
230
231 public void DoProcessQueue()
232 {
233 foreach (ScriptEngine m_ScriptEngine in
234 new ArrayList(ScriptEngine.ScriptEngines))
235 {
236 lastScriptEngine = m_ScriptEngine;
237
238 EventQueueManager.QueueItemStruct QIS = BlankQIS;
239 bool GotItem = false;
240
241 //if (PleaseShutdown)
242 // return;
243
244 if (m_ScriptEngine.m_EventQueueManager == null ||
245 m_ScriptEngine.m_EventQueueManager.eventQueue == null)
246 continue;
247
248 if (m_ScriptEngine.m_EventQueueManager.eventQueue.Count == 0)
249 {
250 // Nothing to do? Sleep a bit waiting for something to do
251 Thread.Sleep(nothingToDoSleepms);
252 }
253 else
254 {
255 // Something in queue, process
256
257 // OBJECT BASED LOCK - TWO THREADS WORKING ON SAME
258 // OBJECT IS NOT GOOD
259 lock (m_ScriptEngine.m_EventQueueManager.eventQueue)
260 {
261 GotItem = false;
262 for (int qc = 0; qc < m_ScriptEngine.m_EventQueueManager.eventQueue.Count; qc++)
263 {
264 // Get queue item
265 QIS = m_ScriptEngine.m_EventQueueManager.eventQueue.Dequeue();
266
267 // Check if object is being processed by
268 // someone else
269 if (m_ScriptEngine.m_EventQueueManager.TryLock(
270 QIS.localID) == false)
271 {
272 // Object is already being processed, requeue it
273 m_ScriptEngine.m_EventQueueManager.
274 eventQueue.Enqueue(QIS);
275 }
276 else
277 {
278 // We have lock on an object and can process it
279 GotItem = true;
280 break;
281 }
282 }
283 }
284
285 if (GotItem == true)
286 {
287 // Execute function
288 try
289 {
290 // Only pipe event if land supports it.
291 if (m_ScriptEngine.World.PipeEventsForScript(
292 QIS.localID))
293 {
294 lastLocalID = QIS.localID;
295 lastItemID = QIS.itemID;
296 LastExecutionStarted = DateTime.Now.Ticks;
297 KillCurrentScript = false;
298 InExecution = true;
299 m_ScriptEngine.m_ScriptManager.ExecuteEvent(
300 QIS.localID,
301 QIS.itemID,
302 QIS.functionName,
303 QIS.llDetectParams,
304 QIS.param);
305
306 InExecution = false;
307 }
308 }
309 catch (TargetInvocationException tie)
310 {
311 Exception e = tie.InnerException;
312
313 if (e is SelfDeleteException) // Forward it
314 throw e;
315
316 InExecution = false;
317 string text = FormatException(tie, QIS.LineMap);
318
319 // DISPLAY ERROR INWORLD
320
321// if (e.InnerException != null)
322// {
323// // Send inner exception
324// string line = " (unknown line)";
325// Regex rx = new Regex(@"SecondLife\.Script\..+[\s:](?<line>\d+)\.?\r?$", RegexOptions.Compiled);
326// if (rx.Match(e.InnerException.ToString()).Success)
327// line = " (line " + rx.Match(e.InnerException.ToString()).Result("${line}") + ")";
328// text += e.InnerException.Message.ToString() + line;
329// }
330// else
331// {
332// text += "\r\n";
333// // Send normal
334// text += e.Message.ToString();
335// }
336// if (KillCurrentScript)
337// text += "\r\nScript will be deactivated!";
338
339 try
340 {
341 if (text.Length >= 1100)
342 text = text.Substring(0, 1099);
343 IScriptHost m_host =
344 m_ScriptEngine.World.GetSceneObjectPart(QIS.localID);
345 m_ScriptEngine.World.SimChat(
346 Utils.StringToBytes(text),
347 ChatTypeEnum.DebugChannel, 2147483647,
348 m_host.AbsolutePosition,
349 m_host.Name, m_host.UUID, false);
350 }
351 catch (Exception)
352 {
353 m_log.Error("[" +
354 ScriptEngineName + "]: " +
355 "Unable to send text in-world:\r\n" +
356 text);
357 }
358 finally
359 {
360 // So we are done sending message in-world
361 if (KillCurrentScript)
362 {
363 m_ScriptEngine.m_EventQueueManager.
364 m_ScriptEngine.m_ScriptManager.
365 StopScript(
366 QIS.localID, QIS.itemID);
367 }
368 }
369 }
370 catch (Exception)
371 {
372 throw;
373 }
374 finally
375 {
376 InExecution = false;
377 m_ScriptEngine.m_EventQueueManager.ReleaseLock(
378 QIS.localID);
379 }
380 }
381 }
382 }
383 }
384
385 string FormatException(Exception e, Dictionary<KeyValuePair<int,int>,
386 KeyValuePair<int,int>> LineMap)
387 {
388 if (e.InnerException == null)
389 return e.ToString();
390
391 string message = "Runtime error:\n" + e.InnerException.StackTrace;
392 string[] lines = message.Split(new char[] {'\n'});
393
394 foreach (string line in lines)
395 {
396 if (line.Contains("SecondLife.Script"))
397 {
398 int idx = line.IndexOf(':');
399 if (idx != -1)
400 {
401 string val = line.Substring(idx+1);
402 int lineNum = 0;
403 if (int.TryParse(val, out lineNum))
404 {
405 KeyValuePair<int, int> pos =
406 Compiler.FindErrorPosition(
407 lineNum, 0, LineMap);
408
409 int scriptLine = pos.Key;
410 int col = pos.Value;
411 if (scriptLine == 0)
412 scriptLine++;
413 if (col == 0)
414 col++;
415 message = string.Format("Runtime error:\n" +
416 "Line ({0}): {1}", scriptLine - 1,
417 e.InnerException.Message);
418
419 return message;
420 }
421 }
422 }
423 }
424
425 return message;
426 }
427 }
428}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
deleted file mode 100644
index 7ffdb1a..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
+++ /dev/null
@@ -1,241 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Reflection;
31using System.Threading;
32using log4net;
33using OpenSim.Framework;
34
35namespace OpenSim.Region.ScriptEngine.DotNetEngine
36{
37 /// <summary>
38 /// This class does maintenance on script engine.
39 /// </summary>
40 public class MaintenanceThread
41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
44 //public ScriptEngine m_ScriptEngine;
45 private int MaintenanceLoopms;
46 private int MaintenanceLoopTicks_ScriptLoadUnload;
47 private int MaintenanceLoopTicks_Other;
48
49
50 public MaintenanceThread()
51 {
52 //m_ScriptEngine = _ScriptEngine;
53
54 ReadConfig();
55
56 // Start maintenance thread
57 StartMaintenanceThread();
58 }
59
60 ~MaintenanceThread()
61 {
62 StopMaintenanceThread();
63 }
64
65 public void ReadConfig()
66 {
67 // Bad hack, but we need a m_ScriptEngine :)
68 lock (ScriptEngine.ScriptEngines)
69 {
70 foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
71 {
72 MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
73 MaintenanceLoopTicks_ScriptLoadUnload =
74 m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1);
75 MaintenanceLoopTicks_Other =
76 m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10);
77
78 return;
79 }
80 }
81 }
82
83 #region " Maintenance thread "
84 /// <summary>
85 /// Maintenance thread. Enforcing max execution time for example.
86 /// </summary>
87 public Thread MaintenanceThreadThread;
88
89 /// <summary>
90 /// Starts maintenance thread
91 /// </summary>
92 private void StartMaintenanceThread()
93 {
94 if (MaintenanceThreadThread == null)
95 {
96 MaintenanceThreadThread = new Thread(MaintenanceLoop);
97 MaintenanceThreadThread.Name = "ScriptMaintenanceThread";
98 MaintenanceThreadThread.IsBackground = true;
99 MaintenanceThreadThread.Start();
100 }
101 }
102
103 /// <summary>
104 /// Stops maintenance thread
105 /// </summary>
106 private void StopMaintenanceThread()
107 {
108#if DEBUG
109 //m_log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: StopMaintenanceThread() called");
110#endif
111 //PleaseShutdown = true;
112 Thread.Sleep(100);
113 try
114 {
115 if (MaintenanceThreadThread != null && MaintenanceThreadThread.IsAlive)
116 {
117 MaintenanceThreadThread.Abort();
118 }
119 }
120 catch (Exception)
121 {
122 //m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Exception stopping maintenence thread: " + ex.ToString());
123 }
124 }
125
126 // private ScriptEngine lastScriptEngine; // Keep track of what ScriptEngine instance we are at so we can give exception
127 /// <summary>
128 /// A thread should run in this loop and check all running scripts
129 /// </summary>
130 public void MaintenanceLoop()
131 {
132 //if (m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens < MaintenanceLoopms)
133 // m_log.Warn("[" + m_ScriptEngine.ScriptEngineName + "]: " +
134 // "Configuration error: MaxEventExecutionTimeMs is less than MaintenanceLoopms. The Maintenance Loop will only check scripts once per run.");
135
136 long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks;
137 long Last_ReReadConfigFilens = DateTime.Now.Ticks;
138 int MaintenanceLoopTicks_ScriptLoadUnload_Count = 0;
139 int MaintenanceLoopTicks_Other_Count = 0;
140 bool MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = false;
141 bool MaintenanceLoopTicks_Other_ResetCount = false;
142
143 while (true)
144 {
145 try
146 {
147 while (true)
148 {
149 Thread.Sleep(MaintenanceLoopms); // Sleep before next pass
150
151 // Reset counters?
152 if (MaintenanceLoopTicks_ScriptLoadUnload_ResetCount)
153 {
154 MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = false;
155 MaintenanceLoopTicks_ScriptLoadUnload_Count = 0;
156 }
157 if (MaintenanceLoopTicks_Other_ResetCount)
158 {
159 MaintenanceLoopTicks_Other_ResetCount = false;
160 MaintenanceLoopTicks_Other_Count = 0;
161 }
162
163 // Increase our counters
164 MaintenanceLoopTicks_ScriptLoadUnload_Count++;
165 MaintenanceLoopTicks_Other_Count++;
166
167
168 //lock (ScriptEngine.ScriptEngines)
169 //{
170 foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
171 {
172 // lastScriptEngine = m_ScriptEngine;
173 // Re-reading config every x seconds
174 if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
175 {
176 MaintenanceLoopTicks_Other_ResetCount = true;
177 if (m_ScriptEngine.RefreshConfigFilens > 0)
178 {
179 // Check if its time to re-read config
180 if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
181 m_ScriptEngine.RefreshConfigFilens)
182 {
183 //m_log.Debug("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens);
184 // Its time to re-read config file
185 m_ScriptEngine.ReadConfig();
186 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
187 }
188
189
190 // Adjust number of running script threads if not correct
191 if (m_ScriptEngine.m_EventQueueManager != null)
192 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
193
194 // Check if any script has exceeded its max execution time
195 if (EventQueueManager.EnforceMaxExecutionTime)
196 {
197 // We are enforcing execution time
198 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
199 EventQueueManager.maxFunctionExecutionTimens)
200 {
201 // Its time to check again
202 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
203 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
204 }
205 }
206 }
207 }
208 if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
209 {
210 MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = true;
211 // LOAD / UNLOAD SCRIPTS
212 if (m_ScriptEngine.m_ScriptManager != null)
213 m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
214 }
215 }
216 //}
217 }
218 }
219 catch(ThreadAbortException)
220 {
221 m_log.Error("Thread aborted in MaintenanceLoopThread. If this is during shutdown, please ignore");
222 }
223 catch (Exception ex)
224 {
225 m_log.ErrorFormat("Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: {0}", ex.ToString());
226 }
227 }
228 }
229 #endregion
230
231 ///// <summary>
232 ///// If set to true then threads and stuff should try to make a graceful exit
233 ///// </summary>
234 //public bool PleaseShutdown
235 //{
236 // get { return _PleaseShutdown; }
237 // set { _PleaseShutdown = value; }
238 //}
239 //private bool _PleaseShutdown = false;
240 }
241}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Properties/AssemblyInfo.cs
deleted file mode 100644
index 4c4c5e7..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.InteropServices;
30
31// General information about an assembly is controlled through the following
32// set of attributes. Change these attribute values to modify the information
33// associated with an assembly.
34
35[assembly : AssemblyTitle("OpenSim.Region.ScriptEngine.DotNetEngine")]
36[assembly : AssemblyDescription("")]
37[assembly : AssemblyConfiguration("")]
38[assembly : AssemblyCompany("http://opensimulator.org")]
39[assembly : AssemblyProduct("OpenSim.Region.ScriptEngine.DotNetEngine")]
40[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
41[assembly : AssemblyTrademark("")]
42[assembly : AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47
48[assembly : ComVisible(false)]
49
50// The following GUID is for the ID of the typelib if this project is exposed to COM
51
52[assembly : Guid("2842257e-6fde-4460-9368-4cde57fa9cc4")]
53
54// Version information for an assembly consists of the following four values:
55//
56// Major Version
57// Minor Version
58// Build Number
59// Revision
60//
61// You can specify all the values or you can default the Revision and Build Numbers
62// by using the '*' as shown below:
63
64[assembly : AssemblyVersion("0.6.5.*")]
65[assembly : AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Resources/DotNetEngine.addin.xml b/OpenSim/Region/ScriptEngine/DotNetEngine/Resources/DotNetEngine.addin.xml
deleted file mode 100644
index 78a8dca..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Resources/DotNetEngine.addin.xml
+++ /dev/null
@@ -1,13 +0,0 @@
1<Addin id="OpenSim.Region.ScriptEngine.DotNetEngine" version="0.2">
2 <Runtime>
3 <Import assembly="OpenSim.Region.ScriptEngine.DotNetEngine.dll"/>
4 </Runtime>
5
6 <Dependencies>
7 <Addin id="OpenSim" version="0.5" />
8 </Dependencies>
9
10 <Extension path = "/OpenSim/RegionModules">
11 <RegionModule id="DotNetEngine" type="OpenSim.Region.ScriptEngine.DotNetEngine.ScriptEngine" />
12 </Extension>
13</Addin>
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
deleted file mode 100644
index 9806218..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
+++ /dev/null
@@ -1,485 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenSim.Framework;
34using OpenSim.Region.CoreModules.Framework.EventQueue;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.ScriptEngine.Interfaces;
38using OpenMetaverse;
39using OpenMetaverse.StructuredData;
40using OpenSim.Region.ScriptEngine.Shared;
41using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
42
43namespace OpenSim.Region.ScriptEngine.DotNetEngine
44{
45 [Serializable]
46 public class ScriptEngine : INonSharedRegionModule, IScriptEngine, IScriptModule
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 public static List<ScriptEngine> ScriptEngines =
51 new List<ScriptEngine>();
52
53 private Scene m_Scene;
54 public Scene World
55 {
56 get { return m_Scene; }
57 }
58
59 // Handles and queues incoming events from OpenSim
60 public EventManager m_EventManager;
61
62 // Executes events, handles script threads
63 public EventQueueManager m_EventQueueManager;
64
65 // Load, unload and execute scripts
66 public ScriptManager m_ScriptManager;
67
68 // Handles loading/unloading of scripts into AppDomains
69 public AppDomainManager m_AppDomainManager;
70
71 // Thread that does different kinds of maintenance,
72 // for example refreshing config and killing scripts
73 // that has been running too long
74 public static MaintenanceThread m_MaintenanceThread;
75
76 private IConfigSource m_ConfigSource;
77 public IConfig ScriptConfigSource;
78 private bool m_enabled = false;
79
80 public IConfig Config
81 {
82 get { return ScriptConfigSource; }
83 }
84
85 public IConfigSource ConfigSource
86 {
87 get { return m_ConfigSource; }
88 }
89
90 // How many seconds between re-reading config-file.
91 // 0 = never. ScriptEngine will try to adjust to new config changes.
92 public int RefreshConfigFileSeconds {
93 get { return (int)(RefreshConfigFilens / 10000000); }
94 set { RefreshConfigFilens = value * 10000000; }
95 }
96
97 public long RefreshConfigFilens;
98
99 public string ScriptEngineName
100 {
101 get { return "ScriptEngine.DotNetEngine"; }
102 }
103
104 public IScriptModule ScriptModule
105 {
106 get { return this; }
107 }
108
109 public event ScriptRemoved OnScriptRemoved;
110 public event ObjectRemoved OnObjectRemoved;
111
112 public ScriptEngine()
113 {
114 // For logging, just need any instance, doesn't matter
115 Common.mySE = this;
116
117 lock (ScriptEngines)
118 {
119 // Keep a list of ScriptEngines for shared threads
120 // to process all instances
121 ScriptEngines.Add(this);
122 }
123 }
124
125 public void Initialise(IConfigSource config)
126 {
127 m_ConfigSource = config;
128 }
129
130 public void AddRegion(Scene Sceneworld)
131 {
132 // Make sure we have config
133 if (ConfigSource.Configs[ScriptEngineName] == null)
134 ConfigSource.AddConfig(ScriptEngineName);
135
136 ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
137
138 m_enabled = ScriptConfigSource.GetBoolean("Enabled", true);
139 if (!m_enabled)
140 return;
141
142 m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing");
143
144 m_Scene = Sceneworld;
145
146 // Create all objects we'll be using
147 m_EventQueueManager = new EventQueueManager(this);
148 m_EventManager = new EventManager(this, true);
149
150 // We need to start it
151 m_ScriptManager = new ScriptManager(this);
152 m_ScriptManager.Setup();
153 m_AppDomainManager = new AppDomainManager(this);
154 if (m_MaintenanceThread == null)
155 m_MaintenanceThread = new MaintenanceThread();
156
157 m_log.Info("[" + ScriptEngineName + "]: Reading configuration "+
158 "from config section \"" + ScriptEngineName + "\"");
159
160 ReadConfig();
161
162 m_Scene.StackModuleInterface<IScriptModule>(this);
163 }
164
165 public void RemoveRegion(Scene scene)
166 {
167 }
168
169 public void RegionLoaded(Scene scene)
170 {
171 if (!m_enabled)
172 return;
173
174 m_EventManager.HookUpEvents();
175
176 m_Scene.EventManager.OnScriptReset += OnScriptReset;
177 m_Scene.EventManager.OnGetScriptRunning += OnGetScriptRunning;
178 m_Scene.EventManager.OnStartScript += OnStartScript;
179 m_Scene.EventManager.OnStopScript += OnStopScript;
180
181 m_ScriptManager.Start();
182 }
183
184 public void Shutdown()
185 {
186 // We are shutting down
187 lock (ScriptEngines)
188 {
189 ScriptEngines.Remove(this);
190 }
191 }
192
193 public void ReadConfig()
194 {
195 RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 0);
196
197 if (m_EventQueueManager != null) m_EventQueueManager.ReadConfig();
198 if (m_EventManager != null) m_EventManager.ReadConfig();
199 if (m_ScriptManager != null) m_ScriptManager.ReadConfig();
200 if (m_AppDomainManager != null) m_AppDomainManager.ReadConfig();
201 if (m_MaintenanceThread != null) m_MaintenanceThread.ReadConfig();
202 }
203
204 #region IRegionModule
205
206 public void Close()
207 {
208 }
209
210 public Type ReplaceableInterface
211 {
212 get { return null; }
213 }
214
215 public string Name
216 {
217 get { return "Common." + ScriptEngineName; }
218 }
219
220 public bool IsSharedModule
221 {
222 get { return false; }
223 }
224
225 public bool PostObjectEvent(uint localID, EventParams p)
226 {
227 return m_EventQueueManager.AddToObjectQueue(localID, p.EventName,
228 p.DetectParams, p.Params);
229 }
230
231 public bool PostScriptEvent(UUID itemID, EventParams p)
232 {
233 uint localID = m_ScriptManager.GetLocalID(itemID);
234 return m_EventQueueManager.AddToScriptQueue(localID, itemID,
235 p.EventName, p.DetectParams, p.Params);
236 }
237
238 public bool PostScriptEvent(UUID itemID, string name, Object[] p)
239 {
240 Object[] lsl_p = new Object[p.Length];
241 for (int i = 0; i < p.Length ; i++)
242 {
243 if (p[i] is int)
244 lsl_p[i] = new LSL_Types.LSLInteger((int)p[i]);
245 else if (p[i] is string)
246 lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
247 else if (p[i] is Vector3)
248 lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z);
249 else if (p[i] is Quaternion)
250 lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
251 else if (p[i] is float)
252 lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]);
253 else
254 lsl_p[i] = p[i];
255 }
256
257 return PostScriptEvent(itemID, new EventParams(name, lsl_p, new DetectParams[0]));
258 }
259
260 public bool PostObjectEvent(UUID itemID, string name, Object[] p)
261 {
262 SceneObjectPart part = m_Scene.GetSceneObjectPart(itemID);
263 if (part == null)
264 return false;
265
266 Object[] lsl_p = new Object[p.Length];
267 for (int i = 0; i < p.Length ; i++)
268 {
269 if (p[i] is int)
270 lsl_p[i] = new LSL_Types.LSLInteger((int)p[i]);
271 else if (p[i] is string)
272 lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
273 else if (p[i] is Vector3)
274 lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z);
275 else if (p[i] is Quaternion)
276 lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
277 else if (p[i] is float)
278 lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]);
279 else
280 lsl_p[i] = p[i];
281 }
282
283 return PostObjectEvent(part.LocalId, new EventParams(name, lsl_p, new DetectParams[0]));
284 }
285
286 public DetectParams GetDetectParams(UUID itemID, int number)
287 {
288 uint localID = m_ScriptManager.GetLocalID(itemID);
289 if (localID == 0)
290 return null;
291
292 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
293
294 if (id == null)
295 return null;
296
297 DetectParams[] det = m_ScriptManager.GetDetectParams(id);
298
299 if (number < 0 || number >= det.Length)
300 return null;
301
302 return det[number];
303 }
304
305 public int GetStartParameter(UUID itemID)
306 {
307 return m_ScriptManager.GetStartParameter(itemID);
308 }
309
310 public void SetMinEventDelay(UUID itemID, double delay)
311 {
312 // TODO in DotNet, done in XEngine
313 throw new NotImplementedException();
314 }
315
316 #endregion
317
318 public void SetState(UUID itemID, string state)
319 {
320 uint localID = m_ScriptManager.GetLocalID(itemID);
321 if (localID == 0)
322 return;
323
324 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
325
326 if (id == null)
327 return;
328
329 string currentState = id.State;
330
331 if (currentState != state)
332 {
333 try
334 {
335 m_EventManager.state_exit(localID);
336
337 }
338 catch (AppDomainUnloadedException)
339 {
340 m_log.Error("[SCRIPT]: state change called when "+
341 "script was unloaded. Nothing to worry about, "+
342 "but noting the occurance");
343 }
344
345 id.State = state;
346
347 try
348 {
349 int eventFlags = m_ScriptManager.GetStateEventFlags(localID,
350 itemID);
351
352 SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
353 if (part != null)
354 part.SetScriptEvents(itemID, eventFlags);
355
356 m_EventManager.state_entry(localID);
357 }
358 catch (AppDomainUnloadedException)
359 {
360 m_log.Error("[SCRIPT]: state change called when "+
361 "script was unloaded. Nothing to worry about, but "+
362 "noting the occurance");
363 }
364 }
365 }
366
367 public bool GetScriptState(UUID itemID)
368 {
369 uint localID = m_ScriptManager.GetLocalID(itemID);
370 if (localID == 0)
371 return false;
372
373 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
374 if (id == null)
375 return false;
376
377 return id.Running;
378 }
379
380 public void SetScriptState(UUID itemID, bool state)
381 {
382 uint localID = m_ScriptManager.GetLocalID(itemID);
383 if (localID == 0)
384 return;
385
386 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
387 if (id == null)
388 return;
389
390 if (!id.Disabled)
391 id.Running = state;
392 }
393
394 public void ApiResetScript(UUID itemID)
395 {
396 uint localID = m_ScriptManager.GetLocalID(itemID);
397 if (localID == 0)
398 return;
399
400 m_ScriptManager.ResetScript(localID, itemID);
401 }
402
403 public void ResetScript(UUID itemID)
404 {
405 uint localID = m_ScriptManager.GetLocalID(itemID);
406 if (localID == 0)
407 return;
408
409 m_ScriptManager.ResetScript(localID, itemID);
410 }
411
412 public void OnScriptReset(uint localID, UUID itemID)
413 {
414 ResetScript(itemID);
415 }
416
417 public void OnStartScript(uint localID, UUID itemID)
418 {
419 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
420 if (id == null)
421 return;
422
423 if (!id.Disabled)
424 id.Running = true;
425 }
426
427 public void OnStopScript(uint localID, UUID itemID)
428 {
429 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
430 if (id == null)
431 return;
432
433 id.Running = false;
434 }
435
436 public void OnGetScriptRunning(IClientAPI controllingClient,
437 UUID objectID, UUID itemID)
438 {
439 uint localID = m_ScriptManager.GetLocalID(itemID);
440 if (localID == 0)
441 return;
442
443 InstanceData id = m_ScriptManager.GetScript(localID, itemID);
444 if (id == null)
445 return;
446
447 IEventQueue eq = World.RequestModuleInterface<IEventQueue>();
448 if (eq == null)
449 {
450 controllingClient.SendScriptRunningReply(objectID, itemID,
451 id.Running);
452 }
453 else
454 {
455 eq.Enqueue(EventQueueHelper.ScriptRunningReplyEvent(objectID, itemID, id.Running, true),
456 controllingClient.AgentId);
457 }
458 }
459
460 public IScriptApi GetApi(UUID itemID, string name)
461 {
462 return m_ScriptManager.GetApi(itemID, name);
463 }
464
465 public IScriptWorkItem QueueEventHandler(Object o)
466 {
467 return null;
468 }
469
470 public string GetAssemblyName(UUID itemID)
471 {
472 return "";
473 }
474
475 public string GetXMLState(UUID itemID)
476 {
477 return "";
478 }
479
480 public bool CanBeDeleted(UUID itemID)
481 {
482 return true;
483 }
484 }
485}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
deleted file mode 100644
index 6ac209e..0000000
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ /dev/null
@@ -1,703 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using System.Globalization;
31using System.Runtime.Remoting;
32using System.Runtime.Remoting.Lifetime;
33using log4net;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Region.ScriptEngine.Interfaces;
38using OpenSim.Region.ScriptEngine.Shared;
39using OpenSim.Region.ScriptEngine.Shared.Api;
40using System.Collections.Generic;
41using System.IO;
42using System.Runtime.Serialization.Formatters.Binary;
43using System.Threading;
44using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
45using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
46using OpenSim.Region.ScriptEngine.Shared.CodeTools;
47
48namespace OpenSim.Region.ScriptEngine.DotNetEngine
49{
50 public class InstanceData
51 {
52 public IScript Script;
53 public string State;
54 public bool Running;
55 public bool Disabled;
56 public string Source;
57 public int StartParam;
58 public AppDomain AppDomain;
59 public Dictionary<string, IScriptApi> Apis;
60 public Dictionary<KeyValuePair<int,int>, KeyValuePair<int,int>>
61 LineMap;
62// public ISponsor ScriptSponsor;
63 }
64
65 public class ScriptManager
66 {
67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
68
69 #region Declares
70
71 private Thread scriptLoadUnloadThread;
72 private static Thread staticScriptLoadUnloadThread = null;
73 private Queue<LUStruct> LUQueue = new Queue<LUStruct>();
74 private static bool PrivateThread;
75 private int LoadUnloadMaxQueueSize;
76 private Object scriptLock = new Object();
77 private bool m_started = false;
78 private Dictionary<InstanceData, DetectParams[]> detparms =
79 new Dictionary<InstanceData, DetectParams[]>();
80
81 // Load/Unload structure
82 private struct LUStruct
83 {
84 public uint localID;
85 public UUID itemID;
86 public string script;
87 public LUType Action;
88 public int startParam;
89 public bool postOnRez;
90 }
91
92 private enum LUType
93 {
94 Unknown = 0,
95 Load = 1,
96 Unload = 2
97 }
98
99 public Dictionary<uint, Dictionary<UUID, InstanceData>> Scripts =
100 new Dictionary<uint, Dictionary<UUID, InstanceData>>();
101
102 private Compiler LSLCompiler;
103
104 public Scene World
105 {
106 get { return m_scriptEngine.World; }
107 }
108
109 #endregion
110
111 public void Initialize()
112 {
113 // Create our compiler
114 LSLCompiler = new Compiler(m_scriptEngine);
115 }
116
117 public void _StartScript(uint localID, UUID itemID, string Script,
118 int startParam, bool postOnRez)
119 {
120 m_log.DebugFormat(
121 "[{0}]: ScriptManager StartScript: localID: {1}, itemID: {2}",
122 m_scriptEngine.ScriptEngineName, localID, itemID);
123
124 // We will initialize and start the script.
125 // It will be up to the script itself to hook up the correct events.
126 string CompiledScriptFile = String.Empty;
127
128 SceneObjectPart m_host = World.GetSceneObjectPart(localID);
129
130 if (null == m_host)
131 {
132 m_log.ErrorFormat(
133 "[{0}]: Could not find scene object part corresponding "+
134 "to localID {1} to start script",
135 m_scriptEngine.ScriptEngineName, localID);
136
137 return;
138 }
139
140 UUID assetID = UUID.Zero;
141 TaskInventoryItem taskInventoryItem = new TaskInventoryItem();
142 if (m_host.TaskInventory.TryGetValue(itemID, out taskInventoryItem))
143 assetID = taskInventoryItem.AssetID;
144
145 ScenePresence presence =
146 World.GetScenePresence(taskInventoryItem.OwnerID);
147
148 CultureInfo USCulture = new CultureInfo("en-US");
149 Thread.CurrentThread.CurrentCulture = USCulture;
150
151 try
152 {
153 // Compile (We assume LSL)
154 CompiledScriptFile =
155 (string)LSLCompiler.PerformScriptCompile(Script,
156 assetID.ToString(), taskInventoryItem.OwnerID);
157
158 if (presence != null && (!postOnRez))
159 presence.ControllingClient.SendAgentAlertMessage(
160 "Compile successful", false);
161
162 m_log.InfoFormat("[SCRIPT]: Compiled assetID {0}: {1}",
163 assetID, CompiledScriptFile);
164
165 InstanceData id = new InstanceData();
166
167 IScript CompiledScript;
168 CompiledScript =
169 m_scriptEngine.m_AppDomainManager.LoadScript(
170 CompiledScriptFile, out id.AppDomain);
171 //Register the sponsor
172// ISponsor scriptSponsor = new ScriptSponsor();
173// ILease lease = (ILease)RemotingServices.GetLifetimeService(CompiledScript as MarshalByRefObject);
174// lease.Register(scriptSponsor);
175// id.ScriptSponsor = scriptSponsor;
176
177 id.LineMap = LSLCompiler.LineMap();
178 id.Script = CompiledScript;
179 id.Source = Script;
180 id.StartParam = startParam;
181 id.State = "default";
182 id.Running = true;
183 id.Disabled = false;
184
185 // Add it to our script memstruct
186 m_scriptEngine.m_ScriptManager.SetScript(localID, itemID, id);
187
188 id.Apis = new Dictionary<string, IScriptApi>();
189
190 ApiManager am = new ApiManager();
191
192 foreach (string api in am.GetApis())
193 {
194 id.Apis[api] = am.CreateApi(api);
195 id.Apis[api].Initialize(m_scriptEngine, m_host,
196 localID, itemID);
197 }
198
199 foreach (KeyValuePair<string,IScriptApi> kv in id.Apis)
200 {
201 CompiledScript.InitApi(kv.Key, kv.Value);
202 }
203
204 // Fire the first start-event
205 int eventFlags =
206 m_scriptEngine.m_ScriptManager.GetStateEventFlags(
207 localID, itemID);
208
209 m_host.SetScriptEvents(itemID, eventFlags);
210
211 m_scriptEngine.m_EventQueueManager.AddToScriptQueue(
212 localID, itemID, "state_entry", new DetectParams[0],
213 new object[] { });
214
215 if (postOnRez)
216 {
217 m_scriptEngine.m_EventQueueManager.AddToScriptQueue(
218 localID, itemID, "on_rez", new DetectParams[0],
219 new object[] { new LSL_Types.LSLInteger(startParam) });
220 }
221
222 string[] warnings = LSLCompiler.GetWarnings();
223
224 if (warnings != null && warnings.Length != 0)
225 {
226 if (presence != null && (!postOnRez))
227 presence.ControllingClient.SendAgentAlertMessage(
228 "Script saved with warnings, check debug window!",
229 false);
230
231 foreach (string warning in warnings)
232 {
233 try
234 {
235 // DISPLAY WARNING INWORLD
236 string text = "Warning:\n" + warning;
237 if (text.Length > 1100)
238 text = text.Substring(0, 1099);
239
240 World.SimChat(Utils.StringToBytes(text),
241 ChatTypeEnum.DebugChannel, 2147483647,
242 m_host.AbsolutePosition, m_host.Name, m_host.UUID,
243 false);
244 }
245 catch (Exception e2) // LEGIT: User Scripting
246 {
247 m_log.Error("[" +
248 m_scriptEngine.ScriptEngineName +
249 "]: Error displaying warning in-world: " +
250 e2.ToString());
251 m_log.Error("[" +
252 m_scriptEngine.ScriptEngineName + "]: " +
253 "Warning:\r\n" +
254 warning);
255 }
256 }
257 }
258 }
259 catch (Exception e) // LEGIT: User Scripting
260 {
261 if (presence != null && (!postOnRez))
262 presence.ControllingClient.SendAgentAlertMessage(
263 "Script saved with errors, check debug window!",
264 false);
265 try
266 {
267 // DISPLAY ERROR INWORLD
268 string text = "Error compiling script:\n" +
269 e.Message.ToString();
270 if (text.Length > 1100)
271 text = text.Substring(0, 1099);
272
273 World.SimChat(Utils.StringToBytes(text),
274 ChatTypeEnum.DebugChannel, 2147483647,
275 m_host.AbsolutePosition, m_host.Name, m_host.UUID,
276 false);
277 }
278 catch (Exception e2) // LEGIT: User Scripting
279 {
280 m_log.Error("[" +
281 m_scriptEngine.ScriptEngineName +
282 "]: Error displaying error in-world: " +
283 e2.ToString());
284 m_log.Error("[" +
285 m_scriptEngine.ScriptEngineName + "]: " +
286 "Errormessage: Error compiling script:\r\n" +
287 e2.Message.ToString());
288 }
289 }
290 }
291
292 public void _StopScript(uint localID, UUID itemID)
293 {
294 InstanceData id = GetScript(localID, itemID);
295 if (id == null)
296 return;
297
298 m_log.DebugFormat("[{0}]: Unloading script",
299 m_scriptEngine.ScriptEngineName);
300
301 // Stop long command on script
302 AsyncCommandManager.RemoveScript(m_scriptEngine, localID, itemID);
303
304 try
305 {
306 // Get AppDomain
307 // Tell script not to accept new requests
308 id.Running = false;
309 id.Disabled = true;
310 AppDomain ad = id.AppDomain;
311
312 // Remove from internal structure
313 RemoveScript(localID, itemID);
314
315 // Tell AppDomain that we have stopped script
316 m_scriptEngine.m_AppDomainManager.StopScript(ad);
317 }
318 catch (Exception e) // LEGIT: User Scripting
319 {
320 m_log.Error("[" +
321 m_scriptEngine.ScriptEngineName +
322 "]: Exception stopping script localID: " +
323 localID + " LLUID: " + itemID.ToString() +
324 ": " + e.ToString());
325 }
326 }
327
328 public void ReadConfig()
329 {
330 // TODO: Requires sharing of all ScriptManagers to single thread
331 PrivateThread = true;
332 LoadUnloadMaxQueueSize = m_scriptEngine.ScriptConfigSource.GetInt(
333 "LoadUnloadMaxQueueSize", 100);
334 }
335
336 #region Object init/shutdown
337
338 public ScriptEngine m_scriptEngine;
339
340 public ScriptManager(ScriptEngine scriptEngine)
341 {
342 m_scriptEngine = scriptEngine;
343 }
344
345 public void Setup()
346 {
347 ReadConfig();
348 Initialize();
349 }
350
351 public void Start()
352 {
353 m_started = true;
354
355
356 AppDomain.CurrentDomain.AssemblyResolve +=
357 new ResolveEventHandler(CurrentDomain_AssemblyResolve);
358
359 //
360 // CREATE THREAD
361 // Private or shared
362 //
363 if (PrivateThread)
364 {
365 // Assign one thread per region
366 //scriptLoadUnloadThread = StartScriptLoadUnloadThread();
367 }
368 else
369 {
370 // Shared thread - make sure one exist, then assign it to the private
371 if (staticScriptLoadUnloadThread == null)
372 {
373 //staticScriptLoadUnloadThread =
374 // StartScriptLoadUnloadThread();
375 }
376 scriptLoadUnloadThread = staticScriptLoadUnloadThread;
377 }
378 }
379
380 ~ScriptManager()
381 {
382 // Abort load/unload thread
383 try
384 {
385 if (scriptLoadUnloadThread != null &&
386 scriptLoadUnloadThread.IsAlive == true)
387 {
388 scriptLoadUnloadThread.Abort();
389 //scriptLoadUnloadThread.Join();
390 }
391 }
392 catch
393 {
394 }
395 }
396
397 #endregion
398
399 #region Load / Unload scripts (Thread loop)
400
401 public void DoScriptLoadUnload()
402 {
403 if (!m_started)
404 return;
405
406 lock (LUQueue)
407 {
408 if (LUQueue.Count > 0)
409 {
410 LUStruct item = LUQueue.Dequeue();
411
412 if (item.Action == LUType.Unload)
413 {
414 _StopScript(item.localID, item.itemID);
415 RemoveScript(item.localID, item.itemID);
416 }
417 else if (item.Action == LUType.Load)
418 {
419 m_log.DebugFormat("[{0}]: Loading script",
420 m_scriptEngine.ScriptEngineName);
421 _StartScript(item.localID, item.itemID, item.script,
422 item.startParam, item.postOnRez);
423 }
424 }
425 }
426 }
427
428 #endregion
429
430 #region Helper functions
431
432 private static Assembly CurrentDomain_AssemblyResolve(
433 object sender, ResolveEventArgs args)
434 {
435 return Assembly.GetExecutingAssembly().FullName == args.Name ?
436 Assembly.GetExecutingAssembly() : null;
437 }
438
439 #endregion
440
441 #region Start/Stop/Reset script
442
443 /// <summary>
444 /// Fetches, loads and hooks up a script to an objects events
445 /// </summary>
446 /// <param name="itemID"></param>
447 /// <param name="localID"></param>
448 public void StartScript(uint localID, UUID itemID, string Script, int startParam, bool postOnRez)
449 {
450 lock (LUQueue)
451 {
452 if ((LUQueue.Count >= LoadUnloadMaxQueueSize) && m_started)
453 {
454 m_log.Error("[" +
455 m_scriptEngine.ScriptEngineName +
456 "]: ERROR: Load/unload queue item count is at " +
457 LUQueue.Count +
458 ". Config variable \"LoadUnloadMaxQueueSize\" "+
459 "is set to " + LoadUnloadMaxQueueSize +
460 ", so ignoring new script.");
461
462 return;
463 }
464
465 LUStruct ls = new LUStruct();
466 ls.localID = localID;
467 ls.itemID = itemID;
468 ls.script = Script;
469 ls.Action = LUType.Load;
470 ls.startParam = startParam;
471 ls.postOnRez = postOnRez;
472 LUQueue.Enqueue(ls);
473 }
474 }
475
476 /// <summary>
477 /// Disables and unloads a script
478 /// </summary>
479 /// <param name="localID"></param>
480 /// <param name="itemID"></param>
481 public void StopScript(uint localID, UUID itemID)
482 {
483 LUStruct ls = new LUStruct();
484 ls.localID = localID;
485 ls.itemID = itemID;
486 ls.Action = LUType.Unload;
487 ls.startParam = 0;
488 ls.postOnRez = false;
489 lock (LUQueue)
490 {
491 LUQueue.Enqueue(ls);
492 }
493 }
494
495 #endregion
496
497 #region Perform event execution in script
498
499 // Execute a LL-event-function in Script
500 internal void ExecuteEvent(uint localID, UUID itemID,
501 string FunctionName, DetectParams[] qParams, object[] args)
502 {
503 int ExeStage=0; // ;^) Ewe Loon, for debuging
504 InstanceData id=null;
505 try // ;^) Ewe Loon,fix
506 { // ;^) Ewe Loon,fix
507 ExeStage = 1; // ;^) Ewe Loon, for debuging
508 id = GetScript(localID, itemID);
509 if (id == null)
510 return;
511 ExeStage = 2; // ;^) Ewe Loon, for debuging
512 if (qParams.Length>0) // ;^) Ewe Loon,fix
513 detparms[id] = qParams;
514 ExeStage = 3; // ;^) Ewe Loon, for debuging
515 if (id.Running)
516 id.Script.ExecuteEvent(id.State, FunctionName, args);
517 ExeStage = 4; // ;^) Ewe Loon, for debuging
518 if (qParams.Length>0) // ;^) Ewe Loon,fix
519 detparms.Remove(id);
520 ExeStage = 5; // ;^) Ewe Loon, for debuging
521 }
522 catch (Exception e) // ;^) Ewe Loon, From here down tis fix
523 {
524 if ((ExeStage == 3)&&(qParams.Length>0))
525 detparms.Remove(id);
526 SceneObjectPart ob = m_scriptEngine.World.GetSceneObjectPart(localID);
527 m_log.InfoFormat("[Script Error] ,{0},{1},@{2},{3},{4},{5}", ob.Name , FunctionName, ExeStage, e.Message, qParams.Length, detparms.Count);
528 if (ExeStage != 2) throw e;
529 }
530 }
531
532 public uint GetLocalID(UUID itemID)
533 {
534 foreach (KeyValuePair<uint, Dictionary<UUID, InstanceData> > k
535 in Scripts)
536 {
537 if (k.Value.ContainsKey(itemID))
538 return k.Key;
539 }
540 return 0;
541 }
542
543 public int GetStateEventFlags(uint localID, UUID itemID)
544 {
545 try
546 {
547 InstanceData id = GetScript(localID, itemID);
548 if (id == null)
549 {
550 return 0;
551 }
552 int evflags = id.Script.GetStateEventFlags(id.State);
553
554 return (int)evflags;
555 }
556 catch (Exception)
557 {
558 }
559
560 return 0;
561 }
562
563 #endregion
564
565 #region Internal functions to keep track of script
566
567 public List<UUID> GetScriptKeys(uint localID)
568 {
569 if (Scripts.ContainsKey(localID) == false)
570 return new List<UUID>();
571
572 Dictionary<UUID, InstanceData> Obj;
573 Scripts.TryGetValue(localID, out Obj);
574
575 return new List<UUID>(Obj.Keys);
576 }
577
578 public InstanceData GetScript(uint localID, UUID itemID)
579 {
580 lock (scriptLock)
581 {
582 InstanceData id = null;
583
584 if (Scripts.ContainsKey(localID) == false)
585 return null;
586
587 Dictionary<UUID, InstanceData> Obj;
588 Scripts.TryGetValue(localID, out Obj);
589 if (Obj==null) return null;
590 if (Obj.ContainsKey(itemID) == false)
591 return null;
592
593 // Get script
594 Obj.TryGetValue(itemID, out id);
595 return id;
596 }
597 }
598
599 public void SetScript(uint localID, UUID itemID, InstanceData id)
600 {
601 lock (scriptLock)
602 {
603 // Create object if it doesn't exist
604 if (Scripts.ContainsKey(localID) == false)
605 {
606 Scripts.Add(localID, new Dictionary<UUID, InstanceData>());
607 }
608
609 // Delete script if it exists
610 Dictionary<UUID, InstanceData> Obj;
611 Scripts.TryGetValue(localID, out Obj);
612 if (Obj.ContainsKey(itemID) == true)
613 Obj.Remove(itemID);
614
615 // Add to object
616 Obj.Add(itemID, id);
617 }
618 }
619
620 public void RemoveScript(uint localID, UUID itemID)
621 {
622 if (localID == 0)
623 localID = GetLocalID(itemID);
624
625 // Don't have that object?
626 if (Scripts.ContainsKey(localID) == false)
627 return;
628
629 // Delete script if it exists
630 Dictionary<UUID, InstanceData> Obj;
631 Scripts.TryGetValue(localID, out Obj);
632 if (Obj.ContainsKey(itemID) == true)
633 Obj.Remove(itemID);
634 }
635
636 #endregion
637
638 public void ResetScript(uint localID, UUID itemID)
639 {
640 InstanceData id = GetScript(localID, itemID);
641 string script = id.Source;
642 StopScript(localID, itemID);
643 SceneObjectPart part = World.GetSceneObjectPart(localID);
644 part.Inventory.GetInventoryItem(itemID).PermsMask = 0;
645 part.Inventory.GetInventoryItem(itemID).PermsGranter = UUID.Zero;
646 StartScript(localID, itemID, script, id.StartParam, false);
647 }
648
649 #region Script serialization/deserialization
650
651 public void GetSerializedScript(uint localID, UUID itemID)
652 {
653 // Serialize the script and return it
654 // Should not be a problem
655 FileStream fs = File.Create("SERIALIZED_SCRIPT_" + itemID);
656 BinaryFormatter b = new BinaryFormatter();
657 b.Serialize(fs, GetScript(localID, itemID));
658 fs.Close();
659 }
660
661 public void PutSerializedScript(uint localID, UUID itemID)
662 {
663 // Deserialize the script and inject it into an AppDomain
664
665 // How to inject into an AppDomain?
666 }
667
668 #endregion
669
670 public DetectParams[] GetDetectParams(InstanceData id)
671 {
672 if (detparms.ContainsKey(id))
673 return detparms[id];
674
675 return null;
676 }
677
678 public int GetStartParameter(UUID itemID)
679 {
680 uint localID = GetLocalID(itemID);
681 InstanceData id = GetScript(localID, itemID);
682
683 if (id == null)
684 return 0;
685
686 return id.StartParam;
687 }
688
689 public IScriptApi GetApi(UUID itemID, string name)
690 {
691 uint localID = GetLocalID(itemID);
692
693 InstanceData id = GetScript(localID, itemID);
694 if (id == null)
695 return null;
696
697 if (id.Apis.ContainsKey(name))
698 return id.Apis[name];
699
700 return null;
701 }
702 }
703}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 1607d34..9d97cb2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -137,11 +137,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
137 if (cmdHandlerThread == null) 137 if (cmdHandlerThread == null)
138 { 138 {
139 // Start the thread that will be doing the work 139 // Start the thread that will be doing the work
140 cmdHandlerThread = new Thread(CmdHandlerThreadLoop); 140 cmdHandlerThread = Watchdog.StartThread(CmdHandlerThreadLoop, "AsyncLSLCmdHandlerThread", ThreadPriority.Normal, true);
141 cmdHandlerThread.Name = "AsyncLSLCmdHandlerThread";
142 cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
143 cmdHandlerThread.IsBackground = true;
144 cmdHandlerThread.Start();
145 } 141 }
146 } 142 }
147 143
@@ -185,6 +181,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
185 Thread.Sleep(cmdHandlerThreadCycleSleepms); 181 Thread.Sleep(cmdHandlerThreadCycleSleepms);
186 182
187 DoOneCmdHandlerPass(); 183 DoOneCmdHandlerPass();
184
185 Watchdog.UpdateThread();
188 } 186 }
189 } 187 }
190 catch 188 catch
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 1dc20ff..0f01c36 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1267,12 +1267,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1267 protected void SetScale(SceneObjectPart part, LSL_Vector scale) 1267 protected void SetScale(SceneObjectPart part, LSL_Vector scale)
1268 { 1268 {
1269 // TODO: this needs to trigger a persistance save as well 1269 // TODO: this needs to trigger a persistance save as well
1270
1271 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 1270 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
1272 return; 1271 return;
1273 1272 if (scale.x < 0.01)
1274 if (scale.x < 0.01 || scale.y < 0.01 || scale.z < 0.01) 1273 scale.x = 0.01;
1275 return; 1274 if (scale.y < 0.01)
1275 scale.y = 0.01;
1276 if (scale.z < 0.01)
1277 scale.z = 0.01;
1276 1278
1277 if (part.ParentGroup.RootPart.PhysActor != null && part.ParentGroup.RootPart.PhysActor.IsPhysical) 1279 if (part.ParentGroup.RootPart.PhysActor != null && part.ParentGroup.RootPart.PhysActor.IsPhysical)
1278 { 1280 {
@@ -1283,12 +1285,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1283 if (scale.z > World.m_maxPhys) 1285 if (scale.z > World.m_maxPhys)
1284 scale.z = World.m_maxPhys; 1286 scale.z = World.m_maxPhys;
1285 } 1287 }
1288
1286 if (scale.x > World.m_maxNonphys) 1289 if (scale.x > World.m_maxNonphys)
1287 scale.x = World.m_maxNonphys; 1290 scale.x = World.m_maxNonphys;
1288 if (scale.y > World.m_maxNonphys) 1291 if (scale.y > World.m_maxNonphys)
1289 scale.y = World.m_maxNonphys; 1292 scale.y = World.m_maxNonphys;
1290 if (scale.z > World.m_maxNonphys) 1293 if (scale.z > World.m_maxNonphys)
1291 scale.z = World.m_maxNonphys; 1294 scale.z = World.m_maxNonphys;
1295
1292 Vector3 tmp = part.Scale; 1296 Vector3 tmp = part.Scale;
1293 tmp.X = (float)scale.x; 1297 tmp.X = (float)scale.x;
1294 tmp.Y = (float)scale.y; 1298 tmp.Y = (float)scale.y;
@@ -2043,7 +2047,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2043 if (local != 0) 2047 if (local != 0)
2044 force *= llGetRot(); 2048 force *= llGetRot();
2045 2049
2046 m_host.ParentGroup.RootPart.SetForce(new PhysicsVector((float)force.x, (float)force.y, (float)force.z)); 2050 m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z));
2047 } 2051 }
2048 } 2052 }
2049 } 2053 }
@@ -2058,7 +2062,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2058 { 2062 {
2059 if (!m_host.ParentGroup.IsDeleted) 2063 if (!m_host.ParentGroup.IsDeleted)
2060 { 2064 {
2061 PhysicsVector tmpForce = m_host.ParentGroup.RootPart.GetForce(); 2065 Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce();
2062 force.x = tmpForce.X; 2066 force.x = tmpForce.X;
2063 force.y = tmpForce.Y; 2067 force.y = tmpForce.Y;
2064 force.z = tmpForce.Z; 2068 force.z = tmpForce.Z;
@@ -4180,7 +4184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4180 { 4184 {
4181 applied_linear_impulse *= m_host.GetWorldRotation(); 4185 applied_linear_impulse *= m_host.GetWorldRotation();
4182 } 4186 }
4183 pusheeav.PhysicsActor.AddForce(new PhysicsVector(applied_linear_impulse.X, applied_linear_impulse.Y, applied_linear_impulse.Z), true); 4187 pusheeav.PhysicsActor.AddForce(applied_linear_impulse, true);
4184 } 4188 }
4185 } 4189 }
4186 } 4190 }
@@ -6088,7 +6092,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6088 if (!m_host.ParentGroup.IsDeleted) 6092 if (!m_host.ParentGroup.IsDeleted)
6089 { 6093 {
6090 m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, 6094 m_host.ParentGroup.RootPart.SetVehicleVectorParam(param,
6091 new PhysicsVector((float)vec.x, (float)vec.y, (float)vec.z)); 6095 new Vector3((float)vec.x, (float)vec.y, (float)vec.z));
6092 } 6096 }
6093 } 6097 }
6094 } 6098 }
@@ -7227,13 +7231,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7227 public LSL_Integer llGetNumberOfPrims() 7231 public LSL_Integer llGetNumberOfPrims()
7228 { 7232 {
7229 m_host.AddScriptLPS(1); 7233 m_host.AddScriptLPS(1);
7230 List<ScenePresence> presences = World.GetScenePresences(); 7234 ScenePresence[] presences = World.GetScenePresences();
7231 if (presences.Count == 0) 7235 if (presences.Length == 0)
7232 return 0; 7236 return 0;
7233 7237
7234 int avatarCount = 0; 7238 int avatarCount = 0;
7235 foreach (ScenePresence presence in presences) 7239 for (int i = 0; i < presences.Length; i++)
7236 { 7240 {
7241 ScenePresence presence = presences[i];
7242
7237 if (!presence.IsChildAgent && presence.ParentID != 0) 7243 if (!presence.IsChildAgent && presence.ParentID != 0)
7238 { 7244 {
7239 if (m_host.ParentGroup.HasChildPrim(presence.ParentID)) 7245 if (m_host.ParentGroup.HasChildPrim(presence.ParentID))
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index a09c8db..b75a2e4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -404,7 +404,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
404 404
405 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) 405 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts)
406 { 406 {
407 List<ScenePresence> Presences; 407 List<ScenePresence> presences;
408 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 408 List<SensedEntity> sensedEntities = new List<SensedEntity>();
409 409
410 // If this is an avatar sense by key try to get them directly 410 // If this is an avatar sense by key try to get them directly
@@ -414,16 +414,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
414 ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID); 414 ScenePresence p = m_CmdManager.m_ScriptEngine.World.GetScenePresence(ts.keyID);
415 if (p == null) 415 if (p == null)
416 return sensedEntities; 416 return sensedEntities;
417 Presences = new List<ScenePresence>(); 417 presences = new List<ScenePresence>();
418 Presences.Add(p); 418 presences.Add(p);
419 } 419 }
420 else 420 else
421 { 421 {
422 Presences = m_CmdManager.m_ScriptEngine.World.GetScenePresences(); 422 presences = new List<ScenePresence>(m_CmdManager.m_ScriptEngine.World.GetScenePresences());
423 } 423 }
424 424
425 // If nobody about quit fast 425 // If nobody about quit fast
426 if (Presences.Count == 0) 426 if (presences.Count == 0)
427 return sensedEntities; 427 return sensedEntities;
428 428
429 SceneObjectPart SensePoint = ts.host; 429 SceneObjectPart SensePoint = ts.host;
@@ -440,8 +440,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
440 Vector3 toRegionPos; 440 Vector3 toRegionPos;
441 double dis; 441 double dis;
442 442
443 foreach (ScenePresence presence in Presences) 443 for (int i = 0; i < presences.Count; i++)
444 { 444 {
445 ScenePresence presence = presences[i];
445 bool keep = true; 446 bool keep = true;
446 447
447 if (presence.IsDeleted) 448 if (presence.IsDeleted)
@@ -515,16 +516,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
515 { 516 {
516 List<Object> data = new List<Object>(); 517 List<Object> data = new List<Object>();
517 518
518 foreach (SenseRepeatClass ts in SenseRepeaters) 519 lock (SenseRepeatListLock)
519 { 520 {
520 if (ts.itemID == itemID) 521 foreach (SenseRepeatClass ts in SenseRepeaters)
521 { 522 {
522 data.Add(ts.interval); 523 if (ts.itemID == itemID)
523 data.Add(ts.name); 524 {
524 data.Add(ts.keyID); 525 data.Add(ts.interval);
525 data.Add(ts.type); 526 data.Add(ts.name);
526 data.Add(ts.range); 527 data.Add(ts.keyID);
527 data.Add(ts.arc); 528 data.Add(ts.type);
529 data.Add(ts.range);
530 data.Add(ts.arc);
531 }
528 } 532 }
529 } 533 }
530 return data.ToArray(); 534 return data.ToArray();
diff --git a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
index d7c39a3..704b74f 100644
--- a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
+++ b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs
@@ -68,11 +68,11 @@ namespace OpenSim.Region.UserStatistics
68 HTMLUtil.OL_O(ref output, ""); 68 HTMLUtil.OL_O(ref output, "");
69 foreach (Scene scene in all_scenes) 69 foreach (Scene scene in all_scenes)
70 { 70 {
71 List<ScenePresence> avatarInScene = scene.GetScenePresences(); 71 ScenePresence[] avatarInScene = scene.GetScenePresences();
72 72
73 HTMLUtil.LI_O(ref output, ""); 73 HTMLUtil.LI_O(ref output, String.Empty);
74 output.Append(scene.RegionInfo.RegionName); 74 output.Append(scene.RegionInfo.RegionName);
75 HTMLUtil.OL_O(ref output, ""); 75 HTMLUtil.OL_O(ref output, String.Empty);
76 foreach (ScenePresence av in avatarInScene) 76 foreach (ScenePresence av in avatarInScene)
77 { 77 {
78 Dictionary<string,string> queues = new Dictionary<string, string>(); 78 Dictionary<string,string> queues = new Dictionary<string, string>();
@@ -81,7 +81,7 @@ namespace OpenSim.Region.UserStatistics
81 IStatsCollector isClient = (IStatsCollector) av.ControllingClient; 81 IStatsCollector isClient = (IStatsCollector) av.ControllingClient;
82 queues = decodeQueueReport(isClient.Report()); 82 queues = decodeQueueReport(isClient.Report());
83 } 83 }
84 HTMLUtil.LI_O(ref output, ""); 84 HTMLUtil.LI_O(ref output, String.Empty);
85 output.Append(av.Name); 85 output.Append(av.Name);
86 output.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"); 86 output.Append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
87 output.Append((av.IsChildAgent ? "Child" : "Root")); 87 output.Append((av.IsChildAgent ? "Child" : "Root"));
@@ -96,12 +96,12 @@ namespace OpenSim.Region.UserStatistics
96 (int) av.AbsolutePosition.Z)); 96 (int) av.AbsolutePosition.Z));
97 } 97 }
98 Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1)); 98 Dictionary<string, int> throttles = DecodeClientThrottles(av.ControllingClient.GetThrottlesPacked(1));
99 99
100 HTMLUtil.UL_O(ref output, ""); 100 HTMLUtil.UL_O(ref output, String.Empty);
101 101
102 foreach (string throttlename in throttles.Keys) 102 foreach (string throttlename in throttles.Keys)
103 { 103 {
104 HTMLUtil.LI_O(ref output, ""); 104 HTMLUtil.LI_O(ref output, String.Empty);
105 output.Append(throttlename); 105 output.Append(throttlename);
106 output.Append(":"); 106 output.Append(":");
107 output.Append(throttles[throttlename].ToString()); 107 output.Append(throttles[throttlename].ToString());
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/Commands_LSL.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/Commands_LSL.cs
deleted file mode 100644
index 0b7c894..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/Commands_LSL.cs
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.ScriptEngine.Shared;
32
33namespace OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL
34{
35 public class Commands_LSL : IScriptEngineComponent
36 {
37
38
39 }
40}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/LSL_BaseClass.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/LSL_BaseClass.cs
deleted file mode 100644
index fdbc699..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/LSL_BaseClass.cs
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using OpenSim.ScriptEngine.Shared;
34
35namespace OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL
36{
37 public class Script : IScriptCommandProvider
38 {
39 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
41 public void llSay(int channelID, string text)
42 {
43 m_log.InfoFormat("[{0}] llSay({1}, \"{2}\")", "(Commands_LSL)OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL.Script", channelID, text);
44 }
45
46 public void ExecuteCommand(string functionName, params object[] args)
47 {
48
49 }
50
51 public string Name
52 {
53 get { return "SECS.DotNetEngine.Commands_LSL.Script"; }
54 }
55 }
56} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/Properties/AssemblyInfo.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/Properties/AssemblyInfo.cs
deleted file mode 100644
index fc67ec1..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// General Information about an assembly is controlled through the following
33// set of attributes. Change these attribute values to modify the information
34// associated with an assembly.
35[assembly: AssemblyTitle("OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL")]
36[assembly: AssemblyDescription("")]
37[assembly: AssemblyConfiguration("")]
38[assembly: AssemblyCompany("http://opensimulator.org")]
39[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL")]
40[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
41[assembly: AssemblyTrademark("")]
42[assembly: AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47[assembly: ComVisible(false)]
48
49// The following GUID is for the ID of the typelib if this project is exposed to COM
50[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
51
52// Version information for an assembly consists of the following four values:
53//
54// Major Version
55// Minor Version
56// Build Number
57// Revision
58//
59// You can specify all the values or you can default the Build and Revision Numbers
60// by using the '*' as shown below:
61// [assembly: AssemblyVersion("0.6.5.*")]
62[assembly: AssemblyVersion("0.6.5.*")]
63[assembly: AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_OSSL/Properties/AssemblyInfo.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_OSSL/Properties/AssemblyInfo.cs
deleted file mode 100644
index c6b15cf..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_OSSL/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// General Information about an assembly is controlled through the following
33// set of attributes. Change these attribute values to modify the information
34// associated with an assembly.
35[assembly: AssemblyTitle("OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL")]
36[assembly: AssemblyDescription("")]
37[assembly: AssemblyConfiguration("")]
38[assembly: AssemblyCompany("http://opensimulator.org")]
39[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL")]
40[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
41[assembly: AssemblyTrademark("")]
42[assembly: AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47[assembly: ComVisible(false)]
48
49// The following GUID is for the ID of the typelib if this project is exposed to COM
50[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
51
52// Version information for an assembly consists of the following four values:
53//
54// Major Version
55// Minor Version
56// Build Number
57// Revision
58//
59// You can specify all the values or you can default the Build and Revision Numbers
60// by using the '*' as shown below:
61// [assembly: AssemblyVersion("0.6.5.*")]
62[assembly: AssemblyVersion("0.6.5.*")]
63[assembly: AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/CILCompiler.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/CILCompiler.cs
deleted file mode 100644
index 3d2d9d2..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/CILCompiler.cs
+++ /dev/null
@@ -1,187 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.CodeDom.Compiler;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Text.RegularExpressions;
33using log4net;
34using OpenSim.ScriptEngine.Shared;
35using ScriptAssemblies;
36
37namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
38{
39 public abstract class CILCompiler
40 {
41 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 private string ScriptEnginesPath = "ScriptEngines";
43 private string Name { get { return "SECS.DotNetEngine.CILCompiler"; } }
44 private string m_scriptAssemblyName;
45 internal string ScriptAssemblyName { get { return m_scriptAssemblyName; } set { m_scriptAssemblyName = value; } }
46
47 // Default inherit
48 protected string ScriptInheritFrom = typeof(ScriptAssemblies.ScriptBase).Name;
49 private readonly System.Security.Cryptography.MD5CryptoServiceProvider MD5Sum = new System.Security.Cryptography.MD5CryptoServiceProvider();
50 protected CodeDomProvider CompileProvider;
51
52 //private string[] AppDomainAssemblies = new string[] { "OpenSim.Region.ScriptEngine.Shared.dll", "OpenSim.Region.ScriptEngine.Shared.Script.dll", "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll" };
53 private readonly string[] AppDomainAssemblies = new string[] {
54 Assembly.GetAssembly(typeof(Int32)).Location,
55 "OpenSim.ScriptEngine.Shared.dll",
56 "OpenSim.ScriptEngine.Shared.Script.dll",
57 Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.Shared.dll")
58 };
59
60 public abstract string PreProcessScript(ref string script);
61
62 public CILCompiler()
63 {
64 }
65
66 private static readonly Regex FileNameFixer = new Regex(@"[^a-zA-Z0-9\.\-]", RegexOptions.Compiled | RegexOptions.Singleline);
67 public string Compile(ScriptMetaData data, ref string _script)
68 {
69 // Add "using", "inherit", default constructor, etc around script.
70 string script = PreProcessScript(ref _script);
71
72 // Get filename based on content
73 string md5Sum = System.Convert.ToBase64String(
74 MD5Sum.ComputeHash(
75 System.Text.Encoding.ASCII.GetBytes(script)
76 ));
77 // Unique name for this assembly
78 ScriptAssemblyName = "SECS_Script_" + FileNameFixer.Replace(md5Sum, "_");
79
80 string OutFile = Path.Combine(ScriptEnginesPath, ScriptAssemblyName + ".dll");
81
82 // Make sure target dir exist
83 if (!Directory.Exists(ScriptEnginesPath))
84 try { Directory.CreateDirectory(ScriptEnginesPath); }
85 catch { }
86
87 // Already exist? No point in recompiling
88 if (File.Exists(OutFile))
89 return OutFile;
90
91 //
92 // Dump source code
93 //
94 string dumpFile = OutFile + ".txt";
95 try
96 {
97 if (File.Exists(dumpFile))
98 File.Delete(dumpFile);
99 File.WriteAllText(dumpFile, script);
100 }
101 catch (Exception e)
102 {
103 m_log.DebugFormat("[{0}] Exception trying to dump script source code to file \"{1}\": {2}", Name, dumpFile, e.ToString());
104 }
105
106 //
107 // COMPILE
108 //
109
110 CompilerParameters parameters = new CompilerParameters();
111 parameters.IncludeDebugInformation = true;
112 //string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
113
114 foreach (string file in AppDomainAssemblies)
115 {
116 parameters.ReferencedAssemblies.Add(file);
117 m_log.DebugFormat("[{0}] Adding reference for compile: \"{1}\".", Name, file);
118 }
119 //lock (commandProvider)
120 //{
121 // foreach (string key in commandProvider.Keys)
122 // {
123 // IScriptCommandProvider cp = commandProvider[key];
124 // string
125 // file = cp.GetType().Assembly.Location;
126 // parameters.ReferencedAssemblies.Add(file);
127 // m_log.DebugFormat("[{0}] Loading command provider assembly \"{1}\" into AppDomain: \"{2}\".", Name,
128 // key, file);
129 // }
130 //}
131
132 parameters.GenerateExecutable = false;
133 parameters.OutputAssembly = OutFile;
134 parameters.IncludeDebugInformation = true;
135 //parameters.WarningLevel = 1; // Should be 4?
136 parameters.TreatWarningsAsErrors = false;
137
138 // Do compile
139 CompilerResults results = CompileProvider.CompileAssemblyFromSource(parameters, script);
140
141
142 //
143 // WARNINGS AND ERRORS
144 //
145 //TODO
146 int display = 5;
147 if (results.Errors.Count > 0)
148 {
149 string errtext = String.Empty;
150 foreach (CompilerError CompErr in results.Errors)
151 {
152 // Show 5 errors max
153 //
154 if (display <= 0)
155 break;
156 display--;
157
158 string severity = "Error";
159 if (CompErr.IsWarning)
160 severity = "Warning";
161
162 //TODO: Implement
163 KeyValuePair<int, int> lslPos = new KeyValuePair<int, int>();
164
165 //lslPos = "NOT IMPLEMENTED";// FindErrorPosition(CompErr.Line, CompErr.Column);
166
167 string text = CompErr.ErrorText;
168
169 // The Second Life viewer's script editor begins
170 // countingn lines and columns at 0, so we subtract 1.
171 errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n",
172 lslPos.Key - 1, lslPos.Value - 1,
173 CompErr.ErrorNumber, text, severity);
174 }
175
176 if (!File.Exists(OutFile))
177 {
178 throw new Exception(errtext);
179 }
180 }
181
182 // TODO: Process errors
183 return OutFile;
184 }
185
186 }
187}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_CS.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_CS.cs
deleted file mode 100644
index a8599bf..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_CS.cs
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.CodeDom.Compiler;
29using System.Collections.Generic;
30using System.Text;
31using Microsoft.CSharp;
32using OpenSim.ScriptEngine.Shared;
33
34namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
35{
36 public class Compiler_CS : CILCompiler, IScriptCompiler
37 {
38 private string[] ScriptUsing = new string[]
39 {
40 "System",
41 "OpenSim.ScriptEngine.Shared",
42 "OpenSim.Region.ScriptEngine.Shared",
43 "System.Collections.Generic"
44 };
45
46 public Compiler_CS()
47 {
48 CompileProvider = new CSharpCodeProvider();
49 }
50
51 public override string PreProcessScript(ref string script)
52 {
53 string s = "";
54 foreach (string u in ScriptUsing)
55 {
56 s += "using " + u + ";";
57 }
58
59 s += "\r\n"
60 + String.Empty + "namespace ScriptAssemblies { "
61 + String.Empty + "public class UserScript" + " : " + ScriptInheritFrom + " { \r\n" +
62 @"public Script() { } " +
63 script +
64 "} }\r\n";
65
66 return s;
67 }
68
69 }
70}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_JS.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_JS.cs
deleted file mode 100644
index 4361ae2..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_JS.cs
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.CodeDom.Compiler;
29using System.Collections.Generic;
30using System.Text;
31using Microsoft.JScript;
32using OpenSim.ScriptEngine.Shared;
33
34namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
35{
36 public class Compiler_JS : CILCompiler, IScriptCompiler
37 {
38
39 public Compiler_JS()
40 {
41 CompileProvider = new JScriptCodeProvider() as CodeDomProvider;
42 }
43
44 public override string PreProcessScript(ref string script)
45 {
46 return
47 "import OpenSim.Region.ScriptEngine.Shared; import System.Collections.Generic;\r\n" +
48 "package SecondLife {\r\n" +
49 "class Script extends OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" +
50 script +
51 "} }\r\n";
52
53 }
54
55 }
56}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_LSL.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_LSL.cs
deleted file mode 100644
index 496afc9..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_LSL.cs
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30using System.Text;
31using OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.LSL;
32using OpenSim.ScriptEngine.Shared;
33
34namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
35{
36 public class Compiler_LSL : IScriptCompiler
37 {
38
39
40 private readonly Compiler_CS m_Compiler_CS = new Compiler_CS();
41 private readonly LSL2CS m_LSL2CS = new LSL2CS();
42
43 public string Compile(ScriptMetaData scriptMetaData, ref string script)
44 {
45 // Convert script to CS
46 string scriptCS = m_LSL2CS.Convert(ref script);
47 // Use CS compiler to compile it
48 return m_Compiler_CS.Compile(scriptMetaData, ref scriptCS);
49 }
50
51 public string PreProcessScript(ref string script)
52 {
53 // This is handled by our converter
54 return script;
55 }
56 }
57}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_VB.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_VB.cs
deleted file mode 100644
index 04597ba..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_VB.cs
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.CodeDom.Compiler;
29using System.Collections.Generic;
30using System.Text;
31using Microsoft.VisualBasic;
32using OpenSim.ScriptEngine.Shared;
33
34namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
35{
36 public class Compiler_VB : CILCompiler, IScriptCompiler
37 {
38
39 public Compiler_VB()
40 {
41 CompileProvider = new VBCodeProvider() as CodeDomProvider;
42 }
43
44 public override string PreProcessScript(ref string script)
45 {
46 return
47 "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " +
48 String.Empty + "NameSpace SecondLife:" +
49 String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass: " +
50 "\r\nPublic Sub New()\r\nEnd Sub: " +
51 script +
52 ":End Class :End Namespace\r\n";
53 }
54 }
55}
56
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_YP.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_YP.cs
deleted file mode 100644
index dce17ad..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Compiler_YP.cs
+++ /dev/null
@@ -1,55 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30using System.Text;
31using OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.YP;
32using OpenSim.ScriptEngine.Shared;
33
34namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
35{
36 public class Compiler_YP: IScriptCompiler
37 {
38
39 private readonly Compiler_CS m_Compiler_CS = new Compiler_CS();
40
41 public string Compile(ScriptMetaData scriptMetaData, ref string script)
42 {
43 // Convert script to CS
44 string scriptCS = YP2CS.Convert(ref script);
45 // Use CS compiler to compile it
46 return m_Compiler_CS.Compile(scriptMetaData, ref scriptCS);
47 }
48
49 public string PreProcessScript(ref string script)
50 {
51 // This is handled by our converter
52 return script;
53 }
54 }
55}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/LSL/LSL2CS.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/LSL/LSL2CS.cs
deleted file mode 100644
index d4af1c7..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/LSL/LSL2CS.cs
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30using OpenSim.Region.ScriptEngine.Shared.CodeTools;
31
32namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.LSL
33{
34 public class LSL2CS
35 {
36 private ICodeConverter Converter = new CSCodeGenerator();
37
38 public string Convert(ref string script)
39 {
40 //m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap;
41 return Converter.Convert(script);
42 }
43 }
44}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Properties/AssemblyInfo.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Properties/AssemblyInfo.cs
deleted file mode 100644
index dedc48e..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// General Information about an assembly is controlled through the following
33// set of attributes. Change these attribute values to modify the information
34// associated with an assembly.
35[assembly: AssemblyTitle("OpenSim.ScriptEngine.Components.DotNetEngine.Compilers")]
36[assembly: AssemblyDescription("")]
37[assembly: AssemblyConfiguration("")]
38[assembly: AssemblyCompany("http://opensimulator.org")]
39[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Compilers")]
40[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
41[assembly: AssemblyTrademark("")]
42[assembly: AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47[assembly: ComVisible(false)]
48
49// The following GUID is for the ID of the typelib if this project is exposed to COM
50[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
51
52// Version information for an assembly consists of the following four values:
53//
54// Major Version
55// Minor Version
56// Build Number
57// Revision
58//
59// You can specify all the values or you can default the Build and Revision Numbers
60// by using the '*' as shown below:
61// [assembly: AssemblyVersion("0.6.5.*")]
62[assembly: AssemblyVersion("0.6.5.*")]
63[assembly: AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/YP/YP2CS.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/YP/YP2CS.cs
deleted file mode 100644
index 10b5715..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Compilers/YP/YP2CS.cs
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30
31namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.YP
32{
33 public class YP2CS
34 {
35 public static string Convert(ref string script)
36 {
37 return script;
38 }
39
40 public string PreProcessScript(ref string script)
41 {
42 return
43 "using OpenSim.Region.ScriptEngine.Shared.YieldProlog; " +
44 "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" +
45 String.Empty + "namespace SecondLife { " +
46 String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" +
47 //@"public Script() { } " +
48 @"static OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP YP=null; " +
49 @"public Script() { YP= new OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP(); } " +
50 script +
51 "} }\r\n";
52 }
53 }
54}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs
deleted file mode 100644
index 81dc62d..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs
+++ /dev/null
@@ -1,121 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Scenes;
33using OpenSim.Region.ScriptEngine.Shared;
34using OpenSim.ScriptEngine.Shared;
35using EventParams = OpenSim.ScriptEngine.Shared.EventParams;
36
37namespace OpenSim.ScriptEngine.Components.DotNetEngine.Events
38{
39 public class LSLEventProvider : IScriptEventProvider
40 {
41 public delegate void RezScriptDelegate(uint localID, UUID itemID, string script, int startParam, bool postOnRez,
42 string engine);
43 public event RezScriptDelegate RezScript;
44 public delegate void RemoveScriptDelegate(uint localID, UUID itemID);
45 public event RemoveScriptDelegate RemoveScript;
46 public delegate void ScriptChangedDelegate(uint localID, uint change);
47 public event ScriptChangedDelegate ScriptChanged;
48
49 private RegionInfoStructure CurrentRegion;
50 public void Initialize(RegionInfoStructure currentRegion)
51 {
52 CurrentRegion = currentRegion;
53 HookupEvents();
54 }
55
56 private void HookupEvents()
57 {
58 CurrentRegion.Scene.EventManager.OnObjectGrab += OnObjectGrab;
59 CurrentRegion.Scene.EventManager.OnRezScript += OnRezScript;
60 CurrentRegion.Scene.EventManager.OnRemoveScript += OnRemoveScript;
61 CurrentRegion.Scene.EventManager.OnScriptChangedEvent += OnScriptChangedEvent;
62
63
64 }
65
66 private void OnScriptChangedEvent(uint localID, uint change)
67 {
68 // Script is being changed, fire event
69 if (ScriptChanged != null)
70 ScriptChanged(localID, change);
71 }
72
73 private void OnRemoveScript(uint localID, UUID itemID)
74 {
75 // Script is being removed, fire event
76 if (RemoveScript != null)
77 RemoveScript(localID, itemID);
78 }
79
80 private void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
81 {
82 // New script being created, fire event
83 if (RezScript != null)
84 RezScript(localID, itemID, script, startParam, postOnRez, engine);
85 }
86
87 private void OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
88 {
89 // Add to queue for all scripts in ObjectID object
90 DetectParams[] det = new DetectParams[1];
91 det[0] = new DetectParams();
92 det[0].Key = remoteClient.AgentId;
93 //det[0].Populate(World);
94
95 if (originalID == 0)
96 {
97 SceneObjectPart part =
98 CurrentRegion.Scene.GetSceneObjectPart(localID);
99
100 if (part == null)
101 return;
102
103 det[0].LinkNum = part.LinkNum;
104 }
105 else
106 {
107 SceneObjectPart originalPart =
108 CurrentRegion.Scene.GetSceneObjectPart(originalID);
109 det[0].LinkNum = originalPart.LinkNum;
110 }
111 if (surfaceArgs != null)
112 {
113 det[0].SurfaceTouchArgs = surfaceArgs;
114 }
115 Shared.EventParams ep =
116 new Shared.EventParams(localID, "touch_start", new Object[] {new LSL_Types.LSLInteger(1)}, det);
117 CurrentRegion.Executors_Execute(ep);
118
119 }
120 }
121}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Events/Properties/AssemblyInfo.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Events/Properties/AssemblyInfo.cs
deleted file mode 100644
index 299304a..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Events/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// General Information about an assembly is controlled through the following
33// set of attributes. Change these attribute values to modify the information
34// associated with an assembly.
35[assembly: AssemblyTitle("OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler")]
36[assembly: AssemblyDescription("")]
37[assembly: AssemblyConfiguration("")]
38[assembly: AssemblyCompany("http://opensimulator.org")]
39[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler")]
40[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
41[assembly: AssemblyTrademark("")]
42[assembly: AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47[assembly: ComVisible(false)]
48
49// The following GUID is for the ID of the typelib if this project is exposed to COM
50[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
51
52// Version information for an assembly consists of the following four values:
53//
54// Major Version
55// Minor Version
56// Build Number
57// Revision
58//
59// You can specify all the values or you can default the Build and Revision Numbers
60// by using the '*' as shown below:
61// [assembly: AssemblyVersion("0.6.5.*")]
62[assembly: AssemblyVersion("0.6.5.*")]
63[assembly: AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/BaseClassFactory.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/BaseClassFactory.cs
deleted file mode 100644
index afa2300..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/BaseClassFactory.cs
+++ /dev/null
@@ -1,240 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using System.Reflection.Emit;
33using System.Text;
34using OpenSim.ScriptEngine.Shared;
35
36namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
37{
38 public class BaseClassFactory
39 {
40
41
42 public static void MakeBaseClass(ScriptStructure script)
43 {
44 string asmName = "ScriptAssemblies";
45 string ModuleID = asmName;
46 string ClassID = "Script";
47 string moveToDir = "ScriptEngines";
48 string asmFileName = ModuleID + "_" + ClassID + ".dll";
49 if (!Directory.Exists(moveToDir))
50 Directory.CreateDirectory(moveToDir);
51
52 ILGenerator ilgen;
53 AssemblyBuilder asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
54 new AssemblyName(asmName), AssemblyBuilderAccess.RunAndSave);
55
56 // The module builder
57 ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule(ModuleID, asmFileName);
58
59 // The class builder
60 TypeBuilder classBuilder = modBuilder.DefineType(ClassID, TypeAttributes.Class | TypeAttributes.Public);
61
62 // The default constructor
63 //ConstructorBuilder ctorBuilder = classBuilder.DefineDefaultConstructor(MethodAttributes.Public);
64
65
66 Type[] paramsTypeArray = new Type[] {typeof (System.ParamArrayAttribute)};
67 Type[] executeFunctionTypeArray = new Type[] {typeof (string), typeof (System.ParamArrayAttribute)};
68 foreach (IScriptCommandProvider cp in script.RegionInfo.CommandProviders.Values)
69 {
70 Type t = cp.GetType();
71 foreach (MethodInfo mi in t.GetMethods())
72 {
73 MethodBuilder methodBuilder = classBuilder.DefineMethod(mi.Name, mi.Attributes, mi.GetType(), Type.EmptyTypes);
74 methodBuilder.SetParameters(paramsTypeArray);
75 //ParameterBuilder paramBuilder = methodBuilder.DefineParameter(1, ParameterAttributes.None, "args");
76
77 ilgen = methodBuilder.GetILGenerator();
78 //ilgen.Emit(OpCodes.Nop);
79 //ilgen.Emit(OpCodes.Ldarg_0);
80 //ilgen.Emit(OpCodes.Ldc_I4_0);
81 //ilgen.Emit(OpCodes.Ldelem_Ref);
82 //ilgen.MarkSequencePoint(doc, 6, 1, 6, 100);
83
84 //MethodInfo ExecuteFunction = typeof(ScriptAssemblies.IScript).GetMethod(
85 // "ExecuteFunction",
86 // executeFunctionTypeArray);
87
88 ilgen.DeclareLocal(typeof(string));
89 ilgen.Emit(OpCodes.Nop);
90 ilgen.Emit(OpCodes.Ldstr, mi.Name);
91 ilgen.Emit(OpCodes.Stloc_0);
92 ilgen.Emit(OpCodes.Ldarg_0);
93 ilgen.Emit(OpCodes.Ldloc_0);
94 ilgen.Emit(OpCodes.Ldarg_1);
95
96 // FieldInfo testInfo = classBuilder.
97 //BindingFlags.NonPublic | BindingFlags.Instance);
98
99 //ilgen.Emit(OpCodes.Ldfld, testInfo);
100
101 //ilgen.EmitCall(OpCodes.Call, ExecuteFunction, executeFunctionTypeArray);
102 ilgen.EmitCall(OpCodes.Call, typeof(System.Console).GetMethod("WriteLine"), executeFunctionTypeArray);
103
104 // // string.Format("Hello, {0} World!", toWhom)
105 // //
106 // ilgen.Emit(OpCodes.Ldstr, "Hello, {0} World!");
107 // ilgen.Emit(OpCodes.Ldarg_1);
108 // ilgen.Emit(OpCodes.Call, typeof(string).GetMethod
109 //("Format", new Type[] { typeof(string), typeof(object) }));
110
111 // // m_log.Debug("Hello, World!");
112 // //
113 // ilgen.Emit(OpCodes.Call, typeof(Console).GetMethod
114 // ("WriteLine", new Type[] { typeof(string) }));
115 ilgen.Emit(OpCodes.Ret);
116
117
118
119 //Label eom = ilgen.DefineLabel();
120 //ilgen.Emit(OpCodes.Br_S, eom);
121 //ilgen.MarkLabel(eom);
122 //ilgen.Emit(OpCodes.Ret);
123 //Type test = methodBuilder.SetParameters();
124
125
126 //methodBuilder.SetParameters(typeof (object[]));
127
128
129 }
130 }
131
132
133 //// Two fields: m_firstname, m_lastname
134 //FieldBuilder fBuilderFirstName = classBuilder.DefineField("m_firstname", typeof(string), FieldAttributes.Private);
135 //FieldBuilder fBuilderLastName = classBuilder.DefineField("m_lastname", typeof(string), FieldAttributes.Private);
136
137 //// Two properties for this object: FirstName, LastName
138 //PropertyBuilder pBuilderFirstName = classBuilder.DefineProperty("FirstName", System.Reflection.PropertyAttributes.HasDefault, typeof(string), null);
139 //PropertyBuilder pBuilderLastName = classBuilder.DefineProperty("LastName", System.Reflection.PropertyAttributes.HasDefault, typeof(string), null);
140
141 //// Custom attributes for get, set accessors
142 //MethodAttributes getSetAttr = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName;
143
144 //// get,set accessors for FirstName
145 //MethodBuilder mGetFirstNameBuilder = classBuilder.DefineMethod("get_FirstName", getSetAttr, typeof(string), Type.EmptyTypes);
146
147 //// Code generation
148 //ilgen = mGetFirstNameBuilder.GetILGenerator();
149 //ilgen.Emit(OpCodes.Ldarg_0);
150 //ilgen.Emit(OpCodes.Ldfld, fBuilderFirstName); // returning the firstname field
151 //ilgen.Emit(OpCodes.Ret);
152
153 //MethodBuilder mSetFirstNameBuilder = classBuilder.DefineMethod("set_FirstName", getSetAttr, null, new Type[] { typeof(string) });
154
155 //// Code generation
156 //ilgen = mSetFirstNameBuilder.GetILGenerator();
157 //ilgen.Emit(OpCodes.Ldarg_0);
158 //ilgen.Emit(OpCodes.Ldarg_1);
159 //ilgen.Emit(OpCodes.Stfld, fBuilderFirstName); // setting the firstname field from the first argument (1)
160 //ilgen.Emit(OpCodes.Ret);
161
162 //// get,set accessors for LastName
163 //MethodBuilder mGetLastNameBuilder = classBuilder.DefineMethod("get_LastName", getSetAttr, typeof(string), Type.EmptyTypes);
164
165 //// Code generation
166 //ilgen = mGetLastNameBuilder.GetILGenerator();
167 //ilgen.Emit(OpCodes.Ldarg_0);
168 //ilgen.Emit(OpCodes.Ldfld, fBuilderLastName); // returning the firstname field
169 //ilgen.Emit(OpCodes.Ret);
170
171 //MethodBuilder mSetLastNameBuilder = classBuilder.DefineMethod("set_LastName", getSetAttr, null, new Type[] { typeof(string) });
172
173 //// Code generation
174 //ilgen = mSetLastNameBuilder.GetILGenerator();
175 //ilgen.Emit(OpCodes.Ldarg_0);
176 //ilgen.Emit(OpCodes.Ldarg_1);
177 //ilgen.Emit(OpCodes.Stfld, fBuilderLastName); // setting the firstname field from the first argument (1)
178 //ilgen.Emit(OpCodes.Ret);
179
180 //// Assigning get/set accessors
181 //pBuilderFirstName.SetGetMethod(mGetFirstNameBuilder);
182 //pBuilderFirstName.SetSetMethod(mSetFirstNameBuilder);
183
184 //pBuilderLastName.SetGetMethod(mGetLastNameBuilder);
185 //pBuilderLastName.SetSetMethod(mSetLastNameBuilder);
186
187 //// Now, a custom method named GetFullName that concatenates FirstName and LastName properties
188 //MethodBuilder mGetFullNameBuilder = classBuilder.DefineMethod("GetFullName", MethodAttributes.Public, typeof(string), Type.EmptyTypes);
189
190 //// Code generation
191 //ilgen = mGetFullNameBuilder.GetILGenerator();
192 //ilgen.Emit(OpCodes.Ldarg_0);
193 //ilgen.Emit(OpCodes.Call, mGetFirstNameBuilder); // getting the firstname
194 //ilgen.Emit(OpCodes.Ldstr, " "); // an space
195 //ilgen.Emit(OpCodes.Ldarg_0);
196 //ilgen.Emit(OpCodes.Call, mGetLastNameBuilder); // getting the lastname
197
198 //// We need the 'Concat' method from string type
199 //MethodInfo concatMethod = typeof(String).GetMethod("Concat", new Type[] { typeof(string), typeof(string), typeof(string) });
200
201 //ilgen.Emit(OpCodes.Call, concatMethod); // calling concat and returning the result
202 //ilgen.Emit(OpCodes.Ret);
203
204 //// Another constructor that initializes firstname and lastname
205 //ConstructorBuilder ctorBuilder2 = classBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(string), typeof(string) });
206 //ctorBuilder2.DefineParameter(1, ParameterAttributes.In, "firstname");
207 //ctorBuilder2.DefineParameter(2, ParameterAttributes.In, "lastname");
208
209 //// Code generation
210 //ilgen = ctorBuilder2.GetILGenerator();
211
212 //// First of all, we need to call the base constructor,
213 //// the Object's constructor in this sample
214 //Type objType = Type.GetType("System.Object");
215 //ConstructorInfo objCtor = objType.GetConstructor(Type.EmptyTypes);
216
217 //ilgen.Emit(OpCodes.Ldarg_0);
218 //ilgen.Emit(OpCodes.Call, objCtor); // calling the Object's constructor
219
220 //ilgen.Emit(OpCodes.Ldarg_0);
221 //ilgen.Emit(OpCodes.Ldarg_1);
222 //ilgen.Emit(OpCodes.Call, mSetFirstNameBuilder); // setting the firstname field from the first argument (1)
223 //ilgen.Emit(OpCodes.Ldarg_0);
224 //ilgen.Emit(OpCodes.Ldarg_2);
225 //ilgen.Emit(OpCodes.Call, mSetLastNameBuilder); // setting the lastname field from the second argument (2)
226 //ilgen.Emit(OpCodes.Ret);
227
228 // Finally, create the type and save the assembly
229 classBuilder.CreateType();
230
231 asmBuilder.Save(asmFileName);
232 string toFile = Path.Combine(moveToDir, asmFileName);
233 if (File.Exists(toFile))
234 File.Delete(toFile);
235 File.Move(asmFileName, toFile);
236
237 //string a = "";
238 }
239 }
240}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/LoadUnloadStructure.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/LoadUnloadStructure.cs
deleted file mode 100644
index 9468c18..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/LoadUnloadStructure.cs
+++ /dev/null
@@ -1,49 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.ScriptEngine.Shared;
32
33namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
34{
35 public struct LoadUnloadStructure
36 {
37 public ScriptStructure Script;
38 public LUType Action;
39 public bool PostOnRez;
40 public int StartParam;
41
42 public enum LUType
43 {
44 Unknown = 0,
45 Load = 1,
46 Unload = 2
47 }
48 }
49}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/Properties/AssemblyInfo.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/Properties/AssemblyInfo.cs
deleted file mode 100644
index 1831e50..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// General Information about an assembly is controlled through the following
33// set of attributes. Change these attribute values to modify the information
34// associated with an assembly.
35[assembly: AssemblyTitle("OpenSim.Grid.ScriptEngine.Components.DefaultScheduler")]
36[assembly: AssemblyDescription("")]
37[assembly: AssemblyConfiguration("")]
38[assembly: AssemblyCompany("http://opensimulator.org")]
39[assembly: AssemblyProduct("OpenSim.Grid.ScriptEngine.Components.DefaultScheduler")]
40[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
41[assembly: AssemblyTrademark("")]
42[assembly: AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47[assembly: ComVisible(false)]
48
49// The following GUID is for the ID of the typelib if this project is exposed to COM
50[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
51
52// Version information for an assembly consists of the following four values:
53//
54// Major Version
55// Minor Version
56// Build Number
57// Revision
58//
59// You can specify all the values or you can default the Build and Revision Numbers
60// by using the '*' as shown below:
61// [assembly: AssemblyVersion("0.6.5.*")]
62[assembly: AssemblyVersion("0.6.5.*")]
63[assembly: AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/Scheduler.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/Scheduler.cs
deleted file mode 100644
index 8c36764..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/Scheduler.cs
+++ /dev/null
@@ -1,55 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30using OpenMetaverse;
31using OpenSim.ScriptEngine.Shared;
32
33namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
34{
35 public class Scheduler : IScriptScheduler
36 {
37
38 private ScriptManager m_ScriptManager = new ScriptManager();
39 public void AddScript(ScriptStructure scriptStructure)
40 {
41 m_ScriptManager.AddScript(scriptStructure);
42 }
43
44 public void Removecript(uint id, UUID itemID)
45 {
46 m_ScriptManager.RemoveScript(id, itemID);
47 }
48
49 public void Close()
50 {
51 m_ScriptManager.Close();
52 }
53
54 }
55}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptLoader.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptLoader.cs
deleted file mode 100644
index 3c20f20..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptLoader.cs
+++ /dev/null
@@ -1,216 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using OpenSim.ScriptEngine.Shared;
34using IScript=OpenSim.Region.ScriptEngine.Shared.ScriptBase.IScript;
35
36namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
37{
38 public class ScriptLoader : IScriptLoader
39 {
40 //
41 // This class does AppDomain handling and loading/unloading of
42 // scripts in it. It is instanced in "ScriptEngine" and controlled
43 // from "ScriptManager"
44 //
45 // 1. Create a new AppDomain if old one is full (or doesn't exist)
46 // 2. Load scripts into AppDomain
47 // 3. Unload scripts from AppDomain (stopping them and marking
48 // them as inactive)
49 // 4. Unload AppDomain completely when all scripts in it has stopped
50 //
51
52 public string Name { get { return "SECS.DotNetEngine.Scheduler.ScriptLoader"; } }
53 private int maxScriptsPerAppDomain = 10;
54
55 // Internal list of all AppDomains
56 private List<AppDomainStructure> appDomains =
57 new List<AppDomainStructure>();
58 private Dictionary<string, AppDomainStructure> AppDomainFiles = new Dictionary<string, AppDomainStructure>();
59 public readonly string[] AssembliesInAppDomain = new string[] { "OpenSim.ScriptEngine.Shared.Script.dll", "OpenSim.Region.ScriptEngine.Shared.dll" };
60
61 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
62
63 // Structure to keep track of data around AppDomain
64 private class AppDomainStructure
65 {
66 public AppDomain CurrentAppDomain; // The AppDomain itself
67 public int ScriptsLoaded; // Number of scripts loaded into AppDomain
68 public int ScriptsWaitingUnload; // Number of dead scripts
69 }
70
71 // Current AppDomain
72 private AppDomainStructure currentAD;
73
74 private object getLock = new object(); // Mutex
75 private object freeLock = new object(); // Mutex
76
77 // Find a free AppDomain, creating one if necessary
78 private AppDomainStructure GetFreeAppDomain()
79 {
80 lock (getLock)
81 {
82 // Current full?
83 if (currentAD != null &&
84 currentAD.ScriptsLoaded >= maxScriptsPerAppDomain)
85 {
86 // Add it to AppDomains list and empty current
87 appDomains.Add(currentAD);
88 currentAD = null;
89 }
90 // No current
91 if (currentAD == null)
92 {
93 // Create a new current AppDomain
94 currentAD = new AppDomainStructure();
95 currentAD.CurrentAppDomain = PrepareNewAppDomain();
96 }
97
98 return currentAD;
99 }
100 }
101
102 private int AppDomainNameCount;
103 public ScriptAssemblies.IScript LoadScript(ScriptStructure script)
104 {
105 // Find next available AppDomain to put it in
106 AppDomainStructure FreeAppDomain;
107
108 // If we already have loaded file, then reuse that AppDomains
109 if (AppDomainFiles.ContainsKey(script.AssemblyFileName))
110 FreeAppDomain = AppDomainFiles[script.AssemblyFileName];
111 else
112 FreeAppDomain = GetFreeAppDomain();
113
114 // Set script object AppDomain
115 script.AppDomain = FreeAppDomain.CurrentAppDomain;
116
117 // Create instance of script
118 ScriptAssemblies.IScript mbrt = (ScriptAssemblies.IScript)
119 FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(
120 script.AssemblyFileName, "ScriptAssemblies.Script");
121 //, true, BindingFlags.CreateInstance, null);
122 FreeAppDomain.ScriptsLoaded++;
123
124 return mbrt;
125 }
126
127 // Create and prepare a new AppDomain for scripts
128 private AppDomain PrepareNewAppDomain()
129 {
130 // Create and prepare a new AppDomain
131 AppDomainNameCount++;
132
133 // TODO: Currently security match current appdomain
134
135 // Construct and initialize settings for a second AppDomain.
136 AppDomainSetup ads = new AppDomainSetup();
137 ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
138 ads.DisallowBindingRedirects = true;
139 ads.DisallowCodeDownload = true;
140 ads.LoaderOptimization = LoaderOptimization.MultiDomainHost;
141 ads.ShadowCopyFiles = "false"; // Disable shadowing
142 ads.ConfigurationFile =
143 AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
144
145 AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" +
146 AppDomainNameCount, null, ads);
147
148 foreach (string file in AssembliesInAppDomain)
149 {
150 m_log.InfoFormat("[{0}] AppDomain Loading: \"{1}\"->\"{2}\".", Name, file,
151 AssemblyName.GetAssemblyName(file).ToString());
152 AD.Load(AssemblyName.GetAssemblyName(file));
153 }
154
155 // Return the new AppDomain
156 return AD;
157 }
158
159 // Unload appdomains that are full and have only dead scripts
160 private void UnloadAppDomains()
161 {
162 lock (freeLock)
163 {
164 // Go through all
165 foreach (AppDomainStructure ads in new ArrayList(appDomains))
166 {
167 // Don't process current AppDomain
168 if (ads.CurrentAppDomain != currentAD.CurrentAppDomain)
169 {
170 // Not current AppDomain
171 // Is number of unloaded bigger or equal to number of loaded?
172 if (ads.ScriptsLoaded <= ads.ScriptsWaitingUnload)
173 {
174 // Remove from internal list
175 appDomains.Remove(ads);
176
177 // Unload
178 AppDomain.Unload(ads.CurrentAppDomain);
179 }
180 }
181 }
182 }
183 }
184
185 // Increase "dead script" counter for an AppDomain
186 public void StopScript(AppDomain ad)
187 {
188 lock (freeLock)
189 {
190 // Check if it is current AppDomain
191 if (currentAD.CurrentAppDomain == ad)
192 {
193 // Yes - increase
194 currentAD.ScriptsWaitingUnload++;
195 return;
196 }
197
198 // Lopp through all AppDomains
199 foreach (AppDomainStructure ads in new ArrayList(appDomains))
200 {
201 if (ads.CurrentAppDomain == ad)
202 {
203 // Found it
204 ads.ScriptsWaitingUnload++;
205 break;
206 }
207 }
208 }
209
210 UnloadAppDomains(); // Outsite lock, has its own GetLock
211 }
212
213
214
215 }
216} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptManager.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptManager.cs
deleted file mode 100644
index 3dad902..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptManager.cs
+++ /dev/null
@@ -1,203 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Diagnostics;
31using System.Reflection;
32using System.Text;
33using System.Threading;
34using log4net;
35using OpenMetaverse;
36using OpenSim.Region.ScriptEngine.Shared;
37using OpenSim.ScriptEngine.Shared;
38using EventParams=OpenSim.ScriptEngine.Shared.EventParams;
39
40namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
41{
42 public partial class ScriptManager: IScriptExecutor
43 {
44 private const int NoWorkSleepMs = 50;
45 private const int NoWorkSleepMsInc = 1; // How much time to increase wait with on every iteration
46 private const int NoWorkSleepMsIncMax = 300; // Max time to wait
47
48 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 public string Name { get { return "SECS.DotNetEngine.ScriptManager"; } }
50 private static Thread ScriptLoadUnloadThread;
51 public Dictionary<uint, Dictionary<UUID, ScriptStructure>> Scripts = new Dictionary<uint, Dictionary<UUID, ScriptStructure>>();
52
53 private RegionInfoStructure CurrentRegion;
54 public void Initialize(RegionInfoStructure currentRegion)
55 {
56 CurrentRegion = currentRegion;
57 }
58
59 public ScriptManager()
60 {
61 ScriptLoadUnloadThread = new Thread(LoadUnloadLoop);
62 ScriptLoadUnloadThread.Name = "ScriptLoadUnloadThread";
63 ScriptLoadUnloadThread.IsBackground = true;
64 ScriptLoadUnloadThread.Start();
65 }
66 public void Close() { }
67
68 private void LoadUnloadLoop ()
69 {
70 int _NoWorkSleepMsInc = 0;
71 while (true)
72 {
73 if (DoScriptLoadUnload())
74 {
75 // We found work, reset counter
76 _NoWorkSleepMsInc = NoWorkSleepMs;
77 } else
78 {
79 // We didn't find work
80 // Sleep
81 Thread.Sleep(NoWorkSleepMs + NoWorkSleepMsInc);
82 // Increase sleep delay
83 _NoWorkSleepMsInc += NoWorkSleepMsInc;
84 // Make sure we don't exceed max
85 if (_NoWorkSleepMsInc > NoWorkSleepMsIncMax)
86 _NoWorkSleepMsInc = NoWorkSleepMsIncMax;
87 }
88 }
89 }
90
91 #region Add/Remove/Find script functions for our Script memory structure
92 private void MemAddScript(ScriptStructure script)
93 {
94 lock (scriptLock)
95 {
96 // Create object if it doesn't exist
97 if (!Scripts.ContainsKey(script.LocalID))
98 Scripts.Add(script.LocalID, new Dictionary<UUID, ScriptStructure>());
99
100 // Delete script if it exists
101 Dictionary<UUID, ScriptStructure> Obj;
102 if (Scripts.TryGetValue(script.LocalID, out Obj))
103 if (Obj.ContainsKey(script.ItemID) == true)
104 Obj.Remove(script.ItemID);
105
106 // Add to object
107 Obj.Add(script.ItemID, script);
108 }
109 }
110 private void MemRemoveScript(uint LocalID, UUID ItemID)
111 {
112 // TODO: Also clean up command queue and async commands for object
113 lock (scriptLock)
114 {
115 // Create object if it doesn't exist
116 if (!Scripts.ContainsKey(LocalID))
117 return;
118
119 // Delete script if it exists
120 Dictionary<UUID, ScriptStructure> Obj;
121 if (Scripts.TryGetValue(LocalID, out Obj))
122 if (Obj.ContainsKey(ItemID) == true)
123 Obj.Remove(ItemID);
124
125 // Empty?
126 if (Obj.Count == 0)
127 Scripts.Remove(LocalID);
128
129 }
130 }
131 public bool TryGetScript(uint localID, UUID itemID, ref ScriptStructure script)
132 {
133 lock (scriptLock)
134 {
135
136 if (Scripts.ContainsKey(localID) == false)
137 return false;
138
139 Dictionary<UUID, ScriptStructure> Obj;
140 if (Scripts.TryGetValue(localID, out Obj))
141 if (Obj.ContainsKey(itemID) == false)
142 return false;
143
144 // Get script
145 return Obj.TryGetValue(itemID, out script);
146 }
147 }
148 public ScriptStructure GetScript(uint localID, UUID itemID)
149 {
150 lock (scriptLock)
151 {
152
153 if (Scripts.ContainsKey(localID) == false)
154 throw new Exception("No script with LocalID " + localID + " was found.");
155
156 Dictionary<UUID, ScriptStructure> Obj;
157 if (Scripts.TryGetValue(localID, out Obj))
158 if (Obj.ContainsKey(itemID) == false)
159 throw new Exception("No script with ItemID " + itemID + " was found.");
160
161 // Get script
162 return Obj[itemID];
163 }
164 }
165 public bool TryGetScripts(uint localID, ref Dictionary<UUID, ScriptStructure> returnList)
166 {
167 Dictionary<UUID, ScriptStructure> getList = GetScripts(localID);
168 if (getList != null)
169 {
170 returnList = getList;
171 return true;
172 }
173 return false;
174 }
175 public Dictionary<UUID, ScriptStructure> GetScripts(uint localID)
176 {
177 lock (scriptLock)
178 {
179
180 if (Scripts.ContainsKey(localID) == false)
181 return null;
182 return Scripts[localID];
183 }
184 }
185 #endregion
186
187 public void ExecuteCommand(EventParams p)
188 {
189 ScriptStructure ss = new ScriptStructure();
190 if (TryGetScript(p.LocalID, p.ItemID, ref ss))
191 ExecuteCommand(ref ss, p);
192 }
193
194 public void ExecuteCommand(ref ScriptStructure scriptContainer, EventParams p)
195 {
196 m_log.DebugFormat("[{0}] ######################################################", Name);
197 m_log.DebugFormat("[{0}] Command execution ItemID {1}: \"{2}\".", Name, scriptContainer.ItemID, p.EventName);
198 scriptContainer.ExecuteEvent(p);
199 m_log.DebugFormat("[{0}] ######################################################", Name);
200 }
201
202 }
203}
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptManager_ScriptLoadUnload.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptManager_ScriptLoadUnload.cs
deleted file mode 100644
index dd72dbf..0000000
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler/ScriptManager_ScriptLoadUnload.cs
+++ /dev/null
@@ -1,287 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Globalization;
31using System.Reflection;
32using System.Text;
33using System.Threading;
34using log4net;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Region.ScriptEngine.Interfaces;
39using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
40using OpenSim.ScriptEngine.Shared;
41
42namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
43{
44 public partial class ScriptManager
45 {
46 private Queue<LoadUnloadStructure> LUQueue = new Queue<LoadUnloadStructure>();
47 private int LoadUnloadMaxQueueSize = 500;
48 private Object scriptLock = new Object();
49 //private Dictionary<InstanceData, DetectParams[]> detparms = new Dictionary<InstanceData, DetectParams[]>();
50
51 // Load/Unload structure
52
53
54 public void AddScript(ScriptStructure script)
55 {
56 lock (LUQueue)
57 {
58 if ((LUQueue.Count >= LoadUnloadMaxQueueSize))
59 {
60 m_log.ErrorFormat("[{0}] ERROR: Load queue count is at {1} of max {2}. Ignoring load request for script LocalID: {3}, ItemID: {4}.",
61 Name, LUQueue.Count, LoadUnloadMaxQueueSize, script.LocalID, script.ItemID);
62 return;
63 }
64
65 LoadUnloadStructure ls = new LoadUnloadStructure();
66 ls.Script = script;
67 ls.Action = LoadUnloadStructure.LUType.Load;
68 LUQueue.Enqueue(ls);
69 }
70
71 }
72 public void RemoveScript(uint localID, UUID itemID)
73 {
74 LoadUnloadStructure ls = new LoadUnloadStructure();
75
76 // See if we can find script
77 if (!TryGetScript(localID, itemID, ref ls.Script))
78 {
79 // Set manually
80 ls.Script.LocalID = localID;
81 ls.Script.ItemID = itemID;
82 }
83 ls.Script.StartParam = 0;
84
85 ls.Action = LoadUnloadStructure.LUType.Unload;
86 ls.PostOnRez = false;
87
88 lock (LUQueue)
89 {
90 LUQueue.Enqueue(ls);
91 }
92 }
93
94 internal bool DoScriptLoadUnload()
95 {
96 bool ret = false;
97 // if (!m_started)
98 // return;
99
100 lock (LUQueue)
101 {
102 if (LUQueue.Count > 0)
103 {
104 LoadUnloadStructure item = LUQueue.Dequeue();
105 ret = true;
106
107 if (item.Action == LoadUnloadStructure.LUType.Unload)
108 {
109 _StopScript(item.Script.LocalID, item.Script.ItemID);
110 RemoveScript(item.Script.LocalID, item.Script.ItemID);
111 }
112 else if (item.Action == LoadUnloadStructure.LUType.Load)
113 {
114 m_log.DebugFormat("[{0}] Loading script", Name);
115 _StartScript(item);
116 }
117 }
118 }
119 return ret;
120 }
121
122 //public void _StartScript(uint localID, UUID itemID, string Script, int startParam, bool postOnRez)
123 private void _StartScript(LoadUnloadStructure ScriptObject)
124 {
125 m_log.DebugFormat(
126 "[{0}]: ScriptManager StartScript: localID: {1}, itemID: {2}",
127 Name, ScriptObject.Script.LocalID, ScriptObject.Script.ItemID);
128
129 // We will initialize and start the script.
130 // It will be up to the script itself to hook up the correct events.
131
132 SceneObjectPart m_host = ScriptObject.Script.RegionInfo.Scene.GetSceneObjectPart(ScriptObject.Script.LocalID);
133
134 if (null == m_host)
135 {
136 m_log.ErrorFormat(
137 "[{0}]: Could not find scene object part corresponding " +
138 "to localID {1} to start script",
139 Name, ScriptObject.Script.LocalID);
140
141 return;
142 }
143
144 //UUID assetID = UUID.Zero;
145 TaskInventoryItem taskInventoryItem = new TaskInventoryItem();
146 //if (m_host.TaskInventory.TryGetValue(ScriptObject.Script.ItemID, out taskInventoryItem))
147 // assetID = taskInventoryItem.AssetID;
148
149 ScenePresence presence =
150 ScriptObject.Script.RegionInfo.Scene.GetScenePresence(taskInventoryItem.OwnerID);
151
152 CultureInfo USCulture = new CultureInfo("en-US");
153 Thread.CurrentThread.CurrentCulture = USCulture;
154
155 try
156 {
157 //
158 // Compile script to an assembly
159 //
160 //TODO: DEBUG
161 BaseClassFactory.MakeBaseClass(ScriptObject.Script);
162
163 m_log.DebugFormat("[{0}] Compiling script {1}", Name, ScriptObject.Script.Name);
164
165 string fileName = "";
166 try
167 {
168 IScriptCompiler compiler =
169 ScriptObject.Script.RegionInfo.FindCompiler(ScriptObject.Script.ScriptMetaData);
170 //RegionInfoStructure currentRegionInfo = ScriptObject.Script.RegionInfo;
171 fileName = compiler.Compile(ScriptObject.Script.ScriptMetaData,
172 ref ScriptObject.Script.Source);
173 ScriptObject.Script.AssemblyFileName = fileName;
174 }
175 catch (Exception e)
176 {
177 m_log.ErrorFormat("[{0}] Internal error while compiling \"{1}\": {2}", Name, ScriptObject.Script.Name, e.ToString());
178 }
179 m_log.DebugFormat("[{0}] Compiled \"{1}\" to assembly: \"{2}\".", Name, ScriptObject.Script.Name, fileName);
180
181 // Add it to our script memstruct
182 MemAddScript(ScriptObject.Script);
183
184 ScriptAssemblies.IScript CompiledScript;
185 CompiledScript = CurrentRegion.ScriptLoader.LoadScript(ScriptObject.Script);
186 ScriptObject.Script.State = "default";
187 ScriptObject.Script.ScriptObject = CompiledScript;
188 ScriptObject.Script.Disabled = false;
189 ScriptObject.Script.Running = true;
190 //id.LineMap = LSLCompiler.LineMap();
191 //id.Script = CompiledScript;
192 //id.Source = item.Script.Script;
193 //item.StartParam = startParam;
194
195
196
197 // TODO: Fire the first start-event
198 //int eventFlags =
199 // m_scriptEngine.m_ScriptManager.GetStateEventFlags(
200 // localID, itemID);
201
202 //m_host.SetScriptEvents(itemID, eventFlags);
203 ScriptObject.Script.RegionInfo.Executors_Execute(ScriptObject.Script,
204 new EventParams(ScriptObject.Script.LocalID, ScriptObject.Script.ItemID, "state_entry", new object[] { }, new Region.ScriptEngine.Shared.DetectParams[0])
205 );
206
207 if (ScriptObject.PostOnRez)
208 {
209 ScriptObject.Script.RegionInfo.Executors_Execute(ScriptObject.Script,
210 new EventParams(ScriptObject.Script.LocalID, "on_rez", new object[]
211 {new Region.ScriptEngine.Shared.LSL_Types.LSLInteger(ScriptObject.StartParam)
212 }, new Region.ScriptEngine.Shared.DetectParams[0]));
213 }
214 }
215 catch (Exception e) // LEGIT: User Scripting
216 {
217 if (presence != null && (!ScriptObject.PostOnRez))
218 presence.ControllingClient.SendAgentAlertMessage(
219 "Script saved with errors, check debug window!",
220 false);
221 try
222 {
223 // DISPLAY ERROR INWORLD
224 string text = "Error compiling script:\n" +
225 e.Message.ToString();
226 if (text.Length > 1100)
227 text = text.Substring(0, 1099);
228
229 ScriptObject.Script.RegionInfo.Scene.SimChat(Utils.StringToBytes(text),
230 ChatTypeEnum.DebugChannel, 2147483647,
231 m_host.AbsolutePosition, m_host.Name, m_host.UUID,
232 false);
233 }
234 catch (Exception e2) // LEGIT: User Scripting
235 {
236 m_log.Error("[" +
237 Name +
238 "]: Error displaying error in-world: " +
239 e2.ToString());
240 m_log.Error("[" +
241 Name + "]: " +
242 "Errormessage: Error compiling script:\r\n" +
243 e2.Message.ToString());
244 }
245 }
246 }
247
248
249
250 public void _StopScript(uint localID, UUID itemID)
251 {
252 ScriptStructure ss = new ScriptStructure();
253 if (!TryGetScript(localID, itemID, ref ss))
254 return;
255
256 m_log.DebugFormat("[{0}] Unloading script", Name);
257
258 // Stop long command on script
259 //AsyncCommandManager.RemoveScript(ss);
260
261 try
262 {
263 // Get AppDomain
264 // Tell script not to accept new requests
265 ss.Running = false;
266 ss.Disabled = true;
267 //AppDomain ad = ss.AppDomain;
268
269 // Remove from internal structure
270 MemRemoveScript(localID, itemID);
271
272 // TODO: Tell AppDomain that we have stopped script
273
274 }
275 catch (Exception e) // LEGIT: User Scripting
276 {
277 m_log.Error("[" +
278 Name +
279 "]: Exception stopping script localID: " +
280 localID + " LLUID: " + itemID.ToString() +
281 ": " + e.ToString());
282 }
283 }
284
285
286 }
287}
diff --git a/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine.cs b/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine.cs
deleted file mode 100644
index 3b8a0ae..0000000
--- a/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine.cs
+++ /dev/null
@@ -1,196 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30using System.Text;
31using System.Text.RegularExpressions;
32using log4net;
33using Nini.Config;
34using OpenMetaverse;
35using OpenSim.ApplicationPlugins.ScriptEngine;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.ScriptEngine.Components.DotNetEngine.Events;
39using OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler;
40using OpenSim.ScriptEngine.Shared;
41using ComponentFactory = OpenSim.ApplicationPlugins.ScriptEngine.ComponentFactory;
42
43namespace OpenSim.ScriptEngine.Engines.DotNetEngine
44{
45 // This is a sample engine
46 public partial class DotNetEngine : IScriptEngine
47 {
48
49 //private string[] _ComponentNames = new string[] {
50 // "Commands_LSL",
51 // "Commands_OSSL",
52 // "Compiler_CS",
53 // "Compiler_JS",
54 // "Compiler_LSL",
55 // "Compiler_VB",
56 // "LSLEventProvider",
57 // "Scheduler"
58 // };
59 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
60
61 public string Name { get { return "SECS.DotNetEngine"; } }
62 //public bool IsSharedModule { get { return true; } }
63 internal RegionInfoStructure RegionInfo;
64
65 private string[] commandNames = new string[]
66 {
67 "Commands_LSL"
68 };
69
70 private string[] compilerNames = new string[]
71 {
72 "Compiler_CS",
73 "Compiler_JS",
74 "Compiler_LSL",
75 "Compiler_YP",
76 "Compiler_VB"
77 };
78 private string[] schedulerNames = new string[]
79 {
80 "Scheduler"
81 };
82
83 //internal IScriptLoader m_ScriptLoader;
84 internal LSLEventProvider m_LSLEventProvider;
85 //internal IScriptExecutor m_Executor;
86 //internal Dictionary<string, IScriptCompiler> Compilers = new Dictionary<string, IScriptCompiler>();
87 internal Dictionary<string, IScriptScheduler> Schedulers = new Dictionary<string, IScriptScheduler>();
88 public static Dictionary<string, IScriptCompiler> Compilers = new Dictionary<string, IScriptCompiler>();
89// private static bool haveInitialized = false;
90
91 public DotNetEngine()
92 {
93 RegionInfo = new RegionInfoStructure();
94 RegionInfo.Compilers = Compilers;
95 RegionInfo.Schedulers = Schedulers;
96 RegionInfo.Executors = new Dictionary<string, IScriptExecutor>();
97 RegionInfo.CommandProviders = new Dictionary<string, IScriptCommandProvider>();
98 RegionInfo.EventProviders = new Dictionary<string, IScriptEventProvider>();
99 }
100
101 public void Initialise(Scene scene, IConfigSource source)
102 {
103 RegionInfo.Scene = scene;
104 RegionInfo.ConfigSource = source;
105
106 m_log.DebugFormat("[{0}] Initializing components", Name);
107 InitializeComponents();
108 }
109
110 public void PostInitialise() { }
111
112 /// <summary>
113 /// Called on region close
114 /// </summary>
115 public void Close()
116 {
117 ComponentClose();
118 }
119 #region Initialize the Script Engine Components we need
120 public void InitializeComponents()
121 {
122 string cname = "";
123 m_log.DebugFormat("[{0}] Component initialization", Name);
124 // Initialize an instance of all module we want
125 try
126 {
127 cname = "ScriptManager";
128 m_log.DebugFormat("[{0}] Executor: {1}", Name, cname);
129 RegionInfo.Executors.Add(cname,
130 ComponentFactory.GetComponentInstance(RegionInfo, cname) as IScriptExecutor);
131
132 cname = "ScriptLoader";
133 m_log.DebugFormat("[{0}] ScriptLoader: {1}", Name, cname);
134 RegionInfo.ScriptLoader =
135 ComponentFactory.GetComponentInstance(RegionInfo, cname) as IScriptExecutor as ScriptLoader;
136
137 // CommandProviders
138 foreach (string cn in commandNames)
139 {
140 cname = cn;
141 m_log.DebugFormat("[{0}] CommandProvider: {1}", Name, cname);
142 RegionInfo.CommandProviders.Add(cname,
143 ComponentFactory.GetComponentInstance(RegionInfo, cname) as
144 IScriptCommandProvider);
145 }
146
147 // Compilers
148 foreach (string cn in compilerNames)
149 {
150 cname = cn;
151 m_log.DebugFormat("[{0}] Compiler: {1}", Name, cname);
152 RegionInfo.Compilers.Add(cname,
153 ComponentFactory.GetComponentInstance(RegionInfo, cname) as
154 IScriptCompiler);
155 }
156
157 // Schedulers
158 foreach (string cn in schedulerNames)
159 {
160 cname = cn;
161 m_log.DebugFormat("[{0}] Scheduler: {1}", Name, cname);
162 RegionInfo.Schedulers.Add(cname,
163 ComponentFactory.GetComponentInstance(RegionInfo, cname) as
164 IScriptScheduler);
165 }
166
167 // Event provider
168 cname = "LSLEventProvider";
169 m_log.DebugFormat("[{0}] EventProvider: {1}", Name, cname);
170 IScriptEventProvider sep = ComponentFactory.GetComponentInstance(RegionInfo, cname) as IScriptEventProvider;
171 RegionInfo.EventProviders.Add(cname, sep);
172 m_LSLEventProvider = sep as LSLEventProvider;
173
174 // Hook up events
175 m_LSLEventProvider.RezScript += Events_RezScript;
176 m_LSLEventProvider.RemoveScript += Events_RemoveScript;
177 }
178 catch (Exception e)
179 {
180 m_log.ErrorFormat("[{0}] Exception while loading \"{1}\": {2}", Name, cname, e.ToString());
181 }
182 }
183
184 private void ComponentClose()
185 {
186 // Close schedulers
187 foreach (IScriptScheduler scheduler in RegionInfo.Schedulers.Values)
188 {
189 scheduler.Close();
190 }
191 }
192
193 #endregion
194
195 }
196}
diff --git a/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine_ScriptLoadUnload.cs b/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine_ScriptLoadUnload.cs
deleted file mode 100644
index a113c1e..0000000
--- a/OpenSim/ScriptEngine/Engines/DotNetEngine/DotNetEngine_ScriptLoadUnload.cs
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenMetaverse;
32using OpenSim.ScriptEngine.Components.DotNetEngine.Events;
33using OpenSim.ScriptEngine.Shared;
34
35namespace OpenSim.ScriptEngine.Engines.DotNetEngine
36{
37 public partial class DotNetEngine
38 {
39
40 //internal Dictionary<int, IScriptScheduler> ScriptMapping = new Dictionary<int, IScriptScheduler>();
41
42
43 //
44 // HANDLE EVENTS FROM SCRIPTS
45 // We will handle script add, change and remove events outside of command pipeline
46 //
47 #region Script Add/Change/Remove
48 void Events_RezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
49 {
50 // ###
51 // # New script created
52 // ###
53 m_log.DebugFormat(
54 "[{0}] NEW SCRIPT: localID: {1}, itemID: {2}, startParam: {3}, postOnRez: {4}, engine: {5}",
55 Name, localID, itemID, startParam, postOnRez, engine);
56
57 // Make a script object
58 ScriptStructure scriptObject = new ScriptStructure();
59 scriptObject.RegionInfo = RegionInfo;
60 scriptObject.LocalID = localID;
61 scriptObject.ItemID = itemID;
62 scriptObject.Source = script;
63
64 //
65 // Get MetaData from script header
66 //
67 ScriptMetaData scriptMetaData = ScriptMetaData.Extract(ref script);
68 scriptObject.ScriptMetaData = scriptMetaData;
69 foreach (string key in scriptObject.ScriptMetaData.Keys)
70 {
71 m_log.DebugFormat("[{0}] Script metadata: Key: \"{1}\", Value: \"{2}\".", Name, key, scriptObject.ScriptMetaData[key]);
72 }
73
74 //
75 // Load this assembly
76 //
77 // TODO: Use Executor to send a command instead?
78 m_log.DebugFormat("[{0}] Adding script to scheduler", Name);
79 RegionInfo.FindScheduler(scriptObject.ScriptMetaData).AddScript(scriptObject);
80 // Add to our internal mapping
81 //ScriptMapping.Add(itemID, Schedulers[scheduler]);
82 }
83
84 private void Events_RemoveScript(uint localID, UUID itemID)
85 {
86 // Tell all schedulers to remove this item
87 foreach (IScriptScheduler scheduler in RegionInfo.Schedulers.Values)
88 {
89 scheduler.Removecript(localID, itemID);
90 }
91 }
92 #endregion
93
94 }
95}
diff --git a/OpenSim/ScriptEngine/Engines/DotNetEngine/Properties/AssemblyInfo.cs b/OpenSim/ScriptEngine/Engines/DotNetEngine/Properties/AssemblyInfo.cs
deleted file mode 100644
index bca9c2c..0000000
--- a/OpenSim/ScriptEngine/Engines/DotNetEngine/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// General Information about an assembly is controlled through the following
33// set of attributes. Change these attribute values to modify the information
34// associated with an assembly.
35[assembly: AssemblyTitle("OpenSim.ScriptEngine.Engines.DotNetEngine")]
36[assembly: AssemblyDescription("")]
37[assembly: AssemblyConfiguration("")]
38[assembly: AssemblyCompany("http://opensimulator.org")]
39[assembly: AssemblyProduct("OpenSim.ScriptEngine.Engines.DotNetEngine")]
40[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
41[assembly: AssemblyTrademark("")]
42[assembly: AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47[assembly: ComVisible(false)]
48
49// The following GUID is for the ID of the typelib if this project is exposed to COM
50[assembly: Guid("1d1c68a7-026f-4556-a060-4af69f488d2a")]
51
52// Version information for an assembly consists of the following four values:
53//
54// Major Version
55// Minor Version
56// Build Number
57// Revision
58//
59// You can specify all the values or you can default the Build and Revision Numbers
60// by using the '*' as shown below:
61// [assembly: AssemblyVersion("0.6.5.*")]
62[assembly: AssemblyVersion("0.6.5.*")]
63[assembly: AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/ScriptEngine/Shared.Script/ICommandProvider.cs b/OpenSim/ScriptEngine/Shared.Script/ICommandProvider.cs
deleted file mode 100644
index 6a02a4a..0000000
--- a/OpenSim/ScriptEngine/Shared.Script/ICommandProvider.cs
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace ScriptAssemblies
33{
34 public interface ICommandProvider
35 {
36 void ExecuteCommand(string functionName, params object[] args);
37 string Name { get; }
38 }
39}
diff --git a/OpenSim/ScriptEngine/Shared.Script/IScript.cs b/OpenSim/ScriptEngine/Shared.Script/IScript.cs
deleted file mode 100644
index 6afb4d5..0000000
--- a/OpenSim/ScriptEngine/Shared.Script/IScript.cs
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace ScriptAssemblies
33{
34 public interface IScript
35 {
36 void ExecuteFunction(string functionName, params object[] args);
37 }
38} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared.Script/Properties/AssemblyInfo.cs b/OpenSim/ScriptEngine/Shared.Script/Properties/AssemblyInfo.cs
deleted file mode 100644
index 090cb44..0000000
--- a/OpenSim/ScriptEngine/Shared.Script/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// General Information about an assembly is controlled through the following
33// set of attributes. Change these attribute values to modify the information
34// associated with an assembly.
35[assembly: AssemblyTitle("OpenSim.ScriptEngine.Shared.Script")]
36[assembly: AssemblyDescription("")]
37[assembly: AssemblyConfiguration("")]
38[assembly: AssemblyCompany("http://opensimulator.org")]
39[assembly: AssemblyProduct("OpenSim.ScriptEngine.Shared.Script")]
40[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
41[assembly: AssemblyTrademark("")]
42[assembly: AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47[assembly: ComVisible(false)]
48
49// The following GUID is for the ID of the typelib if this project is exposed to COM
50[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
51
52// Version information for an assembly consists of the following four values:
53//
54// Major Version
55// Minor Version
56// Build Number
57// Revision
58//
59// You can specify all the values or you can default the Build and Revision Numbers
60// by using the '*' as shown below:
61// [assembly: AssemblyVersion("0.6.5.*")]
62[assembly: AssemblyVersion("0.6.5.*")]
63[assembly: AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/ScriptEngine/Shared.Script/ScriptBase.cs b/OpenSim/ScriptEngine/Shared.Script/ScriptBase.cs
deleted file mode 100644
index ab7835d..0000000
--- a/OpenSim/ScriptEngine/Shared.Script/ScriptBase.cs
+++ /dev/null
@@ -1,72 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Runtime.Remoting.Lifetime;
32using System.Text;
33
34namespace ScriptAssemblies
35{
36 public class ScriptBase : MarshalByRefObject, IScript
37 {
38
39 #region AppDomain Serialization Keep-Alive
40 //
41 // Never expire this object
42 //
43 public override Object InitializeLifetimeService()
44 {
45 ILease lease = (ILease)base.InitializeLifetimeService();
46
47 if (lease.CurrentState == LeaseState.Initial)
48 {
49 lease.InitialLeaseTime = TimeSpan.Zero;
50 }
51 return lease;
52 }
53 #endregion
54
55 public delegate void ExecuteFunctionEventDelegate(string functionName, params object[] args);
56 public event ExecuteFunctionEventDelegate OnExecuteFunction;
57
58 //private List<ICommandProvider> CommandProviders = new List<ICommandProvider>();
59
60 public ScriptBase()
61 {
62 }
63
64 public void ExecuteFunction(string functionName, params object[] args)
65 {
66 // We got a new command, fire event
67 if (OnExecuteFunction != null)
68 OnExecuteFunction(functionName, args);
69
70 }
71 }
72}
diff --git a/OpenSim/ScriptEngine/Shared/EventParams.cs b/OpenSim/ScriptEngine/Shared/EventParams.cs
deleted file mode 100644
index 28eaa58..0000000
--- a/OpenSim/ScriptEngine/Shared/EventParams.cs
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenMetaverse;
32using OpenSim.Region.ScriptEngine.Shared;
33using log4net;
34using System.Reflection;
35
36namespace OpenSim.ScriptEngine.Shared
37{
38 /// <summary>
39 /// Holds all the data required to execute a scripting event.
40 /// </summary>
41 public class EventParams
42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 public string EventName;
45 public Object[] Params;
46 public Region.ScriptEngine.Shared.DetectParams[] DetectParams;
47 public uint LocalID;
48 public UUID ItemID;
49
50 public EventParams(uint localID, UUID itemID, string eventName, Object[] eventParams, DetectParams[] detectParams)
51 {
52 LocalID = localID;
53 ItemID = itemID;
54 EventName = eventName;
55 Params = eventParams;
56 DetectParams = detectParams;
57 }
58 public EventParams(uint localID, string eventName, Object[] eventParams, DetectParams[] detectParams)
59 {
60 LocalID = localID;
61 EventName = eventName;
62 Params = eventParams;
63 DetectParams = detectParams;
64 }
65 public void test(params object[] args)
66 {
67 string functionName = "test";
68 test2(functionName, args);
69 }
70 public void test2(string functionName, params object[] args)
71 {
72 String logMessage = functionName;
73 foreach (object arg in args)
74 {
75 logMessage +=", "+arg;
76 }
77 m_log.Debug(logMessage);
78 }
79
80
81 }
82}
diff --git a/OpenSim/ScriptEngine/Shared/IScriptCommandProvider.cs b/OpenSim/ScriptEngine/Shared/IScriptCommandProvider.cs
deleted file mode 100644
index b2498d6..0000000
--- a/OpenSim/ScriptEngine/Shared/IScriptCommandProvider.cs
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.ScriptEngine.Shared
33{
34 public interface IScriptCommandProvider : ScriptAssemblies.ICommandProvider
35 {
36 }
37}
diff --git a/OpenSim/ScriptEngine/Shared/IScriptCompiler.cs b/OpenSim/ScriptEngine/Shared/IScriptCompiler.cs
deleted file mode 100644
index 57249fd..0000000
--- a/OpenSim/ScriptEngine/Shared/IScriptCompiler.cs
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Reflection;
30using System.Text;
31using ScriptAssemblies;
32
33namespace OpenSim.ScriptEngine.Shared
34{
35 public interface IScriptCompiler : IScriptEngineComponent
36 {
37 string Compile(ScriptMetaData scriptMetaData, ref string script);
38 string PreProcessScript(ref string script);
39 }
40} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptEngine.cs b/OpenSim/ScriptEngine/Shared/IScriptEngine.cs
deleted file mode 100644
index 3acd1d5..0000000
--- a/OpenSim/ScriptEngine/Shared/IScriptEngine.cs
+++ /dev/null
@@ -1,49 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30using Nini.Config;
31using OpenSim.Region.Framework.Interfaces;
32using OpenSim.Region.Framework.Scenes;
33
34namespace OpenSim.ScriptEngine.Shared
35{
36 public interface IScriptEngine
37 {
38 //string[] ComponentNames { get; }
39 //Dictionary<string, IScriptEngineComponent> Components { get; }
40 //void InitializeComponents();
41 void Initialise(Scene scene, IConfigSource source);
42 void PostInitialise();
43 void Close();
44 string Name { get; }
45 // string Name { get; }
46 //void Initialize();
47 //void Close();
48 }
49} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptEngineComponent.cs b/OpenSim/ScriptEngine/Shared/IScriptEngineComponent.cs
deleted file mode 100644
index 0959b53..0000000
--- a/OpenSim/ScriptEngine/Shared/IScriptEngineComponent.cs
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30
31namespace OpenSim.ScriptEngine.Shared
32{
33 public interface IScriptEngineComponent
34 {
35 }
36} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptEngineRegionComponent.cs b/OpenSim/ScriptEngine/Shared/IScriptEngineRegionComponent.cs
deleted file mode 100644
index eeb86c1..0000000
--- a/OpenSim/ScriptEngine/Shared/IScriptEngineRegionComponent.cs
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28namespace OpenSim.ScriptEngine.Shared
29{
30 public interface IScriptEngineRegionComponent
31 {
32 void Initialize(RegionInfoStructure currentRegion);
33 }
34}
diff --git a/OpenSim/ScriptEngine/Shared/IScriptEventProvider.cs b/OpenSim/ScriptEngine/Shared/IScriptEventProvider.cs
deleted file mode 100644
index b796a4b..0000000
--- a/OpenSim/ScriptEngine/Shared/IScriptEventProvider.cs
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Text;
31
32namespace OpenSim.ScriptEngine.Shared
33{
34 public interface IScriptEventProvider : IScriptEngineComponent, IScriptEngineRegionComponent
35 {
36
37 }
38} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptExecutor.cs b/OpenSim/ScriptEngine/Shared/IScriptExecutor.cs
deleted file mode 100644
index a48c7e5..0000000
--- a/OpenSim/ScriptEngine/Shared/IScriptExecutor.cs
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.Text;
30using OpenSim.ScriptEngine.Shared;
31
32namespace OpenSim.ScriptEngine.Shared
33{
34 public interface IScriptExecutor : IScriptEngineComponent, IScriptEngineRegionComponent
35 {
36 void ExecuteCommand(ref ScriptStructure scriptContainer, EventParams p);
37 void ExecuteCommand(EventParams p);
38 }
39} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/IScriptLoader.cs b/OpenSim/ScriptEngine/Shared/IScriptLoader.cs
deleted file mode 100644
index 6beea17..0000000
--- a/OpenSim/ScriptEngine/Shared/IScriptLoader.cs
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using OpenSim.ScriptEngine.Shared;
29
30namespace OpenSim.ScriptEngine.Shared
31{
32 public interface IScriptLoader: IScriptEngineComponent
33 {
34 ScriptAssemblies.IScript LoadScript(ScriptStructure script);
35 }
36} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/Properties/AssemblyInfo.cs b/OpenSim/ScriptEngine/Shared/Properties/AssemblyInfo.cs
deleted file mode 100644
index 4ce44ed..0000000
--- a/OpenSim/ScriptEngine/Shared/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.Reflection;
29using System.Runtime.CompilerServices;
30using System.Runtime.InteropServices;
31
32// General Information about an assembly is controlled through the following
33// set of attributes. Change these attribute values to modify the information
34// associated with an assembly.
35[assembly: AssemblyTitle("OpenSim.ScriptEngine.Shared")]
36[assembly: AssemblyDescription("")]
37[assembly: AssemblyConfiguration("")]
38[assembly: AssemblyCompany("http://opensimulator.org")]
39[assembly: AssemblyProduct("OpenSim.ScriptEngine.Shared")]
40[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
41[assembly: AssemblyTrademark("")]
42[assembly: AssemblyCulture("")]
43
44// Setting ComVisible to false makes the types in this assembly not visible
45// to COM components. If you need to access a type in this assembly from
46// COM, set the ComVisible attribute to true on that type.
47[assembly: ComVisible(false)]
48
49// The following GUID is for the ID of the typelib if this project is exposed to COM
50[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
51
52// Version information for an assembly consists of the following four values:
53//
54// Major Version
55// Minor Version
56// Build Number
57// Revision
58//
59// You can specify all the values or you can default the Build and Revision Numbers
60// by using the '*' as shown below:
61// [assembly: AssemblyVersion("0.6.5.*")]
62[assembly: AssemblyVersion("0.6.5.*")]
63[assembly: AssemblyFileVersion("0.6.5.0")]
diff --git a/OpenSim/ScriptEngine/Shared/RegionInfoStructure.cs b/OpenSim/ScriptEngine/Shared/RegionInfoStructure.cs
deleted file mode 100644
index 64b33d4..0000000
--- a/OpenSim/ScriptEngine/Shared/RegionInfoStructure.cs
+++ /dev/null
@@ -1,120 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using log4net;
32using Nini.Config;
33using OpenSim.Region.Framework.Scenes;
34using OpenSim.Region.ScriptEngine.Shared;
35using OpenSim.ScriptEngine.Shared;
36using EventParams = OpenSim.ScriptEngine.Shared.EventParams;
37
38namespace OpenSim.ScriptEngine.Shared
39{
40 public struct RegionInfoStructure
41 {
42 public Scene Scene;
43 public IConfigSource ConfigSource;
44
45 public IScriptLoader ScriptLoader;
46 public Dictionary<string, IScriptEventProvider> EventProviders;
47 public Dictionary<string, IScriptExecutor> Executors;
48 public Dictionary<string, IScriptCompiler> Compilers;
49 public Dictionary<string, IScriptScheduler> Schedulers;
50 public Dictionary<string, IScriptCommandProvider> CommandProviders;
51
52 public void Executors_Execute(EventParams p)
53 {
54 // Execute a command on all executors
55 lock (Executors)
56 {
57 foreach (IScriptExecutor exec in Executors.Values)
58 {
59 exec.ExecuteCommand(p);
60 }
61 }
62 }
63 public void Executors_Execute(ScriptStructure scriptContainer, EventParams p)
64 {
65 // Execute a command on all executors
66 lock (Executors)
67 {
68 foreach (IScriptExecutor exec in Executors.Values)
69 {
70 exec.ExecuteCommand(ref scriptContainer, p);
71 }
72 }
73 }
74
75 public IScriptCompiler FindCompiler(ScriptMetaData scriptMetaData)
76 {
77 string compiler = "Compiler_LSL";
78 if (scriptMetaData.ContainsKey("Compiler"))
79 compiler = scriptMetaData["Compiler"];
80
81 lock (Compilers)
82 {
83 if (!Compilers.ContainsKey(compiler))
84 throw new Exception("Requested script compiler \"" + compiler + "\" does not exist.");
85
86 return Compilers[compiler];
87 }
88 }
89
90 public IScriptScheduler FindScheduler(ScriptMetaData scriptMetaData)
91 {
92 string scheduler = "Scheduler";
93 if (scriptMetaData.ContainsKey("Scheduler"))
94 scheduler = scriptMetaData["Scheduler"];
95
96 lock (Schedulers)
97 {
98 if (!Schedulers.ContainsKey(scheduler))
99 throw new Exception("Requested script scheduler \"" + scheduler + "\" does not exist.");
100
101 return Schedulers[scheduler];
102 }
103 }
104
105 //public Assembly[] GetCommandProviderAssemblies()
106 //{
107 // lock (CommandProviders)
108 // {
109 // Assembly[] ass = new Assembly[CommandProviders.Count];
110 // int i = 0;
111 // foreach (string key in CommandProviders.Keys)
112 // {
113 // ass[i] = CommandProviders[key].GetType().Assembly;
114 // i++;
115 // }
116 // return ass;
117 // }
118 //}
119 }
120} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/ScriptMetaData.cs b/OpenSim/ScriptEngine/Shared/ScriptMetaData.cs
deleted file mode 100644
index e351632..0000000
--- a/OpenSim/ScriptEngine/Shared/ScriptMetaData.cs
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29
30namespace OpenSim.ScriptEngine.Shared
31{
32 public class ScriptMetaData: Dictionary<string, string>
33 {
34 private static readonly char[] LineSeparator = "\r\n".ToCharArray();
35 private static readonly char[] Separator = { ':' };
36 public static ScriptMetaData Extract(ref string Script)
37 {
38 ScriptMetaData ret = new ScriptMetaData();
39 if (string.IsNullOrEmpty(Script))
40 return ret;
41
42 // Process it line by line
43 string Line = "";
44 for (int i = 0; i < Script.Length + 1; i++)
45 {
46 // Found a line separator?
47 if (i < Script.Length
48 && Script[i] != LineSeparator[0]
49 && Script[i] != LineSeparator[1])
50 {
51 // No, not end of line. Add to current line
52 Line += Script[i];
53 }
54 else
55 {
56 // Extract MetaData from this line. Returns False if not found.
57 if (!_GetMetaFromLine(ret, Line))
58 continue;
59 // Empty for next round
60 Line = "";
61 }
62 }
63 return ret;
64 }
65
66 private static bool _GetMetaFromLine(ScriptMetaData ret, string line)
67 {
68 line = line.Trim();
69
70 // Empty line? We may find more later
71 if (line == "")
72 return true;
73
74 // Is this a comment? If not, then return false
75 if (!line.StartsWith("//"))
76 return false;
77
78 // It is a comment
79 string[] keyval = line.Split(Separator, 2, StringSplitOptions.None);
80 keyval[0] = keyval[0].Substring(2, keyval[0].Length - 2).Trim();
81 keyval[1] = keyval[1].Trim();
82
83 // Add it
84 if (keyval[0] != "")
85 if (!ret.ContainsKey(keyval[0]))
86 {
87 //m_log.DebugFormat("[DotNetEngine] Script metadata: Key: \"{0}\", Value: \"{1}\".", keyval[0], keyval[1]);
88 ret.Add(keyval[0], keyval[1]);
89 }
90
91 return true;
92 }
93
94 }
95} \ No newline at end of file
diff --git a/OpenSim/ScriptEngine/Shared/ScriptStructure.cs b/OpenSim/ScriptEngine/Shared/ScriptStructure.cs
deleted file mode 100644
index 1095a8b..0000000
--- a/OpenSim/ScriptEngine/Shared/ScriptStructure.cs
+++ /dev/null
@@ -1,137 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Region.ScriptEngine.Interfaces;
35using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
36using OpenSim.ScriptEngine.Shared;
37
38namespace OpenSim.ScriptEngine.Shared
39{
40 public struct ScriptStructure
41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
44 public RegionInfoStructure RegionInfo;
45 public ScriptMetaData ScriptMetaData;
46
47 public ScriptAssemblies.IScript ScriptObject;
48 public string State;
49 public bool Running;
50 public bool Disabled;
51 public string Source;
52 public int StartParam;
53 public AppDomain AppDomain;
54 public Dictionary<string, IScriptApi> Apis;
55 public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap;
56 public uint LocalID;
57 public UUID ItemID;
58 public string AssemblyFileName;
59
60 public string ScriptID { get { return LocalID.ToString() + "." + ItemID.ToString(); } }
61 public string Name { get { return "Script:" + ScriptID; } }
62 private bool Initialized;
63 private Dictionary<string, Delegate> InternalFunctions;
64 public string AssemblyName;
65
66 public void ExecuteEvent(EventParams p)
67 {
68 ExecuteMethod(p, true);
69 }
70
71 public void ExecuteMethod(EventParams p)
72 {
73 ExecuteMethod(p, false);
74 }
75 private void ExecuteMethod(EventParams p, bool isEvent)
76 {
77 // First time initialization?
78 if (!Initialized)
79 {
80 Initialized = true;
81 CacheInternalFunctions();
82 }
83
84 lock (InternalFunctions)
85 {
86 // Make function name
87 string FunctionName;
88 if (isEvent)
89 FunctionName = State + "_event_" + p.EventName;
90 else
91 FunctionName = p.EventName;
92
93 // Check if this function exist
94 if (!InternalFunctions.ContainsKey(FunctionName))
95 {
96 // TODO: Send message in-world
97 m_log.ErrorFormat("[{0}] Script function \"{1}\" was not found.", Name, FunctionName);
98 return;
99 }
100
101 // Execute script function
102 try
103 {
104 InternalFunctions[FunctionName].DynamicInvoke(p.Params);
105 }
106 catch (Exception e)
107 {
108 m_log.ErrorFormat("[{0}] Execute \"{1}\" failed: {2}", Name, FunctionName, e.ToString());
109 }
110 }
111 }
112
113 /// <summary>
114 /// Cache functions into a dictionary with delegates. Should be faster than reflection.
115 /// </summary>
116 private void CacheInternalFunctions()
117 {
118 Type scriptObjectType = ScriptObject.GetType();
119 InternalFunctions = new Dictionary<string, Delegate>();
120
121 MethodInfo[] methods = scriptObjectType.GetMethods();
122 lock (InternalFunctions)
123 {
124 // Read all methods into a dictionary
125 foreach (MethodInfo mi in methods)
126 {
127 // TODO: We don't support overloading
128 if (!InternalFunctions.ContainsKey(mi.Name))
129 InternalFunctions.Add(mi.Name, Delegate.CreateDelegate(scriptObjectType, ScriptObject, mi));
130 else
131 m_log.ErrorFormat("[{0}] Error: Script function \"{1}\" is already added. We do not support overloading.",
132 Name, mi.Name);
133 }
134 }
135 }
136 }
137}
diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs
index a7b33c9..10cd9c5 100644
--- a/OpenSim/Server/ServerMain.cs
+++ b/OpenSim/Server/ServerMain.cs
@@ -96,7 +96,7 @@ namespace OpenSim.Server
96 if (port != 0) 96 if (port != 0)
97 server = m_Server.GetHttpServer(port); 97 server = m_Server.GetHttpServer(port);
98 98
99 if (port != m_Server.DefaultPort) 99 if (port != m_Server.DefaultPort && port != 0)
100 m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, port); 100 m_log.InfoFormat("[SERVER]: Loading {0} on port {1}", friendlyName, port);
101 else 101 else
102 m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName); 102 m_log.InfoFormat("[SERVER]: Loading {0}", friendlyName);
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_OSSL/Commands_OSSL.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index 86eab09..6e59642 100644
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Commands_OSSL/Commands_OSSL.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -27,18 +27,27 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Net;
31using OpenSim.ScriptEngine.Shared; 31using System.Reflection;
32using Nini.Config;
33using log4net;
34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Data;
37using OpenSim.Services.Interfaces;
38using OpenMetaverse;
32 39
33namespace OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL 40namespace OpenSim.Services.PresenceService
34{ 41{
35 public class Commands_OSSL : IScriptEngineComponent 42 public class PresenceService : PresenceServiceBase, IPresenceService
36 { 43 {
37 //private RegionInfoStructure CurrentRegion; 44 private static readonly ILog m_log =
38 public void Initialize(RegionInfoStructure currentRegion) 45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47
48 public PresenceService(IConfigSource config)
49 : base(config)
39 { 50 {
40 //CurrentRegion = currentRegion;
41 } 51 }
42
43 } 52 }
44} 53}
diff --git a/OpenSim/Services/PresenceService/PresenceServiceBase.cs b/OpenSim/Services/PresenceService/PresenceServiceBase.cs
new file mode 100644
index 0000000..60a246b
--- /dev/null
+++ b/OpenSim/Services/PresenceService/PresenceServiceBase.cs
@@ -0,0 +1,84 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Data;
33using OpenSim.Services.Interfaces;
34using OpenSim.Services.Base;
35
36namespace OpenSim.Services.PresenceService
37{
38 public class PresenceServiceBase : ServiceBase
39 {
40 protected IPresenceData m_Database = null;
41
42 public PresenceServiceBase(IConfigSource config)
43 : base(config)
44 {
45 string dllName = String.Empty;
46 string connString = String.Empty;
47 string realm = "agents";
48
49 //
50 // Try reading the [DatabaseService] section, if it exists
51 //
52 IConfig dbConfig = config.Configs["DatabaseService"];
53 if (dbConfig != null)
54 {
55 if (dllName == String.Empty)
56 dllName = dbConfig.GetString("StorageProvider", String.Empty);
57 if (connString == String.Empty)
58 connString = dbConfig.GetString("ConnectionString", String.Empty);
59 }
60
61 //
62 // [PresenceService] section overrides [DatabaseService], if it exists
63 //
64 IConfig presenceConfig = config.Configs["PresenceService"];
65 if (presenceConfig != null)
66 {
67 dllName = presenceConfig.GetString("StorageProvider", dllName);
68 connString = presenceConfig.GetString("ConnectionString", connString);
69 realm = presenceConfig.GetString("Realm", realm);
70 }
71
72 //
73 // We tried, but this doesn't exist. We can't proceed.
74 //
75 if (dllName.Equals(String.Empty))
76 throw new Exception("No StorageProvider configured");
77
78 m_Database = LoadPlugin<IPresenceData>(dllName, new Object[] { connString, realm });
79 if (m_Database == null)
80 throw new Exception("Could not find a storage interface in the given module");
81
82 }
83 }
84}
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
index 426ef29..38986a2 100644
--- a/OpenSim/Tools/pCampBot/PhysicsBot.cs
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -154,7 +154,7 @@ namespace pCampBot
154 client.Network.OnConnected += new NetworkManager.ConnectedCallback(this.Network_OnConnected); 154 client.Network.OnConnected += new NetworkManager.ConnectedCallback(this.Network_OnConnected);
155 client.Network.OnSimConnected += new NetworkManager.SimConnectedCallback(this.Network_OnConnected); 155 client.Network.OnSimConnected += new NetworkManager.SimConnectedCallback(this.Network_OnConnected);
156 client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(this.Network_OnDisconnected); 156 client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(this.Network_OnDisconnected);
157 client.Objects.OnNewPrim += Objects_NewPrim; 157 client.Objects.ObjectUpdate += Objects_NewPrim;
158 //client.Assets.OnAssetReceived += Asset_ReceivedCallback; 158 //client.Assets.OnAssetReceived += Asset_ReceivedCallback;
159 if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name")) 159 if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name"))
160 { 160 {
@@ -369,8 +369,10 @@ namespace pCampBot
369 } 369 }
370 } 370 }
371 371
372 public void Objects_NewPrim(Simulator simulator, Primitive prim, ulong regionHandle, ushort timeDilation) 372 public void Objects_NewPrim(object sender, PrimEventArgs args)
373 { 373 {
374 Primitive prim = args.Prim;
375
374 if (prim != null) 376 if (prim != null)
375 { 377 {
376 if (prim.Textures != null) 378 if (prim.Textures != null)
@@ -396,7 +398,6 @@ namespace pCampBot
396 client.Assets.RequestImage(prim.Sculpt.SculptTexture, ImageType.Normal, Asset_TextureCallback_Texture); 398 client.Assets.RequestImage(prim.Sculpt.SculptTexture, ImageType.Normal, Asset_TextureCallback_Texture);
397 } 399 }
398 } 400 }
399
400 } 401 }
401 402
402 403
diff --git a/Prebuild/src/Core/Nodes/ProjectNode.cs b/Prebuild/src/Core/Nodes/ProjectNode.cs
index 0a24abf..04af7a3 100644
--- a/Prebuild/src/Core/Nodes/ProjectNode.cs
+++ b/Prebuild/src/Core/Nodes/ProjectNode.cs
@@ -90,6 +90,10 @@ namespace Prebuild.Core.Nodes
90 /// .NET 3.5 90 /// .NET 3.5
91 /// </summary> 91 /// </summary>
92 v3_5, 92 v3_5,
93 /// <summary>
94 /// .NET 4.0
95 /// </summary>
96 v4_0,
93 } 97 }
94 /// <summary> 98 /// <summary>
95 /// The Node object representing /Prebuild/Solution/Project elements 99 /// The Node object representing /Prebuild/Solution/Project elements
diff --git a/Prebuild/src/Core/Targets/VS2008Target.cs b/Prebuild/src/Core/Targets/VS2008Target.cs
index f30017b..e685962 100644
--- a/Prebuild/src/Core/Targets/VS2008Target.cs
+++ b/Prebuild/src/Core/Targets/VS2008Target.cs
@@ -120,7 +120,7 @@ namespace Prebuild.Core.Targets
120 #region Constructors 120 #region Constructors
121 121
122 /// <summary> 122 /// <summary>
123 /// Initializes a new instance of the <see cref="VS2005Target"/> class. 123 /// Initializes a new instance of the <see cref="VS2008Target"/> class.
124 /// </summary> 124 /// </summary>
125 public VS2008Target() 125 public VS2008Target()
126 : base() 126 : base()
diff --git a/Prebuild/src/Core/Targets/VS2010Target.cs b/Prebuild/src/Core/Targets/VS2010Target.cs
new file mode 100644
index 0000000..8772d18
--- /dev/null
+++ b/Prebuild/src/Core/Targets/VS2010Target.cs
@@ -0,0 +1,134 @@
1using System;
2using System.Collections;
3using System.Collections.Specialized;
4using System.IO;
5using System.Text;
6
7using Prebuild.Core.Attributes;
8using Prebuild.Core.Interfaces;
9using Prebuild.Core.Nodes;
10using Prebuild.Core.Utilities;
11using System.CodeDom.Compiler;
12
13namespace Prebuild.Core.Targets
14{
15
16 /// <summary>
17 ///
18 /// </summary>
19 [Target("vs2010")]
20 public class VS2010Target : VSGenericTarget
21 {
22 #region Fields
23 string solutionVersion = "11.00";
24 string productVersion = "9.0.21022";
25 string schemaVersion = "2.0";
26 string versionName = "Visual Studio 2010";
27 string name = "vs2008";
28 VSVersion version = VSVersion.VS10;
29
30 Hashtable tools;
31 Kernel kernel;
32
33 /// <summary>
34 /// Gets or sets the solution version.
35 /// </summary>
36 /// <value>The solution version.</value>
37 public override string SolutionVersion
38 {
39 get
40 {
41 return solutionVersion;
42 }
43 }
44 /// <summary>
45 /// Gets or sets the product version.
46 /// </summary>
47 /// <value>The product version.</value>
48 public override string ProductVersion
49 {
50 get
51 {
52 return productVersion;
53 }
54 }
55 /// <summary>
56 /// Gets or sets the schema version.
57 /// </summary>
58 /// <value>The schema version.</value>
59 public override string SchemaVersion
60 {
61 get
62 {
63 return schemaVersion;
64 }
65 }
66 /// <summary>
67 /// Gets or sets the name of the version.
68 /// </summary>
69 /// <value>The name of the version.</value>
70 public override string VersionName
71 {
72 get
73 {
74 return versionName;
75 }
76 }
77 /// <summary>
78 /// Gets or sets the version.
79 /// </summary>
80 /// <value>The version.</value>
81 public override VSVersion Version
82 {
83 get
84 {
85 return version;
86 }
87 }
88 /// <summary>
89 /// Gets the name.
90 /// </summary>
91 /// <value>The name.</value>
92 public override string Name
93 {
94 get
95 {
96 return name;
97 }
98 }
99
100 protected override string GetToolsVersionXml(FrameworkVersion frameworkVersion)
101 {
102 switch (frameworkVersion)
103 {
104 case FrameworkVersion.v4_0:
105 return "ToolsVersion=\"4.0\"";
106 case FrameworkVersion.v3_5:
107 return "ToolsVersion=\"3.5\"";
108 case FrameworkVersion.v3_0:
109 return "ToolsVersion=\"3.0\"";
110 default:
111 return "ToolsVersion=\"2.0\"";
112 }
113 }
114
115 public override string SolutionTag
116 {
117 get { return "# Visual Studio 2010"; }
118 }
119
120 #endregion
121
122 #region Constructors
123
124 /// <summary>
125 /// Initializes a new instance of the <see cref="VS2010Target"/> class.
126 /// </summary>
127 public VS2010Target()
128 : base()
129 {
130 }
131
132 #endregion
133 }
134}
diff --git a/Prebuild/src/Core/Targets/VSGenericTarget.cs b/Prebuild/src/Core/Targets/VSGenericTarget.cs
index 84f1df5..fdcc2b9 100644
--- a/Prebuild/src/Core/Targets/VSGenericTarget.cs
+++ b/Prebuild/src/Core/Targets/VSGenericTarget.cs
@@ -173,7 +173,7 @@ namespace Prebuild.Core.Targets
173 #region Project File 173 #region Project File
174 using (ps) 174 using (ps)
175 { 175 {
176 ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {0}>", GetToolsVersionXml(project.FrameworkVersion)); 176 ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" ToolsVersion=\"{0}\">", this.Version == VSVersion.VS10 ? "4.0" : "3.5");
177 ps.WriteLine(" <PropertyGroup>"); 177 ps.WriteLine(" <PropertyGroup>");
178 ps.WriteLine(" <ProjectType>Local</ProjectType>"); 178 ps.WriteLine(" <ProjectType>Local</ProjectType>");
179 ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", this.ProductVersion); 179 ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", this.ProductVersion);
diff --git a/Prebuild/src/Core/Targets/VSVersion.cs b/Prebuild/src/Core/Targets/VSVersion.cs
index f477086..59549b0 100644
--- a/Prebuild/src/Core/Targets/VSVersion.cs
+++ b/Prebuild/src/Core/Targets/VSVersion.cs
@@ -45,6 +45,10 @@ namespace Prebuild.Core.Targets
45 /// <summary> 45 /// <summary>
46 /// Visual Studio 2008 46 /// Visual Studio 2008
47 /// </summary> 47 /// </summary>
48 VS90 48 VS90,
49 /// <summary>
50 /// Visual Studio 2010
51 /// </summary>
52 VS10
49 } 53 }
50} 54}
diff --git a/README.txt b/README.txt
index 83ac7d6..3a87fe2 100644
--- a/README.txt
+++ b/README.txt
@@ -25,7 +25,7 @@ See configuring OpenSim
25== Installation on Linux == 25== Installation on Linux ==
26 26
27Prereqs: 27Prereqs:
28 * Mono >= 2.0.1 (>= 2.4.2 is better) 28 * Mono >= 2.4.2
29 * Nant >= 0.86beta 29 * Nant >= 0.86beta
30 * sqlite3 or mysql 5.x (you'll need a back end database) 30 * sqlite3 or mysql 5.x (you'll need a back end database)
31 31
diff --git a/ThirdParty/SmartThreadPool/SmartThreadPool.cs b/ThirdParty/SmartThreadPool/SmartThreadPool.cs
index c21984e..bd52f62 100644
--- a/ThirdParty/SmartThreadPool/SmartThreadPool.cs
+++ b/ThirdParty/SmartThreadPool/SmartThreadPool.cs
@@ -499,7 +499,11 @@ namespace Amib.Threading
499 } 499 }
500 500
501 // Create a new thread 501 // Create a new thread
502 Thread workerThread = new Thread(new ThreadStart(ProcessQueuedItems), _stpStartInfo.StackSize); 502 Thread workerThread;
503 if (_stpStartInfo.StackSize > 0)
504 workerThread = new Thread(ProcessQueuedItems, _stpStartInfo.StackSize);
505 else
506 workerThread = new Thread(ProcessQueuedItems);
503 507
504 // Configure the new thread and start it 508 // Configure the new thread and start it
505 workerThread.Name = "STP " + Name + " Thread #" + _threadCounter; 509 workerThread.Name = "STP " + Name + " Thread #" + _threadCounter;
diff --git a/bin/OpenMetaverse.dll b/bin/OpenMetaverse.dll
index 6ec1b1c..8b07942 100644
--- a/bin/OpenMetaverse.dll
+++ b/bin/OpenMetaverse.dll
Binary files differ
diff --git a/bin/OpenMetaverseTypes.dll b/bin/OpenMetaverseTypes.dll
index 6cea131..331d58b 100644
--- a/bin/OpenMetaverseTypes.dll
+++ b/bin/OpenMetaverseTypes.dll
Binary files differ
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 79d57d2..927eb7a 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -38,8 +38,22 @@
38 38
39 ; Sets the method that OpenSim will use to fire asynchronous 39 ; Sets the method that OpenSim will use to fire asynchronous
40 ; events. Valid values are UnsafeQueueUserWorkItem, 40 ; events. Valid values are UnsafeQueueUserWorkItem,
41 ; QueueUserWorkItem, BeginInvoke, SmartThreadPool, and Thread 41 ; QueueUserWorkItem, BeginInvoke, SmartThreadPool, and Thread.
42 ; async_call_method = SmartThreadPool 42 ; SmartThreadPool is reported to work well on Mono/Linux, but
43 ; UnsafeQueueUserWorkItem has been benchmarked with better
44 ; performance on .NET/Windows
45 ;async_call_method = SmartThreadPool
46
47 ; There are several operations on large collections (such as
48 ; the current avatar list) that can be run synchronously or
49 ; in parallel. Running in parallel should increase performance
50 ; on a multi-core system, but will make debugging more
51 ; difficult if something deadlocks or times out
52 use_async_when_possible = false
53
54 ; Max threads to allocate on the FireAndForget thread pool
55 ; when running with the SmartThreadPool option above
56 MaxPoolThreads = 15
43 57
44 ; ## 58 ; ##
45 ; ## CLIENTS 59 ; ## CLIENTS
@@ -51,9 +65,6 @@
51 ; Set this to the DLL containing the client stack to use. 65 ; Set this to the DLL containing the client stack to use.
52 clientstack_plugin="OpenSim.Region.ClientStack.LindenUDP.dll" 66 clientstack_plugin="OpenSim.Region.ClientStack.LindenUDP.dll"
53 67
54 ; Max threads to allocate on the FireAndForget pool
55 MaxPoolThreads = 15
56
57 ; ## 68 ; ##
58 ; ## REGIONS 69 ; ## REGIONS
59 ; ## 70 ; ##
@@ -207,7 +218,6 @@
207 ; ## SCRIPT ENGINE 218 ; ## SCRIPT ENGINE
208 ; ## 219 ; ##
209 220
210 ;DefaultScriptEngine = "ScriptEngine.DotNetEngine"
211 DefaultScriptEngine = "XEngine" 221 DefaultScriptEngine = "XEngine"
212 222
213 ; ## 223 ; ##
@@ -351,8 +361,9 @@
351 ; already separated from packet handling with a queue, so this will only 361 ; already separated from packet handling with a queue, so this will only
352 ; affect whether networking internals such as packet decoding and 362 ; affect whether networking internals such as packet decoding and
353 ; acknowledgement accounting are done synchronously or asynchronously 363 ; acknowledgement accounting are done synchronously or asynchronously
354 async_packet_handling = false 364 ;
355 365 ;async_packet_handling = false
366
356 ; The client socket receive buffer size determines how many 367 ; The client socket receive buffer size determines how many
357 ; incoming requests we can process; the default on .NET is 8192 368 ; incoming requests we can process; the default on .NET is 8192
358 ; which is about 2 4k-sized UDP datagrams. On mono this is 369 ; which is about 2 4k-sized UDP datagrams. On mono this is
@@ -367,22 +378,26 @@
367 ; by the system's settings for the maximum client receive buffer 378 ; by the system's settings for the maximum client receive buffer
368 ; size (on linux systems you can set that with "sysctl -w 379 ; size (on linux systems you can set that with "sysctl -w
369 ; net.core.rmem_max=X") 380 ; net.core.rmem_max=X")
381 ;
370 ;client_socket_rcvbuf_size = 8388608 382 ;client_socket_rcvbuf_size = 8388608
371 383
372 ; Maximum outbound bytes per second for a single scene. This can be used to 384 ; Maximum outbound bytes per second for a single scene. This can be used to
373 ; throttle total outbound UDP traffic for a simulator. The default value is 385 ; throttle total outbound UDP traffic for a simulator. The default value is
374 ; 0, meaning no throttling at the scene level. The example given here is 386 ; 0, meaning no throttling at the scene level. The example given here is
375 ; 20 megabits 387 ; 20 megabits
388 ;
376 ;scene_throttle_max_bps = 2621440 389 ;scene_throttle_max_bps = 2621440
377 390
378 ; Maximum bits per second to send to any single client. This will override 391 ; Maximum bits per second to send to any single client. This will override
379 ; the user's viewer preference settings. The default value is 0, meaning no 392 ; the user's viewer preference settings. The default value is 0, meaning no
380 ; aggregate throttling on clients (only per-category throttling). The 393 ; aggregate throttling on clients (only per-category throttling). The
381 ; example given here is 1.5 megabits 394 ; example given here is 1.5 megabits
395 ;
382 ;client_throttle_max_bps = 196608 396 ;client_throttle_max_bps = 196608
383 397
384 ; Per-client bytes per second rates for the various throttle categories. 398 ; Per-client bytes per second rates for the various throttle categories.
385 ; These are default values that will be overriden by clients 399 ; These are default values that will be overriden by clients
400 ;
386 ;resend_default = 12500 401 ;resend_default = 12500
387 ;land_default = 500 402 ;land_default = 500
388 ;wind_default = 500 403 ;wind_default = 500
@@ -395,6 +410,7 @@
395 ; Per-client maximum burst rates in bytes per second for the various 410 ; Per-client maximum burst rates in bytes per second for the various
396 ; throttle categories. These are default values that will be overriden by 411 ; throttle categories. These are default values that will be overriden by
397 ; clients 412 ; clients
413 ;
398 ;resend_limit = 18750 414 ;resend_limit = 18750
399 ;land_limit = 29750 415 ;land_limit = 29750
400 ;wind_limit = 18750 416 ;wind_limit = 18750
@@ -403,6 +419,28 @@
403 ;texture_limit = 55750 419 ;texture_limit = 55750
404 ;asset_limit = 27500 420 ;asset_limit = 27500
405 ;state_limit = 37000 421 ;state_limit = 37000
422
423 ; Configures how ObjectUpdates are aggregated. These numbers
424 ; do not literally mean how many updates will be put in each
425 ; packet that goes over the wire, as packets are
426 ; automatically split on a 1400 byte boundary. These control
427 ; the balance between responsiveness of interest list updates
428 ; and total throughput. Higher numbers will ensure more full-
429 ; sized packets and faster sending of data, but more delay in
430 ; updating interest lists
431 ;
432 ;PrimTerseUpdatesPerPacket = 25
433 ;AvatarTerseUpdatesPerPacket = 10
434 ;PrimFullUpdatesPerPacket = 100
435
436 ; TextureSendLimit determines how many packets will be put on
437 ; the outgoing queue each cycle. Like the settings above, this
438 ; is a balance between responsiveness to priority updates and
439 ; total throughput. Higher numbers will give a better
440 ; throughput at the cost of reduced responsiveness to client
441 ; priority changes or transfer aborts
442 ;
443 ;TextureSendLimit = 20
406 444
407[Chat] 445[Chat]
408 ; Controls whether the chat module is enabled. Default is true. 446 ; Controls whether the chat module is enabled. Default is true.
@@ -787,137 +825,12 @@
787 ; Density of tree population 825 ; Density of tree population
788 tree_density = 1000.0 826 tree_density = 1000.0
789 827
828
790[VectorRender] 829[VectorRender]
791 830
792 ; the font to use for rendering text (default: Arial) 831 ; the font to use for rendering text (default: Arial)
793 ; font_name = "Arial" 832 ; font_name = "Arial"
794 833
795[ScriptEngine.DotNetEngine]
796 Enabled = true
797
798 ScriptDelayFactor = 1.0
799 ScriptDistanceLimitFactor = 1.0
800
801 ; Maximum length of notecard line read
802 ; Increasing this to large values potentially opens
803 ; up the system to malicious scripters
804 ; NotecardLineReadCharsMax = 255
805
806 ;
807 ; These settings are specific to DotNetEngine script engine
808 ; Other script engines based on OpenSim.Region.ScriptEngine.Common.dll will have almost identical settings, but in another section of this config file.
809 ;
810
811 ; When a script receives an event the event is queued.
812 ; Any free thread will start executing this event. One script can only have one event executed simultaneously.
813 ; If you have only one thread, and one script has a loop or does a lot of work, then no other scripts can run at the same time.
814 ; Same if you have 10 threads, then only 10 scripts can be run simultaneously.
815 ; But because most scripts exit after their task, the threads are free to go on to the next script.
816
817 ; Refresh ScriptEngine config options (these settings) every xx seconds
818 ; 0 = Do not refresh
819 ; Set it to number of seconds between refresh, for example 30.
820 ; Will allow you to change ScriptEngine settings while server is running just by using "CONFIG SET" on console
821 ; For example to increase or decrease number of threads: CONFIG SET NumberOfScriptThreads 10
822 ; NOTE! Disabled for now. Feature does not work.
823 RefreshConfig=0
824
825 ; Number of threads to use for script event execution
826 ; Threads are shared across all regions
827 NumberOfScriptThreads=2
828
829 ; Script event execution thread priority inside application.
830 ; Valid values: Lowest, BelowNormal, Normal, AboveNormal, Highest
831 ScriptThreadPriority=BelowNormal
832
833 ; How long MAX should a script event be allowed to run (per event execution)?
834 ; Do not set this too low (like 50ms) as there are some time wasted in simply executing a function
835 ; There is also a small speed penalty for every kill that is made
836 MaxEventExecutionTimeMs=5000
837
838 ; Should we enable the max script event execution thread to look for scripts that exceed their timeslice?
839 EnforceMaxEventExecutionTime=true
840
841 ; Should we stop the script completely when time exceeds?
842 ; This is useful if you have a high <MaxEventExecutionTimeMs> and want to deactivate scripts that go wrong
843 ; Note that for example physics engine can slow down the system and make scripts spend more time
844 DeactivateScriptOnTimeout=false
845
846 ; If no scripts have executed in this pass how long should we sleep before checking again
847 ; Impact:
848 ; Too low and you will waste lots of CPU
849 ; Too high and people touching object or similar will have to wait up to this amount of time before script responding
850 SleepTimeIfNoScriptExecutionMs=50
851
852 ; AppDomains are used for two things:
853 ; * Security: Scripts inside AppDomains are limited in permissions.
854 ; * Script unloading: When a script is deactivated it can not be unloaded. Only whole AppDomains can be unloaded.
855 ; AppDomains are therefore only unloaded once ALL active scripts inside it has been deactivated (removed from prims).
856 ; Each AppDomain has some memory overhead. But leaving dead scripts in memory also has memory overhead.
857 ScriptsPerAppDomain=1
858
859 ; MaintenanceLoop
860 ; How often to run maintenance loop
861 ; Maintenance loop is doing: script compile/load, script unload, reload config, adjust running config and enforce max execution time
862 MaintenanceLoopms=50
863
864 ; How many maintenanceloops between each of these.
865 ; (if 2 then function will be executed every MaintenanceLoopms*2 ms)
866 ; Script loading/unloading
867
868 ; How long load/unload thread should sleep if there is nothing to do
869 ; Higher value makes it respond slower when scripts are added/removed from prims
870 ; But once active it will process all in queue before sleeping again
871 MaintenanceLoopTicks_ScriptLoadUnload=1
872
873 ; Other tasks
874 ; check if we need to reload config, adjust running config and enforce max execution time
875 MaintenanceLoopTicks_Other=10
876
877 ; Allow the use of os* functions (some are dangerous)
878 ; Default is false
879 AllowOSFunctions = false
880
881 ; Threat level to allow if os functions are enabled
882 ; One of None, VeryLow, Low, Moderate, High, VeryHigh, Severe
883 ; Default is VeryLow
884 OSFunctionThreatLevel = VeryLow
885
886 ; Maximum number of items in load/unload queue before we start rejecting loads
887 ; Note that we will only be rejecting load. Unloads will still be able to queue.
888 LoadUnloadMaxQueueSize=100
889
890 ; Maximum number of (LSL) events that can be queued before new events are ignored.
891 EventExecutionMaxQueueSize=300
892
893 ; Async LL command sleep
894 ; If no async LL commands are waiting, how long should thread sleep before checking again
895 ; Async LL commands are LSL-commands that causes an event to be fired back with result
896 ; currently unused
897 ; AsyncLLCommandLoopms=50
898
899 ; When script is converted from LSL to C#, or just plain compiled, a copy of the script source will be put in the ScriptEngine folder
900 WriteScriptSourceToDebugFile=false
901
902 ; Specify default script compiler
903 ; If you do not specify //cs, //vb, //js or //lsl tag as the first characters of your script then the default compiler will be chosen
904 ; Valid languages are: lsl, cs, js and vb
905 DefaultCompileLanguage=lsl
906
907 ; Specify what compilers are allowed to be used
908 ; Note vb only works on Windows for now (Mono lacks VB compile support)
909 ; Valid languages are: lsl, cs, js and vb
910 ; AllowedCompilers=lsl,cs,js,vb. *warning*, non lsl languages have access to static methods such as System.IO.File. Enable at your own risk.
911 AllowedCompilers=lsl
912
913 ; Compile scripts with debugging
914 ; Probably a thousand times slower, but gives you a line number when something goes wrong.
915 CompileWithDebugInformation=true
916
917 ; Remove old scripts on next startup
918 ; currently unused
919 ;CleanUpOldScriptsOnStartup=true
920
921 834
922[LL-Functions] 835[LL-Functions]
923 ; Set the following to true to allow administrator owned scripts to execute console commands 836 ; Set the following to true to allow administrator owned scripts to execute console commands
@@ -1361,43 +1274,14 @@
1361 ;RecycleDataBlocks = true; 1274 ;RecycleDataBlocks = true;
1362 1275
1363 1276
1364[LLClient]
1365 ; Resend packets markes as reliable until they are received
1366 ;
1367 ;ReliableIsImportant = false
1368
1369 ; Maximum number of times to resend packets marked reliable
1370 ;
1371 ;MaxReliableResends = 3
1372
1373 ; Configures how ObjectUpdates are compressed.
1374 ;
1375 ;TerseUpdatesPerPacket=10
1376 ;FullUpdatesPerPacket=14
1377 ;TerseUpdateRate=10
1378 ;FullUpdateRate=14
1379
1380 ;PacketMTU = 1400
1381
1382 ; TextureSendLimit determines how many different textures
1383 ; will be considered on each cycle. Textures are selected
1384 ; by priority. The old mechanism specified a value of 10 for
1385 ; this parameter.
1386 ;
1387 ;TextureSendLimit = 10
1388
1389 ; TextureDataLimit determines how many packets will be sent for
1390 ; each of the selected textures. Default is 5.
1391 ;
1392 ;TextureDataLimit = 5
1393
1394[InterestManagement] 1277[InterestManagement]
1395 ; This section controls how state updates are prioritized for each client 1278 ; This section controls how state updates are prioritized for each client
1396 UpdatePrioritizationScheme = Distance 1279 ; Valid values are Time, Distance, SimpleAngularDistance, and FrontBack
1397 ReprioritizeUpdate = true 1280 UpdatePrioritizationScheme = FrontBack
1398 RootUpdateReprioritizationDistance = 10.0 1281 ReprioritizationEnabled = true
1399 ChildUpdateReprioritizationDistance = 20.0 1282 ReprioritizationInterval = 2000.0
1400 ReprioritizeUpdatesInterval = 5000.0 1283 RootReprioritizationDistance = 10.0
1284 ChildReprioritizationDistance = 20.0
1401 1285
1402;; 1286;;
1403;; These are defaults that are overwritten below in [Architecture]. 1287;; These are defaults that are overwritten below in [Architecture].
diff --git a/bin/Prebuild.exe b/bin/Prebuild.exe
index e58657c..eb4c224 100755
--- a/bin/Prebuild.exe
+++ b/bin/Prebuild.exe
Binary files differ
diff --git a/prebuild.xml b/prebuild.xml
index 81f907d..2d61b73 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -588,6 +588,7 @@
588 <ReferencePath>../../../../bin/</ReferencePath> 588 <ReferencePath>../../../../bin/</ReferencePath>
589 <Reference name="System"/> 589 <Reference name="System"/>
590 <Reference name="System.Drawing"/> 590 <Reference name="System.Drawing"/>
591 <Reference name="CSJ2K.dll"/>
591 <Reference name="OpenMetaverseTypes.dll"/> 592 <Reference name="OpenMetaverseTypes.dll"/>
592 <Reference name="OpenMetaverse.dll"/> 593 <Reference name="OpenMetaverse.dll"/>
593 <Reference name="Nini.dll" /> 594 <Reference name="Nini.dll" />
@@ -747,6 +748,7 @@
747 748
748 <ReferencePath>../../../bin/</ReferencePath> 749 <ReferencePath>../../../bin/</ReferencePath>
749 <Reference name="System"/> 750 <Reference name="System"/>
751 <Reference name="System.Core"/>
750 <Reference name="System.Xml"/> 752 <Reference name="System.Xml"/>
751 <Reference name="System.Drawing"/> 753 <Reference name="System.Drawing"/>
752 <Reference name="System.Web"/> 754 <Reference name="System.Web"/>
@@ -1411,6 +1413,37 @@
1411 </Files> 1413 </Files>
1412 </Project> 1414 </Project>
1413 1415
1416 <Project frameworkVersion="v3_5" name="OpenSim.Services.PresenceService" path="OpenSim/Services/PresenceService" type="Library">
1417 <Configuration name="Debug">
1418 <Options>
1419 <OutputPath>../../../bin/</OutputPath>
1420 </Options>
1421 </Configuration>
1422 <Configuration name="Release">
1423 <Options>
1424 <OutputPath>../../../bin/</OutputPath>
1425 </Options>
1426 </Configuration>
1427
1428 <ReferencePath>../../../bin/</ReferencePath>
1429 <Reference name="System"/>
1430 <Reference name="OpenMetaverseTypes.dll"/>
1431 <Reference name="OpenMetaverse.dll"/>
1432 <Reference name="OpenSim.Framework"/>
1433 <Reference name="OpenSim.Framework.Console"/>
1434 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
1435 <Reference name="OpenSim.Services.Interfaces"/>
1436 <Reference name="OpenSim.Services.Base"/>
1437 <Reference name="OpenSim.Services.Connectors"/>
1438 <Reference name="OpenSim.Data"/>
1439 <Reference name="Nini.dll" />
1440 <Reference name="log4net.dll"/>
1441
1442 <Files>
1443 <Match pattern="*.cs" recurse="true"/>
1444 </Files>
1445 </Project>
1446
1414 <Project frameworkVersion="v3_5" name="OpenSim.Services.InventoryService" path="OpenSim/Services/InventoryService" type="Library"> 1447 <Project frameworkVersion="v3_5" name="OpenSim.Services.InventoryService" path="OpenSim/Services/InventoryService" type="Library">
1415 <Configuration name="Debug"> 1448 <Configuration name="Debug">
1416 <Options> 1449 <Options>
@@ -2672,46 +2705,6 @@
2672 </Project> 2705 </Project>
2673 2706
2674 2707
2675 <Project frameworkVersion="v3_5" name="OpenSim.Region.ScriptEngine.DotNetEngine" path="OpenSim/Region/ScriptEngine/DotNetEngine" type="Library">
2676 <Configuration name="Debug">
2677 <Options>
2678 <OutputPath>../../../../bin/</OutputPath>
2679 </Options>
2680 </Configuration>
2681 <Configuration name="Release">
2682 <Options>
2683 <OutputPath>../../../../bin/</OutputPath>
2684 </Options>
2685 </Configuration>
2686
2687 <ReferencePath>../../../../bin/</ReferencePath>
2688 <ReferencePath>../../../../bin/</ReferencePath>
2689 <Reference name="System"/>
2690 <Reference name="System.Data"/>
2691 <Reference name="System.Xml"/>
2692 <Reference name="System.Runtime.Remoting"/>
2693 <Reference name="OpenMetaverseTypes.dll"/>
2694 <Reference name="OpenMetaverse.StructuredData.dll"/>
2695 <Reference name="RAIL.dll"/>
2696 <Reference name="OpenSim.Framework"/>
2697 <Reference name="OpenSim.Framework.Console"/>
2698 <Reference name="OpenSim.Region.CoreModules" />
2699 <Reference name="OpenSim.Region.Framework" />
2700 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
2701 <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/>
2702 <Reference name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime"/>
2703 <Reference name="OpenSim.Region.ScriptEngine.Shared.CodeTools"/>
2704 <Reference name="Microsoft.JScript"/>
2705 <Reference name="Nini.dll" />
2706 <Reference name="log4net.dll"/>
2707 <Reference name="Tools.dll"/>
2708
2709 <Files>
2710 <Match pattern="*.addin.xml" path="Resources" buildAction="EmbeddedResource" recurse="true"/>
2711 <Match pattern="*.cs" recurse="true"/>
2712 </Files>
2713 </Project>
2714
2715 <Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Shared.Script" path="OpenSim/ScriptEngine/Shared.Script" type="Library"> 2708 <Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Shared.Script" path="OpenSim/ScriptEngine/Shared.Script" type="Library">
2716 <Configuration name="Debug"> 2709 <Configuration name="Debug">
2717 <Options> 2710 <Options>
@@ -2813,251 +2806,6 @@
2813 </Files> 2806 </Files>
2814 </Project> 2807 </Project>
2815 2808
2816 <Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL" path="OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL" type="Library">
2817 <Configuration name="Debug">
2818 <Options>
2819 <OutputPath>../../../../../bin/</OutputPath>
2820 </Options>
2821 </Configuration>
2822 <Configuration name="Release">
2823 <Options>
2824 <OutputPath>../../../../../bin/</OutputPath>
2825 </Options>
2826 </Configuration>
2827
2828 <ReferencePath>../../../../../bin/</ReferencePath>
2829 <Reference name="System"/>
2830 <Reference name="System.Data"/>
2831 <Reference name="System.Web"/>
2832 <Reference name="System.Xml"/>
2833 <Reference name="OpenMetaverseTypes.dll"/>
2834 <Reference name="OpenMetaverse.dll"/>
2835 <Reference name="OpenSim" />
2836 <Reference name="OpenSim.Framework"/>
2837 <Reference name="OpenSim.Framework.Communications"/>
2838 <Reference name="OpenSim.Region.CoreModules" />
2839 <Reference name="OpenSim.Region.Framework" />
2840 <Reference name="OpenSim.Region.Physics.Manager" />
2841 <Reference name="OpenSim.Framework.Console"/>
2842 <Reference name="Nini.dll" />
2843 <Reference name="log4net.dll"/>
2844 <Reference name="OpenSim.ScriptEngine.Shared"/>
2845 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
2846 <Reference name="OpenSim.ScriptEngine.Shared.Script"/>
2847
2848 <Files>
2849 <Match pattern="*.cs" recurse="true" >
2850 <Exclude name="Tests" pattern="Tests" />
2851 </Match>
2852 </Files>
2853 </Project>
2854
2855 <Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL" path="OpenSim/ScriptEngine/Components/DotNetEngine/Commands_OSSL" type="Library">
2856 <Configuration name="Debug">
2857 <Options>
2858 <OutputPath>../../../../../bin/</OutputPath>
2859 </Options>
2860 </Configuration>
2861 <Configuration name="Release">
2862 <Options>
2863 <OutputPath>../../../../../bin/</OutputPath>
2864 </Options>
2865 </Configuration>
2866
2867 <ReferencePath>../../../../../bin/</ReferencePath>
2868 <Reference name="System"/>
2869 <Reference name="System.Data"/>
2870 <Reference name="System.Web"/>
2871 <Reference name="System.Xml"/>
2872 <Reference name="OpenMetaverseTypes.dll"/>
2873 <Reference name="OpenMetaverse.dll"/>
2874 <Reference name="OpenSim" />
2875 <Reference name="OpenSim.Framework"/>
2876 <Reference name="OpenSim.Framework.Communications"/>
2877 <Reference name="OpenSim.Region.CoreModules" />
2878 <Reference name="OpenSim.Region.Framework" />
2879 <Reference name="OpenSim.Region.Physics.Manager" />
2880 <Reference name="OpenSim.Framework.Console"/>
2881 <Reference name="Nini.dll" />
2882 <Reference name="log4net.dll"/>
2883 <Reference name="OpenSim.ScriptEngine.Shared"/>
2884 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
2885 <Reference name="OpenSim.ScriptEngine.Shared.Script"/>
2886
2887 <Files>
2888 <Match pattern="*.cs" recurse="true" >
2889 <Exclude name="Tests" pattern="Tests" />
2890 </Match>
2891 </Files>
2892 </Project>
2893
2894 <Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Components.DotNetEngine.Compilers" path="OpenSim/ScriptEngine/Components/DotNetEngine/Compilers" type="Library">
2895 <Configuration name="Debug">
2896 <Options>
2897 <OutputPath>../../../../../bin/</OutputPath>
2898 </Options>
2899 </Configuration>
2900 <Configuration name="Release">
2901 <Options>
2902 <OutputPath>../../../../../bin/</OutputPath>
2903 </Options>
2904 </Configuration>
2905
2906 <ReferencePath>../../../../../bin/</ReferencePath>
2907 <ReferencePath>../../../../../bin/ScriptEngines/</ReferencePath>
2908 <Reference name="System"/>
2909 <Reference name="System.Data"/>
2910 <Reference name="System.Web"/>
2911 <Reference name="System.Xml"/>
2912 <Reference name="OpenMetaverseTypes.dll"/>
2913 <Reference name="OpenMetaverse.dll"/>
2914 <Reference name="OpenSim" />
2915 <Reference name="OpenSim.Framework"/>
2916 <Reference name="OpenSim.Framework.Communications"/>
2917 <Reference name="OpenSim.Region.CoreModules" />
2918 <Reference name="OpenSim.Region.Framework" />
2919 <Reference name="OpenSim.Region.Physics.Manager" />
2920 <Reference name="OpenSim.Framework.Console"/>
2921 <Reference name="Nini.dll" />
2922 <Reference name="log4net.dll"/>
2923 <Reference name="OpenSim.ScriptEngine.Shared"/>
2924 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
2925 <Reference name="OpenSim.ScriptEngine.Shared.Script"/>
2926 <Reference name="OpenSim.Region.ScriptEngine.Shared.CodeTools"/>
2927 <Reference name="Microsoft.JScript"/>
2928
2929 <Files>
2930 <Match pattern="*.cs" recurse="true" >
2931 <Exclude name="Tests" pattern="Tests" />
2932 </Match>
2933 </Files>
2934 </Project>
2935
2936 <Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Components.DotNetEngine.Events" path="OpenSim/ScriptEngine/Components/DotNetEngine/Events" type="Library">
2937 <Configuration name="Debug">
2938 <Options>
2939 <OutputPath>../../../../../bin/</OutputPath>
2940 </Options>
2941 </Configuration>
2942 <Configuration name="Release">
2943 <Options>
2944 <OutputPath>../../../../../bin/</OutputPath>
2945 </Options>
2946 </Configuration>
2947
2948 <ReferencePath>../../../../../bin/</ReferencePath>
2949 <Reference name="System"/>
2950 <Reference name="System.Data"/>
2951 <Reference name="System.Web"/>
2952 <Reference name="System.Xml"/>
2953 <Reference name="OpenMetaverseTypes.dll"/>
2954 <Reference name="OpenMetaverse.dll"/>
2955 <Reference name="OpenSim" />
2956 <Reference name="OpenSim.Framework"/>
2957 <Reference name="OpenSim.Framework.Communications"/>
2958 <Reference name="OpenSim.Region.CoreModules" />
2959 <Reference name="OpenSim.Region.Framework" />
2960 <Reference name="OpenSim.Region.Physics.Manager" />
2961 <Reference name="OpenSim.Framework.Console"/>
2962 <Reference name="Nini.dll" />
2963 <Reference name="log4net.dll"/>
2964 <Reference name="OpenSim.ScriptEngine.Shared"/>
2965 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
2966 <Reference name="OpenSim.ScriptEngine.Shared.Script"/>
2967 <Reference name="Microsoft.JScript"/>
2968
2969 <Files>
2970 <Match pattern="*.cs" recurse="true" >
2971 <Exclude name="Tests" pattern="Tests" />
2972 </Match>
2973 </Files>
2974 </Project>
2975
2976 <Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler" path="OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler" type="Library">
2977 <Configuration name="Debug">
2978 <Options>
2979 <OutputPath>../../../../../bin/</OutputPath>
2980 </Options>
2981 </Configuration>
2982 <Configuration name="Release">
2983 <Options>
2984 <OutputPath>../../../../../bin/</OutputPath>
2985 </Options>
2986 </Configuration>
2987
2988 <ReferencePath>../../../../../bin/</ReferencePath>
2989 <ReferencePath>../../../../../bin/ScriptEngines/</ReferencePath>
2990 <Reference name="System"/>
2991 <Reference name="System.Data"/>
2992 <Reference name="System.Web"/>
2993 <Reference name="System.Xml"/>
2994 <Reference name="OpenMetaverseTypes.dll"/>
2995 <Reference name="OpenMetaverse.dll"/>
2996 <Reference name="OpenSim" />
2997 <Reference name="OpenSim.Framework"/>
2998 <Reference name="OpenSim.Framework.Communications"/>
2999 <Reference name="OpenSim.Region.CoreModules" />
3000 <Reference name="OpenSim.Region.Framework" />
3001 <Reference name="OpenSim.Region.Physics.Manager" />
3002 <Reference name="OpenSim.Framework.Console"/>
3003 <Reference name="Nini.dll" />
3004 <Reference name="log4net.dll"/>
3005 <Reference name="OpenSim.ScriptEngine.Shared"/>
3006 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
3007 <Reference name="OpenSim.ScriptEngine.Shared.Script"/>
3008
3009 <Files>
3010 <Match pattern="*.cs" recurse="true" >
3011 <Exclude name="Tests" pattern="Tests" />
3012 </Match>
3013 </Files>
3014 </Project>
3015
3016 <Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Engines.DotNetEngine" path="OpenSim/ScriptEngine/Engines/DotNetEngine" type="Library">
3017 <Configuration name="Debug">
3018 <Options>
3019 <OutputPath>../../../../bin/</OutputPath>
3020 </Options>
3021 </Configuration>
3022 <Configuration name="Release">
3023 <Options>
3024 <OutputPath>../../../../bin/</OutputPath>
3025 </Options>
3026 </Configuration>
3027
3028 <ReferencePath>../../../../bin/</ReferencePath>
3029 <ReferencePath>../../../../bin/ScriptEngines/</ReferencePath>
3030 <Reference name="System"/>
3031 <Reference name="System.Data"/>
3032 <Reference name="System.Web"/>
3033 <Reference name="System.Xml"/>
3034 <Reference name="OpenMetaverseTypes.dll"/>
3035 <Reference name="OpenMetaverse.dll"/>
3036 <Reference name="OpenSim" />
3037 <Reference name="OpenSim.Framework"/>
3038 <Reference name="OpenSim.Framework.Communications"/>
3039 <Reference name="OpenSim.Region.CoreModules" />
3040 <Reference name="OpenSim.Region.Framework" />
3041 <Reference name="OpenSim.Region.Physics.Manager" />
3042 <Reference name="OpenSim.Framework.Console"/>
3043 <Reference name="Nini.dll" />
3044 <Reference name="log4net.dll"/>
3045 <Reference name="OpenSim.ApplicationPlugins.ScriptEngine"/>
3046 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
3047 <Reference name="OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler"/>
3048 <Reference name="OpenSim.ScriptEngine.Components.DotNetEngine.Events"/>
3049 <Reference name="OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL"/>
3050 <Reference name="OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL"/>
3051 <Reference name="OpenSim.ScriptEngine.Shared"/>
3052 <Reference name="OpenSim.ScriptEngine.Shared.Script"/>
3053
3054 <Files>
3055 <Match pattern="*.cs" recurse="true" >
3056 <Exclude name="Tests" pattern="Tests" />
3057 </Match>
3058 </Files>
3059 </Project>
3060
3061 <Project frameworkVersion="v3_5" name="OpenSim.Region.UserStatistics" path="OpenSim/Region/UserStatistics" type="Library"> 2809 <Project frameworkVersion="v3_5" name="OpenSim.Region.UserStatistics" path="OpenSim/Region/UserStatistics" type="Library">
3062 <Configuration name="Debug"> 2810 <Configuration name="Debug">
3063 <Options> 2811 <Options>
@@ -3135,7 +2883,7 @@
3135 </Files> 2883 </Files>
3136 </Project> 2884 </Project>
3137 2885
3138 <Project name="OpenSim.Tools.lslc" path="OpenSim/Tools/Compiler" type="Exe"> 2886 <Project frameworkVersion="v3_5" name="OpenSim.Tools.lslc" path="OpenSim/Tools/Compiler" type="Exe">
3139 <Configuration name="Debug"> 2887 <Configuration name="Debug">
3140 <Options> 2888 <Options>
3141 <OutputPath>../../../bin/</OutputPath> 2889 <OutputPath>../../../bin/</OutputPath>
diff --git a/runprebuild2010.bat b/runprebuild2010.bat
new file mode 100644
index 0000000..8c832b3
--- /dev/null
+++ b/runprebuild2010.bat
@@ -0,0 +1,2 @@
1bin\Prebuild.exe /target vs2010
2echo C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild OpenSim.sln > compile.bat