From e2b9a5d7aa08c9f99a77d9bbf05a08566fd9cd21 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Jun 2012 08:54:39 +0100 Subject: [PATCH 01/29] Don't let scripts rotate root part of physical linksets like SL, Update client rotation of avatars 'linked' to child parts. (put back some 'cosmetics' from previus commit). Still let lsl api use physics engine ideia of part Physical state on this where it should be SOP ideia, so is that is clear that sync with engine is SOP responsability. --- .../Shared/Api/Implementation/LSL_Api.cs | 97 ++++++++++++------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fe8511843d..389a82b742 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -660,18 +660,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); double x,y,z,s; + v.x *= 0.5; + v.y *= 0.5; + v.z *= 0.5; + double c1 = Math.Cos(v.x); + double c2 = Math.Cos(v.y); + double c1c2 = c1 * c2; + double s1 = Math.Sin(v.x); + double s2 = Math.Sin(v.y); + double s1s2 = s1 * s2; + double c1s2 = c1 * s2; + double s1c2 = s1 * c2; + double c3 = Math.Cos(v.z); + double s3 = Math.Sin(v.z); - double c1 = Math.Cos(v.x * 0.5); - double c2 = Math.Cos(v.y * 0.5); - double c3 = Math.Cos(v.z * 0.5); - double s1 = Math.Sin(v.x * 0.5); - double s2 = Math.Sin(v.y * 0.5); - double s3 = Math.Sin(v.z * 0.5); - - x = s1 * c2 * c3 + c1 * s2 * s3; - y = c1 * s2 * c3 - s1 * c2 * s3; - z = s1 * s2 * c3 + c1 * c2 * s3; - s = c1 * c2 * c3 - s1 * s2 * s3; + x = s1c2 * c3 + c1s2 * s3; + y = c1s2 * c3 - s1c2 * s3; + z = s1s2 * c3 + c1c2 * s3; + s = c1c2 * c3 - s1s2 * s3; return new LSL_Rotation(x, y, z, s); } @@ -1911,11 +1917,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Primitive.TextureEntry tex = part.Shape.Textures; Color4 texcolor; LSL_Vector rgb = new LSL_Vector(); + int nsides = GetNumberOfSides(part); + if (face == ScriptBaseClass.ALL_SIDES) { int i; - - for (i = 0 ; i < GetNumberOfSides(part); i++) + for (i = 0; i < nsides; i++) { texcolor = tex.GetFace((uint)i).RGBA; rgb.x += texcolor.R; @@ -1923,13 +1930,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api rgb.z += texcolor.B; } - rgb.x /= (float)GetNumberOfSides(part); - rgb.y /= (float)GetNumberOfSides(part); - rgb.z /= (float)GetNumberOfSides(part); + float invnsides = 1.0f / (float)nsides; + + rgb.x *= invnsides; + rgb.y *= invnsides; + rgb.z *= invnsides; return rgb; } - if (face >= 0 && face < GetNumberOfSides(part)) + if (face >= 0 && face < nsides) { texcolor = tex.GetFace((uint)face).RGBA; rgb.x = texcolor.R; @@ -2328,13 +2337,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // (root prim). ParentID may be nonzero in attachments and // using it would cause attachments and HUDs to rotate // to the wrong positions. + SetRot(m_host, Rot2Quaternion(rot)); } else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. - SceneObjectPart rootPart = m_host.ParentGroup.RootPart; - if (rootPart != null) // better safe than sorry + SceneObjectPart rootPart;// = m_host.ParentGroup.RootPart; + if (m_host.ParentGroup != null && ((rootPart = m_host.ParentGroup.RootPart) != null)) // better safe than sorry { SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); } @@ -2346,6 +2356,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetLocalRot(LSL_Rotation rot) { m_host.AddScriptLPS(1); + SetRot(m_host, Rot2Quaternion(rot)); ScriptSleep(200); } @@ -2355,25 +2366,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; - part.UpdateRotation(rot); - // Update rotation does not move the object in the physics scene if it's a linkset. + bool isroot = (part == part.ParentGroup.RootPart); + bool isphys; -//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type -// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; - - // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line - // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt - // It's perfectly okay when the object is not an active physical body though. - // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against - // but only if the object is not physial and active. This is important for rotating doors. - // without the absoluteposition = absoluteposition happening, the doors do not move in the physics - // scene PhysicsActor pa = part.PhysActor; - if (pa != null && !pa.IsPhysical && part == part.ParentGroup.RootPart) + // keep using physactor ideia of isphysical + // it should be SOP ideia of that + // not much of a issue with ubitODE + if (pa != null && pa.IsPhysical) + isphys = true; + else + isphys = false; + + // SL doesn't let scripts rotate root of physical linksets + if (isroot && isphys) + return; + + part.UpdateRotation(rot); + + // Update rotation does not move the object in the physics engine if it's a non physical linkset + // so do a nasty update of parts positions if is a root part rotation + if (isroot && pa != null) // with if above implies non physical root part { part.ParentGroup.ResetChildPrimPhysicsPositions(); } + else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part + { + List sittingavas = part.ParentGroup.GetLinkedAvatars(); + if (sittingavas.Count > 0) + { + foreach (ScenePresence av in sittingavas) + { + if (isroot || part.LocalId == av.ParentID) + av.SendTerseUpdateToAllClients(); + } + } + } } /// @@ -2422,7 +2451,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llGetLocalRot() { m_host.AddScriptLPS(1); - return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); + Quaternion rot = m_host.RotationOffset; + return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); } public void llSetForce(LSL_Vector force, int local) @@ -8534,6 +8564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) return; + LSL_Rotation lr = rules.GetQuaternionItem(idx++); SetRot(part, Rot2Quaternion(lr)); break; From e7aceae3e0e21b9f739dbcaac055c18991887e50 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Jun 2012 09:06:25 +0100 Subject: [PATCH 02/29] split ugly expression in a if making it simpler to read --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 389a82b742..d9867a8ff0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2343,10 +2343,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. - SceneObjectPart rootPart;// = m_host.ParentGroup.RootPart; - if (m_host.ParentGroup != null && ((rootPart = m_host.ParentGroup.RootPart) != null)) // better safe than sorry + SceneObjectPart rootPart; + if (m_host.ParentGroup != null) // better safe than sorry { - SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); + rootPart = m_host.ParentGroup.RootPart; + if (rootPart != null) + SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); } } From 8cf414ba32ba995562e574cd2a58ce7ee204a562 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Jun 2012 11:38:40 +0100 Subject: [PATCH 03/29] *CHECK/REVIEW* comented out not used sp.ParentPosition. Comented out SOG.AbsolutePosition changing 'linked' avatars positions ( reason in code coment ) --- .../Framework/Scenes/SceneObjectGroup.cs | 18 ++++++++++++----- .../Region/Framework/Scenes/ScenePresence.cs | 20 ++++++++++--------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index aab6a49d1b..96eeec442d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -631,6 +631,14 @@ namespace OpenSim.Region.Framework.Scenes if (triggerScriptEvent) part.TriggerScriptChangedEvent(Changed.POSITION); } + +/* + This seems not needed and should not be needed: + sp absolute position depends on sit part absolute position fixed above. + sp ParentPosition is not used anywhere. + Since presence is sitting, viewer considers it 'linked' to root prim, so it will move/rotate it + Sending a extra packet with avatar position is not only bandwidth waste, but may cause jitter in viewers due to UPD nature. + if (!m_dupeInProgress) { foreach (ScenePresence av in m_linkedAvatars) @@ -640,12 +648,12 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 offset = p.GetWorldPosition() - av.ParentPosition; av.AbsolutePosition += offset; - av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition +// av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition av.SendAvatarDataToAllAgents(); } } } - +*/ //if (m_rootPart.PhysActor != null) //{ //m_rootPart.PhysActor.Position = @@ -676,8 +684,8 @@ namespace OpenSim.Region.Framework.Scenes if (agent.ParentUUID != UUID.Zero) { agent.ParentPart = null; - agent.ParentPosition = Vector3.Zero; - // agent.ParentUUID = UUID.Zero; +// agent.ParentPosition = Vector3.Zero; +// agent.ParentUUID = UUID.Zero; } } @@ -3752,7 +3760,7 @@ namespace OpenSim.Region.Framework.Scenes else // ugly rotation update of all parts { - group.AbsolutePosition = AbsolutePosition; + group.ResetChildPrimPhysicsPositions(); } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 87b4d9fdfd..a068aab52e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -433,7 +433,7 @@ namespace OpenSim.Region.Framework.Scenes get { return (IClientCore)ControllingClient; } } - public Vector3 ParentPosition { get; set; } +// public Vector3 ParentPosition { get; set; } /// /// Position of this avatar relative to the region the avatar is in @@ -491,7 +491,7 @@ namespace OpenSim.Region.Framework.Scenes if (ParentID == 0) { m_pos = value; - ParentPosition = Vector3.Zero; +// ParentPosition = Vector3.Zero; } //m_log.DebugFormat( @@ -857,11 +857,12 @@ namespace OpenSim.Region.Framework.Scenes part.ParentGroup.AddAvatar(UUID); if (part.SitTargetPosition != Vector3.Zero) part.SitTargetAvatar = UUID; - ParentPosition = part.GetWorldPosition(); +// ParentPosition = part.GetWorldPosition(); ParentID = part.LocalId; ParentPart = part; m_pos = m_prevSitOffset; - pos = ParentPosition; +// pos = ParentPosition; + pos = part.GetWorldPosition(); } ParentUUID = UUID.Zero; @@ -1933,11 +1934,12 @@ namespace OpenSim.Region.Framework.Scenes part.SitTargetAvatar = UUID.Zero; part.ParentGroup.DeleteAvatar(UUID); - ParentPosition = part.GetWorldPosition(); +// ParentPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); - m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); - ParentPosition = Vector3.Zero; +// m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); +// ParentPosition = Vector3.Zero; + m_pos += part.GetWorldPosition() + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); ParentID = 0; ParentPart = null; @@ -2388,13 +2390,13 @@ namespace OpenSim.Region.Framework.Scenes // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; Rotation = sitTargetOrient; - ParentPosition = part.AbsolutePosition; +// ParentPosition = part.AbsolutePosition; part.ParentGroup.AddAvatar(UUID); } else { m_pos -= part.AbsolutePosition; - ParentPosition = part.AbsolutePosition; +// ParentPosition = part.AbsolutePosition; part.ParentGroup.AddAvatar(UUID); // m_log.DebugFormat( From ca22feb09ab4f3ea172f3e81b140c00ba7ab8e9c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Jun 2012 13:28:33 +0100 Subject: [PATCH 04/29] don't send a lot of avatar data when we are just changing position or rotation ( SendTerseUpdateToAllClients() in place of SendAvatarDataToAllAgents() ) --- .../Shared/Api/Implementation/LSL_Api.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d9867a8ff0..05adf8eb4c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8026,7 +8026,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Quaternion srot = sitpart.RotationOffset; rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation av.Rotation = rot; - av.SendAvatarDataToAllAgents(); +// av.SendAvatarDataToAllAgents(); + av.SendTerseUpdateToAllClients(); } break; @@ -8046,7 +8047,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation } av.Rotation = rot; - av.SendAvatarDataToAllAgents(); +// av.SendAvatarDataToAllAgents(); + av.SendTerseUpdateToAllClients(); } break; @@ -8141,7 +8143,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { positionChanged = false; av.OffsetPosition = finalPos; - av.SendAvatarDataToAllAgents(); +// av.SendAvatarDataToAllAgents(); + av.SendTerseUpdateToAllClients(); } LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); @@ -8157,7 +8160,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (positionChanged) { av.OffsetPosition = finalPos; - av.SendAvatarDataToAllAgents(); +// av.SendAvatarDataToAllAgents(); + av.SendTerseUpdateToAllClients(); positionChanged = false; } } From 909572ed8618f15c7603cbb8a91563d55dc42061 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Jun 2012 09:40:51 +0100 Subject: [PATCH 05/29] fix SceneGraph Add/Remove PhysicalPrim counters --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index b7466bea14..a600b86cde 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -585,12 +585,12 @@ namespace OpenSim.Region.Framework.Scenes protected internal void AddPhysicalPrim(int number) { - m_physicalPrim++; + m_physicalPrim += number; } protected internal void RemovePhysicalPrim(int number) { - m_physicalPrim--; + m_physicalPrim -= number; } protected internal void AddToScriptLPS(int number) From c8f7cd60cd5e16b6917c0b67358bee4eb04716d1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 21 Jun 2012 19:05:36 +0100 Subject: [PATCH 06/29] fix turning off phanton always decreasing number of physical parts --- .../Framework/Scenes/SceneObjectPart.cs | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8e74dc8f4b..a48605d3d8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4496,7 +4496,8 @@ namespace OpenSim.Region.Framework.Scenes { if (pa != null) { - ParentGroup.Scene.RemovePhysicalPrim(1); + if(wasUsingPhysics) + ParentGroup.Scene.RemovePhysicalPrim(1); RemoveFromPhysics(); } @@ -4513,38 +4514,37 @@ namespace OpenSim.Region.Framework.Scenes { AddToPhysics(UsePhysics, SetPhantom, building, false); pa = PhysActor; - /* - if (pa != null) - { - if ( - // ((AggregateScriptEvents & scriptEvents.collision) != 0) || - // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || - // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || - // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || - // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || - // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || - ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || - ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || - (CollisionSound != UUID.Zero) - ) - { - pa.OnCollisionUpdate += PhysicsCollision; - pa.SubscribeEvents(1000); - } - } - */ +/* + if (pa != null) + { + if ( +// ((AggregateScriptEvents & scriptEvents.collision) != 0) || +// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || +// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || +// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || + ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || + ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || + (CollisionSound != UUID.Zero) + ) + { + pa.OnCollisionUpdate += PhysicsCollision; + pa.SubscribeEvents(1000); + } + } +*/ } else // it already has a physical representation { DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. - /* moved into DoPhysicsPropertyUpdate - if(VolumeDetectActive) - pa.SetVolumeDetect(1); - else - pa.SetVolumeDetect(0); - */ - +/* moved into DoPhysicsPropertyUpdate + if(VolumeDetectActive) + pa.SetVolumeDetect(1); + else + pa.SetVolumeDetect(0); +*/ if (pa.Building != building) pa.Building = building; From ba58d7a9b2dc1233e46006a20b8924788cbb53db Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 22 Jun 2012 18:04:12 +0100 Subject: [PATCH 07/29] add a temp debug message --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 75f783b016..3d3fb8e05c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -717,7 +717,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP udpClient = ((LLClientView)client).UDPClient; if (!udpClient.IsConnected) + { + m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet for a unConnected client in " + m_scene.RegionInfo.RegionName); return; + } #endregion Packet to Client Mapping From 646b7fb8f2e285945b70a657674e5c3dac84b931 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 22 Jun 2012 18:10:53 +0100 Subject: [PATCH 08/29] i more debug --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 3d3fb8e05c..c64b5f2dcb 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -710,7 +710,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP IClientAPI client; if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView)) { - //m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); + m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); return; } From 0de3ad530713324d23ac513e7a317a2acd539a22 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 22 Jun 2012 18:18:12 +0100 Subject: [PATCH 09/29] more debug --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 5a87958af6..80b6f64938 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -6402,6 +6402,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP { handlerCompleteMovementToRegion(sender, true); } + else + m_log.Debug("HandleCompleteAgentMovement NULL handler"); + handlerCompleteMovementToRegion = null; return true; From 1468b01afc9defab4cde690293bd368cb73cd437 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 22 Jun 2012 18:29:46 +0100 Subject: [PATCH 10/29] coment out some of previus debug messaged before forgetting about them... --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index c64b5f2dcb..bd8273dbdf 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -710,7 +710,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP IClientAPI client; if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView)) { - m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); +// m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); return; } @@ -718,7 +718,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (!udpClient.IsConnected) { - m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet for a unConnected client in " + m_scene.RegionInfo.RegionName); +// m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet for a unConnected client in " + m_scene.RegionInfo.RegionName); return; } From 9ca9770cf69bb148c9509c9dbe2f6c981aec36a5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 25 Jun 2012 00:44:09 +0100 Subject: [PATCH 11/29] fix a seg fault in sp.cs --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a068aab52e..4940063ead 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3570,7 +3570,8 @@ namespace OpenSim.Region.Framework.Scenes // m_reprioritizationTimer.Dispose(); RemoveFromPhysicalScene(); - Animator.Close(); + if(Animator != null) + Animator.Close(); Animator = null; } From 29abb7d62af2d45598b077fc9abb3ed11149f414 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 28 Jun 2012 12:20:55 +0100 Subject: [PATCH 12/29] reactivate physics raycasts on llCastRay() until it's clear what is its problem if any... --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 75add29ed2..f475b997c2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -12614,7 +12614,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); - if (false)// World.SuportsRayCastFiltered()) + if (World.SuportsRayCastFiltered()) { if (dist == 0) return list; From 0d26e271c9a60d959b643500a83aee3e67c4d035 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 29 Jun 2012 01:02:22 +0200 Subject: [PATCH 13/29] stop chat being sent to child avs again. --- OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 357c2af421..6215526794 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -352,9 +352,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat UUID fromAgentID, string fromName, ChatTypeEnum type, string message, ChatSourceType src) { - // don't send llRegionSay to child agents. Send normal chat because you - // can't talk across sim borders if it's not done - if (type == ChatTypeEnum.Broadcast && presence.IsChildAgent) return false; + // don't send chat to child agents + if (presence.IsChildAgent) return false; Vector3 fromRegionPos = fromPos + regionPos; Vector3 toRegionPos = presence.AbsolutePosition + From 7ab8bc0a60e88a8c7099829ff8cf70d2450432a2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 29 Jun 2012 01:17:53 +0100 Subject: [PATCH 14/29] don't recoil attachments doing llRezObject() --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f475b997c2..8c51473bf6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3129,13 +3129,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api new_group.RootPart.UUID.ToString()) }, new DetectParams[0])); - float groupmass = new_group.GetMass(); + // do recoil + SceneObjectGroup hostgrp = m_host.ParentGroup; + if (hostgrp == null) + return; + + if (hostgrp.IsAttachment) // don't recoil avatars + return; PhysicsActor pa = new_group.RootPart.PhysActor; if (pa != null && pa.IsPhysical && llvel != Vector3.Zero) { - // recoil + float groupmass = new_group.GetMass(); llvel *= -groupmass; llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0); } From 38cdf77cef4964bb9eac9ccefb30334cd6737e9d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 29 Jun 2012 03:41:04 +0100 Subject: [PATCH 15/29] in CreateAvatarUpdateBlock() change updateflags to 0. Original flags seem prim related only. This does fix the wrong viewer side move of a avatar in prim edition mode (anv mantis 854), with no apparent side effects .. may need more testing --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 80b6f64938..9c96b52f62 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5078,10 +5078,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP update.TextureEntry = Utils.EmptyBytes; // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes; +/* all this flags seem related to prims and not avatars. This allow for wrong viewer side move of a avatar in prim edition mode (anv mantis 854) update.UpdateFlags = (uint)( PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner | PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer | PrimFlags.ObjectOwnerModify); +*/ + update.UpdateFlags = 0; return update; } From e9e409a7948b98a4f0befd6f49ca4d2cb1cabe60 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 29 Jun 2012 22:37:16 +0200 Subject: [PATCH 16/29] Remove spammy debug --- OpenSim/Region/CoreModules/World/Land/LandObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 42844440c1..5974112b4b 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs @@ -200,7 +200,7 @@ namespace OpenSim.Region.CoreModules.World.Land * (long)m_scene.RegionInfo.ObjectCapacity * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus / 65536L); - m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax); + //m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax); return parcelMax; } } From ec7c7fe5f8b99a2aba4c2f9bc4913535e0e91507 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 30 Jun 2012 08:49:07 +0100 Subject: [PATCH 17/29] ubitode: create and use 4 off world collision spaces for offworld static prims --- .../Region/Physics/UbitOdePlugin/OdeScene.cs | 49 ++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 286c7f0721..6c72324ba4 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -302,6 +302,7 @@ namespace OpenSim.Region.Physics.OdePlugin // split static geometry collision into a grid as before private IntPtr[,] staticPrimspace; + private IntPtr[] staticPrimspaceOffRegion; public Object OdeLock; private static Object SimulationLock; @@ -551,6 +552,7 @@ namespace OpenSim.Region.Physics.OdePlugin // create all spaces now int i, j; IntPtr newspace; + for (i = 0; i < spaceGridMaxX; i++) for (j = 0; j < spaceGridMaxY; j++) { @@ -573,6 +575,29 @@ namespace OpenSim.Region.Physics.OdePlugin // let this now be real maximum values spaceGridMaxX--; spaceGridMaxY--; + + // create 4 off world spaces (x<0,x>max,y<0,y>max) + staticPrimspaceOffRegion = new IntPtr[4]; + + for (i = 0; i < 4; i++) + { + newspace = d.HashSpaceCreate(StaticSpace); + d.GeomSetCategoryBits(newspace, (int)CollisionCategories.Space); + waitForSpaceUnlock(newspace); + d.SpaceSetSublevel(newspace, 2); + d.HashSpaceSetLevels(newspace, -2, 8); + d.GeomSetCategoryBits(newspace, (uint)(CollisionCategories.Space | + CollisionCategories.Geom | + CollisionCategories.Land | + CollisionCategories.Water | + CollisionCategories.Phantom | + CollisionCategories.VolumeDtc + )); + d.GeomSetCollideBits(newspace, 0); + + staticPrimspaceOffRegion[i] = newspace; + } + m_lastframe = DateTime.UtcNow; } @@ -1650,20 +1675,22 @@ namespace OpenSim.Region.Physics.OdePlugin public IntPtr calculateSpaceForGeom(Vector3 pos) { int x, y; + + if (pos.X < 0) + return staticPrimspaceOffRegion[0]; + + if (pos.Y < 0) + return staticPrimspaceOffRegion[2]; + x = (int)(pos.X * spacesPerMeter); - if (x < 0) - x = 0; - else if (x > spaceGridMaxX) - x = spaceGridMaxX; - + if (x > spaceGridMaxX) + return staticPrimspaceOffRegion[1]; + y = (int)(pos.Y * spacesPerMeter); - if (y < 0) - y = 0; - else if (y >spaceGridMaxY) - y = spaceGridMaxY; + if (y > spaceGridMaxY) + return staticPrimspaceOffRegion[3]; - IntPtr tmpSpace = staticPrimspace[x, y]; - return tmpSpace; + return staticPrimspace[x, y]; } #endregion From d3f1fc79e50edb9ef851bdedfa83e9f5c13b4519 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 1 Jul 2012 01:33:20 +0100 Subject: [PATCH 18/29] *TO CHECK/REVIEW/REVERT/TEST whatever* pollService new requests get enqueued to unified requests queue directly. Retries get into that every 100ms. 3 working threads as before plus another that only does retries timming. --- .../HttpServer/PollServiceRequestManager.cs | 203 ++++++++++++++++++ .../HttpServer/PollServiceWorkerThread.cs | 3 + 2 files changed, 206 insertions(+) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index c3e1a79f94..e488b380e7 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -33,8 +33,11 @@ using log4net; using HttpServer; using OpenSim.Framework; + +/* namespace OpenSim.Framework.Servers.HttpServer { + public class PollServiceRequestManager { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -156,3 +159,203 @@ namespace OpenSim.Framework.Servers.HttpServer } } } + */ + +using System.IO; +using System.Text; +using System.Collections.Generic; + +namespace OpenSim.Framework.Servers.HttpServer +{ + public class PollServiceRequestManager + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private readonly BaseHttpServer m_server; + + private BlockingQueue m_requests = new BlockingQueue(); + private static Queue m_retry_requests = new Queue(); + + private uint m_WorkerThreadCount = 0; + private Thread[] m_workerThreads; + private Thread m_retrysThread; + + private bool m_running = true; + + private int m_timeout = 250; + + public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout) + { + m_server = pSrv; + m_WorkerThreadCount = pWorkerThreadCount; + m_workerThreads = new Thread[m_WorkerThreadCount]; + + //startup worker threads + for (uint i = 0; i < m_WorkerThreadCount; i++) + { + m_workerThreads[i] + = Watchdog.StartThread( + poolWorkerJob, + String.Format("PollServiceWorkerThread{0}", i), + ThreadPriority.Normal, + false, + true, + int.MaxValue); + } + + m_retrysThread = Watchdog.StartThread( + this.CheckRetries, + "PollServiceWatcherThread", + ThreadPriority.Normal, + false, + true, + 1000 * 60 * 10); + } + + + private void ReQueueEvent(PollServiceHttpRequest req) + { + if (m_running) + { + lock (m_retry_requests) + m_retry_requests.Enqueue(req); + } + } + + public void Enqueue(PollServiceHttpRequest req) + { + if (m_running) + m_requests.Enqueue(req); + } + + private void CheckRetries() + { + while (m_running) + { + Thread.Sleep(100); // let the world move + Watchdog.UpdateThread(); + lock (m_retry_requests) + { + while (m_retry_requests.Count > 0 && m_running) + Enqueue(m_retry_requests.Dequeue()); + } + } + } + + ~PollServiceRequestManager() + { + m_running = false; + m_timeout = -10000; // cause all to expire + Thread.Sleep(1000); // let the world move + + foreach (Thread t in m_workerThreads) + { + try + { + t.Abort(); + } + catch + { + } + } + + try + { + foreach (PollServiceHttpRequest req in m_retry_requests) + { + m_server.DoHTTPGruntWork( + req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), + new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); + } + } + catch + { + } + + PollServiceHttpRequest wreq; + m_retry_requests.Clear(); + + while (m_requests.Count() > 0) + { + try + { + wreq = m_requests.Dequeue(0); + m_server.DoHTTPGruntWork( + wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id), + new OSHttpResponse(new HttpResponse(wreq.HttpContext, wreq.Request), wreq.HttpContext)); + } + catch + { + } + } + + m_requests.Clear(); + } + + // work threads + + private void poolWorkerJob() + { + PollServiceHttpRequest req; + StreamReader str; + + while (true) + { + req = m_requests.Dequeue(5000); + + Watchdog.UpdateThread(); + if (req != null) + { + try + { + if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) + { + try + { + str = new StreamReader(req.Request.Body); + } + catch (System.ArgumentException) + { + // Stream was not readable means a child agent + // was closed due to logout, leaving the + // Event Queue request orphaned. + continue; + } + + try + { + Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); + m_server.DoHTTPGruntWork(responsedata, + new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); + } + catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream + { + // Ignore it, no need to reply + } + + str.Close(); + + } + else + { + if ((Environment.TickCount - req.RequestTime) > m_timeout) + { + m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), + new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); + } + else + { + ReQueueEvent(req); + } + } + } + catch (Exception e) + { + m_log.ErrorFormat("Exception in poll service thread: " + e.ToString()); + } + } + } + } + } +} + diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs index b39185fba9..7cd27e5290 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs @@ -25,6 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* Ubit work moved to PollServiceRequestManager + using System; using System.Collections; using System.Collections.Generic; @@ -128,3 +130,4 @@ namespace OpenSim.Framework.Servers.HttpServer } } } +*/ \ No newline at end of file From 7eb95c9ed90939fc243995eaaefed90bf45c37ed Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 1 Jul 2012 18:05:35 +0200 Subject: [PATCH 19/29] Bring casing of llSHA1String in line with SL --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 8c51473bf6..dd7563a4c8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7479,7 +7479,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llSHA1String(string src) { m_host.AddScriptLPS(1); - return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); + return Util.SHA1Hash(src, Encoding.UTF8).ToUpper(); } protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) From 4f04ec5fc26892f3ddc72741e6b600cff19c27da Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 2 Jul 2012 02:04:56 +0200 Subject: [PATCH 20/29] Implement the buggy version of llXorBase64Strings() for compatibility's sake --- .../Shared/Api/Implementation/LSL_Api.cs | 87 ++++++++++++++++++- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index dd7563a4c8..fd8e586d37 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8676,10 +8676,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llXorBase64Strings(string str1, string str2) { - m_host.AddScriptLPS(1); - Deprecated("llXorBase64Strings"); + string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + ScriptSleep(300); - return String.Empty; + m_host.AddScriptLPS(1); + + if (str1 == String.Empty) + return String.Empty; + if (str2 == String.Empty) + return str1; + + int len = str2.Length; + if ((len % 4) != 0) // LL is EVIL!!!! + { + while (str2.EndsWith("=")) + str2 = str2.Substring(0, str2.Length - 1); + + len = str2.Length; + int mod = len % 4; + + if (mod == 1) + str2 = str2.Substring(0, str2.Length - 1); + else if (mod == 2) + str2 += "=="; + else if (mod == 3) + str2 += "="; + } + + byte[] data1; + byte[] data2; + try + { + data1 = Convert.FromBase64String(str1); + data2 = Convert.FromBase64String(str2); + } + catch (Exception) + { + return new LSL_String(String.Empty); + } + + // For cases where the decoded length of s2 is greater + // than the decoded length of s1, simply perform a normal + // decode and XOR + // + if (data2.Length >= data1.Length) + { + for (int pos = 0 ; pos < data1.Length ; pos++ ) + data1[pos] ^= data2[pos]; + + return Convert.ToBase64String(data1); + } + + // Remove padding + while (str1.EndsWith("=")) + str1 = str1.Substring(0, str1.Length - 1); + while (str2.EndsWith("=")) + str2 = str2.Substring(0, str2.Length - 1); + + byte[] d1 = new byte[str1.Length]; + byte[] d2 = new byte[str2.Length]; + + for (int i = 0 ; i < str1.Length ; i++) + { + int idx = b64.IndexOf(str1.Substring(i, 1)); + if (idx == -1) + idx = 0; + d1[i] = (byte)idx; + } + + for (int i = 0 ; i < str2.Length ; i++) + { + int idx = b64.IndexOf(str2.Substring(i, 1)); + if (idx == -1) + idx = 0; + d2[i] = (byte)idx; + } + + string output = String.Empty; + + for (int pos = 0 ; pos < d1.Length ; pos++) + output += b64[d1[pos] ^ d2[pos % d2.Length]]; + + while (output.Length % 3 > 0) + output += "="; + + return output; } public void llRemoteDataSetRegion() From b2fa20001f8af9d62b0caa3612d8f1ab6f2caa87 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 4 Jul 2012 06:14:47 +0100 Subject: [PATCH 21/29] *test* slow http retries pool rate to original 1s --- .../Framework/Servers/HttpServer/PollServiceRequestManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index e488b380e7..36f2b9b2a9 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -232,7 +232,7 @@ namespace OpenSim.Framework.Servers.HttpServer { while (m_running) { - Thread.Sleep(100); // let the world move + Thread.Sleep(1000); // let the world move slow it to original polling rate Watchdog.UpdateThread(); lock (m_retry_requests) { From e533eef962fe05ea7ca156fa3420cb2a1d679297 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 4 Jul 2012 15:07:10 +0100 Subject: [PATCH 22/29] *test2* http poll: increased again the pool rate do 10/s but increased timeout to 1s. So data there is less delay when there is new data, but enought waiting time for it to be avaiable --- .../Framework/Servers/HttpServer/PollServiceRequestManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 36f2b9b2a9..125d9c29df 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -182,7 +182,7 @@ namespace OpenSim.Framework.Servers.HttpServer private bool m_running = true; - private int m_timeout = 250; + private int m_timeout = 1000; // increase timeout 250; public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout) { @@ -232,7 +232,7 @@ namespace OpenSim.Framework.Servers.HttpServer { while (m_running) { - Thread.Sleep(1000); // let the world move slow it to original polling rate + Thread.Sleep(100); // let the world move .. back to faster rate Watchdog.UpdateThread(); lock (m_retry_requests) { From 02cb0bf80a0b67eb0316ac74e1ea9741bfce1385 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 4 Jul 2012 17:40:02 +0100 Subject: [PATCH 23/29] added a timeout paramenter to PollServiceEventArgs, so each type can define it's timeout --- OpenSim/Framework/Console/RemoteConsole.cs | 2 +- OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | 5 ++++- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index eabb62dd01..e04ca1e1e0 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -233,7 +233,7 @@ namespace OpenSim.Framework.Console string uri = "/ReadResponses/" + sessionID.ToString() + "/"; m_Server.AddPollServiceHTTPHandler( - uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID)); + uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout XmlDocument xmldoc = new XmlDocument(); XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 9d512c6249..2407533ab1 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs @@ -44,13 +44,16 @@ namespace OpenSim.Framework.Servers.HttpServer public NoEventsMethod NoEvents; public RequestMethod Request; public UUID Id; - public PollServiceEventArgs(RequestMethod pRequest, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,UUID pId) + public int TimeOutms; + + public PollServiceEventArgs(RequestMethod pRequest, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, UUID pId, int pTimeOutms) { Request = pRequest; HasEvents = pHasEvents; GetEvents = pGetEvents; NoEvents = pNoEvents; Id = pId; + TimeOutms = pTimeOutms; } } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index a91b02cc71..016ed9757c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -361,7 +361,7 @@ namespace OpenSim.Region.ClientStack.Linden // This will persist this beyond the expiry of the caps handlers MainServer.Instance.AddPollServiceHTTPHandler( capsBase + EventQueueGetUUID.ToString() + "/", - new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); + new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID,1000)); // 1 sec timeout Random rnd = new Random(Environment.TickCount); lock (m_ids) diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index a701b46db8..e93266c9e5 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp m_HttpServer.AddPollServiceHTTPHandler( uri, - new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); + new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode,25000)); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } @@ -216,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp m_HttpsServer.AddPollServiceHTTPHandler( uri, - new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); + new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode,25000)); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } From bc5d554f548e973221f8a18cdcb5a5883ed6039f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 4 Jul 2012 17:58:32 +0100 Subject: [PATCH 24/29] use the pollEvent timeout paramenter on pooling --- .../Servers/HttpServer/PollServiceRequestManager.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 125d9c29df..45b1375ff8 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -182,7 +182,7 @@ namespace OpenSim.Framework.Servers.HttpServer private bool m_running = true; - private int m_timeout = 1000; // increase timeout 250; +// private int m_timeout = 1000; // increase timeout 250; now use the event one public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout) { @@ -245,7 +245,7 @@ namespace OpenSim.Framework.Servers.HttpServer ~PollServiceRequestManager() { m_running = false; - m_timeout = -10000; // cause all to expire +// m_timeout = -10000; // cause all to expire Thread.Sleep(1000); // let the world move foreach (Thread t in m_workerThreads) @@ -299,7 +299,8 @@ namespace OpenSim.Framework.Servers.HttpServer PollServiceHttpRequest req; StreamReader str; - while (true) +// while (true) + while (m_running) { req = m_requests.Dequeue(5000); @@ -338,7 +339,9 @@ namespace OpenSim.Framework.Servers.HttpServer } else { - if ((Environment.TickCount - req.RequestTime) > m_timeout) +// if ((Environment.TickCount - req.RequestTime) > m_timeout) + + if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) { m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); From 4854d779041e987ae13de4f30a37e4fab1b7a3d7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Jul 2012 23:09:20 +0200 Subject: [PATCH 25/29] Add an EventType enum and Type field to the poll service event args. This allows the manager to tell what type of event it is. All events except for lsl http in go to the "slow queue" which is run once per second as before. --- .../HttpServer/PollServiceEventArgs.cs | 8 ++++ .../HttpServer/PollServiceRequestManager.cs | 37 +++++++++++++------ .../Scripting/LSLHttp/UrlModule.cs | 8 ++-- .../Shared/Api/Implementation/LSL_Api.cs | 2 +- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 2407533ab1..7c92a50155 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs @@ -45,6 +45,13 @@ namespace OpenSim.Framework.Servers.HttpServer public RequestMethod Request; public UUID Id; public int TimeOutms; + public EventType Type; + + public enum EventType : int + { + Normal = 0, + LslHttp = 1 + } public PollServiceEventArgs(RequestMethod pRequest, HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, UUID pId, int pTimeOutms) { @@ -54,6 +61,7 @@ namespace OpenSim.Framework.Servers.HttpServer NoEvents = pNoEvents; Id = pId; TimeOutms = pTimeOutms; + Type = EventType.Normal; } } } diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 45b1375ff8..c7c7c13c94 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -174,13 +174,15 @@ namespace OpenSim.Framework.Servers.HttpServer private readonly BaseHttpServer m_server; private BlockingQueue m_requests = new BlockingQueue(); - private static Queue m_retry_requests = new Queue(); + private BlockingQueue m_slowRequests = new BlockingQueue(); + private static Queue m_retryRequests = new Queue(); private uint m_WorkerThreadCount = 0; private Thread[] m_workerThreads; private Thread m_retrysThread; private bool m_running = true; + private int slowCount = 0; // private int m_timeout = 1000; // increase timeout 250; now use the event one @@ -195,7 +197,7 @@ namespace OpenSim.Framework.Servers.HttpServer { m_workerThreads[i] = Watchdog.StartThread( - poolWorkerJob, + PoolWorkerJob, String.Format("PollServiceWorkerThread{0}", i), ThreadPriority.Normal, false, @@ -217,15 +219,20 @@ namespace OpenSim.Framework.Servers.HttpServer { if (m_running) { - lock (m_retry_requests) - m_retry_requests.Enqueue(req); + lock (m_retryRequests) + m_retryRequests.Enqueue(req); } } public void Enqueue(PollServiceHttpRequest req) { if (m_running) - m_requests.Enqueue(req); + { + if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp) + m_slowRequests.Enqueue(req); + else + m_requests.Enqueue(req); + } } private void CheckRetries() @@ -234,10 +241,18 @@ namespace OpenSim.Framework.Servers.HttpServer { Thread.Sleep(100); // let the world move .. back to faster rate Watchdog.UpdateThread(); - lock (m_retry_requests) + lock (m_retryRequests) { - while (m_retry_requests.Count > 0 && m_running) - Enqueue(m_retry_requests.Dequeue()); + while (m_retryRequests.Count > 0 && m_running) + m_requests.Enqueue(m_retryRequests.Dequeue()); + } + slowCount++; + if (slowCount >= 10) + { + slowCount = 0; + + while (m_slowRequests.Count() > 0 && m_running) + m_requests.Enqueue(m_retryRequests.Dequeue()); } } } @@ -261,7 +276,7 @@ namespace OpenSim.Framework.Servers.HttpServer try { - foreach (PollServiceHttpRequest req in m_retry_requests) + foreach (PollServiceHttpRequest req in m_retryRequests) { m_server.DoHTTPGruntWork( req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), @@ -273,7 +288,7 @@ namespace OpenSim.Framework.Servers.HttpServer } PollServiceHttpRequest wreq; - m_retry_requests.Clear(); + m_retryRequests.Clear(); while (m_requests.Count() > 0) { @@ -294,7 +309,7 @@ namespace OpenSim.Framework.Servers.HttpServer // work threads - private void poolWorkerJob() + private void PoolWorkerJob() { PollServiceHttpRequest req; StreamReader str; diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index e93266c9e5..9c5596bbe3 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -172,9 +172,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp string uri = "/lslhttp/" + urlcode.ToString(); - m_HttpServer.AddPollServiceHTTPHandler( - uri, - new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode,25000)); + PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); + args.Type = PollServiceEventArgs.EventType.LslHttp; + m_HttpServer.AddPollServiceHTTPHandler(uri, args); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } @@ -422,7 +422,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) { - UrlData url = null; + UrlData url = null; RequestData requestData = null; lock (m_RequestMap) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fd8e586d37..58085946c4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7479,7 +7479,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llSHA1String(string src) { m_host.AddScriptLPS(1); - return Util.SHA1Hash(src, Encoding.UTF8).ToUpper(); + return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); } protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) From bf292ce26f5742eaf1ae534320506b28f3a5492c Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 5 Jul 2012 23:24:15 +0200 Subject: [PATCH 26/29] Fix the boo-boo --- .../Servers/HttpServer/PollServiceRequestManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index c7c7c13c94..06745f9b2b 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -229,9 +229,9 @@ namespace OpenSim.Framework.Servers.HttpServer if (m_running) { if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp) - m_slowRequests.Enqueue(req); - else m_requests.Enqueue(req); + else + m_slowRequests.Enqueue(req); } } @@ -252,7 +252,7 @@ namespace OpenSim.Framework.Servers.HttpServer slowCount = 0; while (m_slowRequests.Count() > 0 && m_running) - m_requests.Enqueue(m_retryRequests.Dequeue()); + m_requests.Enqueue(m_slowRequests.Dequeue()); } } } From b8c2efa49c35d623a6a2969322536fde67cb86dc Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 6 Jul 2012 00:23:05 +0200 Subject: [PATCH 27/29] Convert the slow request queue into a regular queue and add some cleanup and locking. --- .../HttpServer/PollServiceRequestManager.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 06745f9b2b..6f87c85b8d 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -174,7 +174,7 @@ namespace OpenSim.Framework.Servers.HttpServer private readonly BaseHttpServer m_server; private BlockingQueue m_requests = new BlockingQueue(); - private BlockingQueue m_slowRequests = new BlockingQueue(); + private static Queue m_slowRequests = new Queue(); private static Queue m_retryRequests = new Queue(); private uint m_WorkerThreadCount = 0; @@ -229,9 +229,14 @@ namespace OpenSim.Framework.Servers.HttpServer if (m_running) { if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp) + { m_requests.Enqueue(req); + } else - m_slowRequests.Enqueue(req); + { + lock (m_slowRequests) + m_slowRequests.Enqueue(req); + } } } @@ -251,8 +256,11 @@ namespace OpenSim.Framework.Servers.HttpServer { slowCount = 0; - while (m_slowRequests.Count() > 0 && m_running) - m_requests.Enqueue(m_slowRequests.Dequeue()); + lock (m_slowRequests) + { + while (m_slowRequests.Count > 0 && m_running) + m_requests.Enqueue(m_slowRequests.Dequeue()); + } } } } @@ -290,6 +298,12 @@ namespace OpenSim.Framework.Servers.HttpServer PollServiceHttpRequest wreq; m_retryRequests.Clear(); + lock (m_slowRequests) + { + while (m_slowRequests.Count > 0 && m_running) + m_requests.Enqueue(m_slowRequests.Dequeue()); + } + while (m_requests.Count() > 0) { try From ba91d4ba93103f82876e0f2563c34aa6e4767392 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 6 Jul 2012 01:06:48 +0100 Subject: [PATCH 28/29] Changed GetTexture error code RequestedRangeNotSatisfiable to NotFound, since viewers don't seem to handle that and keep retrying --- OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 217217e25e..0797215b77 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -226,7 +226,9 @@ namespace OpenSim.Capabilities.Handlers // sending back the last byte instead of an error status if (start >= texture.Data.Length) { - response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable; +// response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable; + // viewers don't seem to handle RequestedRangeNotSatisfiable and keep retrying with same parameters + response.StatusCode = (int)System.Net.HttpStatusCode.NotFound; } else { From ce7864632bf239a44321cc5806a95a78e0f259ed Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 6 Jul 2012 17:13:11 +0100 Subject: [PATCH 29/29] added llSetVelocity. will refuse to work on vehicles and on attachments ( this last may need fix) added also some code for llSetAngularVelocity but not working still --- .../Framework/Scenes/SceneObjectPart.cs | 28 +++++++++++++++++++ .../Shared/Api/Implementation/LSL_Api.cs | 18 +++++++++++- .../Shared/Api/Interface/ILSL_Api.cs | 2 ++ .../Shared/Api/Runtime/LSL_Stub.cs | 10 +++++++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a48605d3d8..ed32adc7c1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1845,6 +1845,34 @@ namespace OpenSim.Region.Framework.Scenes } } +// SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future + public void SetVelocity(Vector3 pVel, bool localGlobalTF) + { + if (ParentGroup == null || ParentGroup.IsDeleted) + return; + + if (ParentGroup.IsAttachment) + return; // don't work on attachments (for now ??) + + SceneObjectPart root = ParentGroup.RootPart; + + if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles + return; + + PhysicsActor pa = root.PhysActor; + + if (pa == null || !pa.IsPhysical) + return; + + if (localGlobalTF) + { + pVel = pVel * GetWorldRotation(); + } + + ParentGroup.Velocity = pVel; + } + + /// /// hook to the physics scene to apply angular impulse /// This is sent up to the group, which then finds the root prim diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 58085946c4..0ee27482c7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2538,6 +2538,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.ApplyImpulse(v, local != 0); } + public void llApplyRotationalImpulse(LSL_Vector force, int local) { m_host.AddScriptLPS(1); @@ -2564,6 +2565,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api llSetTorque(torque, local); } + public void llSetVelocity(LSL_Vector vel, int local) + { + m_host.AddScriptLPS(1); + m_host.SetVelocity(new Vector3((float)vel.x, (float)vel.y, (float)vel.z), local != 0); + } + public LSL_Vector llGetVel() { m_host.AddScriptLPS(1); @@ -2590,10 +2597,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); } + + public void llSetAngularVelocity(LSL_Vector avel, int local) + { + m_host.AddScriptLPS(1); + // Still not done !!!! +// m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0); + } + public LSL_Vector llGetOmega() { m_host.AddScriptLPS(1); - return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z); + Vector3 avel = m_host.AngularVelocity; + return new LSL_Vector(avel.X, avel.Y, avel.Z); } public LSL_Float llGetTimeOfDay() diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 50f520af74..40ae495613 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -328,6 +328,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llSensorRemove(); void llSensorRepeat(string name, string id, int type, double range, double arc, double rate); void llSetAlpha(double alpha, int face); + void llSetAngularVelocity(LSL_Vector angvelocity, int local); void llSetBuoyancy(double buoyancy); void llSetCameraAtOffset(LSL_Vector offset); void llSetCameraEyeOffset(LSL_Vector offset); @@ -376,6 +377,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llSetVehicleRotationParam(int param, LSL_Rotation rot); void llSetVehicleType(int type); void llSetVehicleVectorParam(int param, LSL_Vector vec); + void llSetVelocity(LSL_Vector velocity, int local); void llShout(int channelID, string text); LSL_Float llSin(double f); void llSitTarget(LSL_Vector offset, LSL_Rotation rot); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 116f639a87..2f8e1692ef 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1475,6 +1475,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llSetAlpha(alpha, face); } + public void llSetAngularVelocity(LSL_Vector angvelocity, int local) + { + m_LSL_Functions.llSetAngularVelocity(angvelocity, local); + } + public void llSetBuoyancy(double buoyancy) { m_LSL_Functions.llSetBuoyancy(buoyancy); @@ -1705,6 +1710,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llSetVehicleVectorParam(param, vec); } + public void llSetVelocity(LSL_Vector velocity, int local) + { + m_LSL_Functions.llSetVelocity(velocity, local); + } + public void llShout(int channelID, string text) { m_LSL_Functions.llShout(channelID, text);