narrange to do basic cleanup of the CMS module

0.6.0-stable
Sean Dague 2008-09-03 18:11:44 +00:00
parent eee0fa73e0
commit af5c7e52b1
14 changed files with 2597 additions and 2261 deletions

View File

@ -1,114 +1,136 @@
#region Header
// AuraMetaEntity.cs created with MonoDevelop // AuraMetaEntity.cs created with MonoDevelop
// User: bongiojp at 3:03 PM 8/6/2008 // User: bongiojp at 3:03 PM 8/6/2008
// //
// To change standard headers go to Edit->Preferences->Coding->Standard Headers // To change standard headers go to Edit->Preferences->Coding->Standard Headers
// //
#endregion Header
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public class AuraMetaEntity : PointMetaEntity
{
#region Constructors
//transparency of root part, NOT particle system. Should probably add support for changing particle system transparency.
public AuraMetaEntity(Scene scene, uint LocalId, LLVector3 groupPos, float transparency, LLVector3 color, LLVector3 scale)
: base(scene, LocalId, groupPos, transparency)
{
SetAura(color, scale);
}
public class AuraMetaEntity : PointMetaEntity public AuraMetaEntity(Scene scene, LLUUID uuid, uint LocalId, LLVector3 groupPos, float transparency, LLVector3 color, LLVector3 scale)
{ : base(scene, uuid, LocalId, groupPos, transparency)
//transparency of root part, NOT particle system. Should probably add support for changing particle system transparency. {
public AuraMetaEntity(Scene scene, uint LocalId, LLVector3 groupPos, float transparency, LLVector3 color, LLVector3 scale) : base(scene, LocalId, groupPos, transparency) SetAura(color, scale);
{ }
SetAura(color, scale);
}
public AuraMetaEntity(Scene scene, LLUUID uuid, uint LocalId, LLVector3 groupPos, float transparency, LLVector3 color, LLVector3 scale) : base(scene, uuid, LocalId, groupPos, transparency) #endregion Constructors
{
SetAura(color, scale);
}
private float Average(LLVector3 values) #region Private Methods
{
return (values.X + values.Y + values.Z)/3f;
}
public void SetAura(LLVector3 color, LLVector3 scale) private float Average(LLVector3 values)
{ {
SetAura(color, Average(scale) * 2.0f); return (values.X + values.Y + values.Z)/3f;
} }
public void SetAura(LLVector3 color, float radius) #endregion Private Methods
{
SceneObjectPart From = m_Entity.RootPart;
//m_log.Debug("[META ENTITY] BEFORE: radius = " + radius); #region Public Methods
float burstRadius = 0.1f;
Primitive.ParticleSystem.SourcePattern patternFlags = Primitive.ParticleSystem.SourcePattern.None; public void SetAura(LLVector3 color, LLVector3 scale)
float age = 1.5f; {
float burstRate = 0.4f; SetAura(color, Average(scale) * 2.0f);
if (radius >= 8.0f) }
{
//float sizeOfObject = radius / 2.0f; public void SetAura(LLVector3 color, float radius)
burstRadius = (radius - 8.0f)/3f; {
burstRate = 1.5f; SceneObjectPart From = m_Entity.RootPart;
radius = 7.99f;
patternFlags = Primitive.ParticleSystem.SourcePattern.Explode; //m_log.Debug("[META ENTITY] BEFORE: radius = " + radius);
age = 4.0f; float burstRadius = 0.1f;
} Primitive.ParticleSystem.SourcePattern patternFlags = Primitive.ParticleSystem.SourcePattern.None;
SetAura(From, color, radius, burstRadius, age, burstRate, patternFlags); float age = 1.5f;
} float burstRate = 0.4f;
public void SetAura(SceneObjectPart From, LLVector3 color, float radius, float burstRadius, float age, float burstRate, libsecondlife.Primitive.ParticleSystem.SourcePattern patternFlags) if (radius >= 8.0f)
{ {
Primitive.ParticleSystem prules = new Primitive.ParticleSystem(); //float sizeOfObject = radius / 2.0f;
//prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Emissive | burstRadius = (radius - 8.0f)/3f;
// Primitive.ParticleSystem.ParticleDataFlags.FollowSrc; //PSYS_PART_FLAGS burstRate = 1.5f;
//prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Beam | radius = 7.99f;
// Primitive.ParticleSystem.ParticleDataFlags.TargetPos; patternFlags = Primitive.ParticleSystem.SourcePattern.Explode;
prules.PartStartColor.R = color.X; //PSYS_PART_START_COLOR age = 4.0f;
prules.PartStartColor.G = color.Y; }
prules.PartStartColor.B = color.Z; SetAura(From, color, radius, burstRadius, age, burstRate, patternFlags);
prules.PartStartColor.A = 0.5f; //PSYS_PART_START_ALPHA, transparency }
prules.PartEndColor.R = color.X; //PSYS_PART_END_COLOR
prules.PartEndColor.G = color.Y; public void SetAura(SceneObjectPart From, LLVector3 color, float radius, float burstRadius, float age, float burstRate, libsecondlife.Primitive.ParticleSystem.SourcePattern patternFlags)
prules.PartEndColor.B = color.Z; {
prules.PartEndColor.A = 0.5f; //PSYS_PART_END_ALPHA, transparency Primitive.ParticleSystem prules = new Primitive.ParticleSystem();
/*prules.PartStartScaleX = 0.5f; //PSYS_PART_START_SCALE //prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Emissive |
prules.PartStartScaleY = 0.5f; // Primitive.ParticleSystem.ParticleDataFlags.FollowSrc; //PSYS_PART_FLAGS
prules.PartEndScaleX = 0.5f; //PSYS_PART_END_SCALE //prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Beam |
prules.PartEndScaleY = 0.5f; // Primitive.ParticleSystem.ParticleDataFlags.TargetPos;
*/ prules.PartStartColor.R = color.X; //PSYS_PART_START_COLOR
prules.PartStartScaleX = radius; //PSYS_PART_START_SCALE prules.PartStartColor.G = color.Y;
prules.PartStartScaleY = radius; prules.PartStartColor.B = color.Z;
prules.PartEndScaleX = radius; //PSYS_PART_END_SCALE prules.PartStartColor.A = 0.5f; //PSYS_PART_START_ALPHA, transparency
prules.PartEndScaleY = radius; prules.PartEndColor.R = color.X; //PSYS_PART_END_COLOR
prules.PartMaxAge = age; //PSYS_PART_MAX_AGE prules.PartEndColor.G = color.Y;
prules.PartAcceleration.X = 0.0f; //PSYS_SRC_ACCEL prules.PartEndColor.B = color.Z;
prules.PartAcceleration.Y = 0.0f; prules.PartEndColor.A = 0.5f; //PSYS_PART_END_ALPHA, transparency
prules.PartAcceleration.Z = 0.0f; /*prules.PartStartScaleX = 0.5f; //PSYS_PART_START_SCALE
prules.Pattern = patternFlags; //PSYS_SRC_PATTERN prules.PartStartScaleY = 0.5f;
//prules.Texture = LLUUID.Zero;//= LLUUID //PSYS_SRC_TEXTURE, default used if blank prules.PartEndScaleX = 0.5f; //PSYS_PART_END_SCALE
prules.BurstRate = burstRate; //PSYS_SRC_BURST_RATE prules.PartEndScaleY = 0.5f;
prules.BurstPartCount = 2; //PSYS_SRC_BURST_PART_COUNT */
//prules.BurstRadius = radius; //PSYS_SRC_BURST_RADIUS prules.PartStartScaleX = radius; //PSYS_PART_START_SCALE
prules.BurstRadius = burstRadius; //PSYS_SRC_BURST_RADIUS prules.PartStartScaleY = radius;
prules.BurstSpeedMin = 0.001f; //PSYS_SRC_BURST_SPEED_MIN prules.PartEndScaleX = radius; //PSYS_PART_END_SCALE
prules.PartEndScaleY = radius;
prules.PartMaxAge = age; //PSYS_PART_MAX_AGE
prules.PartAcceleration.X = 0.0f; //PSYS_SRC_ACCEL
prules.PartAcceleration.Y = 0.0f;
prules.PartAcceleration.Z = 0.0f;
prules.Pattern = patternFlags; //PSYS_SRC_PATTERN
//prules.Texture = LLUUID.Zero;//= LLUUID //PSYS_SRC_TEXTURE, default used if blank
prules.BurstRate = burstRate; //PSYS_SRC_BURST_RATE
prules.BurstPartCount = 2; //PSYS_SRC_BURST_PART_COUNT
//prules.BurstRadius = radius; //PSYS_SRC_BURST_RADIUS
prules.BurstRadius = burstRadius; //PSYS_SRC_BURST_RADIUS
prules.BurstSpeedMin = 0.001f; //PSYS_SRC_BURST_SPEED_MIN
prules.BurstSpeedMax = 0.001f; //PSYS_SRC_BURST_SPEED_MAX prules.BurstSpeedMax = 0.001f; //PSYS_SRC_BURST_SPEED_MAX
prules.MaxAge = 0.0f; //PSYS_SRC_MAX_AGE prules.MaxAge = 0.0f; //PSYS_SRC_MAX_AGE
//prules.Target = To; //PSYS_SRC_TARGET_KEY //prules.Target = To; //PSYS_SRC_TARGET_KEY
prules.AngularVelocity.X = 0.0f; //PSYS_SRC_OMEGA prules.AngularVelocity.X = 0.0f; //PSYS_SRC_OMEGA
prules.AngularVelocity.Y = 0.0f; prules.AngularVelocity.Y = 0.0f;
prules.AngularVelocity.Z = 0.0f; prules.AngularVelocity.Z = 0.0f;
prules.InnerAngle = 0.0f; //PSYS_SRC_ANGLE_BEGIN prules.InnerAngle = 0.0f; //PSYS_SRC_ANGLE_BEGIN
prules.OuterAngle = 0.0f; //PSYS_SRC_ANGLE_END prules.OuterAngle = 0.0f; //PSYS_SRC_ANGLE_END
prules.CRC = 1; //activates the particle system?? prules.CRC = 1; //activates the particle system??
From.AddNewParticleSystem(prules); From.AddNewParticleSystem(prules);
} }
}
#endregion Public Methods
}
} }

View File

