From ddff2f246cb4862abcac5308ae2532c9828691fb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Dec 2011 15:17:26 -0800 Subject: Moved an external test into the method that uses those preconditions. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 30 +++++++++--------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 36d8c0b..526fab3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1161,10 +1161,10 @@ namespace OpenSim.Region.Framework.Scenes public void CompleteMovement(IClientAPI client, bool openChildAgents) { // DateTime startTime = DateTime.Now; - -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Completing movement of {0} into region {1}", -// client.Name, Scene.RegionInfo.RegionName); + + m_log.DebugFormat( + "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", + client.Name, Scene.RegionInfo.RegionName, AbsolutePosition); Vector3 look = Velocity; if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) @@ -2383,9 +2383,7 @@ namespace OpenSim.Region.Framework.Scenes m_lastVelocity = Velocity; } - // followed suggestion from mic bowman. reversed the two lines below. - if (ParentID == 0 && PhysicsActor != null || ParentID != 0) // Check that we have a physics actor or we're sitting on something - CheckForBorderCrossing(); + CheckForBorderCrossing(); CheckForSignificantMovement(); // sends update to the modules. } @@ -2741,7 +2739,8 @@ namespace OpenSim.Region.Framework.Scenes /// protected void CheckForBorderCrossing() { - if (IsChildAgent) + // Check that we we are not a child and have a physics actor or we're sitting on something + if (IsChildAgent || (ParentID == 0 && PhysicsActor != null || ParentID != 0)) return; Vector3 pos2 = AbsolutePosition; @@ -2757,7 +2756,6 @@ namespace OpenSim.Region.Framework.Scenes if (!IsInTransit) { // Checks if where it's headed exists a region - bool needsTransit = false; if (m_scene.TestBorderCross(pos2, Cardinals.W)) { @@ -2828,7 +2826,7 @@ namespace OpenSim.Region.Framework.Scenes Velocity = Vector3.Zero; AbsolutePosition = pos; -// m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); + m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); AddToPhysicalScene(isFlying); } @@ -2861,22 +2859,16 @@ namespace OpenSim.Region.Framework.Scenes } } else - { - // We must remove the agent from the physical scene if it has been placed in transit. If we don't, - // then this method continues to be called from ScenePresence.Update() until the handover of the client between - // regions is completed. Since this handover can take more than 1000ms (due to the 1000ms - // event queue polling response from the server), this results in the avatar pausing on the border - // for the handover period. - RemoveFromPhysicalScene(); - + { // This constant has been inferred from experimentation // I'm not sure what this value should be, so I tried a few values. timeStep = 0.04f; pos2 = AbsolutePosition; pos2.X = pos2.X + (vel.X * timeStep); pos2.Y = pos2.Y + (vel.Y * timeStep); - pos2.Z = pos2.Z + (vel.Z * timeStep); + // Don't touch the Z m_pos = pos2; + m_log.ErrorFormat("m_pos={0}", m_pos); } } -- cgit v1.1 From 219ec7ef20ccefb257be5ec650a13758b2a3cda3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 22 Dec 2011 08:18:03 -0800 Subject: Fixing a bug introduced yesterday. This put the precondition test inside CheckForBorderCrossing the right way. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 214 ++++++++++++----------- 1 file changed, 109 insertions(+), 105 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6f02475..040cbfc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2736,137 +2736,141 @@ namespace OpenSim.Region.Framework.Scenes /// protected void CheckForBorderCrossing() { - // Check that we we are not a child and have a physics actor or we're sitting on something - if (IsChildAgent || (ParentID == 0 && PhysicsActor != null || ParentID != 0)) + // Check that we we are not a child + if (IsChildAgent) return; - Vector3 pos2 = AbsolutePosition; - Vector3 vel = Velocity; - int neighbor = 0; - int[] fix = new int[2]; + // We only do this if we have a physics actor or we're sitting on something + if (ParentID == 0 && PhysicsActor != null || ParentID != 0) + { + Vector3 pos2 = AbsolutePosition; + Vector3 vel = Velocity; + int neighbor = 0; + int[] fix = new int[2]; - float timeStep = 0.1f; - pos2.X = pos2.X + (vel.X*timeStep); - pos2.Y = pos2.Y + (vel.Y*timeStep); - pos2.Z = pos2.Z + (vel.Z*timeStep); + float timeStep = 0.1f; + pos2.X = pos2.X + (vel.X * timeStep); + pos2.Y = pos2.Y + (vel.Y * timeStep); + pos2.Z = pos2.Z + (vel.Z * timeStep); - if (!IsInTransit) - { - // Checks if where it's headed exists a region - bool needsTransit = false; - if (m_scene.TestBorderCross(pos2, Cardinals.W)) + if (!IsInTransit) { - if (m_scene.TestBorderCross(pos2, Cardinals.S)) + // Checks if where it's headed exists a region + bool needsTransit = false; + if (m_scene.TestBorderCross(pos2, Cardinals.W)) { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); + if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.SW, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.NW, ref fix); + } + else + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); + } } - else + else if (m_scene.TestBorderCross(pos2, Cardinals.E)) { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.W, ref fix); + if (m_scene.TestBorderCross(pos2, Cardinals.S)) + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); + } + else if (m_scene.TestBorderCross(pos2, Cardinals.N)) + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); + } + else + { + needsTransit = true; + neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); + } } - } - else if (m_scene.TestBorderCross(pos2, Cardinals.E)) - { - if (m_scene.TestBorderCross(pos2, Cardinals.S)) + else if (m_scene.TestBorderCross(pos2, Cardinals.S)) { needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.SE, ref fix); + neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); } else if (m_scene.TestBorderCross(pos2, Cardinals.N)) { needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.NE, ref fix); + neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); } - else - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.E, ref fix); - } - } - else if (m_scene.TestBorderCross(pos2, Cardinals.S)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.S, ref fix); - } - else if (m_scene.TestBorderCross(pos2, Cardinals.N)) - { - needsTransit = true; - neighbor = m_scene.HaveNeighbor(Cardinals.N, ref fix); - } - // Makes sure avatar does not end up outside region - if (neighbor <= 0) - { - if (needsTransit) + // Makes sure avatar does not end up outside region + if (neighbor <= 0) { - if (m_requestedSitTargetUUID == UUID.Zero) + if (needsTransit) { - bool isFlying = Flying; - RemoveFromPhysicalScene(); - - Vector3 pos = AbsolutePosition; - if (AbsolutePosition.X < 0) - pos.X += Velocity.X * 2; - else if (AbsolutePosition.X > Constants.RegionSize) - pos.X -= Velocity.X * 2; - if (AbsolutePosition.Y < 0) - pos.Y += Velocity.Y * 2; - else if (AbsolutePosition.Y > Constants.RegionSize) - pos.Y -= Velocity.Y * 2; - Velocity = Vector3.Zero; - AbsolutePosition = pos; - - m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); - - AddToPhysicalScene(isFlying); + if (m_requestedSitTargetUUID == UUID.Zero) + { + bool isFlying = Flying; + RemoveFromPhysicalScene(); + + Vector3 pos = AbsolutePosition; + if (AbsolutePosition.X < 0) + pos.X += Velocity.X * 2; + else if (AbsolutePosition.X > Constants.RegionSize) + pos.X -= Velocity.X * 2; + if (AbsolutePosition.Y < 0) + pos.Y += Velocity.Y * 2; + else if (AbsolutePosition.Y > Constants.RegionSize) + pos.Y -= Velocity.Y * 2; + Velocity = Vector3.Zero; + AbsolutePosition = pos; + + m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); + + AddToPhysicalScene(isFlying); + } } } - } - else if (neighbor > 0) - { - if (!CrossToNewRegion()) + else if (neighbor > 0) { - if (m_requestedSitTargetUUID == UUID.Zero) + if (!CrossToNewRegion()) { - bool isFlying = Flying; - RemoveFromPhysicalScene(); - - Vector3 pos = AbsolutePosition; - if (AbsolutePosition.X < 0) - pos.X += Velocity.X * 2; - else if (AbsolutePosition.X > Constants.RegionSize) - pos.X -= Velocity.X * 2; - if (AbsolutePosition.Y < 0) - pos.Y += Velocity.Y * 2; - else if (AbsolutePosition.Y > Constants.RegionSize) - pos.Y -= Velocity.Y * 2; - Velocity = Vector3.Zero; - AbsolutePosition = pos; - - AddToPhysicalScene(isFlying); + if (m_requestedSitTargetUUID == UUID.Zero) + { + bool isFlying = Flying; + RemoveFromPhysicalScene(); + + Vector3 pos = AbsolutePosition; + if (AbsolutePosition.X < 0) + pos.X += Velocity.X * 2; + else if (AbsolutePosition.X > Constants.RegionSize) + pos.X -= Velocity.X * 2; + if (AbsolutePosition.Y < 0) + pos.Y += Velocity.Y * 2; + else if (AbsolutePosition.Y > Constants.RegionSize) + pos.Y -= Velocity.Y * 2; + Velocity = Vector3.Zero; + AbsolutePosition = pos; + + AddToPhysicalScene(isFlying); + } } } } - } - else - { - // This constant has been inferred from experimentation - // I'm not sure what this value should be, so I tried a few values. - timeStep = 0.04f; - pos2 = AbsolutePosition; - pos2.X = pos2.X + (vel.X * timeStep); - pos2.Y = pos2.Y + (vel.Y * timeStep); - // Don't touch the Z - m_pos = pos2; - m_log.ErrorFormat("m_pos={0}", m_pos); - } + else + { + // This constant has been inferred from experimentation + // I'm not sure what this value should be, so I tried a few values. + timeStep = 0.04f; + pos2 = AbsolutePosition; + pos2.X = pos2.X + (vel.X * timeStep); + pos2.Y = pos2.Y + (vel.Y * timeStep); + // Don't touch the Z + m_pos = pos2; + m_log.DebugFormat("[SCENE PRESENCE]: In transit m_pos={0}", m_pos); + } + } } /// -- cgit v1.1 From 2347593dac0d435851fb1437b87c42a5fd4f9060 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 22 Dec 2011 16:48:52 +0000 Subject: Harmonizing SP with Avination --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 96 ++++++++++++++---------- 1 file changed, 55 insertions(+), 41 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 040cbfc..c578fc0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is /// necessary. /// - protected List m_attachments = new List(); + private List m_attachments = new List(); public Object AttachmentsSyncLock { get; private set; } @@ -550,8 +550,12 @@ namespace OpenSim.Region.Framework.Scenes } } - m_pos = value; - ParentPosition = Vector3.Zero; + // Don't update while sitting + if (ParentID == 0) + { + m_pos = value; + ParentPosition = Vector3.Zero; + } //m_log.DebugFormat( // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", @@ -566,6 +570,13 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 OffsetPosition { get { return m_pos; } + set + { + // There is no offset position when not seated + if (ParentID == 0) + return; + m_pos = value; + } } /// @@ -2740,8 +2751,10 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent) return; - // We only do this if we have a physics actor or we're sitting on something - if (ParentID == 0 && PhysicsActor != null || ParentID != 0) + if (ParentID != 0) + return; + + if (!IsInTransit) { Vector3 pos2 = AbsolutePosition; Vector3 vel = Velocity; @@ -3100,30 +3113,28 @@ namespace OpenSim.Region.Framework.Scenes catch { } // Attachment objects - lock (m_attachments) + List attachments = GetAttachments(); + if (attachments.Count > 0) { - if (m_attachments.Count > 0) - { - cAgent.AttachmentObjects = new List(); - cAgent.AttachmentObjectStates = new List(); - // IScriptModule se = m_scene.RequestModuleInterface(); - InTransitScriptStates.Clear(); + cAgent.AttachmentObjects = new List(); + cAgent.AttachmentObjectStates = new List(); +// IScriptModule se = m_scene.RequestModuleInterface(); + InTransitScriptStates.Clear(); - foreach (SceneObjectGroup sog in m_attachments) - { - // We need to make a copy and pass that copy - // because of transfers withn the same sim - ISceneObject clone = sog.CloneForNewScene(); - // Attachment module assumes that GroupPosition holds the offsets...! - ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; - ((SceneObjectGroup)clone).IsAttachment = false; - cAgent.AttachmentObjects.Add(clone); - string state = sog.GetStateSnapshot(); - cAgent.AttachmentObjectStates.Add(state); - InTransitScriptStates.Add(state); - // Let's remove the scripts of the original object here - sog.RemoveScriptInstances(true); - } + foreach (SceneObjectGroup sog in attachments) + { + // We need to make a copy and pass that copy + // because of transfers withn the same sim + ISceneObject clone = sog.CloneForNewScene(); + // Attachment module assumes that GroupPosition holds the offsets...! + ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; + ((SceneObjectGroup)clone).IsAttachment = false; + cAgent.AttachmentObjects.Add(clone); + string state = sog.GetStateSnapshot(); + cAgent.AttachmentObjectStates.Add(state); + InTransitScriptStates.Add(state); + // Let's remove the scripts of the original object here + sog.RemoveScriptInstances(true); } } } @@ -3531,26 +3542,29 @@ namespace OpenSim.Region.Framework.Scenes /// The arguments for the event public void SendScriptEventToAttachments(string eventName, Object[] args) { - if (m_scriptEngines.Length == 0) - return; - - lock (m_attachments) + Util.FireAndForget(delegate(object x) { - foreach (SceneObjectGroup grp in m_attachments) + if (m_scriptEngines.Length == 0) + return; + + lock (m_attachments) { - // 16384 is CHANGED_ANIMATION - // - // Send this to all attachment root prims - // - foreach (IScriptModule m in m_scriptEngines) + foreach (SceneObjectGroup grp in m_attachments) { - if (m == null) // No script engine loaded - continue; + // 16384 is CHANGED_ANIMATION + // + // Send this to all attachment root prims + // + foreach (IScriptModule m in m_scriptEngines) + { + if (m == null) // No script engine loaded + continue; - m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); + m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); + } } } - } + }); } internal void PushForce(Vector3 impulse) -- cgit v1.1 From 6412349decb36a7278528477bacb5b71534ad657 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 22 Dec 2011 16:51:51 +0000 Subject: Add a few comments, correct a merge artefact --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c578fc0..fc6eb6d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -570,6 +570,8 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 OffsetPosition { get { return m_pos; } + // Don't remove setter. It's not currently used in core but + // upcoming Avination code needs it. set { // There is no offset position when not seated @@ -2751,7 +2753,10 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent) return; - if (ParentID != 0) + // If we don't have a PhysActor, we can't cross anyway + // Also don't do this while sat, sitting avatars cross with the + // object they sit on. + if (ParentID != 0 || PhysActor == null) return; if (!IsInTransit) -- cgit v1.1 From 7f527814d524fe6b0fb5243dbdb558e5b661e4a5 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 22 Dec 2011 16:57:49 +0000 Subject: And a typo fix --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fc6eb6d..3d1c1b5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2756,7 +2756,7 @@ namespace OpenSim.Region.Framework.Scenes // If we don't have a PhysActor, we can't cross anyway // Also don't do this while sat, sitting avatars cross with the // object they sit on. - if (ParentID != 0 || PhysActor == null) + if (ParentID != 0 || PhysicsActor == null) return; if (!IsInTransit) -- cgit v1.1 From 983b49c0c872e997576d7fc167319e28e6f970e3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Jan 2012 18:25:31 +0000 Subject: commented out "Prevented flyoff" log message for now as this becomes problematic with bot testing. Please uncomment if still needed. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3d1c1b5..42cd4be 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2844,7 +2844,7 @@ namespace OpenSim.Region.Framework.Scenes Velocity = Vector3.Zero; AbsolutePosition = pos; - m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); +// m_log.DebugFormat("[SCENE PRESENCE]: Prevented flyoff for {0} at {1}", Name, AbsolutePosition); AddToPhysicalScene(isFlying); } -- cgit v1.1