Some Work on the Primitive class

Sugilite
MW 2007-06-12 14:46:29 +00:00
parent c43725874f
commit 9f1158ba6a
5 changed files with 143 additions and 59 deletions

View File

@ -41,9 +41,9 @@ namespace OpenSim.Region
{ {
public class Primitive : Entity public class Primitive : Entity
{ {
protected PrimData primData; internal PrimData primData;
private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
private Dictionary<uint, IClientAPI> m_clientThreads; // private Dictionary<uint, IClientAPI> m_clientThreads;
private ulong m_regionHandle; private ulong m_regionHandle;
private const uint FULL_MASK_PERMISSIONS = 2147483647; private const uint FULL_MASK_PERMISSIONS = 2147483647;
private bool physicsEnabled = false; private bool physicsEnabled = false;
@ -95,7 +95,7 @@ namespace OpenSim.Region
/// <param name="world"></param> /// <param name="world"></param>
public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world) public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world)
{ {
m_clientThreads = clientThreads; // m_clientThreads = clientThreads;
m_regionHandle = regionHandle; m_regionHandle = regionHandle;
m_world = world; m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>(); inventoryItems = new Dictionary<LLUUID, InventoryItem>();
@ -112,7 +112,7 @@ namespace OpenSim.Region
/// <param name="localID"></param> /// <param name="localID"></param>
public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world, LLUUID owner, LLUUID fullID, uint localID) public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world, LLUUID owner, LLUUID fullID, uint localID)
{ {
m_clientThreads = clientThreads; // m_clientThreads = clientThreads;
m_regionHandle = regionHandle; m_regionHandle = regionHandle;
m_world = world; m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>(); inventoryItems = new Dictionary<LLUUID, InventoryItem>();
@ -134,7 +134,7 @@ namespace OpenSim.Region
/// <param name="position"></param> /// <param name="position"></param>
public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world, LLUUID owner, uint localID, LLVector3 position) public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world, LLUUID owner, uint localID, LLVector3 position)
{ {
m_clientThreads = clientThreads; //m_clientThreads = clientThreads;
m_regionHandle = regionHandle; m_regionHandle = regionHandle;
m_world = world; m_world = world;
inventoryItems = new Dictionary<LLUUID, InventoryItem>(); inventoryItems = new Dictionary<LLUUID, InventoryItem>();
@ -191,11 +191,16 @@ namespace OpenSim.Region
/// </summary> /// </summary>
public override void update() public override void update()
{ {
if (this.updateFlag == 1) if (this.updateFlag == 1) // is a new prim just been created/reloaded
{ {
this.SendFullUpdateToAllClients(); this.SendFullUpdateToAllClients();
this.updateFlag = 0; this.updateFlag = 0;
} }
if (this.updateFlag == 2) //some change has been made so update the clients
{
this.SendTerseUpdateToALLClients();
this.updateFlag = 0;
}
} }
/// <summary> /// <summary>
@ -216,7 +221,8 @@ namespace OpenSim.Region
/// <param name="pos"></param> /// <param name="pos"></param>
public void UpdatePosition(LLVector3 pos) public void UpdatePosition(LLVector3 pos)
{ {
this.Pos = new LLVector3(pos.X, pos.Y, pos.Z);
this.updateFlag = 2;
} }
/// <summary> /// <summary>
@ -272,58 +278,44 @@ namespace OpenSim.Region
} }
/// <summary>
///
/// </summary>
/// <param name="client"></param>
public void GetProperites(IClientAPI client)
{
ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
proper.ObjectData[0].ItemID = LLUUID.Zero;
proper.ObjectData[0].CreationDate = (ulong)this.primData.CreationDate;
proper.ObjectData[0].CreatorID = this.primData.OwnerID;
proper.ObjectData[0].FolderID = LLUUID.Zero;
proper.ObjectData[0].FromTaskID = LLUUID.Zero;
proper.ObjectData[0].GroupID = LLUUID.Zero;
proper.ObjectData[0].InventorySerial = 0;
proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
proper.ObjectData[0].ObjectID = this.uuid;
proper.ObjectData[0].OwnerID = primData.OwnerID;
proper.ObjectData[0].TouchName = new byte[0];
proper.ObjectData[0].TextureID = new byte[0];
proper.ObjectData[0].SitName = new byte[0];
proper.ObjectData[0].Name = new byte[0];
proper.ObjectData[0].Description = new byte[0];
proper.ObjectData[0].OwnerMask = this.primData.OwnerMask;
proper.ObjectData[0].NextOwnerMask = this.primData.NextOwnerMask;
proper.ObjectData[0].GroupMask = this.primData.GroupMask;
proper.ObjectData[0].EveryoneMask = this.primData.EveryoneMask;
proper.ObjectData[0].BaseMask = this.primData.BaseMask;
client.OutPacket(proper);
}
#endregion #endregion
# region Inventory Methods # region Inventory Methods
/// <summary>
///
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool AddToInventory(InventoryItem item) public bool AddToInventory(InventoryItem item)
{ {
return false; return false;
} }
/// <summary>
///
/// </summary>
/// <param name="itemID"></param>
/// <returns></returns>
public InventoryItem RemoveFromInventory(LLUUID itemID) public InventoryItem RemoveFromInventory(LLUUID itemID)
{ {
return null; return null;
} }
/// <summary>
///
/// </summary>
/// <param name="simClient"></param>
/// <param name="packet"></param>
public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet) public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet)
{ {
} }
/// <summary>
///
/// </summary>
/// <param name="simClient"></param>
/// <param name="xferID"></param>
public void RequestXferInventory(IClientAPI simClient, ulong xferID) public void RequestXferInventory(IClientAPI simClient, ulong xferID)
{ {
//will only currently work if the total size of the inventory data array is under about 1000 bytes //will only currently work if the total size of the inventory data array is under about 1000 bytes
@ -336,6 +328,10 @@ namespace OpenSim.Region
simClient.OutPacket(send); simClient.OutPacket(send);
} }
/// <summary>
///
/// </summary>
/// <returns></returns>
public byte[] ConvertInventoryToBytes() public byte[] ConvertInventoryToBytes()
{ {
System.Text.Encoding enc = System.Text.Encoding.ASCII; System.Text.Encoding enc = System.Text.Encoding.ASCII;
@ -353,6 +349,10 @@ namespace OpenSim.Region
return result; return result;
} }
/// <summary>
///
/// </summary>
/// <param name="data"></param>
public void CreateInventoryFromBytes(byte[] data) public void CreateInventoryFromBytes(byte[] data)
{ {
@ -362,7 +362,22 @@ namespace OpenSim.Region
#region Update viewers Methods #region Update viewers Methods
//should change these mehtods, so that outgoing packets are sent through the avatar class? /// <summary>
///
/// </summary>
/// <param name="remoteClient"></param>
public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
{
this.SendFullUpdateToClient(remoteClient);
for (int i = 0; i < this.children.Count; i++)
{
if (this.children[i] is Primitive)
{
((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
}
}
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@ -41,9 +41,10 @@ namespace OpenSim.Region
public class SceneObject : Entity public class SceneObject : Entity
{ {
private LLUUID rootUUID; private LLUUID rootUUID;
private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>(); //private Dictionary<LLUUID, Primitive> ChildPrimitives = new Dictionary<LLUUID, Primitive>();
private Dictionary<uint, IClientAPI> m_clientThreads; protected Primitive rootPrimitive;
private World m_world; private World m_world;
protected ulong regionHandle;
/// <summary> /// <summary>
/// ///
@ -61,6 +62,8 @@ namespace OpenSim.Region
/// <param name="localID"></param> /// <param name="localID"></param>
public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID)
{ {
this.rootPrimitive = new Primitive(null, this.regionHandle, this.m_world);
this.rootPrimitive.CreateFromPacket(addPacket, agentID, localID);
} }
/// <summary> /// <summary>
@ -94,33 +97,33 @@ namespace OpenSim.Region
/// <param name="client"></param> /// <param name="client"></param>
public void GetProperites(IClientAPI client) public void GetProperites(IClientAPI client)
{ {
/* //needs changing
ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
proper.ObjectData[0].ItemID = LLUUID.Zero; proper.ObjectData[0].ItemID = LLUUID.Zero;
proper.ObjectData[0].CreationDate = (ulong)this.primData.CreationDate; proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.primData.CreationDate;
proper.ObjectData[0].CreatorID = this.primData.OwnerID; proper.ObjectData[0].CreatorID = this.rootPrimitive.primData.OwnerID;
proper.ObjectData[0].FolderID = LLUUID.Zero; proper.ObjectData[0].FolderID = LLUUID.Zero;
proper.ObjectData[0].FromTaskID = LLUUID.Zero; proper.ObjectData[0].FromTaskID = LLUUID.Zero;
proper.ObjectData[0].GroupID = LLUUID.Zero; proper.ObjectData[0].GroupID = LLUUID.Zero;
proper.ObjectData[0].InventorySerial = 0; proper.ObjectData[0].InventorySerial = 0;
proper.ObjectData[0].LastOwnerID = LLUUID.Zero; proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
proper.ObjectData[0].ObjectID = this.uuid; proper.ObjectData[0].ObjectID = this.uuid;
proper.ObjectData[0].OwnerID = primData.OwnerID; proper.ObjectData[0].OwnerID = this.rootPrimitive.primData.OwnerID;
proper.ObjectData[0].TouchName = new byte[0]; proper.ObjectData[0].TouchName = new byte[0];
proper.ObjectData[0].TextureID = new byte[0]; proper.ObjectData[0].TextureID = new byte[0];
proper.ObjectData[0].SitName = new byte[0]; proper.ObjectData[0].SitName = new byte[0];
proper.ObjectData[0].Name = new byte[0]; proper.ObjectData[0].Name = new byte[0];
proper.ObjectData[0].Description = new byte[0]; proper.ObjectData[0].Description = new byte[0];
proper.ObjectData[0].OwnerMask = this.primData.OwnerMask; proper.ObjectData[0].OwnerMask = this.rootPrimitive.primData.OwnerMask;
proper.ObjectData[0].NextOwnerMask = this.primData.NextOwnerMask; proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.primData.NextOwnerMask;
proper.ObjectData[0].GroupMask = this.primData.GroupMask; proper.ObjectData[0].GroupMask = this.rootPrimitive.primData.GroupMask;
proper.ObjectData[0].EveryoneMask = this.primData.EveryoneMask; proper.ObjectData[0].EveryoneMask = this.rootPrimitive.primData.EveryoneMask;
proper.ObjectData[0].BaseMask = this.primData.BaseMask; proper.ObjectData[0].BaseMask = this.rootPrimitive.primData.BaseMask;
client.OutPacket(proper); client.OutPacket(proper);
* */
} }
} }

View File

@ -210,7 +210,14 @@ namespace OpenSim.Region
/// <param name="remoteClient"></param> /// <param name="remoteClient"></param>
public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
{ {
foreach (Entity ent in Entities.Values)
{
if (ent.localid == localID)
{
((OpenSim.Region.Primitive)ent).UpdatePosition(pos);
break;
}
}
} }
/// <summary> /// <summary>

View File

@ -511,9 +511,9 @@ namespace OpenSim.Region
remoteClient.OnChatFromViewer += new ChatFromViewer(this.SimChat); remoteClient.OnChatFromViewer += new ChatFromViewer(this.SimChat);
remoteClient.OnRequestWearables += new GenericCall(this.InformClientOfNeighbours); remoteClient.OnRequestWearables += new GenericCall(this.InformClientOfNeighbours);
remoteClient.OnAddPrim += new GenericCall4(this.AddNewPrim); remoteClient.OnAddPrim += new GenericCall4(this.AddNewPrim);
remoteClient.OnUpdatePrimPosition += new UpdatePrimVector(this.UpdatePrimPosition);
/* /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest);
remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest);
remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest); remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest);
remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest); remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest);
remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest); remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest);

View File

@ -60,6 +60,11 @@ namespace OpenSim
} }
} }
/// <summary>
///
/// </summary>
/// <param name="circuitCode"></param>
/// <param name="packet"></param>
public virtual void ClientInPacket(uint circuitCode, Packet packet) public virtual void ClientInPacket(uint circuitCode, Packet packet)
{ {
if (this.ClientThreads.ContainsKey(circuitCode)) if (this.ClientThreads.ContainsKey(circuitCode))
@ -68,36 +73,79 @@ namespace OpenSim
} }
} }
/// <summary>
///
/// </summary>
/// <param name="circuitCode"></param>
/// <returns></returns>
public virtual bool AddNewCircuitCodeClient(uint circuitCode) public virtual bool AddNewCircuitCodeClient(uint circuitCode)
{ {
return false; return false;
} }
/// <summary>
///
/// </summary>
/// <param name="packet"></param>
public virtual void SendPacketToAllClients(Packet packet) public virtual void SendPacketToAllClients(Packet packet)
{ {
} }
/// <summary>
///
/// </summary>
/// <param name="packet"></param>
/// <param name="simClient"></param>
public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient) public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient)
{ {
} }
/// <summary>
///
/// </summary>
/// <param name="packetType"></param>
/// <param name="handler"></param>
public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler) public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler)
{ {
} }
/// <summary>
///
/// </summary>
public virtual void RegisterClientPacketHandlers() public virtual void RegisterClientPacketHandlers()
{ {
} }
/// <summary>
///
/// </summary>
/// <param name="remoteEP"></param>
/// <param name="initialcirpack"></param>
/// <param name="clientThreads"></param>
/// <param name="world"></param>
/// <param name="assetCache"></param>
/// <param name="packServer"></param>
/// <param name="inventoryCache"></param>
/// <param name="authenSessions"></param>
/// <returns></returns>
protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions) protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary<uint, ClientView> clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions)
{ {
return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions ); return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions );
} }
/// <summary>
///
/// </summary>
/// <param name="epSender"></param>
/// <param name="useCircuit"></param>
/// <param name="assetCache"></param>
/// <param name="inventoryCache"></param>
/// <param name="authenticateSessionsClass"></param>
/// <returns></returns>
public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass) public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass)
{ {
ClientView newuser = ClientView newuser =
@ -110,11 +158,22 @@ namespace OpenSim
return true; return true;
} }
/// <summary>
///
/// </summary>
/// <param name="buffer"></param>
/// <param name="size"></param>
/// <param name="flags"></param>
/// <param name="circuitcode"></param>
public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
{ {
this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode); this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode);
} }
/// <summary>
///
/// </summary>
/// <param name="circuitcode"></param>
public virtual void RemoveClientCircuit(uint circuitcode) public virtual void RemoveClientCircuit(uint circuitcode)
{ {
this._networkHandler.RemoveClientCircuit(circuitcode); this._networkHandler.RemoveClientCircuit(circuitcode);