aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2009-10-27 11:32:11 +0000
committerMelanie2009-10-27 11:32:11 +0000
commit31a848e97bd984ab0a85feca397ce419f6ae839a (patch)
tree4743f5eb7c12b3723ed4b986d19714d1b3a0a3ea /OpenSim
parentCommented out instrumentation in ODEPrim.cs (diff)
parentFinally hunted down the Parallel deadlock. Packets were being handled asynchr... (diff)
downloadopensim-SC_OLD-31a848e97bd984ab0a85feca397ce419f6ae839a.zip
opensim-SC_OLD-31a848e97bd984ab0a85feca397ce419f6ae839a.tar.gz
opensim-SC_OLD-31a848e97bd984ab0a85feca397ce419f6ae839a.tar.bz2
opensim-SC_OLD-31a848e97bd984ab0a85feca397ce419f6ae839a.tar.xz
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim')
-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.cs55
-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.cs42
-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.cs99
-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.cs146
-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.cs86
-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.cs27
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs318
-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/EventQueueThreadClass.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs83
-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/Server/ServerMain.cs2
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs53
-rw-r--r--OpenSim/Services/PresenceService/PresenceServiceBase.cs84
-rw-r--r--OpenSim/Tools/pCampBot/PhysicsBot.cs7
89 files changed, 2417 insertions, 1740 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/Data/IPresenceData.cs b/OpenSim/Data/IPresenceData.cs
new file mode 100644
index 0000000..ca661a2
--- /dev/null
+++ b/OpenSim/Data/IPresenceData.cs
@@ -0,0 +1,55 @@
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 OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Data
34{
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
46 {
47 bool Store(PresenceData data);
48
49 PresenceData Get(UUID principalID);
50
51 bool SetDataItem(UUID principalID, string item, string value);
52
53 bool Delete(UUID regionID);
54 }
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..10f38ab 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,14 @@ 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
1327 STPStartInfo startInfo = new STPStartInfo();
1328 startInfo.IdleTimeout = 2000; // 2 seconds
1329 startInfo.MaxWorkerThreads = maxThreads;
1330 startInfo.MinWorkerThreads = 2;
1331 startInfo.StackSize = 524288;
1332 startInfo.ThreadPriority = ThreadPriority.Normal;
1333 1329
1334 startInfo.StartSuspended = false; 1330 m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2);
1335
1336 m_ThreadPool = new SmartThreadPool(startInfo);
1337 } 1331 }
1338 1332
1339 public static void FireAndForget(System.Threading.WaitCallback callback, object obj) 1333 public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
@@ -1341,20 +1335,22 @@ namespace OpenSim.Framework
1341 switch (FireAndForgetMethod) 1335 switch (FireAndForgetMethod)
1342 { 1336 {
1343 case FireAndForgetMethod.UnsafeQueueUserWorkItem: 1337 case FireAndForgetMethod.UnsafeQueueUserWorkItem:
1344 System.Threading.ThreadPool.UnsafeQueueUserWorkItem(callback, obj); 1338 ThreadPool.UnsafeQueueUserWorkItem(callback, obj);
1345 break; 1339 break;
1346 case FireAndForgetMethod.QueueUserWorkItem: 1340 case FireAndForgetMethod.QueueUserWorkItem:
1347 System.Threading.ThreadPool.QueueUserWorkItem(callback, obj); 1341 ThreadPool.QueueUserWorkItem(callback, obj);
1348 break; 1342 break;
1349 case FireAndForgetMethod.BeginInvoke: 1343 case FireAndForgetMethod.BeginInvoke:
1350 FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>(); 1344 FireAndForgetWrapper wrapper = Singleton.GetInstance<FireAndForgetWrapper>();
1351 wrapper.FireAndForget(callback, obj); 1345 wrapper.FireAndForget(callback, obj);
1352 break; 1346 break;
1353 case FireAndForgetMethod.SmartThreadPool: 1347 case FireAndForgetMethod.SmartThreadPool:
1354 m_ThreadPool.QueueWorkItem(delegate(object o) { callback(o); return null; }, obj); 1348 if (m_ThreadPool == null)
1349 m_ThreadPool = new SmartThreadPool(2000, 15, 2);
1350 m_ThreadPool.QueueWorkItem(SmartThreadPoolCallback, new object[] { callback, obj });
1355 break; 1351 break;
1356 case FireAndForgetMethod.Thread: 1352 case FireAndForgetMethod.Thread:
1357 System.Threading.Thread thread = new System.Threading.Thread(delegate(object o) { callback(o); }); 1353 Thread thread = new Thread(delegate(object o) { callback(o); });
1358 thread.Start(obj); 1354 thread.Start(obj);
1359 break; 1355 break;
1360 default: 1356 default:
@@ -1362,6 +1358,16 @@ namespace OpenSim.Framework
1362 } 1358 }
1363 } 1359 }
1364 1360
1361 private static object SmartThreadPoolCallback(object o)
1362 {
1363 object[] array = (object[])o;
1364 WaitCallback callback = (WaitCallback)array[0];
1365 object obj = array[1];
1366
1367 callback(obj);
1368 return null;
1369 }
1370
1365 #endregion FireAndForget Threading Pattern 1371 #endregion FireAndForget Threading Pattern
1366 } 1372 }
1367} 1373}
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..e3233da 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
@@ -775,11 +808,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
775 { 808 {
776 m_log.Error("[LLUDPSERVER]: Error in the incoming packet handler loop: " + ex.Message, ex); 809 m_log.Error("[LLUDPSERVER]: Error in the incoming packet handler loop: " + ex.Message, ex);
777 } 810 }
811
812 Watchdog.UpdateThread();
778 } 813 }
779 814
780 if (packetInbox.Count > 0) 815 if (packetInbox.Count > 0)
781 m_log.Warn("[LLUDPSERVER]: IncomingPacketHandler is shutting down, dropping " + packetInbox.Count + " packets"); 816 m_log.Warn("[LLUDPSERVER]: IncomingPacketHandler is shutting down, dropping " + packetInbox.Count + " packets");
782 packetInbox.Clear(); 817 packetInbox.Clear();
818
819 Watchdog.RemoveThread();
783 } 820 }
784 821
785 private void OutgoingPacketHandler() 822 private void OutgoingPacketHandler()
@@ -788,6 +825,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
788 // on to en-US to avoid number parsing issues 825 // on to en-US to avoid number parsing issues
789 Culture.SetCurrentCulture(); 826 Culture.SetCurrentCulture();
790 827
828 // Typecast the function to an Action<IClientAPI> once here to avoid allocating a new
829 // Action generic every round
830 Action<IClientAPI> clientPacketHandler = ClientOutgoingPacketHandler;
831
791 while (base.IsRunning) 832 while (base.IsRunning)
792 { 833 {
793 try 834 try
@@ -836,18 +877,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
836 877
837 // Handle outgoing packets, resends, acknowledgements, and pings for each 878 // Handle outgoing packets, resends, acknowledgements, and pings for each
838 // client. m_packetSent will be set to true if a packet is sent 879 // client. m_packetSent will be set to true if a packet is sent
839 m_scene.ClientManager.ForEachSync(ClientOutgoingPacketHandler); 880 m_scene.ForEachClient(clientPacketHandler, false);
840 881
841 // If nothing was sent, sleep for the minimum amount of time before a 882 // If nothing was sent, sleep for the minimum amount of time before a
842 // token bucket could get more tokens 883 // token bucket could get more tokens
843 if (!m_packetSent) 884 if (!m_packetSent)
844 Thread.Sleep((int)TickCountResolution); 885 Thread.Sleep((int)TickCountResolution);
886
887 Watchdog.UpdateThread();
845 } 888 }
846 catch (Exception ex) 889 catch (Exception ex)
847 { 890 {
848 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex); 891 m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler loop threw an exception: " + ex.Message, ex);
849 } 892 }
850 } 893 }
894
895 Watchdog.RemoveThread();
851 } 896 }
852 897
853 private void ClientOutgoingPacketHandler(IClientAPI client) 898 private void ClientOutgoingPacketHandler(IClientAPI client)
@@ -897,7 +942,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
897 } 942 }
898 943
899 // Make sure this client is still alive 944 // Make sure this client is still alive
900 if (m_scene.ClientManager.TryGetValue(udpClient.AgentID, out client)) 945 if (m_scene.TryGetClient(udpClient.AgentID, out client))
901 { 946 {
902 try 947 try
903 { 948 {
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..42051d0 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,17 +265,17 @@ 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;
@@ -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,28 @@ 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 //if (doAsynchronous)
4268 // m_clientManager.ForEach(action);
4269 //else
4270 // m_clientManager.ForEachSync(action);
4271 }
4272
4273 public bool TryGetClient(UUID avatarID, out IClientAPI client)
4274 {
4275 return m_clientManager.TryGetValue(avatarID, out client);
4276 }
4277
4278 public bool TryGetClient(System.Net.IPEndPoint remoteEndPoint, out IClientAPI client)
4279 {
4280 return m_clientManager.TryGetValue(remoteEndPoint, out client);
4243 } 4281 }
4244 4282
4245 public void ForEachSOG(Action<SceneObjectGroup> action) 4283 public void ForEachSOG(Action<SceneObjectGroup> action)
@@ -4571,7 +4609,7 @@ namespace OpenSim.Region.Framework.Scenes
4571 { 4609 {
4572 case PhysicsJointType.Ball: 4610 case PhysicsJointType.Ball:
4573 { 4611 {
4574 PhysicsVector jointAnchor = PhysicsScene.GetJointAnchor(joint); 4612 Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint);
4575 Vector3 proxyPos = new Vector3(jointAnchor.X, jointAnchor.Y, jointAnchor.Z); 4613 Vector3 proxyPos = new Vector3(jointAnchor.X, jointAnchor.Y, jointAnchor.Z);
4576 jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update 4614 jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos); // schedules the entire group for a terse update
4577 } 4615 }
@@ -4579,7 +4617,7 @@ namespace OpenSim.Region.Framework.Scenes
4579 4617
4580 case PhysicsJointType.Hinge: 4618 case PhysicsJointType.Hinge:
4581 { 4619 {
4582 PhysicsVector jointAnchor = PhysicsScene.GetJointAnchor(joint); 4620 Vector3 jointAnchor = PhysicsScene.GetJointAnchor(joint);
4583 4621
4584 // Normally, we would just ask the physics scene to return the axis for the joint. 4622 // 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 4623 // 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 69b3ded..38a0cff 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 }
@@ -2375,7 +2374,7 @@ namespace OpenSim.Region.Framework.Scenes
2375 if (m_rootPart.PhysActor.IsPhysical) 2374 if (m_rootPart.PhysActor.IsPhysical)
2376 { 2375 {
2377 Vector3 llmoveforce = pos - AbsolutePosition; 2376 Vector3 llmoveforce = pos - AbsolutePosition;
2378 PhysicsVector grabforce = new PhysicsVector(llmoveforce.X, llmoveforce.Y, llmoveforce.Z); 2377 Vector3 grabforce = llmoveforce;
2379 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; 2378 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass;
2380 m_rootPart.PhysActor.AddForce(grabforce,true); 2379 m_rootPart.PhysActor.AddForce(grabforce,true);
2381 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2380 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
@@ -2480,7 +2479,7 @@ namespace OpenSim.Region.Framework.Scenes
2480 rotationAxis.Normalize(); 2479 rotationAxis.Normalize();
2481 2480
2482 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); 2481 //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis);
2483 PhysicsVector spinforce = new PhysicsVector(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); 2482 Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z);
2484 spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor 2483 spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor
2485 m_rootPart.PhysActor.AddAngularForce(spinforce,true); 2484 m_rootPart.PhysActor.AddAngularForce(spinforce,true);
2486 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2485 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
@@ -2707,8 +2706,7 @@ namespace OpenSim.Region.Framework.Scenes
2707 if (scale.Z > m_scene.m_maxPhys) 2706 if (scale.Z > m_scene.m_maxPhys)
2708 scale.Z = m_scene.m_maxPhys; 2707 scale.Z = m_scene.m_maxPhys;
2709 } 2708 }
2710 part.PhysActor.Size = 2709 part.PhysActor.Size = scale;
2711 new PhysicsVector(scale.X, scale.Y, scale.Z);
2712 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2710 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2713 } 2711 }
2714 //if (part.UUID != m_rootPart.UUID) 2712 //if (part.UUID != m_rootPart.UUID)
@@ -2852,8 +2850,7 @@ namespace OpenSim.Region.Framework.Scenes
2852 2850
2853 if (part.PhysActor != null) 2851 if (part.PhysActor != null)
2854 { 2852 {
2855 part.PhysActor.Size = 2853 part.PhysActor.Size = prevScale;
2856 new PhysicsVector(prevScale.X, prevScale.Y, prevScale.Z);
2857 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 2854 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
2858 } 2855 }
2859 2856
@@ -3366,6 +3363,8 @@ namespace OpenSim.Region.Framework.Scenes
3366 return GetPriorityByDistance(client); 3363 return GetPriorityByDistance(client);
3367 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: 3364 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3368 return GetPriorityBySimpleAngularDistance(client); 3365 return GetPriorityBySimpleAngularDistance(client);
3366 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3367 return GetPriorityByFrontBack(client);
3369 default: 3368 default:
3370 throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); 3369 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3371 } 3370 }
@@ -3398,6 +3397,16 @@ namespace OpenSim.Region.Framework.Scenes
3398 return double.NaN; 3397 return double.NaN;
3399 } 3398 }
3400 3399
3400 private double GetPriorityByFrontBack(IClientAPI client)
3401 {
3402 ScenePresence presence = Scene.GetScenePresence(client.AgentId);
3403 if (presence != null)
3404 {
3405 return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis);
3406 }
3407 return double.NaN;
3408 }
3409
3401 public double GetPriorityByDistance(Vector3 position) 3410 public double GetPriorityByDistance(Vector3 position)
3402 { 3411 {
3403 return Vector3.Distance(AbsolutePosition, position); 3412 return Vector3.Distance(AbsolutePosition, position);
@@ -3427,5 +3436,21 @@ namespace OpenSim.Region.Framework.Scenes
3427 else 3436 else
3428 return double.MinValue; 3437 return double.MinValue;
3429 } 3438 }
3439
3440 public double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis)
3441 {
3442 // Distance
3443 double priority = Vector3.Distance(camPosition, AbsolutePosition);
3444
3445 // Scale
3446 //priority -= GroupScale().Length();
3447
3448 // Plane equation
3449 float d = -Vector3.Dot(camPosition, camAtAxis);
3450 float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d;
3451 if (p < 0.0f) priority *= 2.0f;
3452
3453 return priority;
3454 }
3430 } 3455 }
3431} 3456}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 32171a0..70f3112 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
@@ -2312,8 +2316,8 @@ if (m_shape != null) {
2312 /// </summary> 2316 /// </summary>
2313 public void SendFullUpdateToAllClients() 2317 public void SendFullUpdateToAllClients()
2314 { 2318 {
2315 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2319 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2316 for (int i = 0; i < avatars.Count; i++) 2320 for (int i = 0; i < avatars.Length; i++)
2317 { 2321 {
2318 // Ugly reference :( 2322 // Ugly reference :(
2319 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, 2323 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
@@ -2323,8 +2327,8 @@ if (m_shape != null) {
2323 2327
2324 public void SendFullUpdateToAllClientsExcept(UUID agentID) 2328 public void SendFullUpdateToAllClientsExcept(UUID agentID)
2325 { 2329 {
2326 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2330 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2327 for (int i = 0; i < avatars.Count; i++) 2331 for (int i = 0; i < avatars.Length; i++)
2328 { 2332 {
2329 // Ugly reference :( 2333 // Ugly reference :(
2330 if (avatars[i].UUID != agentID) 2334 if (avatars[i].UUID != agentID)
@@ -2389,18 +2393,36 @@ if (m_shape != null) {
2389 /// </summary> 2393 /// </summary>
2390 public void SendScheduledUpdates() 2394 public void SendScheduledUpdates()
2391 { 2395 {
2392 if (m_updateFlag == 1) //some change has been made so update the clients 2396 const float VELOCITY_TOLERANCE = 0.01f;
2397 const float POSITION_TOLERANCE = 10.0f;
2398
2399 if (m_updateFlag == 1)
2393 { 2400 {
2394 AddTerseUpdateToAllAvatars(); 2401 // Throw away duplicate or insignificant updates
2395 ClearUpdateSchedule(); 2402 if (RotationOffset != m_lastRotation ||
2403 Acceleration != m_lastAcceleration ||
2404 (Velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE ||
2405 (RotationalVelocity - m_lastAngularVelocity).Length() > VELOCITY_TOLERANCE ||
2406 (OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE)
2407 {
2408 AddTerseUpdateToAllAvatars();
2409 ClearUpdateSchedule();
2396 2410
2397 // This causes the Scene to 'poll' physical objects every couple of frames 2411 // This causes the Scene to 'poll' physical objects every couple of frames
2398 // bad, so it's been replaced by an event driven method. 2412 // bad, so it's been replaced by an event driven method.
2399 //if ((ObjectFlags & (uint)PrimFlags.Physics) != 0) 2413 //if ((ObjectFlags & (uint)PrimFlags.Physics) != 0)
2400 //{ 2414 //{
2401 // Only send the constant terse updates on physical objects! 2415 // Only send the constant terse updates on physical objects!
2402 //ScheduleTerseUpdate(); 2416 //ScheduleTerseUpdate();
2403 //} 2417 //}
2418
2419 // Update the "last" values
2420 m_lastPosition = OffsetPosition;
2421 m_lastRotation = RotationOffset;
2422 m_lastVelocity = Velocity;
2423 m_lastAcceleration = Acceleration;
2424 m_lastAngularVelocity = RotationalVelocity;
2425 }
2404 } 2426 }
2405 else 2427 else
2406 { 2428 {
@@ -2467,8 +2489,8 @@ if (m_shape != null) {
2467 /// </summary> 2489 /// </summary>
2468 public void SendTerseUpdateToAllClients() 2490 public void SendTerseUpdateToAllClients()
2469 { 2491 {
2470 List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); 2492 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2471 for (int i = 0; i < avatars.Count; i++) 2493 for (int i = 0; i < avatars.Length; i++)
2472 { 2494 {
2473 SendTerseUpdateToClient(avatars[i].ControllingClient); 2495 SendTerseUpdateToClient(avatars[i].ControllingClient);
2474 } 2496 }
@@ -2542,7 +2564,7 @@ if (m_shape != null) {
2542 } 2564 }
2543 } 2565 }
2544 2566
2545 public void SetForce(PhysicsVector force) 2567 public void SetForce(Vector3 force)
2546 { 2568 {
2547 if (PhysActor != null) 2569 if (PhysActor != null)
2548 { 2570 {
@@ -2566,7 +2588,7 @@ if (m_shape != null) {
2566 } 2588 }
2567 } 2589 }
2568 2590
2569 public void SetVehicleVectorParam(int param, PhysicsVector value) 2591 public void SetVehicleVectorParam(int param, Vector3 value)
2570 { 2592 {
2571 if (PhysActor != null) 2593 if (PhysActor != null)
2572 { 2594 {
@@ -3408,8 +3430,8 @@ if (m_shape != null) {
3408 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( 3430 PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
3409 Name, 3431 Name,
3410 Shape, 3432 Shape,
3411 new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z), 3433 AbsolutePosition,
3412 new PhysicsVector(Scale.X, Scale.Y, Scale.Z), 3434 Scale,
3413 RotationOffset, 3435 RotationOffset,
3414 UsePhysics); 3436 UsePhysics);
3415 3437
@@ -3549,7 +3571,7 @@ if (m_shape != null) {
3549 // in SL. 3571 // in SL.
3550 // 3572 //
3551 if (ParentGroup.RootPart != this) 3573 if (ParentGroup.RootPart != this)
3552 ParentGroup.RootPart.Rezzed = DateTime.Now; 3574 ParentGroup.RootPart.Rezzed = DateTime.UtcNow;
3553 3575
3554 ParentGroup.HasGroupChanged = true; 3576 ParentGroup.HasGroupChanged = true;
3555 ScheduleFullUpdate(); 3577 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 8d8b3fe..8df997e 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 8da9687..5ed3b14 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
@@ -634,7 +626,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
634 /// </summary> 626 /// </summary>
635 /// <param name="force"></param> 627 /// <param name="force"></param>
636 /// <param name="pushforce">Is this a push by a script?</param> 628 /// <param name="pushforce">Is this a push by a script?</param>
637 public override void AddForce(PhysicsVector force, bool pushforce) 629 public override void AddForce(Vector3 force, bool pushforce)
638 { 630 {
639 if (pushforce) 631 if (pushforce)
640 { 632 {
@@ -656,7 +648,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
656 //m_lastUpdateSent = false; 648 //m_lastUpdateSent = false;
657 } 649 }
658 650
659 public void doForce(PhysicsVector force, bool now) 651 public void doForce(Vector3 force, bool now)
660 { 652 {
661 653
662 tempVector3.setValue(force.X, force.Y, force.Z); 654 tempVector3.setValue(force.X, force.Y, force.Z);
@@ -671,7 +663,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
671 } 663 }
672 } 664 }
673 665
674 public void doImpulse(PhysicsVector force, bool now) 666 public void doImpulse(Vector3 force, bool now)
675 { 667 {
676 668
677 tempVector3.setValue(force.X, force.Y, force.Z); 669 tempVector3.setValue(force.X, force.Y, force.Z);
@@ -686,12 +678,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
686 } 678 }
687 } 679 }
688 680
689 public override void AddAngularForce(PhysicsVector force, bool pushforce) 681 public override void AddAngularForce(Vector3 force, bool pushforce)
690 { 682 {
691 683
692 } 684 }
693 685
694 public override void SetMomentum(PhysicsVector momentum) 686 public override void SetMomentum(Vector3 momentum)
695 { 687 {
696 688
697 } 689 }
@@ -808,7 +800,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
808 800
809 AvatarGeomAndBodyCreation(m_position.X, m_position.Y, 801 AvatarGeomAndBodyCreation(m_position.X, m_position.Y,
810 m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2)); 802 m_position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2));
811 Velocity = new PhysicsVector(0f, 0f, 0f); 803 Velocity = Vector3.Zero;
812 804
813 } 805 }
814 else 806 else
@@ -852,9 +844,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
852 } 844 }
853 //PidStatus = true; 845 //PidStatus = true;
854 846
855 PhysicsVector vec = new PhysicsVector(); 847 Vector3 vec = Vector3.Zero;
856 848
857 PhysicsVector vel = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); 849 Vector3 vel = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
858 850
859 float movementdivisor = 1f; 851 float movementdivisor = 1f;
860 852
@@ -885,7 +877,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
885 // Avatar to Avatar collisions 877 // Avatar to Avatar collisions
886 // Prim to avatar collisions 878 // Prim to avatar collisions
887 879
888 PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); 880 Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
889 vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2); 881 vec.X = (m_target_velocity.X - vel.X) * (PID_D) + (m_zeroPosition.X - pos.X) * (PID_P * 2);
890 vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2); 882 vec.Y = (m_target_velocity.Y - vel.Y) * (PID_D) + (m_zeroPosition.Y - pos.Y) * (PID_P * 2);
891 if (m_flying) 883 if (m_flying)
@@ -927,7 +919,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
927 { 919 {
928 // We're colliding with something and we're not flying but we're moving 920 // We're colliding with something and we're not flying but we're moving
929 // This means we're walking or running. 921 // This means we're walking or running.
930 PhysicsVector pos = new PhysicsVector(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ()); 922 Vector3 pos = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
931 vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P; 923 vec.Z = (m_target_velocity.Z - vel.Z) * PID_D + (m_zeroPosition.Z - pos.Z) * PID_P;
932 if (m_target_velocity.X > 0) 924 if (m_target_velocity.X > 0)
933 { 925 {
@@ -1016,7 +1008,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1016 tempVector2 = Body.getInterpolationLinearVelocity(); 1008 tempVector2 = Body.getInterpolationLinearVelocity();
1017 1009
1018 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 1010 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
1019 PhysicsVector vec = new PhysicsVector(tempVector1.getX(),tempVector1.getY(),tempVector1.getZ()); 1011 Vector3 vec = new Vector3(tempVector1.getX(), tempVector1.getY(), tempVector1.getZ());
1020 1012
1021 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 1013 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
1022 if (vec.X < -10.0f) vec.X = 0.0f; 1014 if (vec.X < -10.0f) vec.X = 0.0f;
@@ -1048,7 +1040,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1048 else 1040 else
1049 { 1041 {
1050 m_lastUpdateSent = false; 1042 m_lastUpdateSent = false;
1051 vec = new PhysicsVector(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ()); 1043 vec = new Vector3(tempVector2.getX(), tempVector2.getY(), tempVector2.getZ());
1052 m_velocity.X = (vec.X); 1044 m_velocity.X = (vec.X);
1053 m_velocity.Y = (vec.Y); 1045 m_velocity.Y = (vec.Y);
1054 1046
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
index f22ea71..5b542db 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
@@ -567,20 +566,20 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
567 public override float PIDHoverTau { set { m_PIDHoverTau = value; } } 566 public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
568 567
569 568
570 public override void AddForce(PhysicsVector force, bool pushforce) 569 public override void AddForce(Vector3 force, bool pushforce)
571 { 570 {
572 m_forcelist.Add(force); 571 m_forcelist.Add(force);
573 m_taintforce = true; 572 m_taintforce = true;
574 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); 573 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
575 } 574 }
576 575
577 public override void AddAngularForce(PhysicsVector force, bool pushforce) 576 public override void AddAngularForce(Vector3 force, bool pushforce)
578 { 577 {
579 m_angularforcelist.Add(force); 578 m_angularforcelist.Add(force);
580 m_taintaddangularforce = true; 579 m_taintaddangularforce = true;
581 } 580 }
582 581
583 public override void SetMomentum(PhysicsVector momentum) 582 public override void SetMomentum(Vector3 momentum)
584 { 583 {
585 } 584 }
586 585
@@ -778,7 +777,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
778 777
779 } 778 }
780 779
781 if (!_position.IsIdentical(m_taintposition, 0f)) 780 if (!_position.ApproxEquals(m_taintposition, 0f))
782 { 781 {
783 m_log.Debug("[PHYSICS]: TaintMove"); 782 m_log.Debug("[PHYSICS]: TaintMove");
784 changemove(timestep); 783 changemove(timestep);
@@ -796,7 +795,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
796 } 795 }
797 // 796 //
798 797
799 if (!_size.IsIdentical(m_taintsize, 0)) 798 if (!_size.ApproxEquals(m_taintsize, 0f))
800 { 799 {
801 m_log.Debug("[PHYSICS]: TaintSize"); 800 m_log.Debug("[PHYSICS]: TaintSize");
802 changesize(timestep); 801 changesize(timestep);
@@ -820,7 +819,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
820 m_log.Debug("[PHYSICS]: TaintAngularForce"); 819 m_log.Debug("[PHYSICS]: TaintAngularForce");
821 changeAddAngularForce(timestep); 820 changeAddAngularForce(timestep);
822 } 821 }
823 if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) 822 if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
824 { 823 {
825 m_log.Debug("[PHYSICS]: TaintTorque"); 824 m_log.Debug("[PHYSICS]: TaintTorque");
826 changeSetTorque(timestep); 825 changeSetTorque(timestep);
@@ -835,7 +834,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
835 m_log.Debug("[PHYSICS]: TaintSelected"); 834 m_log.Debug("[PHYSICS]: TaintSelected");
836 changeSelectedStatus(timestep); 835 changeSelectedStatus(timestep);
837 } 836 }
838 if (!m_taintVelocity.IsIdentical(PhysicsVector.Zero, 0.001f)) 837 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
839 { 838 {
840 m_log.Debug("[PHYSICS]: TaintVelocity"); 839 m_log.Debug("[PHYSICS]: TaintVelocity");
841 changevelocity(timestep); 840 changevelocity(timestep);
@@ -849,7 +848,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
849 { 848 {
850 changefloatonwater(timestep); 849 changefloatonwater(timestep);
851 } 850 }
852 if (!m_angularlock.IsIdentical(m_taintAngularLock, 0)) 851 if (!m_angularlock.ApproxEquals(m_taintAngularLock, 0))
853 { 852 {
854 m_log.Debug("[PHYSICS]: TaintAngularLock"); 853 m_log.Debug("[PHYSICS]: TaintAngularLock");
855 changeAngularLock(timestep); 854 changeAngularLock(timestep);
@@ -1012,7 +1011,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1012 { 1011 {
1013 if (_parent_scene.needsMeshing(_pbs)) 1012 if (_parent_scene.needsMeshing(_pbs))
1014 { 1013 {
1015 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); 1014 ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
1016 // createmesh returns null when it doesn't mesh. 1015 // createmesh returns null when it doesn't mesh.
1017 CreateGeom(IntPtr.Zero, _mesh); 1016 CreateGeom(IntPtr.Zero, _mesh);
1018 } 1017 }
@@ -1029,7 +1028,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1029 return _parent_scene.needsMeshing(_pbs); 1028 return _parent_scene.needsMeshing(_pbs);
1030 } 1029 }
1031 1030
1032 internal void ProcessGeomCreationAsTriMesh(PhysicsVector positionOffset, Quaternion orientation) 1031 internal void ProcessGeomCreationAsTriMesh(Vector3 positionOffset, Quaternion orientation)
1033 { 1032 {
1034 // Don't need to re-enable body.. it's done in SetMesh 1033 // Don't need to re-enable body.. it's done in SetMesh
1035 float meshlod = _parent_scene.meshSculptLOD; 1034 float meshlod = _parent_scene.meshSculptLOD;
@@ -1038,7 +1037,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1038 meshlod = _parent_scene.MeshSculptphysicalLOD; 1037 meshlod = _parent_scene.MeshSculptphysicalLOD;
1039 1038
1040 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical); 1039 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical);
1041 if (!positionOffset.IsIdentical(PhysicsVector.Zero, 0.001f) || orientation != Quaternion.Identity) 1040 if (!positionOffset.ApproxEquals(Vector3.Zero, 0.001f) || orientation != Quaternion.Identity)
1042 { 1041 {
1043 1042
1044 float[] xyz = new float[3]; 1043 float[] xyz = new float[3];
@@ -1202,7 +1201,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1202 //m_log.Info("[PHYSICS]: dequeing forcelist"); 1201 //m_log.Info("[PHYSICS]: dequeing forcelist");
1203 if (IsPhysical) 1202 if (IsPhysical)
1204 { 1203 {
1205 PhysicsVector iforce = new PhysicsVector(); 1204 Vector3 iforce = Vector3.Zero;
1206 for (int i = 0; i < m_forcelist.Count; i++) 1205 for (int i = 0; i < m_forcelist.Count; i++)
1207 { 1206 {
1208 iforce = iforce + m_forcelist[i]; 1207 iforce = iforce + m_forcelist[i];
@@ -1237,7 +1236,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1237 //m_log.Info("[PHYSICS]: dequeing forcelist"); 1236 //m_log.Info("[PHYSICS]: dequeing forcelist");
1238 if (IsPhysical) 1237 if (IsPhysical)
1239 { 1238 {
1240 PhysicsVector iforce = new PhysicsVector(); 1239 Vector3 iforce = Vector3.Zero;
1241 for (int i = 0; i < m_angularforcelist.Count; i++) 1240 for (int i = 0; i < m_angularforcelist.Count; i++)
1242 { 1241 {
1243 iforce = iforce + m_angularforcelist[i]; 1242 iforce = iforce + m_angularforcelist[i];
@@ -1276,7 +1275,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1276 } 1275 }
1277 } 1276 }
1278 } 1277 }
1279 m_taintTorque = new PhysicsVector(0, 0, 0); 1278 m_taintTorque = Vector3.Zero;
1280 } 1279 }
1281 1280
1282 private void changedisable(float timestep) 1281 private void changedisable(float timestep)
@@ -1317,7 +1316,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1317 1316
1318 //resetCollisionAccounting(); 1317 //resetCollisionAccounting();
1319 } 1318 }
1320 m_taintVelocity = PhysicsVector.Zero; 1319 m_taintVelocity = Vector3.Zero;
1321 } 1320 }
1322 1321
1323 private void changelink(float timestep) 1322 private void changelink(float timestep)
@@ -1361,7 +1360,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1361 1360
1362 if (m_taintparent != null) 1361 if (m_taintparent != null)
1363 { 1362 {
1364 m_taintparent.Position.Z = m_taintparent.Position.Z + 0.02f; 1363 Vector3 taintparentPosition = m_taintparent.Position;
1364 taintparentPosition.Z = m_taintparent.Position.Z + 0.02f;
1365 m_taintparent.Position = taintparentPosition;
1365 _parent_scene.AddPhysicsActorTaint(m_taintparent); 1366 _parent_scene.AddPhysicsActorTaint(m_taintparent);
1366 } 1367 }
1367 } 1368 }
@@ -1382,7 +1383,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1382 { 1383 {
1383 if (_parent == null) 1384 if (_parent == null)
1384 { 1385 {
1385 if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f, 1f, 1f), 0)) 1386 if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
1386 { 1387 {
1387 //d.BodySetFiniteRotationMode(Body, 0); 1388 //d.BodySetFiniteRotationMode(Body, 0);
1388 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z); 1389 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
@@ -1395,7 +1396,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1395 } 1396 }
1396 1397
1397 } 1398 }
1398 m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); 1399 m_angularlock = m_taintAngularLock;
1399 1400
1400 } 1401 }
1401 #endregion 1402 #endregion
@@ -1460,17 +1461,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1460 // TODO: NEED btVector3 for Linear Velocity 1461 // TODO: NEED btVector3 for Linear Velocity
1461 // NEED btVector3 for Position 1462 // NEED btVector3 for Position
1462 1463
1463 PhysicsVector pos = new PhysicsVector(_position.X, _position.Y, _position.Z); //TODO: Insert values gotten from bullet 1464 Vector3 pos = _position; //TODO: Insert values gotten from bullet
1464 PhysicsVector vel = new PhysicsVector(_velocity.X, _velocity.Y, _velocity.Z); 1465 Vector3 vel = _velocity;
1465 1466
1466 _target_velocity = 1467 _target_velocity =
1467 new PhysicsVector( 1468 new Vector3(
1468 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), 1469 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1469 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), 1470 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1470 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep) 1471 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
1471 ); 1472 );
1472 1473
1473 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1474 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1474 { 1475 {
1475 1476
1476 /* TODO: Do Bullet equiv 1477 /* TODO: Do Bullet equiv
@@ -1512,8 +1513,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1512 { 1513 {
1513 PID_G = m_PIDTau + 1; 1514 PID_G = m_PIDTau + 1;
1514 } 1515 }
1515 PhysicsVector pos = new PhysicsVector(0, 0, 0); //TODO: Insert values gotten from bullet 1516 Vector3 pos = Vector3.Zero; //TODO: Insert values gotten from bullet
1516 PhysicsVector vel = new PhysicsVector(0, 0, 0); 1517 Vector3 vel = Vector3.Zero;
1517 1518
1518 // determine what our target height really is based on HoverType 1519 // determine what our target height really is based on HoverType
1519 switch (m_PIDHoverType) 1520 switch (m_PIDHoverType)
@@ -1545,13 +1546,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1545 1546
1546 1547
1547 _target_velocity = 1548 _target_velocity =
1548 new PhysicsVector(0.0f, 0.0f, 1549 new Vector3(0.0f, 0.0f,
1549 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep) 1550 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1550 ); 1551 );
1551 1552
1552 // if velocity is zero, use position control; otherwise, velocity control 1553 // if velocity is zero, use position control; otherwise, velocity control
1553 1554
1554 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1555 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1555 { 1556 {
1556 1557
1557 /* TODO: Do Bullet Equiv 1558 /* TODO: Do Bullet Equiv
@@ -1626,8 +1627,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1626 else 1627 else
1627 { 1628 {
1628 if (m_zeroPosition == null) 1629 if (m_zeroPosition == null)
1629 m_zeroPosition = new PhysicsVector(0, 0, 0); 1630 m_zeroPosition = Vector3.Zero;
1630 m_zeroPosition.setValues(_position.X, _position.Y, _position.Z); 1631 m_zeroPosition = _position;
1631 return; 1632 return;
1632 } 1633 }
1633 } 1634 }
@@ -2177,7 +2178,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2177 2178
2178 //if (hasTrimesh) 2179 //if (hasTrimesh)
2179 //{ 2180 //{
2180 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); 2181 ProcessGeomCreationAsTriMesh(Vector3.Zero, Quaternion.Identity);
2181 // createmesh returns null when it doesn't mesh. 2182 // createmesh returns null when it doesn't mesh.
2182 2183
2183 /* 2184 /*
@@ -2197,11 +2198,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2197 { 2198 {
2198 if (chld == null) 2199 if (chld == null)
2199 continue; 2200 continue;
2200 PhysicsVector offset = chld.Position - Position; 2201 Vector3 offset = chld.Position - Position;
2201 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); 2202 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z);
2202 pos *= Quaternion.Inverse(Orientation); 2203 pos *= Quaternion.Inverse(Orientation);
2203 //pos *= Orientation; 2204 //pos *= Orientation;
2204 offset.setValues(pos.X, pos.Y, pos.Z); 2205 offset = pos;
2205 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation); 2206 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
2206 2207
2207 _mesh.Append(chld._mesh); 2208 _mesh.Append(chld._mesh);
@@ -2433,7 +2434,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2433 m_collisionscore = 0; 2434 m_collisionscore = 0;
2434 m_disabled = false; 2435 m_disabled = false;
2435 // The body doesn't already have a finite rotation mode set here 2436 // The body doesn't already have a finite rotation mode set here
2436 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 2437 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
2437 { 2438 {
2438 // TODO: Create Angular Motor on Axis Lock! 2439 // TODO: Create Angular Motor on Axis Lock!
2439 } 2440 }
@@ -2447,7 +2448,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2447 { 2448 {
2448 if (_parent == null) 2449 if (_parent == null)
2449 { 2450 {
2450 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2451 Vector3 pv = Vector3.Zero;
2451 bool lastZeroFlag = _zeroFlag; 2452 bool lastZeroFlag = _zeroFlag;
2452 if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero) 2453 if (tempPosition3 != null && tempPosition3.Handle != IntPtr.Zero)
2453 tempPosition3.Dispose(); 2454 tempPosition3.Dispose();
@@ -2471,10 +2472,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2471 tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel 2472 tempAngularVelocity1 = Body.getInterpolationAngularVelocity(); //rotvel
2472 tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel 2473 tempLinearVelocity1 = Body.getInterpolationLinearVelocity(); // vel
2473 2474
2474 _torque.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(), 2475 _torque = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getX(),
2475 tempAngularVelocity1.getZ()); 2476 tempAngularVelocity1.getZ());
2476 PhysicsVector l_position = new PhysicsVector(); 2477 Vector3 l_position = Vector3.Zero;
2477 Quaternion l_orientation = new Quaternion(); 2478 Quaternion l_orientation = Quaternion.Identity;
2478 m_lastposition = _position; 2479 m_lastposition = _position;
2479 m_lastorientation = _orientation; 2480 m_lastorientation = _orientation;
2480 2481
@@ -2598,20 +2599,18 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2598 _velocity.Z = tempLinearVelocity1.getZ(); 2599 _velocity.Z = tempLinearVelocity1.getZ();
2599 2600
2600 _acceleration = ((_velocity - m_lastVelocity) / 0.1f); 2601 _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
2601 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, 2602 _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f,
2602 _velocity.Y - m_lastVelocity.Y / 0.1f, 2603 _velocity.Y - m_lastVelocity.Y / 0.1f,
2603 _velocity.Z - m_lastVelocity.Z / 0.1f); 2604 _velocity.Z - m_lastVelocity.Z / 0.1f);
2604 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); 2605 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
2605 2606
2606 if (_velocity.IsIdentical(pv, 0.5f)) 2607 if (_velocity.ApproxEquals(pv, 0.5f))
2607 { 2608 {
2608 m_rotationalVelocity = pv; 2609 m_rotationalVelocity = pv;
2609 } 2610 }
2610 else 2611 else
2611 { 2612 {
2612 2613 m_rotationalVelocity = new Vector3(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(), tempAngularVelocity1.getZ());
2613 m_rotationalVelocity.setValues(tempAngularVelocity1.getX(), tempAngularVelocity1.getY(),
2614 tempAngularVelocity1.getZ());
2615 } 2614 }
2616 2615
2617 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString()); 2616 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
@@ -2665,7 +2664,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2665 m_taintremove = true; 2664 m_taintremove = true;
2666 } 2665 }
2667 2666
2668 internal void EnableAxisMotor(PhysicsVector axislock) 2667 internal void EnableAxisMotor(Vector3 axislock)
2669 { 2668 {
2670 if (m_aMotor != null) 2669 if (m_aMotor != null)
2671 DisableAxisMotor(); 2670 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 abed8df..cbe73bb 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
@@ -1256,19 +1256,19 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1256 /// </summary> 1256 /// </summary>
1257 public class BulletXCharacter : BulletXActor 1257 public class BulletXCharacter : BulletXActor
1258 { 1258 {
1259 public BulletXCharacter(BulletXScene parent_scene, PhysicsVector pos) 1259 public BulletXCharacter(BulletXScene parent_scene, OpenMetaverse.Vector3 pos)
1260 : this(String.Empty, parent_scene, pos) 1260 : this(String.Empty, parent_scene, pos)
1261 { 1261 {
1262 } 1262 }
1263 1263
1264 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos) 1264 public BulletXCharacter(String avName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos)
1265 : this(avName, parent_scene, pos, new PhysicsVector(), new PhysicsVector(), new PhysicsVector(), 1265 : this(avName, parent_scene, pos, OpenMetaverse.Vector3.Zero, OpenMetaverse.Vector3.Zero, OpenMetaverse.Vector3.Zero,
1266 OpenMetaverse.Quaternion.Identity) 1266 OpenMetaverse.Quaternion.Identity)
1267 { 1267 {
1268 } 1268 }
1269 1269
1270 public BulletXCharacter(String avName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, 1270 public BulletXCharacter(String avName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos, OpenMetaverse.Vector3 velocity,
1271 PhysicsVector size, PhysicsVector acceleration, OpenMetaverse.Quaternion orientation) 1271 OpenMetaverse.Vector3 size, OpenMetaverse.Vector3 acceleration, OpenMetaverse.Quaternion orientation)
1272 : base(avName) 1272 : base(avName)
1273 { 1273 {
1274 //This fields will be removed. They're temporal 1274 //This fields will be removed. They're temporal
@@ -1323,25 +1323,25 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1323 set { return; } 1323 set { return; }
1324 } 1324 }
1325 1325
1326 public override PhysicsVector Position 1326 public override OpenMetaverse.Vector3 Position
1327 { 1327 {
1328 get { return base.Position; } 1328 get { return base.Position; }
1329 set { base.Position = value; } 1329 set { base.Position = value; }
1330 } 1330 }
1331 1331
1332 public override PhysicsVector Velocity 1332 public override OpenMetaverse.Vector3 Velocity
1333 { 1333 {
1334 get { return base.Velocity; } 1334 get { return base.Velocity; }
1335 set { base.Velocity = value; } 1335 set { base.Velocity = value; }
1336 } 1336 }
1337 1337
1338 public override PhysicsVector Size 1338 public override OpenMetaverse.Vector3 Size
1339 { 1339 {
1340 get { return base.Size; } 1340 get { return base.Size; }
1341 set { base.Size = value; } 1341 set { base.Size = value; }
1342 } 1342 }
1343 1343
1344 public override PhysicsVector Acceleration 1344 public override OpenMetaverse.Vector3 Acceleration
1345 { 1345 {
1346 get { return base.Acceleration; } 1346 get { return base.Acceleration; }
1347 } 1347 }
@@ -1370,17 +1370,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1370 set { base.Kinematic = value; } 1370 set { base.Kinematic = value; }
1371 } 1371 }
1372 1372
1373 public override void SetAcceleration(PhysicsVector accel) 1373 public override void SetAcceleration(OpenMetaverse.Vector3 accel)
1374 { 1374 {
1375 base.SetAcceleration(accel); 1375 base.SetAcceleration(accel);
1376 } 1376 }
1377 1377
1378 public override void AddForce(PhysicsVector force, bool pushforce) 1378 public override void AddForce(OpenMetaverse.Vector3 force, bool pushforce)
1379 { 1379 {
1380 base.AddForce(force, pushforce); 1380 base.AddForce(force, pushforce);
1381 } 1381 }
1382 1382
1383 public override void SetMomentum(PhysicsVector momentum) 1383 public override void SetMomentum(OpenMetaverse.Vector3 momentum)
1384 { 1384 {
1385 base.SetMomentum(momentum); 1385 base.SetMomentum(momentum);
1386 } 1386 }
@@ -1430,7 +1430,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1430 m.Translation = v3; 1430 m.Translation = v3;
1431 rigidBody.WorldTransform = m; 1431 rigidBody.WorldTransform = m;
1432 //When an Avie touch the ground it's vertical velocity it's reduced to ZERO 1432 //When an Avie touch the ground it's vertical velocity it's reduced to ZERO
1433 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); 1433 Speed(new OpenMetaverse.Vector3(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
1434 } 1434 }
1435 } 1435 }
1436 1436
@@ -1452,7 +1452,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1452 //For now all prims have the same density, all prims are made of water. Be water my friend! :D 1452 //For now all prims have the same density, all prims are made of water. Be water my friend! :D
1453 private const float _density = 1000.0f; 1453 private const float _density = 1000.0f;
1454 private BulletXScene _parent_scene; 1454 private BulletXScene _parent_scene;
1455 private PhysicsVector m_prev_position = new PhysicsVector(0, 0, 0); 1455 private OpenMetaverse.Vector3 m_prev_position;
1456 private bool m_lastUpdateSent = false; 1456 private bool m_lastUpdateSent = false;
1457 //added by jed zhu 1457 //added by jed zhu
1458 private IMesh _mesh; 1458 private IMesh _mesh;
@@ -1460,17 +1460,17 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1460 1460
1461 1461
1462 1462
1463 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector size, 1463 public BulletXPrim(String primName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos, OpenMetaverse.Vector3 size,
1464 OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical) 1464 OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool isPhysical)
1465 : this( 1465 : this(
1466 primName, parent_scene, pos, new PhysicsVector(), size, new PhysicsVector(), rotation, mesh, pbs, 1466 primName, parent_scene, pos, OpenMetaverse.Vector3.Zero, size, OpenMetaverse.Vector3.Zero, rotation, mesh, pbs,
1467 isPhysical) 1467 isPhysical)
1468 { 1468 {
1469 } 1469 }
1470 1470
1471 public BulletXPrim(String primName, BulletXScene parent_scene, PhysicsVector pos, PhysicsVector velocity, 1471 public BulletXPrim(String primName, BulletXScene parent_scene, OpenMetaverse.Vector3 pos, OpenMetaverse.Vector3 velocity,
1472 PhysicsVector size, 1472 OpenMetaverse.Vector3 size,
1473 PhysicsVector acceleration, OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, 1473 OpenMetaverse.Vector3 acceleration, OpenMetaverse.Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs,
1474 bool isPhysical) 1474 bool isPhysical)
1475 : base(primName) 1475 : base(primName)
1476 { 1476 {
@@ -1481,7 +1481,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1481 1481
1482 _position = pos; 1482 _position = pos;
1483 _physical = isPhysical; 1483 _physical = isPhysical;
1484 _velocity = _physical ? velocity : new PhysicsVector(); 1484 _velocity = _physical ? velocity : OpenMetaverse.Vector3.Zero;
1485 _size = size; 1485 _size = size;
1486 _acceleration = acceleration; 1486 _acceleration = acceleration;
1487 _orientation = rotation; 1487 _orientation = rotation;
@@ -1497,19 +1497,19 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1497 set { return; } 1497 set { return; }
1498 } 1498 }
1499 1499
1500 public override PhysicsVector Position 1500 public override OpenMetaverse.Vector3 Position
1501 { 1501 {
1502 get { return base.Position; } 1502 get { return base.Position; }
1503 set { base.Position = value; } 1503 set { base.Position = value; }
1504 } 1504 }
1505 1505
1506 public override PhysicsVector Velocity 1506 public override OpenMetaverse.Vector3 Velocity
1507 { 1507 {
1508 get { return base.Velocity; } 1508 get { return base.Velocity; }
1509 set { base.Velocity = value; } 1509 set { base.Velocity = value; }
1510 } 1510 }
1511 1511
1512 public override PhysicsVector Size 1512 public override OpenMetaverse.Vector3 Size
1513 { 1513 {
1514 get { return _size; } 1514 get { return _size; }
1515 set 1515 set
@@ -1522,7 +1522,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1522 } 1522 }
1523 } 1523 }
1524 1524
1525 public override PhysicsVector Acceleration 1525 public override OpenMetaverse.Vector3 Acceleration
1526 { 1526 {
1527 get { return base.Acceleration; } 1527 get { return base.Acceleration; }
1528 } 1528 }
@@ -1583,7 +1583,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1583 set { base.Kinematic = value; } 1583 set { base.Kinematic = value; }
1584 } 1584 }
1585 1585
1586 public override void SetAcceleration(PhysicsVector accel) 1586 public override void SetAcceleration(OpenMetaverse.Vector3 accel)
1587 { 1587 {
1588 lock (BulletXScene.BulletXLock) 1588 lock (BulletXScene.BulletXLock)
1589 { 1589 {
@@ -1591,12 +1591,12 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1591 } 1591 }
1592 } 1592 }
1593 1593
1594 public override void AddForce(PhysicsVector force, bool pushforce) 1594 public override void AddForce(OpenMetaverse.Vector3 force, bool pushforce)
1595 { 1595 {
1596 base.AddForce(force,pushforce); 1596 base.AddForce(force,pushforce);
1597 } 1597 }
1598 1598
1599 public override void SetMomentum(PhysicsVector momentum) 1599 public override void SetMomentum(OpenMetaverse.Vector3 momentum)
1600 { 1600 {
1601 base.SetMomentum(momentum); 1601 base.SetMomentum(momentum);
1602 } 1602 }
@@ -1613,7 +1613,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1613 //When a Prim touch the ground it's vertical velocity it's reduced to ZERO 1613 //When a Prim touch the ground it's vertical velocity it's reduced to ZERO
1614 //Static objects don't have linear velocity 1614 //Static objects don't have linear velocity
1615 if (_physical) 1615 if (_physical)
1616 Speed(new PhysicsVector(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f)); 1616 Speed(new OpenMetaverse.Vector3(rigidBody.LinearVelocity.X, rigidBody.LinearVelocity.Y, 0.0f));
1617 } 1617 }
1618 } 1618 }
1619 1619
@@ -1632,7 +1632,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1632 { 1632 {
1633 if (!m_lastUpdateSent) 1633 if (!m_lastUpdateSent)
1634 { 1634 {
1635 _velocity = new PhysicsVector(0, 0, 0); 1635 _velocity = OpenMetaverse.Vector3.Zero;
1636 base.ScheduleTerseUpdate(); 1636 base.ScheduleTerseUpdate();
1637 m_lastUpdateSent = true; 1637 m_lastUpdateSent = true;
1638 } 1638 }
@@ -1654,8 +1654,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1654 1654
1655 #region Methods for updating values of RigidBody 1655 #region Methods for updating values of RigidBody
1656 1656
1657 protected internal void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, PhysicsVector pos, 1657 protected internal void CreateRigidBody(BulletXScene parent_scene, IMesh mesh, OpenMetaverse.Vector3 pos,
1658 PhysicsVector size) 1658 OpenMetaverse.Vector3 size)
1659 { 1659 {
1660 //For RigidBody Constructor. The next values might change 1660 //For RigidBody Constructor. The next values might change
1661 float _linearDamping = 0.0f; 1661 float _linearDamping = 0.0f;
@@ -1683,7 +1683,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1683 Vector3[] v3Vertices = new Vector3[iVertexCount]; 1683 Vector3[] v3Vertices = new Vector3[iVertexCount];
1684 for (int i = 0; i < iVertexCount; i++) 1684 for (int i = 0; i < iVertexCount; i++)
1685 { 1685 {
1686 PhysicsVector v = mesh.getVertexList()[i]; 1686 OpenMetaverse.Vector3 v = mesh.getVertexList()[i];
1687 if (v != null) // Note, null has special meaning. See meshing code for details 1687 if (v != null) // Note, null has special meaning. See meshing code for details
1688 v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v); 1688 v3Vertices[i] = BulletXMaths.PhysicsVectorToXnaVector3(v);
1689 else 1689 else
@@ -1709,7 +1709,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1709 } 1709 }
1710 } 1710 }
1711 1711
1712 protected internal void ReCreateRigidBody(PhysicsVector size) 1712 protected internal void ReCreateRigidBody(OpenMetaverse.Vector3 size)
1713 { 1713 {
1714 //There is a bug when trying to remove a rigidBody that is colliding with something.. 1714 //There is a bug when trying to remove a rigidBody that is colliding with something..
1715 try 1715 try
@@ -1729,7 +1729,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1729 GC.Collect(); 1729 GC.Collect();
1730 } 1730 }
1731 1731
1732 protected internal override void ReSize(PhysicsVector _newSize) 1732 protected internal override void ReSize(OpenMetaverse.Vector3 _newSize)
1733 { 1733 {
1734 //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't 1734 //I wonder to know how to resize with a simple instruction in BulletX. It seems that for now there isn't
1735 //so i have to do it manually. That's recreating rigidbody 1735 //so i have to do it manually. That's recreating rigidbody
@@ -1744,8 +1744,8 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1744 /// </summary> 1744 /// </summary>
1745 internal class BulletXPlanet 1745 internal class BulletXPlanet
1746 { 1746 {
1747 private PhysicsVector _staticPosition; 1747 private OpenMetaverse.Vector3 _staticPosition;
1748// private PhysicsVector _staticVelocity; 1748// private Vector3 _staticVelocity;
1749// private OpenMetaverse.Quaternion _staticOrientation; 1749// private OpenMetaverse.Quaternion _staticOrientation;
1750 private float _mass; 1750 private float _mass;
1751 // private BulletXScene _parentscene; 1751 // private BulletXScene _parentscene;
@@ -1759,7 +1759,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1759 1759
1760 internal BulletXPlanet(BulletXScene parent_scene, float[] heightField) 1760 internal BulletXPlanet(BulletXScene parent_scene, float[] heightField)
1761 { 1761 {
1762 _staticPosition = new PhysicsVector(BulletXScene.MaxXY/2, BulletXScene.MaxXY/2, 0); 1762 _staticPosition = new OpenMetaverse.Vector3(BulletXScene.MaxXY / 2, BulletXScene.MaxXY / 2, 0);
1763// _staticVelocity = new PhysicsVector(); 1763// _staticVelocity = new PhysicsVector();
1764// _staticOrientation = OpenMetaverse.Quaternion.Identity; 1764// _staticOrientation = OpenMetaverse.Quaternion.Identity;
1765 _mass = 0; //No active 1765 _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 7603131..6bfdff2 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
@@ -231,9 +231,9 @@ namespace OpenSim.Region.Physics.Manager
231 public abstract float PIDHoverTau { set;} 231 public abstract float PIDHoverTau { set;}
232 232
233 233
234 public abstract void AddForce(PhysicsVector force, bool pushforce); 234 public abstract void AddForce(Vector3 force, bool pushforce);
235 public abstract void AddAngularForce(PhysicsVector force, bool pushforce); 235 public abstract void AddAngularForce(Vector3 force, bool pushforce);
236 public abstract void SetMomentum(PhysicsVector momentum); 236 public abstract void SetMomentum(Vector3 momentum);
237 public abstract void SubscribeEvents(int ms); 237 public abstract void SubscribeEvents(int ms);
238 public abstract void UnSubscribeEvents(); 238 public abstract void UnSubscribeEvents();
239 public abstract bool SubscribedEvents(); 239 public abstract bool SubscribedEvents();
@@ -246,9 +246,9 @@ namespace OpenSim.Region.Physics.Manager
246 get{ return false; } 246 get{ return false; }
247 } 247 }
248 248
249 public override PhysicsVector Position 249 public override Vector3 Position
250 { 250 {
251 get { return PhysicsVector.Zero; } 251 get { return Vector3.Zero; }
252 set { return; } 252 set { return; }
253 } 253 }
254 254
@@ -296,9 +296,9 @@ namespace OpenSim.Region.Physics.Manager
296 set { return; } 296 set { return; }
297 } 297 }
298 298
299 public override PhysicsVector Size 299 public override Vector3 Size
300 { 300 {
301 get { return PhysicsVector.Zero; } 301 get { return Vector3.Zero; }
302 set { return; } 302 set { return; }
303 } 303 }
304 304
@@ -307,9 +307,9 @@ namespace OpenSim.Region.Physics.Manager
307 get { return 0f; } 307 get { return 0f; }
308 } 308 }
309 309
310 public override PhysicsVector Force 310 public override Vector3 Force
311 { 311 {
312 get { return PhysicsVector.Zero; } 312 get { return Vector3.Zero; }
313 set { return; } 313 set { return; }
314 } 314 }
315 315
@@ -324,7 +324,7 @@ namespace OpenSim.Region.Physics.Manager
324 324
325 } 325 }
326 326
327 public override void VehicleVectorParam(int param, PhysicsVector value) 327 public override void VehicleVectorParam(int param, Vector3 value)
328 { 328 {
329 329
330 } 330 }
@@ -344,14 +344,14 @@ namespace OpenSim.Region.Physics.Manager
344 344
345 } 345 }
346 346
347 public override PhysicsVector CenterOfMass 347 public override Vector3 CenterOfMass
348 { 348 {
349 get { return PhysicsVector.Zero; } 349 get { return Vector3.Zero; }
350 } 350 }
351 351
352 public override PhysicsVector GeometricCenter 352 public override Vector3 GeometricCenter
353 { 353 {
354 get { return PhysicsVector.Zero; } 354 get { return Vector3.Zero; }
355 } 355 }
356 356
357 public override PrimitiveBaseShape Shape 357 public override PrimitiveBaseShape Shape
@@ -359,15 +359,15 @@ namespace OpenSim.Region.Physics.Manager
359 set { return; } 359 set { return; }
360 } 360 }
361 361
362 public override PhysicsVector Velocity 362 public override Vector3 Velocity
363 { 363 {
364 get { return PhysicsVector.Zero; } 364 get { return Vector3.Zero; }
365 set { return; } 365 set { return; }
366 } 366 }
367 367
368 public override PhysicsVector Torque 368 public override Vector3 Torque
369 { 369 {
370 get { return PhysicsVector.Zero; } 370 get { return Vector3.Zero; }
371 set { return; } 371 set { return; }
372 } 372 }
373 373
@@ -387,9 +387,9 @@ namespace OpenSim.Region.Physics.Manager
387 set { } 387 set { }
388 } 388 }
389 389
390 public override PhysicsVector Acceleration 390 public override Vector3 Acceleration
391 { 391 {
392 get { return PhysicsVector.Zero; } 392 get { return Vector3.Zero; }
393 } 393 }
394 394
395 public override bool IsPhysical 395 public override bool IsPhysical
@@ -436,26 +436,26 @@ namespace OpenSim.Region.Physics.Manager
436 { 436 {
437 } 437 }
438 438
439 public override void LockAngularMotion(PhysicsVector axis) 439 public override void LockAngularMotion(Vector3 axis)
440 { 440 {
441 } 441 }
442 442
443 public override void AddForce(PhysicsVector force, bool pushforce) 443 public override void AddForce(Vector3 force, bool pushforce)
444 { 444 {
445 } 445 }
446 446
447 public override void AddAngularForce(PhysicsVector force, bool pushforce) 447 public override void AddAngularForce(Vector3 force, bool pushforce)
448 { 448 {
449 449
450 } 450 }
451 451
452 public override PhysicsVector RotationalVelocity 452 public override Vector3 RotationalVelocity
453 { 453 {
454 get { return PhysicsVector.Zero; } 454 get { return Vector3.Zero; }
455 set { return; } 455 set { return; }
456 } 456 }
457 457
458 public override PhysicsVector PIDTarget { set { return; } } 458 public override Vector3 PIDTarget { set { return; } }
459 public override bool PIDActive { set { return; } } 459 public override bool PIDActive { set { return; } }
460 public override float PIDTau { set { return; } } 460 public override float PIDTau { set { return; } }
461 461
@@ -464,7 +464,7 @@ namespace OpenSim.Region.Physics.Manager
464 public override PIDHoverType PIDHoverType { set { return; } } 464 public override PIDHoverType PIDHoverType { set { return; } }
465 public override float PIDHoverTau { set { return; } } 465 public override float PIDHoverTau { set { return; } }
466 466
467 public override void SetMomentum(PhysicsVector momentum) 467 public override void SetMomentum(Vector3 momentum)
468 { 468 {
469 } 469 }
470 470
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 71ace16..c86bc62 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
@@ -1311,7 +1302,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1311 d.GeomDestroy(Shell); 1302 d.GeomDestroy(Shell);
1312 AvatarGeomAndBodyCreation(_position.X, _position.Y, 1303 AvatarGeomAndBodyCreation(_position.X, _position.Y,
1313 _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor); 1304 _position.Z + (Math.Abs(CAPSULE_LENGTH - prevCapsule) * 2), m_tensor);
1314 Velocity = new PhysicsVector(0f, 0f, 0f); 1305 Velocity = Vector3.Zero;
1315 1306
1316 _parent_scene.geom_name_map[Shell] = m_name; 1307 _parent_scene.geom_name_map[Shell] = m_name;
1317 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 1308 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this;
@@ -1325,7 +1316,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1325 } 1316 }
1326 } 1317 }
1327 1318
1328 if (!m_taintPosition.IsIdentical(_position, 0.05f)) 1319 if (!m_taintPosition.ApproxEquals(_position, 0.05f))
1329 { 1320 {
1330 if (Body != IntPtr.Zero) 1321 if (Body != IntPtr.Zero)
1331 { 1322 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
index 467eba0..4a802cd 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
@@ -1,16 +1,4 @@
1/* 1/*
2 * Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
3 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
4 * ODEPrim.cs contains methods dealing with Prim editing, Prim
5 * characteristics and Kinetic motion.
6 * ODEDynamics.cs contains methods dealing with Prim Physical motion
7 * (dynamics) and the associated settings. Old Linear and angular
8 * motors for dynamic motion have been replace with MoveLinear()
9 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
10 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
11 * switch between 'VEHICLE' parameter use and general dynamics
12 * settings use.
13 *
14 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
15 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
16 * 4 *
@@ -37,6 +25,19 @@
37 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 */ 26 */
39 27
28/* Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
29 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
30 * ODEPrim.cs contains methods dealing with Prim editing, Prim
31 * characteristics and Kinetic motion.
32 * ODEDynamics.cs contains methods dealing with Prim Physical motion
33 * (dynamics) and the associated settings. Old Linear and angular
34 * motors for dynamic motion have been replace with MoveLinear()
35 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
36 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
37 * switch between 'VEHICLE' parameter use and general dynamics
38 * settings use.
39 */
40
40using System; 41using System;
41using System.Collections.Generic; 42using System.Collections.Generic;
42using System.Reflection; 43using System.Reflection;
@@ -231,7 +232,7 @@ namespace OpenSim.Region.Physics.OdePlugin
231 232
232 }//end ProcessFloatVehicleParam 233 }//end ProcessFloatVehicleParam
233 234
234 internal void ProcessVectorVehicleParam(Vehicle pParam, PhysicsVector pValue) 235 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue)
235 { 236 {
236 switch (pParam) 237 switch (pParam)
237 { 238 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index f59f0ae..5ff9d32 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -1,18 +1,5 @@
1/* 1/* Copyright (c) Contributors, http://opensimulator.org/
2 * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
3 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
4 * ODEPrim.cs contains methods dealing with Prim editing, Prim
5 * characteristics and Kinetic motion.
6 * ODEDynamics.cs contains methods dealing with Prim Physical motion
7 * (dynamics) and the associated settings. Old Linear and angular
8 * motors for dynamic motion have been replace with MoveLinear()
9 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
10 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
11 * switch between 'VEHICLE' parameter use and general dynamics
12 * settings use.
13 * Copyright (c) Contributors, http://opensimulator.org/
14 * See CONTRIBUTORS.TXT for a full list of copyright holders. 2 * See CONTRIBUTORS.TXT for a full list of copyright holders.
15 *
16 * Redistribution and use in source and binary forms, with or without 3 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions are met: 4 * modification, are permitted provided that the following conditions are met:
18 * * Redistributions of source code must retain the above copyright 5 * * Redistributions of source code must retain the above copyright
@@ -35,6 +22,20 @@
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */ 24 */
25
26/*
27 * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
28 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
29 * ODEPrim.cs contains methods dealing with Prim editing, Prim
30 * characteristics and Kinetic motion.
31 * ODEDynamics.cs contains methods dealing with Prim Physical motion
32 * (dynamics) and the associated settings. Old Linear and angular
33 * motors for dynamic motion have been replace with MoveLinear()
34 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
35 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
36 * switch between 'VEHICLE' parameter use and general dynamics
37 * settings use.
38 */
38using System; 39using System;
39using System.Collections.Generic; 40using System.Collections.Generic;
40using System.Reflection; 41using System.Reflection;
@@ -56,44 +57,43 @@ namespace OpenSim.Region.Physics.OdePlugin
56 { 57 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 58 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 59
59 private PhysicsVector _position; 60 private Vector3 _position;
60 private PhysicsVector _velocity; 61 private Vector3 _velocity;
61 private PhysicsVector _torque = new PhysicsVector(0,0,0); 62 private Vector3 _torque;
62 private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); 63 private Vector3 m_lastVelocity;
63 private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); 64 private Vector3 m_lastposition;
64 private Quaternion m_lastorientation = new Quaternion(); 65 private Quaternion m_lastorientation = new Quaternion();
65 private PhysicsVector m_rotationalVelocity; 66 private Vector3 m_rotationalVelocity;
66 private PhysicsVector _size; 67 private Vector3 _size;
67 private PhysicsVector _acceleration; 68 private Vector3 _acceleration;
68 // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f); 69 // private d.Vector3 _zeroPosition = new d.Vector3(0.0f, 0.0f, 0.0f);
69 private Quaternion _orientation; 70 private Quaternion _orientation;
70 private PhysicsVector m_taintposition; 71 private Vector3 m_taintposition;
71 private PhysicsVector m_taintsize; 72 private Vector3 m_taintsize;
72 private PhysicsVector m_taintVelocity = new PhysicsVector(0, 0, 0); 73 private Vector3 m_taintVelocity;
73 private PhysicsVector m_taintTorque = new PhysicsVector(0, 0, 0); 74 private Vector3 m_taintTorque;
74 private Quaternion m_taintrot; 75 private Quaternion m_taintrot;
75 private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); 76 private Vector3 m_angularlock = Vector3.One;
76 private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); 77 private Vector3 m_taintAngularLock = Vector3.One;
77 private IntPtr Amotor = IntPtr.Zero; 78 private IntPtr Amotor = IntPtr.Zero;
78 79
79 private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0); 80 private Vector3 m_PIDTarget;
80 // private PhysicsVector m_taintPIDTarget = new PhysicsVector(0, 0, 0); 81 private float m_PIDTau;
81 private float m_PIDTau = 0f;
82 private float PID_D = 35f; 82 private float PID_D = 35f;
83 private float PID_G = 25f; 83 private float PID_G = 25f;
84 private bool m_usePID = false; 84 private bool m_usePID;
85 85
86 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), 86 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
87 // and are for non-VEHICLES only. 87 // and are for non-VEHICLES only.
88 88
89 private float m_PIDHoverHeight = 0f; 89 private float m_PIDHoverHeight;
90 private float m_PIDHoverTau = 0f; 90 private float m_PIDHoverTau;
91 private bool m_useHoverPID = false; 91 private bool m_useHoverPID;
92 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground; 92 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground;
93 private float m_targetHoverHeight = 0f; 93 private float m_targetHoverHeight;
94 private float m_groundHeight = 0f; 94 private float m_groundHeight;
95 private float m_waterHeight = 0f; 95 private float m_waterHeight;
96 private float m_buoyancy = 0f; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. 96 private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
97 97
98 // private float m_tensor = 5f; 98 // private float m_tensor = 5f;
99 private int body_autodisable_frames = 20; 99 private int body_autodisable_frames = 20;
@@ -104,11 +104,11 @@ namespace OpenSim.Region.Physics.OdePlugin
104 | CollisionCategories.Body 104 | CollisionCategories.Body
105 | CollisionCategories.Character 105 | CollisionCategories.Character
106 ); 106 );
107 private bool m_taintshape = false; 107 private bool m_taintshape;
108 private bool m_taintPhysics = false; 108 private bool m_taintPhysics;
109 private bool m_collidesLand = true; 109 private bool m_collidesLand = true;
110 private bool m_collidesWater = false; 110 private bool m_collidesWater;
111 public bool m_returnCollisions = false; 111 public bool m_returnCollisions;
112 112
113 // Default we're a Geometry 113 // Default we're a Geometry
114 private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); 114 private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
@@ -116,85 +116,83 @@ namespace OpenSim.Region.Physics.OdePlugin
116 // Default, Collide with Other Geometries, spaces and Bodies 116 // Default, Collide with Other Geometries, spaces and Bodies
117 private CollisionCategories m_collisionFlags = m_default_collisionFlags; 117 private CollisionCategories m_collisionFlags = m_default_collisionFlags;
118 118
119 public bool m_taintremove = false; 119 public bool m_taintremove;
120 public bool m_taintdisable = false; 120 public bool m_taintdisable;
121 public bool m_disabled = false; 121 public bool m_disabled;
122 public bool m_taintadd = false; 122 public bool m_taintadd;
123 public bool m_taintselected = false; 123 public bool m_taintselected;
124 public bool m_taintCollidesWater = false; 124 public bool m_taintCollidesWater;
125 125
126 public uint m_localID = 0; 126 public uint m_localID;
127 127
128 //public GCHandle gc; 128 //public GCHandle gc;
129 private CollisionLocker ode; 129 private CollisionLocker ode;
130 130
131 private bool m_taintforce = false; 131 private bool m_taintforce = false;
132 private bool m_taintaddangularforce = false; 132 private bool m_taintaddangularforce = false;
133 private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); 133 private Vector3 m_force;
134 private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); 134 private List<Vector3> m_forcelist = new List<Vector3>();
135 private List<PhysicsVector> m_angularforcelist = new List<PhysicsVector>(); 135 private List<Vector3> m_angularforcelist = new List<Vector3>();
136 136
137 private IMesh _mesh; 137 private IMesh _mesh;
138 private PrimitiveBaseShape _pbs; 138 private PrimitiveBaseShape _pbs;
139 private OdeScene _parent_scene; 139 private OdeScene _parent_scene;
140 public IntPtr m_targetSpace = (IntPtr) 0; 140 public IntPtr m_targetSpace = IntPtr.Zero;
141 public IntPtr prim_geom; 141 public IntPtr prim_geom;
142 public IntPtr prev_geom; 142 public IntPtr prev_geom;
143 public IntPtr _triMeshData; 143 public IntPtr _triMeshData;
144 144
145 private IntPtr _linkJointGroup = (IntPtr)0; 145 private IntPtr _linkJointGroup = IntPtr.Zero;
146 private PhysicsActor _parent = null; 146 private PhysicsActor _parent;
147 private PhysicsActor m_taintparent = null; 147 private PhysicsActor m_taintparent;
148 148
149 private List<OdePrim> childrenPrim = new List<OdePrim>(); 149 private List<OdePrim> childrenPrim = new List<OdePrim>();
150 150
151 private bool iscolliding = false; 151 private bool iscolliding;
152 private bool m_isphysical = false; 152 private bool m_isphysical;
153 private bool m_isSelected = false; 153 private bool m_isSelected;
154 154
155 internal bool m_isVolumeDetect = false; // If true, this prim only detects collisions but doesn't collide actively 155 internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
156 156
157 private bool m_throttleUpdates = false; 157 private bool m_throttleUpdates;
158 private int throttleCounter = 0; 158 private int throttleCounter;
159 public int m_interpenetrationcount = 0; 159 public int m_interpenetrationcount;
160 public float m_collisionscore = 0; 160 public float m_collisionscore;
161 public int m_roundsUnderMotionThreshold = 0; 161 public int m_roundsUnderMotionThreshold;
162 private int m_crossingfailures = 0; 162 private int m_crossingfailures;
163 163
164 public bool outofBounds = false; 164 public bool outofBounds;
165 private float m_density = 10.000006836f; // Aluminum g/cm3; 165 private float m_density = 10.000006836f; // Aluminum g/cm3;
166 166
167 public bool _zeroFlag = false; 167 public bool _zeroFlag;
168 private bool m_lastUpdateSent = false; 168 private bool m_lastUpdateSent;
169 169
170 public IntPtr Body = (IntPtr) 0; 170 public IntPtr Body = IntPtr.Zero;
171 public String m_primName; 171 public String m_primName;
172// private String m_primName; 172 private Vector3 _target_velocity;
173 private PhysicsVector _target_velocity;
174 public d.Mass pMass; 173 public d.Mass pMass;
175 174
176 public int m_eventsubscription = 0; 175 public int m_eventsubscription;
177 private CollisionEventUpdate CollisionEventsThisFrame = null; 176 private CollisionEventUpdate CollisionEventsThisFrame;
178 177
179 private IntPtr m_linkJoint = (IntPtr)0; 178 private IntPtr m_linkJoint = IntPtr.Zero;
180 179
181 public volatile bool childPrim = false; 180 public volatile bool childPrim;
182 181
183 private ODEDynamics m_vehicle; 182 private ODEDynamics m_vehicle;
184 183
185 internal int m_material = (int)Material.Wood; 184 internal int m_material = (int)Material.Wood;
186 185
187 public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size, 186 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
188 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) 187 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
189 { 188 {
190 _target_velocity = new PhysicsVector(0, 0, 0);
191 m_vehicle = new ODEDynamics(); 189 m_vehicle = new ODEDynamics();
192 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); 190 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
193 ode = dode; 191 ode = dode;
194 _velocity = new PhysicsVector(); 192 if (!pos.IsFinite())
195 if (!PhysicsVector.isFinite(pos))
196 { 193 {
197 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); 194 pos = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f),
195 parent_scene.GetTerrainHeightAtXY(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f)) + 0.5f);
198 m_log.Warn("[PHYSICS]: Got nonFinite Object create Position"); 196 m_log.Warn("[PHYSICS]: Got nonFinite Object create Position");
199 } 197 }
200 _position = pos; 198 _position = pos;
@@ -209,9 +207,9 @@ namespace OpenSim.Region.Physics.OdePlugin
209 prim_geom = IntPtr.Zero; 207 prim_geom = IntPtr.Zero;
210 prev_geom = IntPtr.Zero; 208 prev_geom = IntPtr.Zero;
211 209
212 if (!PhysicsVector.isFinite(pos)) 210 if (!pos.IsFinite())
213 { 211 {
214 size = new PhysicsVector(0.5f, 0.5f, 0.5f); 212 size = new Vector3(0.5f, 0.5f, 0.5f);
215 m_log.Warn("[PHYSICS]: Got nonFinite Object create Size"); 213 m_log.Warn("[PHYSICS]: Got nonFinite Object create Size");
216 } 214 }
217 215
@@ -221,8 +219,6 @@ namespace OpenSim.Region.Physics.OdePlugin
221 219
222 _size = size; 220 _size = size;
223 m_taintsize = _size; 221 m_taintsize = _size;
224 _acceleration = new PhysicsVector();
225 m_rotationalVelocity = PhysicsVector.Zero;
226 222
227 if (!QuaternionIsFinite(rotation)) 223 if (!QuaternionIsFinite(rotation))
228 { 224 {
@@ -387,7 +383,7 @@ namespace OpenSim.Region.Physics.OdePlugin
387 m_disabled = false; 383 m_disabled = false;
388 384
389 // The body doesn't already have a finite rotation mode set here 385 // The body doesn't already have a finite rotation mode set here
390 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 386 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0.0f)) && _parent == null)
391 { 387 {
392 createAMotor(m_angularlock); 388 createAMotor(m_angularlock);
393 } 389 }
@@ -800,6 +796,8 @@ namespace OpenSim.Region.Physics.OdePlugin
800 m_collisionscore = 0; 796 m_collisionscore = 0;
801 } 797 }
802 798
799 private static Dictionary<IMesh, IntPtr> m_MeshToTriMeshMap = new Dictionary<IMesh, IntPtr>();
800
803 public void setMesh(OdeScene parent_scene, IMesh mesh) 801 public void setMesh(OdeScene parent_scene, IMesh mesh)
804 { 802 {
805 // This sleeper is there to moderate how long it takes between 803 // This sleeper is there to moderate how long it takes between
@@ -831,19 +829,24 @@ namespace OpenSim.Region.Physics.OdePlugin
831 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage 829 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
832 830
833 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory 831 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
832 if (m_MeshToTriMeshMap.ContainsKey(mesh))
833 {
834 _triMeshData = m_MeshToTriMeshMap[mesh];
835 }
836 else
837 {
838 _triMeshData = d.GeomTriMeshDataCreate();
834 839
835 _triMeshData = d.GeomTriMeshDataCreate(); 840 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
836 841 d.GeomTriMeshDataPreprocess(_triMeshData);
837 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); 842 m_MeshToTriMeshMap[mesh] = _triMeshData;
838 d.GeomTriMeshDataPreprocess(_triMeshData); 843 }
839 844
840 _parent_scene.waitForSpaceUnlock(m_targetSpace); 845 _parent_scene.waitForSpaceUnlock(m_targetSpace);
841
842 try 846 try
843 { 847 {
844 if (prim_geom == IntPtr.Zero) 848 if (prim_geom == IntPtr.Zero)
845 { 849 {
846//Console.WriteLine(" setMesh 1");
847 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); 850 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
848 } 851 }
849 } 852 }
@@ -853,6 +856,7 @@ namespace OpenSim.Region.Physics.OdePlugin
853 return; 856 return;
854 } 857 }
855 858
859
856 // if (IsPhysical && Body == (IntPtr) 0) 860 // if (IsPhysical && Body == (IntPtr) 0)
857 // { 861 // {
858 // Recreate the body 862 // Recreate the body
@@ -873,7 +877,7 @@ namespace OpenSim.Region.Physics.OdePlugin
873 877
874 if (prim_geom != IntPtr.Zero) 878 if (prim_geom != IntPtr.Zero)
875 { 879 {
876 if (!_position.IsIdentical(m_taintposition,0f)) 880 if (!_position.ApproxEquals(m_taintposition, 0f))
877 changemove(timestep); 881 changemove(timestep);
878 882
879 if (m_taintrot != _orientation) 883 if (m_taintrot != _orientation)
@@ -898,7 +902,7 @@ namespace OpenSim.Region.Physics.OdePlugin
898 changePhysicsStatus(timestep); 902 changePhysicsStatus(timestep);
899 // 903 //
900 904
901 if (!_size.IsIdentical(m_taintsize,0)) 905 if (!_size.ApproxEquals(m_taintsize,0f))
902 changesize(timestep); 906 changesize(timestep);
903 // 907 //
904 908
@@ -912,7 +916,7 @@ namespace OpenSim.Region.Physics.OdePlugin
912 if (m_taintaddangularforce) 916 if (m_taintaddangularforce)
913 changeAddAngularForce(timestep); 917 changeAddAngularForce(timestep);
914 918
915 if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f)) 919 if (!m_taintTorque.ApproxEquals(Vector3.Zero, 0.001f))
916 changeSetTorque(timestep); 920 changeSetTorque(timestep);
917 921
918 if (m_taintdisable) 922 if (m_taintdisable)
@@ -921,7 +925,7 @@ namespace OpenSim.Region.Physics.OdePlugin
921 if (m_taintselected != m_isSelected) 925 if (m_taintselected != m_isSelected)
922 changeSelectedStatus(timestep); 926 changeSelectedStatus(timestep);
923 927
924 if (!m_taintVelocity.IsIdentical(PhysicsVector.Zero, 0.001f)) 928 if (!m_taintVelocity.ApproxEquals(Vector3.Zero, 0.001f))
925 changevelocity(timestep); 929 changevelocity(timestep);
926 930
927 if (m_taintparent != _parent) 931 if (m_taintparent != _parent)
@@ -930,7 +934,7 @@ namespace OpenSim.Region.Physics.OdePlugin
930 if (m_taintCollidesWater != m_collidesWater) 934 if (m_taintCollidesWater != m_collidesWater)
931 changefloatonwater(timestep); 935 changefloatonwater(timestep);
932 936
933 if (!m_angularlock.IsIdentical(m_taintAngularLock,0)) 937 if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f))
934 changeAngularLock(timestep); 938 changeAngularLock(timestep);
935 939
936 } 940 }
@@ -950,7 +954,7 @@ namespace OpenSim.Region.Physics.OdePlugin
950 //If we have a parent then we're not authorative here 954 //If we have a parent then we're not authorative here
951 if (_parent == null) 955 if (_parent == null)
952 { 956 {
953 if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f,1f,1f), 0)) 957 if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
954 { 958 {
955 //d.BodySetFiniteRotationMode(Body, 0); 959 //d.BodySetFiniteRotationMode(Body, 0);
956 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z); 960 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
@@ -967,7 +971,7 @@ namespace OpenSim.Region.Physics.OdePlugin
967 } 971 }
968 } 972 }
969 // Store this for later in case we get turned into a separate body 973 // Store this for later in case we get turned into a separate body
970 m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z); 974 m_angularlock = m_taintAngularLock;
971 975
972 } 976 }
973 977
@@ -1111,7 +1115,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1111 prm.m_disabled = false; 1115 prm.m_disabled = false;
1112 1116
1113 // The body doesn't already have a finite rotation mode set here 1117 // The body doesn't already have a finite rotation mode set here
1114 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 1118 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
1115 { 1119 {
1116 prm.createAMotor(m_angularlock); 1120 prm.createAMotor(m_angularlock);
1117 } 1121 }
@@ -1154,7 +1158,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1154 m_disabled = false; 1158 m_disabled = false;
1155 1159
1156 // The body doesn't already have a finite rotation mode set here 1160 // The body doesn't already have a finite rotation mode set here
1157 if ((!m_angularlock.IsIdentical(PhysicsVector.Zero, 0)) && _parent == null) 1161 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
1158 { 1162 {
1159 createAMotor(m_angularlock); 1163 createAMotor(m_angularlock);
1160 } 1164 }
@@ -1338,7 +1342,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1338 m_taintshape = false; 1342 m_taintshape = false;
1339 m_taintforce = false; 1343 m_taintforce = false;
1340 m_taintdisable = false; 1344 m_taintdisable = false;
1341 m_taintVelocity = PhysicsVector.Zero; 1345 m_taintVelocity = Vector3.Zero;
1342 } 1346 }
1343 1347
1344 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh) 1348 public void CreateGeom(IntPtr m_targetSpace, IMesh _mesh)
@@ -1567,7 +1571,7 @@ Console.WriteLine(" JointCreateFixed");
1567//Console.WriteLine("Move " + m_primName); 1571//Console.WriteLine("Move " + m_primName);
1568 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009 1572 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
1569 // NON-'VEHICLES' are dealt with here 1573 // NON-'VEHICLES' are dealt with here
1570 if (d.BodyIsEnabled(Body) && !m_angularlock.IsIdentical(PhysicsVector.Zero, 0.003f)) 1574 if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f))
1571 { 1575 {
1572 d.Vector3 avel2 = d.BodyGetAngularVel(Body); 1576 d.Vector3 avel2 = d.BodyGetAngularVel(Body);
1573 if (m_angularlock.X == 1) 1577 if (m_angularlock.X == 1)
@@ -1624,7 +1628,7 @@ Console.WriteLine(" JointCreateFixed");
1624 1628
1625 d.Vector3 pos = d.BodyGetPosition(Body); 1629 d.Vector3 pos = d.BodyGetPosition(Body);
1626 _target_velocity = 1630 _target_velocity =
1627 new PhysicsVector( 1631 new Vector3(
1628 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep), 1632 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1629 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep), 1633 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1630 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep) 1634 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
@@ -1632,7 +1636,7 @@ Console.WriteLine(" JointCreateFixed");
1632 1636
1633 // if velocity is zero, use position control; otherwise, velocity control 1637 // if velocity is zero, use position control; otherwise, velocity control
1634 1638
1635 if (_target_velocity.IsIdentical(PhysicsVector.Zero,0.1f)) 1639 if (_target_velocity.ApproxEquals(Vector3.Zero,0.1f))
1636 { 1640 {
1637 // keep track of where we stopped. No more slippin' & slidin' 1641 // keep track of where we stopped. No more slippin' & slidin'
1638 1642
@@ -1717,13 +1721,13 @@ Console.WriteLine(" JointCreateFixed");
1717 1721
1718 1722
1719 _target_velocity = 1723 _target_velocity =
1720 new PhysicsVector(0.0f, 0.0f, 1724 new Vector3(0.0f, 0.0f,
1721 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep) 1725 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1722 ); 1726 );
1723 1727
1724 // if velocity is zero, use position control; otherwise, velocity control 1728 // if velocity is zero, use position control; otherwise, velocity control
1725 1729
1726 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f)) 1730 if (_target_velocity.ApproxEquals(Vector3.Zero, 0.1f))
1727 { 1731 {
1728 // keep track of where we stopped. No more slippin' & slidin' 1732 // keep track of where we stopped. No more slippin' & slidin'
1729 1733
@@ -1812,7 +1816,7 @@ Console.WriteLine(" JointCreateFixed");
1812 d.BodySetQuaternion(Body, ref myrot); 1816 d.BodySetQuaternion(Body, ref myrot);
1813 if (m_isphysical) 1817 if (m_isphysical)
1814 { 1818 {
1815 if (!m_angularlock.IsIdentical(new PhysicsVector(1, 1, 1), 0)) 1819 if (!m_angularlock.ApproxEquals(Vector3.One, 0f))
1816 createAMotor(m_angularlock); 1820 createAMotor(m_angularlock);
1817 } 1821 }
1818 } 1822 }
@@ -2121,7 +2125,7 @@ Console.WriteLine(" JointCreateFixed");
2121 //m_log.Info("[PHYSICS]: dequeing forcelist"); 2125 //m_log.Info("[PHYSICS]: dequeing forcelist");
2122 if (IsPhysical) 2126 if (IsPhysical)
2123 { 2127 {
2124 PhysicsVector iforce = new PhysicsVector(); 2128 Vector3 iforce = Vector3.Zero;
2125 for (int i = 0; i < m_forcelist.Count; i++) 2129 for (int i = 0; i < m_forcelist.Count; i++)
2126 { 2130 {
2127 iforce = iforce + (m_forcelist[i] * 100); 2131 iforce = iforce + (m_forcelist[i] * 100);
@@ -2151,8 +2155,8 @@ Console.WriteLine(" JointCreateFixed");
2151 d.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z); 2155 d.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z);
2152 } 2156 }
2153 } 2157 }
2154 2158
2155 m_taintTorque = new PhysicsVector(0, 0, 0); 2159 m_taintTorque = Vector3.Zero;
2156 } 2160 }
2157 2161
2158 public void changeAddAngularForce(float timestamp) 2162 public void changeAddAngularForce(float timestamp)
@@ -2164,7 +2168,7 @@ Console.WriteLine(" JointCreateFixed");
2164 //m_log.Info("[PHYSICS]: dequeing forcelist"); 2168 //m_log.Info("[PHYSICS]: dequeing forcelist");
2165 if (IsPhysical) 2169 if (IsPhysical)
2166 { 2170 {
2167 PhysicsVector iforce = new PhysicsVector(); 2171 Vector3 iforce = Vector3.Zero;
2168 for (int i = 0; i < m_angularforcelist.Count; i++) 2172 for (int i = 0; i < m_angularforcelist.Count; i++)
2169 { 2173 {
2170 iforce = iforce + (m_angularforcelist[i] * 100); 2174 iforce = iforce + (m_angularforcelist[i] * 100);
@@ -2198,7 +2202,7 @@ Console.WriteLine(" JointCreateFixed");
2198 2202
2199 //resetCollisionAccounting(); 2203 //resetCollisionAccounting();
2200 } 2204 }
2201 m_taintVelocity = PhysicsVector.Zero; 2205 m_taintVelocity = Vector3.Zero;
2202 } 2206 }
2203 2207
2204 public override bool IsPhysical 2208 public override bool IsPhysical
@@ -2207,7 +2211,7 @@ Console.WriteLine(" JointCreateFixed");
2207 set { 2211 set {
2208 m_isphysical = value; 2212 m_isphysical = value;
2209 if (!m_isphysical) // Zero the remembered last velocity 2213 if (!m_isphysical) // Zero the remembered last velocity
2210 m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); 2214 m_lastVelocity = Vector3.Zero;
2211 } 2215 }
2212 } 2216 }
2213 2217
@@ -2252,7 +2256,7 @@ Console.WriteLine(" JointCreateFixed");
2252 get { return _zeroFlag; } 2256 get { return _zeroFlag; }
2253 } 2257 }
2254 2258
2255 public override PhysicsVector Position 2259 public override Vector3 Position
2256 { 2260 {
2257 get { return _position; } 2261 get { return _position; }
2258 2262
@@ -2261,12 +2265,12 @@ Console.WriteLine(" JointCreateFixed");
2261 } 2265 }
2262 } 2266 }
2263 2267
2264 public override PhysicsVector Size 2268 public override Vector3 Size
2265 { 2269 {
2266 get { return _size; } 2270 get { return _size; }
2267 set 2271 set
2268 { 2272 {
2269 if (PhysicsVector.isFinite(value)) 2273 if (value.IsFinite())
2270 { 2274 {
2271 _size = value; 2275 _size = value;
2272 } 2276 }
@@ -2282,13 +2286,13 @@ Console.WriteLine(" JointCreateFixed");
2282 get { return CalculateMass(); } 2286 get { return CalculateMass(); }
2283 } 2287 }
2284 2288
2285 public override PhysicsVector Force 2289 public override Vector3 Force
2286 { 2290 {
2287 //get { return PhysicsVector.Zero; } 2291 //get { return Vector3.Zero; }
2288 get { return m_force; } 2292 get { return m_force; }
2289 set 2293 set
2290 { 2294 {
2291 if (PhysicsVector.isFinite(value)) 2295 if (value.IsFinite())
2292 { 2296 {
2293 m_force = value; 2297 m_force = value;
2294 } 2298 }
@@ -2310,7 +2314,7 @@ Console.WriteLine(" JointCreateFixed");
2310 m_vehicle.ProcessFloatVehicleParam((Vehicle) param, value); 2314 m_vehicle.ProcessFloatVehicleParam((Vehicle) param, value);
2311 } 2315 }
2312 2316
2313 public override void VehicleVectorParam(int param, PhysicsVector value) 2317 public override void VehicleVectorParam(int param, Vector3 value)
2314 { 2318 {
2315 m_vehicle.ProcessVectorVehicleParam((Vehicle) param, value); 2319 m_vehicle.ProcessVectorVehicleParam((Vehicle) param, value);
2316 } 2320 }
@@ -2328,14 +2332,14 @@ Console.WriteLine(" JointCreateFixed");
2328 } 2332 }
2329 } 2333 }
2330 2334
2331 public override PhysicsVector CenterOfMass 2335 public override Vector3 CenterOfMass
2332 { 2336 {
2333 get { return PhysicsVector.Zero; } 2337 get { return Vector3.Zero; }
2334 } 2338 }
2335 2339
2336 public override PhysicsVector GeometricCenter 2340 public override Vector3 GeometricCenter
2337 { 2341 {
2338 get { return PhysicsVector.Zero; } 2342 get { return Vector3.Zero; }
2339 } 2343 }
2340 2344
2341 public override PrimitiveBaseShape Shape 2345 public override PrimitiveBaseShape Shape
@@ -2347,13 +2351,13 @@ Console.WriteLine(" JointCreateFixed");
2347 } 2351 }
2348 } 2352 }
2349 2353
2350 public override PhysicsVector Velocity 2354 public override Vector3 Velocity
2351 { 2355 {
2352 get 2356 get
2353 { 2357 {
2354 // Averate previous velocity with the new one so 2358 // Averate previous velocity with the new one so
2355 // client object interpolation works a 'little' better 2359 // client object interpolation works a 'little' better
2356 PhysicsVector returnVelocity = new PhysicsVector(); 2360 Vector3 returnVelocity = Vector3.Zero;
2357 returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2; 2361 returnVelocity.X = (m_lastVelocity.X + _velocity.X)/2;
2358 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2; 2362 returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y)/2;
2359 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2; 2363 returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z)/2;
@@ -2361,7 +2365,7 @@ Console.WriteLine(" JointCreateFixed");
2361 } 2365 }
2362 set 2366 set
2363 { 2367 {
2364 if (PhysicsVector.isFinite(value)) 2368 if (value.IsFinite())
2365 { 2369 {
2366 _velocity = value; 2370 _velocity = value;
2367 2371
@@ -2376,19 +2380,19 @@ Console.WriteLine(" JointCreateFixed");
2376 } 2380 }
2377 } 2381 }
2378 2382
2379 public override PhysicsVector Torque 2383 public override Vector3 Torque
2380 { 2384 {
2381 get 2385 get
2382 { 2386 {
2383 if (!m_isphysical || Body == IntPtr.Zero) 2387 if (!m_isphysical || Body == IntPtr.Zero)
2384 return new PhysicsVector(0,0,0); 2388 return Vector3.Zero;
2385 2389
2386 return _torque; 2390 return _torque;
2387 } 2391 }
2388 2392
2389 set 2393 set
2390 { 2394 {
2391 if (PhysicsVector.isFinite(value)) 2395 if (value.IsFinite())
2392 { 2396 {
2393 m_taintTorque = value; 2397 m_taintTorque = value;
2394 _parent_scene.AddPhysicsActorTaint(this); 2398 _parent_scene.AddPhysicsActorTaint(this);
@@ -2440,20 +2444,20 @@ Console.WriteLine(" JointCreateFixed");
2440 return true; 2444 return true;
2441 } 2445 }
2442 2446
2443 public override PhysicsVector Acceleration 2447 public override Vector3 Acceleration
2444 { 2448 {
2445 get { return _acceleration; } 2449 get { return _acceleration; }
2446 } 2450 }
2447 2451
2448 2452
2449 public void SetAcceleration(PhysicsVector accel) 2453 public void SetAcceleration(Vector3 accel)
2450 { 2454 {
2451 _acceleration = accel; 2455 _acceleration = accel;
2452 } 2456 }
2453 2457
2454 public override void AddForce(PhysicsVector force, bool pushforce) 2458 public override void AddForce(Vector3 force, bool pushforce)
2455 { 2459 {
2456 if (PhysicsVector.isFinite(force)) 2460 if (force.IsFinite())
2457 { 2461 {
2458 m_forcelist.Add(force); 2462 m_forcelist.Add(force);
2459 m_taintforce = true; 2463 m_taintforce = true;
@@ -2465,9 +2469,9 @@ Console.WriteLine(" JointCreateFixed");
2465 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); 2469 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
2466 } 2470 }
2467 2471
2468 public override void AddAngularForce(PhysicsVector force, bool pushforce) 2472 public override void AddAngularForce(Vector3 force, bool pushforce)
2469 { 2473 {
2470 if (PhysicsVector.isFinite(force)) 2474 if (force.IsFinite())
2471 { 2475 {
2472 m_angularforcelist.Add(force); 2476 m_angularforcelist.Add(force);
2473 m_taintaddangularforce = true; 2477 m_taintaddangularforce = true;
@@ -2478,23 +2482,23 @@ Console.WriteLine(" JointCreateFixed");
2478 } 2482 }
2479 } 2483 }
2480 2484
2481 public override PhysicsVector RotationalVelocity 2485 public override Vector3 RotationalVelocity
2482 { 2486 {
2483 get 2487 get
2484 { 2488 {
2485 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2489 Vector3 pv = Vector3.Zero;
2486 if (_zeroFlag) 2490 if (_zeroFlag)
2487 return pv; 2491 return pv;
2488 m_lastUpdateSent = false; 2492 m_lastUpdateSent = false;
2489 2493
2490 if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) 2494 if (m_rotationalVelocity.ApproxEquals(pv, 0.2f))
2491 return pv; 2495 return pv;
2492 2496
2493 return m_rotationalVelocity; 2497 return m_rotationalVelocity;
2494 } 2498 }
2495 set 2499 set
2496 { 2500 {
2497 if (PhysicsVector.isFinite(value)) 2501 if (value.IsFinite())
2498 { 2502 {
2499 m_rotationalVelocity = value; 2503 m_rotationalVelocity = value;
2500 } 2504 }
@@ -2535,16 +2539,16 @@ Console.WriteLine(" JointCreateFixed");
2535 m_taintparent = null; 2539 m_taintparent = null;
2536 } 2540 }
2537 2541
2538 public override void LockAngularMotion(PhysicsVector axis) 2542 public override void LockAngularMotion(Vector3 axis)
2539 { 2543 {
2540 // reverse the zero/non zero values for ODE. 2544 // reverse the zero/non zero values for ODE.
2541 if (PhysicsVector.isFinite(axis)) 2545 if (axis.IsFinite())
2542 { 2546 {
2543 axis.X = (axis.X > 0) ? 1f : 0f; 2547 axis.X = (axis.X > 0) ? 1f : 0f;
2544 axis.Y = (axis.Y > 0) ? 1f : 0f; 2548 axis.Y = (axis.Y > 0) ? 1f : 0f;
2545 axis.Z = (axis.Z > 0) ? 1f : 0f; 2549 axis.Z = (axis.Z > 0) ? 1f : 0f;
2546 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); 2550 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z);
2547 m_taintAngularLock = new PhysicsVector(axis.X, axis.Y, axis.Z); 2551 m_taintAngularLock = axis;
2548 } 2552 }
2549 else 2553 else
2550 { 2554 {
@@ -2557,7 +2561,7 @@ Console.WriteLine(" JointCreateFixed");
2557 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! 2561 // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit!
2558 if (_parent == null) 2562 if (_parent == null)
2559 { 2563 {
2560 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2564 Vector3 pv = Vector3.Zero;
2561 bool lastZeroFlag = _zeroFlag; 2565 bool lastZeroFlag = _zeroFlag;
2562 if (Body != (IntPtr)0) // FIXME -> or if it is a joint 2566 if (Body != (IntPtr)0) // FIXME -> or if it is a joint
2563 { 2567 {
@@ -2566,9 +2570,9 @@ Console.WriteLine(" JointCreateFixed");
2566 d.Vector3 vel = d.BodyGetLinearVel(Body); 2570 d.Vector3 vel = d.BodyGetLinearVel(Body);
2567 d.Vector3 rotvel = d.BodyGetAngularVel(Body); 2571 d.Vector3 rotvel = d.BodyGetAngularVel(Body);
2568 d.Vector3 torque = d.BodyGetTorque(Body); 2572 d.Vector3 torque = d.BodyGetTorque(Body);
2569 _torque.setValues(torque.X, torque.Y, torque.Z); 2573 _torque = new Vector3(torque.X, torque.Y, torque.Z);
2570 PhysicsVector l_position = new PhysicsVector(); 2574 Vector3 l_position = Vector3.Zero;
2571 Quaternion l_orientation = new Quaternion(); 2575 Quaternion l_orientation = Quaternion.Identity;
2572 2576
2573 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 2577 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
2574 //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } 2578 //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
@@ -2703,16 +2707,16 @@ Console.WriteLine(" JointCreateFixed");
2703 _velocity.Z = vel.Z; 2707 _velocity.Z = vel.Z;
2704 2708
2705 _acceleration = ((_velocity - m_lastVelocity) / 0.1f); 2709 _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
2706 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f); 2710 _acceleration = new Vector3(_velocity.X - m_lastVelocity.X / 0.1f, _velocity.Y - m_lastVelocity.Y / 0.1f, _velocity.Z - m_lastVelocity.Z / 0.1f);
2707 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); 2711 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
2708 2712
2709 if (_velocity.IsIdentical(pv, 0.5f)) 2713 if (_velocity.ApproxEquals(pv, 0.5f))
2710 { 2714 {
2711 m_rotationalVelocity = pv; 2715 m_rotationalVelocity = pv;
2712 } 2716 }
2713 else 2717 else
2714 { 2718 {
2715 m_rotationalVelocity.setValues(rotvel.X, rotvel.Y, rotvel.Z); 2719 m_rotationalVelocity = new Vector3(rotvel.X, rotvel.Y, rotvel.Z);
2716 } 2720 }
2717 2721
2718 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString()); 2722 //m_log.Debug("ODE: " + m_rotationalVelocity.ToString());
@@ -2760,15 +2764,15 @@ Console.WriteLine(" JointCreateFixed");
2760 } 2764 }
2761 } 2765 }
2762 2766
2763 public override void SetMomentum(PhysicsVector momentum) 2767 public override void SetMomentum(Vector3 momentum)
2764 { 2768 {
2765 } 2769 }
2766 2770
2767 public override PhysicsVector PIDTarget 2771 public override Vector3 PIDTarget
2768 { 2772 {
2769 set 2773 set
2770 { 2774 {
2771 if (PhysicsVector.isFinite(value)) 2775 if (value.IsFinite())
2772 { 2776 {
2773 m_PIDTarget = value; 2777 m_PIDTarget = value;
2774 } 2778 }
@@ -2784,7 +2788,7 @@ Console.WriteLine(" JointCreateFixed");
2784 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } } 2788 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
2785 public override float PIDHoverTau { set { m_PIDHoverTau = value; } } 2789 public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
2786 2790
2787 private void createAMotor(PhysicsVector axis) 2791 private void createAMotor(Vector3 axis)
2788 { 2792 {
2789 if (Body == IntPtr.Zero) 2793 if (Body == IntPtr.Zero)
2790 return; 2794 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 35fc616..26cd1dd 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 b50364b..96c3e26 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 e7d989c..8bdb18d 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
@@ -518,15 +516,15 @@ namespace OpenSim.Region.Physics.PhysXPlugin
518 516
519 public class PhysXPrim : PhysicsActor 517 public class PhysXPrim : PhysicsActor
520 { 518 {
521 private PhysicsVector _velocity; 519 private Vector3 _velocity;
522 private PhysicsVector _acceleration; 520 private Vector3 _acceleration;
523 private PhysicsVector m_rotationalVelocity; 521 private Vector3 m_rotationalVelocity;
524 private NxActor _prim; 522 private NxActor _prim;
525 523
526 public PhysXPrim(NxActor prim) 524 public PhysXPrim(NxActor prim)
527 { 525 {
528 _velocity = new PhysicsVector(); 526 _velocity = Vector3.Zero;
529 _acceleration = new PhysicsVector(); 527 _acceleration = Vector3.Zero;
530 _prim = prim; 528 _prim = prim;
531 } 529 }
532 530
@@ -580,7 +578,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
580 set { return; } 578 set { return; }
581 } 579 }
582 580
583 public override PhysicsVector RotationalVelocity 581 public override Vector3 RotationalVelocity
584 { 582 {
585 get { return m_rotationalVelocity; } 583 get { return m_rotationalVelocity; }
586 set { m_rotationalVelocity = value; } 584 set { m_rotationalVelocity = value; }
@@ -616,11 +614,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin
616 get { return false; } 614 get { return false; }
617 } 615 }
618 616
619 public override PhysicsVector Position 617 public override Vector3 Position
620 { 618 {
621 get 619 get
622 { 620 {
623 PhysicsVector pos = new PhysicsVector(); 621 Vector3 pos = Vector3.Zero;
624 Vec3 vec = _prim.Position; 622 Vec3 vec = _prim.Position;
625 pos.X = vec.X; 623 pos.X = vec.X;
626 pos.Y = vec.Y; 624 pos.Y = vec.Y;
@@ -629,7 +627,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
629 } 627 }
630 set 628 set
631 { 629 {
632 PhysicsVector vec = value; 630 Vector3 vec = value;
633 Vec3 pos = new Vec3(); 631 Vec3 pos = new Vec3();
634 pos.X = vec.X; 632 pos.X = vec.X;
635 pos.Y = vec.Y; 633 pos.Y = vec.Y;
@@ -643,15 +641,15 @@ namespace OpenSim.Region.Physics.PhysXPlugin
643 set { return; } 641 set { return; }
644 } 642 }
645 643
646 public override PhysicsVector Velocity 644 public override Vector3 Velocity
647 { 645 {
648 get { return _velocity; } 646 get { return _velocity; }
649 set { _velocity = value; } 647 set { _velocity = value; }
650 } 648 }
651 649
652 public override PhysicsVector Torque 650 public override Vector3 Torque
653 { 651 {
654 get { return PhysicsVector.Zero; } 652 get { return Vector3.Zero; }
655 set { return; } 653 set { return; }
656 } 654 }
657 655
@@ -682,31 +680,31 @@ namespace OpenSim.Region.Physics.PhysXPlugin
682 set { } 680 set { }
683 } 681 }
684 682
685 public override PhysicsVector Acceleration 683 public override Vector3 Acceleration
686 { 684 {
687 get { return _acceleration; } 685 get { return _acceleration; }
688 } 686 }
689 687
690 public void SetAcceleration(PhysicsVector accel) 688 public void SetAcceleration(Vector3 accel)
691 { 689 {
692 _acceleration = accel; 690 _acceleration = accel;
693 } 691 }
694 692
695 public override void AddForce(PhysicsVector force, bool pushforce) 693 public override void AddForce(Vector3 force, bool pushforce)
696 { 694 {
697 } 695 }
698 696
699 public override void AddAngularForce(PhysicsVector force, bool pushforce) 697 public override void AddAngularForce(Vector3 force, bool pushforce)
700 { 698 {
701 } 699 }
702 700
703 public override void SetMomentum(PhysicsVector momentum) 701 public override void SetMomentum(Vector3 momentum)
704 { 702 {
705 } 703 }
706 704
707 public override PhysicsVector Size 705 public override Vector3 Size
708 { 706 {
709 get { return PhysicsVector.Zero; } 707 get { return Vector3.Zero; }
710 set { } 708 set { }
711 } 709 }
712 710
@@ -718,7 +716,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
718 { 716 {
719 } 717 }
720 718
721 public override void LockAngularMotion(PhysicsVector axis) 719 public override void LockAngularMotion(Vector3 axis)
722 { 720 {
723 721
724 } 722 }
@@ -728,9 +726,9 @@ namespace OpenSim.Region.Physics.PhysXPlugin
728 get { return 0f; } 726 get { return 0f; }
729 } 727 }
730 728
731 public override PhysicsVector Force 729 public override Vector3 Force
732 { 730 {
733 get { return PhysicsVector.Zero; } 731 get { return Vector3.Zero; }
734 set { return; } 732 set { return; }
735 } 733 }
736 734
@@ -745,7 +743,7 @@ namespace OpenSim.Region.Physics.PhysXPlugin
745 743
746 } 744 }
747 745
748 public override void VehicleVectorParam(int param, PhysicsVector value) 746 public override void VehicleVectorParam(int param, Vector3 value)
749 { 747 {
750 748
751 } 749 }
@@ -760,21 +758,21 @@ namespace OpenSim.Region.Physics.PhysXPlugin
760 758
761 } 759 }
762 760
763 public override PhysicsVector CenterOfMass 761 public override Vector3 CenterOfMass
764 { 762 {
765 get { return PhysicsVector.Zero; } 763 get { return Vector3.Zero; }
766 } 764 }
767 765
768 public override PhysicsVector GeometricCenter 766 public override Vector3 GeometricCenter
769 { 767 {
770 get { return PhysicsVector.Zero; } 768 get { return Vector3.Zero; }
771 } 769 }
772 770
773 public override void CrossingFailure() 771 public override void CrossingFailure()
774 { 772 {
775 } 773 }
776 774
777 public override PhysicsVector PIDTarget { set { return; } } 775 public override Vector3 PIDTarget { set { return; } }
778 public override bool PIDActive { set { return; } } 776 public override bool PIDActive { set { return; } }
779 public override float PIDTau { set { return; } } 777 public override float PIDTau { set { return; } }
780 778
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
index 583d2ff..51fd41a 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
@@ -132,12 +132,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
132 /// </summary> 132 /// </summary>
133 private void Start() 133 private void Start()
134 { 134 {
135 EventQueueThread = new Thread(EventQueueThreadLoop); 135 EventQueueThread = Watchdog.StartThread(EventQueueThreadLoop, "EventQueueManagerThread_" + ThreadCount, MyThreadPriority, true);
136 EventQueueThread.IsBackground = true;
137
138 EventQueueThread.Priority = MyThreadPriority;
139 EventQueueThread.Name = "EventQueueManagerThread_" + ThreadCount;
140 EventQueueThread.Start();
141 136
142 // Look at this... Don't you wish everyone did that solid 137 // Look at this... Don't you wish everyone did that solid
143 // coding everywhere? :P 138 // coding everywhere? :P
@@ -184,6 +179,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
184 while (true) 179 while (true)
185 { 180 {
186 DoProcessQueue(); 181 DoProcessQueue();
182 Watchdog.UpdateThread();
187 } 183 }
188 } 184 }
189 catch (ThreadAbortException) 185 catch (ThreadAbortException)
@@ -214,6 +210,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
214 m_log.ErrorFormat("[{0}]: Exception {1} thrown", ScriptEngineName, e.GetType().ToString()); 210 m_log.ErrorFormat("[{0}]: Exception {1} thrown", ScriptEngineName, e.GetType().ToString());
215 throw e; 211 throw e;
216 } 212 }
213
214 Watchdog.UpdateThread();
217 } 215 }
218 } 216 }
219 catch (ThreadAbortException) 217 catch (ThreadAbortException)
@@ -226,6 +224,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
226 "[{0}]: Event queue thread terminating with exception. PLEASE REBOOT YOUR SIM - SCRIPT EVENTS WILL NOT WORK UNTIL YOU DO. Exception is {1}", 224 "[{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); 225 ScriptEngineName, e);
228 } 226 }
227
228 Watchdog.RemoveThread();
229 } 229 }
230 230
231 public void DoProcessQueue() 231 public void DoProcessQueue()
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
index 7ffdb1a..87fdf1f 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
@@ -93,10 +93,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
93 { 93 {
94 if (MaintenanceThreadThread == null) 94 if (MaintenanceThreadThread == null)
95 { 95 {
96 MaintenanceThreadThread = new Thread(MaintenanceLoop); 96 MaintenanceThreadThread = Watchdog.StartThread(MaintenanceLoop, "ScriptMaintenanceThread", ThreadPriority.Normal, true);
97 MaintenanceThreadThread.Name = "ScriptMaintenanceThread";
98 MaintenanceThreadThread.IsBackground = true;
99 MaintenanceThreadThread.Start();
100 } 97 }
101 } 98 }
102 99
@@ -164,56 +161,54 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
164 MaintenanceLoopTicks_ScriptLoadUnload_Count++; 161 MaintenanceLoopTicks_ScriptLoadUnload_Count++;
165 MaintenanceLoopTicks_Other_Count++; 162 MaintenanceLoopTicks_Other_Count++;
166 163
167 164 foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
168 //lock (ScriptEngine.ScriptEngines) 165 {
169 //{ 166 // lastScriptEngine = m_ScriptEngine;
170 foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines)) 167 // Re-reading config every x seconds
168 if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
171 { 169 {
172 // lastScriptEngine = m_ScriptEngine; 170 MaintenanceLoopTicks_Other_ResetCount = true;
173 // Re-reading config every x seconds 171 if (m_ScriptEngine.RefreshConfigFilens > 0)
174 if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
175 { 172 {
176 MaintenanceLoopTicks_Other_ResetCount = true; 173 // Check if its time to re-read config
177 if (m_ScriptEngine.RefreshConfigFilens > 0) 174 if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
175 m_ScriptEngine.RefreshConfigFilens)
178 { 176 {
179 // Check if its time to re-read config 177 //m_log.Debug("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens);
180 if (DateTime.Now.Ticks - Last_ReReadConfigFilens > 178 // Its time to re-read config file
181 m_ScriptEngine.RefreshConfigFilens) 179 m_ScriptEngine.ReadConfig();
182 { 180 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
183 //m_log.Debug("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens); 181 }
184 // Its time to re-read config file
185 m_ScriptEngine.ReadConfig();
186 Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
187 }
188 182
189 183
190 // Adjust number of running script threads if not correct 184 // Adjust number of running script threads if not correct
191 if (m_ScriptEngine.m_EventQueueManager != null) 185 if (m_ScriptEngine.m_EventQueueManager != null)
192 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads(); 186 m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
193 187
194 // Check if any script has exceeded its max execution time 188 // Check if any script has exceeded its max execution time
195 if (EventQueueManager.EnforceMaxExecutionTime) 189 if (EventQueueManager.EnforceMaxExecutionTime)
190 {
191 // We are enforcing execution time
192 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
193 EventQueueManager.maxFunctionExecutionTimens)
196 { 194 {
197 // We are enforcing execution time 195 // Its time to check again
198 if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens > 196 m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
199 EventQueueManager.maxFunctionExecutionTimens) 197 Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
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 } 198 }
206 } 199 }
207 } 200 }
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 } 201 }
216 //} 202 if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
203 {
204 MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = true;
205 // LOAD / UNLOAD SCRIPTS
206 if (m_ScriptEngine.m_ScriptManager != null)
207 m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
208 }
209 }
210
211 Watchdog.UpdateThread();
217 } 212 }
218 } 213 }
219 catch(ThreadAbortException) 214 catch(ThreadAbortException)
@@ -225,6 +220,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
225 m_log.ErrorFormat("Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: {0}", ex.ToString()); 220 m_log.ErrorFormat("Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: {0}", ex.ToString());
226 } 221 }
227 } 222 }
223
224 Watchdog.RemoveThread();
228 } 225 }
229 #endregion 226 #endregion
230 227
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 11f255f..3849558 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;
@@ -4176,7 +4180,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4176 { 4180 {
4177 applied_linear_impulse *= m_host.GetWorldRotation(); 4181 applied_linear_impulse *= m_host.GetWorldRotation();
4178 } 4182 }
4179 pusheeav.PhysicsActor.AddForce(new PhysicsVector(applied_linear_impulse.X, applied_linear_impulse.Y, applied_linear_impulse.Z), true); 4183 pusheeav.PhysicsActor.AddForce(applied_linear_impulse, true);
4180 } 4184 }
4181 } 4185 }
4182 } 4186 }
@@ -6084,7 +6088,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6084 if (!m_host.ParentGroup.IsDeleted) 6088 if (!m_host.ParentGroup.IsDeleted)
6085 { 6089 {
6086 m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, 6090 m_host.ParentGroup.RootPart.SetVehicleVectorParam(param,
6087 new PhysicsVector((float)vec.x, (float)vec.y, (float)vec.z)); 6091 new Vector3((float)vec.x, (float)vec.y, (float)vec.z));
6088 } 6092 }
6089 } 6093 }
6090 } 6094 }
@@ -7223,13 +7227,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7223 public LSL_Integer llGetNumberOfPrims() 7227 public LSL_Integer llGetNumberOfPrims()
7224 { 7228 {
7225 m_host.AddScriptLPS(1); 7229 m_host.AddScriptLPS(1);
7226 List<ScenePresence> presences = World.GetScenePresences(); 7230 ScenePresence[] presences = World.GetScenePresences();
7227 if (presences.Count == 0) 7231 if (presences.Length == 0)
7228 return 0; 7232 return 0;
7229 7233
7230 int avatarCount = 0; 7234 int avatarCount = 0;
7231 foreach (ScenePresence presence in presences) 7235 for (int i = 0; i < presences.Length; i++)
7232 { 7236 {
7237 ScenePresence presence = presences[i];
7238
7233 if (!presence.IsChildAgent && presence.ParentID != 0) 7239 if (!presence.IsChildAgent && presence.ParentID != 0)
7234 { 7240 {
7235 if (m_host.ParentGroup.HasChildPrim(presence.ParentID)) 7241 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/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/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
new file mode 100644
index 0000000..6e59642
--- /dev/null
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -0,0 +1,53 @@
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.Net;
31using System.Reflection;
32using Nini.Config;
33using log4net;
34using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Data;
37using OpenSim.Services.Interfaces;
38using OpenMetaverse;
39
40namespace OpenSim.Services.PresenceService
41{
42 public class PresenceService : PresenceServiceBase, IPresenceService
43 {
44 private static readonly ILog m_log =
45 LogManager.GetLogger(
46 MethodBase.GetCurrentMethod().DeclaringType);
47
48 public PresenceService(IConfigSource config)
49 : base(config)
50 {
51 }
52 }
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