From d0ae8bb86aa64632cf2e3d4e879d7a5f5fb96bb3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 7 Nov 2016 12:45:20 +0000 Subject: start removing old hack of using SetMomentum to just set instant velocity, now that TargetVelocity is avaiable --- .../Region/PhysicsModules/ubOde/ODECharacter.cs | 40 +++++++++++++++++++--- OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | 5 +-- OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs | 1 + 3 files changed, 39 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index 9640e91..f7e1044 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs @@ -632,6 +632,25 @@ namespace OpenSim.Region.PhysicsModule.ubOde } } + public override Vector3 TargetVelocity + { + get + { + return m_targetVelocity; + } + set + { + if (value.IsFinite()) + { + AddChange(changes.TargetVelocity, value); + } + else + { + m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character"); + } + } + } + public override Vector3 Torque { get { return Vector3.Zero; } @@ -689,7 +708,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } else { - AddChange(changes.Velocity, force); + AddChange(changes.TargetVelocity, force); } } else @@ -1671,16 +1690,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde { AvatarGeomAndBodyDestroy(); - float oldsz = m_size.Z; m_size = pSize; - AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z + (m_size.Z - oldsz) * 0.5f); - Velocity = Vector3.Zero; - +// Velocity = Vector3.Zero; + m_targetVelocity = Vector3.Zero; _parent_scene.actor_name_map[collider] = (PhysicsActor)this; _parent_scene.actor_name_map[capsule] = (PhysicsActor)this; @@ -1739,6 +1756,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void changeVelocity(Vector3 newVel) { + _velocity = newVel; + setFreeMove(); + + if (Body != IntPtr.Zero) + d.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); + } + + private void changeTargetVelocity(Vector3 newVel) + { m_pidControllerActive = true; m_freemove = false; _target_velocity = newVel; @@ -1881,6 +1907,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde changeVelocity((Vector3)arg); break; + case changes.TargetVelocity: + changeTargetVelocity((Vector3)arg); + break; + // case changes.Acceleration: // changeacceleration((Vector3)arg); // break; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 4adf87e..3403f4b 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -3805,6 +3805,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde changevelocity((Vector3)arg); break; + case changes.TargetVelocity: + break; + // case changes.Acceleration: // changeacceleration((Vector3)arg); // break; @@ -3933,8 +3936,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde donullchange(); break; - - default: donullchange(); break; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index e6aa7ef..6267051 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -112,6 +112,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde OriOffset, // not in use // arg Vector3 new position in local coords. Changes prim position in object Velocity, + TargetVelocity, AngVelocity, Acceleration, Force, -- cgit v1.1 From 07893ec3e7e2bfe2066eb0477574543b4efa6930 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 7 Nov 2016 16:03:23 +0000 Subject: a few more changes on the avatars Velocity/TargetVelocity/SetMomentum. Need talk with Robert before last changes bc of bullet --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 30 +++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6f4d6c3..f96fb85 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -781,6 +781,34 @@ namespace OpenSim.Region.Framework.Scenes } } + // requested Velocity for physics engines avatar motors + // only makes sense if there is a physical rep + public Vector3 TargetVelocity + { + get + { + if (PhysicsActor != null) + return PhysicsActor.TargetVelocity; + else + return Vector3.Zero; + } + + set + { + if (PhysicsActor != null) + { + try + { + PhysicsActor.TargetVelocity = value; + } + catch (Exception e) + { + m_log.Error("[SCENE PRESENCE]: TARGETVELOCITY " + e.Message); + } + } + } + } + private Quaternion m_bodyRot = Quaternion.Identity; /// @@ -3649,7 +3677,7 @@ namespace OpenSim.Region.Framework.Scenes m_forceToApplyValid = true; } */ - Velocity = direc; + TargetVelocity = direc; Animator.UpdateMovementAnimations(); } -- cgit v1.1 From 7ebc08ad6512670ed9897c27475e278168eab18d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 7 Nov 2016 18:34:45 +0000 Subject: partially revert commit f29d5ad662387b97d9e881f28df584dc19fa8c07: if mesh asset does not contain data for PRIM type warn and use convex, do avoid physical peims going underground etc --- .../PhysicsModules/ubOdeMeshing/Meshmerizer.cs | 276 +++++++++++---------- 1 file changed, 141 insertions(+), 135 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs index bcd1530..ca94034 100644 --- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs +++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs @@ -395,6 +395,10 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing { // m_log.DebugFormat("[MESH]: experimental mesh proxy generation for {0}", primName); + + // for ubOde we have a diferent mesh use priority + // priority is to use full mesh then decomposition + // SL does the oposite bool usemesh = false; coords = new List(); @@ -443,16 +447,10 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing if (physicsParms != null) usemesh = true; - else - { - m_log.WarnFormat("[MESH]: Data for PRIM shape type not found for prim {0}",primName); - return false; - } } if(!usemesh && (map.ContainsKey("physics_convex"))) physicsParms = (OSDMap)map["physics_convex"]; - if (physicsParms == null) { @@ -555,160 +553,168 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing range = range - min; range *= invMaxU16; - if (!convex && cmap.ContainsKey("HullList") && cmap.ContainsKey("Positions")) + if(!convex) { - List hsizes = new List(); - int totalpoints = 0; - data = cmap["HullList"].AsBinary(); - for (i = 0; i < data.Length; i++) + // if mesh data not present and not convex then we need convex decomposition data + if (cmap.ContainsKey("HullList") && cmap.ContainsKey("Positions")) { - t1 = data[i]; - if (t1 == 0) - t1 = 256; - totalpoints += t1; - hsizes.Add(t1); - } + List hsizes = new List(); + int totalpoints = 0; + data = cmap["HullList"].AsBinary(); + for (i = 0; i < data.Length; i++) + { + t1 = data[i]; + if (t1 == 0) + t1 = 256; + totalpoints += t1; + hsizes.Add(t1); + } - data = cmap["Positions"].AsBinary(); - int ptr = 0; - int vertsoffset = 0; + data = cmap["Positions"].AsBinary(); + int ptr = 0; + int vertsoffset = 0; - if (totalpoints == data.Length / 6) // 2 bytes per coord, 3 coords per point - { - foreach (int hullsize in hsizes) + if (totalpoints == data.Length / 6) // 2 bytes per coord, 3 coords per point { - for (i = 0; i < hullsize; i++ ) - { - t1 = data[ptr++]; - t1 += data[ptr++] << 8; - t2 = data[ptr++]; - t2 += data[ptr++] << 8; - t3 = data[ptr++]; - t3 += data[ptr++] << 8; - - f3 = new float3((t1 * range.X + min.X), - (t2 * range.Y + min.Y), - (t3 * range.Z + min.Z)); - vs.Add(f3); - } - - if(hullsize <3) + foreach (int hullsize in hsizes) { - vs.Clear(); - continue; - } + for (i = 0; i < hullsize; i++ ) + { + t1 = data[ptr++]; + t1 += data[ptr++] << 8; + t2 = data[ptr++]; + t2 += data[ptr++] << 8; + t3 = data[ptr++]; + t3 += data[ptr++] << 8; + + f3 = new float3((t1 * range.X + min.X), + (t2 * range.Y + min.Y), + (t3 * range.Z + min.Z)); + vs.Add(f3); + } - if (hullsize <5) - { - foreach (float3 point in vs) + if(hullsize <3) { - c.X = point.x; - c.Y = point.y; - c.Z = point.z; - coords.Add(c); + vs.Clear(); + continue; } - f = new Face(vertsoffset, vertsoffset + 1, vertsoffset + 2); - faces.Add(f); - if (hullsize == 4) + if (hullsize <5) { - // not sure about orientation.. - f = new Face(vertsoffset, vertsoffset + 2, vertsoffset + 3); - faces.Add(f); - f = new Face(vertsoffset, vertsoffset + 3, vertsoffset + 1); - faces.Add(f); - f = new Face(vertsoffset + 3, vertsoffset + 2, vertsoffset + 1); + foreach (float3 point in vs) + { + c.X = point.x; + c.Y = point.y; + c.Z = point.z; + coords.Add(c); + } + f = new Face(vertsoffset, vertsoffset + 1, vertsoffset + 2); faces.Add(f); + + if (hullsize == 4) + { + // not sure about orientation.. + f = new Face(vertsoffset, vertsoffset + 2, vertsoffset + 3); + faces.Add(f); + f = new Face(vertsoffset, vertsoffset + 3, vertsoffset + 1); + faces.Add(f); + f = new Face(vertsoffset + 3, vertsoffset + 2, vertsoffset + 1); + faces.Add(f); + } + vertsoffset += vs.Count; + vs.Clear(); + continue; + } + /* + if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f)) + { + vs.Clear(); + continue; } - vertsoffset += vs.Count; - vs.Clear(); - continue; - } -/* - if (!HullUtils.ComputeHull(vs, ref hullr, 0, 0.0f)) - { - vs.Clear(); - continue; - } - nverts = hullr.Vertices.Count; - nindexs = hullr.Indices.Count; + nverts = hullr.Vertices.Count; + nindexs = hullr.Indices.Count; - if (nindexs % 3 != 0) - { - vs.Clear(); - continue; - } + if (nindexs % 3 != 0) + { + vs.Clear(); + continue; + } - for (i = 0; i < nverts; i++) - { - c.X = hullr.Vertices[i].x; - c.Y = hullr.Vertices[i].y; - c.Z = hullr.Vertices[i].z; - coords.Add(c); - } + for (i = 0; i < nverts; i++) + { + c.X = hullr.Vertices[i].x; + c.Y = hullr.Vertices[i].y; + c.Z = hullr.Vertices[i].z; + coords.Add(c); + } - for (i = 0; i < nindexs; i += 3) - { - t1 = hullr.Indices[i]; - if (t1 > nverts) - break; - t2 = hullr.Indices[i + 1]; - if (t2 > nverts) - break; - t3 = hullr.Indices[i + 2]; - if (t3 > nverts) - break; - f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); - faces.Add(f); - } -*/ - List indices; - if (!HullUtils.ComputeHull(vs, out indices)) - { - vs.Clear(); - continue; - } + for (i = 0; i < nindexs; i += 3) + { + t1 = hullr.Indices[i]; + if (t1 > nverts) + break; + t2 = hullr.Indices[i + 1]; + if (t2 > nverts) + break; + t3 = hullr.Indices[i + 2]; + if (t3 > nverts) + break; + f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); + faces.Add(f); + } + */ + List indices; + if (!HullUtils.ComputeHull(vs, out indices)) + { + vs.Clear(); + continue; + } - nverts = vs.Count; - nindexs = indices.Count; + nverts = vs.Count; + nindexs = indices.Count; - if (nindexs % 3 != 0) - { - vs.Clear(); - continue; - } + if (nindexs % 3 != 0) + { + vs.Clear(); + continue; + } - for (i = 0; i < nverts; i++) - { - c.X = vs[i].x; - c.Y = vs[i].y; - c.Z = vs[i].z; - coords.Add(c); - } + for (i = 0; i < nverts; i++) + { + c.X = vs[i].x; + c.Y = vs[i].y; + c.Z = vs[i].z; + coords.Add(c); + } - for (i = 0; i < nindexs; i += 3) - { - t1 = indices[i]; - if (t1 > nverts) - break; - t2 = indices[i + 1]; - if (t2 > nverts) - break; - t3 = indices[i + 2]; - if (t3 > nverts) - break; - f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); - faces.Add(f); + for (i = 0; i < nindexs; i += 3) + { + t1 = indices[i]; + if (t1 > nverts) + break; + t2 = indices[i + 1]; + if (t2 > nverts) + break; + t3 = indices[i + 2]; + if (t3 > nverts) + break; + f = new Face(vertsoffset + t1, vertsoffset + t2, vertsoffset + t3); + faces.Add(f); + } + vertsoffset += nverts; + vs.Clear(); } - vertsoffset += nverts; - vs.Clear(); } + if (coords.Count > 0 && faces.Count > 0) + return true; + } + else + { + // if neither mesh or decomposition present, warn and use convex + m_log.WarnFormat("[MESH]: Data for PRIM shape type ( mesh or decomposition) not found for prim {0}",primName); } - if (coords.Count > 0 && faces.Count > 0) - return true; } - vs.Clear(); if (cmap.ContainsKey("BoundingVerts")) -- cgit v1.1 From 6c44dceced81f3ae0a7650f8186f17b15dd55fe0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 8 Nov 2016 13:39:49 +0000 Subject: change display and log of normal script errors --- .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 67 +++++++++++++++------- 1 file changed, 47 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 611df58..d725907 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -924,26 +924,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance { try { - // DISPLAY ERROR INWORLD - string text = FormatException(e); - - if (text.Length > 1000) - text = text.Substring(0, 1000); - Engine.World.SimChat(Utils.StringToBytes(text), - ChatTypeEnum.DebugChannel, 2147483647, - Part.AbsolutePosition, - Part.Name, Part.UUID, false); - - - m_log.Debug(string.Format( - "[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ", - ScriptName, - data.EventName, - PrimName, - Part.UUID, - Part.AbsolutePosition, - Part.ParentGroup.Scene.Name), - e); + + if(e.InnerException != null && e.InnerException is ScriptException) + { + string text = e.InnerException.Message + + "(script: " + ScriptName + + " event: " + data.EventName + + " at " + Part.AbsolutePosition + ")"; + if (text.Length > 1000) + text = text.Substring(0, 1000); + Engine.World.SimChat(Utils.StringToBytes(text), + ChatTypeEnum.DebugChannel, 2147483647, + Part.AbsolutePosition, + Part.Name, Part.UUID, false); + m_log.Debug(string.Format( + "[SCRIPT INSTANCE]: {0} (at event {1}, part {2} {3} at {4} in {5}", + e.InnerException.Message, + data.EventName, + PrimName, + Part.UUID, + Part.AbsolutePosition, + Part.ParentGroup.Scene.Name)); + + } + else + { + + // DISPLAY ERROR INWORLD + string text = FormatException(e); + + if (text.Length > 1000) + text = text.Substring(0, 1000); + Engine.World.SimChat(Utils.StringToBytes(text), + ChatTypeEnum.DebugChannel, 2147483647, + Part.AbsolutePosition, + Part.Name, Part.UUID, false); + + + m_log.Debug(string.Format( + "[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ", + ScriptName, + data.EventName, + PrimName, + Part.UUID, + Part.AbsolutePosition, + Part.ParentGroup.Scene.Name), + e); + } } catch (Exception) { -- cgit v1.1 From 92984556e1e8b8386b2362b821679ed76891e262 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 8 Nov 2016 23:09:53 +0000 Subject: change the clock source on tokenBucket --- .../Region/ClientStack/Linden/UDP/TokenBucket.cs | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs index 0ac573a..7b9661b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/TokenBucket.cs @@ -62,8 +62,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// protected const float m_minimumDripRate = 1500; - /// Time of the last drip, in system ticks - protected Int32 m_lastDrip; + /// Time of the last drip + protected double m_lastDrip; /// /// The number of bytes that can be sent at this moment. This is the @@ -166,10 +166,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// protected float m_totalDripRequest; public float TotalDripRequest - { - get { return m_totalDripRequest; } - set { m_totalDripRequest = value; } - } + { + get { return m_totalDripRequest; } + set { m_totalDripRequest = value; } + } #endregion Properties @@ -193,9 +193,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP Parent = parent; RequestedDripRate = dripRate; RequestedBurst = MaxBurst; - // TotalDripRequest = dripRate; // this will be overwritten when a child node registers - // MaxBurst = (Int64)((double)dripRate * m_quantumsPerBurst); - m_lastDrip = Util.EnvironmentTickCount() + 100000; + m_lastDrip = Util.GetTimeStampMS() + 50.0; } #endregion Constructor @@ -210,7 +208,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected float DripRateModifier() { float driprate = DripRate; - return driprate >= TotalDripRequest ? 1.0f : driprate / TotalDripRequest; + return driprate >= TotalDripRequest ? 1.0f : (driprate / TotalDripRequest); } /// @@ -313,14 +311,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP return; } - Int32 now = Util.EnvironmentTickCount(); - Int32 deltaMS = now - m_lastDrip; + double now = Util.GetTimeStampMS(); + double deltaMS = now - m_lastDrip; m_lastDrip = now; if (deltaMS <= 0) return; - m_tokenCount += deltaMS * DripRate * m_timeScale; + m_tokenCount += (float)deltaMS * DripRate * m_timeScale; float burst = Burst; if (m_tokenCount > burst) -- cgit v1.1 From 94d2422230be405f44be3697e663ef4fac8369f8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 9 Nov 2016 10:21:02 +0000 Subject: change the clock source on udp outgoing, remove some dead code --- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 134 ++------------------- .../Region/ClientStack/Linden/UDP/ThrottleRates.cs | 4 +- .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 25 ---- 3 files changed, 10 insertions(+), 153 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 0e67095..8355f2b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -323,7 +323,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP protected int m_elapsedMSSinceLastStatReport = 0; /// Environment.TickCount of the last time the outgoing packet handler executed - protected int m_tickLastOutgoingPacketHandler; + protected double m_tickLastOutgoingPacketHandler; /// Keeps track of the number of elapsed milliseconds since the last time the outgoing packet handler looped protected int m_elapsedMSOutgoingPacketHandler; @@ -356,20 +356,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } - - protected ExpiringCache> m_pendingCache = new ExpiringCache>(); - /// - /// Event used to signal when queued packets are available for sending. - /// - /// - /// This allows the outbound loop to only operate when there is data to send rather than continuously polling. - /// Some data is sent immediately and not queued. That data would not trigger this event. - /// WRONG use. May be usefull in future revision - /// -// protected AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false); - protected Pool m_incomingPacketPool; /// @@ -467,8 +455,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP int sceneThrottleBps = 0; bool usePools = false; - - IConfig config = configSource.Configs["ClientStack.LindenUDP"]; if (config != null) { @@ -927,10 +913,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP } PacketPool.Instance.ReturnPacket(packet); - - /// WRONG use. May be usefull in future revision -// if (packetQueued) -// m_dataPresentEvent.Set(); } /// @@ -2079,14 +2061,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_sendPing = false; // Update elapsed time - int thisTick = Environment.TickCount & Int32.MaxValue; - if (m_tickLastOutgoingPacketHandler > thisTick) - m_elapsedMSOutgoingPacketHandler += ((Int32.MaxValue - m_tickLastOutgoingPacketHandler) + thisTick); - else - m_elapsedMSOutgoingPacketHandler += (thisTick - m_tickLastOutgoingPacketHandler); - + double thisTick = Util.GetTimeStampMS(); + int deltaMS = (int)(thisTick - m_tickLastOutgoingPacketHandler); m_tickLastOutgoingPacketHandler = thisTick; + // update some 1ms resolution chained timers + + m_elapsedMSOutgoingPacketHandler += deltaMS; + // Check for pending outgoing resends every 100ms if (m_elapsedMSOutgoingPacketHandler >= 100) { @@ -2109,15 +2091,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_sendPing = true; m_elapsed500MSOutgoingPacketHandler = 0; } - #endregion Update Timers - // Use this for emergency monitoring -- bug hunting - //if (m_scene.EmergencyMonitoring) - // clientPacketHandler = MonitoredClientOutgoingPacketHandler; - //else - // clientPacketHandler = ClientOutgoingPacketHandler; - // Handle outgoing packets, resends, acknowledgements, and pings for each // client. m_packetSent will be set to true if a packet is sent Scene.ForEachClient(clientPacketHandler); @@ -2129,7 +2104,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if(Scene.GetNumberOfClients() == 0) { - Thread.Sleep(250); // be friendly to PIs, but how long ?? + Thread.Sleep(100); } else if (!m_packetSent) // Thread.Sleep((int)TickCountResolution); outch this is bad on linux @@ -2204,99 +2179,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public long IncomingPacketsProcessed { get; protected set; } - protected void MonitoredClientOutgoingPacketHandler(IClientAPI client) - { - nticks++; - watch1.Start(); - m_currentOutgoingClient = client; - - try - { - if (client is LLClientView) - { - LLClientView llClient = (LLClientView)client; - LLUDPClient udpClient = llClient.UDPClient; - - if (udpClient.IsConnected) - { - if (m_resendUnacked) - { - nticksUnack++; - watch2.Start(); - - HandleUnacked(llClient); - - watch2.Stop(); - avgResendUnackedTicks = (nticksUnack - 1)/(float)nticksUnack * avgResendUnackedTicks + (watch2.ElapsedTicks / (float)nticksUnack); - watch2.Reset(); - } - - if (m_sendAcks) - { - nticksAck++; - watch2.Start(); - - SendAcks(udpClient); - - watch2.Stop(); - avgSendAcksTicks = (nticksAck - 1) / (float)nticksAck * avgSendAcksTicks + (watch2.ElapsedTicks / (float)nticksAck); - watch2.Reset(); - } - - if (m_sendPing) - { - nticksPing++; - watch2.Start(); - - SendPing(udpClient); - - watch2.Stop(); - avgSendPingTicks = (nticksPing - 1) / (float)nticksPing * avgSendPingTicks + (watch2.ElapsedTicks / (float)nticksPing); - watch2.Reset(); - } - - watch2.Start(); - // Dequeue any outgoing packets that are within the throttle limits - if (udpClient.DequeueOutgoing()) - { - m_packetSent = true; - npacksSent++; - } - else - { - npackNotSent++; - } - - watch2.Stop(); - avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks); - watch2.Reset(); - - } - else - { - m_log.WarnFormat("[LLUDPSERVER]: Client is not connected"); - } - } - } - catch (Exception ex) - { - m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name + - " threw an exception: " + ex.Message, ex); - } - watch1.Stop(); - avgProcessingTicks = (nticks - 1) / (float)nticks * avgProcessingTicks + (watch1.ElapsedTicks / (float)nticks); - watch1.Reset(); - - // reuse this -- it's every ~100ms - if (Scene.EmergencyMonitoring && nticks % 100 == 0) - { - m_log.InfoFormat("[LLUDPSERVER]: avg processing ticks: {0} avg unacked: {1} avg acks: {2} avg ping: {3} avg dequeue: {4} (TickCountRes: {5} sent: {6} notsent: {7})", - avgProcessingTicks, avgResendUnackedTicks, avgSendAcksTicks, avgSendPingTicks, avgDequeueTicks, TickCountResolution, npacksSent, npackNotSent); - npackNotSent = npacksSent = 0; - } - - } - #endregion protected void ProcessInPacket(IncomingPacket incomingPacket) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs b/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs index a476b91..6278e36 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/ThrottleRates.cs @@ -92,8 +92,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP Asset = throttleConfig.GetInt("asset_default", 10500); Total = Resend + Land + Wind + Cloud + Task + Texture + Asset; - // 3000000 bps default max - ClientMaxRate = throttleConfig.GetInt("client_throttle_max_bps", 375000); + // 5120000 bps default max + ClientMaxRate = throttleConfig.GetInt("client_throttle_max_bps", 640000); if (ClientMaxRate > 1000000) ClientMaxRate = 1000000; // no more than 8Mbps diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 08d0fbf..071530b 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -126,13 +126,6 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden (mod, cmd) => MainConsole.Instance.Output(GetThrottlesReport(cmd))); scene.AddCommand( - "Comms", this, "emergency-monitoring", - "emergency-monitoring", - "Go on/off emergency monitoring mode", - "Go on/off emergency monitoring mode", - HandleEmergencyMonitoring); - - scene.AddCommand( "Comms", this, "show client stats", "show client stats [first_name last_name]", "Show client request stats", @@ -197,24 +190,6 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden return report.ToString(); } - protected void HandleEmergencyMonitoring(string module, string[] cmd) - { - bool mode = true; - if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on")) - { - mode = true; - MainConsole.Instance.Output("Emergency Monitoring ON"); - } - else - { - mode = false; - MainConsole.Instance.Output("Emergency Monitoring OFF"); - } - - foreach (Scene s in m_scenes.Values) - s.EmergencyMonitoring = mode; - } - protected string GetColumnEntry(string entry, int maxLength, int columnPadding) { return string.Format( -- cgit v1.1 From c349a1a5e76a97d8b421afedcbb6320e846404ad Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 9 Nov 2016 11:21:46 +0000 Subject: also log estimated average Util.GetTimeStampMS() resolution --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 8355f2b..ffdb639 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -444,10 +444,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP int now = start; while (now == start) now = Environment.TickCount; - TickCountResolution += (float)(now - start) * 0.1f; + TickCountResolution += (float)(now - start); } - TickCountResolution = (float)Math.Ceiling(TickCountResolution); - m_log.Info("[LLUDPSERVER]: Average Environment.TickCount resolution: " + TickCountResolution + "ms"); + m_log.Info("[LLUDPSERVER]: Average Environment.TickCount resolution: " + TickCountResolution * 0.1f + "ms"); + + TickCountResolution = 0f; + for (int i = 0; i < 100; i++) + { + double start = Util.GetTimeStampMS(); + double now = start; + while (now == start) + now = Util.GetTimeStampMS(); + TickCountResolution += (float)((now - start)); + } + + TickCountResolution = (float)Math.Round(TickCountResolution * 0.01f,6,MidpointRounding.AwayFromZero); + m_log.Info("[LLUDPSERVER]: Average Util.GetTimeStampMS resolution: " + TickCountResolution + "ms"); #endregion Environment.TickCount Measurement -- cgit v1.1 From 924c5fb55e8e5561c2d9d939b1c5dd77a9d6955a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 9 Nov 2016 19:41:07 +0000 Subject: minor cleanup --- .../UserAccounts/RemoteUserAccountServiceConnector.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index eead05d..9140d78 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -144,10 +144,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts return account; account = base.GetUserAccount(scopeID, userID); - lock(m_Cache) - if(account != null) + if(account != null) + { + lock(m_Cache) m_Cache.Cache(userID, account); - + } return account; } @@ -162,9 +163,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts account = base.GetUserAccount(scopeID, firstName, lastName); if (account != null) + { lock(m_Cache) m_Cache.Cache(account.PrincipalID, account); - + } return account; } @@ -195,16 +197,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts List ext = base.GetUserAccounts(scopeID, missing); if(ext != null && ext.Count >0 ) { - accs.AddRange(ext); foreach(UserAccount acc in ext) { if(acc != null) + { + accs.Add(acc); lock(m_Cache) m_Cache.Cache(acc.PrincipalID, acc); + } } } } - return accs; } -- cgit v1.1 From 1e1d0d8204181e4dedf438332625941cd56b02c2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 9 Nov 2016 20:09:49 +0000 Subject: move UserAccountCache access locking to its methods and not callers. --- .../LocalUserAccountServiceConnector.cs | 18 ++---- .../RemoteUserAccountServiceConnector.cs | 27 +++------ .../UserAccounts/UserAccountCache.cs | 64 +++++++++++++--------- 3 files changed, 54 insertions(+), 55 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 3127199..a413a8b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -154,14 +154,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { bool inCache = false; UserAccount account; - lock(m_Cache) - account = m_Cache.Get(userID, out inCache); + account = m_Cache.Get(userID, out inCache); if (inCache) return account; account = UserAccountService.GetUserAccount(scopeID, userID); - lock(m_Cache) - m_Cache.Cache(userID, account); + m_Cache.Cache(userID, account); return account; } @@ -170,15 +168,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { bool inCache = false; UserAccount account; - lock(m_Cache) - account = m_Cache.Get(firstName + " " + lastName, out inCache); + account = m_Cache.Get(firstName + " " + lastName, out inCache); if (inCache) return account; account = UserAccountService.GetUserAccount(scopeID, firstName, lastName); if (account != null) - lock(m_Cache) - m_Cache.Cache(account.PrincipalID, account); + m_Cache.Cache(account.PrincipalID, account); return account; } @@ -201,8 +197,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { if(UUID.TryParse(id, out uuid)) { - lock(m_Cache) - account = m_Cache.Get(uuid, out inCache); + account = m_Cache.Get(uuid, out inCache); if (inCache) ret.Add(account); else @@ -220,8 +215,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts foreach(UserAccount acc in ext) { if(acc != null) - lock(m_Cache) - m_Cache.Cache(acc.PrincipalID, acc); + m_Cache.Cache(acc.PrincipalID, acc); } } return ret; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index 9140d78..60dd97a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -128,8 +128,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts // flags, title, etc. And country, don't forget country! private void OnNewClient(IClientAPI client) { - lock(m_Cache) - m_Cache.Remove(client.Name); + m_Cache.Remove(client.Name); } #region Overwritten methods from IUserAccountService @@ -138,17 +137,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { bool inCache = false; UserAccount account; - lock(m_Cache) - account = m_Cache.Get(userID, out inCache); + account = m_Cache.Get(userID, out inCache); if (inCache) return account; account = base.GetUserAccount(scopeID, userID); if(account != null) - { - lock(m_Cache) - m_Cache.Cache(userID, account); - } + m_Cache.Cache(userID, account); + return account; } @@ -156,17 +152,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { bool inCache = false; UserAccount account; - lock(m_Cache) - account = m_Cache.Get(firstName + " " + lastName, out inCache); + account = m_Cache.Get(firstName + " " + lastName, out inCache); if (inCache) return account; account = base.GetUserAccount(scopeID, firstName, lastName); if (account != null) - { - lock(m_Cache) - m_Cache.Cache(account.PrincipalID, account); - } + m_Cache.Cache(account.PrincipalID, account); + return account; } @@ -183,8 +176,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { if(UUID.TryParse(id, out uuid)) { - lock(m_Cache) - account = m_Cache.Get(uuid, out inCache); + account = m_Cache.Get(uuid, out inCache); if (inCache) accs.Add(account); else @@ -202,8 +194,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts if(acc != null) { accs.Add(acc); - lock(m_Cache) - m_Cache.Cache(acc.PrincipalID, acc); + m_Cache.Cache(acc.PrincipalID, acc); } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs index 53610d9..97baf87 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs @@ -44,6 +44,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts private ExpiringCache m_UUIDCache; private ExpiringCache m_NameCache; + private object accessLock = new object(); public UserAccountCache() { @@ -54,60 +55,73 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public void Cache(UUID userID, UserAccount account) { // Cache even null accounts - m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS); - if (account != null) - m_NameCache.AddOrUpdate(account.Name, account.PrincipalID, CACHE_EXPIRATION_SECONDS); + lock(accessLock) + { + m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS); + if (account != null) + m_NameCache.AddOrUpdate(account.Name, account.PrincipalID, CACHE_EXPIRATION_SECONDS); //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID); + } } public void Invalidate(UUID userID) { - m_UUIDCache.Remove(userID); + lock(accessLock) + m_UUIDCache.Remove(userID); } public UserAccount Get(UUID userID, out bool inCache) { UserAccount account = null; inCache = false; - if (m_UUIDCache.TryGetValue(userID, out account)) + lock(accessLock) { - //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName); - inCache = true; - return account; + if (m_UUIDCache.TryGetValue(userID, out account)) + { + //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName); + inCache = true; + return account; + } } - return null; } public UserAccount Get(string name, out bool inCache) { inCache = false; - if (!m_NameCache.Contains(name)) - return null; + lock(accessLock) + { + if (!m_NameCache.Contains(name)) + return null; - UserAccount account = null; - UUID uuid = UUID.Zero; - if (m_NameCache.TryGetValue(name, out uuid)) - if (m_UUIDCache.TryGetValue(uuid, out account)) + UserAccount account = null; + UUID uuid = UUID.Zero; + if (m_NameCache.TryGetValue(name, out uuid)) { - inCache = true; - return account; + if (m_UUIDCache.TryGetValue(uuid, out account)) + { + inCache = true; + return account; + } } - + } return null; } public void Remove(string name) { - if (!m_NameCache.Contains(name)) - return; - - UUID uuid = UUID.Zero; - if (m_NameCache.TryGetValue(name, out uuid)) + lock(accessLock) { - m_NameCache.Remove(name); - m_UUIDCache.Remove(uuid); + if (!m_NameCache.Contains(name)) + return; + + UUID uuid = UUID.Zero; + if (m_NameCache.TryGetValue(name, out uuid)) + { + m_NameCache.Remove(name); + m_UUIDCache.Remove(uuid); + } } } } -- cgit v1.1 From 53003db4cf8fe468a4c417db72c0dfd9b6c30404 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 9 Nov 2016 22:12:27 +0000 Subject: stop warning about integer division cast to float --- OpenSim/Region/Framework/Scenes/Scene.cs | 5 ++--- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 168080f..ca32940 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -67,8 +67,6 @@ namespace OpenSim.Region.Framework.Scenes #region Fields - public bool EmergencyMonitoring = false; - /// /// Show debug information about animations. /// @@ -4606,7 +4604,8 @@ Label_GroupsDone: } // TODO: This check should probably be in QueryAccess(). - ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, RegionInfo.RegionSizeX / 2, RegionInfo.RegionSizeY / 2); + ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, + (float)RegionInfo.RegionSizeX * 0.5f, (float)RegionInfo.RegionSizeY * 0.5f); if (nearestParcel == null) { m_log.InfoFormat( diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 1141f54..f5f83ca 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -246,11 +246,11 @@ namespace OpenSim.Region.Framework.Scenes // try to work around that scale down X and Y acording to region size, so reducing the resolution // // viewers need to scale up - float scaleX = m_parentScene.RegionInfo.RegionSizeX / Constants.RegionSize; + float scaleX = (float)m_parentScene.RegionInfo.RegionSizeX / (float)Constants.RegionSize; if (scaleX == 0) scaleX = 1.0f; scaleX = 1.0f / scaleX; - float scaleY = m_parentScene.RegionInfo.RegionSizeY / Constants.RegionSize; + float scaleY = (float)m_parentScene.RegionInfo.RegionSizeY / (float)Constants.RegionSize; if (scaleY == 0) scaleY = 1.0f; scaleY = 1.0f / scaleY; -- cgit v1.1 From d1baa3e0c3b1783a68061980ffd8b9693c5a474a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 9 Nov 2016 22:39:52 +0000 Subject: fix some invalid string.format arguments --- .../Framework/Scenes/Scene.PacketHandlers.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneBase.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 89 +++++++++++++++++++++- 3 files changed, 89 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index a5abe76..3f48372 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -614,7 +614,7 @@ namespace OpenSim.Region.Framework.Scenes { m_log.Error( string.Format( - "[AGENT INVENTORY]: Error in SendInventoryAsync() for {0} with folder ID {1}. Exception ", e)); + "[AGENT INVENTORY]: Error in SendInventoryAsync() for {0} with folder ID {1}. Exception ", e, folderID)); } Thread.Sleep(20); } diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 1de55ec..d406625 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -287,7 +287,7 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); + m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception {0}", e)); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1a73c3e..bafee28 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -14358,6 +14358,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return contacts.ToArray(); } + private ContactResult? GroundIntersection2(Vector3 rayStart, Vector3 rayEnd) + { + // get work copies + float sx = rayStart.X; + float ex = rayEnd.X; + float sy = rayStart.Y; + float ey = rayEnd.Y; + + float dx = ex - sx; + float dy = ey - sy; + + // region size info + float rsx = World.RegionInfo.RegionSizeX; + + float tmp; + + // region bounds + if(sx < 0) + { + if(ex < 0) // totally outside + return null; + if(dx <= 0) // out and going away + return null; + else if(ex >= rsx) + ex = rsx - 0.001f; + tmp = -sx / dx; + sy += dy * dx; + sx = 0; + } + else if(sx >= rsx) + { + if(ex >= rsx) // totally outside + return null; + if(dx >= 0) // out and going away + return null; + else if(ex < 0) + ex = 0; + tmp = (rsx - sx) / dx; + sy += dy * dx; + sx = rsx - 0.001f; + } + + float rsy = World.RegionInfo.RegionSizeY; + if(sy < 0) + { + if(dy <= 0) // out and going away + return null; + else if(ey >= rsy) + ey = rsy - 0.001f; + tmp = -sy / dy; + sx += dy * dx; + sy = 0; + } + else if(sy >= rsy) + { + if(dy >= 0) // out and going away + return null; + else if(ey < 0) + ey = 0; + tmp = (rsy - sy) / dy; + sx += dy * dx; + sy = rsy - 0.001f; + } + + if(sx < 0 || sx >= rsx) + return null; + + float sz = rayStart.Z; + float ez = rayEnd.Z; + float dz = ez - sz; + + float dist = dx * dx + dy * dy + dz * dz; + if(dist < 0.001) + return null; + dist = (float)Math.Sqrt(dist); + tmp = 1.0f / dist; + Vector3 rayn = new Vector3(dx * tmp, dy * tmp, dz * tmp); + + ContactResult? result = null; + + + + return result; + } + private ContactResult? GroundIntersection(Vector3 rayStart, Vector3 rayEnd) { double[,] heightfield = World.Heightmap.GetDoubles(); @@ -16024,8 +16109,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api catch (InvalidCastException e) { Error(originFunc,string.Format( - " error running rule #{1}: arg #{2} ", - rulesParsed, idx - idxStart) + e.Message); + " error running rule #{0}: arg #{1} {2}", + rulesParsed, idx - idxStart, e.Message)); } finally { -- cgit v1.1 From bddaef51220198c3a3894edeece750e29337a558 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 10 Nov 2016 17:56:51 +0000 Subject: on Select use again the priority queues to send ObjectProperties, including physics via caps. This is need to reduce useless redudance --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 33 +++++++++++++++-- .../Framework/Scenes/Scene.PacketHandlers.cs | 42 ++-------------------- 2 files changed, 34 insertions(+), 41 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 276b367..99c9049 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -2856,6 +2856,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public void SendSelectedPartsProprieties(List parts) { +/* not in use // udp part ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties); @@ -2893,6 +2894,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP llsdBody.Add("ObjectData", array); eq.Enqueue(BuildEvent("ObjectPhysicsProperties", llsdBody),AgentId); +*/ } @@ -4839,7 +4841,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP OpenSim.Framework.Lazy> propertyUpdates = new OpenSim.Framework.Lazy>(); - + + List needPhysics = new List(); + EntityUpdate iupdate; Int32 timeinqueue; // this is just debugging code & can be dropped later @@ -4867,6 +4871,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (update.Entity is SceneObjectPart) { SceneObjectPart sop = (SceneObjectPart)update.Entity; + needPhysics.Add(sop); ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop); objectPropertiesBlocks.Value.Add(objPropDB); propertyUpdates.Value.Add(update); @@ -4932,7 +4937,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP // fpcnt++; // fbcnt++; } - + } + + if(needPhysics.Count > 0) + { + IEventQueue eq = Scene.RequestModuleInterface(); + if(eq != null) + { + OSDArray array = new OSDArray(); + foreach(SceneObjectPart sop in needPhysics) + { + OSDMap physinfo = new OSDMap(6); + physinfo["LocalID"] = sop.LocalId; + physinfo["Density"] = sop.Density; + physinfo["Friction"] = sop.Friction; + physinfo["GravityMultiplier"] = sop.GravityModifier; + physinfo["Restitution"] = sop.Restitution; + physinfo["PhysicsShapeType"] = (int)sop.PhysicsShapeType; + array.Add(physinfo); + } + + OSDMap llsdBody = new OSDMap(1); + llsdBody.Add("ObjectData", array); + + eq.Enqueue(BuildEvent("ObjectPhysicsProperties", llsdBody),AgentId); + } } // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt); diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 3f48372..24a2db7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -166,8 +166,6 @@ namespace OpenSim.Region.Framework.Scenes /// public void SelectPrim(List primIDs, IClientAPI remoteClient) { - List needUpdates = new List(); - foreach(uint primLocalID in primIDs) { SceneObjectPart part = GetSceneObjectPart(primLocalID); @@ -179,8 +177,6 @@ namespace OpenSim.Region.Framework.Scenes if (sog == null) continue; - needUpdates.Add((ISceneEntity)part); - // waste of time because properties do not send prim flags as they should // if a friend got or lost edit rights after login, a full update is needed if(sog.OwnerID != remoteClient.AgentId) @@ -193,10 +189,9 @@ namespace OpenSim.Region.Framework.Scenes part.IsSelected = true; EventManager.TriggerParcelPrimCountTainted(); } - } - if(needUpdates.Count > 0) - remoteClient.SendSelectedPartsProprieties(needUpdates); + part.SendPropertiesToClient(remoteClient); + } } /// @@ -248,38 +243,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetSceneObjectPart(primLocalID); if (part == null) return; - /* - // A deselect packet contains all the local prims being deselected. However, since selection is still - // group based we only want the root prim to trigger a full update - otherwise on objects with many prims - // we end up sending many duplicate ObjectUpdates - if (part.ParentGroup.RootPart.LocalId != part.LocalId) - return; - - // This is wrong, wrong, wrong. Selection should not be - // handled by group, but by prim. Legacy cruft. - // TODO: Make selection flagging per prim! - // - if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) - || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) - part.ParentGroup.IsSelected = false; - - part.ParentGroup.ScheduleGroupForFullUpdate(); - - // If it's not an attachment, and we are allowed to move it, - // then we might have done so. If we moved across a parcel - // boundary, we will need to recount prims on the parcels. - // For attachments, that makes no sense. - // - if (!part.ParentGroup.IsAttachment) - { - if (Permissions.CanEditObject( - part.UUID, remoteClient.AgentId) - || Permissions.CanMoveObject( - part.UUID, remoteClient.AgentId)) - EventManager.TriggerParcelPrimCountTainted(); - } - */ - + bool oldgprSelect = part.ParentGroup.IsSelected; // This is wrong, wrong, wrong. Selection should not be -- cgit v1.1 From 743a9d617e92f2ccd01816aec3bef73df22ed534 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 10 Nov 2016 19:21:07 +0000 Subject: also cache not found useraccounts when search by ID. Change the expire time to 5minutes in this case --- .../UserAccounts/LocalUserAccountServiceConnector.cs | 5 +---- .../UserAccounts/RemoteUserAccountServiceConnector.cs | 10 +++------- .../ServiceConnectorsOut/UserAccounts/UserAccountCache.cs | 9 +++++++-- 3 files changed, 11 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index a413a8b..9325de9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -213,10 +213,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { ret.AddRange(ext); foreach(UserAccount acc in ext) - { - if(acc != null) - m_Cache.Cache(acc.PrincipalID, acc); - } + m_Cache.Cache(acc.PrincipalID, acc); } return ret; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index 60dd97a..e84b666 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -142,8 +142,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts return account; account = base.GetUserAccount(scopeID, userID); - if(account != null) - m_Cache.Cache(userID, account); + m_Cache.Cache(userID, account); return account; } @@ -191,11 +190,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { foreach(UserAccount acc in ext) { - if(acc != null) - { - accs.Add(acc); - m_Cache.Cache(acc.PrincipalID, acc); - } + accs.Add(acc); + m_Cache.Cache(acc.PrincipalID, acc); } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs index 97baf87..f514bd7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs @@ -37,6 +37,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public class UserAccountCache : IUserAccountCacheModule { private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! + private const double CACHENULL_EXPIRATION_SECONDS = 600; // 5minutes // private static readonly ILog m_log = // LogManager.GetLogger( @@ -57,9 +58,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts // Cache even null accounts lock(accessLock) { - m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS); - if (account != null) + if (account == null) + m_UUIDCache.AddOrUpdate(userID, null, CACHENULL_EXPIRATION_SECONDS); + else + { + m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS); m_NameCache.AddOrUpdate(account.Name, account.PrincipalID, CACHE_EXPIRATION_SECONDS); + } //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID); } -- cgit v1.1 From 58b7be48a9466ee8df670e743bfa1711fe6a6450 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 10 Nov 2016 23:07:57 +0000 Subject: ubOde: add a needed lock --- OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index 6267051..f642699 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -1221,8 +1221,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde /// public void RemoveCollisionEventReporting(PhysicsActor obj) { - if (_collisionEventPrim.Contains(obj) && !_collisionEventPrimRemove.Contains(obj)) - _collisionEventPrimRemove.Add(obj); + lock(_collisionEventPrimRemove) + { + if (_collisionEventPrim.Contains(obj) && !_collisionEventPrimRemove.Contains(obj)) + _collisionEventPrimRemove.Add(obj); + } } public override float TimeDilation @@ -1759,10 +1762,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde prm.SleeperAddCollisionEvents(); sleepers.Clear(); - foreach (PhysicsActor obj in _collisionEventPrimRemove) - _collisionEventPrim.Remove(obj); + lock(_collisionEventPrimRemove) + { + foreach (PhysicsActor obj in _collisionEventPrimRemove) + _collisionEventPrim.Remove(obj); - _collisionEventPrimRemove.Clear(); + _collisionEventPrimRemove.Clear(); + } // do a ode simulation step d.WorldQuickStep(world, ODE_STEPSIZE); -- cgit v1.1 From 56a79a252c285c68cbdc856dc215d1155dff8c36 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 10 Nov 2016 23:14:08 +0000 Subject: GetUserAccounts cannot cache null accounts --- .../UserAccounts/LocalUserAccountServiceConnector.cs | 9 +++++++-- .../UserAccounts/RemoteUserAccountServiceConnector.cs | 7 +++++-- .../ServiceConnectorsOut/UserAccounts/UserAccountCache.cs | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 9325de9..b72ffbb 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -211,9 +211,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts List ext = UserAccountService.GetUserAccounts(scopeID, missing); if(ext != null && ext.Count > 0) { - ret.AddRange(ext); foreach(UserAccount acc in ext) - m_Cache.Cache(acc.PrincipalID, acc); + { + if(acc != null) + { + ret.Add(acc); + m_Cache.Cache(acc.PrincipalID, acc); + } + } } return ret; } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index e84b666..f5eda11 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs @@ -190,8 +190,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { foreach(UserAccount acc in ext) { - accs.Add(acc); - m_Cache.Cache(acc.PrincipalID, acc); + if(acc != null) + { + accs.Add(acc); + m_Cache.Cache(acc.PrincipalID, acc); + } } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs index f514bd7..03cb680 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs @@ -37,7 +37,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public class UserAccountCache : IUserAccountCacheModule { private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! - private const double CACHENULL_EXPIRATION_SECONDS = 600; // 5minutes + private const double CACHENULL_EXPIRATION_SECONDS = 600; // 10minutes // private static readonly ILog m_log = // LogManager.GetLogger( -- cgit v1.1 From 326821f66ed6286ee8b2ea6f5606d3eb902489fc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Nov 2016 12:59:43 +0000 Subject: reduce useraccouts cache time --- .../ServiceConnectorsOut/UserAccounts/UserAccountCache.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs index 03cb680..6c1cc52 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs @@ -36,8 +36,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { public class UserAccountCache : IUserAccountCacheModule { - private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! - private const double CACHENULL_EXPIRATION_SECONDS = 600; // 10minutes + private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour! + private const double CACHE_NULL_EXPIRATION_SECONDS = 600; // 10minutes // private static readonly ILog m_log = // LogManager.GetLogger( @@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts lock(accessLock) { if (account == null) - m_UUIDCache.AddOrUpdate(userID, null, CACHENULL_EXPIRATION_SECONDS); + m_UUIDCache.AddOrUpdate(userID, null, CACHE_NULL_EXPIRATION_SECONDS); else { m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS); -- cgit v1.1 From 4a7b8c1b41972a8ea40f08b57d3111d59505748b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 12 Nov 2016 03:31:34 +0000 Subject: ubOde fix a multhreading timming issue --- OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 3403f4b..60b24ec 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -1157,6 +1157,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_building = true; // control must set this to false when done + AddChange(changes.Add, null); + // get basic mass parameters ODEPhysRepData repData = _parent_scene.m_meshWorker.NewActorPhysRep(this, _pbs, _size, m_shapetype); @@ -1165,8 +1167,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_OBBOffset = repData.OBBOffset; UpdatePrimBodyData(); - - AddChange(changes.Add, null); } private void resetCollisionAccounting() -- cgit v1.1 From e13ff5a39233fd871e69f9ace23b4559cdfdcb7f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 13 Nov 2016 11:19:54 -0800 Subject: BulletSim: update avatar velocity setting to the new TargetVelocity pattern. Now PhysicsActor.Velocity.set and PhysicsActor.SetMomentum do the same thing of setting the instantanious avatar velocity. PhysicsActor.TargetVelocity sets a velocity target and the movement motor is used to accelerate the' avatar to that velocity. --- .../PhysicsModules/BulletS/BSActorAvatarMove.cs | 8 +--- .../Region/PhysicsModules/BulletS/BSCharacter.cs | 45 +++++++++------------- .../Region/PhysicsModules/BulletS/BSPhysObject.cs | 34 ++++++++++++---- OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs | 11 ------ 4 files changed, 47 insertions(+), 51 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs index 79ee00f..40c6b98 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs @@ -108,10 +108,6 @@ public class BSActorAvatarMove : BSActor { if (m_velocityMotor != null) { -// if (targ == OMV.Vector3.Zero) -// Util.PrintCallStack(); -// -// Console.WriteLine("SetVelocityAndTarget, {0} {1}", vel, targ); m_velocityMotor.Reset(); m_velocityMotor.SetTarget(targ); m_velocityMotor.SetCurrent(vel); @@ -128,7 +124,7 @@ public class BSActorAvatarMove : BSActor m_waitingForLowVelocityForStationary = true; } - // If a movement motor has not been created, create one and start the hovering. + // If a movement motor has not been created, create one and start the movement private void ActivateAvatarMove() { if (m_velocityMotor == null) @@ -161,7 +157,7 @@ public class BSActorAvatarMove : BSActor } } - // Called just before the simulation step. Update the vertical position for hoverness. + // Called just before the simulation step. private void Mover(float timeStep) { // Don't do movement while the object is selected. diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs index 757f06c..6322695 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs @@ -449,6 +449,7 @@ public sealed class BSCharacter : BSPhysObject public override OMV.Vector3 GeometricCenter { get { return OMV.Vector3.Zero; } } public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } } + // PhysicsActor.TargetVelocity // Sets the target in the motor. This starts the changing of the avatar's velocity. public override OMV.Vector3 TargetVelocity { @@ -459,7 +460,7 @@ public sealed class BSCharacter : BSPhysObject set { DetailLog("{0},BSCharacter.setTargetVelocity,call,vel={1}", LocalID, value); - m_targetVelocity = value; + base.m_targetVelocity = value; OMV.Vector3 targetVel = value; if (_setAlwaysRun && !_flying) targetVel *= new OMV.Vector3(BSParam.AvatarAlwaysRunFactor, BSParam.AvatarAlwaysRunFactor, 1f); @@ -472,46 +473,38 @@ public sealed class BSCharacter : BSPhysObject public override OMV.Vector3 Velocity { get { return RawVelocity; } set { - RawVelocity = value; - OMV.Vector3 vel = RawVelocity; - - DetailLog("{0}: set Velocity = {1}", LocalID, value); - - PhysScene.TaintedObject(LocalID, "BSCharacter.setVelocity", delegate() + if (m_moveActor != null) { - if (m_moveActor != null) - m_moveActor.SetVelocityAndTarget(vel, vel, true /* inTaintTime */); + // m_moveActor.SetVelocityAndTarget(OMV.Vector3.Zero, OMV.Vector3.Zero, false /* inTaintTime */); + m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, false /* inTaintTime */); + } + base.Velocity = value; + } + } - DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, vel); - ForceVelocity = vel; - }); + // SetMomentum just sets the velocity without a target. We need to stop the movement actor if a character. + public override void SetMomentum(OMV.Vector3 momentum) + { + if (m_moveActor != null) + { + // m_moveActor.SetVelocityAndTarget(OMV.Vector3.Zero, OMV.Vector3.Zero, false /* inTaintTime */); + m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, false /* inTaintTime */); } + base.SetMomentum(momentum); } public override OMV.Vector3 ForceVelocity { get { return RawVelocity; } set { PhysScene.AssertInTaintTime("BSCharacter.ForceVelocity"); -// Util.PrintCallStack(); - DetailLog("{0}: set ForceVelocity = {1}", LocalID, value); + DetailLog("{0}: BSCharacter.ForceVelocity.set = {1}", LocalID, value); - RawVelocity = value; + RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity); PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity); PhysScene.PE.Activate(PhysBody, true); } } - // SetMomentum just sets the velocity without a target. We need to stop the movement actor if a character. - public override void SetMomentum(OMV.Vector3 momentum) - { - if (m_moveActor != null) - { - m_moveActor.SetVelocityAndTarget(OMV.Vector3.Zero, OMV.Vector3.Zero, false /* inTaintTime */); - } - base.SetMomentum(momentum); - } - - public override OMV.Vector3 Torque { get { return RawTorque; } set { RawTorque = value; diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs index 3682455..a846869 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs @@ -230,15 +230,22 @@ public abstract class BSPhysObject : PhysicsActor // Update the physical location and motion of the object. Called with data from Bullet. public abstract void UpdateProperties(EntityProperties entprop); + // The position value as known by BulletSim. Does not effect the physics engine. public virtual OMV.Vector3 RawPosition { get; set; } + // Set position in BulletSim and the physics engined to a value immediately. Must be called at taint time. public abstract OMV.Vector3 ForcePosition { get; set; } + // The orientation value as known by BulletSim. Does not effect the physics engine. public virtual OMV.Quaternion RawOrientation { get; set; } + // Set orientation in BulletSim and the physics engine to a value immediately. Must be called at taint time. public abstract OMV.Quaternion ForceOrientation { get; set; } + // The velocity value as known by BulletSim. Does not effect the physics engine. public virtual OMV.Vector3 RawVelocity { get; set; } + // Set velocity in BulletSim and the physics engined to a value immediately. Must be called at taint time. public abstract OMV.Vector3 ForceVelocity { get; set; } + // The rotational velocity value as known by BulletSim. Does not effect the physics engine. public OMV.Vector3 RawRotationalVelocity { get; set; } // RawForce is a constant force applied to object (see Force { set; } ) @@ -252,17 +259,28 @@ public abstract class BSPhysObject : PhysicsActor public abstract void AddAngularForce(bool inTaintTime, OMV.Vector3 force); public abstract void AddForce(bool inTaintTime, OMV.Vector3 force); + // PhysicsActor.Velocity + public override OMV.Vector3 Velocity + { + get { return RawVelocity; } + set + { + // This sets the velocity now. BSCharacter will override to clear target velocity + // before calling this. + RawVelocity = value; + PhysScene.TaintedObject(LocalID, TypeName + ".SetVelocity", delegate () { + // DetailLog("{0},BSPhysObject.Velocity.set,vel={1}", LocalID, RawVelocity); + ForceVelocity = RawVelocity; + }); + } + } + // PhysicsActor.SetMomentum - // All the physics engined use this as a way of forcing the velocity to something. + // All the physics engines use this as a way of forcing the velocity to something. + // BSCharacter overrides this so it can set the target velocity to zero before calling this. public override void SetMomentum(OMV.Vector3 momentum) { - // This doesn't just set Velocity=momentum because velocity is ramped up to (see MoveActor) - RawVelocity = momentum; - PhysScene.TaintedObject(LocalID, TypeName + ".SetMomentum", delegate() - { - // DetailLog("{0},BSPrim.SetMomentum,taint,vel={1}", LocalID, RawVelocity); - ForceVelocity = RawVelocity; - }); + this.Velocity = momentum; } public override OMV.Vector3 RotationalVelocity { diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs index 78a617d..db2b9db 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs @@ -787,17 +787,6 @@ public class BSPrim : BSPhysObject } } } - public override OMV.Vector3 Velocity { - get { return RawVelocity; } - set { - RawVelocity = value; - PhysScene.TaintedObject(LocalID, "BSPrim.setVelocity", delegate() - { - // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, RawVelocity); - ForceVelocity = RawVelocity; - }); - } - } public override OMV.Vector3 ForceVelocity { get { return RawVelocity; } set { -- cgit v1.1 From 4ebb4e371f44e8e8e9612d8e5eaab274263a2f89 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 13 Nov 2016 19:25:32 +0000 Subject: prevent self call to llSetScriptState(ownname,FALSE) from blocking entire engine --- OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs | 2 +- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 14 +++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs index 6355669..361a0b9 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs @@ -68,7 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces void SetMinEventDelay(UUID itemID, double delay); int GetStartParameter(UUID itemID); - void SetScriptState(UUID itemID, bool state); + void SetScriptState(UUID itemID, bool state, bool self); bool GetScriptState(UUID itemID); void SetState(UUID itemID, string newState); void ApiResetScript(UUID itemID); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bafee28..af04951 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -521,7 +521,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((item = GetScriptByName(name)) != UUID.Zero) { - m_ScriptEngine.SetScriptState(item, run == 0 ? false : true); + m_ScriptEngine.SetScriptState(item, run == 0 ? false : true, item == m_item.ItemID); } else { diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index e12f850..7822df9 100755 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1854,15 +1854,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine return instance; } - public void SetScriptState(UUID itemID, bool running) + public void SetScriptState(UUID itemID, bool running, bool self) { IScriptInstance instance = GetInstance(itemID); if (instance != null) { if (running) - instance.Start(); + instance.Start(); else - instance.Stop(100); + { + if(self) + { + instance.Running = false; + throw new EventAbortException(); + } + else + instance.Stop(100); + } } } -- cgit v1.1 From ae17b5d203677ff99cf0c3ee9d9ec9309600b568 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 14 Nov 2016 03:21:07 +0000 Subject: reduce calls to physics world cast rays for camera collision check --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 8 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 97 +++++++++++----------- 2 files changed, 54 insertions(+), 51 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 99c9049..46c6a19 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -6263,7 +6263,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP bool movement = CheckAgentMovementUpdateSignificance(x); bool camera = CheckAgentCameraUpdateSignificance(x); - + // Was there a significant movement/state change? if (movement) { @@ -6274,6 +6274,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; m_thisAgentUpdateArgs.State = x.State; + m_thisAgentUpdateArgs.NeedsCameraCollision = !camera; + UpdateAgent handlerAgentUpdate = OnAgentUpdate; UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; @@ -6282,7 +6284,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (handlerAgentUpdate != null) OnAgentUpdate(this, m_thisAgentUpdateArgs); - + } // Was there a significant camera(s) change? @@ -6293,6 +6295,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; + m_thisAgentUpdateArgs.NeedsCameraCollision = true; + UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate; if (handlerAgentCameraUpdate != null) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f96fb85..2ca218c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2297,6 +2297,48 @@ namespace OpenSim.Region.Framework.Scenes /// /// + private void checkCameraCollision() + { + if(!m_scene.PhysicsScene.SupportsRayCast()) + return; + + ++m_movementUpdateCount; + if (m_movementUpdateCount < 1) + m_movementUpdateCount = 1; + + if (m_doingCamRayCast || m_movementUpdateCount % NumMovementsBetweenRayCast != 0) + return; + + if (m_followCamAuto && !m_mouseLook) + { + Vector3 posAdjusted = AbsolutePosition; +// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; + posAdjusted.Z += 1.0f; // viewer current camera focus point + Vector3 tocam = CameraPosition - posAdjusted; + tocam.X = (float)Math.Round(tocam.X, 1); + tocam.Y = (float)Math.Round(tocam.Y, 1); + tocam.Z = (float)Math.Round(tocam.Z, 1); + + float distTocamlen = tocam.Length(); + if (distTocamlen > 0.3f) + { + tocam *= (1.0f / distTocamlen); + posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); + posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); + posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); + + m_doingCamRayCast = true; + m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); + } + } + else if (CameraConstraintActive) + { + Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... + UpdateCameraCollisionPlane(plane); + CameraConstraintActive = false; + } + } + private void UpdateCameraCollisionPlane(Vector4 plane) { if (m_lastCameraCollisionPlane != plane) @@ -2442,38 +2484,8 @@ namespace OpenSim.Region.Framework.Scenes // Raycast from the avatar's head to the camera to see if there's anything blocking the view // this exclude checks may not be complete - - if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) - { - if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) - { - Vector3 posAdjusted = AbsolutePosition; -// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; - posAdjusted.Z += 1.0f; // viewer current camera focus point - Vector3 tocam = CameraPosition - posAdjusted; - tocam.X = (float)Math.Round(tocam.X, 1); - tocam.Y = (float)Math.Round(tocam.Y, 1); - tocam.Z = (float)Math.Round(tocam.Z, 1); - - float distTocamlen = tocam.Length(); - if (distTocamlen > 0.3f) - { - tocam *= (1.0f / distTocamlen); - posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); - posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); - posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); - - m_doingCamRayCast = true; - m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); - } - } - else if (CameraConstraintActive && (m_mouseLook || ParentID != 0)) - { - Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... - UpdateCameraCollisionPlane(plane); - CameraConstraintActive = false; - } - } + if(agentData.NeedsCameraCollision && ParentID == 0) // condition parentID may be wrong + checkCameraCollision(); uint flagsForScripts = (uint)flags; flags = RemoveIgnoredControls(flags, IgnoredControls); @@ -2742,14 +2754,10 @@ namespace OpenSim.Region.Framework.Scenes // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); if (IsChildAgent) - { - // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); return; - } - ++m_movementUpdateCount; - if (m_movementUpdateCount < 1) - m_movementUpdateCount = 1; + if(IsInTransit) + return; // AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; @@ -2779,17 +2787,8 @@ namespace OpenSim.Region.Framework.Scenes m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; - - //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); - // Raycast from the avatar's head to the camera to see if there's anything blocking the view - if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) - { - if (m_followCamAuto) - { - Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; - m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); - } - } + if(agentData.NeedsCameraCollision) + checkCameraCollision(); TriggerScenePresenceUpdated(); } -- cgit v1.1 From e304acb06fddfd79ceedd6991f4c9f1a3fd08e79 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 14 Nov 2016 05:15:41 +0000 Subject: fix unack bytes stats report --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index 246f003..d59b761 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -161,6 +161,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Total byte count of unacked packets sent to this client public int UnackedBytes; + private int m_packetsUnAckReported; /// Total number of received packets that we have reported to the OnPacketStats event(s) private int m_packetsReceivedReported; /// Total number of sent packets that we have reported to the OnPacketStats event(s) @@ -389,11 +390,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP { int newPacketsReceived = PacketsReceived - m_packetsReceivedReported; int newPacketsSent = PacketsSent - m_packetsSentReported; - + int newPacketUnAck = UnackedBytes - m_packetsUnAckReported; callback(newPacketsReceived, newPacketsSent, UnackedBytes); m_packetsReceivedReported += newPacketsReceived; m_packetsSentReported += newPacketsSent; + m_packetsUnAckReported += newPacketUnAck; } } -- cgit v1.1 From a858804b420f700965abf3b6601b83c0fb1d9b7c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 14 Nov 2016 22:08:39 +0000 Subject: fix a vector range parsing --- .../Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index e65f860..688648b 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs @@ -920,7 +920,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands return false; } - string rawConsoleEndVector = rawComponents.Skip(2).Take(1).Single(); + string rawConsoleEndVector = rawComponents.Skip(1).Take(1).Single(); if (!ConsoleUtil.TryParseConsoleMaxVector(rawConsoleEndVector, out endVector)) { -- cgit v1.1 From 8196f21af9ce53a0daf9cd415de06db2e0eff75a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 14 Nov 2016 22:13:02 +0000 Subject: change camera collision check rules --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 57 ++++++++++++++---------- 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2ca218c..3378ead 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2313,25 +2313,23 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 posAdjusted = AbsolutePosition; // posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; + // not good for tiny or huge avatars posAdjusted.Z += 1.0f; // viewer current camera focus point Vector3 tocam = CameraPosition - posAdjusted; - tocam.X = (float)Math.Round(tocam.X, 1); - tocam.Y = (float)Math.Round(tocam.Y, 1); - tocam.Z = (float)Math.Round(tocam.Z, 1); - float distTocamlen = tocam.Length(); - if (distTocamlen > 0.3f) + float distTocamlen = tocam.LengthSquared(); + if (distTocamlen > 0.08f && distTocamlen < 400) { + distTocamlen = (float)Math.Sqrt(distTocamlen); tocam *= (1.0f / distTocamlen); - posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); - posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); - posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); m_doingCamRayCast = true; m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); + return; } } - else if (CameraConstraintActive) + + if (CameraConstraintActive) { Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... UpdateCameraCollisionPlane(plane); @@ -2350,17 +2348,14 @@ namespace OpenSim.Region.Framework.Scenes public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) { - const float POSITION_TOLERANCE = 0.02f; - const float ROTATION_TOLERANCE = 0.02f; +// const float POSITION_TOLERANCE = 0.02f; +// const float ROTATION_TOLERANCE = 0.02f; - m_doingCamRayCast = false; if (hitYN && localid != LocalId) { - SceneObjectGroup group = m_scene.GetGroupByPrim(localid); - bool IsPrim = group != null; - if (IsPrim) + if (localid != 0) { - SceneObjectPart part = group.GetPart(localid); + SceneObjectPart part = m_scene.GetSceneObjectPart(localid); if (part != null && !part.VolumeDetectActive) { CameraConstraintActive = true; @@ -2393,13 +2388,16 @@ namespace OpenSim.Region.Framework.Scenes UpdateCameraCollisionPlane(plane); } } - else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || - !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) +// else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || +// !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) + else if(CameraConstraintActive) { Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... UpdateCameraCollisionPlane(plane); CameraConstraintActive = false; } + + m_doingCamRayCast = false; } /// @@ -2767,7 +2765,7 @@ namespace OpenSim.Region.Framework.Scenes // Use these three vectors to figure out what the agent is looking at // Convert it to a Matrix and/or Quaternion - // this my need lock + // this may need lock CameraAtAxis = agentData.CameraAtAxis; CameraLeftAxis = agentData.CameraLeftAxis; CameraUpAxis = agentData.CameraUpAxis; @@ -2781,11 +2779,24 @@ namespace OpenSim.Region.Framework.Scenes DrawDistance = agentData.Far; - // Check if Client has camera in 'follow cam' or 'build' mode. - Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); - m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) - && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; + // Check if Client has camera in 'follow cam' or 'build' mode. +// Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); + m_followCamAuto = false; + if(!m_mouseLook) + { + if((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f)) + { + Vector3 camdif = new Vector3(1f, 0f, 0f) * Rotation; + float ftmp = camdif.X - CameraAtAxis.X; + if(Math.Abs(ftmp) < 0.1f) + { + ftmp = camdif.Y - CameraAtAxis.Y; + if(Math.Abs(ftmp) < 0.1f) + m_followCamAuto = true; + } + } + } if(agentData.NeedsCameraCollision) checkCameraCollision(); -- cgit v1.1 From 8dd9601fdcdaf77060446f40e69b3d1524afa31f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 16 Nov 2016 00:42:08 +0000 Subject: minor change to getdisplaynames cap url --- .../Linden/Caps/GetDisplayNamesModule.cs | 7 ++-- .../Avatar/InstantMessage/InstantMessageModule.cs | 44 +--------------------- 2 files changed, 5 insertions(+), 46 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs index eabacb4..bf559d3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetDisplayNamesModule.cs @@ -120,14 +120,13 @@ namespace OpenSim.Region.ClientStack.Linden public virtual void RegisterCaps(UUID agentID, Caps caps) { - UUID capID = UUID.Random(); - if (m_URL == "localhost") { - m_log.DebugFormat("[GET_DISPLAY_NAMES]: /CAPS/agents/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); + string capUrl = "/CAPS/" + UUID.Random() + "/"; +// m_log.DebugFormat("[GET_DISPLAY_NAMES]: {0} in region {1}", capUrl, m_scene.RegionInfo.RegionName); caps.RegisterHandler( "GetDisplayNames", - new GetDisplayNamesHandler("/CAPS/agents" + capID + "/", m_UserManager, "GetDisplayNames", agentID.ToString())); + new GetDisplayNamesHandler(capUrl, m_UserManager, "GetDisplayNames", agentID.ToString())); } else { diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index 2ba35df..7d54a00 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs @@ -45,10 +45,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage private static readonly ILog m_log = LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); - protected Timer m_logTimer = new Timer(10000); - protected List m_logData = new List(); - protected string m_restUrl; - /// /// Is this module enabled? /// @@ -68,12 +64,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage "InstantMessageModule", "InstantMessageModule") != "InstantMessageModule") return; - m_restUrl = config.Configs["Messaging"].GetString("LogURL", String.Empty); } m_enabled = true; - m_logTimer.AutoReset = false; - m_logTimer.Elapsed += LogTimerElapsed; } public virtual void AddRegion(Scene scene) @@ -153,20 +146,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage } #endregion - +/* public virtual void OnViewerInstantMessage(IClientAPI client, GridInstantMessage im) { im.fromAgentName = client.FirstName + " " + client.LastName; OnInstantMessage(client, im); } - +*/ public virtual void OnInstantMessage(IClientAPI client, GridInstantMessage im) { byte dialog = im.dialog; - if (client != null && dialog == (byte)InstantMessageDialog.MessageFromAgent) - LogInstantMesssage(im); - if (dialog != (byte)InstantMessageDialog.MessageFromAgent && dialog != (byte)InstantMessageDialog.StartTyping && dialog != (byte)InstantMessageDialog.StopTyping @@ -243,35 +233,5 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // OnInstantMessage(null, msg); } - - protected virtual void LogInstantMesssage(GridInstantMessage im) - { - if (m_logData.Count < 20) - { - // Restart the log write timer - m_logTimer.Stop(); - } - if (!m_logTimer.Enabled) - m_logTimer.Start(); - - lock (m_logData) - { - m_logData.Add(im); - } - } - - protected virtual void LogTimerElapsed(object source, ElapsedEventArgs e) - { - lock (m_logData) - { - if (m_restUrl != String.Empty && m_logData.Count > 0) - { - bool success = SynchronousRestObjectRequester.MakeRequest, bool>("POST", m_restUrl + "/LogMessages/", m_logData); - if (!success) - m_log.ErrorFormat("[INSTANT MESSAGE]: Failed to save log data"); - } - m_logData.Clear(); - } - } } } -- cgit v1.1 From 05ba77fd3b72bb29a1f57245f8cd4ddeb6a19fb8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 16 Nov 2016 03:47:48 +0000 Subject: fix parsing of a vector4 and storing on a lsl quaternion needed for lightShare scripts --- .../Shared/Api/Implementation/LS_Api.cs | 10 ++++----- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 25 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index e5e43f8..8cd065b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs @@ -295,7 +295,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -342,7 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -532,7 +532,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx++; try { - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); } catch (InvalidCastException) { @@ -654,7 +654,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: idx++; - iQ = rules.GetQuaternionItem(idx); + iQ = rules.GetVector4Item(idx); try { wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index c36e7c6..738a814 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -700,6 +700,31 @@ namespace OpenSim.Region.ScriptEngine.Shared } } + // use LSL_Types.Quaternion to parse and store a vector4 for lightShare + public LSL_Types.Quaternion GetVector4Item(int itemIndex) + { + if (Data[itemIndex] is LSL_Types.Quaternion) + { + LSL_Types.Quaternion q = (LSL_Types.Quaternion)Data[itemIndex]; + return q; + } + else if(Data[itemIndex] is OpenMetaverse.Quaternion) + { + LSL_Types.Quaternion q = new LSL_Types.Quaternion( + (OpenMetaverse.Quaternion)Data[itemIndex]); + q.Normalize(); + return q; + } + else + { + throw new InvalidCastException(string.Format( + "{0} expected but {1} given", + typeof(LSL_Types.Quaternion).Name, + Data[itemIndex] != null ? + Data[itemIndex].GetType().Name : "null")); + } + } + public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) { if (Data[itemIndex] is LSL_Types.Quaternion) -- cgit v1.1