From 2d8669ad398d90fdea9bf76a4e07707a75b9ff83 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 2 Aug 2016 21:08:22 +0100 Subject: reduce ubOde walking super climbers --- OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'OpenSim') 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 vec.Z = depth * PID_P * 50; if (!flying) + { vec.Z += -vel.Z * PID_D; + if(n.Z < 0.4f) + { + vec.X = depth * PID_P * 50 - vel.X * PID_D; + vec.X *= n.X; + vec.Y = depth * PID_P * 50 - vel.Y * PID_D; + vec.Y *= n.Y; + vec.Z *= n.Z; + if(n.Z < 0.1f) + { + // cancel the slope pose + n.X = 0f; + n.Y = 0f; + n.Z = 1.0f; + } + } + } if (depth < 0.2f) { -- cgit v1.1 From e15dc7211311b2fe6ca83cb12d80a5c9d1ad0ef5 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 3 Aug 2016 10:26:57 -0400 Subject: Provide tests for native datatypes where LSL Constants are used in lists as JSON elements. Namely: LSL_Float/double, LSL_String/string, LSL_Integer/int. Fixes http://opensimulator.org/mantis/view.php?id=7957 Signed-off-by: UbitUmarov --- .../Shared/Api/Implementation/LSL_Api.cs | 30 +++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'OpenSim') 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 private OSD ListToJson(object o) { - if (o is LSL_Float) - return OSD.FromReal(((LSL_Float)o).value); - if (o is LSL_Integer) + if (o is LSL_Float || o is double) { - int i = ((LSL_Integer)o).value; + double float_val; + if (o is double) + float_val = ((double)o); + else + float_val = ((LSL_Float)o).value; + + return OSD.FromReal(float_val); + } + if (o is LSL_Integer || o is int) + { + int i; + if (o is int) + i = ((int)o); + else + i = ((LSL_Integer)o).value; + if (i == 0) return OSD.FromBoolean(false); else if (i == 1) @@ -16441,9 +16454,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return OSD.FromString(((LSL_Rotation)o).ToString()); if (o is LSL_Vector) return OSD.FromString(((LSL_Vector)o).ToString()); - if (o is LSL_String) + if (o is LSL_String || o is string) { - string str = ((LSL_String)o).m_string; + string str; + if (o is string) + str = ((string)o); + else + str = ((LSL_String)o).m_string; + if (str == ScriptBaseClass.JSON_NULL) return new OSD(); return OSD.FromString(str); -- cgit v1.1 From 374911c410a72ac1e10caa6633555ff3b36679e0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 4 Aug 2016 00:39:28 +0100 Subject: try to speed up get by position X,Y on region info cache --- .../ServiceConnectorsOut/Grid/RegionInfoCache.cs | 227 ++++++++++++++++++++- 1 file changed, 224 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs index 6db9515..37fa441 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs @@ -27,6 +27,7 @@ using System; using System.Reflection; using System.Threading; +using System.Runtime.InteropServices; using System.Collections.Generic; using OpenSim.Framework; using OpenSim.Services.Interfaces; @@ -159,6 +160,136 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } } + // dont care about endianess + [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 8)] + public class fastRegionHandle + { + [FieldOffset(0)] public ulong handle; + [FieldOffset(0)] public uint y; + [FieldOffset(4)] public uint x; + + public fastRegionHandle(ulong h) + { + handle = h; + } + + public fastRegionHandle(uint px, uint py) + { + y = py & 0xffffff00; + x = px & 0xffffff00; + } + // actually do care + public ulong toHandle() + { + if(BitConverter.IsLittleEndian) + return handle; + return (ulong) x << 32 | (ulong)y ; + } + + public static bool operator ==(fastRegionHandle value1, fastRegionHandle value2) + { + return value1.handle == value2.handle; + } + public static bool operator !=(fastRegionHandle value1, fastRegionHandle value2) + { + return value1.handle != value2.handle; + } + public override int GetHashCode() + { + return handle.GetHashCode(); + } + public override bool Equals(Object obj) + { + if(obj == null) + return false; + fastRegionHandle p = obj as fastRegionHandle; + return p.handle == handle; + } + } + +/* + [StructLayout(LayoutKind.Explicit, Size = 8, Pack = 8)] + public class regionHandle + { + [FieldOffset(0)] private ulong handle; + [FieldOffset(0)] public uint a; + [FieldOffset(4)] public uint b; + + public regionHandle(ulong h) + { + handle = h; + } + + public regionHandle(uint px, uint py) + { + if(BitConverter.IsLittleEndian) + { + a = py & 0xffffff00; + b = px & 0xffffff00; + } + else + { + a = px & 0xffffff00; + b = py & 0xffffff00; + } + } + + public uint x + { + get + { + if(BitConverter.IsLittleEndian) + return b; + return a; + } + set + { + if(BitConverter.IsLittleEndian) + b = value & 0xffffff00; + else + a = value & 0xffffff00; + } + } + + public uint y + { + get + { + if(BitConverter.IsLittleEndian) + return a; + return b; + } + set + { + if(BitConverter.IsLittleEndian) + a = value; + else + b = value; + } + } + + public static bool operator ==(regionHandle value1, regionHandle value2) + { + return value1.handle == value2.handle; + } + public static bool operator !=(regionHandle value1, regionHandle value2) + { + return value1.handle != value2.handle; + } + public override int GetHashCode() + { + return handle.GetHashCode(); + } + public override bool Equals(Object obj) + { + if(obj == null) + return false; + regionHandle p = obj as regionHandle; + return p.handle == handle; + } + } +*/ + public class RegionInfoForScope { public const ulong HANDLEMASH = 0xffffff00ffffff00ul; @@ -168,6 +299,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private Dictionary expires; private Dictionary byname; private Dictionary byuuid; + // includes handles to the inside of large regions + private Dictionary innerHandles = new Dictionary(); public RegionInfoForScope() { @@ -189,6 +322,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid expires[handle] = expire; byname[region.RegionName] = handle; byuuid[region.RegionID] = handle; + addToInner(region); } public void Add(GridRegion region, DateTime expire) @@ -211,6 +345,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid expires[handle] = expire; byname[region.RegionName] = handle; byuuid[region.RegionID] = handle; + + addToInner(region); } public void AddUpdate(GridRegion region, DateTime expire) @@ -226,16 +362,30 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid ulong handle = region.RegionHandle & HANDLEMASH; - storage[handle] = region; if(expires.ContainsKey(handle)) { if(expires[handle] < expire) expires[handle] = expire; + if(storage.ContainsKey(handle)) + { + GridRegion oldr = storage[handle]; + if (oldr.RegionSizeX != region.RegionSizeX + || oldr.RegionSizeY != region.RegionSizeY) + { + removeFromInner(oldr); + addToInner(region); + } + } } else - expires[handle] = expire; + { + expires[handle] = expire; + addToInner(region); + } + storage[handle] = region; byname[region.RegionName] = handle; byuuid[region.RegionID] = handle; + } public void Remove(GridRegion region) @@ -272,6 +422,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid byname.Remove(r.RegionName); if(byuuid != null) byuuid.Remove(r.RegionID); + removeFromInner(r); } storage.Remove(handle); } @@ -297,6 +448,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid byuuid = null; storage = null; expires = null; + innerHandles.Clear(); } public bool Contains(GridRegion region) @@ -365,7 +517,34 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if(storage.ContainsKey(handle)) return storage[handle]; - + + if(!innerHandles.ContainsKey(handle)) + return null; + + ulong rhandle = innerHandles[handle]; + if(!storage.ContainsKey(rhandle)) + return null; + + GridRegion r = storage[rhandle]; + if(r == null) + return null; + + // extra check, possible redundant + + int test = r.RegionLocX; + if(x < test) + return null; + test += r.RegionSizeX; + if(x >= test) + return null; + test = r.RegionLocY; + if (y < test) + return null; + test += r.RegionSizeY; + if (y < test) + return r; + +/* // next do the harder work foreach(KeyValuePair kvp in storage) { @@ -386,6 +565,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (y < test) return r; } +*/ return null; } @@ -421,6 +601,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid byname.Remove(r.RegionName); if(byuuid != null) byuuid.Remove(r.RegionID); + removeFromInner(r); } storage.Remove(h); } @@ -447,6 +628,46 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid else return byname.Count; } + + private void addToInner(GridRegion region) + { + int rsx = region.RegionSizeX >> 8; + int rsy = region.RegionSizeY >> 8; + ulong handle = region.RegionHandle & HANDLEMASH; + fastRegionHandle fh = new fastRegionHandle(handle); + uint startY = fh.y; + for(int i = 0; i < rsx; i++) + { + for(int j = 0; j < rsy ; j++) + { + innerHandles[fh.toHandle()] = handle; + fh.y += 256; + } + + fh.y = startY; + fh.x += 256; + } + } + + private void removeFromInner(GridRegion region) + { + int rsx = region.RegionSizeX >> 8; + int rsy = region.RegionSizeY >> 8; + ulong handle = region.RegionHandle & HANDLEMASH; + fastRegionHandle fh = new fastRegionHandle(handle); + uint startY = fh.y; + for(int i = 0; i < rsx; i++) + { + for(int j = 0; j < rsy ; j++) + { + innerHandles.Remove(fh.toHandle()); + fh.y += 256; + } + + fh.y = startY; + fh.x += 256; + } + } } public class RegionsExpiringCache -- cgit v1.1 From 9e07c557461388a50dc430ecb2cc608f32431f47 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 4 Aug 2016 01:16:17 +0100 Subject: no need to place normal size regions on the inner lookup table (HANDLEMASH ? its MASK) --- .../CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs index 37fa441..221ec67 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs @@ -631,8 +631,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void addToInner(GridRegion region) { - int rsx = region.RegionSizeX >> 8; - int rsy = region.RegionSizeY >> 8; + int rsx = region.RegionSizeX; + int rsy = region.RegionSizeY; + + if(rsx < 512 && rsy < 512) + return; + + rsx >>= 8; + rsy >>= 8; + ulong handle = region.RegionHandle & HANDLEMASH; fastRegionHandle fh = new fastRegionHandle(handle); uint startY = fh.y; -- cgit v1.1 From 721d5ed145b01ae2f4ef753372e98379fcdeea72 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 4 Aug 2016 01:19:52 +0100 Subject: well then also no need to remove them :) --- .../ServiceConnectorsOut/Grid/RegionInfoCache.cs | 38 +++++++++++++--------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs index 221ec67..9fd4cd5 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs @@ -292,8 +292,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public class RegionInfoForScope { - public const ulong HANDLEMASH = 0xffffff00ffffff00ul; - public const ulong HANDLECOORDMASH = 0xffffff00ul; + public const ulong HANDLEMASK = 0xffffff00ffffff00ul; + public const ulong HANDLECOORDMASK = 0xffffff00ul; private Dictionary storage; private Dictionary expires; @@ -317,7 +317,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid byname = new Dictionary(); byuuid = new Dictionary(); - ulong handle = region.RegionHandle & HANDLEMASH; + ulong handle = region.RegionHandle & HANDLEMASK; storage[handle] = region; expires[handle] = expire; byname[region.RegionName] = handle; @@ -327,7 +327,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void Add(GridRegion region, DateTime expire) { - ulong handle = region.RegionHandle & HANDLEMASH; + ulong handle = region.RegionHandle & HANDLEMASK; if(storage != null && storage.ContainsKey(handle)) return; @@ -360,7 +360,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if(byuuid == null) byuuid = new Dictionary(); - ulong handle = region.RegionHandle & HANDLEMASH; + ulong handle = region.RegionHandle & HANDLEMASK; if(expires.ContainsKey(handle)) { @@ -398,7 +398,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if(byuuid != null) byuuid.Remove(region.RegionID); - ulong handle = region.RegionHandle & HANDLEMASH; + ulong handle = region.RegionHandle & HANDLEMASK; if(storage != null) storage.Remove(handle); if(expires != null) @@ -411,7 +411,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void Remove(ulong handle) { - handle &= HANDLEMASH; + handle &= HANDLEMASK; if(storage != null) { @@ -458,7 +458,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if(region == null) return false; - ulong handle = region.RegionHandle & HANDLEMASH; + ulong handle = region.RegionHandle & HANDLEMASK; return storage.ContainsKey(handle); } @@ -467,7 +467,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if(storage == null) return false; - handle &= HANDLEMASH; + handle &= HANDLEMASK; return storage.ContainsKey(handle); } @@ -476,7 +476,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if(storage == null) return null; - handle &= HANDLEMASH; + handle &= HANDLEMASK; if(storage.ContainsKey(handle)) return storage[handle]; @@ -511,9 +511,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return null; // look for a handle first this should find normal size regions - ulong handle = (ulong)x & HANDLECOORDMASH; + ulong handle = (ulong)x & HANDLECOORDMASK; handle <<= 32; - handle |= ((ulong)y & HANDLECOORDMASH); + handle |= ((ulong)y & HANDLECOORDMASK); if(storage.ContainsKey(handle)) return storage[handle]; @@ -640,7 +640,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid rsx >>= 8; rsy >>= 8; - ulong handle = region.RegionHandle & HANDLEMASH; + ulong handle = region.RegionHandle & HANDLEMASK; fastRegionHandle fh = new fastRegionHandle(handle); uint startY = fh.y; for(int i = 0; i < rsx; i++) @@ -658,9 +658,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void removeFromInner(GridRegion region) { - int rsx = region.RegionSizeX >> 8; - int rsy = region.RegionSizeY >> 8; - ulong handle = region.RegionHandle & HANDLEMASH; + int rsx = region.RegionSizeX; + int rsy = region.RegionSizeY; + + if(rsx < 512 && rsy < 512) + return; + + rsx >>= 8; + rsy >>= 8; + ulong handle = region.RegionHandle & HANDLEMASK; fastRegionHandle fh = new fastRegionHandle(handle); uint startY = fh.y; for(int i = 0; i < rsx; i++) -- cgit v1.1 From 1b16ad90882d4154e800acddfd3687edc378bf3b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 4 Aug 2016 03:16:29 +0100 Subject: let get by handle also search on inner lookup table --- .../CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs index 9fd4cd5..5eb525b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RegionInfoCache.cs @@ -401,6 +401,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid ulong handle = region.RegionHandle & HANDLEMASK; if(storage != null) storage.Remove(handle); + removeFromInner(region); if(expires != null) { expires.Remove(handle); @@ -479,7 +480,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid handle &= HANDLEMASK; if(storage.ContainsKey(handle)) return storage[handle]; + + if(!innerHandles.ContainsKey(handle)) + return null; + ulong rhandle = innerHandles[handle]; + if(storage.ContainsKey(rhandle)) + return storage[rhandle]; + return null; } -- cgit v1.1