*Added support for prim counting on parcels

**No restrictions yet in place, or total prim count
This commit is contained in:
mingchen
2007-07-14 15:11:36 +00:00
parent 5a909a2054
commit 423d03eaef
6 changed files with 229 additions and 28 deletions

View File

@@ -45,6 +45,8 @@ namespace OpenSim.Region.Environment.Scenes
public bool m_isRootPrim;
public EntityBase m_Parent;
private ParcelManager m_parcelManager;
#region Properties
/// <summary>
/// If rootprim, will return world position
@@ -130,10 +132,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="isRoot"></param>
/// <param name="parent"></param>
/// <param name="rootObject"></param>
public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos)
public Primitive(ulong regionHandle, Scene world, ParcelManager parcelManager, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos)
{
m_regionHandle = regionHandle;
m_world = world;
m_parcelManager = parcelManager;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.m_Parent = parent;
this.m_isRootPrim = isRoot;
@@ -141,6 +145,9 @@ namespace OpenSim.Region.Environment.Scenes
this.CreateFromShape(ownerID, localID, pos, shape);
this.Rotation = Axiom.Math.Quaternion.Identity;
m_parcelManager.setPrimsTainted();
}
/// <summary>
@@ -149,11 +156,19 @@ namespace OpenSim.Region.Environment.Scenes
/// <remarks>Empty constructor for duplication</remarks>
public Primitive()
{
m_parcelManager.setPrimsTainted();
}
#endregion
#region Destructors
~Primitive()
{
m_parcelManager.setPrimsTainted();
}
#endregion
#region Duplication
public Primitive Copy(EntityBase parent, SceneObject rootParent)
@@ -260,6 +275,8 @@ namespace OpenSim.Region.Environment.Scenes
this.m_world.DeleteEntity(linkObject.rootUUID);
linkObject.DeleteAllChildren();
m_parcelManager.setPrimsTainted();
}
/// <summary>
@@ -335,6 +352,7 @@ namespace OpenSim.Region.Environment.Scenes
prim.m_pos += offset;
prim.updateFlag = 2;
}
m_parcelManager.setPrimsTainted();
}
/// <summary>
@@ -385,6 +403,8 @@ namespace OpenSim.Region.Environment.Scenes
this.Pos = newPos;
this.updateFlag = 2;
m_parcelManager.setPrimsTainted();
}
/// <summary>
@@ -419,6 +439,8 @@ namespace OpenSim.Region.Environment.Scenes
this.m_pos = newPos;
this.updateFlag = 2;
}
m_parcelManager.setPrimsTainted();
}
#endregion

View File

@@ -59,6 +59,7 @@ namespace OpenSim.Region.Environment.Scenes
private uint _primCount = 702000;
private System.Threading.Mutex _primAllocateMutex = new Mutex(false);
private int storageCount;
private int parcelPrimCheckCount;
private Mutex updateLock;
protected AuthenticateSessionsBase authenticateHandler;
@@ -144,6 +145,8 @@ namespace OpenSim.Region.Environment.Scenes
Terrain = new TerrainEngine();
ScenePresence.LoadAnims();
this.performParcelPrimCountUpdate();
this.httpListener = httpServer;
}
#endregion
@@ -211,6 +214,18 @@ namespace OpenSim.Region.Environment.Scenes
this.Backup();
storageCount = 0;
}
this.parcelPrimCheckCount++;
if (this.parcelPrimCheckCount > 50) //check every 5 seconds for tainted prims
{
if (m_parcelManager.parcelPrimCountTainted)
{
//Perform parcel update of prim count
performParcelPrimCountUpdate();
this.parcelPrimCheckCount = 0;
}
}
}
catch (Exception e)
{
@@ -441,7 +456,7 @@ namespace OpenSim.Region.Environment.Scenes
{
try
{
SceneObject sceneOb = new SceneObject(m_regionHandle, this, ownerID, this.PrimIDAllocate(), pos, shape);
SceneObject sceneOb = new SceneObject(m_regionHandle, this, this.m_eventManager,this.m_parcelManager, ownerID, this.PrimIDAllocate(), pos, shape);
this.Entities.Add(sceneOb.rootUUID, sceneOb);
// Trigger event for listeners
@@ -809,6 +824,12 @@ namespace OpenSim.Region.Environment.Scenes
return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position);
}
public void performParcelPrimCountUpdate()
{
m_parcelManager.resetAllParcelPrimCounts();
m_eventManager.TriggerParcelPrimCountUpdate();
m_parcelManager.parcelPrimCountTainted = false;
}
#endregion
}

View File

@@ -19,6 +19,9 @@ namespace OpenSim.Region.Environment.Scenes
public delegate void OnRemovePresenceDelegate(LLUUID uuid);
public event OnRemovePresenceDelegate OnRemovePresence;
public delegate void OnParcelPrimCountUpdateDelegate();
public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate;
public void TriggerOnFrame()
{
if (OnFrame != null)
@@ -48,5 +51,13 @@ namespace OpenSim.Region.Environment.Scenes
OnBackup(dstore);
}
}
public void TriggerParcelPrimCountUpdate()
{
if (OnParcelPrimCountUpdate != null)
{
OnParcelPrimCountUpdate();
}
}
}
}

View File

@@ -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,27 +68,29 @@ namespace OpenSim.Region.Environment.Scenes
}
}
/// <summary>
///
/// </summary>
public SceneObject(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
public int primCount
{
m_regionHandle = regionHandle;
m_world = world;
this.Pos = pos;
this.CreateRootFromShape(ownerID, localID, shape, pos);
// Setup a backup event listener
world.EventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup);
get
{
return this.ChildPrimitives.Count;
}
}
/// <summary>
/// Processes backup
///
/// </summary>
/// <param name="datastore"></param>
void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore)
public SceneObject(ulong regionHandle, Scene world, EventManager eventManager, ParcelManager parcelManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
{
datastore.StoreObject(this);
m_regionHandle = regionHandle;
m_world = world;
m_eventManager = eventManager;
m_parcelManager = parcelManager;
this.Pos = pos;
this.CreateRootFromShape(ownerID, localID, shape, pos);
registerEvents();
}
/// <summary>
@@ -94,9 +99,40 @@ namespace OpenSim.Region.Environment.Scenes
/// <remarks>Need a null constructor for duplication</remarks>
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);
}
/// <summary>
/// Processes backup
/// </summary>
/// <param name="datastore"></param>
public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore)
{
datastore.StoreObject(this);
}
/// <summary>
/// Sends my primitive info to the parcel manager for it to keep tally of all of the prims!
/// </summary>
private void ProcessParcelPrimCountUpdate()
{
m_parcelManager.addPrimToParcelCounts(this);
}
/// <summary>
///
/// </summary>
@@ -105,7 +141,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="localID"></param>
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
}
/// <summary>
///
/// Copies a prim or group of prims (SceneObject) -- TODO: cleanup code
/// </summary>
/// <returns>A complete copy of the object</returns>
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();
}
/// <summary>
@@ -256,5 +295,6 @@ namespace OpenSim.Region.Environment.Scenes
client.OutPacket(proper);
}
}
}