From 937c06db54f8152486d37a4ba604ffb3bcdccbb4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 Dec 2011 21:57:22 +0000 Subject: Code cleanup related to ScenePresence.PhysicsActor and OdeScene/OdeCharacter Stop hiding RemoveAvatar failure, add log messages when characters are removed through defects or re-added unexpectedly. Add commented out log lines for future use. Use automatic property for PhysicsActor for better code readability and simplicity --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 59 +++++++++++++----------- 1 file changed, 32 insertions(+), 27 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 beff239..6f5b6fe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -285,16 +285,10 @@ namespace OpenSim.Region.Framework.Scenes #region Properties - protected PhysicsActor m_physicsActor; - /// /// Physical scene representation of this Avatar. /// - public PhysicsActor PhysicsActor - { - set { m_physicsActor = value; } - get { return m_physicsActor; } - } + public PhysicsActor PhysicsActor { get; private set; } private byte m_movementflag; @@ -1032,18 +1026,19 @@ namespace OpenSim.Region.Framework.Scenes { if (PhysicsActor != null) { - try - { - PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; - PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; - m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); - PhysicsActor.UnSubscribeEvents(); - PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; - PhysicsActor = null; - } - catch - { } +// PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; + PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; + m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); + PhysicsActor.UnSubscribeEvents(); + PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; + PhysicsActor = null; } +// else +// { +// m_log.ErrorFormat( +// "[SCENE PRESENCE]: Attempt to remove physics actor for {0} on {1} but this scene presence has no physics actor", +// Name, Scene.RegionInfo.RegionName); +// } } /// @@ -1925,7 +1920,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE]: {0} {1}", SitTargetisSet, SitTargetUnOccupied); if (PhysicsActor != null) - m_sitAvatarHeight = m_physicsActor.Size.Z; + m_sitAvatarHeight = PhysicsActor.Size.Z; bool canSit = false; pos = part.AbsolutePosition + offset; @@ -2570,7 +2565,10 @@ namespace OpenSim.Region.Framework.Scenes // only send update from root agents to other clients; children are only "listening posts" if (IsChildAgent) { - m_log.Warn("[SCENE PRESENCE]: Attempt to send avatar data from a child agent"); + m_log.WarnFormat( + "[SCENE PRESENCE]: Attempt to send avatar data from a child agent for {0} in {1}", + Name, Scene.RegionInfo.RegionName); + return; } @@ -2628,7 +2626,10 @@ namespace OpenSim.Region.Framework.Scenes // only send update from root agents to other clients; children are only "listening posts" if (IsChildAgent) { - m_log.Warn("[SCENE PRESENCE]: Attempt to send avatar data from a child agent"); + m_log.WarnFormat( + "[SCENE PRESENCE]: Attempt to send avatar data from a child agent for {0} in {1}", + Name, Scene.RegionInfo.RegionName); + return; } @@ -3039,8 +3040,6 @@ namespace OpenSim.Region.Framework.Scenes CameraPosition = cAgentData.Center + offset; - //SetHeight(cAgentData.AVHeight); - if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); @@ -3251,6 +3250,13 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE PRESENCE]: Adding physics actor for {0}, ifFlying = {1} in {2}", // Name, isFlying, Scene.RegionInfo.RegionName); + if (PhysicsActor != null) + { + m_log.ErrorFormat( + "[SCENE PRESENCE]: Adding physics actor for {0} to {1} but this scene presence already has a physics actor", + Name, Scene.RegionInfo.RegionName); + } + if (Appearance.AvatarHeight == 0) Appearance.SetHeight(); @@ -3258,11 +3264,10 @@ namespace OpenSim.Region.Framework.Scenes Vector3 pVec = AbsolutePosition; - // Old bug where the height was in centimeters instead of meters - PhysicsActor = scene.AddAvatar(LocalId, Firstname + "." + Lastname, pVec, - new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); + PhysicsActor = scene.AddAvatar( + LocalId, Firstname + "." + Lastname, pVec, + new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); - scene.AddPhysicsActorTaint(PhysicsActor); //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong -- cgit v1.1 From c0ba99e5ada0b734b932091befce69dbd53d149a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 15 Dec 2011 22:29:36 +0000 Subject: Stop having to call SetHeight again in ScenePresence.AddToPhysicalScene() when we've already passed size information to the avatar at PhysicsScene.AddAvatar() Eliminate some copypasta for height setting in OdeCharacter --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 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 6f5b6fe..ac58dae 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1149,13 +1149,11 @@ namespace OpenSim.Region.Framework.Scenes /// /// Sets avatar height in the physics plugin /// + /// New height of avatar public void SetHeight(float height) { if (PhysicsActor != null && !IsChildAgent) - { - Vector3 SetSize = new Vector3(0.45f, 0.6f, height); - PhysicsActor.Size = SetSize; - } + PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); } /// @@ -3273,8 +3271,6 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong PhysicsActor.SubscribeEvents(500); PhysicsActor.LocalID = LocalId; - - SetHeight(Appearance.AvatarHeight); } private void OutOfBoundsCall(Vector3 pos) -- cgit v1.1 From 3bf699ad36081c9c53ee6845a5c85a3a1856b923 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 16 Dec 2011 08:59:33 -0800 Subject: No functional changes. Changed the prefix of that log message [CONNECTION BEGIN] to [SCENE] because that's where the message happens. Also changed the instantiation of a vector object to be done only once instead of every time we receive a position update. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 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 ac58dae..800b7e0 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -502,9 +502,9 @@ namespace OpenSim.Region.Framework.Scenes { m_pos = PhysicsActor.Position; -// m_log.DebugFormat( -// "[SCENE PRESENCE]: Set position {0} for {1} in {2} via getting AbsolutePosition!", -// m_pos, Name, Scene.RegionInfo.RegionName); + //m_log.DebugFormat( + // "[SCENE PRESENCE]: Set position {0} for {1} in {2} via getting AbsolutePosition!", + // m_pos, Name, Scene.RegionInfo.RegionName); } else { @@ -534,7 +534,6 @@ namespace OpenSim.Region.Framework.Scenes } } } - return m_pos; } set @@ -554,9 +553,9 @@ namespace OpenSim.Region.Framework.Scenes m_pos = value; ParentPosition = Vector3.Zero; -// m_log.DebugFormat( -// "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", -// Scene.RegionInfo.RegionName, Name, m_pos); + //m_log.DebugFormat( + // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", + // Scene.RegionInfo.RegionName, Name, m_pos); } } @@ -3006,6 +3005,7 @@ namespace OpenSim.Region.Framework.Scenes CopyFrom(cAgentData); } + private static Vector3 marker = new Vector3(-1f, -1f, -1f); /// /// This updates important decision making data about a child agent /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region @@ -3026,8 +3026,8 @@ namespace OpenSim.Region.Framework.Scenes // region's draw distance. // DrawDistance = cAgentData.Far; DrawDistance = Scene.DefaultDrawDistance; - - if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! + + if (cAgentData.Position != marker) // UGH!! m_pos = cAgentData.Position + offset; if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) -- cgit v1.1 From a3a17e929e7a39566a677672572433fe35d25849 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 16 Dec 2011 23:20:12 +0000 Subject: Stop generating client flags when we send out full object updates. These were entirely unused. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ------ 1 file changed, 6 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 800b7e0..7be95cd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -784,7 +784,6 @@ namespace OpenSim.Region.Framework.Scenes public void RegisterToEvents() { ControllingClient.OnCompleteMovementToRegion += CompleteMovement; - //ControllingClient.OnCompleteMovementToRegion += SendInitialData; ControllingClient.OnAgentUpdate += HandleAgentUpdate; ControllingClient.OnAgentRequestSit += HandleAgentRequestSit; ControllingClient.OnAgentSit += HandleAgentSit; @@ -832,11 +831,6 @@ namespace OpenSim.Region.Framework.Scenes #endregion - public uint GenerateClientFlags(UUID ObjectID) - { - return m_scene.Permissions.GenerateClientFlags(m_uuid, ObjectID); - } - #region Status Methods /// -- cgit v1.1 From 964ec57ffe5ce2e9feac4295ade9cc4a5a223d69 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 16 Dec 2011 17:24:50 -0800 Subject: Changed the async approach on close child agents. This may improve crossings a little bit. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++++- 1 file changed, 4 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 800b7e0..b16eaba 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2955,7 +2955,10 @@ namespace OpenSim.Region.Framework.Scenes if (byebyeRegions.Count > 0) { m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); - m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, byebyeRegions); + Util.FireAndForget(delegate + { + m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, byebyeRegions); + }); } foreach (ulong handle in byebyeRegions) -- cgit v1.1 From 0b91ec8dd2b78461cb0fcdec567a83e88a76ac87 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Dec 2011 18:58:05 +0000 Subject: Migrate detailed "appearance show" report generation up to AvatarFactoryModule from AppearanceInfoModule so that it can be used in debug (inactive). Further filters "debug packet " to exclused [Request]ObjectPropertiesFamily if level is below 25. Adjust some method doc Minor changes to some logging messages. --- 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 7be95cd..f2e2ce7 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2667,7 +2667,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendAppearanceToAgent(ScenePresence avatar) { // m_log.DebugFormat( -// "[SCENE PRESENCE] Send appearance from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); +// "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); avatar.ControllingClient.SendAppearance( UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); -- cgit v1.1 From 92039f295d7fe66bf1a09b29483f9057e395839e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Dec 2011 20:13:48 +0000 Subject: Stop sending the viewer its own AvatarAppearance packet. The viewer warns in the log if it receives this. Stopping this doesn't appear to have adverse effects on viewer 1 or viewer 3 - the viewer gets its own appearance from body parts/clothes and self-baked textures. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++++- 1 file changed, 4 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 f2e2ce7..9cad3fe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2532,7 +2532,10 @@ namespace OpenSim.Region.Framework.Scenes // again here... this comes after the cached appearance check because the avatars // appearance goes into the avatar update packet SendAvatarDataToAllAgents(); - SendAppearanceToAgent(this); + + // Sending us our own appearance does not seem to be necessary, and the viewer warns in the log if you do + // this. +// SendAppearanceToAgent(this); // If we are using the the cached appearance then send it out to everyone if (cachedappearance) -- cgit v1.1 From fa0a71253f0c824b6fc952c1a8927c8f189892b9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Dec 2011 18:54:15 +0000 Subject: Though the viewer warns about receiving this, not sending appears to break baked texture caching when crossing region boundaries. Needs further investigation. Revert "Stop sending the viewer its own AvatarAppearance packet." This reverts commit 92039f295d7fe66bf1a09b29483f9057e395839e. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +---- 1 file changed, 1 insertion(+), 4 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..b8ae553 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2532,10 +2532,7 @@ namespace OpenSim.Region.Framework.Scenes // again here... this comes after the cached appearance check because the avatars // appearance goes into the avatar update packet SendAvatarDataToAllAgents(); - - // Sending us our own appearance does not seem to be necessary, and the viewer warns in the log if you do - // this. -// SendAppearanceToAgent(this); + SendAppearanceToAgent(this); // If we are using the the cached appearance then send it out to everyone if (cachedappearance) -- cgit v1.1