diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index b47813fb97..6f64512318 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs @@ -215,8 +215,6 @@ namespace OpenSim LocalWorld = new Scene(udpServer.PacketServer.ClientManager, regionDat, authenBase, commsManager, this.AssetCache, tmpStoreManager, httpServer); this.m_localWorld.Add(LocalWorld); - //LocalWorld.InventoryCache = InventoryCache; - //LocalWorld.AssetCache = AssetCache; udpServer.LocalWorld = LocalWorld; diff --git a/OpenSim/Region/Environment/ParcelManager.cs b/OpenSim/Region/Environment/ParcelManager.cs index 1b8b16f8cc..4f836efe85 100644 --- a/OpenSim/Region/Environment/ParcelManager.cs +++ b/OpenSim/Region/Environment/ParcelManager.cs @@ -206,7 +206,7 @@ namespace OpenSim.Region.Environment } else { - Console.WriteLine("Point (" + x + ", " + y + ") determined from point (" + x_float + ", " + y_float + ")"); + // Console.WriteLine("Point (" + x + ", " + y + ") determined from point (" + x_float + ", " + y_float + ")"); return parcelList[parcelIDList[x, y]]; } } diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index 833bf85b01..23dcf6e771 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs @@ -9,6 +9,8 @@ using OpenSim.Framework.Types; namespace OpenSim.Region.Environment.Scenes { + public delegate void PrimCountTaintedDelegate(); + public class Primitive : EntityBase { private const uint FULL_MASK_PERMISSIONS = 2147483647; @@ -47,6 +49,8 @@ namespace OpenSim.Region.Environment.Scenes private EventManager m_eventManager; + public event PrimCountTaintedDelegate OnPrimCountTainted; + #region Properties /// /// If rootprim, will return world position @@ -132,22 +136,21 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public Primitive(ulong regionHandle, Scene world, EventManager eventManager, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos) + public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos) { m_regionHandle = regionHandle; m_world = world; - m_eventManager = eventManager; inventoryItems = new Dictionary(); this.m_Parent = parent; this.m_isRootPrim = isRoot; this.m_RootParent = rootObject; - this.CreateFromShape(ownerID, localID, pos, shape); this.Rotation = Axiom.Math.Quaternion.Identity; - - m_eventManager.TriggerParcelPrimCountTainted(); + m_world.AcknowledgeNewPrim(this); + + this.OnPrimCountTainted(); } /// @@ -156,7 +159,7 @@ namespace OpenSim.Region.Environment.Scenes /// Empty constructor for duplication public Primitive() { - m_eventManager.TriggerParcelPrimCountTainted(); + } #endregion @@ -165,7 +168,7 @@ namespace OpenSim.Region.Environment.Scenes ~Primitive() { - m_eventManager.TriggerParcelPrimCountTainted(); + this.OnPrimCountTainted(); } #endregion @@ -174,17 +177,20 @@ namespace OpenSim.Region.Environment.Scenes public Primitive Copy(EntityBase parent, SceneObject rootParent) { Primitive dupe = (Primitive)this.MemberwiseClone(); - // TODO: Copy this properly. - dupe.inventoryItems = this.inventoryItems; + dupe.m_Parent = parent; dupe.m_RootParent = rootParent; - dupe.m_Shape = this.m_Shape.Copy(); + // TODO: Copy this properly. + dupe.inventoryItems = this.inventoryItems; dupe.children = new List(); + dupe.m_Shape = this.m_Shape.Copy(); + dupe.m_regionHandle = this.m_regionHandle; + dupe.m_world = this.m_world; + uint newLocalID = this.m_world.PrimIDAllocate(); dupe.uuid = LLUUID.Random(); dupe.LocalId = newLocalID; - dupe.m_regionHandle = this.m_regionHandle; if (parent is SceneObject) { @@ -200,7 +206,10 @@ namespace OpenSim.Region.Environment.Scenes dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z); dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); dupe.m_pos = new LLVector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); + rootParent.AddChildToList(dupe); + this.m_world.AcknowledgeNewPrim(dupe); + dupe.TriggerOnPrimCountTainted(); foreach (Primitive prim in this.children) { @@ -213,7 +222,6 @@ namespace OpenSim.Region.Environment.Scenes #endregion - #region Override from EntityBase /// /// @@ -276,7 +284,7 @@ namespace OpenSim.Region.Environment.Scenes this.m_world.DeleteEntity(linkObject.rootUUID); linkObject.DeleteAllChildren(); - m_eventManager.TriggerParcelPrimCountTainted(); + this.OnPrimCountTainted(); } /// @@ -352,7 +360,7 @@ namespace OpenSim.Region.Environment.Scenes prim.m_pos += offset; prim.updateFlag = 2; } - m_eventManager.TriggerParcelPrimCountTainted(); + this.OnPrimCountTainted(); } /// @@ -404,7 +412,7 @@ namespace OpenSim.Region.Environment.Scenes this.Pos = newPos; this.updateFlag = 2; - m_eventManager.TriggerParcelPrimCountTainted(); + this.OnPrimCountTainted(); } /// @@ -533,6 +541,7 @@ namespace OpenSim.Region.Environment.Scenes this.updateFlag = 1; } #endregion + #region Client Update Methods /// @@ -622,5 +631,10 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + + public void TriggerOnPrimCountTainted() + { + this.OnPrimCountTainted(); + } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index e370047f90..ad46322718 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -139,7 +139,6 @@ namespace OpenSim.Region.Environment.Scenes m_scriptManager = new ScriptManager(this); m_eventManager = new EventManager(); - m_eventManager.OnParcelPrimCountTainted += new EventManager.OnParcelPrimCountTaintedDelegate(m_parcelManager.setPrimsTainted); m_eventManager.OnParcelPrimCountAdd += new EventManager.OnParcelPrimCountAddDelegate(m_parcelManager.addPrimToParcelCounts); MainLog.Instance.Verbose("World.cs - creating new entitities instance"); @@ -221,14 +220,14 @@ namespace OpenSim.Region.Environment.Scenes } this.parcelPrimCheckCount++; - if (this.parcelPrimCheckCount > 50) //check every 5 seconds for tainted prims + if (this.parcelPrimCheckCount > 100) //check every 10 seconds for tainted prims { if (m_parcelManager.parcelPrimCountTainted) { //Perform parcel update of prim count performParcelPrimCountUpdate(); this.parcelPrimCheckCount = 0; - } + } } } @@ -434,7 +433,6 @@ namespace OpenSim.Region.Environment.Scenes /// The object to load public void PrimFromStorage(PrimData prim) { - } /// @@ -460,7 +458,8 @@ namespace OpenSim.Region.Environment.Scenes /// public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape) { - SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, this.PrimIDAllocate(), pos, shape); + + SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, this.PrimIDAllocate(), pos, shape); AddNewEntity(sceneOb); } @@ -469,6 +468,14 @@ namespace OpenSim.Region.Environment.Scenes this.Entities.Add(sceneObject.rootUUID, sceneObject); } + /// + /// Called by a prim when it has been created/cloned, so that its events can be subscribed to + /// + /// + public void AcknowledgeNewPrim(Primitive prim) + { + prim.OnPrimCountTainted += m_parcelManager.setPrimsTainted; + } #endregion #region Add/Remove Avatar Methods diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index 46768d5663..f8ebb2f887 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -19,9 +19,6 @@ namespace OpenSim.Region.Environment.Scenes public delegate void OnRemovePresenceDelegate(LLUUID uuid); public event OnRemovePresenceDelegate OnRemovePresence; - public delegate void OnParcelPrimCountTaintedDelegate(); - public event OnParcelPrimCountTaintedDelegate OnParcelPrimCountTainted; - public delegate void OnParcelPrimCountUpdateDelegate(); public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate; @@ -58,13 +55,6 @@ namespace OpenSim.Region.Environment.Scenes } } - public void TriggerParcelPrimCountTainted() - { - if (OnParcelPrimCountTainted != null) - { - OnParcelPrimCountTainted(); - } - } public void TriggerParcelPrimCountUpdate() { if (OnParcelPrimCountUpdate != null) diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index 7992b17d46..95db271bd8 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs @@ -88,7 +88,7 @@ namespace OpenSim.Region.Environment.Scenes this.CreateRootFromShape(ownerID, localID, shape, pos); registerEvents(); - + } /// @@ -97,7 +97,7 @@ namespace OpenSim.Region.Environment.Scenes /// Need a null constructor for duplication public SceneObject() { - + } public void registerEvents() @@ -121,18 +121,15 @@ namespace OpenSim.Region.Environment.Scenes datastore.StoreObject(this); } - /// /// Sends my primitive info to the parcel manager for it to keep tally of all of the prims! /// private void ProcessParcelPrimCountUpdate() { + m_eventManager.TriggerParcelPrimCountAdd(this); } - - - /// /// /// @@ -141,7 +138,9 @@ namespace OpenSim.Region.Environment.Scenes /// public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos) { - this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world,this.m_eventManager, agentID, localID, true, this, this, shape, pos); + + this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world, agentID, localID, true, this, this, shape, pos); + this.children.Add(rootPrimitive); this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); } @@ -156,7 +155,7 @@ namespace OpenSim.Region.Environment.Scenes } /// - /// Copies a prim or group of prims (SceneObject) -- TODO: cleanup code + /// Makes a copy of this SceneObject (and child primitives) /// /// A complete copy of the object public new SceneObject Copy() @@ -171,8 +170,8 @@ namespace OpenSim.Region.Environment.Scenes dupe.children.Add(dupe.rootPrimitive); dupe.rootPrimitive.Pos = this.Pos; dupe.Rotation = this.Rotation; - LLUUID rootu= dupe.rootUUID; - uint rooti = dupe.rootLocalID; + LLUUID rootu = dupe.rootUUID; + uint rooti = dupe.rootLocalID; dupe.registerEvents(); return dupe; diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index 1c502eda64..f8c99aa934 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -18,7 +18,7 @@ using OpenSim.Region.Environment.Scenes; namespace SimpleApp { - class Program : IAssetReceiver, conscmd_callback + class Program : conscmd_callback { private LogBase m_log; AuthenticateSessionsBase m_circuitManager; @@ -42,7 +42,6 @@ namespace SimpleApp LocalAssetServer assetServer = new LocalAssetServer(); assetServer.SetServerInfo("http://127.0.0.1:8003/", ""); - assetServer.SetReceiver(this); AssetCache assetCache = new AssetCache(assetServer); @@ -83,40 +82,6 @@ namespace SimpleApp m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit."); m_log.ReadLine(); } - - private bool AddNewSessionHandler(ulong regionHandle, Login loginData) - { - m_log.WriteLine(LogPriority.NORMAL, "Region [{0}] recieved Login from [{1}] [{2}]", regionHandle, loginData.First, loginData.Last); - - AgentCircuitData agent = new AgentCircuitData(); - agent.AgentID = loginData.Agent; - agent.firstname = loginData.First; - agent.lastname = loginData.Last; - agent.SessionID = loginData.Session; - agent.SecureSessionID = loginData.SecureSession; - agent.circuitcode = loginData.CircuitCode; - agent.BaseFolder = loginData.BaseFolder; - agent.InventoryFolder = loginData.InventoryFolder; - agent.startpos = new LLVector3(128, 128, 70); - - m_circuitManager.AddNewCircuit(agent.circuitcode, agent); - - return true; - } - - #region IAssetReceiver Members - - public void AssetReceived(AssetBase asset, bool IsTexture) - { - throw new Exception("The method or operation is not implemented."); - } - - public void AssetNotFound(AssetBase asset) - { - throw new Exception("The method or operation is not implemented."); - } - - #endregion #region conscmd_callback Members