From 167d8e39fa34c52593c640058287184026c95288 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 22 Oct 2009 13:14:41 -0700 Subject: * Sending (position - hipoffset) instead of position * Sending m_rotation instead of m_bodyRot in full updates to match terse updates (no idea which one is right!) --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 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 d7113bf..99fd86c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2517,15 +2517,12 @@ namespace OpenSim.Region.Framework.Scenes if (m_appearance.Texture == null) return; - // Note: because Quaternion is a struct, it can't be null - Quaternion rot = m_bodyRot; - Vector3 pos = m_pos; pos.Z -= m_appearance.HipOffset; remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, - LocalId, m_pos, m_appearance.Texture.GetBytes(), - m_parentID, rot)); + LocalId, pos, m_appearance.Texture.GetBytes(), + m_parentID, m_bodyRot)); m_scene.StatsReporter.AddAgentUpdates(1); } -- cgit v1.1 From 4ba3842d712ccb47e1b7effe0fdf2ed7da531431 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 22 Oct 2009 13:24:24 -0700 Subject: Forgot to hit save in the last commit --- 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 99fd86c..cfd3fcc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2522,7 +2522,7 @@ namespace OpenSim.Region.Framework.Scenes remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, pos, m_appearance.Texture.GetBytes(), - m_parentID, m_bodyRot)); + m_parentID, m_rotation)); m_scene.StatsReporter.AddAgentUpdates(1); } -- cgit v1.1 From ba2972eaf6d608fe4e6a6610089ab9fb8bae3f2d Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Thu, 22 Oct 2009 14:33:54 -0700 Subject: * Send out m_bodyRot everywhere instead of m_rotation. Still have no clue which is right * Fix WorldMapModule.process() to not trip the watchdog timer --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 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 cfd3fcc..ccfffe7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2417,7 +2417,7 @@ namespace OpenSim.Region.Framework.Scenes pos.Z -= m_appearance.HipOffset; remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, - pos, m_velocity, Vector3.Zero, m_rotation, Vector4.Zero, m_uuid, null, GetUpdatePriority(remoteClient))); + pos, m_velocity, Vector3.Zero, m_bodyRot, Vector4.UnitW, m_uuid, null, GetUpdatePriority(remoteClient))); m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); m_scene.StatsReporter.AddAgentUpdates(1); @@ -2522,7 +2522,7 @@ namespace OpenSim.Region.Framework.Scenes remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, pos, m_appearance.Texture.GetBytes(), - m_parentID, m_rotation)); + m_parentID, m_bodyRot)); m_scene.StatsReporter.AddAgentUpdates(1); } @@ -2585,14 +2585,11 @@ namespace OpenSim.Region.Framework.Scenes // the inventory arrives // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); - // Note: because Quaternion is a struct, it can't be null - Quaternion rot = m_bodyRot; - Vector3 pos = m_pos; pos.Z -= m_appearance.HipOffset; m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, - m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot)); + pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); if (!m_isChildAgent) { @@ -2697,9 +2694,11 @@ namespace OpenSim.Region.Framework.Scenes m_startAnimationSet = true; } - Quaternion rot = m_bodyRot; + Vector3 pos = m_pos; + pos.Z -= m_appearance.HipOffset; + m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, - m_pos, m_appearance.Texture.GetBytes(), m_parentID, rot)); + pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); } -- cgit v1.1 From 588361e2a2398b963871762c2b5485c6a086cf47 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 23 Oct 2009 01:02:36 -0700 Subject: Experimental change to use an immutable array for iterating ScenePresences, avoiding locking and copying the list each time it is accessed --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 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 ccfffe7..77706ac 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -869,14 +869,16 @@ namespace OpenSim.Region.Framework.Scenes m_isChildAgent = false; - List AnimAgents = m_scene.GetScenePresences(); - foreach (ScenePresence p in AnimAgents) + ScenePresence[] animAgents = m_scene.GetScenePresences(); + for (int i = 0; i < animAgents.Length; i++) { - if (p != this) - p.SendAnimPackToClient(ControllingClient); + ScenePresence presence = animAgents[i]; + + if (presence != this) + presence.SendAnimPackToClient(ControllingClient); } - m_scene.EventManager.TriggerOnMakeRootAgent(this); + m_scene.EventManager.TriggerOnMakeRootAgent(this); } /// @@ -2533,9 +2535,12 @@ namespace OpenSim.Region.Framework.Scenes { m_perfMonMS = Environment.TickCount; - List avatars = m_scene.GetScenePresences(); - foreach (ScenePresence avatar in avatars) + ScenePresence[] avatars = m_scene.GetScenePresences(); + + for (int i = 0; i < avatars.Length; i++) { + ScenePresence avatar = avatars[i]; + // only send if this is the root (children are only "listening posts" in a foreign region) if (!IsChildAgent) { @@ -2553,7 +2558,7 @@ namespace OpenSim.Region.Framework.Scenes } } - m_scene.StatsReporter.AddAgentUpdates(avatars.Count); + m_scene.StatsReporter.AddAgentUpdates(avatars.Length); m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); //SendAnimPack(); -- cgit v1.1 From 62f1a5e36d85b95e8f80bc073ba876873494963a Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 23 Oct 2009 02:38:59 -0700 Subject: Implemented a "FrontBack" prioritizer, using distance plus the plane equation to give double weight to prims/avatars in front of you --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (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 77706ac..a610e42 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -297,6 +297,21 @@ namespace OpenSim.Region.Framework.Scenes get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } } + public Vector3 CameraAtAxis + { + get { return m_CameraAtAxis; } + } + + public Vector3 CameraLeftAxis + { + get { return m_CameraLeftAxis; } + } + + public Vector3 CameraUpAxis + { + get { return m_CameraUpAxis; } + } + public Vector3 Lookat { get @@ -3867,6 +3882,8 @@ namespace OpenSim.Region.Framework.Scenes return GetPriorityByDistance(client); case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: return GetPriorityByDistance(client); + case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack: + return GetPriorityByFrontBack(client); default: throw new InvalidOperationException("UpdatePrioritizationScheme not defined."); } @@ -3888,11 +3905,34 @@ namespace OpenSim.Region.Framework.Scenes return double.NaN; } + private double GetPriorityByFrontBack(IClientAPI client) + { + ScenePresence presence = Scene.GetScenePresence(client.AgentId); + if (presence != null) + { + return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis); + } + return double.NaN; + } + private double GetPriorityByDistance(Vector3 position) { return Vector3.Distance(AbsolutePosition, position); } + private double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis) + { + // Distance + double priority = Vector3.Distance(camPosition, AbsolutePosition); + + // Plane equation + float d = -Vector3.Dot(camPosition, camAtAxis); + float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d; + if (p < 0.0f) priority *= 2.0f; + + return priority; + } + private double GetSOGUpdatePriority(SceneObjectGroup sog) { switch (Scene.UpdatePrioritizationScheme) @@ -3903,6 +3943,8 @@ namespace OpenSim.Region.Framework.Scenes return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); + case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack: + return sog.GetPriorityByFrontBack(CameraPosition, CameraAtAxis); default: throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); } @@ -3929,6 +3971,8 @@ namespace OpenSim.Region.Framework.Scenes case Scene.UpdatePrioritizationSchemes.Distance: case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); + case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack: + return GetPriorityByFrontBack(CameraPosition, CameraAtAxis); default: throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); } -- cgit v1.1 From de25dcfb7b28c81b7bce187165be81f65b849a7c Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 25 Oct 2009 01:01:26 -0700 Subject: Minor tweaks to get OpenSim compiling against both the current libomv and the upcoming 0.8.0 --- 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 a610e42..67384fb 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2693,7 +2693,7 @@ namespace OpenSim.Region.Framework.Scenes { if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) { - m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + (AppearanceManager.TextureIndex)j + ") for avatar " + this.Name); + m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name); this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); } } -- cgit v1.1 From b6651ce79017bc7c6d1df66757e26a74bacfc36f Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 26 Oct 2009 18:22:32 -0700 Subject: * Double the priority on avatar bake texture requests to get avatars rezzing in faster than the surrounding scene * Adds duplicate tracking for SceneObjectParts and ScenePresences to avoid sending out duplicate ImprovedTerseObjectUpdate packets --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 69 ++++++++---------------- 1 file changed, 21 insertions(+), 48 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 67384fb..0ac5be0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -93,12 +93,13 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 lastKnownAllowedPosition; public bool sentMessageAboutRestrictedParcelFlyingDown; - + private Vector3 m_lastPosition; + private Quaternion m_lastRotation; + private Vector3 m_lastVelocity; private bool m_updateflag; private byte m_movementflag; private readonly List m_forcesList = new List(); - private short m_updateCount; private uint m_requestedSitTargetID; private UUID m_requestedSitTargetUUID = UUID.Zero; private SendCourseLocationsMethod m_sendCourseLocationsMethod; @@ -145,12 +146,9 @@ namespace OpenSim.Region.Framework.Scenes public string JID = string.Empty; // Agent moves with a PID controller causing a force to be exerted. - private bool m_newForce; private bool m_newCoarseLocations = true; private float m_health = 100f; - private Vector3 m_lastVelocity = Vector3.Zero; - // Default AV Height private float m_avHeight = 127.0f; @@ -158,16 +156,6 @@ namespace OpenSim.Region.Framework.Scenes protected ulong crossingFromRegion; private readonly Vector3[] Dir_Vectors = new Vector3[6]; - - /// - /// The avatar position last sent to clients - /// - private Vector3 lastPhysPos = Vector3.Zero; - - /// - /// The avatar body rotation last sent to clients - /// - private Quaternion lastPhysRot = Quaternion.Identity; // Position of agent's camera in world (region cordinates) protected Vector3 m_CameraCenter = Vector3.Zero; @@ -1123,18 +1111,18 @@ namespace OpenSim.Region.Framework.Scenes CameraConstraintActive = true; //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); - Vector3 normal = Vector3.Normalize(new Vector3(0,0,collisionPoint.Z) - collisionPoint); + Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); } else { - if (((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) - || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02) - || lastPhysRot != m_bodyRot)) + if ((m_pos - m_lastPosition).Length() > 0.02f || + (m_velocity - m_lastVelocity).Length() > 0.02f || + m_bodyRot != m_lastRotation) { if (CameraConstraintActive) { - ControllingClient.SendCameraConstraint(new Vector4(0, 0.5f, 0.9f, -3000f)); + ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); CameraConstraintActive = false; } } @@ -2373,6 +2361,9 @@ namespace OpenSim.Region.Framework.Scenes public override void Update() { + const float VELOCITY_TOLERANCE = 0.01f; + const float POSITION_TOLERANCE = 10.0f; + SendPrimUpdates(); if (m_newCoarseLocations) @@ -2383,28 +2374,17 @@ namespace OpenSim.Region.Framework.Scenes if (m_isChildAgent == false) { - if (m_newForce) // user movement 'forces' (ie commands to move) + // Throw away duplicate or insignificant updates + if (m_bodyRot != m_lastRotation || + (m_velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || + (m_pos - m_lastPosition).Length() > POSITION_TOLERANCE) { SendTerseUpdateToAllClients(); - m_updateCount = 0; - } - else if (m_movementflag != 0) // scripted movement (?) - { - m_updateCount++; - if (m_updateCount > 3) - { - SendTerseUpdateToAllClients(); - m_updateCount = 0; - } - } - else if ((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) - || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02) - || lastPhysRot != m_bodyRot) - { - // Send Terse Update to all clients updates lastPhysPos and m_lastVelocity - // doing the above assures us that we know what we sent the clients last - SendTerseUpdateToAllClients(); - m_updateCount = 0; + + // Update the "last" values + m_lastPosition = m_pos; + m_lastRotation = m_bodyRot; + m_lastVelocity = m_velocity; } // followed suggestion from mic bowman. reversed the two lines below. @@ -2447,15 +2427,10 @@ namespace OpenSim.Region.Framework.Scenes public void SendTerseUpdateToAllClients() { m_perfMonMS = Environment.TickCount; - + m_scene.ForEachClient(SendTerseUpdateToClient); - m_lastVelocity = m_velocity; - lastPhysPos = AbsolutePosition; - lastPhysRot = m_bodyRot; - m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); - } public void SendCoarseLocations() @@ -3316,7 +3291,6 @@ namespace OpenSim.Region.Framework.Scenes /// public override void UpdateMovement() { - m_newForce = false; lock (m_forcesList) { if (m_forcesList.Count > 0) @@ -3338,7 +3312,6 @@ namespace OpenSim.Region.Framework.Scenes // Ignoring this causes no movement to be sent to the physics engine... // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter! } - m_newForce = true; m_forcesList.Clear(); } -- cgit v1.1 From d199767e6991d6f368661fce9c5a072e564b8a4b Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 25 Oct 2009 23:16:12 -0700 Subject: Experimental change of PhysicsVector to Vector3. Untested --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 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 0ac5be0..87fac0c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -434,7 +434,7 @@ namespace OpenSim.Region.Framework.Scenes { lock (m_scene.SyncRoot) { - m_physicsActor.Position = new PhysicsVector(value.X, value.Y, value.Z); + m_physicsActor.Position = value; } } catch (Exception e) @@ -474,7 +474,7 @@ namespace OpenSim.Region.Framework.Scenes { lock (m_scene.SyncRoot) { - m_physicsActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); + m_physicsActor.Velocity = value; } } catch (Exception e) @@ -1046,7 +1046,7 @@ namespace OpenSim.Region.Framework.Scenes m_avHeight = height; if (PhysicsActor != null && !IsChildAgent) { - PhysicsVector SetSize = new PhysicsVector(0.45f, 0.6f, m_avHeight); + Vector3 SetSize = new Vector3(0.45f, 0.6f, m_avHeight); PhysicsActor.Size = SetSize; } } @@ -3345,20 +3345,18 @@ namespace OpenSim.Region.Framework.Scenes PhysicsScene scene = m_scene.PhysicsScene; - PhysicsVector pVec = - new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, - AbsolutePosition.Z); + Vector3 pVec = AbsolutePosition; // Old bug where the height was in centimeters instead of meters if (m_avHeight == 127.0f) { - m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new PhysicsVector(0, 0, 1.56f), + m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, new Vector3(0f, 0f, 1.56f), isFlying); } else { m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec, - new PhysicsVector(0, 0, m_avHeight), isFlying); + new Vector3(0f, 0f, m_avHeight), isFlying); } scene.AddPhysicsActorTaint(m_physicsActor); //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; @@ -3369,7 +3367,7 @@ namespace OpenSim.Region.Framework.Scenes } - private void OutOfBoundsCall(PhysicsVector pos) + private void OutOfBoundsCall(Vector3 pos) { //bool flying = m_physicsActor.Flying; //RemoveFromPhysicalScene(); @@ -3592,7 +3590,7 @@ namespace OpenSim.Region.Framework.Scenes */ } - internal void PushForce(PhysicsVector impulse) + internal void PushForce(Vector3 impulse) { if (PhysicsActor != null) { -- cgit v1.1