@ -1,98 +1,114 @@
#region Header
// BeamMetaEntity.cs created with MonoDevelop // BeamMetaEntity.cs created with MonoDevelop
// User: bongiojp at 3:03 PM 8/6/2008 // User: bongiojp at 3:03 PM 8/6/2008
// //
// To change standard headers go to Edit->Preferences->Coding->Standard Headers // To change standard headers go to Edit->Preferences->Coding->Standard Headers
// //
#endregion Header
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public class BeamMetaEntity : PointMetaEntity
{
#region Constructors
public BeamMetaEntity(Scene scene, uint LocalId, LLVector3 groupPos, float transparency, SceneObjectPart To, LLVector3 color)
: base(scene, LocalId, groupPos, transparency)
{
SetBeamToUUID(To, color);
}
public class BeamMetaEntity : PointMetaEntity public BeamMetaEntity(Scene scene, LLUUID uuid, uint LocalId, LLVector3 groupPos, float transparency, SceneObjectPart To, LLVector3 color)
{ : base(scene, uuid, LocalId, groupPos, transparency)
{
SetBeamToUUID(To, color);
}
public BeamMetaEntity(Scene scene, uint LocalId, LLVector3 groupPos, float transparency, SceneObjectPart To, LLVector3 color) : base(scene, LocalId, groupPos, transparency) #endregion Constructors
{
SetBeamToUUID(To, color);
}
public BeamMetaEntity(Scene scene, LLUUID uuid, uint LocalId, LLVector3 groupPos, float transparency, SceneObjectPart To, LLVector3 color) : base(scene, uuid, LocalId, groupPos, transparency) #region Public Methods
{
SetBeamToUUID(To, color);
}
public void SetBeamToUUID(SceneObjectPart To, LLVector3 color) public void SetBeamToUUID(SceneObjectPart To, LLVector3 color)
{ {
SceneObjectPart From = m_Entity.RootPart; SceneObjectPart From = m_Entity.RootPart;
//Scale size of particles to distance objects are apart (for better visibility) //Scale size of particles to distance objects are apart (for better visibility)
LLVector3 FromPos = From.GetWorldPosition(); LLVector3 FromPos = From.GetWorldPosition();
LLVector3 ToPos = From.GetWorldPosition(); LLVector3 ToPos = From.GetWorldPosition();
LLUUID toUUID = To.UUID; LLUUID toUUID = To.UUID;
float distance = (float) (Math.Sqrt(Math.Pow(FromPos.X-ToPos.X, 2) + float distance = (float) (Math.Sqrt(Math.Pow(FromPos.X-ToPos.X, 2) +
Math.Pow(FromPos.X-ToPos.Y, 2) + Math.Pow(FromPos.X-ToPos.Y, 2) +
Math.Pow(FromPos.X-ToPos.Z, 2) Math.Pow(FromPos.X-ToPos.Z, 2)
) )
); );
//float rate = (float) (distance/4f); //float rate = (float) (distance/4f);
float rate = 0.5f; float rate = 0.5f;
float scale = (float) (distance/128f); float scale = (float) (distance/128f);
float speed = (float) (2.0f - distance/128f); float speed = (float) (2.0f - distance/128f);
SetBeamToUUID(From, To, color, rate, scale, speed); SetBeamToUUID(From, To, color, rate, scale, speed);
} }
public void SetBeamToUUID(SceneObjectPart From, SceneObjectPart To, LLVector3 color, float rate, float scale, float speed) public void SetBeamToUUID(SceneObjectPart From, SceneObjectPart To, LLVector3 color, float rate, float scale, float speed)
{ {
Primitive.ParticleSystem prules = new Primitive.ParticleSystem(); Primitive.ParticleSystem prules = new Primitive.ParticleSystem();
//prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Emissive | //prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Emissive |
// Primitive.ParticleSystem.ParticleDataFlags.FollowSrc; //PSYS_PART_FLAGS // Primitive.ParticleSystem.ParticleDataFlags.FollowSrc; //PSYS_PART_FLAGS
prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Beam | prules.PartDataFlags = Primitive.ParticleSystem.ParticleDataFlags.Beam |
Primitive.ParticleSystem.ParticleDataFlags.TargetPos; Primitive.ParticleSystem.ParticleDataFlags.TargetPos;
prules.PartStartColor.R = color.X; //PSYS_PART_START_COLOR prules.PartStartColor.R = color.X; //PSYS_PART_START_COLOR
prules.PartStartColor.G = color.Y; prules.PartStartColor.G = color.Y;
prules.PartStartColor.B = color.Z; prules.PartStartColor.B = color.Z;
prules.PartStartColor.A = 1.0f; //PSYS_PART_START_ALPHA, transparency prules.PartStartColor.A = 1.0f; //PSYS_PART_START_ALPHA, transparency
prules.PartEndColor.R = color.X; //PSYS_PART_END_COLOR prules.PartEndColor.R = color.X; //PSYS_PART_END_COLOR
prules.PartEndColor.G = color.Y; prules.PartEndColor.G = color.Y;
prules.PartEndColor.B = color.Z; prules.PartEndColor.B = color.Z;
prules.PartEndColor.A = 1.0f; //PSYS_PART_END_ALPHA, transparency prules.PartEndColor.A = 1.0f; //PSYS_PART_END_ALPHA, transparency
prules.PartStartScaleX = scale; //PSYS_PART_START_SCALE prules.PartStartScaleX = scale; //PSYS_PART_START_SCALE
prules.PartStartScaleY = scale; prules.PartStartScaleY = scale;
prules.PartEndScaleX = scale; //PSYS_PART_END_SCALE prules.PartEndScaleX = scale; //PSYS_PART_END_SCALE
prules.PartEndScaleY = scale; prules.PartEndScaleY = scale;
prules.PartMaxAge = 1.0f; //PSYS_PART_MAX_AGE prules.PartMaxAge = 1.0f; //PSYS_PART_MAX_AGE
prules.PartAcceleration.X = 0.0f; //PSYS_SRC_ACCEL prules.PartAcceleration.X = 0.0f; //PSYS_SRC_ACCEL
prules.PartAcceleration.Y = 0.0f; prules.PartAcceleration.Y = 0.0f;
prules.PartAcceleration.Z = 0.0f; prules.PartAcceleration.Z = 0.0f;
//prules.Pattern = Primitive.ParticleSystem.SourcePattern.Explode; //PSYS_SRC_PATTERN //prules.Pattern = Primitive.ParticleSystem.SourcePattern.Explode; //PSYS_SRC_PATTERN
//prules.Texture = LLUUID.Zero;//= LLUUID //PSYS_SRC_TEXTURE, default used if blank //prules.Texture = LLUUID.Zero;//= LLUUID //PSYS_SRC_TEXTURE, default used if blank
prules.BurstRate = rate; //PSYS_SRC_BURST_RATE prules.BurstRate = rate; //PSYS_SRC_BURST_RATE
prules.BurstPartCount = 1; //PSYS_SRC_BURST_PART_COUNT prules.BurstPartCount = 1; //PSYS_SRC_BURST_PART_COUNT
prules.BurstRadius = 0.5f; //PSYS_SRC_BURST_RADIUS prules.BurstRadius = 0.5f; //PSYS_SRC_BURST_RADIUS
prules.BurstSpeedMin = speed; //PSYS_SRC_BURST_SPEED_MIN prules.BurstSpeedMin = speed; //PSYS_SRC_BURST_SPEED_MIN
prules.BurstSpeedMax = speed; //PSYS_SRC_BURST_SPEED_MAX prules.BurstSpeedMax = speed; //PSYS_SRC_BURST_SPEED_MAX
prules.MaxAge = 0.0f; //PSYS_SRC_MAX_AGE prules.MaxAge = 0.0f; //PSYS_SRC_MAX_AGE
prules.Target = To.UUID; //PSYS_SRC_TARGET_KEY prules.Target = To.UUID; //PSYS_SRC_TARGET_KEY
prules.AngularVelocity.X = 0.0f; //PSYS_SRC_OMEGA prules.AngularVelocity.X = 0.0f; //PSYS_SRC_OMEGA
prules.AngularVelocity.Y = 0.0f; prules.AngularVelocity.Y = 0.0f;
prules.AngularVelocity.Z = 0.0f; prules.AngularVelocity.Z = 0.0f;
prules.InnerAngle = 0.0f; //PSYS_SRC_ANGLE_BEGIN prules.InnerAngle = 0.0f; //PSYS_SRC_ANGLE_BEGIN
prules.OuterAngle = 0.0f; //PSYS_SRC_ANGLE_END prules.OuterAngle = 0.0f; //PSYS_SRC_ANGLE_END
prules.CRC = 1; //activates the particle system?? prules.CRC = 1; //activates the particle system??
From.AddNewParticleSystem(prules); From.AddNewParticleSystem(prules);
} }
}
#endregion Public Methods
}
} }

View File

@ -1,148 +1,169 @@
#region Header
// CMEntityCollection.cs created with MonoDevelop // CMEntityCollection.cs created with MonoDevelop
// User: bongiojp at 10:09 AM 7/7/2008 // User: bongiojp at 10:09 AM 7/7/2008
// //
// Creates, Deletes, Stores ContentManagementEntities // Creates, Deletes, Stores ContentManagementEntities
// //
#endregion Header
using System; using System;
using System.Collections.Generic;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Threading;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim; using OpenSim;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
using System.Threading;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public class CMEntityCollection
{
#region Fields
public class CMEntityCollection // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
{ // Any ContentManagementEntities that represent old versions of current SceneObjectGroups or
// private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // old versions of deleted SceneObjectGroups will be stored in this hash table.
// The LLUUID keys are from the SceneObjectGroup RootPart UUIDs
protected Hashtable m_CMEntityHash = Hashtable.Synchronized(new Hashtable()); //LLUUID to ContentManagementEntity
// Any ContentManagementEntities that represent old versions of current SceneObjectGroups or // SceneObjectParts that have not been revisioned will be given green auras stored in this hashtable
// old versions of deleted SceneObjectGroups will be stored in this hash table. // The LLUUID keys are from the SceneObjectPart that they are supposed to be on.
// The LLUUID keys are from the SceneObjectGroup RootPart UUIDs protected Hashtable m_NewlyCreatedEntityAura = Hashtable.Synchronized(new Hashtable()); //LLUUID to AuraMetaEntity
protected Hashtable m_CMEntityHash = Hashtable.Synchronized(new Hashtable()); //LLUUID to ContentManagementEntity
// SceneObjectParts that have not been revisioned will be given green auras stored in this hashtable #endregion Fields
// The LLUUID keys are from the SceneObjectPart that they are supposed to be on.
protected Hashtable m_NewlyCreatedEntityAura = Hashtable.Synchronized(new Hashtable()); //LLUUID to AuraMetaEntity
public Hashtable Entities #region Constructors
{
get { return m_CMEntityHash; }
}
public Hashtable Auras public CMEntityCollection()
{ {
get {return m_NewlyCreatedEntityAura; } }
}
public CMEntityCollection() #endregion Constructors
{}
public bool AddAura(ContentManagementEntity aura) #region Public Properties
{
if (m_NewlyCreatedEntityAura.ContainsKey(aura.UUID))
return false;
m_NewlyCreatedEntityAura.Add(aura.UUID, aura);
return true;
}
public bool AddEntity(ContentManagementEntity ent) public Hashtable Auras
{ {
if (m_CMEntityHash.ContainsKey(ent.UUID)) get {return m_NewlyCreatedEntityAura; }
return false; }
m_CMEntityHash.Add(ent.UUID, ent);
return true;
}
public bool RemoveNewlyCreatedEntityAura(LLUUID uuid) public Hashtable Entities
{ {
if (!m_NewlyCreatedEntityAura.ContainsKey(uuid)) get { return m_CMEntityHash; }
return false; }
m_NewlyCreatedEntityAura.Remove(uuid);
return true;
}
public bool RemoveEntity(LLUUID uuid) #endregion Public Properties
{
if (!m_CMEntityHash.ContainsKey(uuid))
return false;
m_CMEntityHash.Remove(uuid);
return true;
}
public void ClearAll() #region Public Methods
{
m_CMEntityHash.Clear();
m_NewlyCreatedEntityAura.Clear();
}
public bool AddAura(ContentManagementEntity aura)
{
if (m_NewlyCreatedEntityAura.ContainsKey(aura.UUID))
return false;
m_NewlyCreatedEntityAura.Add(aura.UUID, aura);
return true;
}
public bool AddEntity(ContentManagementEntity ent)
{
if (m_CMEntityHash.ContainsKey(ent.UUID))
return false;
m_CMEntityHash.Add(ent.UUID, ent);
return true;
}
// Old uuid and new sceneobjectgroup // Check if there are SceneObjectGroups in the list that do not have corresponding ContentManagementGroups in the CMEntityHash
public AuraMetaEntity CreateAuraForNewlyCreatedEntity(SceneObjectPart part) public System.Collections.ArrayList CheckForMissingEntities(System.Collections.Generic.List<EntityBase> currList)
{ {
AuraMetaEntity ent = new AuraMetaEntity(part.ParentGroup.Scene, System.Collections.ArrayList missingList = new System.Collections.ArrayList();
part.ParentGroup.Scene.PrimIDAllocate(), SceneObjectGroup temp = null;
part.GetWorldPosition(), foreach( EntityBase currObj in currList )
MetaEntity.TRANSLUCENT, {
new LLVector3(0,254,0), if (! (currObj is SceneObjectGroup))
part.Scale continue;
); temp = (SceneObjectGroup) currObj;
m_NewlyCreatedEntityAura.Add(part.UUID, ent);
return ent;
}
// Old uuid and new sceneobjectgroup if (m_CMEntityHash.ContainsKey(temp.UUID))
public ContentManagementEntity CreateNewEntity(SceneObjectGroup group) {
{ foreach(SceneObjectPart part in temp.Children.Values)
ContentManagementEntity ent = new ContentManagementEntity(group, false); if (!((ContentManagementEntity)m_CMEntityHash[temp.UUID]).HasChildPrim(part.UUID))
m_CMEntityHash.Add(group.UUID, ent); missingList.Add(part);
return ent; }
} else //Entire group is missing from revision. (and is a new part in region)
{
foreach(SceneObjectPart part in temp.Children.Values)
missingList.Add(part);
}
}
return missingList;
}
public ContentManagementEntity CreateNewEntity(String xml, Scene scene) public void ClearAll()
{ {
ContentManagementEntity ent = new ContentManagementEntity(xml, scene, false); m_CMEntityHash.Clear();
if (ent == null) m_NewlyCreatedEntityAura.Clear();
return null; }
m_CMEntityHash.Add(ent.UnchangedEntity.UUID, ent);
return ent;
}
// Check if there are SceneObjectGroups in the list that do not have corresponding ContentManagementGroups in the CMEntityHash // Old uuid and new sceneobjectgroup
public System.Collections.ArrayList CheckForMissingEntities(System.Collections.Generic.List<EntityBase> currList) public AuraMetaEntity CreateAuraForNewlyCreatedEntity(SceneObjectPart part)
{ {
System.Collections.ArrayList missingList = new System.Collections.ArrayList(); AuraMetaEntity ent = new AuraMetaEntity(part.ParentGroup.Scene,
SceneObjectGroup temp = null; part.ParentGroup.Scene.PrimIDAllocate(),
foreach( EntityBase currObj in currList ) part.GetWorldPosition(),
{ MetaEntity.TRANSLUCENT,
if (! (currObj is SceneObjectGroup)) new LLVector3(0,254,0),
continue; part.Scale
temp = (SceneObjectGroup) currObj; );
m_NewlyCreatedEntityAura.Add(part.UUID, ent);
return ent;
}
if (m_CMEntityHash.ContainsKey(temp.UUID)) // Old uuid and new sceneobjectgroup
{ public ContentManagementEntity CreateNewEntity(SceneObjectGroup group)
foreach(SceneObjectPart part in temp.Children.Values) {
if (!((ContentManagementEntity)m_CMEntityHash[temp.UUID]).HasChildPrim(part.UUID)) ContentManagementEntity ent = new ContentManagementEntity(group, false);
missingList.Add(part); m_CMEntityHash.Add(group.UUID, ent);
} return ent;
else //Entire group is missing from revision. (and is a new part in region) }
{
foreach(SceneObjectPart part in temp.Children.Values) public ContentManagementEntity CreateNewEntity(String xml, Scene scene)
missingList.Add(part); {
} ContentManagementEntity ent = new ContentManagementEntity(xml, scene, false);
} if (ent == null)
return missingList; return null;
} m_CMEntityHash.Add(ent.UnchangedEntity.UUID, ent);
} return ent;
}
public bool RemoveEntity(LLUUID uuid)
{
if (!m_CMEntityHash.ContainsKey(uuid))
return false;
m_CMEntityHash.Remove(uuid);
return true;
}
public bool RemoveNewlyCreatedEntityAura(LLUUID uuid)
{
if (!m_NewlyCreatedEntityAura.ContainsKey(uuid))
return false;
m_NewlyCreatedEntityAura.Remove(uuid);
return true;
}
#endregion Public Methods
}
} }

View File

