aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Client/Linden/LLProxyLoginModule.cs2
-rw-r--r--OpenSim/Client/Linden/LLStandaloneLoginModule.cs2
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs15
-rw-r--r--OpenSim/Data/Null/NullRegionData.cs5
-rw-r--r--OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs4
-rw-r--r--OpenSim/Region/Application/OpenSim.cs2
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs8
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs4
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs7
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs234
-rw-r--r--OpenSim/Region/Physics/Meshing/Mesh.cs87
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs69
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs17
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs4
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs203
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs277
-rw-r--r--OpenSim/Services/GridService/GridService.cs91
-rw-r--r--OpenSim/Services/Interfaces/IGridService.cs68
-rw-r--r--OpenSim/Tests/Clients/Grid/GridClient.cs177
-rw-r--r--OpenSim/Tests/Clients/Grid/GridForm.html11
-rw-r--r--bin/OpenSim.GridServer.ini.example35
-rw-r--r--bin/OpenSim.ini.example2
-rw-r--r--prebuild.xml29
25 files changed, 912 insertions, 445 deletions
diff --git a/OpenSim/Client/Linden/LLProxyLoginModule.cs b/OpenSim/Client/Linden/LLProxyLoginModule.cs
index f55d9fc..ccd38d4 100644
--- a/OpenSim/Client/Linden/LLProxyLoginModule.cs
+++ b/OpenSim/Client/Linden/LLProxyLoginModule.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Client.Linden
58 { 58 {
59 if (m_firstScene != null) 59 if (m_firstScene != null)
60 { 60 {
61 return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; 61 return m_firstScene.SceneGridService.RegionLoginsEnabled;
62 } 62 }
63 else 63 else
64 { 64 {
diff --git a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
index 4a31e95..fb0aaa5 100644
--- a/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
+++ b/OpenSim/Client/Linden/LLStandaloneLoginModule.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Client.Linden
62 { 62 {
63 if (m_firstScene != null) 63 if (m_firstScene != null)
64 { 64 {
65 return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; 65 return m_firstScene.SceneGridService.RegionLoginsEnabled;
66 } 66 }
67 else 67 else
68 { 68 {
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index ced26a4..e13e12c 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -77,7 +77,7 @@ namespace OpenSim.Data.MySQL
77 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 77 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
78 78
79 List<RegionData> ret = RunCommand(cmd); 79 List<RegionData> ret = RunCommand(cmd);
80 if (ret == null) 80 if (ret.Count == 0)
81 return null; 81 return null;
82 82
83 return ret[0]; 83 return ret[0];
@@ -95,7 +95,7 @@ namespace OpenSim.Data.MySQL
95 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString()); 95 cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
96 96
97 List<RegionData> ret = RunCommand(cmd); 97 List<RegionData> ret = RunCommand(cmd);
98 if (ret == null) 98 if (ret.Count == 0)
99 return null; 99 return null;
100 100
101 return ret[0]; 101 return ret[0];
@@ -170,10 +170,7 @@ namespace OpenSim.Data.MySQL
170 result.Close(); 170 result.Close();
171 CloseReaderCommand(cmd); 171 CloseReaderCommand(cmd);
172 172
173 if (retList.Count > 0) 173 return retList;
174 return retList;
175
176 return null;
177 } 174 }
178 175
179 public bool Store(RegionData data) 176 public bool Store(RegionData data)
@@ -182,12 +179,6 @@ namespace OpenSim.Data.MySQL
182 data.Data.Remove("uuid"); 179 data.Data.Remove("uuid");
183 if (data.Data.ContainsKey("ScopeID")) 180 if (data.Data.ContainsKey("ScopeID"))
184 data.Data.Remove("ScopeID"); 181 data.Data.Remove("ScopeID");
185 if (data.Data.ContainsKey("regionName"))
186 data.Data.Remove("regionName");
187 if (data.Data.ContainsKey("posX"))
188 data.Data.Remove("posX");
189 if (data.Data.ContainsKey("posY"))
190 data.Data.Remove("posY");
191 182
192 string[] fields = new List<string>(data.Data.Keys).ToArray(); 183 string[] fields = new List<string>(data.Data.Keys).ToArray();
193 184
diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs
index e976c40..218fcd0 100644
--- a/OpenSim/Data/Null/NullRegionData.cs
+++ b/OpenSim/Data/Null/NullRegionData.cs
@@ -101,10 +101,7 @@ namespace OpenSim.Data.Null
101 ret.Add(r); 101 ret.Add(r);
102 } 102 }
103 103
104 if (ret.Count > 0) 104 return ret;
105 return ret;
106
107 return null;
108 } 105 }
109 106
110 public bool Store(RegionData data) 107 public bool Store(RegionData data)
diff --git a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
index 0f0c790..ebb2691 100644
--- a/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
+++ b/OpenSim/Framework/Servers/HttpServer/SynchronousRestFormsRequester.cs
@@ -56,14 +56,14 @@ namespace OpenSim.Framework.Servers.HttpServer
56 request.ContentType = "text/www-form-urlencoded"; 56 request.ContentType = "text/www-form-urlencoded";
57 57
58 MemoryStream buffer = new MemoryStream(); 58 MemoryStream buffer = new MemoryStream();
59 59 int length = 0;
60 using (StreamWriter writer = new StreamWriter(buffer)) 60 using (StreamWriter writer = new StreamWriter(buffer))
61 { 61 {
62 writer.WriteLine(obj); 62 writer.WriteLine(obj);
63 writer.Flush(); 63 writer.Flush();
64 length = (int)buffer.Length;
64 } 65 }
65 66
66 int length = (int) buffer.Length;
67 request.ContentLength = length; 67 request.ContentLength = length;
68 68
69 Stream requestStream = request.GetRequestStream(); 69 Stream requestStream = request.GetRequestStream();
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 10071a0..e9c9dc1 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -557,7 +557,7 @@ namespace OpenSim
557 /// <param name="cmd"></param> 557 /// <param name="cmd"></param>
558 private void HandleLoginStatus(string module, string[] cmd) 558 private void HandleLoginStatus(string module, string[] cmd)
559 { 559 {
560 if (m_commsManager.GridService.RegionLoginsEnabled == false) 560 if (m_sceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled == false)
561 561
562 m_log.Info("[ Login ] Login are disabled "); 562 m_log.Info("[ Login ] Login are disabled ");
563 else 563 else
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 7bc0b77..4d13e83 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -209,9 +209,9 @@ namespace OpenSim
209 } 209 }
210 210
211 // Only enable logins to the regions once we have completely finished starting up (apart from scripts) 211 // Only enable logins to the regions once we have completely finished starting up (apart from scripts)
212 if ((m_commsManager != null) && (m_commsManager.GridService != null)) 212 if ((SceneManager.CurrentOrFirstScene != null) && (SceneManager.CurrentOrFirstScene.SceneGridService != null))
213 { 213 {
214 m_commsManager.GridService.RegionLoginsEnabled = true; 214 SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = true;
215 } 215 }
216 216
217 AddPluginCommands(); 217 AddPluginCommands();
@@ -299,12 +299,12 @@ namespace OpenSim
299 if (LoginEnabled) 299 if (LoginEnabled)
300 { 300 {
301 m_log.Info("[LOGIN]: Login is now enabled."); 301 m_log.Info("[LOGIN]: Login is now enabled.");
302 m_commsManager.GridService.RegionLoginsEnabled = true; 302 SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = true;
303 } 303 }
304 else 304 else
305 { 305 {
306 m_log.Info("[LOGIN]: Login is now disabled."); 306 m_log.Info("[LOGIN]: Login is now disabled.");
307 m_commsManager.GridService.RegionLoginsEnabled = false; 307 SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = false;
308 } 308 }
309 } 309 }
310 310
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index d85d3df..37cccc8 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -142,7 +142,7 @@ namespace Flotsam.RegionModules.AssetCache
142 m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); 142 m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory);
143 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); 143 m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory);
144 144
145 m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", true); 145 m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false);
146 m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); 146 m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration));
147 147
148#if WAIT_ON_INPROGRESS_REQUESTS 148#if WAIT_ON_INPROGRESS_REQUESTS
@@ -150,7 +150,7 @@ namespace Flotsam.RegionModules.AssetCache
150#endif 150#endif
151 151
152 m_LogLevel = assetConfig.GetInt("LogLevel", 1); 152 m_LogLevel = assetConfig.GetInt("LogLevel", 1);
153 m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1); 153 m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000);
154 154
155 m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); 155 m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration));
156 m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); 156 m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration));
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
index 613dbe9..4199c98 100644
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
+++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid
61 { 61 {
62 if (m_firstScene != null) 62 if (m_firstScene != null)
63 { 63 {
64 return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; 64 return m_firstScene.SceneGridService.RegionLoginsEnabled;
65 } 65 }
66 else 66 else
67 { 67 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 204c319..56cd87d 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -63,6 +63,13 @@ namespace OpenSim.Region.Framework.Scenes
63 63
64 protected List<UUID> m_agentsInTransit; 64 protected List<UUID> m_agentsInTransit;
65 65
66 public bool RegionLoginsEnabled
67 {
68 get { return m_regionLoginsEnabled; }
69 set { m_regionLoginsEnabled = value; }
70 }
71 private bool m_regionLoginsEnabled = false;
72
66 /// <summary> 73 /// <summary>
67 /// An agent is crossing into this region 74 /// An agent is crossing into this region
68 /// </summary> 75 /// </summary>
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
index 7ab8b98..f22ea71 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
@@ -204,7 +204,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
204 tempAngularVelocity2 = new btVector3(0, 0, 0); 204 tempAngularVelocity2 = new btVector3(0, 0, 0);
205 tempInertia1 = new btVector3(0, 0, 0); 205 tempInertia1 = new btVector3(0, 0, 0);
206 tempInertia2 = new btVector3(0, 0, 0); 206 tempInertia2 = new btVector3(0, 0, 0);
207 tempOrientation1 = new btQuaternion(0,0,0,1); 207 tempOrientation1 = new btQuaternion(0, 0, 0, 1);
208 tempOrientation2 = new btQuaternion(0, 0, 0, 1); 208 tempOrientation2 = new btQuaternion(0, 0, 0, 1);
209 _parent_scene = parent_scene; 209 _parent_scene = parent_scene;
210 tempTransform1 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero); 210 tempTransform1 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero);
@@ -216,10 +216,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
216 tempMotionState2 = new btDefaultMotionState(_parent_scene.TransZero); 216 tempMotionState2 = new btDefaultMotionState(_parent_scene.TransZero);
217 tempMotionState3 = new btDefaultMotionState(_parent_scene.TransZero); 217 tempMotionState3 = new btDefaultMotionState(_parent_scene.TransZero);
218 218
219 219
220 AxisLockLinearLow = new btVector3(-1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize); 220 AxisLockLinearLow = new btVector3(-1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize);
221 int regionsize = (int) Constants.RegionSize; 221 int regionsize = (int)Constants.RegionSize;
222 222
223 if (regionsize == 256) 223 if (regionsize == 256)
224 regionsize = 512; 224 regionsize = 512;
225 225
@@ -611,7 +611,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
611 DisableAxisMotor(); 611 DisableAxisMotor();
612 DisposeOfBody(); 612 DisposeOfBody();
613 SetCollisionShape(null); 613 SetCollisionShape(null);
614 614
615 if (tempMotionState3 != null && tempMotionState3.Handle != IntPtr.Zero) 615 if (tempMotionState3 != null && tempMotionState3.Handle != IntPtr.Zero)
616 { 616 {
617 tempMotionState3.Dispose(); 617 tempMotionState3.Dispose();
@@ -677,8 +677,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
677 tempInertia2.Dispose(); 677 tempInertia2.Dispose();
678 tempInertia1 = null; 678 tempInertia1 = null;
679 } 679 }
680 680
681 681
682 if (tempAngularVelocity2 != null && tempAngularVelocity2.Handle != IntPtr.Zero) 682 if (tempAngularVelocity2 != null && tempAngularVelocity2.Handle != IntPtr.Zero)
683 { 683 {
684 tempAngularVelocity2.Dispose(); 684 tempAngularVelocity2.Dispose();
@@ -802,7 +802,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
802 changesize(timestep); 802 changesize(timestep);
803 } 803 }
804 804
805 // 805 //
806 806
807 if (m_taintshape) 807 if (m_taintshape)
808 { 808 {
@@ -1001,7 +1001,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1001 else 1001 else
1002 SetBody(0); 1002 SetBody(0);
1003 changeSelectedStatus(timestep); 1003 changeSelectedStatus(timestep);
1004 1004
1005 resetCollisionAccounting(); 1005 resetCollisionAccounting();
1006 m_taintPhysics = m_isphysical; 1006 m_taintPhysics = m_isphysical;
1007 } 1007 }
@@ -1012,7 +1012,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1012 { 1012 {
1013 if (_parent_scene.needsMeshing(_pbs)) 1013 if (_parent_scene.needsMeshing(_pbs))
1014 { 1014 {
1015 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero,Quaternion.Identity); 1015 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity);
1016 // createmesh returns null when it doesn't mesh. 1016 // createmesh returns null when it doesn't mesh.
1017 CreateGeom(IntPtr.Zero, _mesh); 1017 CreateGeom(IntPtr.Zero, _mesh);
1018 } 1018 }
@@ -1038,32 +1038,32 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1038 meshlod = _parent_scene.MeshSculptphysicalLOD; 1038 meshlod = _parent_scene.MeshSculptphysicalLOD;
1039 1039
1040 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical); 1040 IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical);
1041 if (!positionOffset.IsIdentical(PhysicsVector.Zero,0.001f) || orientation != Quaternion.Identity) 1041 if (!positionOffset.IsIdentical(PhysicsVector.Zero, 0.001f) || orientation != Quaternion.Identity)
1042 { 1042 {
1043 1043
1044 float[] xyz = new float[3]; 1044 float[] xyz = new float[3];
1045 xyz[0] = positionOffset.X; 1045 xyz[0] = positionOffset.X;
1046 xyz[1] = positionOffset.Y; 1046 xyz[1] = positionOffset.Y;
1047 xyz[2] = positionOffset.Z; 1047 xyz[2] = positionOffset.Z;
1048 1048
1049 Matrix4 m4 = Matrix4.CreateFromQuaternion(orientation); 1049 Matrix4 m4 = Matrix4.CreateFromQuaternion(orientation);
1050 1050
1051 float[,] matrix = new float[3,3]; 1051 float[,] matrix = new float[3, 3];
1052 1052
1053 matrix[0, 0] = m4.M11; 1053 matrix[0, 0] = m4.M11;
1054 matrix[0, 1] = m4.M12; 1054 matrix[0, 1] = m4.M12;
1055 matrix[0, 2] = m4.M13; 1055 matrix[0, 2] = m4.M13;
1056 matrix[1, 0] = m4.M21; 1056 matrix[1, 0] = m4.M21;
1057 matrix[1, 1] = m4.M22; 1057 matrix[1, 1] = m4.M22;
1058 matrix[1, 2] = m4.M23; 1058 matrix[1, 2] = m4.M23;
1059 matrix[2, 0] = m4.M31; 1059 matrix[2, 0] = m4.M31;
1060 matrix[2, 1] = m4.M32; 1060 matrix[2, 1] = m4.M32;
1061 matrix[2, 2] = m4.M33; 1061 matrix[2, 2] = m4.M33;
1062 1062
1063 1063
1064 mesh.TransformLinear(matrix, xyz); 1064 mesh.TransformLinear(matrix, xyz);
1065 1065
1066 1066
1067 1067
1068 } 1068 }
1069 1069
@@ -1088,12 +1088,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1088 SetCollisionShape(null); 1088 SetCollisionShape(null);
1089 // Construction of new prim 1089 // Construction of new prim
1090 ProcessGeomCreation(); 1090 ProcessGeomCreation();
1091 1091
1092 if (IsPhysical) 1092 if (IsPhysical)
1093 SetBody(Mass); 1093 SetBody(Mass);
1094 else 1094 else
1095 SetBody(0); 1095 SetBody(0);
1096 1096
1097 m_taintsize = _size; 1097 m_taintsize = _size;
1098 1098
1099 } 1099 }
@@ -1136,7 +1136,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1136 //prim_geom = IntPtr.Zero; 1136 //prim_geom = IntPtr.Zero;
1137 m_log.Error("[PHYSICS]: PrimGeom dead"); 1137 m_log.Error("[PHYSICS]: PrimGeom dead");
1138 } 1138 }
1139 1139
1140 // we don't need to do space calculation because the client sends a position update also. 1140 // we don't need to do space calculation because the client sends a position update also.
1141 if (_size.X <= 0) _size.X = 0.01f; 1141 if (_size.X <= 0) _size.X = 0.01f;
1142 if (_size.Y <= 0) _size.Y = 0.01f; 1142 if (_size.Y <= 0) _size.Y = 0.01f;
@@ -1153,8 +1153,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1153 tempTransform1.Dispose(); 1153 tempTransform1.Dispose();
1154 tempTransform1 = new btTransform(tempOrientation1, tempPosition1); 1154 tempTransform1 = new btTransform(tempOrientation1, tempPosition1);
1155 1155
1156 1156
1157 1157
1158 1158
1159 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); 1159 //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z);
1160 if (IsPhysical) 1160 if (IsPhysical)
@@ -1162,7 +1162,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1162 SetBody(Mass); 1162 SetBody(Mass);
1163 // Re creates body on size. 1163 // Re creates body on size.
1164 // EnableBody also does setMass() 1164 // EnableBody also does setMass()
1165 1165
1166 } 1166 }
1167 else 1167 else
1168 { 1168 {
@@ -1179,7 +1179,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1179 } 1179 }
1180 } 1180 }
1181 resetCollisionAccounting(); 1181 resetCollisionAccounting();
1182 1182
1183 m_taintshape = false; 1183 m_taintshape = false;
1184 } 1184 }
1185 1185
@@ -1291,7 +1291,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1291 { 1291 {
1292 Body.setCollisionFlags((int)ContactFlags.CF_NO_CONTACT_RESPONSE); 1292 Body.setCollisionFlags((int)ContactFlags.CF_NO_CONTACT_RESPONSE);
1293 disableBodySoft(); 1293 disableBodySoft();
1294 1294
1295 } 1295 }
1296 else 1296 else
1297 { 1297 {
@@ -1299,7 +1299,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1299 enableBodySoft(); 1299 enableBodySoft();
1300 } 1300 }
1301 m_isSelected = m_taintselected; 1301 m_isSelected = m_taintselected;
1302 1302
1303 } 1303 }
1304 1304
1305 private void changevelocity(float timestep) 1305 private void changevelocity(float timestep)
@@ -1368,7 +1368,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1368 _parent = m_taintparent; 1368 _parent = m_taintparent;
1369 1369
1370 m_taintPhysics = m_isphysical; 1370 m_taintPhysics = m_isphysical;
1371 1371
1372 } 1372 }
1373 1373
1374 private void changefloatonwater(float timestep) 1374 private void changefloatonwater(float timestep)
@@ -1627,7 +1627,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1627 { 1627 {
1628 if (m_zeroPosition == null) 1628 if (m_zeroPosition == null)
1629 m_zeroPosition = new PhysicsVector(0, 0, 0); 1629 m_zeroPosition = new PhysicsVector(0, 0, 0);
1630 m_zeroPosition.setValues(_position.X,_position.Y,_position.Z); 1630 m_zeroPosition.setValues(_position.X, _position.Y, _position.Z);
1631 return; 1631 return;
1632 } 1632 }
1633 } 1633 }
@@ -1981,7 +1981,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1981 //_mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical); 1981 //_mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical);
1982 _mesh = p_mesh; 1982 _mesh = p_mesh;
1983 setMesh(_parent_scene, _mesh); 1983 setMesh(_parent_scene, _mesh);
1984 1984
1985 } 1985 }
1986 else 1986 else
1987 { 1987 {
@@ -1994,15 +1994,15 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1994 //SetGeom to a Regular Sphere 1994 //SetGeom to a Regular Sphere
1995 if (tempSize1 == null) 1995 if (tempSize1 == null)
1996 tempSize1 = new btVector3(0, 0, 0); 1996 tempSize1 = new btVector3(0, 0, 0);
1997 tempSize1.setValue(_size.X * 0.5f,_size.Y * 0.5f, _size.Z * 0.5f); 1997 tempSize1.setValue(_size.X * 0.5f, _size.Y * 0.5f, _size.Z * 0.5f);
1998 SetCollisionShape(new btSphereShape(_size.X*0.5f)); 1998 SetCollisionShape(new btSphereShape(_size.X * 0.5f));
1999 } 1999 }
2000 else 2000 else
2001 { 2001 {
2002 // uses halfextents 2002 // uses halfextents
2003 if (tempSize1 == null) 2003 if (tempSize1 == null)
2004 tempSize1 = new btVector3(0, 0, 0); 2004 tempSize1 = new btVector3(0, 0, 0);
2005 tempSize1.setValue(_size.X*0.5f, _size.Y*0.5f, _size.Z*0.5f); 2005 tempSize1.setValue(_size.X * 0.5f, _size.Y * 0.5f, _size.Z * 0.5f);
2006 SetCollisionShape(new btBoxShape(tempSize1)); 2006 SetCollisionShape(new btBoxShape(tempSize1));
2007 } 2007 }
2008 } 2008 }
@@ -2052,14 +2052,24 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2052 } 2052 }
2053 } 2053 }
2054 2054
2055 //IMesh oldMesh = primMesh;
2056
2057 //primMesh = mesh;
2058
2059 //float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
2060 //int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
2061 ////Array.Reverse(indexList);
2062 //primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory
2063
2055 IMesh oldMesh = primMesh; 2064 IMesh oldMesh = primMesh;
2056 2065
2057 primMesh = mesh; 2066 primMesh = mesh;
2058 2067
2059 float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory 2068 float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
2060 int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage 2069 int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
2061 //Array.Reverse(indexList); 2070 //Array.Reverse(indexList);
2062 primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory 2071 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
2072
2063 2073
2064 int VertexCount = vertexList.GetLength(0) / 3; 2074 int VertexCount = vertexList.GetLength(0) / 3;
2065 int IndexCount = indexList.GetLength(0); 2075 int IndexCount = indexList.GetLength(0);
@@ -2068,17 +2078,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2068 btshapeArray.Dispose(); 2078 btshapeArray.Dispose();
2069 //Array.Reverse(indexList); 2079 //Array.Reverse(indexList);
2070 btshapeArray = new btTriangleIndexVertexArray(IndexCount / 3, indexList, (3 * sizeof(int)), 2080 btshapeArray = new btTriangleIndexVertexArray(IndexCount / 3, indexList, (3 * sizeof(int)),
2071 VertexCount, vertexList, 3*sizeof (float)); 2081 VertexCount, vertexList, 3 * sizeof(float));
2072 SetCollisionShape(new btGImpactMeshShape(btshapeArray)); 2082 SetCollisionShape(new btGImpactMeshShape(btshapeArray));
2073 //((btGImpactMeshShape) prim_geom).updateBound(); 2083 //((btGImpactMeshShape) prim_geom).updateBound();
2074 ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1,1, 1)); 2084 ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1, 1, 1));
2075 ((btGImpactMeshShape)prim_geom).updateBound(); 2085 ((btGImpactMeshShape)prim_geom).updateBound();
2076 _parent_scene.SetUsingGImpact(); 2086 _parent_scene.SetUsingGImpact();
2077 if (oldMesh != null) 2087 //if (oldMesh != null)
2078 { 2088 //{
2079 oldMesh.releasePinned(); 2089 // oldMesh.releasePinned();
2080 oldMesh = null; 2090 // oldMesh = null;
2081 } 2091 //}
2082 2092
2083 } 2093 }
2084 2094
@@ -2102,7 +2112,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2102 } 2112 }
2103 */ 2113 */
2104 prim_geom = shape; 2114 prim_geom = shape;
2105 2115
2106 //Body.set 2116 //Body.set
2107 } 2117 }
2108 2118
@@ -2143,8 +2153,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2143 2153
2144 if (prim_geom is btGImpactMeshShape) 2154 if (prim_geom is btGImpactMeshShape)
2145 { 2155 {
2146 ((btGImpactMeshShape) prim_geom).setLocalScaling(new btVector3(1, 1, 1)); 2156 ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1, 1, 1));
2147 ((btGImpactMeshShape) prim_geom).updateBound(); 2157 ((btGImpactMeshShape)prim_geom).updateBound();
2148 } 2158 }
2149 //Body.setCollisionFlags(Body.getCollisionFlags() | (int)ContactFlags.CF_CUSTOM_MATERIAL_CALLBACK); 2159 //Body.setCollisionFlags(Body.getCollisionFlags() | (int)ContactFlags.CF_CUSTOM_MATERIAL_CALLBACK);
2150 //Body.setUserPointer((IntPtr) (int)m_localID); 2160 //Body.setUserPointer((IntPtr) (int)m_localID);
@@ -2159,7 +2169,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2159 { 2169 {
2160 if (chld == null) 2170 if (chld == null)
2161 continue; 2171 continue;
2162 2172
2163 // if (chld.NeedsMeshing()) 2173 // if (chld.NeedsMeshing())
2164 // hasTrimesh = true; 2174 // hasTrimesh = true;
2165 } 2175 }
@@ -2167,40 +2177,40 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2167 2177
2168 //if (hasTrimesh) 2178 //if (hasTrimesh)
2169 //{ 2179 //{
2170 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); 2180 ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity);
2171 // createmesh returns null when it doesn't mesh. 2181 // createmesh returns null when it doesn't mesh.
2172
2173 /*
2174 if (_mesh is Mesh)
2175 {
2176 }
2177 else
2178 {
2179 m_log.Warn("[PHYSICS]: Can't link a OpenSim.Region.Physics.Meshing.Mesh object");
2180 return;
2181 }
2182 */
2183 2182
2184 2183 /*
2185 2184 if (_mesh is Mesh)
2186 foreach (BulletDotNETPrim chld in childrenPrim) 2185 {
2187 { 2186 }
2188 if (chld == null) 2187 else
2189 continue; 2188 {
2190 PhysicsVector offset = chld.Position - Position; 2189 m_log.Warn("[PHYSICS]: Can't link a OpenSim.Region.Physics.Meshing.Mesh object");
2191 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); 2190 return;
2192 pos *= Quaternion.Inverse(Orientation); 2191 }
2193 //pos *= Orientation; 2192 */
2194 offset.setValues(pos.X, pos.Y, pos.Z);
2195 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
2196
2197 _mesh.Append(chld._mesh);
2198
2199 2193
2200 } 2194
2201 setMesh(_parent_scene, _mesh); 2195
2202 2196 foreach (BulletDotNETPrim chld in childrenPrim)
2203 //} 2197 {
2198 if (chld == null)
2199 continue;
2200 PhysicsVector offset = chld.Position - Position;
2201 Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z);
2202 pos *= Quaternion.Inverse(Orientation);
2203 //pos *= Orientation;
2204 offset.setValues(pos.X, pos.Y, pos.Z);
2205 chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation);
2206
2207 _mesh.Append(chld._mesh);
2208
2209
2210 }
2211 setMesh(_parent_scene, _mesh);
2212
2213 //}
2204 2214
2205 if (tempMotionState1 != null && tempMotionState1.Handle != IntPtr.Zero) 2215 if (tempMotionState1 != null && tempMotionState1.Handle != IntPtr.Zero)
2206 tempMotionState1.Dispose(); 2216 tempMotionState1.Dispose();
@@ -2238,7 +2248,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2238 ((btGImpactMeshShape)prim_geom).updateBound(); 2248 ((btGImpactMeshShape)prim_geom).updateBound();
2239 } 2249 }
2240 _parent_scene.AddPrimToScene(this); 2250 _parent_scene.AddPrimToScene(this);
2241 2251
2242 } 2252 }
2243 2253
2244 if (IsPhysical) 2254 if (IsPhysical)
@@ -2252,7 +2262,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2252 if (Body.Handle != IntPtr.Zero) 2262 if (Body.Handle != IntPtr.Zero)
2253 { 2263 {
2254 DisableAxisMotor(); 2264 DisableAxisMotor();
2255 _parent_scene.removeFromWorld(this,Body); 2265 _parent_scene.removeFromWorld(this, Body);
2256 Body.Dispose(); 2266 Body.Dispose();
2257 } 2267 }
2258 Body = null; 2268 Body = null;
@@ -2305,7 +2315,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2305 return; 2315 return;
2306 2316
2307 2317
2308 2318
2309 lock (childrenPrim) 2319 lock (childrenPrim)
2310 { 2320 {
2311 if (!childrenPrim.Contains(prm)) 2321 if (!childrenPrim.Contains(prm))
@@ -2313,8 +2323,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2313 childrenPrim.Add(prm); 2323 childrenPrim.Add(prm);
2314 } 2324 }
2315 } 2325 }
2316 2326
2317 2327
2318 } 2328 }
2319 2329
2320 public void disableBody() 2330 public void disableBody()
@@ -2386,7 +2396,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2386 { 2396 {
2387 Body.clearForces(); 2397 Body.clearForces();
2388 Body.forceActivationState(0); 2398 Body.forceActivationState(0);
2389 2399
2390 } 2400 }
2391 2401
2392 } 2402 }
@@ -2400,7 +2410,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2400 Body.clearForces(); 2410 Body.clearForces();
2401 Body.forceActivationState(4); 2411 Body.forceActivationState(4);
2402 forceenable = true; 2412 forceenable = true;
2403 2413
2404 } 2414 }
2405 m_disabled = false; 2415 m_disabled = false;
2406 } 2416 }
@@ -2415,7 +2425,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2415 SetBody(Mass); 2425 SetBody(Mass);
2416 else 2426 else
2417 SetBody(0); 2427 SetBody(0);
2418 2428
2419 // TODO: Set Collision Category Bits and Flags 2429 // TODO: Set Collision Category Bits and Flags
2420 // TODO: Set Auto Disable data 2430 // TODO: Set Auto Disable data
2421 2431
@@ -2587,10 +2597,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2587 _velocity.Y = tempLinearVelocity1.getY(); 2597 _velocity.Y = tempLinearVelocity1.getY();
2588 _velocity.Z = tempLinearVelocity1.getZ(); 2598 _velocity.Z = tempLinearVelocity1.getZ();
2589 2599
2590 _acceleration = ((_velocity - m_lastVelocity)/0.1f); 2600 _acceleration = ((_velocity - m_lastVelocity) / 0.1f);
2591 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X/0.1f, 2601 _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f,
2592 _velocity.Y - m_lastVelocity.Y/0.1f, 2602 _velocity.Y - m_lastVelocity.Y / 0.1f,
2593 _velocity.Z - m_lastVelocity.Z/0.1f); 2603 _velocity.Z - m_lastVelocity.Z / 0.1f);
2594 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); 2604 //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString());
2595 2605
2596 if (_velocity.IsIdentical(pv, 0.5f)) 2606 if (_velocity.IsIdentical(pv, 0.5f))
@@ -2669,7 +2679,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2669 if (AxisLockAngleHigh != null && AxisLockAngleHigh.Handle != IntPtr.Zero) 2679 if (AxisLockAngleHigh != null && AxisLockAngleHigh.Handle != IntPtr.Zero)
2670 AxisLockAngleHigh.Dispose(); 2680 AxisLockAngleHigh.Dispose();
2671 2681
2672 2682
2673 2683
2674 m_aMotor = new btGeneric6DofConstraint(Body, _parent_scene.TerrainBody, _parent_scene.TransZero, 2684 m_aMotor = new btGeneric6DofConstraint(Body, _parent_scene.TerrainBody, _parent_scene.TransZero,
2675 _parent_scene.TransZero, false); 2685 _parent_scene.TransZero, false);
@@ -2683,7 +2693,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2683 m_aMotor.setLinearUpperLimit(AxisLockLinearHigh); 2693 m_aMotor.setLinearUpperLimit(AxisLockLinearHigh);
2684 _parent_scene.getBulletWorld().addConstraint((btTypedConstraint)m_aMotor); 2694 _parent_scene.getBulletWorld().addConstraint((btTypedConstraint)m_aMotor);
2685 //m_aMotor. 2695 //m_aMotor.
2686 2696
2687 2697
2688 } 2698 }
2689 internal void DisableAxisMotor() 2699 internal void DisableAxisMotor()
@@ -2698,4 +2708,4 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2698 2708
2699 } 2709 }
2700} 2710}
2701 2711
diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs
index ceafaad..7567556 100644
--- a/OpenSim/Region/Physics/Meshing/Mesh.cs
+++ b/OpenSim/Region/Physics/Meshing/Mesh.cs
@@ -40,7 +40,6 @@ namespace OpenSim.Region.Physics.Meshing
40 private List<Triangle> triangles; 40 private List<Triangle> triangles;
41 GCHandle pinnedVirtexes; 41 GCHandle pinnedVirtexes;
42 GCHandle pinnedIndex; 42 GCHandle pinnedIndex;
43 public PrimMesh primMesh = null;
44 public float[] normals; 43 public float[] normals;
45 44
46 public Mesh() 45 public Mesh()
@@ -63,6 +62,8 @@ namespace OpenSim.Region.Physics.Meshing
63 62
64 public void Add(Triangle triangle) 63 public void Add(Triangle triangle)
65 { 64 {
65 if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated)
66 throw new NotSupportedException("Attempt to Add to a pinned Mesh");
66 // If a vertex of the triangle is not yet in the vertices list, 67 // If a vertex of the triangle is not yet in the vertices list,
67 // add it and set its index to the current index count 68 // add it and set its index to the current index count
68 if (!vertices.ContainsKey(triangle.v1)) 69 if (!vertices.ContainsKey(triangle.v1))
@@ -148,40 +149,22 @@ namespace OpenSim.Region.Physics.Meshing
148 149
149 public float[] getVertexListAsFloatLocked() 150 public float[] getVertexListAsFloatLocked()
150 { 151 {
152 if( pinnedVirtexes.IsAllocated )
153 return (float[])(pinnedVirtexes.Target);
151 float[] result; 154 float[] result;
152 155
153 if (primMesh == null) 156 //m_log.WarnFormat("vertices.Count = {0}", vertices.Count);
157 result = new float[vertices.Count * 3];
158 foreach (KeyValuePair<Vertex, int> kvp in vertices)
154 { 159 {
155 //m_log.WarnFormat("vertices.Count = {0}", vertices.Count); 160 Vertex v = kvp.Key;
156 result = new float[vertices.Count * 3]; 161 int i = kvp.Value;
157 foreach (KeyValuePair<Vertex, int> kvp in vertices) 162 //m_log.WarnFormat("kvp.Value = {0}", i);
158 { 163 result[3 * i + 0] = v.X;
159 Vertex v = kvp.Key; 164 result[3 * i + 1] = v.Y;
160 int i = kvp.Value; 165 result[3 * i + 2] = v.Z;
161 //m_log.WarnFormat("kvp.Value = {0}", i);
162 result[3 * i + 0] = v.X;
163 result[3 * i + 1] = v.Y;
164 result[3 * i + 2] = v.Z;
165 }
166 pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
167 }
168 else
169 {
170 int count = primMesh.coords.Count;
171 result = new float[count * 3];
172 for (int i = 0; i < count; i++)
173 {
174 Coord c = primMesh.coords[i];
175 {
176 int resultIndex = 3 * i;
177 result[resultIndex] = c.X;
178 result[resultIndex + 1] = c.Y;
179 result[resultIndex + 2] = c.Z;
180 }
181
182 }
183 pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
184 } 166 }
167 pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
185 return result; 168 return result;
186 } 169 }
187 170
@@ -189,33 +172,13 @@ namespace OpenSim.Region.Physics.Meshing
189 { 172 {
190 int[] result; 173 int[] result;
191 174
192 if (primMesh == null) 175 result = new int[triangles.Count * 3];
193 { 176 for (int i = 0; i < triangles.Count; i++)
194 result = new int[triangles.Count * 3];
195 for (int i = 0; i < triangles.Count; i++)
196 {
197 Triangle t = triangles[i];
198 result[3 * i + 0] = vertices[t.v1];
199 result[3 * i + 1] = vertices[t.v2];
200 result[3 * i + 2] = vertices[t.v3];
201 }
202 }
203 else
204 { 177 {
205 int numFaces = primMesh.faces.Count; 178 Triangle t = triangles[i];
206 result = new int[numFaces * 3]; 179 result[3 * i + 0] = vertices[t.v1];
207 for (int i = 0; i < numFaces; i++) 180 result[3 * i + 1] = vertices[t.v2];
208 { 181 result[3 * i + 2] = vertices[t.v3];
209 Face f = primMesh.faces[i];
210// Coord c1 = primMesh.coords[f.v1];
211// Coord c2 = primMesh.coords[f.v2];
212// Coord c3 = primMesh.coords[f.v3];
213
214 int resultIndex = i * 3;
215 result[resultIndex] = f.v1;
216 result[resultIndex + 1] = f.v2;
217 result[resultIndex + 2] = f.v3;
218 }
219 } 182 }
220 return result; 183 return result;
221 } 184 }
@@ -226,6 +189,9 @@ namespace OpenSim.Region.Physics.Meshing
226 /// <returns></returns> 189 /// <returns></returns>
227 public int[] getIndexListAsIntLocked() 190 public int[] getIndexListAsIntLocked()
228 { 191 {
192 if (pinnedIndex.IsAllocated)
193 return (int[])(pinnedIndex.Target);
194
229 int[] result = getIndexListAsInt(); 195 int[] result = getIndexListAsInt();
230 pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); 196 pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned);
231 197
@@ -245,11 +211,13 @@ namespace OpenSim.Region.Physics.Meshing
245 { 211 {
246 triangles = null; 212 triangles = null;
247 vertices = null; 213 vertices = null;
248 primMesh = null;
249 } 214 }
250 215
251 public void Append(IMesh newMesh) 216 public void Append(IMesh newMesh)
252 { 217 {
218 if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated)
219 throw new NotSupportedException("Attempt to Append to a pinned Mesh");
220
253 if (!(newMesh is Mesh)) 221 if (!(newMesh is Mesh))
254 return; 222 return;
255 223
@@ -260,6 +228,9 @@ namespace OpenSim.Region.Physics.Meshing
260 // Do a linear transformation of mesh. 228 // Do a linear transformation of mesh.
261 public void TransformLinear(float[,] matrix, float[] offset) 229 public void TransformLinear(float[,] matrix, float[] offset)
262 { 230 {
231 if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated)
232 throw new NotSupportedException("Attempt to TransformLinear a pinned Mesh");
233
263 foreach (Vertex v in vertices.Keys) 234 foreach (Vertex v in vertices.Keys)
264 { 235 {
265 if (v == null) 236 if (v == null)
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index f469ad6..0873035 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -76,6 +76,7 @@ namespace OpenSim.Region.Physics.Meshing
76 76
77 private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh 77 private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh
78 78
79 private Dictionary<ulong, Mesh> m_uniqueMeshes = new Dictionary<ulong, Mesh>();
79 80
80 /// <summary> 81 /// <summary>
81 /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may 82 /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may
@@ -170,9 +171,62 @@ namespace OpenSim.Region.Physics.Meshing
170 171
171 } 172 }
172 173
173 public Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) 174 private ulong GetMeshKey( PrimitiveBaseShape pbs, PhysicsVector size, float lod )
175 {
176 ulong hash = 5381;
177
178 hash = djb2(hash, pbs.PathCurve);
179 hash = djb2(hash, (byte)((byte)pbs.HollowShape | (byte)pbs.ProfileShape));
180 hash = djb2(hash, pbs.PathBegin);
181 hash = djb2(hash, pbs.PathEnd);
182 hash = djb2(hash, pbs.PathScaleX);
183 hash = djb2(hash, pbs.PathScaleY);
184 hash = djb2(hash, pbs.PathShearX);
185 hash = djb2(hash, pbs.PathShearY);
186 hash = djb2(hash, (byte)pbs.PathTwist);
187 hash = djb2(hash, (byte)pbs.PathTwistBegin);
188 hash = djb2(hash, (byte)pbs.PathRadiusOffset);
189 hash = djb2(hash, (byte)pbs.PathTaperX);
190 hash = djb2(hash, (byte)pbs.PathTaperY);
191 hash = djb2(hash, pbs.PathRevolutions);
192 hash = djb2(hash, (byte)pbs.PathSkew);
193 hash = djb2(hash, pbs.ProfileBegin);
194 hash = djb2(hash, pbs.ProfileEnd);
195 hash = djb2(hash, pbs.ProfileHollow);
196
197 // TODO: Separate scale out from the primitive shape data (after
198 // scaling is supported at the physics engine level)
199 byte[] scaleBytes = size.GetBytes();
200 for (int i = 0; i < scaleBytes.Length; i++)
201 hash = djb2(hash, scaleBytes[i]);
202
203 // Include LOD in hash, accounting for endianness
204 byte[] lodBytes = new byte[4];
205 Buffer.BlockCopy(BitConverter.GetBytes(lod), 0, lodBytes, 0, 4);
206 if (!BitConverter.IsLittleEndian)
207 {
208 Array.Reverse(lodBytes, 0, 4);
209 }
210 for (int i = 0; i < lodBytes.Length; i++)
211 hash = djb2(hash, lodBytes[i]);
212
213 return hash;
214 }
215
216 private ulong djb2(ulong hash, byte c)
217 {
218 return ((hash << 5) + hash) + (ulong)c;
219 }
220
221 private ulong djb2(ulong hash, ushort c)
222 {
223 hash = ((hash << 5) + hash) + (ulong)((byte)c);
224 return ((hash << 5) + hash) + (ulong)(c >> 8);
225 }
226
227
228 private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod)
174 { 229 {
175 Mesh mesh = new Mesh();
176 PrimMesh primMesh; 230 PrimMesh primMesh;
177 PrimMesher.SculptMesh sculptMesh; 231 PrimMesher.SculptMesh sculptMesh;
178 232
@@ -385,8 +439,6 @@ namespace OpenSim.Region.Physics.Meshing
385 439
386 coords = primMesh.coords; 440 coords = primMesh.coords;
387 faces = primMesh.faces; 441 faces = primMesh.faces;
388
389
390 } 442 }
391 443
392 444
@@ -401,13 +453,13 @@ namespace OpenSim.Region.Physics.Meshing
401 vertices.Add(new Vertex(c.X, c.Y, c.Z)); 453 vertices.Add(new Vertex(c.X, c.Y, c.Z));
402 } 454 }
403 455
456 Mesh mesh = new Mesh();
404 // Add the corresponding triangles to the mesh 457 // Add the corresponding triangles to the mesh
405 for (int i = 0; i < numFaces; i++) 458 for (int i = 0; i < numFaces; i++)
406 { 459 {
407 Face f = faces[i]; 460 Face f = faces[i];
408 mesh.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3])); 461 mesh.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3]));
409 } 462 }
410
411 return mesh; 463 return mesh;
412 } 464 }
413 465
@@ -418,7 +470,12 @@ namespace OpenSim.Region.Physics.Meshing
418 470
419 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) 471 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical)
420 { 472 {
473 // If this mesh has been created already, return it instead of creating another copy
474 // For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory
475 ulong key = GetMeshKey(primShape, size, lod);
421 Mesh mesh = null; 476 Mesh mesh = null;
477 if (m_uniqueMeshes.TryGetValue(key, out mesh))
478 return mesh;
422 479
423 if (size.X < 0.01f) size.X = 0.01f; 480 if (size.X < 0.01f) size.X = 0.01f;
424 if (size.Y < 0.01f) size.Y = 0.01f; 481 if (size.Y < 0.01f) size.Y = 0.01f;
@@ -441,7 +498,7 @@ namespace OpenSim.Region.Physics.Meshing
441 // trim the vertex and triangle lists to free up memory 498 // trim the vertex and triangle lists to free up memory
442 mesh.TrimExcess(); 499 mesh.TrimExcess();
443 } 500 }
444 501 m_uniqueMeshes.Add(key, mesh);
445 return mesh; 502 return mesh;
446 } 503 }
447 } 504 }
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 673ae39..032b5df 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -82,7 +82,6 @@ namespace OpenSim.Region.Physics.OdePlugin
82 82
83 // private float m_tensor = 5f; 83 // private float m_tensor = 5f;
84 private int body_autodisable_frames = 20; 84 private int body_autodisable_frames = 20;
85 private IMesh primMesh = null;
86 85
87 86
88 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom 87 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
@@ -814,14 +813,10 @@ namespace OpenSim.Region.Physics.OdePlugin
814 } 813 }
815 } 814 }
816 815
817 IMesh oldMesh = primMesh; 816 float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
817 int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
818 818
819 primMesh = mesh; 819 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
820
821 float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
822 int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
823
824 primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory
825 820
826 int VertexCount = vertexList.GetLength(0)/3; 821 int VertexCount = vertexList.GetLength(0)/3;
827 int IndexCount = indexList.GetLength(0); 822 int IndexCount = indexList.GetLength(0);
@@ -847,12 +842,6 @@ namespace OpenSim.Region.Physics.OdePlugin
847 return; 842 return;
848 } 843 }
849 844
850 if (oldMesh != null)
851 {
852 oldMesh.releasePinned();
853 oldMesh = null;
854 }
855
856 // if (IsPhysical && Body == (IntPtr) 0) 845 // if (IsPhysical && Body == (IntPtr) 0)
857 // { 846 // {
858 // Recreate the body 847 // Recreate the body
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 6c2b3ed..656fcf5 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -258,6 +258,8 @@ namespace OpenSim.Server.Base
258 258
259 public static Dictionary<string, object> ParseXmlResponse(string data) 259 public static Dictionary<string, object> ParseXmlResponse(string data)
260 { 260 {
261 //m_log.DebugFormat("[XXX]: received xml string: {0}", data);
262
261 Dictionary<string, object> ret = new Dictionary<string, object>(); 263 Dictionary<string, object> ret = new Dictionary<string, object>();
262 264
263 XmlDocument doc = new XmlDocument(); 265 XmlDocument doc = new XmlDocument();
@@ -284,7 +286,7 @@ namespace OpenSim.Server.Base
284 286
285 foreach (XmlNode part in partL) 287 foreach (XmlNode part in partL)
286 { 288 {
287 XmlNode type = part.Attributes.GetNamedItem("Type"); 289 XmlNode type = part.Attributes.GetNamedItem("type");
288 if (type == null || type.Value != "List") 290 if (type == null || type.Value != "List")
289 { 291 {
290 ret[part.Name] = part.InnerText; 292 ret[part.Name] = part.InnerText;
diff --git a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
index 7bf2e66..ebdf489 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Server.Handlers.Grid
45 if (serverConfig == null) 45 if (serverConfig == null)
46 throw new Exception("No section 'Server' in config file"); 46 throw new Exception("No section 'Server' in config file");
47 47
48 string gridService = serverConfig.GetString("GridServiceModule", 48 string gridService = serverConfig.GetString("LocalServiceModule",
49 String.Empty); 49 String.Empty);
50 50
51 if (gridService == String.Empty) 51 if (gridService == String.Empty)
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
index e72c2eb..711639f 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -63,7 +63,10 @@ namespace OpenSim.Server.Handlers.Grid
63 StreamReader sr = new StreamReader(requestData); 63 StreamReader sr = new StreamReader(requestData);
64 string body = sr.ReadToEnd(); 64 string body = sr.ReadToEnd();
65 sr.Close(); 65 sr.Close();
66 66 body = body.Trim();
67
68 //m_log.DebugFormat("[XXX]: query String: {0}", body);
69
67 Dictionary<string, string> request = 70 Dictionary<string, string> request =
68 ServerUtils.ParseQueryString(body); 71 ServerUtils.ParseQueryString(body);
69 72
@@ -98,11 +101,11 @@ namespace OpenSim.Server.Handlers.Grid
98 case "get_region_range": 101 case "get_region_range":
99 return GetRegionRange(request); 102 return GetRegionRange(request);
100 103
101 default:
102 m_log.DebugFormat("[GRID HANDLER]: unknown method request {0}", method);
103 return FailureResult();
104 } 104 }
105 105
106 m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method);
107 return FailureResult();
108
106 } 109 }
107 110
108 #region Method-specific handlers 111 #region Method-specific handlers
@@ -155,22 +158,29 @@ namespace OpenSim.Server.Handlers.Grid
155 158
156 UUID regionID = UUID.Zero; 159 UUID regionID = UUID.Zero;
157 if (request["REGIONID"] != null) 160 if (request["REGIONID"] != null)
158 UUID.TryParse(request["REGIONID"], out scopeID); 161 UUID.TryParse(request["REGIONID"], out regionID);
159 else 162 else
160 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours"); 163 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
161 164
162 List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID); 165 List<GridRegion> rinfos = m_GridService.GetNeighbours(scopeID, regionID);
166 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
163 167
164 Dictionary<string, object> result = new Dictionary<string, object>(); 168 Dictionary<string, object> result = new Dictionary<string, object>();
165 int i = 0; 169 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
166 foreach (GridRegion rinfo in rinfos) 170 result["result"] = "null";
171 else
167 { 172 {
168 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs(); 173 int i = 0;
169 result["region" + i] = rinfoDict; 174 foreach (GridRegion rinfo in rinfos)
170 i++; 175 {
176 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
177 result["region" + i] = rinfoDict;
178 i++;
179 }
171 } 180 }
172 181
173 string xmlString = ServerUtils.BuildXmlResponse(result); 182 string xmlString = ServerUtils.BuildXmlResponse(result);
183 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
174 UTF8Encoding encoding = new UTF8Encoding(); 184 UTF8Encoding encoding = new UTF8Encoding();
175 return encoding.GetBytes(xmlString); 185 return encoding.GetBytes(xmlString);
176 186
@@ -178,32 +188,185 @@ namespace OpenSim.Server.Handlers.Grid
178 188
179 byte[] GetRegionByUUID(Dictionary<string, string> request) 189 byte[] GetRegionByUUID(Dictionary<string, string> request)
180 { 190 {
181 // TODO 191 UUID scopeID = UUID.Zero;
182 return new byte[0]; 192 if (request["SCOPEID"] != null)
193 UUID.TryParse(request["SCOPEID"], out scopeID);
194 else
195 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get neighbours");
196
197 UUID regionID = UUID.Zero;
198 if (request["REGIONID"] != null)
199 UUID.TryParse(request["REGIONID"], out regionID);
200 else
201 m_log.WarnFormat("[GRID HANDLER]: no regionID in request to get neighbours");
202
203 GridRegion rinfo = m_GridService.GetRegionByUUID(scopeID, regionID);
204 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
205
206 Dictionary<string, object> result = new Dictionary<string, object>();
207 if (rinfo == null)
208 result["result"] = "null";
209 else
210 result["result"] = rinfo.ToKeyValuePairs();
211
212 string xmlString = ServerUtils.BuildXmlResponse(result);
213 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
214 UTF8Encoding encoding = new UTF8Encoding();
215 return encoding.GetBytes(xmlString);
183 } 216 }
184 217
185 byte[] GetRegionByPosition(Dictionary<string, string> request) 218 byte[] GetRegionByPosition(Dictionary<string, string> request)
186 { 219 {
187 // TODO 220 UUID scopeID = UUID.Zero;
188 return new byte[0]; 221 if (request["SCOPEID"] != null)
222 UUID.TryParse(request["SCOPEID"], out scopeID);
223 else
224 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by position");
225
226 int x = 0, y = 0;
227 if (request["X"] != null)
228 Int32.TryParse(request["X"], out x);
229 else
230 m_log.WarnFormat("[GRID HANDLER]: no X in request to get region by position");
231 if (request["Y"] != null)
232 Int32.TryParse(request["Y"], out y);
233 else
234 m_log.WarnFormat("[GRID HANDLER]: no Y in request to get region by position");
235
236 GridRegion rinfo = m_GridService.GetRegionByPosition(scopeID, x, y);
237 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
238
239 Dictionary<string, object> result = new Dictionary<string, object>();
240 if (rinfo == null)
241 result["result"] = "null";
242 else
243 result["result"] = rinfo.ToKeyValuePairs();
244
245 string xmlString = ServerUtils.BuildXmlResponse(result);
246 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
247 UTF8Encoding encoding = new UTF8Encoding();
248 return encoding.GetBytes(xmlString);
189 } 249 }
190 250
191 byte[] GetRegionByName(Dictionary<string, string> request) 251 byte[] GetRegionByName(Dictionary<string, string> request)
192 { 252 {
193 // TODO 253 UUID scopeID = UUID.Zero;
194 return new byte[0]; 254 if (request["SCOPEID"] != null)
255 UUID.TryParse(request["SCOPEID"], out scopeID);
256 else
257 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region by name");
258
259 string regionName = string.Empty;
260 if (request["NAME"] != null)
261 regionName = request["NAME"];
262 else
263 m_log.WarnFormat("[GRID HANDLER]: no name in request to get region by name");
264
265 GridRegion rinfo = m_GridService.GetRegionByName(scopeID, regionName);
266 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
267
268 Dictionary<string, object> result = new Dictionary<string, object>();
269 if (rinfo == null)
270 result["result"] = "null";
271 else
272 result["result"] = rinfo.ToKeyValuePairs();
273
274 string xmlString = ServerUtils.BuildXmlResponse(result);
275 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
276 UTF8Encoding encoding = new UTF8Encoding();
277 return encoding.GetBytes(xmlString);
195 } 278 }
196 279
197 byte[] GetRegionsByName(Dictionary<string, string> request) 280 byte[] GetRegionsByName(Dictionary<string, string> request)
198 { 281 {
199 // TODO 282 UUID scopeID = UUID.Zero;
200 return new byte[0]; 283 if (request["SCOPEID"] != null)
284 UUID.TryParse(request["SCOPEID"], out scopeID);
285 else
286 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get regions by name");
287
288 string regionName = string.Empty;
289 if (request["NAME"] != null)
290 regionName = request["NAME"];
291 else
292 m_log.WarnFormat("[GRID HANDLER]: no NAME in request to get regions by name");
293
294 int max = 0;
295 if (request["MAX"] != null)
296 Int32.TryParse(request["MAX"], out max);
297 else
298 m_log.WarnFormat("[GRID HANDLER]: no MAX in request to get regions by name");
299
300 List<GridRegion> rinfos = m_GridService.GetRegionsByName(scopeID, regionName, max);
301 //m_log.DebugFormat("[GRID HANDLER]: neighbours for region {0}: {1}", regionID, rinfos.Count);
302
303 Dictionary<string, object> result = new Dictionary<string, object>();
304 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
305 result["result"] = "null";
306 else
307 {
308 int i = 0;
309 foreach (GridRegion rinfo in rinfos)
310 {
311 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
312 result["region" + i] = rinfoDict;
313 i++;
314 }
315 }
316
317 string xmlString = ServerUtils.BuildXmlResponse(result);
318 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
319 UTF8Encoding encoding = new UTF8Encoding();
320 return encoding.GetBytes(xmlString);
201 } 321 }
202 322
203 byte[] GetRegionRange(Dictionary<string, string> request) 323 byte[] GetRegionRange(Dictionary<string, string> request)
204 { 324 {
205 // TODO 325 //m_log.DebugFormat("[GRID HANDLER]: GetRegionRange");
206 return new byte[0]; 326 UUID scopeID = UUID.Zero;
327 if (request.ContainsKey("SCOPEID"))
328 UUID.TryParse(request["SCOPEID"], out scopeID);
329 else
330 m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to get region range");
331
332 int xmin = 0, xmax = 0, ymin = 0, ymax = 0;
333 if (request.ContainsKey("XMIN"))
334 Int32.TryParse(request["XMIN"], out xmin);
335 else
336 m_log.WarnFormat("[GRID HANDLER]: no XMIN in request to get region range");
337 if (request.ContainsKey("XMAX"))
338 Int32.TryParse(request["XMAX"], out xmax);
339 else
340 m_log.WarnFormat("[GRID HANDLER]: no XMAX in request to get region range");
341 if (request.ContainsKey("YMIN"))
342 Int32.TryParse(request["YMIN"], out ymin);
343 else
344 m_log.WarnFormat("[GRID HANDLER]: no YMIN in request to get region range");
345 if (request.ContainsKey("YMAX"))
346 Int32.TryParse(request["YMAX"], out ymax);
347 else
348 m_log.WarnFormat("[GRID HANDLER]: no YMAX in request to get region range");
349
350
351 List<GridRegion> rinfos = m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax);
352
353 Dictionary<string, object> result = new Dictionary<string, object>();
354 if ((rinfos == null) || ((rinfos != null) && (rinfos.Count == 0)))
355 result["result"] = "null";
356 else
357 {
358 int i = 0;
359 foreach (GridRegion rinfo in rinfos)
360 {
361 Dictionary<string, object> rinfoDict = rinfo.ToKeyValuePairs();
362 result["region" + i] = rinfoDict;
363 i++;
364 }
365 }
366 string xmlString = ServerUtils.BuildXmlResponse(result);
367 //m_log.DebugFormat("[GRID HANDLER]: resp string: {0}", xmlString);
368 UTF8Encoding encoding = new UTF8Encoding();
369 return encoding.GetBytes(xmlString);
207 } 370 }
208 371
209 #endregion 372 #endregion
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
index 0a867db..748892a 100644
--- a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -97,14 +97,27 @@ namespace OpenSim.Services.Connectors
97 97
98 sendData["METHOD"] = "register"; 98 sendData["METHOD"] = "register";
99 99
100 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 100 string reqString = ServerUtils.BuildQueryString(sendData);
101 m_ServerURI + "/grid", 101 //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
102 ServerUtils.BuildQueryString(sendData)); 102 try
103 103 {
104 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 104 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
105 m_ServerURI + "/grid",
106 reqString);
107 if (reply != string.Empty)
108 {
109 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
105 110
106 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) 111 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
107 return true; 112 return true;
113 }
114 else
115 m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
116 }
117 catch (Exception e)
118 {
119 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
120 }
108 121
109 return false; 122 return false;
110 } 123 }
@@ -117,14 +130,26 @@ namespace OpenSim.Services.Connectors
117 130
118 sendData["METHOD"] = "deregister"; 131 sendData["METHOD"] = "deregister";
119 132
120 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 133 try
121 m_ServerURI + "/grid", 134 {
122 ServerUtils.BuildQueryString(sendData)); 135 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
136 m_ServerURI + "/grid",
137 ServerUtils.BuildQueryString(sendData));
123 138
124 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 139 if (reply != string.Empty)
140 {
141 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
125 142
126 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) 143 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
127 return true; 144 return true;
145 }
146 else
147 m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
148 }
149 catch (Exception e)
150 {
151 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
152 }
128 153
129 return false; 154 return false;
130 } 155 }
@@ -138,16 +163,28 @@ namespace OpenSim.Services.Connectors
138 163
139 sendData["METHOD"] = "get_neighbours"; 164 sendData["METHOD"] = "get_neighbours";
140 165
141 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 166 List<GridRegion> rinfos = new List<GridRegion>();
142 m_ServerURI + "/grid", 167
143 ServerUtils.BuildQueryString(sendData)); 168 string reqString = ServerUtils.BuildQueryString(sendData);
169 string reply = string.Empty;
170 try
171 {
172 reply = SynchronousRestFormsRequester.MakeRequest("POST",
173 m_ServerURI + "/grid",
174 reqString);
175 }
176 catch (Exception e)
177 {
178 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
179 return rinfos;
180 }
144 181
145 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 182 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
146 183
147 List<GridRegion> rinfos = new List<GridRegion>();
148 if (replyData != null) 184 if (replyData != null)
149 { 185 {
150 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 186 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
187 //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
151 foreach (object r in rinfosList) 188 foreach (object r in rinfosList)
152 { 189 {
153 if (r is Dictionary<string, object>) 190 if (r is Dictionary<string, object>)
@@ -156,8 +193,8 @@ namespace OpenSim.Services.Connectors
156 rinfos.Add(rinfo); 193 rinfos.Add(rinfo);
157 } 194 }
158 else 195 else
159 m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response", 196 m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}",
160 scopeID, regionID); 197 scopeID, regionID, r.GetType());
161 } 198 }
162 } 199 }
163 else 200 else
@@ -176,24 +213,39 @@ namespace OpenSim.Services.Connectors
176 213
177 sendData["METHOD"] = "get_region_by_uuid"; 214 sendData["METHOD"] = "get_region_by_uuid";
178 215
179 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 216 string reply = string.Empty;
180 m_ServerURI + "/grid", 217 try
181 ServerUtils.BuildQueryString(sendData)); 218 {
182 219 reply = SynchronousRestFormsRequester.MakeRequest("POST",
183 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 220 m_ServerURI + "/grid",
221 ServerUtils.BuildQueryString(sendData));
222 }
223 catch (Exception e)
224 {
225 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
226 return null;
227 }
184 228
185 GridRegion rinfo = null; 229 GridRegion rinfo = null;
186 if ((replyData != null) && (replyData["result"] != null)) 230
231 if (reply != string.Empty)
187 { 232 {
188 if (replyData["result"] is Dictionary<string, object>) 233 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
189 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); 234
235 if ((replyData != null) && (replyData["result"] != null))
236 {
237 if (replyData["result"] is Dictionary<string, object>)
238 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
239 //else
240 // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
241 // scopeID, regionID);
242 }
190 else 243 else
191 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received invalid response", 244 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
192 scopeID, regionID); 245 scopeID, regionID);
193 } 246 }
194 else 247 else
195 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response", 248 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply");
196 scopeID, regionID);
197 249
198 return rinfo; 250 return rinfo;
199 } 251 }
@@ -207,25 +259,38 @@ namespace OpenSim.Services.Connectors
207 sendData["Y"] = y.ToString(); 259 sendData["Y"] = y.ToString();
208 260
209 sendData["METHOD"] = "get_region_by_position"; 261 sendData["METHOD"] = "get_region_by_position";
210 262 string reply = string.Empty;
211 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 263 try
212 m_ServerURI + "/grid", 264 {
213 ServerUtils.BuildQueryString(sendData)); 265 reply = SynchronousRestFormsRequester.MakeRequest("POST",
214 266 m_ServerURI + "/grid",
215 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 267 ServerUtils.BuildQueryString(sendData));
268 }
269 catch (Exception e)
270 {
271 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
272 return null;
273 }
216 274
217 GridRegion rinfo = null; 275 GridRegion rinfo = null;
218 if ((replyData != null) && (replyData["result"] != null)) 276 if (reply != string.Empty)
219 { 277 {
220 if (replyData["result"] is Dictionary<string, object>) 278 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
221 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); 279
280 if ((replyData != null) && (replyData["result"] != null))
281 {
282 if (replyData["result"] is Dictionary<string, object>)
283 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
284 else
285 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response",
286 scopeID, x, y);
287 }
222 else 288 else
223 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response", 289 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
224 scopeID, x, y); 290 scopeID, x, y);
225 } 291 }
226 else 292 else
227 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response", 293 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
228 scopeID, x, y);
229 294
230 return rinfo; 295 return rinfo;
231 } 296 }
@@ -238,25 +303,35 @@ namespace OpenSim.Services.Connectors
238 sendData["NAME"] = regionName; 303 sendData["NAME"] = regionName;
239 304
240 sendData["METHOD"] = "get_region_by_name"; 305 sendData["METHOD"] = "get_region_by_name";
241 306 string reply = string.Empty;
242 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 307 try
243 m_ServerURI + "/grid", 308 {
244 ServerUtils.BuildQueryString(sendData)); 309 reply = SynchronousRestFormsRequester.MakeRequest("POST",
245 310 m_ServerURI + "/grid",
246 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 311 ServerUtils.BuildQueryString(sendData));
312 }
313 catch (Exception e)
314 {
315 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
316 return null;
317 }
247 318
248 GridRegion rinfo = null; 319 GridRegion rinfo = null;
249 if ((replyData != null) && (replyData["result"] != null)) 320 if (reply != string.Empty)
250 { 321 {
251 if (replyData["result"] is Dictionary<string, object>) 322 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
252 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]); 323
324 if ((replyData != null) && (replyData["result"] != null))
325 {
326 if (replyData["result"] is Dictionary<string, object>)
327 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
328 }
253 else 329 else
254 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received invalid response", 330 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response",
255 scopeID, regionName); 331 scopeID, regionName);
256 } 332 }
257 else 333 else
258 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response", 334 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
259 scopeID, regionName);
260 335
261 return rinfo; 336 return rinfo;
262 } 337 }
@@ -270,32 +345,45 @@ namespace OpenSim.Services.Connectors
270 sendData["MAX"] = maxNumber.ToString(); 345 sendData["MAX"] = maxNumber.ToString();
271 346
272 sendData["METHOD"] = "get_regions_by_name"; 347 sendData["METHOD"] = "get_regions_by_name";
273
274 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
275 m_ServerURI + "/grid",
276 ServerUtils.BuildQueryString(sendData));
277
278 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
279
280 List<GridRegion> rinfos = new List<GridRegion>(); 348 List<GridRegion> rinfos = new List<GridRegion>();
281 if (replyData != null) 349 string reply = string.Empty;
350 try
282 { 351 {
283 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 352 reply = SynchronousRestFormsRequester.MakeRequest("POST",
284 foreach (object r in rinfosList) 353 m_ServerURI + "/grid",
354 ServerUtils.BuildQueryString(sendData));
355 }
356 catch (Exception e)
357 {
358 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
359 return rinfos;
360 }
361
362 if (reply != string.Empty)
363 {
364 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
365
366 if (replyData != null)
285 { 367 {
286 if (r is Dictionary<string, object>) 368 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
369 foreach (object r in rinfosList)
287 { 370 {
288 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); 371 if (r is Dictionary<string, object>)
289 rinfos.Add(rinfo); 372 {
373 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
374 rinfos.Add(rinfo);
375 }
376 else
377 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response",
378 scopeID, name, maxNumber);
290 } 379 }
291 else
292 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response",
293 scopeID, name, maxNumber);
294 } 380 }
381 else
382 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
383 scopeID, name, maxNumber);
295 } 384 }
296 else 385 else
297 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response", 386 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
298 scopeID, name, maxNumber);
299 387
300 return rinfos; 388 return rinfos;
301 } 389 }
@@ -312,31 +400,44 @@ namespace OpenSim.Services.Connectors
312 400
313 sendData["METHOD"] = "get_region_range"; 401 sendData["METHOD"] = "get_region_range";
314 402
315 string reply = SynchronousRestFormsRequester.MakeRequest("POST", 403 List<GridRegion> rinfos = new List<GridRegion>();
316 m_ServerURI + "/grid", 404 string reply = string.Empty;
317 ServerUtils.BuildQueryString(sendData)); 405 try
406 {
407 reply = SynchronousRestFormsRequester.MakeRequest("POST",
408 m_ServerURI + "/grid",
409 ServerUtils.BuildQueryString(sendData));
318 410
319 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); 411 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
412 }
413 catch (Exception e)
414 {
415 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
416 return rinfos;
417 }
320 418
321 List<GridRegion> rinfos = new List<GridRegion>(); 419 if (reply != string.Empty)
322 if (replyData != null)
323 { 420 {
324 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; 421 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
325 foreach (object r in rinfosList) 422
423 if (replyData != null)
326 { 424 {
327 if (r is Dictionary<string, object>) 425 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
426 foreach (object r in rinfosList)
328 { 427 {
329 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); 428 if (r is Dictionary<string, object>)
330 rinfos.Add(rinfo); 429 {
430 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
431 rinfos.Add(rinfo);
432 }
331 } 433 }
332 else
333 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received invalid response",
334 scopeID, xmin, xmax, ymin, ymax);
335 } 434 }
435 else
436 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response",
437 scopeID, xmin, xmax, ymin, ymax);
336 } 438 }
337 else 439 else
338 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response", 440 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply");
339 scopeID, xmin, xmax, ymin, ymax);
340 441
341 return rinfos; 442 return rinfos;
342 } 443 }
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs
index 01ffa1d..991acf2 100644
--- a/OpenSim/Services/GridService/GridService.cs
+++ b/OpenSim/Services/GridService/GridService.cs
@@ -50,35 +50,27 @@ namespace OpenSim.Services.GridService
50 : base(config) 50 : base(config)
51 { 51 {
52 m_log.DebugFormat("[GRID SERVICE]: Starting..."); 52 m_log.DebugFormat("[GRID SERVICE]: Starting...");
53 MainConsole.Instance.Commands.AddCommand("kfs", false,
54 "show digest",
55 "show digest <ID>",
56 "Show asset digest", HandleShowDigest);
57
58 MainConsole.Instance.Commands.AddCommand("kfs", false,
59 "delete asset",
60 "delete asset <ID>",
61 "Delete asset from database", HandleDeleteAsset);
62
63 } 53 }
64 54
65 #region IGridService 55 #region IGridService
66 56
67 public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) 57 public bool RegisterRegion(UUID scopeID, GridRegion regionInfos)
68 { 58 {
69 if (m_Database.Get(regionInfos.RegionID, scopeID) != null)
70 {
71 m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID);
72 return false;
73 }
74 // This needs better sanity testing. What if regionInfo is registering in 59 // This needs better sanity testing. What if regionInfo is registering in
75 // overlapping coords? 60 // overlapping coords?
76 if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) 61 RegionData region = m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
62 if ((region != null) && (region.RegionID != regionInfos.RegionID))
77 { 63 {
78 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", 64 m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
79 regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); 65 regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
80 return false; 66 return false;
81 } 67 }
68 if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
69 ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
70 {
71 // Region reregistering in other coordinates. Delete the old entry
72 m_Database.Delete(regionInfos.RegionID);
73 }
82 74
83 // Everything is ok, let's register 75 // Everything is ok, let's register
84 RegionData rdata = RegionInfo2RegionData(regionInfos); 76 RegionData rdata = RegionInfo2RegionData(regionInfos);
@@ -183,9 +175,9 @@ namespace OpenSim.Services.GridService
183 rdata.posX = (int)rinfo.RegionLocX; 175 rdata.posX = (int)rinfo.RegionLocX;
184 rdata.posY = (int)rinfo.RegionLocY; 176 rdata.posY = (int)rinfo.RegionLocY;
185 rdata.RegionID = rinfo.RegionID; 177 rdata.RegionID = rinfo.RegionID;
186 rdata.Data = rinfo.ToKeyValuePairs();
187 rdata.RegionName = rinfo.RegionName; 178 rdata.RegionName = rinfo.RegionName;
188 179 rdata.Data = rinfo.ToKeyValuePairs();
180 rdata.Data["regionHandle"] = Utils.UIntsToLong((uint)rdata.posX, (uint)rdata.posY);
189 return rdata; 181 return rdata;
190 } 182 }
191 183
@@ -196,73 +188,12 @@ namespace OpenSim.Services.GridService
196 rinfo.RegionLocY = rdata.posY; 188 rinfo.RegionLocY = rdata.posY;
197 rinfo.RegionID = rdata.RegionID; 189 rinfo.RegionID = rdata.RegionID;
198 rinfo.RegionName = rdata.RegionName; 190 rinfo.RegionName = rdata.RegionName;
191 rinfo.ScopeID = rdata.ScopeID;
199 192
200 return rinfo; 193 return rinfo;
201 } 194 }
202 195
203 #endregion 196 #endregion
204 197
205 void HandleShowDigest(string module, string[] args)
206 {
207 //if (args.Length < 3)
208 //{
209 // MainConsole.Instance.Output("Syntax: show digest <ID>");
210 // return;
211 //}
212
213 //AssetBase asset = Get(args[2]);
214
215 //if (asset == null || asset.Data.Length == 0)
216 //{
217 // MainConsole.Instance.Output("Asset not found");
218 // return;
219 //}
220
221 //int i;
222
223 //MainConsole.Instance.Output(String.Format("Name: {0}", asset.Name));
224 //MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description));
225 //MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type));
226 //MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType));
227
228 //for (i = 0 ; i < 5 ; i++)
229 //{
230 // int off = i * 16;
231 // if (asset.Data.Length <= off)
232 // break;
233 // int len = 16;
234 // if (asset.Data.Length < off + len)
235 // len = asset.Data.Length - off;
236
237 // byte[] line = new byte[len];
238 // Array.Copy(asset.Data, off, line, 0, len);
239
240 // string text = BitConverter.ToString(line);
241 // MainConsole.Instance.Output(String.Format("{0:x4}: {1}", off, text));
242 //}
243 }
244
245 void HandleDeleteAsset(string module, string[] args)
246 {
247 //if (args.Length < 3)
248 //{
249 // MainConsole.Instance.Output("Syntax: delete asset <ID>");
250 // return;
251 //}
252
253 //AssetBase asset = Get(args[2]);
254
255 //if (asset == null || asset.Data.Length == 0)
256 // MainConsole.Instance.Output("Asset not found");
257 // return;
258 //}
259
260 //Delete(args[2]);
261
262 ////MainConsole.Instance.Output("Asset deleted");
263 //// TODO: Implement this
264
265 //MainConsole.Instance.Output("Asset deletion not supported by database");
266 }
267 } 198 }
268} 199}
diff --git a/OpenSim/Services/Interfaces/IGridService.cs b/OpenSim/Services/Interfaces/IGridService.cs
index a188f7e..ce432ab 100644
--- a/OpenSim/Services/Interfaces/IGridService.cs
+++ b/OpenSim/Services/Interfaces/IGridService.cs
@@ -263,59 +263,55 @@ namespace OpenSim.Services.Interfaces
263 kvp["uuid"] = RegionID.ToString(); 263 kvp["uuid"] = RegionID.ToString();
264 kvp["locX"] = RegionLocX.ToString(); 264 kvp["locX"] = RegionLocX.ToString();
265 kvp["locY"] = RegionLocY.ToString(); 265 kvp["locY"] = RegionLocY.ToString();
266 kvp["external_ip_address"] = ExternalEndPoint.Address.ToString(); 266 kvp["regionName"] = RegionName;
267 kvp["external_port"] = ExternalEndPoint.Port.ToString(); 267 kvp["serverIP"] = ExternalHostName; //ExternalEndPoint.Address.ToString();
268 kvp["external_host_name"] = ExternalHostName; 268 kvp["serverHttpPort"] = HttpPort.ToString();
269 kvp["http_port"] = HttpPort.ToString(); 269 kvp["serverURI"] = ServerURI;
270 kvp["internal_ip_address"] = InternalEndPoint.Address.ToString(); 270 kvp["serverPort"] = InternalEndPoint.Port.ToString();
271 kvp["internal_port"] = InternalEndPoint.Port.ToString();
272 kvp["alternate_ports"] = m_allow_alternate_ports.ToString();
273 kvp["server_uri"] = ServerURI;
274 271
275 return kvp; 272 return kvp;
276 } 273 }
277 274
278 public GridRegion(Dictionary<string, object> kvp) 275 public GridRegion(Dictionary<string, object> kvp)
279 { 276 {
280 if ((kvp["external_ip_address"] != null) && (kvp["external_port"] != null)) 277 if (kvp.ContainsKey("uuid"))
281 { 278 RegionID = new UUID((string)kvp["uuid"]);
282 int port = 0;
283 Int32.TryParse((string)kvp["external_port"], out port);
284 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["external_ip_address"]), port);
285 ExternalEndPoint = ep;
286 }
287 else
288 ExternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
289 279
290 if (kvp["external_host_name"] != null) 280 if (kvp.ContainsKey("locX"))
291 ExternalHostName = (string)kvp["external_host_name"]; 281 RegionLocX = Convert.ToInt32((string)kvp["locX"]);
292 282
293 if (kvp["http_port"] != null) 283 if (kvp.ContainsKey("locY"))
284 RegionLocY = Convert.ToInt32((string)kvp["locY"]);
285
286 if (kvp.ContainsKey("regionName"))
287 RegionName = (string)kvp["regionName"];
288
289 if (kvp.ContainsKey("serverIP"))
294 { 290 {
295 UInt32 port = 0; 291 //int port = 0;
296 UInt32.TryParse((string)kvp["http_port"], out port); 292 //Int32.TryParse((string)kvp["serverPort"], out port);
297 HttpPort = port; 293 //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port);
294 ExternalHostName = (string)kvp["serverIP"];
298 } 295 }
296 else
297 ExternalHostName = "127.0.0.1";
299 298
300 if ((kvp["internal_ip_address"] != null) && (kvp["internal_port"] != null)) 299 if (kvp.ContainsKey("serverPort"))
301 { 300 {
302 int port = 0; 301 Int32 port = 0;
303 Int32.TryParse((string)kvp["internal_port"], out port); 302 Int32.TryParse((string)kvp["serverPort"], out port);
304 IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["internal_ip_address"]), port); 303 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
305 InternalEndPoint = ep;
306 } 304 }
307 else
308 InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);
309 305
310 if (kvp["alternate_ports"] != null) 306 if (kvp.ContainsKey("serverHttpPort"))
311 { 307 {
312 bool alts = false; 308 UInt32 port = 0;
313 Boolean.TryParse((string)kvp["alternate_ports"], out alts); 309 UInt32.TryParse((string)kvp["serverHttpPort"], out port);
314 m_allow_alternate_ports = alts; 310 HttpPort = port;
315 } 311 }
316 312
317 if (kvp["server_uri"] != null) 313 if (kvp.ContainsKey("serverURI"))
318 ServerURI = (string)kvp["server_uri"]; 314 ServerURI = (string)kvp["serverURI"];
319 } 315 }
320 } 316 }
321 317
diff --git a/OpenSim/Tests/Clients/Grid/GridClient.cs b/OpenSim/Tests/Clients/Grid/GridClient.cs
new file mode 100644
index 0000000..941406e
--- /dev/null
+++ b/OpenSim/Tests/Clients/Grid/GridClient.cs
@@ -0,0 +1,177 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Reflection;
5
6using OpenMetaverse;
7using log4net;
8using log4net.Appender;
9using log4net.Layout;
10
11using OpenSim.Framework;
12using OpenSim.Services.Interfaces;
13using GridRegion = OpenSim.Services.Interfaces.GridRegion;
14using OpenSim.Services.Connectors;
15
16namespace OpenSim.Tests.Clients.GridClient
17{
18 public class GridClient
19 {
20 private static readonly ILog m_log =
21 LogManager.GetLogger(
22 MethodBase.GetCurrentMethod().DeclaringType);
23
24 public static void Main(string[] args)
25 {
26 ConsoleAppender consoleAppender = new ConsoleAppender();
27 consoleAppender.Layout =
28 new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
29 log4net.Config.BasicConfigurator.Configure(consoleAppender);
30
31 string serverURI = "http://127.0.0.1:8002";
32 GridServicesConnector m_Connector = new GridServicesConnector(serverURI);
33
34 GridRegion r1 = CreateRegion("Test Region 1", 1000, 1000);
35 GridRegion r2 = CreateRegion("Test Region 2", 1001, 1000);
36 GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000);
37
38 Console.WriteLine("[GRID CLIENT]: *** Registering region 1");
39 bool success = m_Connector.RegisterRegion(UUID.Zero, r1);
40 if (success)
41 Console.WriteLine("[GRID CLIENT]: Successfully registered region 1");
42 else
43 Console.WriteLine("[GRID CLIENT]: region 1 failed to register");
44
45 Console.WriteLine("[GRID CLIENT]: *** Registering region 2");
46 success = m_Connector.RegisterRegion(UUID.Zero, r2);
47 if (success)
48 Console.WriteLine("[GRID CLIENT]: Successfully registered region 2");
49 else
50 Console.WriteLine("[GRID CLIENT]: region 2 failed to register");
51
52 Console.WriteLine("[GRID CLIENT]: *** Registering region 3");
53 success = m_Connector.RegisterRegion(UUID.Zero, r3);
54 if (success)
55 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
56 else
57 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
58
59
60 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
61 success = m_Connector.DeregisterRegion(r3.RegionID);
62 if (success)
63 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
64 else
65 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
66 Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again");
67 success = m_Connector.RegisterRegion(UUID.Zero, r3);
68 if (success)
69 Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
70 else
71 Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
72
73 Console.WriteLine("[GRID CLIENT]: *** GetNeighbours of region 1");
74 List<GridRegion> regions = m_Connector.GetNeighbours(UUID.Zero, r1.RegionID);
75 if (regions == null)
76 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 failed");
77 else if (regions.Count > 0)
78 {
79 if (regions.Count != 1)
80 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned more neighbours than expected: " + regions.Count);
81 else
82 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned the right neighbour " + regions[0].RegionName);
83 }
84 else
85 Console.WriteLine("[GRID CLIENT]: GetNeighbours of region 1 returned 0 neighbours");
86
87
88 Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of region 2 (this should succeed)");
89 GridRegion region = m_Connector.GetRegionByUUID(UUID.Zero, r2.RegionID);
90 if (region == null)
91 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
92 else
93 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
94
95 Console.WriteLine("[GRID CLIENT]: *** GetRegionByUUID of non-existent region (this should fail)");
96 region = m_Connector.GetRegionByUUID(UUID.Zero, UUID.Random());
97 if (region == null)
98 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned null");
99 else
100 Console.WriteLine("[GRID CLIENT]: GetRegionByUUID returned region " + region.RegionName);
101
102 Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of region 3 (this should succeed)");
103 region = m_Connector.GetRegionByName(UUID.Zero, r3.RegionName);
104 if (region == null)
105 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
106 else
107 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
108
109 Console.WriteLine("[GRID CLIENT]: *** GetRegionByName of non-existent region (this should fail)");
110 region = m_Connector.GetRegionByName(UUID.Zero, "Foo");
111 if (region == null)
112 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned null");
113 else
114 Console.WriteLine("[GRID CLIENT]: GetRegionByName returned region " + region.RegionName);
115
116 Console.WriteLine("[GRID CLIENT]: *** GetRegionsByName (this should return 3 regions)");
117 regions = m_Connector.GetRegionsByName(UUID.Zero, "Test", 10);
118 if (regions == null)
119 Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned null");
120 else
121 Console.WriteLine("[GRID CLIENT]: GetRegionsByName returned " + regions.Count + " regions");
122
123 Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)");
124 regions = m_Connector.GetRegionRange(UUID.Zero,
125 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize,
126 900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize);
127 if (regions == null)
128 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
129 else
130 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
131 Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)");
132 regions = m_Connector.GetRegionRange(UUID.Zero,
133 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize,
134 900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize);
135 if (regions == null)
136 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
137 else
138 Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
139
140 Console.Write("Proceed to deregister? Press enter...");
141 Console.ReadLine();
142
143 // Deregister them all
144 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 1");
145 success = m_Connector.DeregisterRegion(r1.RegionID);
146 if (success)
147 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 1");
148 else
149 Console.WriteLine("[GRID CLIENT]: region 1 failed to deregister");
150 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 2");
151 success = m_Connector.DeregisterRegion(r2.RegionID);
152 if (success)
153 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 2");
154 else
155 Console.WriteLine("[GRID CLIENT]: region 2 failed to deregister");
156 Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
157 success = m_Connector.DeregisterRegion(r3.RegionID);
158 if (success)
159 Console.WriteLine("[GRID CLIENT]: Successfully deregistered region 3");
160 else
161 Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
162
163 }
164
165 private static GridRegion CreateRegion(string name, uint xcell, uint ycell)
166 {
167 GridRegion region = new GridRegion(xcell, ycell);
168 region.RegionName = name;
169 region.RegionID = UUID.Random();
170 region.ExternalHostName = "127.0.0.1";
171 region.HttpPort = 9000;
172 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 9000);
173
174 return region;
175 }
176 }
177}
diff --git a/OpenSim/Tests/Clients/Grid/GridForm.html b/OpenSim/Tests/Clients/Grid/GridForm.html
new file mode 100644
index 0000000..252920f
--- /dev/null
+++ b/OpenSim/Tests/Clients/Grid/GridForm.html
@@ -0,0 +1,11 @@
1<html>
2
3<form name="input" action="http://127.0.0.1:8002/grid" method="post">
4xmin:<input type="text" name="XMIN" value="0">
5xmax:<input type="text" name="XMAX" value="0">
6ymin:<input type="text" name="YMIN" value="0">
7ymax:<input type="text" name="YMAX" value="0">
8<input type="hidden" name="METHOD" value="get_region_range">
9<input type="submit" value="Submit" />
10</form>
11</html>
diff --git a/bin/OpenSim.GridServer.ini.example b/bin/OpenSim.GridServer.ini.example
new file mode 100644
index 0000000..695bf9e
--- /dev/null
+++ b/bin/OpenSim.GridServer.ini.example
@@ -0,0 +1,35 @@
1; * The startup section lists all the connectors to start up in this server
2; * instance. This may be only one, or it may be the entire server suite.
3; * Multiple connectors should be seaprated by commas.
4; *
5; * These are the IN connectors the server uses, the in connectors
6; * read this config file and load the needed OUT and database connectors
7; *
8; *
9[Startup]
10 ServiceConnectors = "OpenSim.Server.Handlers.dll:GridServiceConnector"
11
12; * This is common for all services, it's the network setup for the entire
13; * server instance
14; *
15[Network]
16 port = 8002
17
18; * The following are for the remote console
19; * They have no effect for the local or basic console types
20; * Leave commented to diable logins to the console
21;ConsoleUser = Test
22;ConsolePass = secret
23
24; * As an example, the below configuration precisely mimicks the legacy
25; * asset server. It is read by the asset IN connector (defined above)
26; * and it then loads the OUT connector (a local database module). That,
27; * in turn, reads the asset loader and database connection information
28; *
29[GridService]
30 LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
31 StorageProvider = "OpenSim.Data.Null.dll:NullRegionData"
32 ;StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData"
33 ;ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=***;"
34 Realm = "regions"
35
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index e34378c..7a65efe 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -1311,7 +1311,7 @@
1311 ;NoticesEnabled = true 1311 ;NoticesEnabled = true
1312 1312
1313 ; This makes the Groups modules very chatty on the console. 1313 ; This makes the Groups modules very chatty on the console.
1314 ;DebugEnabled = true 1314 DebugEnabled = false
1315 1315
1316 ; Specify which messaging module to use for groups messaging and if it's enabled 1316 ; Specify which messaging module to use for groups messaging and if it's enabled
1317 ;MessagingModule = GroupsMessagingModule 1317 ;MessagingModule = GroupsMessagingModule
diff --git a/prebuild.xml b/prebuild.xml
index cb20319..6ac7b68 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3221,6 +3221,35 @@
3221 </Files> 3221 </Files>
3222 </Project> 3222 </Project>
3223 3223
3224 <!-- Test Clients -->
3225 <Project frameworkVersion="v3_5" name="OpenSim.Tests.Clients.GridClient" path="OpenSim/Tests/Clients/Grid" type="Exe">
3226 <Configuration name="Debug">
3227 <Options>
3228 <OutputPath>../../../../bin/</OutputPath>
3229 </Options>
3230 </Configuration>
3231 <Configuration name="Release">
3232 <Options>
3233 <OutputPath>../../../../bin/</OutputPath>
3234 </Options>
3235 </Configuration>
3236
3237 <ReferencePath>../../../../bin/</ReferencePath>
3238 <Reference name="System"/>
3239 <Reference name="OpenMetaverseTypes.dll"/>
3240 <Reference name="OpenMetaverse.dll"/>
3241 <Reference name="OpenSim.Framework"/>
3242 <Reference name="OpenSim.Services.Interfaces" />
3243 <Reference name="OpenSim.Services.Connectors" />
3244 <Reference name="Nini.dll" />
3245 <Reference name="log4net.dll"/>
3246
3247 <Files>
3248 <Match pattern="*.cs" recurse="true"/>
3249 </Files>
3250 </Project>
3251
3252
3224 <!-- Test assemblies --> 3253 <!-- Test assemblies -->
3225 <Project frameworkVersion="v3_5" name="OpenSim.Tests.Common" path="OpenSim/Tests/Common" type="Library"> 3254 <Project frameworkVersion="v3_5" name="OpenSim.Tests.Common" path="OpenSim/Tests/Common" type="Library">
3226 <Configuration name="Debug"> 3255 <Configuration name="Debug">