aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2016-08-04 06:14:46 +0100
committerUbitUmarov2016-08-04 06:14:46 +0100
commit4c7b2b2ed7e98b4a3af9198c61c5cf0710c71132 (patch)
treeb194c39b10f0a08e4a95fad28bc963343cf1b3a2 /OpenSim/Region
parentMerge branch 'master' into httptests (diff)
parentlet get by handle also search on inner lookup table (diff)
downloadopensim-SC-4c7b2b2ed7e98b4a3af9198c61c5cf0710c71132.zip
opensim-SC-4c7b2b2ed7e98b4a3af9198c61c5cf0710c71132.tar.gz
opensim-SC-4c7b2b2ed7e98b4a3af9198c61c5cf0710c71132.tar.bz2
opensim-SC-4c7b2b2ed7e98b4a3af9198c61c5cf0710c71132.tar.xz
Merge branch 'master' into httptests
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs272
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs30
3 files changed, 298 insertions, 21 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs
index 6db9515..5eb525b 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs
@@ -27,6 +27,7 @@
27using System; 27using System;
28using System.Reflection; 28using System.Reflection;
29using System.Threading; 29using System.Threading;
30using System.Runtime.InteropServices;
30using System.Collections.Generic; 31using System.Collections.Generic;
31using OpenSim.Framework; 32using OpenSim.Framework;
32using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
@@ -159,15 +160,147 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
159 } 160 }
160 } 161 }
161 162
163 // dont care about endianess
164 [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 8)]
165 public class fastRegionHandle
166 {
167 [FieldOffset(0)] public ulong handle;
168 [FieldOffset(0)] public uint y;
169 [FieldOffset(4)] public uint x;
170
171 public fastRegionHandle(ulong h)
172 {
173 handle = h;
174 }
175
176 public fastRegionHandle(uint px, uint py)
177 {
178 y = py & 0xffffff00;
179 x = px & 0xffffff00;
180 }
181 // actually do care
182 public ulong toHandle()
183 {
184 if(BitConverter.IsLittleEndian)
185 return handle;
186 return (ulong) x << 32 | (ulong)y ;
187 }
188
189 public static bool operator ==(fastRegionHandle value1, fastRegionHandle value2)
190 {
191 return value1.handle == value2.handle;
192 }
193 public static bool operator !=(fastRegionHandle value1, fastRegionHandle value2)
194 {
195 return value1.handle != value2.handle;
196 }
197 public override int GetHashCode()
198 {
199 return handle.GetHashCode();
200 }
201 public override bool Equals(Object obj)
202 {
203 if(obj == null)
204 return false;
205 fastRegionHandle p = obj as fastRegionHandle;
206 return p.handle == handle;
207 }
208 }
209
210/*
211 [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 8)]
212 public class regionHandle
213 {
214 [FieldOffset(0)] private ulong handle;
215 [FieldOffset(0)] public uint a;
216 [FieldOffset(4)] public uint b;
217
218 public regionHandle(ulong h)
219 {
220 handle = h;
221 }
222
223 public regionHandle(uint px, uint py)
224 {
225 if(BitConverter.IsLittleEndian)
226 {
227 a = py & 0xffffff00;
228 b = px & 0xffffff00;
229 }
230 else
231 {
232 a = px & 0xffffff00;
233 b = py & 0xffffff00;
234 }
235 }
236
237 public uint x
238 {
239 get
240 {
241 if(BitConverter.IsLittleEndian)
242 return b;
243 return a;
244 }
245 set
246 {
247 if(BitConverter.IsLittleEndian)
248 b = value & 0xffffff00;
249 else
250 a = value & 0xffffff00;
251 }
252 }
253
254 public uint y
255 {
256 get
257 {
258 if(BitConverter.IsLittleEndian)
259 return a;
260 return b;
261 }
262 set
263 {
264 if(BitConverter.IsLittleEndian)
265 a = value;
266 else
267 b = value;
268 }
269 }
270
271 public static bool operator ==(regionHandle value1, regionHandle value2)
272 {
273 return value1.handle == value2.handle;
274 }
275 public static bool operator !=(regionHandle value1, regionHandle value2)
276 {
277 return value1.handle != value2.handle;
278 }
279 public override int GetHashCode()
280 {
281 return handle.GetHashCode();
282 }
283 public override bool Equals(Object obj)
284 {
285 if(obj == null)
286 return false;
287 regionHandle p = obj as regionHandle;
288 return p.handle == handle;
289 }
290 }
291*/
292
162 public class RegionInfoForScope 293 public class RegionInfoForScope
163 { 294 {
164 public const ulong HANDLEMASH = 0xffffff00ffffff00ul; 295 public const ulong HANDLEMASK = 0xffffff00ffffff00ul;
165 public const ulong HANDLECOORDMASH = 0xffffff00ul; 296 public const ulong HANDLECOORDMASK = 0xffffff00ul;
166 297
167 private Dictionary<ulong, GridRegion> storage; 298 private Dictionary<ulong, GridRegion> storage;
168 private Dictionary<ulong, DateTime> expires; 299 private Dictionary<ulong, DateTime> expires;
169 private Dictionary<string, ulong> byname; 300 private Dictionary<string, ulong> byname;
170 private Dictionary<UUID, ulong> byuuid; 301 private Dictionary<UUID, ulong> byuuid;
302 // includes handles to the inside of large regions
303 private Dictionary<ulong, ulong> innerHandles = new Dictionary<ulong, ulong>();
171 304
172 public RegionInfoForScope() 305 public RegionInfoForScope()
173 { 306 {
@@ -184,16 +317,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
184 byname = new Dictionary<string, ulong>(); 317 byname = new Dictionary<string, ulong>();
185 byuuid = new Dictionary<UUID, ulong>(); 318 byuuid = new Dictionary<UUID, ulong>();
186 319
187 ulong handle = region.RegionHandle & HANDLEMASH; 320 ulong handle = region.RegionHandle & HANDLEMASK;
188 storage[handle] = region; 321 storage[handle] = region;
189 expires[handle] = expire; 322 expires[handle] = expire;
190 byname[region.RegionName] = handle; 323 byname[region.RegionName] = handle;
191 byuuid[region.RegionID] = handle; 324 byuuid[region.RegionID] = handle;
325 addToInner(region);
192 } 326 }
193 327
194 public void Add(GridRegion region, DateTime expire) 328 public void Add(GridRegion region, DateTime expire)
195 { 329 {
196 ulong handle = region.RegionHandle & HANDLEMASH; 330 ulong handle = region.RegionHandle & HANDLEMASK;
197 331
198 if(storage != null && storage.ContainsKey(handle)) 332 if(storage != null && storage.ContainsKey(handle))
199 return; 333 return;
@@ -211,6 +345,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
211 expires[handle] = expire; 345 expires[handle] = expire;
212 byname[region.RegionName] = handle; 346 byname[region.RegionName] = handle;
213 byuuid[region.RegionID] = handle; 347 byuuid[region.RegionID] = handle;
348
349 addToInner(region);
214 } 350 }
215 351
216 public void AddUpdate(GridRegion region, DateTime expire) 352 public void AddUpdate(GridRegion region, DateTime expire)
@@ -224,18 +360,32 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
224 if(byuuid == null) 360 if(byuuid == null)
225 byuuid = new Dictionary<UUID, ulong>(); 361 byuuid = new Dictionary<UUID, ulong>();
226 362
227 ulong handle = region.RegionHandle & HANDLEMASH; 363 ulong handle = region.RegionHandle & HANDLEMASK;
228 364
229 storage[handle] = region;
230 if(expires.ContainsKey(handle)) 365 if(expires.ContainsKey(handle))
231 { 366 {
232 if(expires[handle] < expire) 367 if(expires[handle] < expire)
233 expires[handle] = expire; 368 expires[handle] = expire;
369 if(storage.ContainsKey(handle))
370 {
371 GridRegion oldr = storage[handle];
372 if (oldr.RegionSizeX != region.RegionSizeX
373 || oldr.RegionSizeY != region.RegionSizeY)
374 {
375 removeFromInner(oldr);
376 addToInner(region);
377 }
378 }
234 } 379 }
235 else 380 else
236 expires[handle] = expire; 381 {
382 expires[handle] = expire;
383 addToInner(region);
384 }
385 storage[handle] = region;
237 byname[region.RegionName] = handle; 386 byname[region.RegionName] = handle;
238 byuuid[region.RegionID] = handle; 387 byuuid[region.RegionID] = handle;
388
239 } 389 }
240 390
241 public void Remove(GridRegion region) 391 public void Remove(GridRegion region)
@@ -248,9 +398,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
248 if(byuuid != null) 398 if(byuuid != null)
249 byuuid.Remove(region.RegionID); 399 byuuid.Remove(region.RegionID);
250 400
251 ulong handle = region.RegionHandle & HANDLEMASH; 401 ulong handle = region.RegionHandle & HANDLEMASK;
252 if(storage != null) 402 if(storage != null)
253 storage.Remove(handle); 403 storage.Remove(handle);
404 removeFromInner(region);
254 if(expires != null) 405 if(expires != null)
255 { 406 {
256 expires.Remove(handle); 407 expires.Remove(handle);
@@ -261,7 +412,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
261 412
262 public void Remove(ulong handle) 413 public void Remove(ulong handle)
263 { 414 {
264 handle &= HANDLEMASH; 415 handle &= HANDLEMASK;
265 416
266 if(storage != null) 417 if(storage != null)
267 { 418 {
@@ -272,6 +423,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
272 byname.Remove(r.RegionName); 423 byname.Remove(r.RegionName);
273 if(byuuid != null) 424 if(byuuid != null)
274 byuuid.Remove(r.RegionID); 425 byuuid.Remove(r.RegionID);
426 removeFromInner(r);
275 } 427 }
276 storage.Remove(handle); 428 storage.Remove(handle);
277 } 429 }
@@ -297,6 +449,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
297 byuuid = null; 449 byuuid = null;
298 storage = null; 450 storage = null;
299 expires = null; 451 expires = null;
452 innerHandles.Clear();
300 } 453 }
301 454
302 public bool Contains(GridRegion region) 455 public bool Contains(GridRegion region)
@@ -306,7 +459,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
306 if(region == null) 459 if(region == null)
307 return false; 460 return false;
308 461
309 ulong handle = region.RegionHandle & HANDLEMASH; 462 ulong handle = region.RegionHandle & HANDLEMASK;
310 return storage.ContainsKey(handle); 463 return storage.ContainsKey(handle);
311 } 464 }
312 465
@@ -315,7 +468,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
315 if(storage == null) 468 if(storage == null)
316 return false; 469 return false;
317 470
318 handle &= HANDLEMASH; 471 handle &= HANDLEMASK;
319 return storage.ContainsKey(handle); 472 return storage.ContainsKey(handle);
320 } 473 }
321 474
@@ -324,10 +477,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
324 if(storage == null) 477 if(storage == null)
325 return null; 478 return null;
326 479
327 handle &= HANDLEMASH; 480 handle &= HANDLEMASK;
328 if(storage.ContainsKey(handle)) 481 if(storage.ContainsKey(handle))
329 return storage[handle]; 482 return storage[handle];
483
484 if(!innerHandles.ContainsKey(handle))
485 return null;
330 486
487 ulong rhandle = innerHandles[handle];
488 if(storage.ContainsKey(rhandle))
489 return storage[rhandle];
490
331 return null; 491 return null;
332 } 492 }
333 493
@@ -359,13 +519,40 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
359 return null; 519 return null;
360 520
361 // look for a handle first this should find normal size regions 521 // look for a handle first this should find normal size regions
362 ulong handle = (ulong)x & HANDLECOORDMASH; 522 ulong handle = (ulong)x & HANDLECOORDMASK;
363 handle <<= 32; 523 handle <<= 32;
364 handle |= ((ulong)y & HANDLECOORDMASH); 524 handle |= ((ulong)y & HANDLECOORDMASK);
365 525
366 if(storage.ContainsKey(handle)) 526 if(storage.ContainsKey(handle))
367 return storage[handle]; 527 return storage[handle];
368 528
529 if(!innerHandles.ContainsKey(handle))
530 return null;
531
532 ulong rhandle = innerHandles[handle];
533 if(!storage.ContainsKey(rhandle))
534 return null;
535
536 GridRegion r = storage[rhandle];
537 if(r == null)
538 return null;
539
540 // extra check, possible redundant
541
542 int test = r.RegionLocX;
543 if(x < test)
544 return null;
545 test += r.RegionSizeX;
546 if(x >= test)
547 return null;
548 test = r.RegionLocY;
549 if (y < test)
550 return null;
551 test += r.RegionSizeY;
552 if (y < test)
553 return r;
554
555/*
369 // next do the harder work 556 // next do the harder work
370 foreach(KeyValuePair<ulong, GridRegion> kvp in storage) 557 foreach(KeyValuePair<ulong, GridRegion> kvp in storage)
371 { 558 {
@@ -386,6 +573,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
386 if (y < test) 573 if (y < test)
387 return r; 574 return r;
388 } 575 }
576*/
389 return null; 577 return null;
390 } 578 }
391 579
@@ -421,6 +609,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
421 byname.Remove(r.RegionName); 609 byname.Remove(r.RegionName);
422 if(byuuid != null) 610 if(byuuid != null)
423 byuuid.Remove(r.RegionID); 611 byuuid.Remove(r.RegionID);
612 removeFromInner(r);
424 } 613 }
425 storage.Remove(h); 614 storage.Remove(h);
426 } 615 }
@@ -447,6 +636,59 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
447 else 636 else
448 return byname.Count; 637 return byname.Count;
449 } 638 }
639
640 private void addToInner(GridRegion region)
641 {
642 int rsx = region.RegionSizeX;
643 int rsy = region.RegionSizeY;
644
645 if(rsx < 512 && rsy < 512)
646 return;
647
648 rsx >>= 8;
649 rsy >>= 8;
650
651 ulong handle = region.RegionHandle & HANDLEMASK;
652 fastRegionHandle fh = new fastRegionHandle(handle);
653 uint startY = fh.y;
654 for(int i = 0; i < rsx; i++)
655 {
656 for(int j = 0; j < rsy ; j++)
657 {
658 innerHandles[fh.toHandle()] = handle;
659 fh.y += 256;
660 }
661
662 fh.y = startY;
663 fh.x += 256;
664 }
665 }
666
667 private void removeFromInner(GridRegion region)
668 {
669 int rsx = region.RegionSizeX;
670 int rsy = region.RegionSizeY;
671
672 if(rsx < 512 && rsy < 512)
673 return;
674
675 rsx >>= 8;
676 rsy >>= 8;
677 ulong handle = region.RegionHandle & HANDLEMASK;
678 fastRegionHandle fh = new fastRegionHandle(handle);
679 uint startY = fh.y;
680 for(int i = 0; i < rsx; i++)
681 {
682 for(int j = 0; j < rsy ; j++)
683 {
684 innerHandles.Remove(fh.toHandle());
685 fh.y += 256;
686 }
687
688 fh.y = startY;
689 fh.x += 256;
690 }
691 }
450 } 692 }
451 693
452 public class RegionsExpiringCache 694 public class RegionsExpiringCache
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
index 7d855f1..49020e9 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
@@ -1108,7 +1108,24 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1108 vec.Z = depth * PID_P * 50; 1108 vec.Z = depth * PID_P * 50;
1109 1109
1110 if (!flying) 1110 if (!flying)
1111 {
1111 vec.Z += -vel.Z * PID_D; 1112 vec.Z += -vel.Z * PID_D;
1113 if(n.Z < 0.4f)
1114 {
1115 vec.X = depth * PID_P * 50 - vel.X * PID_D;
1116 vec.X *= n.X;
1117 vec.Y = depth * PID_P * 50 - vel.Y * PID_D;
1118 vec.Y *= n.Y;
1119 vec.Z *= n.Z;
1120 if(n.Z < 0.1f)
1121 {
1122 // cancel the slope pose
1123 n.X = 0f;
1124 n.Y = 0f;
1125 n.Z = 1.0f;
1126 }
1127 }
1128 }
1112 1129
1113 if (depth < 0.2f) 1130 if (depth < 0.2f)
1114 { 1131 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index e074af2..cf61943 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -16426,11 +16426,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
16426 16426
16427 private OSD ListToJson(object o) 16427 private OSD ListToJson(object o)
16428 { 16428 {
16429 if (o is LSL_Float) 16429 if (o is LSL_Float || o is double)
16430 return OSD.FromReal(((LSL_Float)o).value);
16431 if (o is LSL_Integer)
16432 { 16430 {
16433 int i = ((LSL_Integer)o).value; 16431 double float_val;
16432 if (o is double)
16433 float_val = ((double)o);
16434 else
16435 float_val = ((LSL_Float)o).value;
16436
16437 return OSD.FromReal(float_val);
16438 }
16439 if (o is LSL_Integer || o is int)
16440 {
16441 int i;
16442 if (o is int)
16443 i = ((int)o);
16444 else
16445 i = ((LSL_Integer)o).value;
16446
16434 if (i == 0) 16447 if (i == 0)
16435 return OSD.FromBoolean(false); 16448 return OSD.FromBoolean(false);
16436 else if (i == 1) 16449 else if (i == 1)
@@ -16441,9 +16454,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
16441 return OSD.FromString(((LSL_Rotation)o).ToString()); 16454 return OSD.FromString(((LSL_Rotation)o).ToString());
16442 if (o is LSL_Vector) 16455 if (o is LSL_Vector)
16443 return OSD.FromString(((LSL_Vector)o).ToString()); 16456 return OSD.FromString(((LSL_Vector)o).ToString());
16444 if (o is LSL_String) 16457 if (o is LSL_String || o is string)
16445 { 16458 {
16446 string str = ((LSL_String)o).m_string; 16459 string str;
16460 if (o is string)
16461 str = ((string)o);
16462 else
16463 str = ((LSL_String)o).m_string;
16464
16447 if (str == ScriptBaseClass.JSON_NULL) 16465 if (str == ScriptBaseClass.JSON_NULL)
16448 return new OSD(); 16466 return new OSD();
16449 return OSD.FromString(str); 16467 return OSD.FromString(str);