@ -1,45 +1,126 @@
#region Header
// CMModel.cs // CMModel.cs
// User: bongiojp // User: bongiojp
// //
// //
#endregion Header
using System; using System;
using System.Collections.Generic;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using libsecondlife; using libsecondlife;
using OpenSim; using OpenSim;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
using System.Diagnostics;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public class CMModel public class CMModel
{ {
#region Static Fields
static float TimeToUpdate = 0; static float TimeToUpdate = 0;
static float TimeToConvertXml = 0; static float TimeToConvertXml = 0;
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
IContentDatabase m_database = null; #endregion Static Fields
#region Fields
/// <value> /// <value>
/// The class that contains all auras and metaentities used in the CMS. /// The class that contains all auras and metaentities used in the CMS.
/// </value> /// </value>
CMEntityCollection m_MetaEntityCollection = new CMEntityCollection(); CMEntityCollection m_MetaEntityCollection = new CMEntityCollection();
IContentDatabase m_database = null;
#endregion Fields
#region Constructors
public CMModel()
{
}
#endregion Constructors
#region Public Properties
public CMEntityCollection MetaEntityCollection public CMEntityCollection MetaEntityCollection
{ {
get { return m_MetaEntityCollection; } get { return m_MetaEntityCollection; }
} }
public CMModel() #endregion Public Properties
#region Public Methods
/// <summary>
/// Compares the scene's object group list to the list of meta entities. If there is an object group that does not have a corresponding meta entity
/// it is a new part that must have a green aura (for diff mode).
/// Returns list of ContentManagementEntities
/// </summary>
public ArrayList CheckForNewEntitiesMissingAuras(Scene scene)
{ {
ArrayList missingList = null;
ArrayList newList = new ArrayList();
m_log.Debug("[CONTENT MANAGEMENT] Checking for new scene object parts in scene: " + scene.RegionInfo.RegionName);
//Check if the current scene has groups not included in the current list of MetaEntities
//If so, then the current scene's parts that are new should be marked green.
missingList = m_MetaEntityCollection.CheckForMissingEntities(scene.GetEntities());
foreach(Object missingPart in missingList)
{
if (m_MetaEntityCollection.Auras.ContainsKey(((SceneObjectPart)missingPart).UUID))
continue;
newList.Add(m_MetaEntityCollection.CreateAuraForNewlyCreatedEntity((SceneObjectPart)missingPart));
}
m_log.Info("Number of missing objects found: " + newList.Count);
return newList;
}
/// <summary>
/// Uses the database to serialize all current scene objects into xml and save into a database with an accompanying log message.
/// </summary>
public void CommitRegion(Scene scene, String logMessage)
{
m_log.Debug("[CONTENT MANAG] saving " + scene.RegionInfo.RegionName + " with log message: " + logMessage + " length of message: " + logMessage.Length);
m_database.SaveRegion(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, logMessage);
m_log.Debug("[CONTENT MANAG] the region name we are dealing with heeeeeeeere: " + scene.RegionInfo.RegionName );
}
public void DeleteAllMetaObjects()
{
m_MetaEntityCollection.ClearAll();
}
public ContentManagementEntity FindMetaEntityAffectedByUndo(LLUUID uuid)
{
ContentManagementEntity ent = GetMetaGroupByPrim(uuid);
return ent;
}
//-------------------------------- HELPERS --------------------------------------------------------------------//
public ContentManagementEntity GetMetaGroupByPrim(LLUUID uuid)
{
foreach (Object ent in m_MetaEntityCollection.Entities.Values)
{
if (((ContentManagementEntity)ent).HasChildPrim(uuid))
return (ContentManagementEntity)ent;
}
return null;
} }
public void Initialise(string database) public void Initialise(string database)
@ -63,12 +144,6 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
m_database.PostInitialise(); m_database.PostInitialise();
} }
public ContentManagementEntity FindMetaEntityAffectedByUndo(LLUUID uuid)
{
ContentManagementEntity ent = GetMetaGroupByPrim(uuid);
return ent;
}
/// <summary> /// <summary>
/// Removes the green aura when an a new scene object group is deleted. /// Removes the green aura when an a new scene object group is deleted.
/// </summary> /// </summary>
@ -80,16 +155,6 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
m_MetaEntityCollection.RemoveNewlyCreatedEntityAura(part.UUID); m_MetaEntityCollection.RemoveNewlyCreatedEntityAura(part.UUID);
} }
/// <summary>
/// Uses the database to serialize all current scene objects into xml and save into a database with an accompanying log message.
/// </summary>
public void CommitRegion(Scene scene, String logMessage)
{
m_log.Debug("[CONTENT MANAG] saving " + scene.RegionInfo.RegionName + " with log message: " + logMessage + " length of message: " + logMessage.Length);
m_database.SaveRegion(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, logMessage);
m_log.Debug("[CONTENT MANAG] the region name we are dealing with heeeeeeeere: " + scene.RegionInfo.RegionName );
}
/// <summary> /// <summary>
/// Retrieves the latest revision of a region in xml form, /// Retrieves the latest revision of a region in xml form,
/// converts it to scene object groups and scene presences, /// converts it to scene object groups and scene presences,
@ -207,32 +272,6 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
scene.Backup(); scene.Backup();
} }
/// <summary>
/// Detects if a scene object group from the scene list has moved or changed scale. The green aura
/// that surrounds the object is then moved or scaled with the group.
/// </summary>
public System.Collections.ArrayList UpdateNormalEntityEffects(SceneObjectGroup group)
{
System.Collections.ArrayList auraList = new System.Collections.ArrayList();
if (group == null)
return null;
foreach(SceneObjectPart part in group.Children.Values)
{
if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID))
{
((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).SetAura(new LLVector3(0,254,0), part.Scale);
((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).RootPart.GroupPosition = part.GetWorldPosition();
auraList.Add((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]);
}
}
return auraList;
}
public void DeleteAllMetaObjects()
{
m_MetaEntityCollection.ClearAll();
}
/// <summary> /// <summary>
/// Downloads the latest revision of the given scene and converts the xml file to CMEntities. After this method, the view can find the differences /// Downloads the latest revision of the given scene and converts the xml file to CMEntities. After this method, the view can find the differences
/// and display the differences to clients. /// and display the differences to clients.
@ -265,45 +304,29 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
TimeToUpdate += x.ElapsedMilliseconds; TimeToUpdate += x.ElapsedMilliseconds;
m_log.Info("[FileSystemDatabase] Time spent Updating entity list for " + scene.RegionInfo.RegionName + ": " + x.ElapsedMilliseconds); m_log.Info("[FileSystemDatabase] Time spent Updating entity list for " + scene.RegionInfo.RegionName + ": " + x.ElapsedMilliseconds);
m_log.Info("[FileSystemDatabase] Time spent Updating so far: " + TimeToUpdate); m_log.Info("[FileSystemDatabase] Time spent Updating so far: " + TimeToUpdate);
} }
/// <summary> /// <summary>
/// Compares the scene's object group list to the list of meta entities. If there is an object group that does not have a corresponding meta entity /// Detects if a scene object group from the scene list has moved or changed scale. The green aura
/// it is a new part that must have a green aura (for diff mode). /// that surrounds the object is then moved or scaled with the group.
/// Returns list of ContentManagementEntities
/// </summary> /// </summary>
public ArrayList CheckForNewEntitiesMissingAuras(Scene scene) public System.Collections.ArrayList UpdateNormalEntityEffects(SceneObjectGroup group)
{ {
ArrayList missingList = null; System.Collections.ArrayList auraList = new System.Collections.ArrayList();
ArrayList newList = new ArrayList(); if (group == null)
return null;
m_log.Debug("[CONTENT MANAGEMENT] Checking for new scene object parts in scene: " + scene.RegionInfo.RegionName); foreach(SceneObjectPart part in group.Children.Values)
//Check if the current scene has groups not included in the current list of MetaEntities
//If so, then the current scene's parts that are new should be marked green.
missingList = m_MetaEntityCollection.CheckForMissingEntities(scene.GetEntities());
foreach(Object missingPart in missingList)
{ {
if (m_MetaEntityCollection.Auras.ContainsKey(((SceneObjectPart)missingPart).UUID)) if (m_MetaEntityCollection.Auras.ContainsKey(part.UUID))
continue; {
newList.Add(m_MetaEntityCollection.CreateAuraForNewlyCreatedEntity((SceneObjectPart)missingPart)); ((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).SetAura(new LLVector3(0,254,0), part.Scale);
((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]).RootPart.GroupPosition = part.GetWorldPosition();
auraList.Add((AuraMetaEntity)m_MetaEntityCollection.Auras[part.UUID]);
}
} }
m_log.Info("Number of missing objects found: " + newList.Count); return auraList;
return newList;
} }
//-------------------------------- HELPERS --------------------------------------------------------------------// #endregion Public Methods
public ContentManagementEntity GetMetaGroupByPrim(LLUUID uuid)
{
foreach (Object ent in m_MetaEntityCollection.Entities.Values)
{
if (((ContentManagementEntity)ent).HasChildPrim(uuid))
return (ContentManagementEntity)ent;
}
return null;
}
} }
} }

View File

@ -1,156 +1,181 @@
#region Header
// CMView.cs created with MonoDevelop // CMView.cs created with MonoDevelop
// User: bongiojp at 11:57 AM 7/3/2008 // User: bongiojp at 11:57 AM 7/3/2008
// //
// To change standard headers go to Edit->Preferences->Coding->Standard Headers // To change standard headers go to Edit->Preferences->Coding->Standard Headers
// //
#endregion Header
using System; using System;
using System.Collections.Generic;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using OpenSim; using OpenSim;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public class CMView
{
#region Static Fields
public class CMView private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
CMModel m_model = null;
public CMView() #endregion Static Fields
{}
public void Initialise(CMModel model) #region Fields
{
m_model = model;
}
public void SendMetaEntitiesToNewClient(IClientAPI client) CMModel m_model = null;
{
}
/// <summary> #endregion Fields
/// update all clients of red/green/blue auras and meta entities that the model knows about.
/// </summary>
public void DisplayRecentChanges()
{
m_log.Debug("[CONTENT MANAGEMENT] Sending update to clients for " + m_model.MetaEntityCollection.Entities.Count + " objects.");
DisplayEntities(m_model.MetaEntityCollection);
DisplayAuras(m_model.MetaEntityCollection);
}
/// <summary> #region Constructors
/// Figures out if the part deleted was a new scene object part or a revisioned part that's been deleted.
/// If it's a new scene object, any green aura attached to it is deleted.
/// If a revisioned part is deleted, a new full update is sent to the environment of the meta entity, which will
/// figure out that there should be a red aura and not a blue aura/beam.
/// </summary>
public void RemoveOrUpdateDeletedEntity(SceneObjectGroup group)
{
// Deal with revisioned parts that have been deleted.
if (m_model.MetaEntityCollection.Entities.ContainsKey(group.UUID))
((ContentManagementEntity)m_model.MetaEntityCollection.Entities[group.UUID]).SendFullDiffUpdateToAll();
// Deal with new parts not revisioned that have been deleted. public CMView()
foreach(SceneObjectPart part in group.Children.Values) {
if (m_model.MetaEntityCollection.Auras.ContainsKey(part.UUID)) }
((AuraMetaEntity)m_model.MetaEntityCollection.Auras[part.UUID]).HideFromAll();
}
// Auras To #endregion Constructors
public void DisplayAuras(CMEntityCollection auraCollection)
{
foreach( Object ent in auraCollection.Auras.Values)
((AuraMetaEntity)ent).SendFullUpdateToAll();
}
// Entities to ALL #region Public Methods
public void DisplayEntities(CMEntityCollection entityCollection)
{
foreach( Object ent in entityCollection.Entities.Values)
((ContentManagementEntity)ent).SendFullDiffUpdateToAll();
}
// Auras To Client // Auras To
public void DisplayAuras(CMEntityCollection auraCollection, IClientAPI client) public void DisplayAuras(CMEntityCollection auraCollection)
{ {
foreach( Object ent in auraCollection.Auras.Values) foreach( Object ent in auraCollection.Auras.Values)
((AuraMetaEntity)ent).SendFullUpdate(client); ((AuraMetaEntity)ent).SendFullUpdateToAll();
} }
// Entities to Client // Auras To Client
public void DisplayEntities(CMEntityCollection entityCollection, IClientAPI client) public void DisplayAuras(CMEntityCollection auraCollection, IClientAPI client)
{ {
foreach( Object ent in entityCollection.Entities.Values) foreach( Object ent in auraCollection.Auras.Values)
((ContentManagementEntity)ent).SendFullDiffUpdate(client); ((AuraMetaEntity)ent).SendFullUpdate(client);
} }
// Entity to ALL // Auras from List To ALL
public void DisplayEntity(ContentManagementEntity ent) public void DisplayAuras(ArrayList list)
{ {
ent.SendFullDiffUpdateToAll(); foreach( Object ent in list)
} {
m_log.Debug("[CONTENT MANAGEMENT] displaying new aura riiiiiiiiiiiight NOW");
((AuraMetaEntity)ent).SendFullUpdateToAll();
}
}
public void DisplayMetaEntity(LLUUID uuid) // Entities to ALL
{ public void DisplayEntities(CMEntityCollection entityCollection)
ContentManagementEntity group = m_model.GetMetaGroupByPrim(uuid); {
if (group != null) foreach( Object ent in entityCollection.Entities.Values)
group.SendFullDiffUpdateToAll(); ((ContentManagementEntity)ent).SendFullDiffUpdateToAll();
} }
// Auras from List To ALL // Entities to Client
public void DisplayAuras(ArrayList list) public void DisplayEntities(CMEntityCollection entityCollection, IClientAPI client)
{ {
foreach( Object ent in list) foreach( Object ent in entityCollection.Entities.Values)
{ ((ContentManagementEntity)ent).SendFullDiffUpdate(client);
m_log.Debug("[CONTENT MANAGEMENT] displaying new aura riiiiiiiiiiiight NOW"); }
((AuraMetaEntity)ent).SendFullUpdateToAll();
}
}
// Entities from List to ALL // Entities from List to ALL
public void DisplayEntities(ArrayList list) public void DisplayEntities(ArrayList list)
{ {
foreach( Object ent in list) foreach( Object ent in list)
((ContentManagementEntity)ent).SendFullDiffUpdateToAll(); ((ContentManagementEntity)ent).SendFullDiffUpdateToAll();
} }
public void DisplayHelpMenu(Scene scene) // Entity to ALL
{ public void DisplayEntity(ContentManagementEntity ent)
string menu = "Menu:\n"; {
menu += "commit (ci) - saves current state of the region to a database on the server\n"; ent.SendFullDiffUpdateToAll();
menu += "diff-mode (dm) - displays those aspects of region that have not been saved but changed since the very last revision. Will dynamically update as you change environment.\n"; }
SendSimChatMessage(scene, menu);
}
public void SendSimChatMessage(Scene scene, string message) public void DisplayHelpMenu(Scene scene)
{ {
scene.SimChat(Helpers.StringToField(message), string menu = "Menu:\n";
ChatTypeEnum.Broadcast, 0, new LLVector3(0,0,0), "Content Manager", LLUUID.Zero, false); menu += "commit (ci) - saves current state of the region to a database on the server\n";
} menu += "diff-mode (dm) - displays those aspects of region that have not been saved but changed since the very last revision. Will dynamically update as you change environment.\n";
SendSimChatMessage(scene, menu);
}
public void Hide(ContentManagementEntity ent) public void DisplayMetaEntity(LLUUID uuid)
{ {
ent.HideFromAll(); ContentManagementEntity group = m_model.GetMetaGroupByPrim(uuid);
} if (group != null)
group.SendFullDiffUpdateToAll();
}
public void HideAllMetaEntities() /// <summary>
{ /// update all clients of red/green/blue auras and meta entities that the model knows about.
foreach(Object obj in m_model.MetaEntityCollection.Entities.Values) /// </summary>
((ContentManagementEntity)obj).HideFromAll(); public void DisplayRecentChanges()
} {
m_log.Debug("[CONTENT MANAGEMENT] Sending update to clients for " + m_model.MetaEntityCollection.Entities.Count + " objects.");
DisplayEntities(m_model.MetaEntityCollection);
DisplayAuras(m_model.MetaEntityCollection);
}
public void HideAllAuras() public void Hide(ContentManagementEntity ent)
{ {
foreach(Object obj in m_model.MetaEntityCollection.Auras.Values) ent.HideFromAll();
((MetaEntity)obj).HideFromAll(); }
}
} public void HideAllAuras()
{
foreach(Object obj in m_model.MetaEntityCollection.Auras.Values)
((MetaEntity)obj).HideFromAll();
}
public void HideAllMetaEntities()
{
foreach(Object obj in m_model.MetaEntityCollection.Entities.Values)
((ContentManagementEntity)obj).HideFromAll();
}
public void Initialise(CMModel model)
{
m_model = model;
}
/// <summary>
/// Figures out if the part deleted was a new scene object part or a revisioned part that's been deleted.
/// If it's a new scene object, any green aura attached to it is deleted.
/// If a revisioned part is deleted, a new full update is sent to the environment of the meta entity, which will
/// figure out that there should be a red aura and not a blue aura/beam.
/// </summary>
public void RemoveOrUpdateDeletedEntity(SceneObjectGroup group)
{
// Deal with revisioned parts that have been deleted.
if (m_model.MetaEntityCollection.Entities.ContainsKey(group.UUID))
((ContentManagementEntity)m_model.MetaEntityCollection.Entities[group.UUID]).SendFullDiffUpdateToAll();
// Deal with new parts not revisioned that have been deleted.
foreach(SceneObjectPart part in group.Children.Values)
if (m_model.MetaEntityCollection.Auras.ContainsKey(part.UUID))
((AuraMetaEntity)m_model.MetaEntityCollection.Auras[part.UUID]).HideFromAll();
}
public void SendMetaEntitiesToNewClient(IClientAPI client)
{
}
public void SendSimChatMessage(Scene scene, string message)
{
scene.SimChat(Helpers.StringToField(message),
ChatTypeEnum.Broadcast, 0, new LLVector3(0,0,0), "Content Manager", LLUUID.Zero, false);
}
#endregion Public Methods
}
} }

