* Changed SimpleApp to use EventManager and Scene timer

* Refactored a lot of m_* and public -> wrappers
afrisby
lbsa71 2007-07-17 17:47:23 +00:00
parent b3830528d1
commit d95918f228
9 changed files with 432 additions and 423 deletions

View File

@ -6,9 +6,9 @@ namespace OpenSim.Region.Environment.Scenes
{
public abstract class EntityBase
{
public LLUUID uuid;
public LLUUID m_uuid;
protected List<EntityBase> children;
protected List<EntityBase> m_children;
protected Scene m_world;
protected string m_name;
@ -82,13 +82,13 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public EntityBase()
{
uuid = new LLUUID();
m_uuid = new LLUUID();
m_pos = new LLVector3();
m_velocity = new LLVector3();
Rotation = new Quaternion();
m_name = "(basic entity)";
children = new List<EntityBase>();
m_children = new List<EntityBase>();
}
/// <summary>
@ -96,7 +96,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public virtual void updateMovement()
{
foreach (EntityBase child in children)
foreach (EntityBase child in m_children)
{
child.updateMovement();
}
@ -105,12 +105,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary>
/// Performs any updates that need to be done at each frame. This function is overridable from it's children.
/// </summary>
public virtual void update()
public virtual void Update()
{
// Do any per-frame updates needed that are applicable to every type of entity
foreach (EntityBase child in children)
foreach (EntityBase child in m_children)
{
child.update();
child.Update();
}
}

View File

@ -15,19 +15,15 @@ namespace OpenSim.Region.Environment.Scenes
{
private const uint FULL_MASK_PERMISSIONS = 2147483647;
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
private LLVector3 m_positionLastFrame = new LLVector3(0, 0, 0);
private ulong m_regionHandle;
private byte updateFlag = 0;
private byte m_updateFlag;
private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
private Dictionary<LLUUID, InventoryItem> inventoryItems;
private Dictionary<LLUUID, InventoryItem> m_inventoryItems;
private string m_description = "";
public string SitName = "";
public string TouchName = "";
public string Text = "";
public LLUUID CreatorID;
public LLUUID OwnerID;
public LLUUID LastOwnerID;
@ -52,6 +48,7 @@ namespace OpenSim.Region.Environment.Scenes
public event PrimCountTaintedDelegate OnPrimCountTainted;
#region Properties
/// <summary>
/// If rootprim, will return world position
/// otherwise will return local offset from rootprim
@ -63,11 +60,11 @@ namespace OpenSim.Region.Environment.Scenes
if (m_isRootPrim)
{
//if we are rootprim then our offset should be zero
return this.m_pos + m_Parent.Pos;
return m_pos + m_Parent.Pos;
}
else
{
return this.m_pos;
return m_pos;
}
}
set
@ -76,63 +73,72 @@ namespace OpenSim.Region.Environment.Scenes
{
m_Parent.Pos = value;
}
this.m_pos = value - m_Parent.Pos;
m_pos = value - m_Parent.Pos;
}
}
public PrimitiveBaseShape Shape
{
get
{
return this.m_Shape;
}
get { return m_Shape; }
}
public LLVector3 WorldPos
{
get
{
if (!this.m_isRootPrim)
if (!m_isRootPrim)
{
Primitive parentPrim = (Primitive)this.m_Parent;
Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z);
Primitive parentPrim = (Primitive)m_Parent;
Vector3 offsetPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z);
offsetPos = parentPrim.Rotation * offsetPos;
return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z);
}
else
{
return this.Pos;
return Pos;
}
}
}
public string Description
{
get
{
return this.m_description;
}
set
{
this.m_description = value;
}
get { return m_description; }
set { m_description = value; }
}
public LLVector3 Scale
{
set { m_Shape.Scale = value; }
get { return m_Shape.Scale; }
}
private string m_sitName = "";
public string SitName
{
get { return m_sitName; }
}
private string m_touchName = "";
public string TouchName
{
get { return m_touchName; }
}
private string m_text = "";
public string Text
{
get { return m_text; }
set
{
this.m_Shape.Scale = value;
}
get
{
return this.m_Shape.Scale;
m_text = value;
ScheduleFullUpdate();
}
}
#endregion
#region Constructors
/// <summary>
///
/// </summary>
@ -144,21 +150,23 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="isRoot"></param>
/// <param name="parent"></param>
/// <param name="rootObject"></param>
public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos)
public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent,
SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos)
{
m_regionHandle = regionHandle;
m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.m_Parent = parent;
this.m_isRootPrim = isRoot;
this.m_RootParent = rootObject;
this.CreateFromShape(ownerID, localID, pos, shape);
this.Rotation = Axiom.Math.Quaternion.Identity;
m_inventoryItems = new Dictionary<LLUUID, InventoryItem>();
m_Parent = parent;
m_isRootPrim = isRoot;
m_RootParent = rootObject;
ClearUpdateSchedule();
CreateFromShape(ownerID, localID, pos, shape);
Rotation = Quaternion.Identity;
m_world.AcknowledgeNewPrim(this);
this.OnPrimCountTainted();
OnPrimCountTainted();
}
/// <summary>
@ -167,7 +175,6 @@ namespace OpenSim.Region.Environment.Scenes
/// <remarks>Empty constructor for duplication</remarks>
public Primitive()
{
}
#endregion
@ -176,28 +183,29 @@ namespace OpenSim.Region.Environment.Scenes
~Primitive()
{
this.OnPrimCountTainted();
OnPrimCountTainted();
}
#endregion
#region Duplication
public Primitive Copy(EntityBase parent, SceneObject rootParent)
{
Primitive dupe = (Primitive)this.MemberwiseClone();
Primitive dupe = (Primitive)MemberwiseClone();
dupe.m_Parent = parent;
dupe.m_RootParent = rootParent;
// TODO: Copy this properly.
dupe.inventoryItems = this.inventoryItems;
dupe.children = new List<EntityBase>();
dupe.m_Shape = this.m_Shape.Copy();
dupe.m_regionHandle = this.m_regionHandle;
dupe.m_world = this.m_world;
dupe.m_inventoryItems = m_inventoryItems;
dupe.m_children = new List<EntityBase>();
dupe.m_Shape = m_Shape.Copy();
dupe.m_regionHandle = m_regionHandle;
dupe.m_world = m_world;
uint newLocalID = this.m_world.PrimIDAllocate();
dupe.uuid = LLUUID.Random();
uint newLocalID = m_world.PrimIDAllocate();
dupe.m_uuid = LLUUID.Random();
dupe.LocalId = newLocalID;
if (parent is SceneObject)
@ -211,18 +219,18 @@ namespace OpenSim.Region.Environment.Scenes
dupe.ParentID = ((Primitive)parent).LocalId;
}
dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z);
dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
dupe.m_pos = new LLVector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z);
dupe.Scale = new LLVector3(Scale.X, Scale.Y, Scale.Z);
dupe.Rotation = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z);
dupe.m_pos = new LLVector3(m_pos.X, m_pos.Y, m_pos.Z);
rootParent.AddChildToList(dupe);
this.m_world.AcknowledgeNewPrim(dupe);
m_world.AcknowledgeNewPrim(dupe);
dupe.TriggerOnPrimCountTainted();
foreach (Primitive prim in this.children)
foreach (Primitive prim in m_children)
{
Primitive primClone = prim.Copy(dupe, rootParent);
dupe.children.Add(primClone);
dupe.m_children.Add(primClone);
}
return dupe;
@ -231,30 +239,41 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
#region Override from EntityBase
/// <summary>
///
/// </summary>
public override void update()
public override void Update()
{
if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes
if (m_updateFlag == 1) //some change has been made so update the clients
{
this.SendFullUpdateToAllClients();
this.updateFlag = 0;
SendTerseUpdateToALLClients();
ClearUpdateSchedule();
}
if (this.updateFlag == 2) //some change has been made so update the clients
else
{
this.SendTerseUpdateToALLClients();
this.updateFlag = 0;
if (m_updateFlag == 2) // is a new prim just been created/reloaded or has major changes
{
SendFullUpdateToAllClients();
ClearUpdateSchedule();
}
}
foreach (EntityBase child in children)
foreach (EntityBase child in m_children)
{
child.update();
child.Update();
}
}
private void ClearUpdateSchedule()
{
m_updateFlag = 0;
}
#endregion
#region Setup
/// <summary>
///
/// </summary>
@ -263,21 +282,36 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="localID"></param>
public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
{
this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
this.OwnerID = ownerID;
this.CreatorID = this.OwnerID;
this.LastOwnerID = LLUUID.Zero;
this.Pos = pos;
this.uuid = LLUUID.Random();
this.m_localId = (uint)(localID);
CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
OwnerID = ownerID;
CreatorID = OwnerID;
LastOwnerID = LLUUID.Zero;
Pos = pos;
m_uuid = LLUUID.Random();
m_localId = (uint)(localID);
this.m_Shape = shape;
this.updateFlag = 1;
m_Shape = shape;
ScheduleFullUpdate();
}
private void ScheduleFullUpdate()
{
m_updateFlag = 2;
}
private void ScheduleTerseUpdate()
{
if (m_updateFlag < 1)
{
m_updateFlag = 1;
}
}
#endregion
#region Linking / unlinking
/// <summary>
///
/// </summary>
@ -286,13 +320,13 @@ namespace OpenSim.Region.Environment.Scenes
{
// Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")");
//TODO check permissions
this.children.Add(linkObject.rootPrimitive);
linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent);
m_children.Add(linkObject.rootPrimitive);
linkObject.rootPrimitive.SetNewParent(this, m_RootParent);
this.m_world.DeleteEntity(linkObject.rootUUID);
m_world.DeleteEntity(linkObject.rootUUID);
linkObject.DeleteAllChildren();
this.OnPrimCountTainted();
OnPrimCountTainted();
}
/// <summary>
@ -302,59 +336,58 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="rootParent"></param>
public void SetNewParent(Primitive newParent, SceneObject rootParent)
{
LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
this.m_isRootPrim = false;
this.m_Parent = newParent;
this.ParentID = newParent.LocalId;
this.m_RootParent = rootParent;
this.m_RootParent.AddChildToList(this);
this.Pos = oldPos;
Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
axPos = this.m_Parent.Rotation.Inverse() * axPos;
this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
this.Rotation = this.m_Parent.Rotation.Inverse() * this.Rotation;
this.updateFlag = 1;
LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
m_isRootPrim = false;
m_Parent = newParent;
ParentID = newParent.LocalId;
m_RootParent = rootParent;
m_RootParent.AddChildToList(this);
Pos = oldPos;
Vector3 axPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z);
axPos = m_Parent.Rotation.Inverse() * axPos;
m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
Quaternion oldRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z);
Rotation = m_Parent.Rotation.Inverse() * Rotation;
ScheduleFullUpdate();
foreach (Primitive child in children)
foreach (Primitive child in m_children)
{
child.SetRootParent(rootParent, newParent, oldPos, oldRot);
}
children.Clear();
m_children.Clear();
}
/// <summary>
///
/// </summary>
/// <param name="newRoot"></param>
public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition, Axiom.Math.Quaternion oldParentRotation)
public void SetRootParent(SceneObject newRoot, Primitive newParent, LLVector3 oldParentPosition,
Quaternion oldParentRotation)
{
LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z);
LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z);
axOldPos = oldParentRotation * axOldPos;
oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z);
oldPos += oldParentPosition;
Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
this.m_isRootPrim = false;
this.m_Parent = newParent;
this.ParentID = newParent.LocalId;
Quaternion oldRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z);
m_isRootPrim = false;
m_Parent = newParent;
ParentID = newParent.LocalId;
newParent.AddToChildrenList(this);
this.m_RootParent = newRoot;
this.m_RootParent.AddChildToList(this);
this.Pos = oldPos;
Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
axPos = this.m_Parent.Rotation.Inverse() * axPos;
this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
this.Rotation = oldParentRotation * this.Rotation;
this.Rotation = this.m_Parent.Rotation.Inverse()* this.Rotation ;
this.updateFlag = 1;
foreach (Primitive child in children)
m_RootParent = newRoot;
m_RootParent.AddChildToList(this);
Pos = oldPos;
Vector3 axPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z);
axPos = m_Parent.Rotation.Inverse() * axPos;
m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
Rotation = oldParentRotation * Rotation;
Rotation = m_Parent.Rotation.Inverse() * Rotation;
ScheduleFullUpdate();
foreach (Primitive child in m_children)
{
child.SetRootParent(newRoot, newParent, oldPos, oldRot);
}
children.Clear();
m_children.Clear();
}
/// <summary>
@ -363,12 +396,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="offset"></param>
public void AddOffsetToChildren(LLVector3 offset)
{
foreach (Primitive prim in this.children)
foreach (Primitive prim in m_children)
{
prim.m_pos += offset;
prim.updateFlag = 2;
prim.ScheduleTerseUpdate();
}
this.OnPrimCountTainted();
OnPrimCountTainted();
}
/// <summary>
@ -377,38 +410,42 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="prim"></param>
public void AddToChildrenList(Primitive prim)
{
this.children.Add(prim);
m_children.Add(prim);
}
#endregion
#region Resizing/Scale
/// <summary>
///
/// </summary>
/// <param name="scale"></param>
public void ResizeGoup(LLVector3 scale)
{
LLVector3 offset = (scale - this.m_Shape.Scale);
LLVector3 offset = (scale - m_Shape.Scale);
offset.X /= 2;
offset.Y /= 2;
offset.Z /= 2;
if (this.m_isRootPrim)
if (m_isRootPrim)
{
this.m_Parent.Pos += offset;
m_Parent.Pos += offset;
}
else
{
this.m_pos += offset;
m_pos += offset;
}
this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z));
this.m_Shape.Scale = scale;
AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z));
m_Shape.Scale = scale;
this.updateFlag = 1;
ScheduleFullUpdate();
}
#endregion
#region Position
/// <summary>
///
/// </summary>
@ -417,10 +454,10 @@ namespace OpenSim.Region.Environment.Scenes
{
LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
this.Pos = newPos;
this.updateFlag = 2;
Pos = newPos;
ScheduleTerseUpdate();
this.OnPrimCountTainted();
OnPrimCountTainted();
}
/// <summary>
@ -430,47 +467,45 @@ namespace OpenSim.Region.Environment.Scenes
public void UpdateSinglePosition(LLVector3 pos)
{
// Console.WriteLine("updating single prim position");
if (this.m_isRootPrim)
if (m_isRootPrim)
{
LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
LLVector3 diff = oldPos - newPos;
Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z);
axDiff = this.Rotation.Inverse() * axDiff;
Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z);
axDiff = Rotation.Inverse() * axDiff;
diff.X = axDiff.x;
diff.Y = axDiff.y;
diff.Z = axDiff.z;
this.Pos = newPos;
Pos = newPos;
foreach (Primitive prim in this.children)
foreach (Primitive prim in m_children)
{
prim.m_pos += diff;
prim.updateFlag = 2;
prim.ScheduleTerseUpdate();
}
this.updateFlag = 2;
ScheduleTerseUpdate();
}
else
{
LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
this.m_pos = newPos;
this.updateFlag = 2;
m_pos = newPos;
ScheduleTerseUpdate();
}
}
#endregion
#region Rotation
/// <summary>
///
/// </summary>
/// <param name="rot"></param>
public void UpdateGroupRotation(LLQuaternion rot)
{
this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
this.updateFlag = 2;
Rotation = new Quaternion(rot.W, rot.X, rot.Y, rot.Z);
ScheduleTerseUpdate();
}
/// <summary>
@ -480,9 +515,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="rot"></param>
public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot)
{
this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
this.Pos = pos;
this.updateFlag = 2;
Rotation = new Quaternion(rot.W, rot.X, rot.Y, rot.Z);
Pos = pos;
ScheduleTerseUpdate();
}
/// <summary>
@ -492,62 +527,67 @@ namespace OpenSim.Region.Environment.Scenes
public void UpdateSingleRotation(LLQuaternion rot)
{
//Console.WriteLine("updating single prim rotation");
Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
Axiom.Math.Quaternion oldParentRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
this.Rotation = axRot;
foreach (Primitive prim in this.children)
Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z);
Quaternion oldParentRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z);
Rotation = axRot;
foreach (Primitive prim in m_children)
{
Axiom.Math.Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z);
Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z);
axPos = oldParentRot * axPos;
axPos = axRot.Inverse() * axPos;
prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
prim.Rotation = oldParentRot * prim.Rotation ;
prim.Rotation = axRot.Inverse()* prim.Rotation;
prim.updateFlag = 2;
prim.Rotation = oldParentRot * prim.Rotation;
prim.Rotation = axRot.Inverse() * prim.Rotation;
prim.ScheduleTerseUpdate();
}
this.updateFlag = 2;
ScheduleTerseUpdate();
}
#endregion
#region Shape
/// <summary>
///
/// </summary>
/// <param name="shapeBlock"></param>
public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock)
{
this.m_Shape.PathBegin = shapeBlock.PathBegin;
this.m_Shape.PathEnd = shapeBlock.PathEnd;
this.m_Shape.PathScaleX = shapeBlock.PathScaleX;
this.m_Shape.PathScaleY = shapeBlock.PathScaleY;
this.m_Shape.PathShearX = shapeBlock.PathShearX;
this.m_Shape.PathShearY = shapeBlock.PathShearY;
this.m_Shape.PathSkew = shapeBlock.PathSkew;
this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin;
this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd;
this.m_Shape.PathCurve = shapeBlock.PathCurve;
this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve;
this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow;
this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset;
this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions;
this.m_Shape.PathTaperX = shapeBlock.PathTaperX;
this.m_Shape.PathTaperY = shapeBlock.PathTaperY;
this.m_Shape.PathTwist = shapeBlock.PathTwist;
this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin;
this.updateFlag = 1;
m_Shape.PathBegin = shapeBlock.PathBegin;
m_Shape.PathEnd = shapeBlock.PathEnd;
m_Shape.PathScaleX = shapeBlock.PathScaleX;
m_Shape.PathScaleY = shapeBlock.PathScaleY;
m_Shape.PathShearX = shapeBlock.PathShearX;
m_Shape.PathShearY = shapeBlock.PathShearY;
m_Shape.PathSkew = shapeBlock.PathSkew;
m_Shape.ProfileBegin = shapeBlock.ProfileBegin;
m_Shape.ProfileEnd = shapeBlock.ProfileEnd;
m_Shape.PathCurve = shapeBlock.PathCurve;
m_Shape.ProfileCurve = shapeBlock.ProfileCurve;
m_Shape.ProfileHollow = shapeBlock.ProfileHollow;
m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset;
m_Shape.PathRevolutions = shapeBlock.PathRevolutions;
m_Shape.PathTaperX = shapeBlock.PathTaperX;
m_Shape.PathTaperY = shapeBlock.PathTaperY;
m_Shape.PathTwist = shapeBlock.PathTwist;
m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin;
ScheduleFullUpdate();
}
#endregion
#region Texture
/// <summary>
///
/// </summary>
/// <param name="textureEntry"></param>
public void UpdateTextureEntry(byte[] textureEntry)
{
this.m_Shape.TextureEntry = textureEntry;
this.updateFlag = 1;
m_Shape.TextureEntry = textureEntry;
ScheduleFullUpdate();
}
#endregion
#region Client Update Methods
@ -558,12 +598,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="remoteClient"></param>
public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
{
this.SendFullUpdateToClient(remoteClient);
for (int i = 0; i < this.children.Count; i++)
SendFullUpdateToClient(remoteClient);
for (int i = 0; i < m_children.Count; i++)
{
if (this.children[i] is Primitive)
if (m_children[i] is Primitive)
{
((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
((Primitive)m_children[i]).SendFullUpdateForAllChildren(remoteClient);
}
}
}
@ -575,11 +615,12 @@ namespace OpenSim.Region.Environment.Scenes
public void SendFullUpdateToClient(IClientAPI remoteClient)
{
LLVector3 lPos;
lPos = this.Pos;
lPos = Pos;
LLQuaternion lRot;
lRot = new LLQuaternion(this.Rotation.x, this.Rotation.y, this.Rotation.z, this.Rotation.w);
lRot = new LLQuaternion(Rotation.x, Rotation.y, Rotation.z, Rotation.w);
remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, lRot, this.m_flags, this.uuid, this.OwnerID, this.Text, this.ParentID);
remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalId, m_Shape, lPos, lRot, m_flags, m_uuid,
OwnerID, m_text, ParentID);
}
/// <summary>
@ -587,10 +628,10 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public void SendFullUpdateToAllClients()
{
List<ScenePresence> avatars = this.m_world.RequestAvatarList();
List<ScenePresence> avatars = m_world.RequestAvatarList();
for (int i = 0; i < avatars.Count; i++)
{
this.SendFullUpdateToClient(avatars[i].ControllingClient);
SendFullUpdateToClient(avatars[i].ControllingClient);
}
}
@ -600,12 +641,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="remoteClient"></param>
public void SendTerseUpdateForAllChildren(IClientAPI remoteClient)
{
this.SendTerseUpdateToClient(remoteClient);
for (int i = 0; i < this.children.Count; i++)
SendTerseUpdateToClient(remoteClient);
for (int i = 0; i < m_children.Count; i++)
{
if (this.children[i] is Primitive)
if (m_children[i] is Primitive)
{
((Primitive)this.children[i]).SendTerseUpdateForAllChildren(remoteClient);
((Primitive)m_children[i]).SendTerseUpdateForAllChildren(remoteClient);
}
}
}
@ -619,11 +660,11 @@ namespace OpenSim.Region.Environment.Scenes
LLVector3 lPos;
Quaternion lRot;
lPos = this.Pos;
lRot = this.Rotation;
lPos = Pos;
lRot = Rotation;
LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w);
RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot);
RemoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalId, lPos, mRot);
}
/// <summary>
@ -631,10 +672,10 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public void SendTerseUpdateToALLClients()
{
List<ScenePresence> avatars = this.m_world.RequestAvatarList();
List<ScenePresence> avatars = m_world.RequestAvatarList();
for (int i = 0; i < avatars.Count; i++)
{
this.SendTerseUpdateToClient(avatars[i].ControllingClient);
SendTerseUpdateToClient(avatars[i].ControllingClient);
}
}
@ -642,7 +683,7 @@ namespace OpenSim.Region.Environment.Scenes
public void TriggerOnPrimCountTainted()
{
this.OnPrimCountTainted();
OnPrimCountTainted();
}
}
}

