From 423d03eaefcae1bcaff8e4d16da014d350c91c42 Mon Sep 17 00:00:00 2001 From: mingchen Date: Sat, 14 Jul 2007 15:11:36 +0000 Subject: *Added support for prim counting on parcels **No restrictions yet in place, or total prim count --- OpenSim/Region/Environment/Scenes/SceneObject.cs | 60 ++++++++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/SceneObject.cs') diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index d1a3e70..f4c4083 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs @@ -47,6 +47,9 @@ namespace OpenSim.Region.Environment.Scenes private PhysicsScene m_PhysScene; private PhysicsActor m_PhysActor; + private EventManager m_eventManager; + private ParcelManager m_parcelManager; + public LLUUID rootUUID { get @@ -65,38 +68,71 @@ namespace OpenSim.Region.Environment.Scenes } } + public int primCount + { + get + { + return this.ChildPrimitives.Count; + } + } + /// /// /// - public SceneObject(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) + public SceneObject(ulong regionHandle, Scene world, EventManager eventManager, ParcelManager parcelManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) { m_regionHandle = regionHandle; m_world = world; + m_eventManager = eventManager; + m_parcelManager = parcelManager; + this.Pos = pos; this.CreateRootFromShape(ownerID, localID, shape, pos); - // Setup a backup event listener - world.EventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup); + registerEvents(); + + } + + /// + /// + /// + /// Need a null constructor for duplication + public SceneObject() + { + } + public void registerEvents() + { + m_eventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup); + m_eventManager.OnParcelPrimCountUpdate += new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); + } + public void unregisterEvents() + { + m_eventManager.OnBackup -= new EventManager.OnBackupDelegate(ProcessBackup); + m_eventManager.OnParcelPrimCountUpdate -= new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); + } /// /// Processes backup /// /// - void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) + public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) { datastore.StoreObject(this); } + /// - /// + /// Sends my primitive info to the parcel manager for it to keep tally of all of the prims! /// - /// Need a null constructor for duplication - public SceneObject() + private void ProcessParcelPrimCountUpdate() { - + m_parcelManager.addPrimToParcelCounts(this); } + + + /// /// /// @@ -105,7 +141,7 @@ 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, agentID, localID, true, this, this, shape, pos); + this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world,this.m_parcelManager, agentID, localID, true, this, this, shape, pos); this.children.Add(rootPrimitive); this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); } @@ -120,7 +156,7 @@ namespace OpenSim.Region.Environment.Scenes } /// - /// + /// Copies a prim or group of prims (SceneObject) -- TODO: cleanup code /// /// A complete copy of the object public new SceneObject Copy() @@ -136,6 +172,8 @@ namespace OpenSim.Region.Environment.Scenes dupe.Rotation = this.Rotation; LLUUID rootu= dupe.rootUUID; uint rooti = dupe.rootLocalID; + + dupe.registerEvents(); return dupe; } @@ -147,6 +185,7 @@ namespace OpenSim.Region.Environment.Scenes this.children.Clear(); this.ChildPrimitives.Clear(); this.rootPrimitive = null; + unregisterEvents(); } /// @@ -256,5 +295,6 @@ namespace OpenSim.Region.Environment.Scenes client.OutPacket(proper); } + } } -- cgit v1.1