View File

@ -1,326 +1,362 @@
#region Header
// ContentManagementEntity.cs // ContentManagementEntity.cs
// User: bongiojp // User: bongiojp
// //
// //
#endregion Header
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public class ContentManagementEntity : MetaEntity public class ContentManagementEntity : MetaEntity
{ {
static float TimeToDiff = 0; #region Static Fields
static float TimeToCreateEntities = 0;
// The LinkNum of parts in m_Entity and m_UnchangedEntity are the same though UUID and LocalId are different. static float TimeToDiff = 0;
// This can come in handy. static float TimeToCreateEntities = 0;
protected SceneObjectGroup m_UnchangedEntity = null;
protected Dictionary<LLUUID, BeamMetaEntity> m_BeamEntities = new Dictionary<LLUUID, BeamMetaEntity>();
protected Dictionary<LLUUID, AuraMetaEntity> m_AuraEntities = new Dictionary<LLUUID, AuraMetaEntity>();
/// <value> #endregion Static Fields
/// Should be set to true when there is a difference between m_UnchangedEntity and the corresponding scene object group in the scene entity list.
/// </value>
bool DiffersFromSceneGroup = false;
public SceneObjectGroup UnchangedEntity #region Fields
{
get { return m_UnchangedEntity; }
}
public ContentManagementEntity(SceneObjectGroup Unchanged, bool physics) : base(Unchanged, false) protected Dictionary<LLUUID, AuraMetaEntity> m_AuraEntities = new Dictionary<LLUUID, AuraMetaEntity>();
{ protected Dictionary<LLUUID, BeamMetaEntity> m_BeamEntities = new Dictionary<LLUUID, BeamMetaEntity>();
m_UnchangedEntity = Unchanged.Copy(Unchanged.RootPart.OwnerID, Unchanged.RootPart.GroupID, false);
}
public ContentManagementEntity(string objectXML, Scene scene, bool physics) : base(objectXML, scene, false) // The LinkNum of parts in m_Entity and m_UnchangedEntity are the same though UUID and LocalId are different.
{ // This can come in handy.
m_UnchangedEntity = new SceneObjectGroup(objectXML); protected SceneObjectGroup m_UnchangedEntity = null;
}
public override void Hide(IClientAPI client) /// <value>
{ /// Should be set to true when there is a difference between m_UnchangedEntity and the corresponding scene object group in the scene entity list.
base.Hide(client); /// </value>
foreach(MetaEntity group in m_AuraEntities.Values) bool DiffersFromSceneGroup = false;
group.Hide(client);
foreach(MetaEntity group in m_BeamEntities.Values)
group.Hide(client);
}
public override void HideFromAll() #endregion Fields
{
base.HideFromAll();
foreach(MetaEntity group in m_AuraEntities.Values)
group.HideFromAll();
foreach(MetaEntity group in m_BeamEntities.Values)
group.HideFromAll();
}
public void SendFullDiffUpdateToAll() #region Constructors
{
FindDifferences();
if (DiffersFromSceneGroup)
{
SendFullUpdateToAll();
SendFullAuraUpdateToAll();
SendFullBeamUpdateToAll();
}
}
public void SendFullDiffUpdate(IClientAPI client) public ContentManagementEntity(SceneObjectGroup Unchanged, bool physics)
{ : base(Unchanged, false)
FindDifferences();
if (DiffersFromSceneGroup)
{
SendFullUpdate(client);
SendFullAuraUpdate(client);
SendFullBeamUpdate(client);
}
}
public void SendFullBeamUpdate(IClientAPI client)
{
if (DiffersFromSceneGroup)
{
foreach(BeamMetaEntity group in m_BeamEntities.Values)
group.SendFullUpdate(client);
}
}
public void SendFullAuraUpdate(IClientAPI client)
{
if (DiffersFromSceneGroup)
{
foreach(AuraMetaEntity group in m_AuraEntities.Values)
group.SendFullUpdate(client);
}
}
public void SendFullBeamUpdateToAll()
{
if (DiffersFromSceneGroup)
{
foreach(BeamMetaEntity group in m_BeamEntities.Values)
group.SendFullUpdateToAll();
}
}
public void SendFullAuraUpdateToAll()
{
if (DiffersFromSceneGroup)
{
foreach(AuraMetaEntity group in m_AuraEntities.Values)
group.SendFullUpdateToAll();
}
}
/// <summary>
/// Search for a corresponding group UUID in the scene. If not found, then the revisioned group this CMEntity represents has been deleted. Mark the metaentity appropriately.
/// If a matching UUID is found in a scene object group, compare the two for differences. If differences exist, Mark the metaentity appropriately.
/// </summary>
public void FindDifferences()
{
System.Collections.Generic.List<EntityBase> sceneEntityList = m_Entity.Scene.GetEntities();
DiffersFromSceneGroup = false;
// if group is not contained in scene's list
if(!ContainsKey(sceneEntityList, m_UnchangedEntity.UUID))
{
foreach(SceneObjectPart part in m_UnchangedEntity.Children.Values)
{
// if scene list no longer contains this part, display translucent part and mark with red aura
if(! ContainsKey(sceneEntityList, part.UUID))
{
// if already displaying a red aura over part, make sure its red
if (m_AuraEntities.ContainsKey(part.UUID))
{
m_AuraEntities[part.UUID].SetAura(new LLVector3(254,0,0), part.Scale);
}
else
{
AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
m_Entity.Scene.PrimIDAllocate(),
part.GetWorldPosition(),
MetaEntity.TRANSLUCENT,
new LLVector3(254,0,0),
part.Scale
);
m_AuraEntities.Add(part.UUID, auraGroup);
}
SceneObjectPart metaPart = m_Entity.GetLinkNumPart(part.LinkNum);
SetPartTransparency(metaPart, MetaEntity.TRANSLUCENT);
}
// otherwise, scene will not contain the part. note: a group can not remove a part without changing group id
}
// a deleted part has no where to point a beam particle system,
// if a metapart had a particle system (maybe it represented a moved part) remove it
if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
{
m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
}
DiffersFromSceneGroup = true;
}
// if scene list does contain group, compare each part in group for differences and display beams and auras appropriately
else
{
MarkWithDifferences((SceneObjectGroup)GetGroupByUUID(sceneEntityList, m_UnchangedEntity.UUID));
}
}
/// <summary>
/// Returns true if there was a change between meta entity and the entity group, false otherwise.
/// If true is returned, it is assumed the metaentity's appearance has changed to reflect the difference (though clients haven't been updated).
/// </summary>
public bool MarkWithDifferences(SceneObjectGroup sceneEntityGroup)
{
SceneObjectPart sceneEntityPart;
SceneObjectPart metaEntityPart;
Diff differences;
bool changed = false;
// Use "UnchangedEntity" to do comparisons because its text, transparency, and other attributes will be just as the user
// had originally saved.
// m_Entity will NOT necessarily be the same entity as the user had saved.
foreach(SceneObjectPart UnchangedPart in m_UnchangedEntity.Children.Values)
{
//This is the part that we use to show changes.
metaEntityPart = m_Entity.GetLinkNumPart(UnchangedPart.LinkNum);
if (sceneEntityGroup.Children.ContainsKey(UnchangedPart.UUID))
{
sceneEntityPart = sceneEntityGroup.Children[UnchangedPart.UUID];
differences = Difference.FindDifferences(UnchangedPart, sceneEntityPart);
if (differences != Diff.NONE)
metaEntityPart.Text = "CHANGE: " + differences.ToString();
if (differences != 0)
{
// Root Part that has been modified
if ((differences&Diff.POSITION) > 0)
{
// If the position of any part has changed, make sure the RootPart of the
// meta entity is pointing with a beam particle system
if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
{
m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
}
BeamMetaEntity beamGroup = new BeamMetaEntity(m_Entity.Scene,
m_Entity.Scene.PrimIDAllocate(),
m_UnchangedEntity.RootPart.GetWorldPosition(),
MetaEntity.TRANSLUCENT,
sceneEntityPart,
new LLVector3(0,0,254)
);
m_BeamEntities.Add(m_UnchangedEntity.RootPart.UUID, beamGroup);
}
if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
{
m_AuraEntities[UnchangedPart.UUID].HideFromAll();
m_AuraEntities.Remove(UnchangedPart.UUID);
}
AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
m_Entity.Scene.PrimIDAllocate(),
UnchangedPart.GetWorldPosition(),
MetaEntity.TRANSLUCENT,
new LLVector3(0,0,254),
UnchangedPart.Scale
);
m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);
DiffersFromSceneGroup = true;
}
else // no differences between scene part and meta part
{
if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
{
m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
}
if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
{
m_AuraEntities[UnchangedPart.UUID].HideFromAll();
m_AuraEntities.Remove(UnchangedPart.UUID);
}
SetPartTransparency(metaEntityPart, MetaEntity.NONE);
}
}
else //The entity currently in the scene is missing parts from the metaentity saved, so mark parts red as deleted.
{
if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
{
m_AuraEntities[UnchangedPart.UUID].HideFromAll();
m_AuraEntities.Remove(UnchangedPart.UUID);
}
AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
m_Entity.Scene.PrimIDAllocate(),
UnchangedPart.GetWorldPosition(),
MetaEntity.TRANSLUCENT,
new LLVector3(254,0,0),
UnchangedPart.Scale
);
m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);
DiffersFromSceneGroup = true;
}
}
return changed;
}
private SceneObjectGroup GetGroupByUUID(System.Collections.Generic.List<EntityBase> list, LLUUID uuid)
{ {
foreach (EntityBase ent in list) m_UnchangedEntity = Unchanged.Copy(Unchanged.RootPart.OwnerID, Unchanged.RootPart.GroupID, false);
{ }
if (ent is SceneObjectGroup)
if (ent.UUID == uuid)
return (SceneObjectGroup)ent;
}
return null;
}
/// <summary> public ContentManagementEntity(string objectXML, Scene scene, bool physics)
/// Check if the revisioned scene object group that this CMEntity is based off of contains a child with the given UUID. : base(objectXML, scene, false)
/// </summary> {
public bool HasChildPrim(LLUUID uuid) m_UnchangedEntity = new SceneObjectGroup(objectXML);
{ }
if (m_UnchangedEntity.Children.ContainsKey(uuid))
return true;
return false;
}
/// <summary> #endregion Constructors
/// Check if the revisioned scene object group that this CMEntity is based off of contains a child with the given LocalId.
/// </summary>
public bool HasChildPrim(uint localID)
{
foreach( SceneObjectPart part in m_UnchangedEntity.Children.Values)
if ( part.LocalId == localID )
return true;
return false;
}
/// <summary> #region Public Properties
/// Check if an entitybase list (like that returned by scene.GetEntities() ) contains a group with the rootpart uuid that matches the current uuid.
/// </summary> public SceneObjectGroup UnchangedEntity
private bool ContainsKey(List<EntityBase> list, LLUUID uuid) {
{ get { return m_UnchangedEntity; }
foreach( EntityBase part in list) }
if (part.UUID == uuid)
return true; #endregion Public Properties
return false;
} #region Private Methods
}
/// <summary>
/// Check if an entitybase list (like that returned by scene.GetEntities() ) contains a group with the rootpart uuid that matches the current uuid.
/// </summary>
private bool ContainsKey(List<EntityBase> list, LLUUID uuid)
{
foreach( EntityBase part in list)
if (part.UUID == uuid)
return true;
return false;
}
private SceneObjectGroup GetGroupByUUID(System.Collections.Generic.List<EntityBase> list, LLUUID uuid)
{
foreach (EntityBase ent in list)
{
if (ent is SceneObjectGroup)
if (ent.UUID == uuid)
return (SceneObjectGroup)ent;
}
return null;
}
#endregion Private Methods
#region Public Methods
/// <summary>
/// Search for a corresponding group UUID in the scene. If not found, then the revisioned group this CMEntity represents has been deleted. Mark the metaentity appropriately.
/// If a matching UUID is found in a scene object group, compare the two for differences. If differences exist, Mark the metaentity appropriately.
/// </summary>
public void FindDifferences()
{
System.Collections.Generic.List<EntityBase> sceneEntityList = m_Entity.Scene.GetEntities();
DiffersFromSceneGroup = false;
// if group is not contained in scene's list
if(!ContainsKey(sceneEntityList, m_UnchangedEntity.UUID))
{
foreach(SceneObjectPart part in m_UnchangedEntity.Children.Values)
{
// if scene list no longer contains this part, display translucent part and mark with red aura
if(! ContainsKey(sceneEntityList, part.UUID))
{
// if already displaying a red aura over part, make sure its red
if (m_AuraEntities.ContainsKey(part.UUID))
{
m_AuraEntities[part.UUID].SetAura(new LLVector3(254,0,0), part.Scale);
}
else
{
AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
m_Entity.Scene.PrimIDAllocate(),
part.GetWorldPosition(),
MetaEntity.TRANSLUCENT,
new LLVector3(254,0,0),
part.Scale
);
m_AuraEntities.Add(part.UUID, auraGroup);
}
SceneObjectPart metaPart = m_Entity.GetLinkNumPart(part.LinkNum);
SetPartTransparency(metaPart, MetaEntity.TRANSLUCENT);
}
// otherwise, scene will not contain the part. note: a group can not remove a part without changing group id
}
// a deleted part has no where to point a beam particle system,
// if a metapart had a particle system (maybe it represented a moved part) remove it
if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
{
m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
}
DiffersFromSceneGroup = true;
}
// if scene list does contain group, compare each part in group for differences and display beams and auras appropriately
else
{
MarkWithDifferences((SceneObjectGroup)GetGroupByUUID(sceneEntityList, m_UnchangedEntity.UUID));
}
}
/// <summary>
/// Check if the revisioned scene object group that this CMEntity is based off of contains a child with the given UUID.
/// </summary>
public bool HasChildPrim(LLUUID uuid)
{
if (m_UnchangedEntity.Children.ContainsKey(uuid))
return true;
return false;
}
/// <summary>
/// Check if the revisioned scene object group that this CMEntity is based off of contains a child with the given LocalId.
/// </summary>
public bool HasChildPrim(uint localID)
{
foreach( SceneObjectPart part in m_UnchangedEntity.Children.Values)
if ( part.LocalId == localID )
return true;
return false;
}
public override void Hide(IClientAPI client)
{
base.Hide(client);
foreach(MetaEntity group in m_AuraEntities.Values)
group.Hide(client);
foreach(MetaEntity group in m_BeamEntities.Values)
group.Hide(client);
}
public override void HideFromAll()
{
base.HideFromAll();
foreach(MetaEntity group in m_AuraEntities.Values)
group.HideFromAll();
foreach(MetaEntity group in m_BeamEntities.Values)
group.HideFromAll();
}
/// <summary>
/// Returns true if there was a change between meta entity and the entity group, false otherwise.
/// If true is returned, it is assumed the metaentity's appearance has changed to reflect the difference (though clients haven't been updated).
/// </summary>
public bool MarkWithDifferences(SceneObjectGroup sceneEntityGroup)
{
SceneObjectPart sceneEntityPart;
SceneObjectPart metaEntityPart;
Diff differences;
bool changed = false;
// Use "UnchangedEntity" to do comparisons because its text, transparency, and other attributes will be just as the user
// had originally saved.
// m_Entity will NOT necessarily be the same entity as the user had saved.
foreach(SceneObjectPart UnchangedPart in m_UnchangedEntity.Children.Values)
{
//This is the part that we use to show changes.
metaEntityPart = m_Entity.GetLinkNumPart(UnchangedPart.LinkNum);
if (sceneEntityGroup.Children.ContainsKey(UnchangedPart.UUID))
{
sceneEntityPart = sceneEntityGroup.Children[UnchangedPart.UUID];
differences = Difference.FindDifferences(UnchangedPart, sceneEntityPart);
if (differences != Diff.NONE)
metaEntityPart.Text = "CHANGE: " + differences.ToString();
if (differences != 0)
{
// Root Part that has been modified
if ((differences&Diff.POSITION) > 0)
{
// If the position of any part has changed, make sure the RootPart of the
// meta entity is pointing with a beam particle system
if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
{
m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
}
BeamMetaEntity beamGroup = new BeamMetaEntity(m_Entity.Scene,
m_Entity.Scene.PrimIDAllocate(),
m_UnchangedEntity.RootPart.GetWorldPosition(),
MetaEntity.TRANSLUCENT,
sceneEntityPart,
new LLVector3(0,0,254)
);
m_BeamEntities.Add(m_UnchangedEntity.RootPart.UUID, beamGroup);
}
if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
{
m_AuraEntities[UnchangedPart.UUID].HideFromAll();
m_AuraEntities.Remove(UnchangedPart.UUID);
}
AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
m_Entity.Scene.PrimIDAllocate(),
UnchangedPart.GetWorldPosition(),
MetaEntity.TRANSLUCENT,
new LLVector3(0,0,254),
UnchangedPart.Scale
);
m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);
DiffersFromSceneGroup = true;
}
else // no differences between scene part and meta part
{
if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
{
m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
}
if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
{
m_AuraEntities[UnchangedPart.UUID].HideFromAll();
m_AuraEntities.Remove(UnchangedPart.UUID);
}
SetPartTransparency(metaEntityPart, MetaEntity.NONE);
}
}
else //The entity currently in the scene is missing parts from the metaentity saved, so mark parts red as deleted.
{
if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
{
m_AuraEntities[UnchangedPart.UUID].HideFromAll();
m_AuraEntities.Remove(UnchangedPart.UUID);
}
AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
m_Entity.Scene.PrimIDAllocate(),
UnchangedPart.GetWorldPosition(),
MetaEntity.TRANSLUCENT,
new LLVector3(254,0,0),
UnchangedPart.Scale
);
m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);
DiffersFromSceneGroup = true;
}
}
return changed;
}
public void SendFullAuraUpdate(IClientAPI client)
{
if (DiffersFromSceneGroup)
{
foreach(AuraMetaEntity group in m_AuraEntities.Values)
group.SendFullUpdate(client);
}
}
public void SendFullAuraUpdateToAll()
{
if (DiffersFromSceneGroup)
{
foreach(AuraMetaEntity group in m_AuraEntities.Values)
group.SendFullUpdateToAll();
}
}
public void SendFullBeamUpdate(IClientAPI client)
{
if (DiffersFromSceneGroup)
{
foreach(BeamMetaEntity group in m_BeamEntities.Values)
group.SendFullUpdate(client);
}
}
public void SendFullBeamUpdateToAll()
{
if (DiffersFromSceneGroup)
{
foreach(BeamMetaEntity group in m_BeamEntities.Values)
group.SendFullUpdateToAll();
}
}
public void SendFullDiffUpdate(IClientAPI client)
{
FindDifferences();
if (DiffersFromSceneGroup)
{
SendFullUpdate(client);
SendFullAuraUpdate(client);
SendFullBeamUpdate(client);
}
}
public void SendFullDiffUpdateToAll()
{
FindDifferences();
if (DiffersFromSceneGroup)
{
SendFullUpdateToAll();
SendFullAuraUpdateToAll();
SendFullBeamUpdateToAll();
}
}
#endregion Public Methods
}
} }