View File

@ -30,7 +30,6 @@ using System.Collections.Generic;
using System.Threading;
using System.Timers;
using libsecondlife;
using libsecondlife.Packets;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Console;
@ -39,17 +38,16 @@ using OpenSim.Framework.Servers;
using OpenSim.Framework.Types;
using OpenSim.Physics.Manager;
using OpenSim.Region.Caches;
using OpenSim.Region.Interfaces;
using OpenSim.Region.Environment.LandManagement;
using OpenSim.Region.Scripting;
using OpenSim.Region.Terrain;
using Caps = OpenSim.Region.Capabilities.Caps;
using Timer = System.Timers.Timer;
using OpenSim.Region.Environment.LandManagement;
using Caps=OpenSim.Region.Capabilities.Caps;
using Timer=System.Timers.Timer;
namespace OpenSim.Region.Environment.Scenes
{
public delegate bool FilterAvatarList(ScenePresence avatar);
public delegate void ForEachScenePresenceDelegate(ScenePresence presence);
public partial class Scene : SceneBase, ILocalStorageReceiver
@ -61,7 +59,7 @@ namespace OpenSim.Region.Environment.Scenes
protected float timeStep = 0.1f;
private Random Rand = new Random();
private uint _primCount = 702000;
private System.Threading.Mutex _primAllocateMutex = new Mutex(false);
private Mutex _primAllocateMutex = new Mutex(false);
private int storageCount;
private int landPrimCheckCount;
private Mutex updateLock;
@ -75,40 +73,39 @@ namespace OpenSim.Region.Environment.Scenes
protected BaseHttpServer httpListener;
#region Properties
/// <summary>
///
/// </summary>
public PhysicsScene PhysScene
{
set
{
this.phyScene = value;
}
get
{
return (this.phyScene);
}
set { phyScene = value; }
get { return (phyScene); }
}
private LandManager m_LandManager;
public LandManager LandManager
{
get { return m_LandManager; }
}
private EstateManager m_estateManager;
public EstateManager EstateManager
{
get { return m_estateManager; }
}
private EventManager m_eventManager;
public EventManager EventManager
{
get { return m_eventManager; }
}
private ScriptManager m_scriptManager;
public ScriptManager ScriptManager
{
get { return m_scriptManager; }
@ -122,31 +119,34 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
#region Constructors
/// <summary>
/// Creates a new World class, and a region to go with it.
/// </summary>
/// <param name="clientThreads">Dictionary to contain client threads</param>
/// <param name="regionHandle">Region Handle for this region</param>
/// <param name="regionName">Region Name for this region</param>
public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer)
public Scene(RegionInfo regInfo, AgentCircuitManager authen, CommunicationsManager commsMan,
AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer)
{
updateLock = new Mutex(false);
this.authenticateHandler = authen;
this.commsManager = commsMan;
this.storageManager = storeManager;
this.assetCache = assetCach;
authenticateHandler = authen;
commsManager = commsMan;
storageManager = storeManager;
assetCache = assetCach;
m_regInfo = regInfo;
m_regionHandle = m_regInfo.RegionHandle;
m_regionName = m_regInfo.RegionName;
this.m_datastore = m_regInfo.DataStore;
this.RegisterRegionWithComms();
m_datastore = m_regInfo.DataStore;
RegisterRegionWithComms();
m_LandManager = new LandManager(this, this.m_regInfo);
m_estateManager = new EstateManager(this, this.m_regInfo);
m_LandManager = new LandManager(this, m_regInfo);
m_estateManager = new EstateManager(this, m_regInfo);
m_scriptManager = new ScriptManager(this);
m_eventManager = new EventManager();
m_eventManager.OnParcelPrimCountAdd += new EventManager.OnParcelPrimCountAddDelegate(m_LandManager.addPrimToLandPrimCounts);
m_eventManager.OnParcelPrimCountAdd +=
new EventManager.OnParcelPrimCountAddDelegate(m_LandManager.addPrimToLandPrimCounts);
MainLog.Instance.Verbose("World.cs - creating new entitities instance");
Entities = new Dictionary<LLUUID, EntityBase>();
@ -167,8 +167,9 @@ namespace OpenSim.Region.Environment.Scenes
ScenePresence.LoadAnims();
this.httpListener = httpServer;
httpListener = httpServer;
}
#endregion
#region Script Handling Methods
@ -187,21 +188,19 @@ namespace OpenSim.Region.Environment.Scenes
{
m_heartbeatTimer.Enabled = true;
m_heartbeatTimer.Interval = 100;
m_heartbeatTimer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
}
#region Update Methods
/// <summary>
/// Performs per-frame updates regularly
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Heartbeat(object sender, EventArgs e)
private void Heartbeat(object sender, EventArgs e)
{
this.Update();
Update();
}
/// <summary>
@ -212,10 +211,9 @@ namespace OpenSim.Region.Environment.Scenes
updateLock.WaitOne();
try
{
if (this.phyScene.IsThreaded)
if (phyScene.IsThreaded)
{
this.phyScene.GetResults();
phyScene.GetResults();
}
foreach (LLUUID UUID in Entities.Keys)
@ -223,45 +221,43 @@ namespace OpenSim.Region.Environment.Scenes
Entities[UUID].updateMovement();
}
lock (this.m_syncRoot)
lock (m_syncRoot)
{
this.phyScene.Simulate(timeStep);
phyScene.Simulate(timeStep);
}
foreach (LLUUID UUID in Entities.Keys)
{
Entities[UUID].update();
Entities[UUID].Update();
}
// General purpose event manager
m_eventManager.TriggerOnFrame();
//backup world data
this.storageCount++;
storageCount++;
if (storageCount > 1200) //set to how often you want to backup
{
this.Backup();
Backup();
storageCount = 0;
}
this.landPrimCheckCount++;
if (this.landPrimCheckCount > 50) //check every 5 seconds for tainted prims
landPrimCheckCount++;
if (landPrimCheckCount > 50) //check every 5 seconds for tainted prims
{
if (m_LandManager.landPrimCountTainted)
{
//Perform land update of prim count
performParcelPrimCountUpdate();
this.landPrimCheckCount = 0;
landPrimCheckCount = 0;
}
}
}
catch (Exception e)
{
MainLog.Instance.Warn("World.cs: Update() - Failed with exception " + e.ToString());
}
updateLock.ReleaseMutex();
}
/// <summary>
@ -270,9 +266,10 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns>
public bool Backup()
{
EventManager.TriggerOnBackup(this.storageManager.DataStore);
EventManager.TriggerOnBackup(storageManager.DataStore);
return true;
}
#endregion
#region Regenerate Terrain
@ -286,16 +283,16 @@ namespace OpenSim.Region.Environment.Scenes
{
Terrain.hills();
lock (this.m_syncRoot)
lock (m_syncRoot)
{
this.phyScene.SetTerrain(Terrain.getHeights1D());
phyScene.SetTerrain(Terrain.getHeights1D());
}
this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
this.ForEachScenePresence(delegate(ScenePresence presence)
ForEachScenePresence(delegate(ScenePresence presence)
{
this.SendLayerData(presence.ControllingClient);
SendLayerData(presence.ControllingClient);
});
foreach (LLUUID UUID in Entities.Keys)
@ -317,16 +314,16 @@ namespace OpenSim.Region.Environment.Scenes
{
try
{
this.Terrain.setHeights2D(newMap);
lock (this.m_syncRoot)
Terrain.setHeights2D(newMap);
lock (m_syncRoot)
{
this.phyScene.SetTerrain(this.Terrain.getHeights1D());
phyScene.SetTerrain(Terrain.getHeights1D());
}
this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
this.ForEachScenePresence(delegate(ScenePresence presence)
ForEachScenePresence(delegate(ScenePresence presence)
{
this.SendLayerData(presence.ControllingClient);
SendLayerData(presence.ControllingClient);
});
foreach (LLUUID UUID in Entities.Keys)
@ -354,9 +351,9 @@ namespace OpenSim.Region.Environment.Scenes
{
/* Dont save here, rely on tainting system instead */
this.ForEachScenePresence(delegate(ScenePresence presence)
ForEachScenePresence(delegate(ScenePresence presence)
{
this.SendLayerData(pointx, pointy, presence.ControllingClient);
SendLayerData(pointx, pointy, presence.ControllingClient);
});
}
}
@ -369,6 +366,7 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
#region Load Terrain
/// <summary>
/// Loads the World heightmap
/// </summary>
@ -377,38 +375,37 @@ namespace OpenSim.Region.Environment.Scenes
{
try
{
double[,] map = this.storageManager.DataStore.LoadTerrain();
double[,] map = storageManager.DataStore.LoadTerrain();
if (map == null)
{
if (string.IsNullOrEmpty(this.m_regInfo.estateSettings.terrainFile))
if (string.IsNullOrEmpty(m_regInfo.estateSettings.terrainFile))
{
Console.WriteLine("No default terrain, procedurally generating...");
this.Terrain.hills();
Terrain.hills();
this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD());
storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
}
else
{
try
{
this.Terrain.loadFromFileF32(this.m_regInfo.estateSettings.terrainFile);
this.Terrain *= this.m_regInfo.estateSettings.terrainMultiplier;
Terrain.loadFromFileF32(m_regInfo.estateSettings.terrainFile);
Terrain *= m_regInfo.estateSettings.terrainMultiplier;
}
catch
{
Console.WriteLine("Unable to load default terrain, procedurally generating instead...");
Terrain.hills();
}
this.storageManager.DataStore.StoreTerrain(this.Terrain.getHeights2DD());
storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
}
}
else
{
this.Terrain.setHeights2D(map);
Terrain.setHeights2D(map);
}
CreateTerrainTexture();
}
catch (Exception e)
{
@ -422,27 +419,27 @@ namespace OpenSim.Region.Environment.Scenes
public void CreateTerrainTexture()
{
//create a texture asset of the terrain
byte[] data = this.Terrain.exportJpegImage("defaultstripe.png");
this.m_regInfo.estateSettings.terrainImageID = LLUUID.Random();
byte[] data = Terrain.exportJpegImage("defaultstripe.png");
m_regInfo.estateSettings.terrainImageID = LLUUID.Random();
AssetBase asset = new AssetBase();
asset.FullID = this.m_regInfo.estateSettings.terrainImageID;
asset.FullID = m_regInfo.estateSettings.terrainImageID;
asset.Data = data;
asset.Name = "terrainImage";
asset.Type = 0;
this.assetCache.AddAsset(asset);
assetCache.AddAsset(asset);
}
#endregion
#region Primitives Methods
/// <summary>
/// Loads the World's objects
/// </summary>
public void LoadPrimsFromStorage()
{
MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives");
this.localStorage.LoadPrimitives(this);
localStorage.LoadPrimitives(this);
}
/// <summary>
@ -476,8 +473,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="ownerID"></param>
public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape)
{
SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, this.PrimIDAllocate(), pos, shape);
SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, PrimIDAllocate(), pos, shape);
AddEntity(sceneOb);
}
@ -487,27 +483,26 @@ namespace OpenSim.Region.Environment.Scenes
{
if (obj is SceneObject)
{
if (((SceneObject)obj).LocalId == localID)
if (((SceneObject) obj).LocalId == localID)
{
RemoveEntity((SceneObject)obj);
RemoveEntity((SceneObject) obj);
return;
}
}
}
}
public void AddEntity(SceneObject sceneObject)
{
this.Entities.Add(sceneObject.rootUUID, sceneObject);
Entities.Add(sceneObject.rootUUID, sceneObject);
}
public void RemoveEntity(SceneObject sceneObject)
{
if (this.Entities.ContainsKey(sceneObject.rootUUID))
if (Entities.ContainsKey(sceneObject.rootUUID))
{
m_LandManager.removePrimFromLandPrimCounts(sceneObject);
this.Entities.Remove(sceneObject.rootUUID);
Entities.Remove(sceneObject.rootUUID);
m_LandManager.setPrimsTainted();
}
}
@ -520,6 +515,7 @@ namespace OpenSim.Region.Environment.Scenes
{
prim.OnPrimCountTainted += m_LandManager.setPrimsTainted;
}
#endregion
#region Add/Remove Avatar Methods
@ -533,48 +529,48 @@ namespace OpenSim.Region.Environment.Scenes
public override void AddNewClient(IClientAPI client, bool child)
{
SubscribeToClientEvents(client);
this.m_estateManager.sendRegionHandshake(client);
m_estateManager.sendRegionHandshake(client);
CreateAndAddScenePresence(client);
this.m_LandManager.sendParcelOverlay(client);
m_LandManager.sendParcelOverlay(client);
}
protected virtual void SubscribeToClientEvents(IClientAPI client)
{
client.OnRegionHandShakeReply += this.SendLayerData;
client.OnRegionHandShakeReply += SendLayerData;
//remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
client.OnChatFromViewer += this.SimChat;
client.OnInstantMessage += this.InstantMessage;
client.OnRequestWearables += this.InformClientOfNeighbours;
client.OnAddPrim += this.AddNewPrim;
client.OnUpdatePrimGroupPosition += this.UpdatePrimPosition;
client.OnUpdatePrimSinglePosition += this.UpdatePrimSinglePosition;
client.OnUpdatePrimGroupRotation += this.UpdatePrimRotation;
client.OnUpdatePrimGroupMouseRotation += this.UpdatePrimRotation;
client.OnUpdatePrimSingleRotation += this.UpdatePrimSingleRotation;
client.OnUpdatePrimScale += this.UpdatePrimScale;
client.OnUpdatePrimShape += this.UpdatePrimShape;
client.OnRequestMapBlocks += this.RequestMapBlocks;
client.OnUpdatePrimTexture += this.UpdatePrimTexture;
client.OnTeleportLocationRequest += this.RequestTeleportLocation;
client.OnObjectSelect += this.SelectPrim;
client.OnObjectDeselect += this.DeselectPrim;
client.OnGrapUpdate += this.MoveObject;
client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest;
client.OnObjectDescription += this.PrimDescription;
client.OnObjectName += this.PrimName;
client.OnLinkObjects += this.LinkObjects;
client.OnObjectDuplicate += this.DuplicateObject;
client.OnChatFromViewer += SimChat;
client.OnInstantMessage += InstantMessage;
client.OnRequestWearables += InformClientOfNeighbours;
client.OnAddPrim += AddNewPrim;
client.OnUpdatePrimGroupPosition += UpdatePrimPosition;
client.OnUpdatePrimSinglePosition += UpdatePrimSinglePosition;
client.OnUpdatePrimGroupRotation += UpdatePrimRotation;
client.OnUpdatePrimGroupMouseRotation += UpdatePrimRotation;
client.OnUpdatePrimSingleRotation += UpdatePrimSingleRotation;
client.OnUpdatePrimScale += UpdatePrimScale;
client.OnUpdatePrimShape += UpdatePrimShape;
client.OnRequestMapBlocks += RequestMapBlocks;
client.OnUpdatePrimTexture += UpdatePrimTexture;
client.OnTeleportLocationRequest += RequestTeleportLocation;
client.OnObjectSelect += SelectPrim;
client.OnObjectDeselect += DeselectPrim;
client.OnGrapUpdate += MoveObject;
client.OnNameFromUUIDRequest += commsManager.HandleUUIDNameRequest;
client.OnObjectDescription += PrimDescription;
client.OnObjectName += PrimName;
client.OnLinkObjects += LinkObjects;
client.OnObjectDuplicate += DuplicateObject;
client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_LandManager.handleParcelPropertiesRequest);
client.OnParcelDivideRequest += new ParcelDivideRequest(m_LandManager.handleParcelDivideRequest);
client.OnParcelJoinRequest += new ParcelJoinRequest(m_LandManager.handleParcelJoinRequest);
client.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(m_LandManager.handleParcelPropertiesUpdateRequest);
client.OnParcelPropertiesUpdateRequest +=
new ParcelPropertiesUpdateRequest(m_LandManager.handleParcelPropertiesUpdateRequest);
client.OnParcelSelectObjects += new ParcelSelectObjects(m_LandManager.handleParcelSelectObjectsRequest);
client.OnParcelObjectOwnerRequest += new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest);
client.OnParcelObjectOwnerRequest +=
new ParcelObjectOwnerRequest(m_LandManager.handleParcelObjectOwnersRequest);
client.OnEstateOwnerMessage += new EstateOwnerMessageRequest(m_estateManager.handleEstateOwnerMessage);
}
protected ScenePresence CreateAndAddScenePresence(IClientAPI client)
@ -582,21 +578,21 @@ namespace OpenSim.Region.Environment.Scenes
ScenePresence newAvatar = null;
MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
newAvatar = new ScenePresence(client, this, this.m_regInfo);
newAvatar = new ScenePresence(client, this, m_regInfo);
MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Adding new avatar to world");
MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Starting RegionHandshake ");
PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
lock (this.m_syncRoot)
lock (m_syncRoot)
{
newAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
newAvatar.PhysActor = phyScene.AddAvatar(pVec);
}
lock (Entities)
{
if (!Entities.ContainsKey(client.AgentId))
{
this.Entities.Add(client.AgentId, newAvatar);
Entities.Add(client.AgentId, newAvatar);
}
else
{
@ -611,7 +607,7 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
this.Avatars.Add(client.AgentId, newAvatar);
Avatars.Add(client.AgentId, newAvatar);
}
}
newAvatar.OnSignificantClientMovement += m_LandManager.handleSignificantClientMovement;
@ -627,9 +623,9 @@ namespace OpenSim.Region.Environment.Scenes
{
m_eventManager.TriggerOnRemovePresence(agentID);
ScenePresence avatar = this.RequestAvatar(agentID);
ScenePresence avatar = RequestAvatar(agentID);
this.ForEachScenePresence(
ForEachScenePresence(
delegate(ScenePresence presence)
{
presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId);
@ -652,12 +648,13 @@ namespace OpenSim.Region.Environment.Scenes
// TODO: Add the removal from physics ?
return;
}
#endregion
#region Request Avatars List Methods
//The idea is to have a group of method that return a list of avatars meeting some requirement
// ie it could be all Avatars within a certain range of the calling prim/avatar.
@ -703,7 +700,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns>
public ScenePresence RequestAvatar(LLUUID avatarID)
{
if (this.Avatars.ContainsKey(avatarID))
if (Avatars.ContainsKey(avatarID))
{
return Avatars[avatarID];
}
@ -712,13 +709,13 @@ namespace OpenSim.Region.Environment.Scenes
public void ForEachScenePresence(ForEachScenePresenceDelegate whatToDo)
{
foreach (ScenePresence presence in this.Avatars.Values)
foreach (ScenePresence presence in Avatars.Values)
{
whatToDo(presence);
}
}
#endregion
#endregion
/// <summary>
///
@ -727,9 +724,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns>
public bool DeleteEntity(LLUUID entID)
{
if (this.Entities.ContainsKey(entID))
if (Entities.ContainsKey(entID))
{
this.Entities.Remove(entID);
Entities.Remove(entID);
return true;
}
return false;
@ -741,7 +738,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (ent is SceneObject)
{
((SceneObject)ent).SendAllChildPrimsToClient(client);
((SceneObject) ent).SendAllChildPrimsToClient(client);
}
}
}
@ -753,12 +750,11 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public void RegisterRegionWithComms()
{
this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo);
if (this.regionCommsHost != null)
regionCommsHost = commsManager.GridServer.RegisterRegion(m_regInfo);
if (regionCommsHost != null)
{
this.regionCommsHost.OnExpectUser += this.NewUserConnection;
this.regionCommsHost.OnAvatarCrossingIntoRegion += this.AgentCrossing;
regionCommsHost.OnExpectUser += NewUserConnection;
regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
}
}
@ -771,35 +767,37 @@ namespace OpenSim.Region.Environment.Scenes
{
// Console.WriteLine("World.cs - add new user connection");
//should just check that its meant for this region
if (regionHandle == this.m_regInfo.RegionHandle)
if (regionHandle == m_regInfo.RegionHandle)
{
if (agent.CapsPath != "")
{
//Console.WriteLine("new user, so creating caps handler for it");
Caps cap = new Caps(this.assetCache, httpListener, this.m_regInfo.ExternalHostName, this.m_regInfo.ExternalEndPoint.Port, agent.CapsPath, agent.AgentID);
Caps cap =
new Caps(assetCache, httpListener, m_regInfo.ExternalHostName, m_regInfo.ExternalEndPoint.Port,
agent.CapsPath, agent.AgentID);
cap.RegisterHandlers();
if (capsHandlers.ContainsKey(agent.AgentID))
{
OpenSim.Framework.Console.MainLog.Instance.Warn("Adding duplicate CAPS entry for user " + agent.AgentID.ToStringHyphenated());
this.capsHandlers[agent.AgentID] = cap;
MainLog.Instance.Warn("Adding duplicate CAPS entry for user " +
agent.AgentID.ToStringHyphenated());
capsHandlers[agent.AgentID] = cap;
}
else
{
this.capsHandlers.Add(agent.AgentID, cap);
capsHandlers.Add(agent.AgentID, cap);
}
}
this.authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
}
}
public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
{
if (regionHandle == this.m_regInfo.RegionHandle)
if (regionHandle == m_regInfo.RegionHandle)
{
if (this.Avatars.ContainsKey(agentID))
if (Avatars.ContainsKey(agentID))
{
this.Avatars[agentID].MakeAvatar(position);
Avatars[agentID].MakeAvatar(position);
}
}
}
@ -809,7 +807,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public void InformClientOfNeighbours(IClientAPI remoteClient)
{
List<RegionInfo> neighbours = this.commsManager.GridServer.RequestNeighbours(this.m_regInfo);
List<RegionInfo> neighbours = commsManager.GridServer.RequestNeighbours(m_regInfo);
if (neighbours != null)
{
@ -820,7 +818,7 @@ namespace OpenSim.Region.Environment.Scenes
agent.InventoryFolder = LLUUID.Zero;
agent.startpos = new LLVector3(128, 128, 70);
agent.child = true;
this.commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent);
commsManager.InterRegion.InformRegionOfChildAgent(neighbours[i].RegionHandle, agent);
remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint);
//this.capsHandlers[remoteClient.AgentId].CreateEstablishAgentComms("", System.Net.IPAddress.Parse(neighbours[i].CommsIPListenAddr) + ":" + neighbours[i].CommsIPListenPort);
}
@ -834,7 +832,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns>
public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
{
return this.commsManager.GridServer.RequestNeighbourInfo(regionHandle);
return commsManager.GridServer.RequestNeighbourInfo(regionHandle);
}
/// <summary>
@ -847,7 +845,7 @@ namespace OpenSim.Region.Environment.Scenes
public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
{
List<MapBlockData> mapBlocks;
mapBlocks = this.commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
mapBlocks = commsManager.GridServer.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
remoteClient.SendMapBlock(mapBlocks);
}
@ -859,20 +857,21 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="position"></param>
/// <param name="lookAt"></param>
/// <param name="flags"></param>
public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position, LLVector3 lookAt, uint flags)
public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, LLVector3 position,
LLVector3 lookAt, uint flags)
{
if (regionHandle == this.m_regionHandle)
if (regionHandle == m_regionHandle)
{
if (this.Avatars.ContainsKey(remoteClient.AgentId))
if (Avatars.ContainsKey(remoteClient.AgentId))
{
remoteClient.SendTeleportLocationStart();
remoteClient.SendLocalTeleport(position, lookAt, flags);
this.Avatars[remoteClient.AgentId].Teleport(position);
Avatars[remoteClient.AgentId].Teleport(position);
}
}
else
{
RegionInfo reg = this.RequestNeighbouringRegionInfo(regionHandle);
RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle);
if (reg != null)
{
remoteClient.SendTeleportLocationStart();
@ -881,11 +880,10 @@ namespace OpenSim.Region.Environment.Scenes
agent.InventoryFolder = LLUUID.Zero;
agent.startpos = new LLVector3(128, 128, 70);
agent.child = true;
this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position);
commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position);
remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4));
}
}
}
@ -898,7 +896,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="position"></param>
public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position)
{
return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position);
return commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position);
}
public void performParcelPrimCountUpdate()
@ -908,7 +906,7 @@ namespace OpenSim.Region.Environment.Scenes
m_LandManager.finalizeLandPrimCountUpdate();
m_LandManager.landPrimCountTainted = false;
}
#endregion
#endregion
}
}

