From 9f1158ba6ac5f36db5a4d374f22276294930dfd7 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 12 Jun 2007 14:46:29 +0000 Subject: [PATCH] Some Work on the Primitive class --- OpenSim/OpenSim.Region/World/Primitive.cs | 101 ++++++++++-------- OpenSim/OpenSim.Region/World/SceneObject.cs | 27 ++--- .../World/World.PacketHandlers.cs | 9 +- OpenSim/OpenSim.Region/World/World.cs | 6 +- OpenSim/OpenSim.RegionServer/PacketServer.cs | 59 ++++++++++ 5 files changed, 143 insertions(+), 59 deletions(-) diff --git a/OpenSim/OpenSim.Region/World/Primitive.cs b/OpenSim/OpenSim.Region/World/Primitive.cs index dbdbdb91ad..0680eb3f3f 100644 --- a/OpenSim/OpenSim.Region/World/Primitive.cs +++ b/OpenSim/OpenSim.Region/World/Primitive.cs @@ -41,9 +41,9 @@ namespace OpenSim.Region { public class Primitive : Entity { - protected PrimData primData; + internal PrimData primData; private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); - private Dictionary m_clientThreads; + // private Dictionary m_clientThreads; private ulong m_regionHandle; private const uint FULL_MASK_PERMISSIONS = 2147483647; private bool physicsEnabled = false; @@ -95,7 +95,7 @@ namespace OpenSim.Region /// public Primitive(Dictionary clientThreads, ulong regionHandle, World world) { - m_clientThreads = clientThreads; + // m_clientThreads = clientThreads; m_regionHandle = regionHandle; m_world = world; inventoryItems = new Dictionary(); @@ -112,7 +112,7 @@ namespace OpenSim.Region /// public Primitive(Dictionary clientThreads, ulong regionHandle, World world, LLUUID owner, LLUUID fullID, uint localID) { - m_clientThreads = clientThreads; + // m_clientThreads = clientThreads; m_regionHandle = regionHandle; m_world = world; inventoryItems = new Dictionary(); @@ -134,7 +134,7 @@ namespace OpenSim.Region /// public Primitive(Dictionary clientThreads, ulong regionHandle, World world, LLUUID owner, uint localID, LLVector3 position) { - m_clientThreads = clientThreads; + //m_clientThreads = clientThreads; m_regionHandle = regionHandle; m_world = world; inventoryItems = new Dictionary(); @@ -191,11 +191,16 @@ namespace OpenSim.Region /// public override void update() { - if (this.updateFlag == 1) + if (this.updateFlag == 1) // is a new prim just been created/reloaded { this.SendFullUpdateToAllClients(); this.updateFlag = 0; } + if (this.updateFlag == 2) //some change has been made so update the clients + { + this.SendTerseUpdateToALLClients(); + this.updateFlag = 0; + } } /// @@ -216,7 +221,8 @@ namespace OpenSim.Region /// public void UpdatePosition(LLVector3 pos) { - + this.Pos = new LLVector3(pos.X, pos.Y, pos.Z); + this.updateFlag = 2; } /// @@ -272,58 +278,44 @@ namespace OpenSim.Region } - /// - /// - /// - /// - 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 # region Inventory Methods - + /// + /// + /// + /// + /// public bool AddToInventory(InventoryItem item) { return false; } + /// + /// + /// + /// + /// public InventoryItem RemoveFromInventory(LLUUID itemID) { return null; } + /// + /// + /// + /// + /// public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet) { } + /// + /// + /// + /// + /// 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 @@ -336,6 +328,10 @@ namespace OpenSim.Region simClient.OutPacket(send); } + /// + /// + /// + /// public byte[] ConvertInventoryToBytes() { System.Text.Encoding enc = System.Text.Encoding.ASCII; @@ -353,6 +349,10 @@ namespace OpenSim.Region return result; } + /// + /// + /// + /// public void CreateInventoryFromBytes(byte[] data) { @@ -362,7 +362,22 @@ namespace OpenSim.Region #region Update viewers Methods - //should change these mehtods, so that outgoing packets are sent through the avatar class? + /// + /// + /// + /// + 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); + } + } + } + /// /// /// @@ -491,7 +506,7 @@ namespace OpenSim.Region { this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false); } - + /// /// /// diff --git a/OpenSim/OpenSim.Region/World/SceneObject.cs b/OpenSim/OpenSim.Region/World/SceneObject.cs index 87c9bb067e..6ded881764 100644 --- a/OpenSim/OpenSim.Region/World/SceneObject.cs +++ b/OpenSim/OpenSim.Region/World/SceneObject.cs @@ -41,9 +41,10 @@ namespace OpenSim.Region public class SceneObject : Entity { private LLUUID rootUUID; - private Dictionary ChildPrimitives = new Dictionary(); - private Dictionary m_clientThreads; + //private Dictionary ChildPrimitives = new Dictionary(); + protected Primitive rootPrimitive; private World m_world; + protected ulong regionHandle; /// /// @@ -61,6 +62,8 @@ namespace OpenSim.Region /// 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); } /// @@ -94,33 +97,33 @@ namespace OpenSim.Region /// public void GetProperites(IClientAPI client) { - /* + //needs changing 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].CreationDate = (ulong)this.rootPrimitive.primData.CreationDate; + proper.ObjectData[0].CreatorID = this.rootPrimitive.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].OwnerID = this.rootPrimitive.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; + proper.ObjectData[0].OwnerMask = this.rootPrimitive.primData.OwnerMask; + proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.primData.NextOwnerMask; + proper.ObjectData[0].GroupMask = this.rootPrimitive.primData.GroupMask; + proper.ObjectData[0].EveryoneMask = this.rootPrimitive.primData.EveryoneMask; + proper.ObjectData[0].BaseMask = this.rootPrimitive.primData.BaseMask; client.OutPacket(proper); - * */ + } } diff --git a/OpenSim/OpenSim.Region/World/World.PacketHandlers.cs b/OpenSim/OpenSim.Region/World/World.PacketHandlers.cs index f266d2ae40..85ca247d53 100644 --- a/OpenSim/OpenSim.Region/World/World.PacketHandlers.cs +++ b/OpenSim/OpenSim.Region/World/World.PacketHandlers.cs @@ -210,7 +210,14 @@ namespace OpenSim.Region /// 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; + } + } } /// diff --git a/OpenSim/OpenSim.Region/World/World.cs b/OpenSim/OpenSim.Region/World/World.cs index da0da7aae2..8c1493ec8b 100644 --- a/OpenSim/OpenSim.Region/World/World.cs +++ b/OpenSim/OpenSim.Region/World/World.cs @@ -511,9 +511,9 @@ namespace OpenSim.Region remoteClient.OnChatFromViewer += new ChatFromViewer(this.SimChat); remoteClient.OnRequestWearables += new GenericCall(this.InformClientOfNeighbours); remoteClient.OnAddPrim += new GenericCall4(this.AddNewPrim); - - /* - remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); + remoteClient.OnUpdatePrimPosition += new UpdatePrimVector(this.UpdatePrimPosition); + + /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest); remoteClient.OnParcelJoinRequest += new ParcelJoinRequest(parcelManager.handleParcelJoinRequest); remoteClient.OnParcelPropertiesUpdateRequest += new ParcelPropertiesUpdateRequest(parcelManager.handleParcelPropertiesUpdateRequest); diff --git a/OpenSim/OpenSim.RegionServer/PacketServer.cs b/OpenSim/OpenSim.RegionServer/PacketServer.cs index f4653e9ed6..f3a7d7323d 100644 --- a/OpenSim/OpenSim.RegionServer/PacketServer.cs +++ b/OpenSim/OpenSim.RegionServer/PacketServer.cs @@ -60,6 +60,11 @@ namespace OpenSim } } + /// + /// + /// + /// + /// public virtual void ClientInPacket(uint circuitCode, Packet packet) { if (this.ClientThreads.ContainsKey(circuitCode)) @@ -68,36 +73,79 @@ namespace OpenSim } } + /// + /// + /// + /// + /// public virtual bool AddNewCircuitCodeClient(uint circuitCode) { return false; } + /// + /// + /// + /// public virtual void SendPacketToAllClients(Packet packet) { } + /// + /// + /// + /// + /// public virtual void SendPacketToAllExcept(Packet packet, ClientView simClient) { } + /// + /// + /// + /// + /// public virtual void AddClientPacketHandler(PacketType packetType, PacketMethod handler) { } + /// + /// + /// public virtual void RegisterClientPacketHandlers() { } + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// protected virtual ClientView CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, Dictionary clientThreads, IWorld world, AssetCache assetCache, PacketServer packServer, InventoryCache inventoryCache, AuthenticateSessionsBase authenSessions) { return new ClientView(remoteEP, initialcirpack, clientThreads, world, assetCache, packServer, inventoryCache, authenSessions ); } + /// + /// + /// + /// + /// + /// + /// + /// + /// public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, InventoryCache inventoryCache, AuthenticateSessionsBase authenticateSessionsClass) { ClientView newuser = @@ -110,11 +158,22 @@ namespace OpenSim return true; } + /// + /// + /// + /// + /// + /// + /// public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) { this._networkHandler.SendPacketTo(buffer, size, flags, circuitcode); } + /// + /// + /// + /// public virtual void RemoveClientCircuit(uint circuitcode) { this._networkHandler.RemoveClientCircuit(circuitcode);