View File

@ -1,30 +1,68 @@
#region Header
// ContentManagementModule.cs // ContentManagementModule.cs
// User: bongiojp // User: bongiojp
#endregion Header
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim; using OpenSim;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
using System.Threading;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public class ContentManagementModule : IRegionModule public class ContentManagementModule : IRegionModule
{ {
#region Static Fields
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
CMController m_control = null;
CMModel m_model = null; #endregion Static Fields
CMView m_view = null;
#region Fields
bool initialised = false; bool initialised = false;
bool m_posted = false; CMController m_control = null;
bool m_enabled = false; bool m_enabled = false;
CMModel m_model = null;
bool m_posted = false;
CMView m_view = null;
#endregion Fields
#region Public Properties
public bool IsSharedModule
{
get { return true; }
}
public string Name
{
get { return "ContentManagementModule"; }
}
#endregion Public Properties
#region Public Methods
public void Close()
{
}
public void Initialise(Scene scene, IConfigSource source) public void Initialise(Scene scene, IConfigSource source)
{ {
@ -95,17 +133,6 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
} }
} }
public void Close() #endregion Public Methods
{}
public string Name
{
get { return "ContentManagementModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
} }
} }

View File

@ -1,159 +1,132 @@
#region Header
// FileSystemDatabase.cs // FileSystemDatabase.cs
// User: bongiojp // User: bongiojp
#endregion Header
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using Slash = System.IO.Path;
using System.Reflection; using System.Reflection;
using System.Xml; using System.Xml;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.World.Serialiser; using OpenSim.Region.Environment.Modules.World.Serialiser;
using OpenSim.Region.Environment.Modules.World.Terrain; using OpenSim.Region.Environment.Modules.World.Terrain;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
using Slash=System.IO.Path;
using System.Diagnostics;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public class FileSystemDatabase : IContentDatabase public class FileSystemDatabase : IContentDatabase
{ {
public static float TimeToDownload = 0; #region Static Fields
public static float TimeToSave = 0;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static float TimeToDownload = 0;
public static float TimeToSave = 0;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string m_repodir = null; #endregion Static Fields
private Dictionary<LLUUID, IRegionSerialiser> m_serialiser = new Dictionary<LLUUID, IRegionSerialiser>();
private Dictionary<LLUUID, Scene> m_scenes = new Dictionary<LLUUID, Scene>();
public FileSystemDatabase() #region Fields
{
}
public void Initialise(Scene scene, string dir) private string m_repodir = null;
{ private Dictionary<LLUUID, Scene> m_scenes = new Dictionary<LLUUID, Scene>();
lock(this) private Dictionary<LLUUID, IRegionSerialiser> m_serialiser = new Dictionary<LLUUID, IRegionSerialiser>();
{
if (m_repodir == null)
m_repodir = dir;
}
lock(m_scenes)
m_scenes.Add(scene.RegionInfo.RegionID, scene);
}
#endregion Fields
// Run once and only once. #region Constructors
public void PostInitialise()
{
SetupSerialiser();
m_log.Info("[FSDB]: Creating repository in " + m_repodir + "."); public FileSystemDatabase()
CreateDirectory();
}
// called by postinitialise
private void SetupSerialiser()
{ {
if (m_serialiser.Count == 0)
foreach(LLUUID region in m_scenes.Keys)
m_serialiser.Add(region,
m_scenes[region].RequestModuleInterface<IRegionSerialiser>()
);
} }
// called by postinitialise #endregion Constructors
private void CreateDirectory()
{
string scenedir;
if (!Directory.Exists(m_repodir))
Directory.CreateDirectory(m_repodir);
foreach (LLUUID region in m_scenes.Keys) #region Private Methods
{
scenedir = m_repodir + Slash.DirectorySeparatorChar + region + Slash.DirectorySeparatorChar;
if (!Directory.Exists(scenedir))
Directory.CreateDirectory(scenedir);
}
}
public int NumOfRegionRev(LLUUID regionid) // called by postinitialise
{ private void CreateDirectory()
string scenedir = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar; {
m_log.Info("[FSDB]: Reading scene dir: " + scenedir); string scenedir;
string[] directories = Directory.GetDirectories(scenedir); if (!Directory.Exists(m_repodir))
return directories.Length; Directory.CreateDirectory(m_repodir);
}
public int GetMostRecentRevision(LLUUID regionid) foreach (LLUUID region in m_scenes.Keys)
{ {
return NumOfRegionRev(regionid); scenedir = m_repodir + Slash.DirectorySeparatorChar + region + Slash.DirectorySeparatorChar;
} if (!Directory.Exists(scenedir))
Directory.CreateDirectory(scenedir);
}
}
public void SaveRegion(LLUUID regionid, string regionName, string logMessage) // called by postinitialise
{ private void SetupSerialiser()
m_log.Info("[FSDB]: ..............................."); {
string scenedir = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar; if (m_serialiser.Count == 0)
foreach(LLUUID region in m_scenes.Keys)
m_serialiser.Add(region,
m_scenes[region].RequestModuleInterface<IRegionSerialiser>()
);
}
m_log.Info("[FSDB]: checking if scene directory exists: " + scenedir); #endregion Private Methods
if (!Directory.Exists(scenedir))
Directory.CreateDirectory(scenedir);
int newRevisionNum = GetMostRecentRevision(regionid)+1; #region Public Methods
string revisiondir = scenedir + newRevisionNum + Slash.DirectorySeparatorChar;
m_log.Info("[FSDB]: checking if revision directory exists: " + revisiondir); public int GetMostRecentRevision(LLUUID regionid)
if (!Directory.Exists(revisiondir)) {
Directory.CreateDirectory(revisiondir); return NumOfRegionRev(regionid);
}
try { public string GetRegionObjectHeightMap(LLUUID regionid)
Stopwatch x = new Stopwatch(); {
x.Start(); String filename = m_repodir + Slash.DirectorySeparatorChar + regionid +
if (m_scenes.ContainsKey(regionid)) Slash.DirectorySeparatorChar + "heightmap.r32";
{ FileStream fs = new FileStream( filename, FileMode.Open);
m_serialiser[regionid].SerialiseRegion(m_scenes[regionid], revisiondir); StreamReader sr = new StreamReader(fs);
} String result = sr.ReadToEnd();
x.Stop(); sr.Close();
TimeToSave += x.ElapsedMilliseconds; fs.Close();
m_log.Info("[FileSystemDatabase] Time spent serialising regions to files on disk for " + regionName + ": " + x.ElapsedMilliseconds); return result;
m_log.Info("[FileSystemDatabase] Time spent serialising regions to files on disk so far: " + TimeToSave); }
}
catch (Exception e)
{
m_log.ErrorFormat("[FSDB]: Serialisation of region failed: " + e);
return;
}
try { public string GetRegionObjectHeightMap(LLUUID regionid, int revision)
// Finish by writing log message. {
FileStream file = new FileStream(revisiondir + "log", FileMode.Create, FileAccess.ReadWrite); String filename = m_repodir + Slash.DirectorySeparatorChar + regionid +
StreamWriter sw = new StreamWriter(file); Slash.DirectorySeparatorChar + "heightmap.r32";
sw.Write(logMessage); FileStream fs = new FileStream( filename, FileMode.Open);
sw.Close(); StreamReader sr = new StreamReader(fs);
} String result = sr.ReadToEnd();
catch (Exception e) sr.Close();
{ fs.Close();
m_log.ErrorFormat("[FSDB]: Failed trying to save log file " + e); return result;
return; }
}
}
public System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid, int revision) public System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid, int revision)
{ {
System.Collections.ArrayList objectList = new System.Collections.ArrayList(); System.Collections.ArrayList objectList = new System.Collections.ArrayList();
string filename = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar + string filename = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar +
+ revision + Slash.DirectorySeparatorChar + "objects.xml"; + revision + Slash.DirectorySeparatorChar + "objects.xml";
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
XmlNode rootNode; XmlNode rootNode;
//int primCount = 0; //int primCount = 0;
//SceneObjectGroup obj = null; //SceneObjectGroup obj = null;
if(File.Exists(filename)) if(File.Exists(filename))
{ {
XmlTextReader reader = new XmlTextReader(filename); XmlTextReader reader = new XmlTextReader(filename);
reader.WhitespaceHandling = WhitespaceHandling.None; reader.WhitespaceHandling = WhitespaceHandling.None;
@ -162,29 +135,29 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
rootNode = doc.FirstChild; rootNode = doc.FirstChild;
foreach (XmlNode aPrimNode in rootNode.ChildNodes) foreach (XmlNode aPrimNode in rootNode.ChildNodes)
{ {
objectList.Add(aPrimNode.OuterXml); objectList.Add(aPrimNode.OuterXml);
} }
return objectList; return objectList;
} }
return null; return null;
} }
public System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid) public System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid)
{ {
int revision = NumOfRegionRev(regionid); int revision = NumOfRegionRev(regionid);
m_log.Info("[FSDB]: found revisions:" + revision); m_log.Info("[FSDB]: found revisions:" + revision);
System.Collections.ArrayList xmlList = new System.Collections.ArrayList(); System.Collections.ArrayList xmlList = new System.Collections.ArrayList();
string filename = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar + string filename = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar +
+ revision + Slash.DirectorySeparatorChar + "objects.xml"; + revision + Slash.DirectorySeparatorChar + "objects.xml";
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
XmlNode rootNode; XmlNode rootNode;
m_log.Info("[FSDB]: Checking if " + filename + " exists."); m_log.Info("[FSDB]: Checking if " + filename + " exists.");
if(File.Exists(filename)) if(File.Exists(filename))
{ {
Stopwatch x = new Stopwatch(); Stopwatch x = new Stopwatch();
x.Start(); x.Start();
XmlTextReader reader = new XmlTextReader(filename); XmlTextReader reader = new XmlTextReader(filename);
reader.WhitespaceHandling = WhitespaceHandling.None; reader.WhitespaceHandling = WhitespaceHandling.None;
@ -193,68 +166,122 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
rootNode = doc.FirstChild; rootNode = doc.FirstChild;
foreach (XmlNode aPrimNode in rootNode.ChildNodes) foreach (XmlNode aPrimNode in rootNode.ChildNodes)
xmlList.Add(aPrimNode.OuterXml); xmlList.Add(aPrimNode.OuterXml);
x.Stop(); x.Stop();
TimeToDownload += x.ElapsedMilliseconds; TimeToDownload += x.ElapsedMilliseconds;
m_log.Info("[FileSystemDatabase] Time spent retrieving xml files so far: " + TimeToDownload); m_log.Info("[FileSystemDatabase] Time spent retrieving xml files so far: " + TimeToDownload);
return xmlList; return xmlList;
} }
return null; return null;
} }
public string GetRegionObjectHeightMap(LLUUID regionid) public void Initialise(Scene scene, string dir)
{ {
String filename = m_repodir + Slash.DirectorySeparatorChar + regionid + lock(this)
Slash.DirectorySeparatorChar + "heightmap.r32"; {
FileStream fs = new FileStream( filename, FileMode.Open); if (m_repodir == null)
StreamReader sr = new StreamReader(fs); m_repodir = dir;
String result = sr.ReadToEnd(); }
sr.Close(); lock(m_scenes)
fs.Close(); m_scenes.Add(scene.RegionInfo.RegionID, scene);
return result; }
}
public string GetRegionObjectHeightMap(LLUUID regionid, int revision) public System.Collections.Generic.SortedDictionary<string, string> ListOfRegionRevisions(LLUUID regionid)
{ {
String filename = m_repodir + Slash.DirectorySeparatorChar + regionid + SortedDictionary<string, string> revisionDict = new SortedDictionary<string,string>();
Slash.DirectorySeparatorChar + "heightmap.r32";
FileStream fs = new FileStream( filename, FileMode.Open);
StreamReader sr = new StreamReader(fs);
String result = sr.ReadToEnd();
sr.Close();
fs.Close();
return result;
}
public System.Collections.Generic.SortedDictionary<string, string> ListOfRegionRevisions(LLUUID regionid) string scenedir = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar;
{ string[] directories = Directory.GetDirectories(scenedir);
SortedDictionary<string, string> revisionDict = new SortedDictionary<string,string>();
string scenedir = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar; FileStream fs = null;
string[] directories = Directory.GetDirectories(scenedir); StreamReader sr = null;
String logMessage = "";
String logLocation = "";
foreach(string revisionDir in directories)
{
try {
logLocation = revisionDir + Slash.DirectorySeparatorChar + "log";
fs = new FileStream( logLocation, FileMode.Open);
sr = new StreamReader(fs);
logMessage = sr.ReadToEnd();
sr.Close();
fs.Close();
revisionDict.Add(revisionDir, logMessage);
}
catch (Exception)
{}
}
FileStream fs = null; return revisionDict;
StreamReader sr = null; }
String logMessage = "";
String logLocation = "";
foreach(string revisionDir in directories)
{
try {
logLocation = revisionDir + Slash.DirectorySeparatorChar + "log";
fs = new FileStream( logLocation, FileMode.Open);
sr = new StreamReader(fs);
logMessage = sr.ReadToEnd();
sr.Close();
fs.Close();
revisionDict.Add(revisionDir, logMessage);
}
catch (Exception)
{}
}
return revisionDict; public int NumOfRegionRev(LLUUID regionid)
} {
} string scenedir = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar;
m_log.Info("[FSDB]: Reading scene dir: " + scenedir);
string[] directories = Directory.GetDirectories(scenedir);
return directories.Length;
}
// Run once and only once.
public void PostInitialise()
{
SetupSerialiser();
m_log.Info("[FSDB]: Creating repository in " + m_repodir + ".");
CreateDirectory();
}
public void SaveRegion(LLUUID regionid, string regionName, string logMessage)
{
m_log.Info("[FSDB]: ...............................");
string scenedir = m_repodir + Slash.DirectorySeparatorChar + regionid + Slash.DirectorySeparatorChar;
m_log.Info("[FSDB]: checking if scene directory exists: " + scenedir);
if (!Directory.Exists(scenedir))
Directory.CreateDirectory(scenedir);
int newRevisionNum = GetMostRecentRevision(regionid)+1;
string revisiondir = scenedir + newRevisionNum + Slash.DirectorySeparatorChar;
m_log.Info("[FSDB]: checking if revision directory exists: " + revisiondir);
if (!Directory.Exists(revisiondir))
Directory.CreateDirectory(revisiondir);
try {
Stopwatch x = new Stopwatch();
x.Start();
if (m_scenes.ContainsKey(regionid))
{
m_serialiser[regionid].SerialiseRegion(m_scenes[regionid], revisiondir);
}
x.Stop();
TimeToSave += x.ElapsedMilliseconds;
m_log.Info("[FileSystemDatabase] Time spent serialising regions to files on disk for " + regionName + ": " + x.ElapsedMilliseconds);
m_log.Info("[FileSystemDatabase] Time spent serialising regions to files on disk so far: " + TimeToSave);
}
catch (Exception e)
{
m_log.ErrorFormat("[FSDB]: Serialisation of region failed: " + e);
return;
}
try {
// Finish by writing log message.
FileStream file = new FileStream(revisiondir + "log", FileMode.Create, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(file);
sw.Write(logMessage);
sw.Close();
}
catch (Exception e)
{
m_log.ErrorFormat("[FSDB]: Failed trying to save log file " + e);
return;
}
}
#endregion Public Methods
}
} }