View File

@ -55,8 +55,8 @@ namespace OpenSim.Region.Environment.Scenes
{
get
{
this.uuid = this.rootPrimitive.uuid;
return this.uuid;
this.m_uuid = this.rootPrimitive.m_uuid;
return this.m_uuid;
}
}
@ -151,7 +151,7 @@ namespace OpenSim.Region.Environment.Scenes
this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world, agentID, localID, true, this, this, shape, pos);
this.children.Add(rootPrimitive);
this.m_children.Add(rootPrimitive);
this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive);
}
@ -177,7 +177,7 @@ namespace OpenSim.Region.Environment.Scenes
dupe.m_regionHandle = this.m_regionHandle;
Primitive newRoot = this.rootPrimitive.Copy(dupe, dupe);
dupe.rootPrimitive = newRoot;
dupe.children.Add(dupe.rootPrimitive);
dupe.m_children.Add(dupe.rootPrimitive);
dupe.rootPrimitive.Pos = this.Pos;
dupe.Rotation = this.Rotation;
dupe.LocalId = m_world.PrimIDAllocate();
@ -191,7 +191,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public void DeleteAllChildren()
{
this.children.Clear();
this.m_children.Clear();
this.ChildPrimitives.Clear();
this.rootPrimitive = null;
unregisterEvents();
@ -208,9 +208,9 @@ namespace OpenSim.Region.Environment.Scenes
public void AddChildToList(Primitive prim)
{
if (!this.ChildPrimitives.ContainsKey(prim.uuid))
if (!this.ChildPrimitives.ContainsKey(prim.m_uuid))
{
this.ChildPrimitives.Add(prim.uuid, prim);
this.ChildPrimitives.Add(prim.m_uuid, prim);
}
}
/// <summary>

View File

@ -120,7 +120,7 @@ namespace OpenSim.Region.Environment.Scenes
{
m_world = world;
this.uuid = theClient.AgentId;
this.m_uuid = theClient.AgentId;
m_regionInfo = reginfo;
m_regionHandle = reginfo.RegionHandle;
@ -349,7 +349,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary>
///
/// </summary>
public override void update()
public override void Update()
{
if (this.childAgent == false)
{
@ -405,7 +405,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="remoteAvatar"></param>
public void SendFullUpdateToOtherClient(ScenePresence remoteAvatar)
{
remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture);
remoteAvatar.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.m_uuid, this.LocalId, this.Pos, DefaultTexture);
}
public void SendFullUpdateToALLClients()
@ -423,7 +423,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary>
public void SendInitialData()
{
this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.uuid, this.LocalId, this.Pos, DefaultTexture);
this.ControllingClient.SendAvatarData(m_regionInfo.RegionHandle, this.firstname, this.lastname, this.m_uuid, this.LocalId, this.Pos, DefaultTexture);
if (this.newAvatar)
{
this.m_world.InformClientOfNeighbours(this.ControllingClient);

View File

@ -12,6 +12,7 @@ using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types;
using OpenSim.Framework.Data;
using OpenSim.Framework.Utilities;
using OpenSim.Region.Environment.Scenes;
namespace SimpleApp
{
@ -78,9 +79,9 @@ namespace SimpleApp
#pragma warning restore 67
private LLUUID myID = LLUUID.Random();
public MyNpcCharacter()
public MyNpcCharacter( EventManager eventManager )
{
eventManager.OnFrame += Update;
}
public virtual LLVector3 StartPos
@ -143,18 +144,9 @@ namespace SimpleApp
{
this.OnRegionHandShakeReply(this);
this.OnCompleteMovementToRegion();
this.StartMovement();
}
public void StartMovement()
{
Timer timer = new Timer();
timer.Enabled = true;
timer.Interval = 500;
timer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
}
public void Heartbeat(object sender, EventArgs e)
private void Update( )
{
Encoding enc = Encoding.ASCII;

View File

@ -21,20 +21,15 @@ namespace SimpleApp
String instanceName = "_Total";
m_counter = new PerformanceCounter(objectName, counterName, instanceName);
Timer timer = new Timer();
timer.Enabled = true;
timer.Interval = 100;
timer.Elapsed += new ElapsedEventHandler(this.Heartbeat);
}
public void Heartbeat(object sender, EventArgs e)
public override void Update( )
{
float cpu = m_counter.NextValue() / 40f;
LLVector3 size = new LLVector3(cpu, cpu, cpu);
rootPrimitive.ResizeGoup( size );
update();
base.Update();
}
}
}

View File

@ -74,24 +74,6 @@ namespace SimpleApp
avatar.Pos = new LLVector3(128, 128, 26);
}
public override void Update()
{
foreach (LLUUID UUID in Entities.Keys)
{
Entities[UUID].updateMovement();
}
lock (this.m_syncRoot)
{
this.phyScene.Simulate(timeStep);
}
foreach (LLUUID UUID in Entities.Keys)
{
Entities[UUID].update();
}
}
#endregion
}
}

View File

@ -54,6 +54,7 @@ namespace SimpleApp
UDPServer udpServer;
Scene scene = SetupScene(regionInfo, out udpServer);
scene.StartTimer();
udpServer.ServerListener();
@ -64,7 +65,7 @@ namespace SimpleApp
SceneObject m_sceneObject = new MySceneObject(scene, scene.EventManager, LLUUID.Zero, scene.PrimIDAllocate(), pos, shape);
scene.AddEntity(m_sceneObject);
MyNpcCharacter m_character = new MyNpcCharacter();
MyNpcCharacter m_character = new MyNpcCharacter( scene.EventManager );
scene.AddNewClient(m_character, false);
m_log.WriteLine(LogPriority.NORMAL, "Press enter to quit.");