* 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 abstract class EntityBase
{ {
public LLUUID uuid; public LLUUID m_uuid;
protected List<EntityBase> children; protected List<EntityBase> m_children;
protected Scene m_world; protected Scene m_world;
protected string m_name; protected string m_name;
@ -82,13 +82,13 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public EntityBase() public EntityBase()
{ {
uuid = new LLUUID(); m_uuid = new LLUUID();
m_pos = new LLVector3(); m_pos = new LLVector3();
m_velocity = new LLVector3(); m_velocity = new LLVector3();
Rotation = new Quaternion(); Rotation = new Quaternion();
m_name = "(basic entity)"; m_name = "(basic entity)";
children = new List<EntityBase>(); m_children = new List<EntityBase>();
} }
/// <summary> /// <summary>
@ -96,7 +96,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public virtual void updateMovement() public virtual void updateMovement()
{ {
foreach (EntityBase child in children) foreach (EntityBase child in m_children)
{ {
child.updateMovement(); child.updateMovement();
} }
@ -105,12 +105,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary> /// <summary>
/// Performs any updates that need to be done at each frame. This function is overridable from it's children. /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
/// </summary> /// </summary>
public virtual void update() public virtual void Update()
{ {
// Do any per-frame updates needed that are applicable to every type of entity // 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 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 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 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 = ""; private string m_description = "";
public string SitName = "";
public string TouchName = "";
public string Text = "";
public LLUUID CreatorID; public LLUUID CreatorID;
public LLUUID OwnerID; public LLUUID OwnerID;
public LLUUID LastOwnerID; public LLUUID LastOwnerID;
@ -52,22 +48,23 @@ namespace OpenSim.Region.Environment.Scenes
public event PrimCountTaintedDelegate OnPrimCountTainted; public event PrimCountTaintedDelegate OnPrimCountTainted;
#region Properties #region Properties
/// <summary> /// <summary>
/// If rootprim, will return world position /// If rootprim, will return world position
/// otherwise will return local offset from rootprim /// otherwise will return local offset from rootprim
/// </summary> /// </summary>
public override LLVector3 Pos public override LLVector3 Pos
{ {
get get
{ {
if (m_isRootPrim) if (m_isRootPrim)
{ {
//if we are rootprim then our offset should be zero //if we are rootprim then our offset should be zero
return this.m_pos + m_Parent.Pos; return m_pos + m_Parent.Pos;
} }
else else
{ {
return this.m_pos; return m_pos;
} }
} }
set set
@ -76,63 +73,72 @@ namespace OpenSim.Region.Environment.Scenes
{ {
m_Parent.Pos = value; m_Parent.Pos = value;
} }
this.m_pos = value - m_Parent.Pos; m_pos = value - m_Parent.Pos;
} }
} }
public PrimitiveBaseShape Shape public PrimitiveBaseShape Shape
{ {
get get { return m_Shape; }
{
return this.m_Shape;
}
} }
public LLVector3 WorldPos public LLVector3 WorldPos
{ {
get get
{ {
if (!this.m_isRootPrim) if (!m_isRootPrim)
{ {
Primitive parentPrim = (Primitive)this.m_Parent; Primitive parentPrim = (Primitive)m_Parent;
Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); Vector3 offsetPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z);
offsetPos = parentPrim.Rotation * offsetPos; offsetPos = parentPrim.Rotation * offsetPos;
return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z); return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z);
} }
else else
{ {
return this.Pos; return Pos;
} }
} }
} }
public string Description public string Description
{ {
get get { return m_description; }
{ set { m_description = value; }
return this.m_description;
}
set
{
this.m_description = value;
}
} }
public LLVector3 Scale 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 set
{ {
this.m_Shape.Scale = value; m_text = value;
} ScheduleFullUpdate();
get
{
return this.m_Shape.Scale;
} }
} }
#endregion #endregion
#region Constructors #region Constructors
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -144,21 +150,23 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="isRoot"></param> /// <param name="isRoot"></param>
/// <param name="parent"></param> /// <param name="parent"></param>
/// <param name="rootObject"></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_regionHandle = regionHandle;
m_world = world; m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>(); m_inventoryItems = new Dictionary<LLUUID, InventoryItem>();
this.m_Parent = parent; m_Parent = parent;
this.m_isRootPrim = isRoot; m_isRootPrim = isRoot;
this.m_RootParent = rootObject; m_RootParent = rootObject;
this.CreateFromShape(ownerID, localID, pos, shape); ClearUpdateSchedule();
this.Rotation = Axiom.Math.Quaternion.Identity; CreateFromShape(ownerID, localID, pos, shape);
Rotation = Quaternion.Identity;
m_world.AcknowledgeNewPrim(this); m_world.AcknowledgeNewPrim(this);
this.OnPrimCountTainted(); OnPrimCountTainted();
} }
/// <summary> /// <summary>
@ -167,7 +175,6 @@ namespace OpenSim.Region.Environment.Scenes
/// <remarks>Empty constructor for duplication</remarks> /// <remarks>Empty constructor for duplication</remarks>
public Primitive() public Primitive()
{ {
} }
#endregion #endregion
@ -176,33 +183,34 @@ namespace OpenSim.Region.Environment.Scenes
~Primitive() ~Primitive()
{ {
this.OnPrimCountTainted(); OnPrimCountTainted();
} }
#endregion #endregion
#region Duplication #region Duplication
public Primitive Copy(EntityBase parent, SceneObject rootParent) public Primitive Copy(EntityBase parent, SceneObject rootParent)
{ {
Primitive dupe = (Primitive)this.MemberwiseClone(); Primitive dupe = (Primitive)MemberwiseClone();
dupe.m_Parent = parent; dupe.m_Parent = parent;
dupe.m_RootParent = rootParent; dupe.m_RootParent = rootParent;
// TODO: Copy this properly. // TODO: Copy this properly.
dupe.inventoryItems = this.inventoryItems; dupe.m_inventoryItems = m_inventoryItems;
dupe.children = new List<EntityBase>(); dupe.m_children = new List<EntityBase>();
dupe.m_Shape = this.m_Shape.Copy(); dupe.m_Shape = m_Shape.Copy();
dupe.m_regionHandle = this.m_regionHandle; dupe.m_regionHandle = m_regionHandle;
dupe.m_world = this.m_world; dupe.m_world = m_world;
uint newLocalID = this.m_world.PrimIDAllocate(); uint newLocalID = m_world.PrimIDAllocate();
dupe.uuid = LLUUID.Random(); dupe.m_uuid = LLUUID.Random();
dupe.LocalId = newLocalID; dupe.LocalId = newLocalID;
if (parent is SceneObject) if (parent is SceneObject)
{ {
dupe.m_isRootPrim = true; dupe.m_isRootPrim = true;
dupe.ParentID = 0; dupe.ParentID = 0;
} }
else else
@ -211,18 +219,18 @@ namespace OpenSim.Region.Environment.Scenes
dupe.ParentID = ((Primitive)parent).LocalId; dupe.ParentID = ((Primitive)parent).LocalId;
} }
dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z); dupe.Scale = new LLVector3(Scale.X, Scale.Y, Scale.Z);
dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); dupe.Rotation = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z);
dupe.m_pos = new LLVector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); dupe.m_pos = new LLVector3(m_pos.X, m_pos.Y, m_pos.Z);
rootParent.AddChildToList(dupe); rootParent.AddChildToList(dupe);
this.m_world.AcknowledgeNewPrim(dupe); m_world.AcknowledgeNewPrim(dupe);
dupe.TriggerOnPrimCountTainted(); dupe.TriggerOnPrimCountTainted();
foreach (Primitive prim in this.children) foreach (Primitive prim in m_children)
{ {
Primitive primClone = prim.Copy(dupe, rootParent); Primitive primClone = prim.Copy(dupe, rootParent);
dupe.children.Add(primClone); dupe.m_children.Add(primClone);
} }
return dupe; return dupe;
@ -231,30 +239,41 @@ namespace OpenSim.Region.Environment.Scenes
#endregion #endregion
#region Override from EntityBase #region Override from EntityBase
/// <summary> /// <summary>
/// ///
/// </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(); SendTerseUpdateToALLClients();
this.updateFlag = 0; ClearUpdateSchedule();
} }
if (this.updateFlag == 2) //some change has been made so update the clients else
{ {
this.SendTerseUpdateToALLClients(); if (m_updateFlag == 2) // is a new prim just been created/reloaded or has major changes
this.updateFlag = 0; {
SendFullUpdateToAllClients();
ClearUpdateSchedule();
}
} }
foreach (EntityBase child in children) foreach (EntityBase child in m_children)
{ {
child.update(); child.Update();
} }
} }
private void ClearUpdateSchedule()
{
m_updateFlag = 0;
}
#endregion #endregion
#region Setup #region Setup
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -263,21 +282,36 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="localID"></param> /// <param name="localID"></param>
public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
{ {
this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
this.OwnerID = ownerID; OwnerID = ownerID;
this.CreatorID = this.OwnerID; CreatorID = OwnerID;
this.LastOwnerID = LLUUID.Zero; LastOwnerID = LLUUID.Zero;
this.Pos = pos; Pos = pos;
this.uuid = LLUUID.Random(); m_uuid = LLUUID.Random();
this.m_localId = (uint)(localID); m_localId = (uint)(localID);
this.m_Shape = shape; m_Shape = shape;
this.updateFlag = 1;
ScheduleFullUpdate();
}
private void ScheduleFullUpdate()
{
m_updateFlag = 2;
}
private void ScheduleTerseUpdate()
{
if (m_updateFlag < 1)
{
m_updateFlag = 1;
}
} }
#endregion #endregion
#region Linking / unlinking #region Linking / unlinking
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -286,13 +320,13 @@ namespace OpenSim.Region.Environment.Scenes
{ {
// Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")");
//TODO check permissions //TODO check permissions
this.children.Add(linkObject.rootPrimitive); m_children.Add(linkObject.rootPrimitive);
linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent); linkObject.rootPrimitive.SetNewParent(this, m_RootParent);
this.m_world.DeleteEntity(linkObject.rootUUID); m_world.DeleteEntity(linkObject.rootUUID);
linkObject.DeleteAllChildren(); linkObject.DeleteAllChildren();
this.OnPrimCountTainted(); OnPrimCountTainted();
} }
/// <summary> /// <summary>
@ -302,59 +336,58 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="rootParent"></param> /// <param name="rootParent"></param>
public void SetNewParent(Primitive newParent, SceneObject rootParent) public void SetNewParent(Primitive newParent, SceneObject rootParent)
{ {
LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
this.m_isRootPrim = false; m_isRootPrim = false;
this.m_Parent = newParent; m_Parent = newParent;
this.ParentID = newParent.LocalId; ParentID = newParent.LocalId;
this.m_RootParent = rootParent; m_RootParent = rootParent;
this.m_RootParent.AddChildToList(this); m_RootParent.AddChildToList(this);
this.Pos = oldPos; Pos = oldPos;
Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); Vector3 axPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z);
axPos = this.m_Parent.Rotation.Inverse() * axPos; axPos = m_Parent.Rotation.Inverse() * axPos;
this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); 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); Quaternion oldRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z);
this.Rotation = this.m_Parent.Rotation.Inverse() * this.Rotation; Rotation = m_Parent.Rotation.Inverse() * Rotation;
this.updateFlag = 1; ScheduleFullUpdate();
foreach (Primitive child in children) foreach (Primitive child in m_children)
{ {
child.SetRootParent(rootParent, newParent, oldPos, oldRot); child.SetRootParent(rootParent, newParent, oldPos, oldRot);
} }
children.Clear(); m_children.Clear();
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="newRoot"></param> /// <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); LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z); Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z);
axOldPos = oldParentRotation * axOldPos; axOldPos = oldParentRotation * axOldPos;
oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z); oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z);
oldPos += oldParentPosition; oldPos += oldParentPosition;
Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); Quaternion oldRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z);
this.m_isRootPrim = false; m_isRootPrim = false;
this.m_Parent = newParent; m_Parent = newParent;
this.ParentID = newParent.LocalId; ParentID = newParent.LocalId;
newParent.AddToChildrenList(this); newParent.AddToChildrenList(this);
this.m_RootParent = newRoot; m_RootParent = newRoot;
this.m_RootParent.AddChildToList(this); m_RootParent.AddChildToList(this);
this.Pos = oldPos; Pos = oldPos;
Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); Vector3 axPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z);
axPos = this.m_Parent.Rotation.Inverse() * axPos; axPos = m_Parent.Rotation.Inverse() * axPos;
this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
this.Rotation = oldParentRotation * this.Rotation; Rotation = oldParentRotation * Rotation;
this.Rotation = this.m_Parent.Rotation.Inverse()* this.Rotation ; Rotation = m_Parent.Rotation.Inverse() * Rotation;
this.updateFlag = 1; ScheduleFullUpdate();
foreach (Primitive child in children) foreach (Primitive child in m_children)
{ {
child.SetRootParent(newRoot, newParent, oldPos, oldRot); child.SetRootParent(newRoot, newParent, oldPos, oldRot);
} }
children.Clear(); m_children.Clear();
} }
/// <summary> /// <summary>
@ -363,12 +396,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="offset"></param> /// <param name="offset"></param>
public void AddOffsetToChildren(LLVector3 offset) public void AddOffsetToChildren(LLVector3 offset)
{ {
foreach (Primitive prim in this.children) foreach (Primitive prim in m_children)
{ {
prim.m_pos += offset; prim.m_pos += offset;
prim.updateFlag = 2; prim.ScheduleTerseUpdate();
} }
this.OnPrimCountTainted(); OnPrimCountTainted();
} }
/// <summary> /// <summary>
@ -377,38 +410,42 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="prim"></param> /// <param name="prim"></param>
public void AddToChildrenList(Primitive prim) public void AddToChildrenList(Primitive prim)
{ {
this.children.Add(prim); m_children.Add(prim);
} }
#endregion #endregion
#region Resizing/Scale #region Resizing/Scale
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="scale"></param> /// <param name="scale"></param>
public void ResizeGoup(LLVector3 scale) public void ResizeGoup(LLVector3 scale)
{ {
LLVector3 offset = (scale - this.m_Shape.Scale); LLVector3 offset = (scale - m_Shape.Scale);
offset.X /= 2; offset.X /= 2;
offset.Y /= 2; offset.Y /= 2;
offset.Z /= 2; offset.Z /= 2;
if (this.m_isRootPrim) if (m_isRootPrim)
{ {
this.m_Parent.Pos += offset; m_Parent.Pos += offset;
} }
else else
{ {
this.m_pos += offset; m_pos += offset;
} }
this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z)); AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z));
this.m_Shape.Scale = scale; m_Shape.Scale = scale;
this.updateFlag = 1; ScheduleFullUpdate();
} }
#endregion #endregion
#region Position #region Position
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@ -417,10 +454,10 @@ namespace OpenSim.Region.Environment.Scenes
{ {
LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
this.Pos = newPos; Pos = newPos;
this.updateFlag = 2; ScheduleTerseUpdate();
this.OnPrimCountTainted(); OnPrimCountTainted();
} }
/// <summary> /// <summary>
@ -429,48 +466,46 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="pos"></param> /// <param name="pos"></param>
public void UpdateSinglePosition(LLVector3 pos) public void UpdateSinglePosition(LLVector3 pos)
{ {
// Console.WriteLine("updating single prim position"); // Console.WriteLine("updating single prim position");
if (this.m_isRootPrim) if (m_isRootPrim)
{ {
LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
LLVector3 diff = oldPos - newPos; LLVector3 diff = oldPos - newPos;
Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z);
axDiff = this.Rotation.Inverse() * axDiff; axDiff = Rotation.Inverse() * axDiff;
diff.X = axDiff.x; diff.X = axDiff.x;
diff.Y = axDiff.y; diff.Y = axDiff.y;
diff.Z = axDiff.z; 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.m_pos += diff;
prim.updateFlag = 2; prim.ScheduleTerseUpdate();
} }
this.updateFlag = 2; ScheduleTerseUpdate();
} }
else else
{ {
LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
this.m_pos = newPos; m_pos = newPos;
this.updateFlag = 2; ScheduleTerseUpdate();
} }
} }
#endregion #endregion
#region Rotation #region Rotation
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="rot"></param> /// <param name="rot"></param>
public void UpdateGroupRotation(LLQuaternion rot) public void UpdateGroupRotation(LLQuaternion rot)
{ {
this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); Rotation = new Quaternion(rot.W, rot.X, rot.Y, rot.Z);
this.updateFlag = 2; ScheduleTerseUpdate();
} }
/// <summary> /// <summary>
@ -480,9 +515,9 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="rot"></param> /// <param name="rot"></param>
public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot)
{ {
this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); Rotation = new Quaternion(rot.W, rot.X, rot.Y, rot.Z);
this.Pos = pos; Pos = pos;
this.updateFlag = 2; ScheduleTerseUpdate();
} }
/// <summary> /// <summary>
@ -492,62 +527,67 @@ namespace OpenSim.Region.Environment.Scenes
public void UpdateSingleRotation(LLQuaternion rot) public void UpdateSingleRotation(LLQuaternion rot)
{ {
//Console.WriteLine("updating single prim rotation"); //Console.WriteLine("updating single prim rotation");
Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); Quaternion axRot = new 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); Quaternion oldParentRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z);
this.Rotation = axRot; Rotation = axRot;
foreach (Primitive prim in this.children) 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 = oldParentRot * axPos;
axPos = axRot.Inverse() * axPos; axPos = axRot.Inverse() * axPos;
prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
prim.Rotation = oldParentRot * prim.Rotation ; prim.Rotation = oldParentRot * prim.Rotation;
prim.Rotation = axRot.Inverse()* prim.Rotation; prim.Rotation = axRot.Inverse() * prim.Rotation;
prim.updateFlag = 2; prim.ScheduleTerseUpdate();
} }
this.updateFlag = 2; ScheduleTerseUpdate();
} }
#endregion #endregion
#region Shape #region Shape
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="shapeBlock"></param> /// <param name="shapeBlock"></param>
public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock)
{ {
this.m_Shape.PathBegin = shapeBlock.PathBegin; m_Shape.PathBegin = shapeBlock.PathBegin;
this.m_Shape.PathEnd = shapeBlock.PathEnd; m_Shape.PathEnd = shapeBlock.PathEnd;
this.m_Shape.PathScaleX = shapeBlock.PathScaleX; m_Shape.PathScaleX = shapeBlock.PathScaleX;
this.m_Shape.PathScaleY = shapeBlock.PathScaleY; m_Shape.PathScaleY = shapeBlock.PathScaleY;
this.m_Shape.PathShearX = shapeBlock.PathShearX; m_Shape.PathShearX = shapeBlock.PathShearX;
this.m_Shape.PathShearY = shapeBlock.PathShearY; m_Shape.PathShearY = shapeBlock.PathShearY;
this.m_Shape.PathSkew = shapeBlock.PathSkew; m_Shape.PathSkew = shapeBlock.PathSkew;
this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin; m_Shape.ProfileBegin = shapeBlock.ProfileBegin;
this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd; m_Shape.ProfileEnd = shapeBlock.ProfileEnd;
this.m_Shape.PathCurve = shapeBlock.PathCurve; m_Shape.PathCurve = shapeBlock.PathCurve;
this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve; m_Shape.ProfileCurve = shapeBlock.ProfileCurve;
this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow; m_Shape.ProfileHollow = shapeBlock.ProfileHollow;
this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset;
this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions; m_Shape.PathRevolutions = shapeBlock.PathRevolutions;
this.m_Shape.PathTaperX = shapeBlock.PathTaperX; m_Shape.PathTaperX = shapeBlock.PathTaperX;
this.m_Shape.PathTaperY = shapeBlock.PathTaperY; m_Shape.PathTaperY = shapeBlock.PathTaperY;
this.m_Shape.PathTwist = shapeBlock.PathTwist; m_Shape.PathTwist = shapeBlock.PathTwist;
this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin; m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin;
this.updateFlag = 1; ScheduleFullUpdate();
} }
#endregion #endregion
#region Texture #region Texture
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="textureEntry"></param> /// <param name="textureEntry"></param>
public void UpdateTextureEntry(byte[] textureEntry) public void UpdateTextureEntry(byte[] textureEntry)
{ {
this.m_Shape.TextureEntry = textureEntry; m_Shape.TextureEntry = textureEntry;
this.updateFlag = 1; ScheduleFullUpdate();
} }
#endregion #endregion
#region Client Update Methods #region Client Update Methods
@ -558,12 +598,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
public void SendFullUpdateForAllChildren(IClientAPI remoteClient) public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
{ {
this.SendFullUpdateToClient(remoteClient); SendFullUpdateToClient(remoteClient);
for (int i = 0; i < this.children.Count; i++) 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) public void SendFullUpdateToClient(IClientAPI remoteClient)
{ {
LLVector3 lPos; LLVector3 lPos;
lPos = this.Pos; lPos = Pos;
LLQuaternion lRot; 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> /// <summary>
@ -587,10 +628,10 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void SendFullUpdateToAllClients() public void SendFullUpdateToAllClients()
{ {
List<ScenePresence> avatars = this.m_world.RequestAvatarList(); List<ScenePresence> avatars = m_world.RequestAvatarList();
for (int i = 0; i < avatars.Count; i++) 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> /// <param name="remoteClient"></param>
public void SendTerseUpdateForAllChildren(IClientAPI remoteClient) public void SendTerseUpdateForAllChildren(IClientAPI remoteClient)
{ {
this.SendTerseUpdateToClient(remoteClient); SendTerseUpdateToClient(remoteClient);
for (int i = 0; i < this.children.Count; i++) 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; LLVector3 lPos;
Quaternion lRot; Quaternion lRot;
lPos = this.Pos; lPos = Pos;
lRot = this.Rotation; lRot = Rotation;
LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); 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> /// <summary>
@ -631,10 +672,10 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void SendTerseUpdateToALLClients() public void SendTerseUpdateToALLClients()
{ {
List<ScenePresence> avatars = this.m_world.RequestAvatarList(); List<ScenePresence> avatars = m_world.RequestAvatarList();
for (int i = 0; i < avatars.Count; i++) 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() public void TriggerOnPrimCountTainted()
{ {
this.OnPrimCountTainted(); OnPrimCountTainted();
} }
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -21,20 +21,15 @@ namespace SimpleApp
String instanceName = "_Total"; String instanceName = "_Total";
m_counter = new PerformanceCounter(objectName, counterName, instanceName); 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; float cpu = m_counter.NextValue() / 40f;
LLVector3 size = new LLVector3(cpu, cpu, cpu); LLVector3 size = new LLVector3(cpu, cpu, cpu);
rootPrimitive.ResizeGoup( size ); rootPrimitive.ResizeGoup( size );
update();
base.Update();
} }
} }
} }

View File

@ -74,24 +74,6 @@ namespace SimpleApp
avatar.Pos = new LLVector3(128, 128, 26); 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 #endregion
} }
} }

View File

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