View File

@ -1,130 +1,142 @@
#region Header
// GitDatabase.cs // GitDatabase.cs
// //
// //
// //
#endregion Header
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Slash = System.IO.Path;
using System.Reflection; using System.Reflection;
using System.Xml; using System.Xml;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Modules.World.Serialiser; using OpenSim.Region.Environment.Modules.World.Serialiser;
using OpenSim.Region.Environment.Modules.World.Terrain; using OpenSim.Region.Environment.Modules.World.Terrain;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
using Slash=System.IO.Path;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
/// <summary>
/// Just a stub :-(
/// </summary>
public class GitDatabase : IContentDatabase
{
#region Constructors
/// <summary> public GitDatabase()
/// Just a stub :-( {
/// </summary> }
public class GitDatabase : IContentDatabase
{
public GitDatabase() #endregion Constructors
{
}
public void Initialise(Scene scene, String dir) #region Public Methods
{
} public SceneObjectGroup GetMostRecentObjectRevision(LLUUID id)
{
return null;
}
public void PostInitialise() public int GetMostRecentRevision(LLUUID regionid)
{ {
return 0;
}
} public SceneObjectGroup GetObjectRevision(LLUUID id, int revision)
{
return null;
}
public int NumOfObjectRev(LLUUID id) public System.Collections.ArrayList GetObjectsFromRegion(LLUUID regionid, int revision)
{ {
return 0; return null;
} }
public int NumOfRegionRev(LLUUID regionid) public string GetRegionObjectHeightMap(LLUUID regionid)
{ {
return 0; return null;
} }
public bool InRepository(LLUUID id) public string GetRegionObjectHeightMap(LLUUID regionid, int revision)
{ {
return false; return null;
} }
public void SaveRegion(LLUUID regionid, string regionName, string logMessage) public string GetRegionObjectXML(LLUUID regionid)
{ {
return null;
}
} public string GetRegionObjectXML(LLUUID regionid, int revision)
{
return null;
}
public System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid) public System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid)
{ {
return null; return null;
} }
public System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid, int revision) public System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid, int revision)
{ {
return null; return null;
} }
public string GetRegionObjectXML(LLUUID regionid) public bool InRepository(LLUUID id)
{ {
return null; return false;
} }
public string GetRegionObjectXML(LLUUID regionid, int revision) public void Initialise(Scene scene, String dir)
{ {
return null; }
}
public string GetRegionObjectHeightMap(LLUUID regionid) public System.Collections.Generic.SortedDictionary<string, string> ListOfObjectRevisions(LLUUID id)
{ {
return null; return null;
} }
public string GetRegionObjectHeightMap(LLUUID regionid, int revision) public System.Collections.Generic.SortedDictionary<string, string> ListOfRegionRevisions(LLUUID id)
{ {
return null; return null;
} }
public System.Collections.ArrayList GetObjectsFromRegion(LLUUID regionid, int revision) public int NumOfObjectRev(LLUUID id)
{ {
return null; return 0;
} }
public System.Collections.Generic.SortedDictionary<string, string> ListOfRegionRevisions(LLUUID id) public int NumOfRegionRev(LLUUID regionid)
{ {
return null; return 0;
} }
public void SaveObject(SceneObjectGroup entity) public void PostInitialise()
{ {
} }
public SceneObjectGroup GetMostRecentObjectRevision(LLUUID id) public void SaveObject(SceneObjectGroup entity)
{ {
return null; }
}
public SceneObjectGroup GetObjectRevision(LLUUID id, int revision) public void SaveRegion(LLUUID regionid, string regionName, string logMessage)
{ {
return null; }
}
public System.Collections.Generic.SortedDictionary<string, string> ListOfObjectRevisions(LLUUID id) #endregion Public Methods
{ }
return null;
}
public int GetMostRecentRevision(LLUUID regionid)
{
return 0;
}
}
} }

View File

