aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs4
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs60
-rw-r--r--OpenSim/Framework/Data.DB4o/DB4oUserData.cs2
-rw-r--r--OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs4
-rw-r--r--OpenSim/Framework/Data.MySQL/MySQLUserData.cs4
-rw-r--r--OpenSim/Framework/Data.SQLite/SQLiteUserData.cs2
-rw-r--r--OpenSim/Framework/Data/GridData.cs4
-rw-r--r--OpenSim/Framework/Remoting.cs2
-rw-r--r--OpenSim/Framework/Util.cs10
-rw-r--r--OpenSim/Region/ClientStack/ClientView.cs29
-rw-r--r--OpenSim/Region/Environment/Scenes/AvatarAppearance.cs4
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs36
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs13
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs88
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPlugin.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_Types.cs22
16 files changed, 136 insertions, 155 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index 2205683..8122b8a 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -122,7 +122,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
122 122
123 public XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request) 123 public XmlRpcResponse XmlRpcShutdownMethod(XmlRpcRequest request)
124 { 124 {
125 MainLog.Instance.Verbose("RADMIN", "Recieved Shutdown Administrator Request"); 125 MainLog.Instance.Verbose("RADMIN", "Received Shutdown Administrator Request");
126 XmlRpcResponse response = new XmlRpcResponse(); 126 XmlRpcResponse response = new XmlRpcResponse();
127 Hashtable requestData = (Hashtable)request.Params[0]; 127 Hashtable requestData = (Hashtable)request.Params[0];
128 128
@@ -170,7 +170,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
170 170
171 public XmlRpcResponse XmlRpcCreateRegionMethod(XmlRpcRequest request) 171 public XmlRpcResponse XmlRpcCreateRegionMethod(XmlRpcRequest request)
172 { 172 {
173 MainLog.Instance.Verbose("RADMIN", "Recieved Create Region Administrator Request"); 173 MainLog.Instance.Verbose("RADMIN", "Received Create Region Administrator Request");
174 XmlRpcResponse response = new XmlRpcResponse(); 174 XmlRpcResponse response = new XmlRpcResponse();
175 Hashtable requestData = (Hashtable)request.Params[0]; 175 Hashtable requestData = (Hashtable)request.Params[0];
176 176
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index abaea23..99356c2 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -36,7 +36,6 @@ using OpenSim.Framework.Console;
36 36
37namespace OpenSim.Framework.Communications.Cache 37namespace OpenSim.Framework.Communications.Cache
38{ 38{
39
40 public delegate void AssetRequestCallback(LLUUID assetID, AssetBase asset); 39 public delegate void AssetRequestCallback(LLUUID assetID, AssetBase asset);
41 40
42 /// <summary> 41 /// <summary>
@@ -77,7 +76,6 @@ namespace OpenSim.Framework.Communications.Cache
77 m_assetCacheThread.IsBackground = true; 76 m_assetCacheThread.IsBackground = true;
78 m_assetCacheThread.Start(); 77 m_assetCacheThread.Start();
79 78
80
81 m_log = log; 79 m_log = log;
82 } 80 }
83 81
@@ -100,7 +98,6 @@ namespace OpenSim.Framework.Communications.Cache
100 } 98 }
101 } 99 }
102 100
103
104 public AssetBase GetAsset(LLUUID assetID) 101 public AssetBase GetAsset(LLUUID assetID)
105 { 102 {
106 AssetBase asset = null; 103 AssetBase asset = null;
@@ -154,7 +151,6 @@ namespace OpenSim.Framework.Communications.Cache
154 } 151 }
155 } 152 }
156 153
157
158 public AssetBase GetAsset(LLUUID assetID, bool isTexture) 154 public AssetBase GetAsset(LLUUID assetID, bool isTexture)
159 { 155 {
160 AssetBase asset = GetAsset(assetID); 156 AssetBase asset = GetAsset(assetID);
@@ -236,8 +232,6 @@ namespace OpenSim.Framework.Communications.Cache
236 return asset; 232 return asset;
237 } 233 }
238 234
239
240
241 public void AssetReceived(AssetBase asset, bool IsTexture) 235 public void AssetReceived(AssetBase asset, bool IsTexture)
242 { 236 {
243 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server 237 if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server
@@ -249,7 +243,7 @@ namespace OpenSim.Framework.Communications.Cache
249 243
250 if (IsTexture) 244 if (IsTexture)
251 { 245 {
252 //Console.WriteLine("asset recieved from asset server"); 246 //Console.WriteLine("asset received from asset server");
253 247
254 TextureImage image = new TextureImage(asset); 248 TextureImage image = new TextureImage(asset);
255 if (!Textures.ContainsKey(image.FullID)) 249 if (!Textures.ContainsKey(image.FullID))
@@ -260,7 +254,7 @@ namespace OpenSim.Framework.Communications.Cache
260 AssetRequest req = RequestedTextures[image.FullID]; 254 AssetRequest req = RequestedTextures[image.FullID];
261 req.ImageInfo = image; 255 req.ImageInfo = image;
262 256
263 req.NumPackets = CalculateNumPackets(image.Data.Length); 257 req.NumPackets = CalculateNumPackets(image.Data);
264 258
265 RequestedTextures.Remove(image.FullID); 259 RequestedTextures.Remove(image.FullID);
266 TextureRequests.Add(req); 260 TextureRequests.Add(req);
@@ -277,15 +271,7 @@ namespace OpenSim.Framework.Communications.Cache
277 { 271 {
278 AssetRequest req = RequestedAssets[assetInf.FullID]; 272 AssetRequest req = RequestedAssets[assetInf.FullID];
279 req.AssetInf = assetInf; 273 req.AssetInf = assetInf;
280 if (assetInf.Data.LongLength > 600) 274 req.NumPackets = CalculateNumPackets(assetInf.Data);
281 {
282 //over 600 bytes so split up file
283 req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000;
284 }
285 else
286 {
287 req.NumPackets = 1;
288 }
289 RequestedAssets.Remove(assetInf.FullID); 275 RequestedAssets.Remove(assetInf.FullID);
290 AssetRequests.Add(req); 276 AssetRequests.Add(req);
291 } 277 }
@@ -326,16 +312,17 @@ namespace OpenSim.Framework.Communications.Cache
326 //} 312 //}
327 } 313 }
328 314
329 private int CalculateNumPackets(int length) 315 private int CalculateNumPackets(byte[] data)
330 { 316 {
317 const uint m_maxPacketSize = 600;
331 int numPackets = 1; 318 int numPackets = 1;
332 319
333 if (length > 600) 320 if (data.LongLength > m_maxPacketSize)
334 { 321 {
335 //over 600 bytes so split up file 322 // over max number of bytes so split up file
336 int restData = (length - 600); 323 long restData = data.LongLength - m_maxPacketSize;
337 int restPackets = ((restData + 999) / 1000); 324 int restPackets = (int) ((restData + m_maxPacketSize - 1) / m_maxPacketSize);
338 numPackets = 1 + restPackets; 325 numPackets += restPackets;
339 } 326 }
340 327
341 return numPackets; 328 return numPackets;
@@ -385,8 +372,7 @@ namespace OpenSim.Framework.Communications.Cache
385 //it is in our cache 372 //it is in our cache
386 AssetInfo asset = Assets[requestID]; 373 AssetInfo asset = Assets[requestID];
387 374
388 //work out how many packets it should be sent in 375 // add to the AssetRequests list
389 // and add to the AssetRequests list
390 AssetRequest req = new AssetRequest(); 376 AssetRequest req = new AssetRequest();
391 req.RequestUser = userInfo; 377 req.RequestUser = userInfo;
392 req.RequestAssetID = requestID; 378 req.RequestAssetID = requestID;
@@ -394,17 +380,7 @@ namespace OpenSim.Framework.Communications.Cache
394 req.AssetRequestSource = source; 380 req.AssetRequestSource = source;
395 req.Params = transferRequest.TransferInfo.Params; 381 req.Params = transferRequest.TransferInfo.Params;
396 req.AssetInf = asset; 382 req.AssetInf = asset;
397 383 req.NumPackets = CalculateNumPackets(asset.Data);
398 if (asset.Data.LongLength > 600)
399 {
400 //over 600 bytes so split up file
401 req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000;
402 }
403 else
404 {
405 req.NumPackets = 1;
406 }
407
408 AssetRequests.Add(req); 384 AssetRequests.Add(req);
409 } 385 }
410 386
@@ -419,17 +395,9 @@ namespace OpenSim.Framework.Communications.Cache
419 //no requests waiting 395 //no requests waiting
420 return; 396 return;
421 } 397 }
422 int num; 398 // if less than 5, do all of them
399 int num = Math.Min(5, AssetRequests.Count);
423 400
424 if (AssetRequests.Count < 5)
425 {
426 //lower than 5 so do all of them
427 num = AssetRequests.Count;
428 }
429 else
430 {
431 num = 5;
432 }
433 AssetRequest req; 401 AssetRequest req;
434 for (int i = 0; i < num; i++) 402 for (int i = 0; i < num; i++)
435 { 403 {
diff --git a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
index 9e5a679..383bfbe 100644
--- a/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
+++ b/OpenSim/Framework/Data.DB4o/DB4oUserData.cs
@@ -199,7 +199,7 @@ namespace OpenSim.Framework.Data.DB4o
199 /// </summary> 199 /// </summary>
200 /// <remarks>Move to inventory server</remarks> 200 /// <remarks>Move to inventory server</remarks>
201 /// <param name="from">Senders account</param> 201 /// <param name="from">Senders account</param>
202 /// <param name="to">Recievers account</param> 202 /// <param name="to">Receivers account</param>
203 /// <param name="item">Inventory item</param> 203 /// <param name="item">Inventory item</param>
204 /// <returns>Success?</returns> 204 /// <returns>Success?</returns>
205 public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) 205 public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
diff --git a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
index 80b65c1..ccab57b 100644
--- a/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
+++ b/OpenSim/Framework/Data.MSSQL/MSSQLUserData.cs
@@ -387,7 +387,7 @@ namespace OpenSim.Framework.Data.MSSQL
387 /// Performs a money transfer request between two accounts 387 /// Performs a money transfer request between two accounts
388 /// </summary> 388 /// </summary>
389 /// <param name="from">The senders account ID</param> 389 /// <param name="from">The senders account ID</param>
390 /// <param name="to">The recievers account ID</param> 390 /// <param name="to">The receivers account ID</param>
391 /// <param name="amount">The amount to transfer</param> 391 /// <param name="amount">The amount to transfer</param>
392 /// <returns>Success?</returns> 392 /// <returns>Success?</returns>
393 public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount) 393 public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount)
@@ -400,7 +400,7 @@ namespace OpenSim.Framework.Data.MSSQL
400 /// </summary> 400 /// </summary>
401 /// <remarks>TODO: Move to inventory server</remarks> 401 /// <remarks>TODO: Move to inventory server</remarks>
402 /// <param name="from">The senders account ID</param> 402 /// <param name="from">The senders account ID</param>
403 /// <param name="to">The recievers account ID</param> 403 /// <param name="to">The receivers account ID</param>
404 /// <param name="item">The item to transfer</param> 404 /// <param name="item">The item to transfer</param>
405 /// <returns>Success?</returns> 405 /// <returns>Success?</returns>
406 public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) 406 public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
diff --git a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
index 6a7cf49..05e5127 100644
--- a/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
+++ b/OpenSim/Framework/Data.MySQL/MySQLUserData.cs
@@ -363,7 +363,7 @@ namespace OpenSim.Framework.Data.MySQL
363 /// Performs a money transfer request between two accounts 363 /// Performs a money transfer request between two accounts
364 /// </summary> 364 /// </summary>
365 /// <param name="from">The senders account ID</param> 365 /// <param name="from">The senders account ID</param>
366 /// <param name="to">The recievers account ID</param> 366 /// <param name="to">The receivers account ID</param>
367 /// <param name="amount">The amount to transfer</param> 367 /// <param name="amount">The amount to transfer</param>
368 /// <returns>Success?</returns> 368 /// <returns>Success?</returns>
369 public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount) 369 public bool MoneyTransferRequest(LLUUID from, LLUUID to, uint amount)
@@ -376,7 +376,7 @@ namespace OpenSim.Framework.Data.MySQL
376 /// </summary> 376 /// </summary>
377 /// <remarks>TODO: Move to inventory server</remarks> 377 /// <remarks>TODO: Move to inventory server</remarks>
378 /// <param name="from">The senders account ID</param> 378 /// <param name="from">The senders account ID</param>
379 /// <param name="to">The recievers account ID</param> 379 /// <param name="to">The receivers account ID</param>
380 /// <param name="item">The item to transfer</param> 380 /// <param name="item">The item to transfer</param>
381 /// <returns>Success?</returns> 381 /// <returns>Success?</returns>
382 public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) 382 public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
diff --git a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
index 346febc..99121be 100644
--- a/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
+++ b/OpenSim/Framework/Data.SQLite/SQLiteUserData.cs
@@ -320,7 +320,7 @@ namespace OpenSim.Framework.Data.SQLite
320 /// </summary> 320 /// </summary>
321 /// <remarks>Move to inventory server</remarks> 321 /// <remarks>Move to inventory server</remarks>
322 /// <param name="from">Senders account</param> 322 /// <param name="from">Senders account</param>
323 /// <param name="to">Recievers account</param> 323 /// <param name="to">Receivers account</param>
324 /// <param name="item">Inventory item</param> 324 /// <param name="item">Inventory item</param>
325 /// <returns>Success?</returns> 325 /// <returns>Success?</returns>
326 public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) 326 public bool InventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
diff --git a/OpenSim/Framework/Data/GridData.cs b/OpenSim/Framework/Data/GridData.cs
index 1aebbda..7864dda 100644
--- a/OpenSim/Framework/Data/GridData.cs
+++ b/OpenSim/Framework/Data/GridData.cs
@@ -79,12 +79,12 @@ namespace OpenSim.Framework.Data
79 79
80 List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query); 80 List<AvatarPickerAvatar> GeneratePickerResults(LLUUID queryID, string query);
81 /// <summary> 81 /// <summary>
82 /// Authenticates a sim by use of it's recv key. 82 /// Authenticates a sim by use of its recv key.
83 /// WARNING: Insecure 83 /// WARNING: Insecure
84 /// </summary> 84 /// </summary>
85 /// <param name="UUID">The UUID sent by the sim</param> 85 /// <param name="UUID">The UUID sent by the sim</param>
86 /// <param name="regionHandle">The regionhandle sent by the sim</param> 86 /// <param name="regionHandle">The regionhandle sent by the sim</param>
87 /// <param name="simrecvkey">The recieving key sent by the sim</param> 87 /// <param name="simrecvkey">The receiving key sent by the sim</param>
88 /// <returns>Whether the sim has been authenticated</returns> 88 /// <returns>Whether the sim has been authenticated</returns>
89 bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey); 89 bool AuthenticateSim(LLUUID UUID, ulong regionHandle, string simrecvkey);
90 90
diff --git a/OpenSim/Framework/Remoting.cs b/OpenSim/Framework/Remoting.cs
index aa7e947..9cf0d11 100644
--- a/OpenSim/Framework/Remoting.cs
+++ b/OpenSim/Framework/Remoting.cs
@@ -38,7 +38,7 @@ namespace OpenSim.Framework
38 /// Suggested implementation 38 /// Suggested implementation
39 /// <para>Store two digests for each foreign host. A local copy of the local hash using the local challenge (when issued), and a local copy of the remote hash using the remote challenge.</para> 39 /// <para>Store two digests for each foreign host. A local copy of the local hash using the local challenge (when issued), and a local copy of the remote hash using the remote challenge.</para>
40 /// <para>When sending data to the foreign host - run 'Sign' on the data and affix the returned byte[] to the message.</para> 40 /// <para>When sending data to the foreign host - run 'Sign' on the data and affix the returned byte[] to the message.</para>
41 /// <para>When recieving data from the foreign host - run 'Authenticate' against the data and the attached byte[].</para> 41 /// <para>When receiving data from the foreign host - run 'Authenticate' against the data and the attached byte[].</para>
42 /// <para>Both hosts should be performing these operations for this to be effective.</para> 42 /// <para>Both hosts should be performing these operations for this to be effective.</para>
43 /// </remarks> 43 /// </remarks>
44 internal class RemoteDigest 44 internal class RemoteDigest
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index a8eef51..740f527 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -373,5 +373,15 @@ namespace OpenSim.Framework
373 config.Configs[(string) row[0]].Set(row.Table.Columns[i].ColumnName, row[i]); 373 config.Configs[(string) row[0]].Set(row.Table.Columns[i].ColumnName, row[i]);
374 } 374 }
375 } 375 }
376
377 public static float Clip(float x, float min, float max)
378 {
379 return Math.Min(Math.Max(x, min), max);
380 }
381
382 public static int Clip(int x, int min, int max)
383 {
384 return Math.Min(Math.Max(x, min), max);
385 }
376 } 386 }
377} 387}
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index 3c35270..75c4187 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -102,7 +102,6 @@ namespace OpenSim.Region.ClientStack
102 protected LLVector3 m_startpos; 102 protected LLVector3 m_startpos;
103 protected EndPoint m_userEndPoint; 103 protected EndPoint m_userEndPoint;
104 104
105
106 /* Properties */ 105 /* Properties */
107 public LLUUID SecureSessionId 106 public LLUUID SecureSessionId
108 { 107 {
@@ -181,7 +180,7 @@ namespace OpenSim.Region.ClientStack
181 180
182 // While working on this, the BlockingQueue had me fooled for a bit. 181 // While working on this, the BlockingQueue had me fooled for a bit.
183 // The Blocking queue causes the thread to stop until there's something 182 // The Blocking queue causes the thread to stop until there's something
184 // in it to process. it's an on-purpose threadlock though because 183 // in it to process. It's an on-purpose threadlock though because
185 // without it, the clientloop will suck up all sim resources. 184 // without it, the clientloop will suck up all sim resources.
186 185
187 m_packetQueue = new PacketQueue(); 186 m_packetQueue = new PacketQueue();
@@ -193,7 +192,6 @@ namespace OpenSim.Region.ClientStack
193 m_clientThread.Start(); 192 m_clientThread.Start();
194 } 193 }
195 194
196
197 public void SetDebug(int newDebug) 195 public void SetDebug(int newDebug)
198 { 196 {
199 m_debug = newDebug; 197 m_debug = newDebug;
@@ -236,10 +234,8 @@ namespace OpenSim.Region.ClientStack
236 public void Kick(string message) 234 public void Kick(string message)
237 { 235 {
238 KickUserPacket kupack = new KickUserPacket(); 236 KickUserPacket kupack = new KickUserPacket();
239
240 kupack.UserInfo.AgentID = AgentId; 237 kupack.UserInfo.AgentID = AgentId;
241 kupack.UserInfo.SessionID = SessionId; 238 kupack.UserInfo.SessionID = SessionId;
242
243 kupack.TargetBlock.TargetIP = (uint)0; 239 kupack.TargetBlock.TargetIP = (uint)0;
244 kupack.TargetBlock.TargetPort = (ushort)0; 240 kupack.TargetBlock.TargetPort = (ushort)0;
245 kupack.UserInfo.Reason = Helpers.StringToField(message); 241 kupack.UserInfo.Reason = Helpers.StringToField(message);
@@ -345,7 +341,6 @@ namespace OpenSim.Region.ClientStack
345 QueItem nextPacket = m_packetQueue.Dequeue(); 341 QueItem nextPacket = m_packetQueue.Dequeue();
346 if (nextPacket.Incoming) 342 if (nextPacket.Incoming)
347 { 343 {
348 //is a incoming packet
349 if (nextPacket.Packet.Type != PacketType.AgentUpdate) 344 if (nextPacket.Packet.Type != PacketType.AgentUpdate)
350 { 345 {
351 m_packetsReceived++; 346 m_packetsReceived++;
@@ -532,7 +527,6 @@ namespace OpenSim.Region.ClientStack
532 public event RegionInfoRequest OnRegionInfoRequest; 527 public event RegionInfoRequest OnRegionInfoRequest;
533 public event EstateCovenantRequest OnEstateCovenantRequest; 528 public event EstateCovenantRequest OnEstateCovenantRequest;
534 529
535
536 #region Scene/Avatar to Client 530 #region Scene/Avatar to Client
537 531
538 /// <summary> 532 /// <summary>
@@ -611,7 +605,6 @@ namespace OpenSim.Region.ClientStack
611 SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID); 605 SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID);
612 } 606 }
613 607
614
615 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) 608 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
616 { 609 {
617 ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); 610 ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
@@ -666,7 +659,7 @@ namespace OpenSim.Region.ClientStack
666 659
667 for (int y = 0; y < 16; y++) 660 for (int y = 0; y < 16; y++)
668 { 661 {
669 for (int x = 0; x < 16; x = x + 4) 662 for (int x = 0; x < 16; x += 4)
670 { 663 {
671 patches[0] = x + 0 + y*16; 664 patches[0] = x + 0 + y*16;
672 patches[1] = x + 1 + y*16; 665 patches[1] = x + 1 + y*16;
@@ -766,7 +759,6 @@ namespace OpenSim.Region.ClientStack
766 newSimPack.Info = new CrossedRegionPacket.InfoBlock(); 759 newSimPack.Info = new CrossedRegionPacket.InfoBlock();
767 newSimPack.Info.Position = pos; 760 newSimPack.Info.Position = pos;
768 newSimPack.Info.LookAt = look; 761 newSimPack.Info.LookAt = look;
769 // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
770 newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock(); 762 newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
771 newSimPack.RegionData.RegionHandle = newRegionHandle; 763 newSimPack.RegionData.RegionHandle = newRegionHandle;
772 byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes(); 764 byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
@@ -775,7 +767,6 @@ namespace OpenSim.Region.ClientStack
775 newSimPack.RegionData.SimIP += (uint) byteIP[1] << 8; 767 newSimPack.RegionData.SimIP += (uint) byteIP[1] << 8;
776 newSimPack.RegionData.SimIP += (uint) byteIP[0]; 768 newSimPack.RegionData.SimIP += (uint) byteIP[0];
777 newSimPack.RegionData.SimPort = (ushort) externalIPEndPoint.Port; 769 newSimPack.RegionData.SimPort = (ushort) externalIPEndPoint.Port;
778 //newSimPack.RegionData.SeedCapability = new byte[0];
779 newSimPack.RegionData.SeedCapability = Helpers.StringToField(capsURL); 770 newSimPack.RegionData.SeedCapability = Helpers.StringToField(capsURL);
780 771
781 OutPacket(newSimPack, ThrottleOutPacketType.Task); 772 OutPacket(newSimPack, ThrottleOutPacketType.Task);
@@ -823,7 +814,6 @@ namespace OpenSim.Region.ClientStack
823 teleport.Info.SimAccess = simAccess; 814 teleport.Info.SimAccess = simAccess;
824 815
825 teleport.Info.SeedCapability = Helpers.StringToField(capsURL); 816 teleport.Info.SeedCapability = Helpers.StringToField(capsURL);
826 //teleport.Info.SeedCapability = new byte[0];
827 817
828 IPAddress oIP = newRegionEndPoint.Address; 818 IPAddress oIP = newRegionEndPoint.Address;
829 byte[] byteIP = oIP.GetAddressBytes(); 819 byte[] byteIP = oIP.GetAddressBytes();
@@ -847,7 +837,6 @@ namespace OpenSim.Region.ClientStack
847 TeleportFailedPacket tpFailed = new TeleportFailedPacket(); 837 TeleportFailedPacket tpFailed = new TeleportFailedPacket();
848 tpFailed.Info.AgentID = this.AgentId; 838 tpFailed.Info.AgentID = this.AgentId;
849 tpFailed.Info.Reason = Helpers.StringToField("unknown failure of teleport"); 839 tpFailed.Info.Reason = Helpers.StringToField("unknown failure of teleport");
850
851 OutPacket(tpFailed, ThrottleOutPacketType.Task); 840 OutPacket(tpFailed, ThrottleOutPacketType.Task);
852 } 841 }
853 842
@@ -946,7 +935,6 @@ namespace OpenSim.Region.ClientStack
946 descend.ItemData[i].SaleType = 0; 935 descend.ItemData[i].SaleType = 0;
947 descend.ItemData[i].Type = (sbyte)item.assetType; 936 descend.ItemData[i].Type = (sbyte)item.assetType;
948 descend.ItemData[i].CRC = 937 descend.ItemData[i].CRC =
949
950 Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType, 938 Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType,
951 descend.ItemData[i].InvType, descend.ItemData[i].Type, 939 descend.ItemData[i].InvType, descend.ItemData[i].Type,
952 descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, descend.ItemData[i].SalePrice, 940 descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, descend.ItemData[i].SalePrice,
@@ -1228,7 +1216,7 @@ namespace OpenSim.Region.ClientStack
1228 Console.WriteLine("SunPhase: {0}", phase); 1216 Console.WriteLine("SunPhase: {0}", phase);
1229 SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket(); 1217 SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket();
1230 //viewertime.TimeInfo.SecPerDay = 86400; 1218 //viewertime.TimeInfo.SecPerDay = 86400;
1231 // viewertime.TimeInfo.SecPerYear = 31536000; 1219 //viewertime.TimeInfo.SecPerYear = 31536000;
1232 viewertime.TimeInfo.SecPerDay = 1000; 1220 viewertime.TimeInfo.SecPerDay = 1000;
1233 viewertime.TimeInfo.SecPerYear = 365000; 1221 viewertime.TimeInfo.SecPerYear = 365000;
1234 viewertime.TimeInfo.SunPhase = 1; 1222 viewertime.TimeInfo.SunPhase = 1;
@@ -1252,14 +1240,9 @@ namespace OpenSim.Region.ClientStack
1252 { 1240 {
1253 yValue = yValue - 1.2f; 1241 yValue = yValue - 1.2f;
1254 } 1242 }
1255 if (yValue > 1) 1243
1256 { 1244 yValue = Util.Clip(yValue, 0, 1);
1257 yValue = 1; 1245
1258 }
1259 if (yValue < 0)
1260 {
1261 yValue = 0;
1262 }
1263 if (sunPhase < 14) 1246 if (sunPhase < 14)
1264 { 1247 {
1265 yValue = 1 - yValue; 1248 yValue = 1 - yValue;
diff --git a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
index b027845..2ec4dbe 100644
--- a/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
+++ b/OpenSim/Region/Environment/Scenes/AvatarAppearance.cs
@@ -88,7 +88,6 @@ namespace OpenSim.Region.Environment.Scenes
88 m_textureEntry = GetDefaultTextureEntry(); 88 m_textureEntry = GetDefaultTextureEntry();
89 } 89 }
90 90
91
92 /// <summary> 91 /// <summary>
93 /// 92 ///
94 /// </summary> 93 /// </summary>
@@ -109,7 +108,6 @@ namespace OpenSim.Region.Environment.Scenes
109 // (float)m_visualParams[125] = LegLength 108 // (float)m_visualParams[125] = LegLength
110 m_avatarHeight = (1.50856f + (((float)m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f))) 109 m_avatarHeight = (1.50856f + (((float)m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f)))
111 + (((float)m_visualParams[125] / 255.0f) / 1.5f); 110 + (((float)m_visualParams[125] / 255.0f) / 1.5f);
112
113 } 111 }
114 112
115 /// <summary> 113 /// <summary>
@@ -119,7 +117,7 @@ namespace OpenSim.Region.Environment.Scenes
119 public void SendAppearanceToOtherAgent(ScenePresence avatar) 117 public void SendAppearanceToOtherAgent(ScenePresence avatar)
120 { 118 {
121 avatar.ControllingClient.SendAppearance(m_scenePresenceID, m_visualParams, 119 avatar.ControllingClient.SendAppearance(m_scenePresenceID, m_visualParams,
122 m_textureEntry.ToBytes()); 120 m_textureEntry.ToBytes());
123 } 121 }
124 122
125 public void SetWearable(IClientAPI client, int wearableId, AvatarWearable wearable) 123 public void SetWearable(IClientAPI client, int wearableId, AvatarWearable wearable)
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 91b6463..89701d7 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -1233,25 +1233,37 @@ namespace OpenSim.Region.Environment.Scenes
1233 uint neighbourx = m_regionInfo.RegionLocX; 1233 uint neighbourx = m_regionInfo.RegionLocX;
1234 uint neighboury = m_regionInfo.RegionLocY; 1234 uint neighboury = m_regionInfo.RegionLocY;
1235 1235
1236 if (pos.X < 1.7F) 1236 // distance to edge that will trigger crossing
1237 const float boundaryDistance = 1.7f;
1238
1239 // distance into new region to place avatar
1240 const float enterDistance = 0.1f;
1241
1242 // region size
1243 // TODO: this should be hard-coded in some common place
1244 const float regionWidth = 256;
1245 const float regionHeight = 256;
1246
1247 if (pos.X < boundaryDistance)
1237 { 1248 {
1238 neighbourx -= 1; 1249 neighbourx--;
1239 newpos.X = 255.9F; 1250 newpos.X = regionWidth - enterDistance;
1240 } 1251 }
1241 if (pos.X > 254.3F) 1252 else if (pos.X > regionWidth - boundaryDistance)
1242 { 1253 {
1243 neighbourx += 1; 1254 neighbourx++;
1244 newpos.X = 0.1F; 1255 newpos.X = enterDistance;
1245 } 1256 }
1246 if (pos.Y < 1.7F) 1257
1258 if (pos.Y < boundaryDistance)
1247 { 1259 {
1248 neighboury -= 1; 1260 neighboury--;
1249 newpos.Y = 255.9F; 1261 newpos.Y = regionHeight - enterDistance;
1250 } 1262 }
1251 if (pos.Y > 254.3F) 1263 else if (pos.Y > regionHeight - boundaryDistance)
1252 { 1264 {
1253 neighboury += 1; 1265 neighboury++;
1254 newpos.Y = 0.1F; 1266 newpos.Y = enterDistance;
1255 } 1267 }
1256 1268
1257 LLVector3 vel = m_velocity; 1269 LLVector3 vel = m_velocity;
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index df3ebb9..545f461 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -125,8 +125,9 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
125 { 125 {
126 BasicActor actor = _actors[i]; 126 BasicActor actor = _actors[i];
127 127
128 actor.Position.X = actor.Position.X + (actor.Velocity.X*timeStep); 128 actor.Position.X += actor.Velocity.X * timeStep;
129 actor.Position.Y = actor.Position.Y + (actor.Velocity.Y*timeStep); 129 actor.Position.Y += actor.Velocity.Y * timeStep;
130
130 if (actor.Position.Y < 0) 131 if (actor.Position.Y < 0)
131 { 132 {
132 actor.Position.Y = 0.1F; 133 actor.Position.Y = 0.1F;
@@ -145,18 +146,18 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
145 actor.Position.X = 255.9F; 146 actor.Position.X = 255.9F;
146 } 147 }
147 148
148 float height = _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 1.0f; 149 float height = _heightMap[(int) actor.Position.Y * 256 + (int) actor.Position.X] + 1.0f;
149 if (actor.Flying) 150 if (actor.Flying)
150 { 151 {
151 if (actor.Position.Z + (actor.Velocity.Z*timeStep) < 152 if (actor.Position.Z + (actor.Velocity.Z * timeStep) <
152 _heightMap[(int) actor.Position.Y*256 + (int) actor.Position.X] + 2) 153 _heightMap[(int) actor.Position.Y * 256 + (int) actor.Position.X] + 2)
153 { 154 {
154 actor.Position.Z = height; 155 actor.Position.Z = height;
155 actor.Velocity.Z = 0; 156 actor.Velocity.Z = 0;
156 } 157 }
157 else 158 else
158 { 159 {
159 actor.Position.Z = actor.Position.Z + (actor.Velocity.Z*timeStep); 160 actor.Position.Z += actor.Velocity.Z * timeStep;
160 } 161 }
161 } 162 }
162 else 163 else
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 0cbd4d6..305a930 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -75,6 +75,10 @@ namespace OpenSim.Region.Physics.OdePlugin
75 75
76 public class OdeScene : PhysicsScene 76 public class OdeScene : PhysicsScene
77 { 77 {
78 // TODO: this should be hard-coded in some common place
79 private const uint m_regionWidth = 256;
80 private const uint m_regionHeight = 256;
81
78 private static float ODE_STEPSIZE = 0.004f; 82 private static float ODE_STEPSIZE = 0.004f;
79 private static bool RENDER_FLAG = false; 83 private static bool RENDER_FLAG = false;
80 private static float metersInSpace = 29.9f; 84 private static float metersInSpace = 29.9f;
@@ -167,12 +171,9 @@ namespace OpenSim.Region.Physics.OdePlugin
167 171
168 } 172 }
169 173
170
171
172 public override void Initialise(IMesher meshmerizer) 174 public override void Initialise(IMesher meshmerizer)
173 { 175 {
174 mesher = meshmerizer; 176 mesher = meshmerizer;
175
176 } 177 }
177 178
178 public string whichspaceamIin(PhysicsVector pos) 179 public string whichspaceamIin(PhysicsVector pos)
@@ -196,7 +197,6 @@ namespace OpenSim.Region.Physics.OdePlugin
196 //Collide all geoms in each space.. 197 //Collide all geoms in each space..
197 //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback); 198 //if (d.GeomIsSpace(g1)) d.SpaceCollide(g1, IntPtr.Zero, nearCallback);
198 //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback); 199 //if (d.GeomIsSpace(g2)) d.SpaceCollide(g2, IntPtr.Zero, nearCallback);
199
200 } 200 }
201 else 201 else
202 { 202 {
@@ -206,14 +206,12 @@ namespace OpenSim.Region.Physics.OdePlugin
206 IntPtr b1 = d.GeomGetBody(g1); 206 IntPtr b1 = d.GeomGetBody(g1);
207 IntPtr b2 = d.GeomGetBody(g2); 207 IntPtr b2 = d.GeomGetBody(g2);
208 208
209
210 if (g1 == g2) 209 if (g1 == g2)
211 return; // Can't collide with yourself 210 return; // Can't collide with yourself
212 211
213 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) 212 if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
214 return; 213 return;
215 214
216
217 d.GeomClassID id = d.GeomGetClass(g1); 215 d.GeomClassID id = d.GeomGetClass(g1);
218 216
219 String name1 = null; 217 String name1 = null;
@@ -230,8 +228,6 @@ namespace OpenSim.Region.Physics.OdePlugin
230 228
231 if (id == d.GeomClassID.TriMeshClass) 229 if (id == d.GeomClassID.TriMeshClass)
232 { 230 {
233
234
235 // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2); 231 // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2);
236 //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); 232 //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2);
237 } 233 }
@@ -297,8 +293,6 @@ namespace OpenSim.Region.Physics.OdePlugin
297 TerrainContact.geom = contacts[i]; 293 TerrainContact.geom = contacts[i];
298 joint = d.JointCreateContact(world, contactgroup, ref TerrainContact); 294 joint = d.JointCreateContact(world, contactgroup, ref TerrainContact);
299 } 295 }
300
301
302 } 296 }
303 else 297 else
304 { 298 {
@@ -311,9 +305,7 @@ namespace OpenSim.Region.Physics.OdePlugin
311 { 305 {
312 contact.geom = contacts[i]; 306 contact.geom = contacts[i];
313 joint = d.JointCreateContact(world, contactgroup, ref contact); 307 joint = d.JointCreateContact(world, contactgroup, ref contact);
314
315 } 308 }
316
317 } 309 }
318 310
319 311
@@ -333,17 +325,12 @@ namespace OpenSim.Region.Physics.OdePlugin
333 325
334 private void collision_optimized(float timeStep) 326 private void collision_optimized(float timeStep)
335 { 327 {
336
337 foreach (OdeCharacter chr in _characters) 328 foreach (OdeCharacter chr in _characters)
338 { 329 {
339
340
341 chr.IsColliding = false; 330 chr.IsColliding = false;
342 chr.CollidingGround = false; 331 chr.CollidingGround = false;
343 chr.CollidingObj = false; 332 chr.CollidingObj = false;
344 d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback); 333 d.SpaceCollide2(space, chr.Shell, IntPtr.Zero, nearCallback);
345
346
347 } 334 }
348 // If the sim is running slow this frame, 335 // If the sim is running slow this frame,
349 // don't process collision for prim! 336 // don't process collision for prim!
@@ -422,11 +409,11 @@ namespace OpenSim.Region.Physics.OdePlugin
422 } 409 }
423 } 410 }
424 } 411 }
412
425 public void RemovePrimThreadLocked(OdePrim prim) 413 public void RemovePrimThreadLocked(OdePrim prim)
426 { 414 {
427 lock (OdeLock) 415 lock (OdeLock)
428 { 416 {
429
430 if (prim.IsPhysical) 417 if (prim.IsPhysical)
431 { 418 {
432 prim.disableBody(); 419 prim.disableBody();
@@ -479,6 +466,7 @@ namespace OpenSim.Region.Physics.OdePlugin
479 } 466 }
480 467
481 } 468 }
469
482 public void resetSpaceArrayItemToZero(IntPtr space) 470 public void resetSpaceArrayItemToZero(IntPtr space)
483 { 471 {
484 for (int x = 0; x < staticPrimspace.GetLength(0); x++) 472 for (int x = 0; x < staticPrimspace.GetLength(0); x++)
@@ -490,6 +478,7 @@ namespace OpenSim.Region.Physics.OdePlugin
490 } 478 }
491 } 479 }
492 } 480 }
481
493 public void resetSpaceArrayItemToZero(int arrayitemX,int arrayitemY) 482 public void resetSpaceArrayItemToZero(int arrayitemX,int arrayitemY)
494 { 483 {
495 staticPrimspace[arrayitemX, arrayitemY] = IntPtr.Zero; 484 staticPrimspace[arrayitemX, arrayitemY] = IntPtr.Zero;
@@ -524,6 +513,7 @@ namespace OpenSim.Region.Physics.OdePlugin
524 if (!(sGeomIsIn.Equals(null))) 513 if (!(sGeomIsIn.Equals(null)))
525 { 514 {
526 if (sGeomIsIn != (IntPtr)0) 515 if (sGeomIsIn != (IntPtr)0)
516 {
527 if (d.GeomIsSpace(currentspace)) 517 if (d.GeomIsSpace(currentspace))
528 { 518 {
529 d.SpaceRemove(sGeomIsIn, geom); 519 d.SpaceRemove(sGeomIsIn, geom);
@@ -532,6 +522,7 @@ namespace OpenSim.Region.Physics.OdePlugin
532 { 522 {
533 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); 523 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + sGeomIsIn.ToString() + " Geom:" + geom.ToString());
534 } 524 }
525 }
535 } 526 }
536 } 527 }
537 528
@@ -586,7 +577,6 @@ namespace OpenSim.Region.Physics.OdePlugin
586 else 577 else
587 { 578 {
588 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); 579 MainLog.Instance.Verbose("Physics", "Invalid Scene passed to 'recalculatespace':" + sGeomIsIn.ToString() + " Geom:" + geom.ToString());
589
590 } 580 }
591 } 581 }
592 } 582 }
@@ -625,6 +615,7 @@ namespace OpenSim.Region.Physics.OdePlugin
625 //locationbasedspace = space; 615 //locationbasedspace = space;
626 return locationbasedspace; 616 return locationbasedspace;
627 } 617 }
618
628 public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos) 619 public int[] calculateSpaceArrayItemFromPos(PhysicsVector pos)
629 { 620 {
630 int[] returnint = new int[2]; 621 int[] returnint = new int[2];
@@ -682,7 +673,7 @@ namespace OpenSim.Region.Physics.OdePlugin
682 } 673 }
683 674
684 public void addActivePrim(OdePrim activatePrim) 675 public void addActivePrim(OdePrim activatePrim)
685 { 676 {
686 // adds active prim.. (ones that should be iterated over in collisions_optimized 677 // adds active prim.. (ones that should be iterated over in collisions_optimized
687 678
688 _activeprims.Add(activatePrim); 679 _activeprims.Add(activatePrim);
@@ -902,17 +893,18 @@ namespace OpenSim.Region.Physics.OdePlugin
902 get { return (false); // for now we won't be multithreaded 893 get { return (false); // for now we won't be multithreaded
903 } 894 }
904 } 895 }
896
905 public float[] ResizeTerrain512(float[] heightMap) 897 public float[] ResizeTerrain512(float[] heightMap)
906 { 898 {
907 float[] returnarr = new float[262144]; 899 float[] returnarr = new float[262144];
908 float[,] resultarr = new float[256, 256]; 900 float[,] resultarr = new float[m_regionWidth, m_regionHeight];
909 901
910 // Filling out the array into it's multi-dimentional components 902 // Filling out the array into it's multi-dimentional components
911 for (int y = 0; y < 256; y++) 903 for (int y = 0; y < m_regionHeight; y++)
912 { 904 {
913 for (int x = 0; x < 256; x++) 905 for (int x = 0; x < m_regionWidth; x++)
914 { 906 {
915 resultarr[y,x] = heightMap[y * 256 + x]; 907 resultarr[y,x] = heightMap[y * m_regionWidth + x];
916 } 908 }
917 } 909 }
918 910
@@ -976,17 +968,17 @@ namespace OpenSim.Region.Physics.OdePlugin
976 // on single loop. 968 // on single loop.
977 969
978 float[,] resultarr2 = new float[512, 512]; 970 float[,] resultarr2 = new float[512, 512];
979 for (int y = 0; y < 256; y++) 971 for (int y = 0; y < m_regionHeight; y++)
980 { 972 {
981 for (int x = 0; x < 256; x++) 973 for (int x = 0; x < m_regionWidth; x++)
982 { 974 {
983 resultarr2[y*2,x*2] = resultarr[y,x]; 975 resultarr2[y*2,x*2] = resultarr[y,x];
984 976
985 if (y < 256) 977 if (y < m_regionHeight)
986 { 978 {
987 if (y + 1 < 256) 979 if (y + 1 < m_regionHeight)
988 { 980 {
989 if (x + 1 < 256) 981 if (x + 1 < m_regionWidth)
990 { 982 {
991 resultarr2[(y * 2) + 1, x * 2] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x+1] + resultarr[y+1, x+1])/4); 983 resultarr2[(y * 2) + 1, x * 2] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x+1] + resultarr[y+1, x+1])/4);
992 } 984 }
@@ -1000,11 +992,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1000 resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x]; 992 resultarr2[(y * 2) + 1, x * 2] = resultarr[y, x];
1001 } 993 }
1002 } 994 }
1003 if (x < 256) 995 if (x < m_regionWidth)
1004 { 996 {
1005 if (x + 1 < 256) 997 if (x + 1 < m_regionWidth)
1006 { 998 {
1007 if (y + 1 < 256) 999 if (y + 1 < m_regionHeight)
1008 { 1000 {
1009 resultarr2[y * 2, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x + 1] + resultarr[y + 1, x + 1]) / 4); 1001 resultarr2[y * 2, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x + 1] + resultarr[y + 1, x + 1]) / 4);
1010 } 1002 }
@@ -1018,9 +1010,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1018 resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x]; 1010 resultarr2[y * 2, (x * 2) + 1] = resultarr[y, x];
1019 } 1011 }
1020 } 1012 }
1021 if (x < 256 && y < 256) 1013 if (x < m_regionWidth && y < m_regionHeight)
1022 { 1014 {
1023 if ((x + 1 < 256) && (y + 1 < 256)) 1015 if ((x + 1 < m_regionWidth) && (y + 1 < m_regionHeight))
1024 { 1016 {
1025 resultarr2[(y * 2) + 1, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x + 1] + resultarr[y + 1, x + 1]) / 4); 1017 resultarr2[(y * 2) + 1, (x * 2) + 1] = ((resultarr[y, x] + resultarr[y + 1, x] + resultarr[y, x + 1] + resultarr[y + 1, x + 1]) / 4);
1026 } 1018 }
@@ -1052,21 +1044,26 @@ namespace OpenSim.Region.Physics.OdePlugin
1052 // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...) 1044 // dbm (danx0r) -- heightmap x,y must be swapped for Ode (should fix ODE, but for now...)
1053 // also, creating a buffer zone of one extra sample all around 1045 // also, creating a buffer zone of one extra sample all around
1054 1046
1047 const uint heightmapWidth = m_regionWidth + 2;
1048 const uint heightmapHeight = m_regionHeight + 2;
1049 const uint heightmapWidthSamples = 2 * m_regionWidth + 2;
1050 const uint heightmapHeightSamples = 2 * m_regionHeight + 2;
1051 const float scale = 1.0f;
1052 const float offset = 0.0f;
1053 const float thickness = 2.0f;
1054 const int wrap = 0;
1055
1055 //Double resolution 1056 //Double resolution
1056 heightMap = ResizeTerrain512(heightMap); 1057 heightMap = ResizeTerrain512(heightMap);
1057 for (int x = 0; x < 514; x++) 1058 for (int x = 0; x < heightmapWidthSamples; x++)
1058 { 1059 {
1059 for (int y = 0; y < 514; y++) 1060 for (int y = 0; y < heightmapHeightSamples; y++)
1060 { 1061 {
1061 int xx = x - 1; 1062 int xx = Util.Clip(x - 1, 0, 511);
1062 if (xx < 0) xx = 0; 1063 int yy = Util.Clip(y - 1, 0, 511);
1063 if (xx > 511) xx = 511;
1064 int yy = y - 1;
1065 if (yy < 0) yy = 0;
1066 if (yy > 511) yy = 511;
1067 1064
1068 double val = (double) heightMap[yy*512 + xx]; 1065 double val = (double) heightMap[yy*512 + xx];
1069 _heightmap[x*514 + y] = val; 1066 _heightmap[x*heightmapHeightSamples + y] = val;
1070 } 1067 }
1071 } 1068 }
1072 1069
@@ -1077,8 +1074,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1077 d.SpaceRemove(space, LandGeom); 1074 d.SpaceRemove(space, LandGeom);
1078 } 1075 }
1079 IntPtr HeightmapData = d.GeomHeightfieldDataCreate(); 1076 IntPtr HeightmapData = d.GeomHeightfieldDataCreate();
1080 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, 258, 258, 514, 514, 1.0f, 0.0f, 2.0f, 0); 1077 d.GeomHeightfieldDataBuildDouble(HeightmapData, _heightmap, 0, heightmapWidth, heightmapHeight,
1081 d.GeomHeightfieldDataSetBounds(HeightmapData, 256, 256); 1078 (int) heightmapWidthSamples, (int) heightmapHeightSamples, scale, offset, thickness, wrap);
1079 d.GeomHeightfieldDataSetBounds(HeightmapData, m_regionWidth, m_regionHeight);
1082 LandGeom = d.CreateHeightfield(space, HeightmapData, 1); 1080 LandGeom = d.CreateHeightfield(space, HeightmapData, 1);
1083 geom_name_map[LandGeom] = "Terrain"; 1081 geom_name_map[LandGeom] = "Terrain";
1084 1082
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
index efc30fe..a565598 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs
@@ -166,7 +166,6 @@ namespace OpenSim.Region.Physics.POSPlugin
166 166
167 public override void AddPhysicsActorTaint(PhysicsActor prim) 167 public override void AddPhysicsActorTaint(PhysicsActor prim)
168 { 168 {
169
170 } 169 }
171 170
172 public override float Simulate(float timeStep) 171 public override float Simulate(float timeStep)
@@ -187,8 +186,8 @@ namespace OpenSim.Region.Physics.POSPlugin
187 } 186 }
188 187
189 bool forcedZ = false; 188 bool forcedZ = false;
190 character.Position.X = character.Position.X + (character._target_velocity.X * timeStep); 189 character.Position.X += character._target_velocity.X * timeStep;
191 character.Position.Y = character.Position.Y + (character._target_velocity.Y * timeStep); 190 character.Position.Y += character._target_velocity.Y * timeStep;
192 191
193 if (character.Position.Y < 0) 192 if (character.Position.Y < 0)
194 { 193 {
@@ -216,7 +215,7 @@ namespace OpenSim.Region.Physics.POSPlugin
216 } 215 }
217 else 216 else
218 { 217 {
219 character.Position.Z = character.Position.Z + (character._target_velocity.Z * timeStep); 218 character.Position.Z += character._target_velocity.Z * timeStep;
220 } 219 }
221 220
222 /// this is it -- the magic you've all been waiting for! Ladies and gentlemen -- 221 /// this is it -- the magic you've all been waiting for! Ladies and gentlemen --
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
index 136b613..3a0b8ed 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
@@ -60,20 +60,22 @@ namespace OpenSim.Region.ScriptEngine.Common
60 { 60 {
61 return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ">"; 61 return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ">";
62 } 62 }
63
63 public static bool operator ==(Vector3 lhs, Vector3 rhs) 64 public static bool operator ==(Vector3 lhs, Vector3 rhs)
64 { 65 {
65 return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); 66 return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z);
66 } 67 }
68
67 public static bool operator !=(Vector3 lhs, Vector3 rhs) 69 public static bool operator !=(Vector3 lhs, Vector3 rhs)
68 { 70 {
69 return !(lhs == rhs); 71 return !(lhs == rhs);
70 } 72 }
73
71 public override int GetHashCode() 74 public override int GetHashCode()
72 { 75 {
73 return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode()); 76 return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode());
74 } 77 }
75 78
76
77 public override bool Equals(object o) 79 public override bool Equals(object o)
78 { 80 {
79 if (!(o is Vector3)) return false; 81 if (!(o is Vector3)) return false;
@@ -91,10 +93,12 @@ namespace OpenSim.Region.ScriptEngine.Common
91 { 93 {
92 return new Vector3(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); 94 return new Vector3(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
93 } 95 }
96
94 public static Vector3 operator -(Vector3 lhs, Vector3 rhs) 97 public static Vector3 operator -(Vector3 lhs, Vector3 rhs)
95 { 98 {
96 return new Vector3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); 99 return new Vector3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);
97 } 100 }
101
98 public static Vector3 operator *(Vector3 lhs, Vector3 rhs) 102 public static Vector3 operator *(Vector3 lhs, Vector3 rhs)
99 { 103 {
100 return new Vector3(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z); 104 return new Vector3(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z);
@@ -145,6 +149,7 @@ namespace OpenSim.Region.ScriptEngine.Common
145 149
146 return new Vector3(result.x, result.y, result.z); 150 return new Vector3(result.x, result.y, result.z);
147 } 151 }
152
148 // I *think* this is how it works.... 153 // I *think* this is how it works....
149 public static Vector3 operator /(Vector3 vec, Quaternion quat) 154 public static Vector3 operator /(Vector3 vec, Quaternion quat)
150 { 155 {
@@ -163,6 +168,7 @@ namespace OpenSim.Region.ScriptEngine.Common
163 { 168 {
164 return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); 169 return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z);
165 } 170 }
171
166 public static Vector3 Cross(Vector3 v1, Vector3 v2) 172 public static Vector3 Cross(Vector3 v1, Vector3 v2)
167 { 173 {
168 return new Vector3 174 return new Vector3
@@ -172,10 +178,12 @@ namespace OpenSim.Region.ScriptEngine.Common
172 v1.x * v2.y - v1.y * v2.x 178 v1.x * v2.y - v1.y * v2.x
173 ); 179 );
174 } 180 }
181
175 public static float Mag(Vector3 v) 182 public static float Mag(Vector3 v)
176 { 183 {
177 return (float)Math.Sqrt(v.x * v.y + v.y * v.y + v.z * v.z); 184 return (float)Math.Sqrt(v.x * v.y + v.y * v.y + v.z * v.z);
178 } 185 }
186
179 public static Vector3 Norm(Vector3 vector) 187 public static Vector3 Norm(Vector3 vector)
180 { 188 {
181 float mag = Mag(vector); 189 float mag = Mag(vector);
@@ -215,7 +223,6 @@ namespace OpenSim.Region.ScriptEngine.Common
215 return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode() ^ s.GetHashCode()); 223 return (x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode() ^ s.GetHashCode());
216 } 224 }
217 225
218
219 public override bool Equals(object o) 226 public override bool Equals(object o)
220 { 227 {
221 if (!(o is Quaternion)) return false; 228 if (!(o is Quaternion)) return false;
@@ -224,6 +231,7 @@ namespace OpenSim.Region.ScriptEngine.Common
224 231
225 return x == quaternion.x && y == quaternion.y && z == quaternion.z && s == quaternion.s; 232 return x == quaternion.x && y == quaternion.y && z == quaternion.z && s == quaternion.s;
226 } 233 }
234
227 public override string ToString() 235 public override string ToString()
228 { 236 {
229 return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ", " + s.ToString() + ">"; 237 return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ", " + s.ToString() + ">";
@@ -257,19 +265,23 @@ namespace OpenSim.Region.ScriptEngine.Common
257 public class list 265 public class list
258 { 266 {
259 private object[] m_data; 267 private object[] m_data;
268
260 public list(params object[] args) 269 public list(params object[] args)
261 { 270 {
262 m_data = new object[args.Length]; 271 m_data = new object[args.Length];
263 m_data = args; 272 m_data = args;
264 } 273 }
274
265 public int Length 275 public int Length
266 { 276 {
267 get { return m_data.Length; } 277 get { return m_data.Length; }
268 } 278 }
279
269 public object[] Data 280 public object[] Data
270 { 281 {
271 get { return m_data; } 282 get { return m_data; }
272 } 283 }
284
273 public static list operator +(list a, list b) 285 public static list operator +(list a, list b)
274 { 286 {
275 object[] tmp; 287 object[] tmp;
@@ -278,6 +290,7 @@ namespace OpenSim.Region.ScriptEngine.Common
278 b.Data.CopyTo(tmp, a.Length); 290 b.Data.CopyTo(tmp, a.Length);
279 return new list(tmp); 291 return new list(tmp);
280 } 292 }
293
281 public list GetSublist(int start, int end) 294 public list GetSublist(int start, int end)
282 { 295 {
283 Console.WriteLine("GetSublist(" + start.ToString() + "," + end.ToString() + ")"); 296 Console.WriteLine("GetSublist(" + start.ToString() + "," + end.ToString() + ")");
@@ -292,8 +305,7 @@ namespace OpenSim.Region.ScriptEngine.Common
292 end = m_data.Length + end; 305 end = m_data.Length + end;
293 } 306 }
294 307
295 // Case start < end 308 // Case start <= end
296
297 if (start <= end) 309 if (start <= end)
298 { 310 {
299 if (start >= m_data.Length) 311 if (start >= m_data.Length)
@@ -350,6 +362,7 @@ namespace OpenSim.Region.ScriptEngine.Common
350 output = output + "]"; 362 output = output + "]";
351 return output; 363 return output;
352 } 364 }
365
353 public override string ToString() 366 public override string ToString()
354 { 367 {
355 string output; 368 string output;
@@ -366,5 +379,4 @@ namespace OpenSim.Region.ScriptEngine.Common
366 } 379 }
367 } 380 }
368 } 381 }
369
370} 382}