From f1b99c4a7f9543c3a2aa36de2e659bdefca9e68b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Feb 2010 21:35:56 +0000 Subject: minor: one method doc --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8d84557..dd797fc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4144,9 +4144,13 @@ namespace OpenSim.Region.Framework.Scenes ScheduleFullUpdate(); } - // Added to handle bug in libsecondlife's TextureEntry.ToBytes() - // not handling RGBA properly. Cycles through, and "fixes" the color - // info + /// + /// Update the textures on the part. + /// + /// Added to handle bug in libsecondlife's TextureEntry.ToBytes() + /// not handling RGBA properly. Cycles through, and "fixes" the color + /// info + /// public void UpdateTexture(Primitive.TextureEntry tex) { //Color4 tmpcolor; -- cgit v1.1 From 0a084a31e9f96cc007f953b47e3319bde6d834f2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Feb 2010 23:23:07 +0000 Subject: refactor: chain two ScenePresence constructors together to eliminate common code. No functional changes --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 26 ++++++++++-------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cd39cab..bcf22c3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -104,6 +104,8 @@ namespace OpenSim.Region.Framework.Scenes } protected ScenePresenceAnimator m_animator; + protected List m_attachments = new List(); + private Dictionary scriptedcontrols = new Dictionary(); private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; @@ -215,9 +217,7 @@ namespace OpenSim.Region.Framework.Scenes // Agent's Draw distance. protected float m_DrawDistance; - protected AvatarAppearance m_appearance; - - protected List m_attachments = new List(); + protected AvatarAppearance m_appearance; // neighbouring regions we have enabled a child agent in // holds the seed cap for the child agent in that region @@ -630,12 +630,16 @@ namespace OpenSim.Region.Framework.Scenes #endregion #region Constructor(s) - - private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) - { - m_animator = new ScenePresenceAnimator(this); + + public ScenePresence() + { m_sendCourseLocationsMethod = SendCoarseLocationsDefault; CreateSceneViewer(); + m_animator = new ScenePresenceAnimator(this); + } + + private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() + { m_rootRegionHandle = reginfo.RegionHandle; m_controllingClient = client; m_firstname = m_controllingClient.FirstName; @@ -659,7 +663,6 @@ namespace OpenSim.Region.Framework.Scenes m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); m_reprioritization_timer.AutoReset = false; - AdjustKnownSeeds(); // TODO: I think, this won't send anything, as we are still a child here... @@ -3321,13 +3324,6 @@ namespace OpenSim.Region.Framework.Scenes m_animator = null; } - public ScenePresence() - { - m_sendCourseLocationsMethod = SendCoarseLocationsDefault; - CreateSceneViewer(); - m_animator = new ScenePresenceAnimator(this); - } - public void AddAttachment(SceneObjectGroup gobj) { lock (m_attachments) -- cgit v1.1 From bf9fc69d017e9179b32cb7fde3374264f5c1ea8d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 5 Feb 2010 19:34:25 +0000 Subject: minor: log what kind of wearable cannot be found --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index bcf22c3..e960d51 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3184,8 +3184,7 @@ namespace OpenSim.Region.Framework.Scenes m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong m_physicsActor.SubscribeEvents(500); - m_physicsActor.LocalID = LocalId; - + m_physicsActor.LocalID = LocalId; } private void OutOfBoundsCall(Vector3 pos) @@ -3195,7 +3194,7 @@ namespace OpenSim.Region.Framework.Scenes //AddToPhysicalScene(flying); if (ControllingClient != null) - ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.",true); + ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); } // Event called by the physics plugin to tell the avatar about a collision. -- cgit v1.1 From 00947cf2ca7a9315ae1d508507db0c95348e25ec Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 8 Feb 2010 19:02:20 +0000 Subject: Add EventManager.OnIncomingSceneObject event which is triggered by an incoming scene object Add a read-only Attachments property to ScenePresence --- OpenSim/Region/Framework/Scenes/EventManager.cs | 29 ++++++++++++++++- OpenSim/Region/Framework/Scenes/Scene.cs | 36 +++++++++++++--------- .../Framework/Scenes/SceneCommunicationService.cs | 1 - OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 +++++- 4 files changed, 58 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 473920e..9f74b2a 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -205,6 +205,12 @@ namespace OpenSim.Region.Framework.Scenes public delegate void OnMakeRootAgentDelegate(ScenePresence presence); public event OnMakeRootAgentDelegate OnMakeRootAgent; + /// + /// Triggered when an object or attachment enters a scene + /// + public event OnIncomingSceneObjectDelegate OnIncomingSceneObject; + public delegate void OnIncomingSceneObjectDelegate(SceneObjectGroup so); + public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel); public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete; @@ -407,7 +413,7 @@ namespace OpenSim.Region.Framework.Scenes } } } - } + } public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) { @@ -1206,6 +1212,27 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerOnIncomingSceneObject(SceneObjectGroup so) + { + OnIncomingSceneObjectDelegate handlerIncomingSceneObject = OnIncomingSceneObject; + if (handlerIncomingSceneObject != null) + { + foreach (OnIncomingSceneObjectDelegate d in handlerIncomingSceneObject.GetInvocationList()) + { + try + { + d(so); + } + catch (Exception e) + { + m_log.ErrorFormat( + "[EVENT MANAGER]: Delegate for TriggerOnIncomingSceneObject failed - continuing. {0} {1}", + e.Message, e.StackTrace); + } + } + } + } + public void TriggerOnRegisterCaps(UUID agentID, Caps caps) { RegisterCapsEvent handlerRegisterCaps = OnRegisterCaps; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 73b0b3e..039d074 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2406,9 +2406,14 @@ namespace OpenSim.Region.Framework.Scenes return successYN; } + /// + /// Called when objects or attachments cross the border between regions. + /// + /// + /// public bool IncomingCreateObject(ISceneObject sog) { - //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); + //m_log.Debug(" >>> IncomingCreateObject(sog) <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); SceneObjectGroup newObject; try { @@ -2425,7 +2430,12 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName); return false; } + newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1); + + // Do this as late as possible so that listeners have full access to the incoming object + EventManager.TriggerOnIncomingSceneObject(newObject); + return true; } @@ -2437,6 +2447,8 @@ namespace OpenSim.Region.Framework.Scenes /// False public virtual bool IncomingCreateObject(UUID userID, UUID itemID) { + //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); + ScenePresence sp = GetScenePresence(userID); if (sp != null) { @@ -2496,29 +2508,25 @@ namespace OpenSim.Region.Framework.Scenes //RootPrim.SetParentLocalId(parentLocalID); - m_log.DebugFormat("[ATTACHMENT]: Received " + - "attachment {0}, inworld asset id {1}", - //grp.RootPart.LastOwnerID.ToString(), - grp.GetFromItemID(), - grp.UUID.ToString()); + m_log.DebugFormat( + "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", grp.GetFromItemID(), grp.UUID); //grp.SetFromAssetID(grp.RootPart.LastOwnerID); - m_log.DebugFormat("[ATTACHMENT]: Attach " + - "to avatar {0} at position {1}", - sp.UUID.ToString(), grp.AbsolutePosition); - AttachObject(sp.ControllingClient, - grp.LocalId, (uint)0, - grp.GroupRotation, - grp.AbsolutePosition, false); + m_log.DebugFormat( + "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); + + AttachObject( + sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); RootPrim.RemFlag(PrimFlags.TemporaryOnRez); grp.SendGroupFullUpdate(); + + } else { RootPrim.RemFlag(PrimFlags.TemporaryOnRez); RootPrim.AddFlag(PrimFlags.TemporaryOnRez); } - } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 6164368..2f6a0db 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -191,7 +191,6 @@ namespace OpenSim.Region.Framework.Scenes if (handlerChildAgentUpdate != null) handlerChildAgentUpdate(cAgentData); - return true; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e960d51..6b95624 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -104,6 +104,14 @@ namespace OpenSim.Region.Framework.Scenes } protected ScenePresenceAnimator m_animator; + /// + /// The scene objects attached to this avatar. Do not change this list directly - use methods such as + /// AddAttachment() and RemoveAttachment(). Lock this list when performing any read operations upon it. + /// + public List Attachments + { + get { return m_attachments; } + } protected List m_attachments = new List(); private Dictionary scriptedcontrols = new Dictionary(); @@ -1105,7 +1113,6 @@ namespace OpenSim.Region.Framework.Scenes m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); SendInitialData(); - } /// -- cgit v1.1 From 9f4883d1468b5fe1c60e1831b24e1fed1eb5caeb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 8 Feb 2010 19:10:54 +0000 Subject: refactor: Reuse SceneObjectGroup.IsAttachmentCheckFull() in Scene.AddSceneObject since this wraps a check that is much less clear --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++---- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 11 ++++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 039d074..ddebd0b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2483,7 +2483,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart p in sceneObject.Children.Values) p.LocalId = 0; - if ((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0)) // Attachment + if (sceneObject.IsAttachmentCheckFull()) // Attachment { sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez); sceneObject.RootPart.AddFlag(PrimFlags.Phantom); @@ -2518,9 +2518,7 @@ namespace OpenSim.Region.Framework.Scenes AttachObject( sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); RootPrim.RemFlag(PrimFlags.TemporaryOnRez); - grp.SendGroupFullUpdate(); - - + grp.SendGroupFullUpdate(); } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8c56870..af46659 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -268,7 +268,16 @@ namespace OpenSim.Region.Framework.Scenes } } - private bool IsAttachmentCheckFull() + /// + /// Check both the attachment property and the relevant properties of the underlying root part. + /// + /// This is necessary in some cases, particularly when a scene object has just crossed into a region and doesn't + /// have the IsAttachment property yet checked. + /// + /// FIXME: However, this should be fixed so that this property + /// propertly reflects the underlying status. + /// + public bool IsAttachmentCheckFull() { return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); } -- cgit v1.1