@ -1,57 +1,70 @@
#region Header
// IContentDatabase.cs // IContentDatabase.cs
// User: bongiojp // User: bongiojp
// //
// //
// //
#endregion Header
using System; using System;
using libsecondlife; using libsecondlife;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using Nini.Config; using Nini.Config;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public interface IContentDatabase public interface IContentDatabase
{ {
/// <summary> #region Methods
/// Similar to the IRegionModule function. This is the function to be called before attempting to interface with the database.
/// Initialise should be called one for each region to be contained in the database. The directory should be the full path
/// to the repository and will only be defined once, regardless of how many times the method is called.
/// </summary>
void Initialise(Scene scene, String dir);
/// <summary> /// <summary>
/// Should be called once after Initialise has been called. /// Returns the most recent revision number of a region.
/// </summary> /// </summary>
void PostInitialise(); int GetMostRecentRevision(LLUUID regionid);
/// <summary> string GetRegionObjectHeightMap(LLUUID regionid);
/// Returns the total number of revisions saved for a specific region.
/// </summary>
int NumOfRegionRev(LLUUID regionid);
/// <summary> string GetRegionObjectHeightMap(LLUUID regionid, int revision);
/// Saves the Region terrain map and objects within the region as xml to the database.
/// </summary>
void SaveRegion(LLUUID regionid, string regionName, string logMessage);
/// <summary> /// <summary>
/// Retrieves the xml that describes each individual object from the last revision or specific revision of the given region. /// Retrieves the xml that describes each individual object from the last revision or specific revision of the given region.
/// </summary> /// </summary>
System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid); System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid);
System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid, int revision);
string GetRegionObjectHeightMap(LLUUID regionid); System.Collections.ArrayList GetRegionObjectXMLList(LLUUID regionid, int revision);
string GetRegionObjectHeightMap(LLUUID regionid, int revision);
/// <summary> /// <summary>
/// Returns a list of the revision numbers and corresponding log messages for a given region. /// Similar to the IRegionModule function. This is the function to be called before attempting to interface with the database.
/// </summary> /// Initialise should be called one for each region to be contained in the database. The directory should be the full path
System.Collections.Generic.SortedDictionary<string, string> ListOfRegionRevisions(LLUUID id); /// to the repository and will only be defined once, regardless of how many times the method is called.
/// </summary>
void Initialise(Scene scene, String dir);
/// <summary> /// <summary>
/// Returns the most recent revision number of a region. /// Returns a list of the revision numbers and corresponding log messages for a given region.
/// </summary> /// </summary>
int GetMostRecentRevision(LLUUID regionid); System.Collections.Generic.SortedDictionary<string, string> ListOfRegionRevisions(LLUUID id);
}
/// <summary>
/// Returns the total number of revisions saved for a specific region.
/// </summary>
int NumOfRegionRev(LLUUID regionid);
/// <summary>
/// Should be called once after Initialise has been called.
/// </summary>
void PostInitialise();
/// <summary>
/// Saves the Region terrain map and objects within the region as xml to the database.
/// </summary>
void SaveRegion(LLUUID regionid, string regionName, string logMessage);
#endregion Methods
}
} }

View File

@ -1,219 +1,256 @@
#region Header
// MetaEntity.cs // MetaEntity.cs
// User: bongiojp // User: bongiojp
// //
// TODO: // TODO:
// Create a physics manager to the meta object if there isn't one or the object knows of no scene but the user wants physics enabled. // Create a physics manager to the meta object if there isn't one or the object knows of no scene but the user wants physics enabled.
#endregion Header
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public class MetaEntity public class MetaEntity
{ {
protected static readonly ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #region Constants
protected SceneObjectGroup m_Entity = null; // The scene object group that represents this meta entity. public const float INVISIBLE = .95f;
protected uint m_metaLocalid;
// Settings for transparency of metaentity // Settings for transparency of metaentity
public const float NONE = 0f; public const float NONE = 0f;
public const float TRANSLUCENT = .5f; public const float TRANSLUCENT = .5f;
public const float INVISIBLE = .95f;
public Scene Scene #endregion Constants
{
get { return m_Entity.Scene; }
}
public SceneObjectPart RootPart #region Static Fields
{
get { return m_Entity.RootPart; }
set { m_Entity.RootPart = value; }
}
public LLUUID UUID protected static readonly ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
{
get { return m_Entity.UUID; }
set { m_Entity.UUID = value; }
}
public uint LocalId #endregion Static Fields
{
get { return m_Entity.LocalId; }
set { m_Entity.LocalId = value; }
}
public SceneObjectGroup ObjectGroup #region Fields
{
get { return m_Entity; }
}
public Dictionary<LLUUID, SceneObjectPart> Children protected SceneObjectGroup m_Entity = null; // The scene object group that represents this meta entity.
{ protected uint m_metaLocalid;
get { return m_Entity.Children; }
set { m_Entity.Children = value; }
}
public int PrimCount #endregion Fields
{
get { return m_Entity.PrimCount; }
}
public MetaEntity() #region Constructors
{
}
/// <summary> public MetaEntity()
/// Makes a new meta entity by copying the given scene object group. {
/// The physics boolean is just a stub right now. }
/// </summary>
public MetaEntity(SceneObjectGroup orig, bool physics)
{
m_Entity = orig.Copy(orig.RootPart.OwnerID, orig.RootPart.GroupID, false);
Initialize(physics);
}
/// <summary> /// <summary>
/// Takes an XML description of a scene object group and converts it to a meta entity. /// Makes a new meta entity by copying the given scene object group.
/// </summary> /// The physics boolean is just a stub right now.
public MetaEntity(string objectXML, Scene scene, bool physics) /// </summary>
{ public MetaEntity(SceneObjectGroup orig, bool physics)
m_Entity = new SceneObjectGroup(objectXML); {
m_Entity.SetScene(scene); m_Entity = orig.Copy(orig.RootPart.OwnerID, orig.RootPart.GroupID, false);
Initialize(physics); Initialize(physics);
} }
// The metaentity objectgroup must have unique localids as well as unique uuids. /// <summary>
// localids are used by the client to refer to parts. /// Takes an XML description of a scene object group and converts it to a meta entity.
// uuids are sent to the client and back to the server to identify parts on the server side. /// </summary>
/// <summary> public MetaEntity(string objectXML, Scene scene, bool physics)
/// Changes localids and uuids of m_Entity. {
/// </summary> m_Entity = new SceneObjectGroup(objectXML);
protected void Initialize(bool physics) m_Entity.SetScene(scene);
{ Initialize(physics);
//make new uuids }
Dictionary<LLUUID, SceneObjectPart> parts = new Dictionary<LLUUID, SceneObjectPart>();
foreach(SceneObjectPart part in m_Entity.Children.Values)
{
part.ResetIDs(part.LinkNum);
parts.Add(part.UUID, part);
}
// make new localids #endregion Constructors
foreach (SceneObjectPart part in m_Entity.Children.Values)
part.LocalId = m_Entity.Scene.PrimIDAllocate();
//finalize #region Public Properties
m_Entity.UpdateParentIDs();
m_Entity.RootPart.PhysActor = null;
m_Entity.Children = parts;
} public Dictionary<LLUUID, SceneObjectPart> Children
{
get { return m_Entity.Children; }
set { m_Entity.Children = value; }
}
public void SendFullUpdate(IClientAPI client) public uint LocalId
{ {
// Not sure what clientFlags should be but 0 seems to work get { return m_Entity.LocalId; }
SendFullUpdate(client, 0); set { m_Entity.LocalId = value; }
} }
public void SendFullUpdateToAll()
{
uint clientFlags = 0;
m_Entity.Scene.ClientManager.ForEachClient(delegate(IClientAPI controller)
{ m_Entity.SendFullUpdateToClient(controller, clientFlags); }
);
}
public void SendFullUpdate(IClientAPI client, uint clientFlags) public SceneObjectGroup ObjectGroup
{ {
m_Entity.SendFullUpdateToClient(client, clientFlags); get { return m_Entity; }
} }
/// <summary> public int PrimCount
/// Hides the metaentity from a single client. {
/// </summary> get { return m_Entity.PrimCount; }
public virtual void Hide(IClientAPI client) }
{
//This deletes the group without removing from any databases.
//This is important because we are not IN any database.
//m_Entity.FakeDeleteGroup();
foreach( SceneObjectPart part in m_Entity.Children.Values)
client.SendKillObject(m_Entity.RegionHandle, part.LocalId);
}
/// <summary> public SceneObjectPart RootPart
/// Sends a kill object message to all clients, effectively "hiding" the metaentity even though it's still on the server. {
/// </summary> get { return m_Entity.RootPart; }
public virtual void HideFromAll() set { m_Entity.RootPart = value; }
{ }
foreach( SceneObjectPart part in m_Entity.Children.Values)
m_Entity.Scene.ClientManager.ForEachClient(delegate(IClientAPI controller)
{ controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); }
);
}
/// <summary> public Scene Scene
/// Makes a single SceneObjectPart see through. {
/// </summary> get { return m_Entity.Scene; }
/// <param name="part"> }
/// A <see cref="SceneObjectPart"/>
/// The part to make see through
/// </param>
/// <param name="transparencyAmount">
/// A <see cref="System.Single"/>
/// The degree of transparency to imbue the part with, 0f being solid and .95f being invisible.
/// </param>
public static void SetPartTransparency(SceneObjectPart part, float transparencyAmount)
{
LLObject.TextureEntry tex = null;
LLColor texcolor;
try
{
tex = part.Shape.Textures;
texcolor = new LLColor();
}
catch(Exception)
{
//m_log.ErrorFormat("[Content Management]: Exception thrown while accessing textures of scene object: " + e);
return;
}
for (uint i = 0; i < tex.FaceTextures.Length; i++) public LLUUID UUID
{ {
try { get { return m_Entity.UUID; }
if (tex.FaceTextures[i] != null) set { m_Entity.UUID = value; }
{ }
texcolor = tex.FaceTextures[i].RGBA;
texcolor.A = transparencyAmount; #endregion Public Properties
tex.FaceTextures[i].RGBA = texcolor;
} #region Protected Methods
}
catch (Exception) // The metaentity objectgroup must have unique localids as well as unique uuids.
{ // localids are used by the client to refer to parts.
//m_log.ErrorFormat("[Content Management]: Exception thrown while accessing different face textures of object: " + e); // uuids are sent to the client and back to the server to identify parts on the server side.
continue; /// <summary>
} /// Changes localids and uuids of m_Entity.
} /// </summary>
try { protected void Initialize(bool physics)
texcolor = tex.DefaultTexture.RGBA; {
texcolor.A = transparencyAmount; //make new uuids
tex.DefaultTexture.RGBA = texcolor; Dictionary<LLUUID, SceneObjectPart> parts = new Dictionary<LLUUID, SceneObjectPart>();
part.Shape.TextureEntry = tex.ToBytes(); foreach(SceneObjectPart part in m_Entity.Children.Values)
} {
catch (Exception) part.ResetIDs(part.LinkNum);
{ parts.Add(part.UUID, part);
//m_log.Info("[Content Management]: Exception thrown while accessing default face texture of object: " + e); }
}
} // make new localids
} foreach (SceneObjectPart part in m_Entity.Children.Values)
part.LocalId = m_Entity.Scene.PrimIDAllocate();
//finalize
m_Entity.UpdateParentIDs();
m_Entity.RootPart.PhysActor = null;
m_Entity.Children = parts;
}
#endregion Protected Methods
#region Public Methods
/// <summary>
/// Hides the metaentity from a single client.
/// </summary>
public virtual void Hide(IClientAPI client)
{
//This deletes the group without removing from any databases.
//This is important because we are not IN any database.
//m_Entity.FakeDeleteGroup();
foreach( SceneObjectPart part in m_Entity.Children.Values)
client.SendKillObject(m_Entity.RegionHandle, part.LocalId);
}
/// <summary>
/// Sends a kill object message to all clients, effectively "hiding" the metaentity even though it's still on the server.
/// </summary>
public virtual void HideFromAll()
{
foreach( SceneObjectPart part in m_Entity.Children.Values)
m_Entity.Scene.ClientManager.ForEachClient(delegate(IClientAPI controller)
{ controller.SendKillObject(m_Entity.RegionHandle, part.LocalId); }
);
}
public void SendFullUpdate(IClientAPI client)
{
// Not sure what clientFlags should be but 0 seems to work
SendFullUpdate(client, 0);
}
public void SendFullUpdate(IClientAPI client, uint clientFlags)
{
m_Entity.SendFullUpdateToClient(client, clientFlags);
}
public void SendFullUpdateToAll()
{
uint clientFlags = 0;
m_Entity.Scene.ClientManager.ForEachClient(delegate(IClientAPI controller)
{ m_Entity.SendFullUpdateToClient(controller, clientFlags); }
);
}
/// <summary>
/// Makes a single SceneObjectPart see through.
/// </summary>
/// <param name="part">
/// A <see cref="SceneObjectPart"/>
/// The part to make see through
/// </param>
/// <param name="transparencyAmount">
/// A <see cref="System.Single"/>
/// The degree of transparency to imbue the part with, 0f being solid and .95f being invisible.
/// </param>
public static void SetPartTransparency(SceneObjectPart part, float transparencyAmount)
{
LLObject.TextureEntry tex = null;
LLColor texcolor;
try
{
tex = part.Shape.Textures;
texcolor = new LLColor();
}
catch(Exception)
{
//m_log.ErrorFormat("[Content Management]: Exception thrown while accessing textures of scene object: " + e);
return;
}
for (uint i = 0; i < tex.FaceTextures.Length; i++)
{
try {
if (tex.FaceTextures[i] != null)
{
texcolor = tex.FaceTextures[i].RGBA;
texcolor.A = transparencyAmount;
tex.FaceTextures[i].RGBA = texcolor;
}
}
catch (Exception)
{
//m_log.ErrorFormat("[Content Management]: Exception thrown while accessing different face textures of object: " + e);
continue;
}
}
try {
texcolor = tex.DefaultTexture.RGBA;
texcolor.A = transparencyAmount;
tex.DefaultTexture.RGBA = texcolor;
part.Shape.TextureEntry = tex.ToBytes();
}
catch (Exception)
{
//m_log.Info("[Content Management]: Exception thrown while accessing default face texture of object: " + e);
}
}
#endregion Public Methods
}
} }

View File

@ -1,62 +1,76 @@
#region Header
// PointMetaEntity.cs created with MonoDevelop // PointMetaEntity.cs created with MonoDevelop
// User: bongiojp at 3:03 PM 8/6/2008 // User: bongiojp at 3:03 PM 8/6/2008
// //
// To change standard headers go to Edit->Preferences->Coding->Standard Headers // To change standard headers go to Edit->Preferences->Coding->Standard Headers
// //
#endregion Header
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
public class PointMetaEntity : MetaEntity
{
#region Constructors
public PointMetaEntity(Scene scene, uint LocalId, LLVector3 groupPos, float transparency)
: base()
{
CreatePointEntity(scene, LLUUID.Random(), LocalId, groupPos);
SetPartTransparency(m_Entity.RootPart, transparency);
}
public class PointMetaEntity : MetaEntity public PointMetaEntity(Scene scene, LLUUID uuid, uint LocalId, LLVector3 groupPos, float transparency)
{ : base()
{
CreatePointEntity(scene, uuid, LocalId, groupPos);
SetPartTransparency(m_Entity.RootPart, transparency);
}
public PointMetaEntity(Scene scene, uint LocalId, LLVector3 groupPos, float transparency) : base() #endregion Constructors
{
CreatePointEntity(scene, LLUUID.Random(), LocalId, groupPos);
SetPartTransparency(m_Entity.RootPart, transparency);
}
public PointMetaEntity(Scene scene, LLUUID uuid, uint LocalId, LLVector3 groupPos, float transparency) : base() #region Private Methods
{
CreatePointEntity(scene, uuid, LocalId, groupPos);
SetPartTransparency(m_Entity.RootPart, transparency);
}
private void CreatePointEntity(Scene scene, LLUUID uuid, uint LocalId, LLVector3 groupPos) private void CreatePointEntity(Scene scene, LLUUID uuid, uint LocalId, LLVector3 groupPos)
{ {
SceneObjectGroup x = new SceneObjectGroup(); SceneObjectGroup x = new SceneObjectGroup();
SceneObjectPart y = new SceneObjectPart(); SceneObjectPart y = new SceneObjectPart();
//Initialize part //Initialize part
y.Name = "Very Small Point"; y.Name = "Very Small Point";
y.RegionHandle = scene.RegionInfo.RegionHandle; y.RegionHandle = scene.RegionInfo.RegionHandle;
y.CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; y.CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
y.OwnerID = LLUUID.Zero; y.OwnerID = LLUUID.Zero;
y.CreatorID = LLUUID.Zero; y.CreatorID = LLUUID.Zero;
y.LastOwnerID = LLUUID.Zero; y.LastOwnerID = LLUUID.Zero;
y.UUID = uuid; y.UUID = uuid;
y.LocalId = LocalId; y.LocalId = LocalId;
y.Shape = PrimitiveBaseShape.CreateBox(); y.Shape = PrimitiveBaseShape.CreateBox();
y.Scale = new LLVector3(0.01f,0.01f,0.01f); y.Scale = new LLVector3(0.01f,0.01f,0.01f);
y.LastOwnerID = LLUUID.Zero; y.LastOwnerID = LLUUID.Zero;
y.GroupPosition = groupPos; y.GroupPosition = groupPos;
y.OffsetPosition = new LLVector3(0, 0, 0); y.OffsetPosition = new LLVector3(0, 0, 0);
y.RotationOffset = new LLQuaternion(0,0,0,0); y.RotationOffset = new LLQuaternion(0,0,0,0);
y.Velocity = new LLVector3(0, 0, 0); y.Velocity = new LLVector3(0, 0, 0);
y.RotationalVelocity = new LLVector3(0, 0, 0); y.RotationalVelocity = new LLVector3(0, 0, 0);
y.AngularVelocity = new LLVector3(0, 0, 0); y.AngularVelocity = new LLVector3(0, 0, 0);
@ -65,17 +79,19 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
y.Flags = 0; y.Flags = 0;
y.TrimPermissions(); y.TrimPermissions();
//Initialize group and add part as root part //Initialize group and add part as root part
x.SetScene(scene); x.SetScene(scene);
y.SetParent(x); y.SetParent(x);
y.ParentID = 0; y.ParentID = 0;
y.LinkNum = 0; y.LinkNum = 0;
x.Children.Add(y.UUID, y); x.Children.Add(y.UUID, y);
x.RootPart = y; x.RootPart = y;
x.RegionHandle = scene.RegionInfo.RegionHandle; x.RegionHandle = scene.RegionInfo.RegionHandle;
x.SetScene(scene); x.SetScene(scene);
m_Entity = x; m_Entity = x;
} }
}
#endregion Private Methods
}
} }

View File

@ -1,85 +1,111 @@
#region Header
// SceneObjectGroupDiff.cs // SceneObjectGroupDiff.cs
// User: bongiojp // User: bongiojp
#endregion Header
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using log4net;
using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Manager;
using log4net;
using Axiom.Math; using Axiom.Math;
using System.Diagnostics;
namespace OpenSim.Region.Environment.Modules.ContentManagement namespace OpenSim.Region.Environment.Modules.ContentManagement
{ {
[Flags] #region Enumerations
public enum Diff
{
NONE = 0,
FACECOLOR = 1,
SHAPE = 1<<1,
MATERIAL = 1<<2,
TEXTURE = 1<<3,
SCALE = 1<<4,
POSITION = 1<<5,
OFFSETPOSITION = 1<<6,
ROTATIONOFFSET = 1<<7,
ROTATIONALVELOCITY = 1<<8,
ACCELERATION = 1<<9,
ANGULARVELOCITY = 1<<10,
VELOCITY = 1<<11,
OBJECTOWNER = 1<<12,
PERMISSIONS = 1<<13,
DESCRIPTION = 1<<14,
NAME = 1<<15,
SCRIPT = 1<<16,
CLICKACTION = 1<<17,
PARTICLESYSTEM = 1<<18,
GLOW = 1<<19,
SALEPRICE = 1<<20,
SITNAME = 1<<21,
SITTARGETORIENTATION = 1<<22,
SITTARGETPOSITION = 1<<23,
TEXT = 1<<24,
TOUCHNAME = 1<<25
};
public static class Difference [Flags]
{ public enum Diff
static float TimeToDiff = 0; {
NONE = 0,
FACECOLOR = 1,
SHAPE = 1<<1,
MATERIAL = 1<<2,
TEXTURE = 1<<3,
SCALE = 1<<4,
POSITION = 1<<5,
OFFSETPOSITION = 1<<6,
ROTATIONOFFSET = 1<<7,
ROTATIONALVELOCITY = 1<<8,
ACCELERATION = 1<<9,
ANGULARVELOCITY = 1<<10,
VELOCITY = 1<<11,
OBJECTOWNER = 1<<12,
PERMISSIONS = 1<<13,
DESCRIPTION = 1<<14,
NAME = 1<<15,
SCRIPT = 1<<16,
CLICKACTION = 1<<17,
PARTICLESYSTEM = 1<<18,
GLOW = 1<<19,
SALEPRICE = 1<<20,
SITNAME = 1<<21,
SITTARGETORIENTATION = 1<<22,
SITTARGETPOSITION = 1<<23,
TEXT = 1<<24,
TOUCHNAME = 1<<25
}
private static readonly ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); #endregion Enumerations
private static int TruncateSignificant(float num, int digits) public static class Difference
{ {
return (int) Math.Ceiling((Math.Truncate(num * 10 * digits)/10*digits)); #region Static Fields
// return (int) ((num * (10*digits))/10*digits);
}
private static bool AreVectorsEquivalent(LLVector3 first, LLVector3 second) static float TimeToDiff = 0;
{ private static readonly ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
if(TruncateSignificant(first.X, 2) == TruncateSignificant(second.X, 2)
&& TruncateSignificant(first.Y, 2) == TruncateSignificant(second.Y, 2)
&& TruncateSignificant(first.Z, 2) == TruncateSignificant(second.Z, 2)
)
return true;
else
return false;
}
private static bool AreQuaternionsEquivalent(LLQuaternion first, LLQuaternion second) #endregion Static Fields
{
LLVector3 firstVector = llRot2Euler(first);
LLVector3 secondVector = llRot2Euler(second);
return AreVectorsEquivalent(firstVector, secondVector);
}
// Taken from Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs #region Private Methods
// Also changed the original function from LSL_Types to LL types
private static bool AreQuaternionsEquivalent(LLQuaternion first, LLQuaternion second)
{
LLVector3 firstVector = llRot2Euler(first);
LLVector3 secondVector = llRot2Euler(second);
return AreVectorsEquivalent(firstVector, secondVector);
}
private static bool AreVectorsEquivalent(LLVector3 first, LLVector3 second)
{
if(TruncateSignificant(first.X, 2) == TruncateSignificant(second.X, 2)
&& TruncateSignificant(first.Y, 2) == TruncateSignificant(second.Y, 2)
&& TruncateSignificant(first.Z, 2) == TruncateSignificant(second.Z, 2)
)
return true;
else
return false;
}
// Taken from Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
private static double NormalizeAngle(double angle)
{
angle = angle % (Math.PI * 2);
if (angle < 0) angle = angle + Math.PI * 2;
return angle;
}
private static int TruncateSignificant(float num, int digits)
{
return (int) Math.Ceiling((Math.Truncate(num * 10 * digits)/10*digits));
// return (int) ((num * (10*digits))/10*digits);
}
// Taken from Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
// Also changed the original function from LSL_Types to LL types
private static LLVector3 llRot2Euler(LLQuaternion r) private static LLVector3 llRot2Euler(LLQuaternion r)
{ {
LLQuaternion t = new LLQuaternion(r.X * r.X, r.Y * r.Y, r.Z * r.Z, r.W * r.W); LLQuaternion t = new LLQuaternion(r.X * r.X, r.Y * r.Y, r.Z * r.Z, r.W * r.W);
@ -97,73 +123,71 @@ namespace OpenSim.Region.Environment.Modules.ContentManagement
return new LLVector3(0.0f, (float)(-Math.PI / 2), (float)NormalizeAngle(Math.Atan2((r.Z * r.W + r.X * r.Y), 0.5 - t.X - t.Z))); return new LLVector3(0.0f, (float)(-Math.PI / 2), (float)NormalizeAngle(Math.Atan2((r.Z * r.W + r.X * r.Y), 0.5 - t.X - t.Z)));
} }
// Taken from Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs #endregion Private Methods
private static double NormalizeAngle(double angle)
{ #region Public Methods
angle = angle % (Math.PI * 2);
if (angle < 0) angle = angle + Math.PI * 2; /// <summary>
return angle; /// Compares the attributes (Vectors, Quaternions, Strings, etc.) between two scene object parts
/// and returns a Diff bitmask which details what the differences are.
/// </summary>
public static Diff FindDifferences(SceneObjectPart first, SceneObjectPart second)
{
Stopwatch x = new Stopwatch();
x.Start();
Diff result = 0;
// VECTOR COMPARISONS
if(! AreVectorsEquivalent(first.Acceleration, second.Acceleration))
result |= Diff.ACCELERATION;
if(! AreVectorsEquivalent(first.AbsolutePosition, second.AbsolutePosition))
result |= Diff.POSITION;
if(! AreVectorsEquivalent(first.AngularVelocity, second.AngularVelocity))
result |= Diff.ANGULARVELOCITY;
if(! AreVectorsEquivalent(first.OffsetPosition, second.OffsetPosition))
result |= Diff.OFFSETPOSITION;
if(! AreVectorsEquivalent(first.RotationalVelocity, second.RotationalVelocity))
result |= Diff.ROTATIONALVELOCITY;
if(! AreVectorsEquivalent(first.Scale, second.Scale))
result |= Diff.SCALE;
if(! AreVectorsEquivalent(first.Velocity, second.Velocity))
result |= Diff.VELOCITY;
// QUATERNION COMPARISONS
if(! AreQuaternionsEquivalent(first.RotationOffset, second.RotationOffset))
result |= Diff.ROTATIONOFFSET;
// MISC COMPARISONS (LLUUID, Byte)
if(first.ClickAction != second.ClickAction)
result |= Diff.CLICKACTION;
if(first.ObjectOwner != second.ObjectOwner)
result |= Diff.OBJECTOWNER;
// STRING COMPARISONS
if(first.Description != second.Description)
result |= Diff.DESCRIPTION;
if(first.Material != second.Material)
result |= Diff.MATERIAL;
if(first.Name != second.Name)
result |= Diff.NAME;
if(first.SitName != second.SitName)
result |= Diff.SITNAME;
if(first.Text != second.Text)
result |= Diff.TEXT;
if(first.TouchName != second.TouchName)
result |= Diff.TOUCHNAME;
x.Stop();
TimeToDiff += x.ElapsedMilliseconds;
//m_log.Info("[DIFFERENCES] Time spent diffing objects so far" + TimeToDiff);
return result;
} }
/// <summary> #endregion Public Methods
/// Compares the attributes (Vectors, Quaternions, Strings, etc.) between two scene object parts }
/// and returns a Diff bitmask which details what the differences are.
/// </summary>
public static Diff FindDifferences(SceneObjectPart first, SceneObjectPart second)
{
Stopwatch x = new Stopwatch();
x.Start();
Diff result = 0;
// VECTOR COMPARISONS
if(! AreVectorsEquivalent(first.Acceleration, second.Acceleration))
result |= Diff.ACCELERATION;
if(! AreVectorsEquivalent(first.AbsolutePosition, second.AbsolutePosition))
result |= Diff.POSITION;
if(! AreVectorsEquivalent(first.AngularVelocity, second.AngularVelocity))
result |= Diff.ANGULARVELOCITY;
if(! AreVectorsEquivalent(first.OffsetPosition, second.OffsetPosition))
result |= Diff.OFFSETPOSITION;
if(! AreVectorsEquivalent(first.RotationalVelocity, second.RotationalVelocity))
result |= Diff.ROTATIONALVELOCITY;
if(! AreVectorsEquivalent(first.Scale, second.Scale))
result |= Diff.SCALE;
if(! AreVectorsEquivalent(first.Velocity, second.Velocity))
result |= Diff.VELOCITY;
// QUATERNION COMPARISONS
if(! AreQuaternionsEquivalent(first.RotationOffset, second.RotationOffset))
result |= Diff.ROTATIONOFFSET;
// MISC COMPARISONS (LLUUID, Byte)
if(first.ClickAction != second.ClickAction)
result |= Diff.CLICKACTION;
if(first.ObjectOwner != second.ObjectOwner)
result |= Diff.OBJECTOWNER;
// STRING COMPARISONS
if(first.Description != second.Description)
result |= Diff.DESCRIPTION;
if(first.Material != second.Material)
result |= Diff.MATERIAL;
if(first.Name != second.Name)
result |= Diff.NAME;
if(first.SitName != second.SitName)
result |= Diff.SITNAME;
if(first.Text != second.Text)
result |= Diff.TEXT;
if(first.TouchName != second.TouchName)
result |= Diff.TOUCHNAME;
x.Stop();
TimeToDiff += x.ElapsedMilliseconds;
//m_log.Info("[DIFFERENCES] Time spent diffing objects so far" + TimeToDiff);
return result;
}
}
} }