From 9800c05c1b3c7804466d6f3a9c38a739156625fd Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 1 Jul 2007 17:26:33 +0000 Subject: Started change to having SceneObject and then that having child Primitives which in turn have a Shape object (currently PrimitiveBaseShape). The plan is only for the SceneObject to interface with the physics engines. As a physics Entity should be able to have mulitple shapes connected to it. --- OpenSim/Region/ClientStack/ClientView.API.cs | 76 +++ .../ClientStack/ClientView.ProcessPackets.cs | 1 - .../Communications/Local/CommunicationsLocal.cs | 2 +- .../Communications/Local/LocalUserServices.cs | 13 +- .../Environment/OpenSim.Region.Environment.csproj | 6 + .../OpenSim.Region.Environment.dll.build | 2 + OpenSim/Region/Environment/Scenes/Entity.cs | 85 +-- OpenSim/Region/Environment/Scenes/EntityBase.cs | 133 +++++ OpenSim/Region/Environment/Scenes/Primitive.cs | 532 ++++--------------- OpenSim/Region/Environment/Scenes/PrimitiveOld.cs | 582 +++++++++++++++++++++ .../Environment/Scenes/Scene.PacketHandlers.cs | 16 +- OpenSim/Region/Environment/Scenes/Scene.cs | 131 ++--- OpenSim/Region/Environment/Scenes/SceneBase.cs | 2 +- OpenSim/Region/Environment/Scenes/SceneEvents.cs | 4 +- OpenSim/Region/Environment/Scenes/SceneObject.cs | 80 ++- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 8 + 16 files changed, 1036 insertions(+), 637 deletions(-) create mode 100644 OpenSim/Region/Environment/Scenes/EntityBase.cs create mode 100644 OpenSim/Region/Environment/Scenes/PrimitiveOld.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index e683db2..5056f41 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -626,6 +626,39 @@ namespace OpenSim.Region.ClientStack OutPacket(outPacket); } + + public void SendPrimitiveToClient2(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID) + { + ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); + outPacket.RegionData.RegionHandle = regionHandle; + outPacket.RegionData.TimeDilation = timeDilation; + outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; + outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, textureID, flags); + outPacket.ObjectData[0].ID = localID; + outPacket.ObjectData[0].FullID = objectID; + outPacket.ObjectData[0].OwnerID = ownerID; + byte[] pb = pos.GetBytes(); + Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); + byte[] rot = rotation.GetBytes(); + Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length); + OutPacket(outPacket); + } + + public void SendPrimitiveToClient2(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID) + { + ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); + outPacket.RegionData.RegionHandle = regionHandle; + outPacket.RegionData.TimeDilation = timeDilation; + outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; + outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, textureID, flags); + outPacket.ObjectData[0].ID = localID; + outPacket.ObjectData[0].FullID = objectID; + outPacket.ObjectData[0].OwnerID = ownerID; + byte[] pb = pos.GetBytes(); + Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); + + OutPacket(outPacket); + } /// /// /// @@ -816,6 +849,22 @@ namespace OpenSim.Region.ClientStack } /// + /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) + /// + /// + /// + protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, LLUUID textureID, uint flags) + { + ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); + this.SetDefaultPrimPacketValues(objupdate); + objupdate.UpdateFlags = flags; + this.SetPrimPacketShapeData(objupdate, primShape, textureID); + + return objupdate; + } + + + /// /// Copy the data from a PrimData object to a ObjectUpdatePacket /// /// @@ -848,6 +897,33 @@ namespace OpenSim.Region.ClientStack objectData.PathTwistBegin = primData.PathTwistBegin; } + protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData, LLUUID textureID) + { + LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID); + objectData.TextureEntry = ntex.ToBytes(); + objectData.PCode = primData.PCode; + objectData.PathBegin = primData.PathBegin; + objectData.PathEnd = primData.PathEnd; + objectData.PathScaleX = primData.PathScaleX; + objectData.PathScaleY = primData.PathScaleY; + objectData.PathShearX = primData.PathShearX; + objectData.PathShearY = primData.PathShearY; + objectData.PathSkew = primData.PathSkew; + objectData.ProfileBegin = primData.ProfileBegin; + objectData.ProfileEnd = primData.ProfileEnd; + objectData.Scale = primData.Scale; + objectData.PathCurve = primData.PathCurve; + objectData.ProfileCurve = primData.ProfileCurve; + objectData.ParentID = primData.ParentID; + objectData.ProfileHollow = primData.ProfileHollow; + objectData.PathRadiusOffset = primData.PathRadiusOffset; + objectData.PathRevolutions = primData.PathRevolutions; + objectData.PathTaperX = primData.PathTaperX; + objectData.PathTaperY = primData.PathTaperY; + objectData.PathTwist = primData.PathTwist; + objectData.PathTwistBegin = primData.PathTwistBegin; + } + /// /// Set some default values in a ObjectUpdatePacket /// diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs index 794ce79..0d90968 100644 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs @@ -211,7 +211,6 @@ namespace OpenSim.Region.ClientStack } break; case PacketType.ObjectAdd: - // m_world.AddNewPrim((ObjectAddPacket)Pack, this); if (OnAddPrim != null) { OnAddPrim(Pack, this); diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs index bacaa3e..7c7c389 100644 --- a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs +++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.Communications.Local public CommunicationsLocal(NetworkServersInfo serversInfo) : base(serversInfo) { - UserServices = new LocalUserServices(this,this.ServersInfo.DefaultHomeLocX,this.ServersInfo.DefaultHomeLocY); + UserServices = new LocalUserServices(this, serversInfo); UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll"); UserServer = UserServices; GridServer = SandBoxServices; diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs index db9d9b9..b441a8d 100644 --- a/OpenSim/Region/Communications/Local/LocalUserServices.cs +++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs @@ -18,13 +18,15 @@ namespace OpenSim.Region.Communications.Local { private CommunicationsLocal m_Parent; + private NetworkServersInfo serversInfo; private uint defaultHomeX ; private uint defaultHomeY; - public LocalUserServices(CommunicationsLocal parent, uint defHomeX, uint defHomeY) + public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversData) { m_Parent = parent; - defaultHomeX = defHomeX; - defaultHomeY = defHomeY; + this.serversInfo = serversData; + defaultHomeX = this.serversInfo.DefaultHomeLocX; + defaultHomeY = this.serversInfo.DefaultHomeLocY; } public UserProfileData GetUserProfile(string firstName, string lastName) @@ -81,7 +83,6 @@ namespace OpenSim.Region.Communications.Local ulong currentRegion = theUser.currentAgent.currentHandle; RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion); - if (reg != null) { response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " + @@ -92,7 +93,9 @@ namespace OpenSim.Region.Communications.Local response.SimPort = (Int32)reg.ExternalEndPoint.Port; response.RegionX = reg.RegionLocX ; response.RegionY = reg.RegionLocY ; - response.SeedCapability = "http://" + reg.ExternalHostName + ":" + reg.ExternalEndPoint.Port.ToString() + "/CAPS/" + capsPath + "0000/"; + + //following port needs changing as we don't want a http listener for every region (or do we?) + response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; theUser.currentAgent.currentRegion = reg.SimUUID; theUser.currentAgent.currentHandle = reg.RegionHandle; diff --git a/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj b/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj index 428f381..9e9405e 100644 --- a/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj +++ b/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj @@ -156,12 +156,18 @@ Code + + Code + Code Code + + Code + Code diff --git a/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build b/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build index 2fa5e76..d4b163e 100644 --- a/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build +++ b/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build @@ -15,8 +15,10 @@ + + diff --git a/OpenSim/Region/Environment/Scenes/Entity.cs b/OpenSim/Region/Environment/Scenes/Entity.cs index db5070d..9603f7f 100644 --- a/OpenSim/Region/Environment/Scenes/Entity.cs +++ b/OpenSim/Region/Environment/Scenes/Entity.cs @@ -34,29 +34,14 @@ using libsecondlife; namespace OpenSim.Region.Environment.Scenes { - public abstract class Entity - { - public libsecondlife.LLUUID uuid; - public Quaternion rotation; - protected List children; - + public abstract class Entity :EntityBase //will be phased out + { protected PhysicsActor _physActor; - protected Scene m_world; - protected string m_name; /// /// /// - public virtual string Name - { - get { return m_name; } - } - - protected LLVector3 m_pos; - /// - /// - /// - public virtual LLVector3 Pos + public override LLVector3 Pos { get { @@ -91,12 +76,11 @@ namespace OpenSim.Region.Environment.Scenes } } - public LLVector3 velocity; - + /// /// /// - public virtual LLVector3 Velocity + public override LLVector3 Velocity { get { @@ -130,64 +114,5 @@ namespace OpenSim.Region.Environment.Scenes velocity = value; } } - - protected uint m_localId; - - public uint LocalId - { - get { return m_localId; } - } - - /// - /// Creates a new Entity (should not occur on it's own) - /// - public Entity() - { - uuid = new libsecondlife.LLUUID(); - - m_pos = new LLVector3(); - velocity = new LLVector3(); - rotation = new Quaternion(); - m_name = "(basic entity)"; - children = new List(); - } - - /// - /// - /// - public virtual void updateMovement() - { - foreach (Entity child in children) - { - child.updateMovement(); - } - } - - /// - /// Performs any updates that need to be done at each frame. This function is overridable from it's children. - /// - public virtual void update() { - // Do any per-frame updates needed that are applicable to every type of entity - foreach (Entity child in children) - { - child.update(); - } - } - - /// - /// Called at a set interval to inform entities that they should back themsleves up to the DB - /// - public virtual void BackUp() - { - - } - - /// - /// Infoms the entity that the land (heightmap) has changed - /// - public virtual void LandRenegerated() - { - - } } } diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs new file mode 100644 index 0000000..edd72c5 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Axiom.MathLib; +using libsecondlife; + +namespace OpenSim.Region.Environment.Scenes +{ + public abstract class EntityBase + { + public libsecondlife.LLUUID uuid; + + protected List children; + + protected Scene m_world; + protected string m_name; + + /// + /// + /// + public virtual string Name + { + get { return m_name; } + } + + protected LLVector3 m_pos; + /// + /// + /// + public virtual LLVector3 Pos + { + get + { + return m_pos; + } + set + { + m_pos = value; + } + } + + public LLVector3 velocity; + + /// + /// + /// + public virtual LLVector3 Velocity + { + get + { + return velocity; + } + set + { + velocity = value; + } + } + + public Quaternion _rotation; + + public virtual Quaternion rotation + { + get + { + return _rotation; + } + set + { + _rotation = value; + } + } + + protected uint m_localId; + + public uint LocalId + { + get { return m_localId; } + } + + /// + /// Creates a new Entity (should not occur on it's own) + /// + public EntityBase() + { + uuid = new libsecondlife.LLUUID(); + + m_pos = new LLVector3(); + velocity = new LLVector3(); + rotation = new Quaternion(); + m_name = "(basic entity)"; + children = new List(); + } + + /// + /// + /// + public virtual void updateMovement() + { + foreach (EntityBase child in children) + { + child.updateMovement(); + } + } + + /// + /// Performs any updates that need to be done at each frame. This function is overridable from it's children. + /// + public virtual void update() + { + // Do any per-frame updates needed that are applicable to every type of entity + foreach (EntityBase child in children) + { + child.update(); + } + } + + /// + /// Called at a set interval to inform entities that they should back themsleves up to the DB + /// + public virtual void BackUp() + { + + } + + /// + /// Infoms the entity that the land (heightmap) has changed + /// + public virtual void LandRenegerated() + { + + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index 0f649b2..497196d 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs @@ -1,31 +1,3 @@ - -/* -* Copyright (c) Contributors, http://www.openmetaverse.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ using System; using System.Collections.Generic; using System.Text; @@ -38,175 +10,66 @@ using OpenSim.Framework.Inventory; namespace OpenSim.Region.Environment.Scenes { - public class Primitive : Entity + public class Primitive : EntityBase { - internal PrimData primData; + private const uint FULL_MASK_PERMISSIONS = 2147483647; + private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); - // private Dictionary m_clientThreads; private ulong m_regionHandle; - private const uint FULL_MASK_PERMISSIONS = 2147483647; - private bool physicsEnabled = false; private byte updateFlag = 0; private uint flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; private Dictionary inventoryItems; - #region Properties + public LLUUID OwnerID; + public Int32 CreationDate; + public uint OwnerMask = FULL_MASK_PERMISSIONS; + public uint NextOwnerMask = FULL_MASK_PERMISSIONS; + public uint GroupMask = FULL_MASK_PERMISSIONS; + public uint EveryoneMask = FULL_MASK_PERMISSIONS; + public uint BaseMask = FULL_MASK_PERMISSIONS; - public LLVector3 Scale - { - set - { - this.primData.Scale = value; - //this.dirtyFlag = true; - } - get - { - return this.primData.Scale; - } - } + private PrimitiveBaseShape m_Shape; - public PhysicsActor PhysActor - { - set - { - this._physActor = value; - } - } + private SceneObject m_RootParent; + private bool isRootPrim; + private EntityBase m_Parent; public override LLVector3 Pos { get { - return base.Pos; + if (isRootPrim) + { + return this.m_pos + m_Parent.Pos; + } + else + { + return this.m_pos; + } } set { - base.Pos = value; + this.m_pos = value - m_Parent.Pos; //should we being subtracting the parent position } - } - #endregion - /// - /// - /// - /// - /// - /// - public Primitive( ulong regionHandle, Scene world) - { - // m_clientThreads = clientThreads; - m_regionHandle = regionHandle; - m_world = world; - inventoryItems = new Dictionary(); } - /// - /// - /// - /// - /// - /// - /// - /// - public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID) + public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent , SceneObject rootObject) { - // m_clientThreads = clientThreads; m_regionHandle = regionHandle; m_world = world; inventoryItems = new Dictionary(); + this.m_Parent = parent; + this.isRootPrim = isRoot; + this.m_RootParent = rootObject; this.CreateFromPacket(addPacket, ownerID, localID); } /// /// /// - /// - /// - /// - /// - /// - /// - public Primitive( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID) - { - // m_clientThreads = clientThreads; - m_regionHandle = regionHandle; - m_world = world; - inventoryItems = new Dictionary(); - this.primData = new PrimData(); - this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - this.primData.OwnerID = owner; - this.primData.FullID = this.uuid = fullID; - this.primData.LocalID = m_localId = localID; - } - - /// - /// Constructor to create a default cube - /// - /// - /// - /// - /// - /// - /// - public Primitive( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position) - { - //m_clientThreads = clientThreads; - m_regionHandle = regionHandle; - m_world = world; - inventoryItems = new Dictionary(); - this.primData = PrimData.DefaultCube(); - this.primData.OwnerID = owner; - this.primData.LocalID = m_localId = localID; - this.Pos = this.primData.Position = position; - - this.updateFlag = 1; - } - - /// - /// - /// - /// - public byte[] GetByteArray() - { - byte[] result = null; - List dataArrays = new List(); - dataArrays.Add(primData.ToBytes()); - foreach (Entity child in children) - { - if (child is OpenSim.Region.Environment.Scenes.Primitive) - { - dataArrays.Add(((OpenSim.Region.Environment.Scenes.Primitive)child).GetByteArray()); - } - } - byte[] primstart = Helpers.StringToField(""); - byte[] primend = Helpers.StringToField(""); - int totalLength = primstart.Length + primend.Length; - for (int i = 0; i < dataArrays.Count; i++) - { - totalLength += dataArrays[i].Length; - } - - result = new byte[totalLength]; - int arraypos = 0; - Array.Copy(primstart, 0, result, 0, primstart.Length); - arraypos += primstart.Length; - for (int i = 0; i < dataArrays.Count; i++) - { - Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length); - arraypos += dataArrays[i].Length; - } - Array.Copy(primend, 0, result, arraypos, primend.Length); - - return result; - } - - #region Overridden Methods - - /// - /// - /// - public override void update() + public override void update() { if (this.updateFlag == 1) // is a new prim just been created/reloaded { @@ -218,112 +81,53 @@ namespace OpenSim.Region.Environment.Scenes this.SendTerseUpdateToALLClients(); this.updateFlag = 0; } - } - - /// - /// - /// - public override void BackUp() - { - } - - #endregion - - #region Packet handlers - - /// - /// - /// - /// - public void UpdatePosition(LLVector3 pos) - { - this.Pos = new LLVector3(pos.X, pos.Y, pos.Z); - this.updateFlag = 2; + base.update(); } /// /// /// /// - public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket) - { - this.primData.PathBegin = updatePacket.PathBegin; - this.primData.PathEnd = updatePacket.PathEnd; - this.primData.PathScaleX = updatePacket.PathScaleX; - this.primData.PathScaleY = updatePacket.PathScaleY; - this.primData.PathShearX = updatePacket.PathShearX; - this.primData.PathShearY = updatePacket.PathShearY; - this.primData.PathSkew = updatePacket.PathSkew; - this.primData.ProfileBegin = updatePacket.ProfileBegin; - this.primData.ProfileEnd = updatePacket.ProfileEnd; - this.primData.PathCurve = updatePacket.PathCurve; - this.primData.ProfileCurve = updatePacket.ProfileCurve; - this.primData.ProfileHollow = updatePacket.ProfileHollow; - this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset; - this.primData.PathRevolutions = updatePacket.PathRevolutions; - this.primData.PathTaperX = updatePacket.PathTaperX; - this.primData.PathTaperY = updatePacket.PathTaperY; - this.primData.PathTwist = updatePacket.PathTwist; - this.primData.PathTwistBegin = updatePacket.PathTwistBegin; - } - - /// - /// - /// - /// - public void UpdateTexture(byte[] tex) - { - this.primData.TextureEntry = tex; - } - - /// - /// - /// - /// - public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) - { - - } - - /// - /// - /// - /// - public void AssignToParent(Primitive prim) - { - - } - - #endregion - - # region Inventory Methods - /// - /// - /// - /// - /// - public bool AddToInventory(InventoryItem item) + /// + /// + public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID) { - return false; - } + this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + this.OwnerID = ownerID; + this.Pos = addPacket.ObjectData.RayEnd; + this.uuid = LLUUID.Random(); + this.m_localId = (uint)(localID); + + PrimitiveBaseShape pShape = new PrimitiveBaseShape(); + this.m_Shape = pShape; + + pShape.PCode = addPacket.ObjectData.PCode; + pShape.PathBegin = addPacket.ObjectData.PathBegin; + pShape.PathEnd = addPacket.ObjectData.PathEnd; + pShape.PathScaleX = addPacket.ObjectData.PathScaleX; + pShape.PathScaleY = addPacket.ObjectData.PathScaleY; + pShape.PathShearX = addPacket.ObjectData.PathShearX; + pShape.PathShearY = addPacket.ObjectData.PathShearY; + pShape.PathSkew = addPacket.ObjectData.PathSkew; + pShape.ProfileBegin = addPacket.ObjectData.ProfileBegin; + pShape.ProfileEnd = addPacket.ObjectData.ProfileEnd; + pShape.Scale = addPacket.ObjectData.Scale; + pShape.PathCurve = addPacket.ObjectData.PathCurve; + pShape.ProfileCurve = addPacket.ObjectData.ProfileCurve; + pShape.ParentID = 0; + pShape.ProfileHollow = addPacket.ObjectData.ProfileHollow; + pShape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; + pShape.PathRevolutions = addPacket.ObjectData.PathRevolutions; + pShape.PathTaperX = addPacket.ObjectData.PathTaperX; + pShape.PathTaperY = addPacket.ObjectData.PathTaperY; + pShape.PathTwist = addPacket.ObjectData.PathTwist; + pShape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; - /// - /// - /// - /// - /// - public InventoryItem RemoveFromInventory(LLUUID itemID) - { - return null; + this.updateFlag = 1; } - /// - /// - /// - /// - /// - public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet) + public void AddToChildren(SceneObject linkObject) { } @@ -331,53 +135,19 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - /// - /// - 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 - SendXferPacketPacket send = new SendXferPacketPacket(); - - send.XferID.ID = xferID; - send.XferID.Packet = 1 + 2147483648; - send.DataPacket.Data = this.ConvertInventoryToBytes(); - - simClient.OutPacket(send); - } - - /// - /// - /// - /// - public byte[] ConvertInventoryToBytes() + /// + public void UpdatePosition(LLVector3 pos) { - System.Text.Encoding enc = System.Text.Encoding.ASCII; - byte[] result = new byte[0]; - List inventoryData = new List(); - int totallength = 0; - foreach (InventoryItem invItem in inventoryItems.Values) + LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); + if (this.isRootPrim) { - byte[] data = enc.GetBytes(invItem.ExportString()); - inventoryData.Add(data); - totallength += data.Length; + this.m_Parent.Pos = newPos; } - //TODO: copy arrays into the single result array - - return result; - } - - /// - /// - /// - /// - public void CreateInventoryFromBytes(byte[] data) - { - + this.Pos = newPos; + this.updateFlag = 2; } - #endregion - - #region Update viewers Methods + #region Client Update Methods /// /// @@ -402,17 +172,9 @@ namespace OpenSim.Region.Environment.Scenes public void SendFullUpdateToClient(IClientAPI remoteClient) { LLVector3 lPos; - if (this._physActor != null && this.physicsEnabled) - { - PhysicsVector pPos = this._physActor.Position; - lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); - } - else - { - lPos = this.Pos; - } + lPos = this.Pos; - remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.primData, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags); + remoteClient.SendPrimitiveToClient2(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags, this.uuid, this.OwnerID); } /// @@ -430,22 +192,31 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// + /// + public void SendTerseUpdateForAllChildren(IClientAPI remoteClient) + { + this.SendTerseUpdateToClient(remoteClient); + for (int i = 0; i < this.children.Count; i++) + { + if (this.children[i] is Primitive) + { + ((Primitive)this.children[i]).SendTerseUpdateForAllChildren(remoteClient); + } + } + } + + /// + /// + /// /// public void SendTerseUpdateToClient(IClientAPI RemoteClient) { LLVector3 lPos; Axiom.MathLib.Quaternion lRot; - if (this._physActor != null && this.physicsEnabled) //is this needed ? doesn't the property fields do this for us? - { - PhysicsVector pPos = this._physActor.Position; - lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); - lRot = this._physActor.Orientation; - } - else - { - lPos = this.Pos; - lRot = this.rotation; - } + + lPos = this.Pos; + lRot = this.rotation; + LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot); } @@ -463,120 +234,5 @@ namespace OpenSim.Region.Environment.Scenes } #endregion - - #region Create Methods - - /// - /// - /// - /// - /// - /// - public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID) - { - PrimData PData = new PrimData(); - this.primData = PData; - this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - - PData.OwnerID = ownerID; - PData.PCode = addPacket.ObjectData.PCode; - PData.PathBegin = addPacket.ObjectData.PathBegin; - PData.PathEnd = addPacket.ObjectData.PathEnd; - PData.PathScaleX = addPacket.ObjectData.PathScaleX; - PData.PathScaleY = addPacket.ObjectData.PathScaleY; - PData.PathShearX = addPacket.ObjectData.PathShearX; - PData.PathShearY = addPacket.ObjectData.PathShearY; - PData.PathSkew = addPacket.ObjectData.PathSkew; - PData.ProfileBegin = addPacket.ObjectData.ProfileBegin; - PData.ProfileEnd = addPacket.ObjectData.ProfileEnd; - PData.Scale = addPacket.ObjectData.Scale; - PData.PathCurve = addPacket.ObjectData.PathCurve; - PData.ProfileCurve = addPacket.ObjectData.ProfileCurve; - PData.ParentID = 0; - PData.ProfileHollow = addPacket.ObjectData.ProfileHollow; - PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; - PData.PathRevolutions = addPacket.ObjectData.PathRevolutions; - PData.PathTaperX = addPacket.ObjectData.PathTaperX; - PData.PathTaperY = addPacket.ObjectData.PathTaperY; - PData.PathTwist = addPacket.ObjectData.PathTwist; - PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; - LLVector3 pos1 = addPacket.ObjectData.RayEnd; - this.primData.FullID = this.uuid = LLUUID.Random(); - this.primData.LocalID = m_localId = (uint)(localID); - this.primData.Position = this.Pos = pos1; - - this.updateFlag = 1; - } - - /// - /// - /// - /// - public void CreateFromBytes(byte[] data) - { - - } - - /// - /// - /// - /// - public void CreateFromPrimData(PrimData primData) - { - this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false); - } - - /// - /// - /// - /// - /// - /// - /// - public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim) - { - - } - - public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) - { - // Console.WriteLine("moving prim to new location " + pos.X + " , " + pos.Y + " , " + pos.Z); - this.Pos = pos; - this.SendTerseUpdateToALLClients(); - } - - 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)primData.CreationDate; - proper.ObjectData[0].CreatorID = 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 = primData.OwnerMask; - proper.ObjectData[0].NextOwnerMask = primData.NextOwnerMask; - proper.ObjectData[0].GroupMask = primData.GroupMask; - proper.ObjectData[0].EveryoneMask = primData.EveryoneMask; - proper.ObjectData[0].BaseMask = primData.BaseMask; - - client.OutPacket(proper); - - } - - #endregion - } } diff --git a/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs b/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs new file mode 100644 index 0000000..d703857 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs @@ -0,0 +1,582 @@ + +/* +* Copyright (c) Contributors, http://www.openmetaverse.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Physics.Manager; +using OpenSim.Framework.Types; +using OpenSim.Framework.Inventory; + +namespace OpenSim.Region.Environment.Scenes +{ + public class PrimitiveOld : Entity + { + internal PrimData primData; + private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); + // private Dictionary m_clientThreads; + private ulong m_regionHandle; + private const uint FULL_MASK_PERMISSIONS = 2147483647; + private bool physicsEnabled = false; + private byte updateFlag = 0; + private uint flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; + + private Dictionary inventoryItems; + + #region Properties + + public LLVector3 Scale + { + set + { + this.primData.Scale = value; + //this.dirtyFlag = true; + } + get + { + return this.primData.Scale; + } + } + + public PhysicsActor PhysActor + { + set + { + this._physActor = value; + } + } + + public override LLVector3 Pos + { + get + { + return base.Pos; + } + set + { + base.Pos = value; + } + } + #endregion + + /// + /// + /// + /// + /// + /// + public PrimitiveOld( ulong regionHandle, Scene world) + { + // m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_world = world; + inventoryItems = new Dictionary(); + } + + /// + /// + /// + /// + /// + /// + /// + /// + public PrimitiveOld(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID) + { + // m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_world = world; + inventoryItems = new Dictionary(); + this.CreateFromPacket(addPacket, ownerID, localID); + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + public PrimitiveOld( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID) + { + // m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_world = world; + inventoryItems = new Dictionary(); + this.primData = new PrimData(); + this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + this.primData.OwnerID = owner; + this.primData.FullID = this.uuid = fullID; + this.primData.LocalID = m_localId = localID; + } + + /// + /// Constructor to create a default cube + /// + /// + /// + /// + /// + /// + /// + public PrimitiveOld( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position) + { + //m_clientThreads = clientThreads; + m_regionHandle = regionHandle; + m_world = world; + inventoryItems = new Dictionary(); + this.primData = PrimData.DefaultCube(); + this.primData.OwnerID = owner; + this.primData.LocalID = m_localId = localID; + this.Pos = this.primData.Position = position; + + this.updateFlag = 1; + } + + /// + /// + /// + /// + public byte[] GetByteArray() + { + byte[] result = null; + List dataArrays = new List(); + dataArrays.Add(primData.ToBytes()); + foreach (Entity child in children) + { + if (child is OpenSim.Region.Environment.Scenes.PrimitiveOld) + { + dataArrays.Add(((OpenSim.Region.Environment.Scenes.PrimitiveOld)child).GetByteArray()); + } + } + byte[] primstart = Helpers.StringToField(""); + byte[] primend = Helpers.StringToField(""); + int totalLength = primstart.Length + primend.Length; + for (int i = 0; i < dataArrays.Count; i++) + { + totalLength += dataArrays[i].Length; + } + + result = new byte[totalLength]; + int arraypos = 0; + Array.Copy(primstart, 0, result, 0, primstart.Length); + arraypos += primstart.Length; + for (int i = 0; i < dataArrays.Count; i++) + { + Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length); + arraypos += dataArrays[i].Length; + } + Array.Copy(primend, 0, result, arraypos, primend.Length); + + return result; + } + + #region Overridden Methods + + /// + /// + /// + public override void update() + { + 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; + } + } + + /// + /// + /// + public override void BackUp() + { + + } + + #endregion + + #region Packet handlers + + /// + /// + /// + /// + public void UpdatePosition(LLVector3 pos) + { + this.Pos = new LLVector3(pos.X, pos.Y, pos.Z); + this.updateFlag = 2; + } + + /// + /// + /// + /// + public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket) + { + this.primData.PathBegin = updatePacket.PathBegin; + this.primData.PathEnd = updatePacket.PathEnd; + this.primData.PathScaleX = updatePacket.PathScaleX; + this.primData.PathScaleY = updatePacket.PathScaleY; + this.primData.PathShearX = updatePacket.PathShearX; + this.primData.PathShearY = updatePacket.PathShearY; + this.primData.PathSkew = updatePacket.PathSkew; + this.primData.ProfileBegin = updatePacket.ProfileBegin; + this.primData.ProfileEnd = updatePacket.ProfileEnd; + this.primData.PathCurve = updatePacket.PathCurve; + this.primData.ProfileCurve = updatePacket.ProfileCurve; + this.primData.ProfileHollow = updatePacket.ProfileHollow; + this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset; + this.primData.PathRevolutions = updatePacket.PathRevolutions; + this.primData.PathTaperX = updatePacket.PathTaperX; + this.primData.PathTaperY = updatePacket.PathTaperY; + this.primData.PathTwist = updatePacket.PathTwist; + this.primData.PathTwistBegin = updatePacket.PathTwistBegin; + } + + /// + /// + /// + /// + public void UpdateTexture(byte[] tex) + { + this.primData.TextureEntry = tex; + } + + /// + /// + /// + /// + public void UpdateObjectFlags(ObjectFlagUpdatePacket pack) + { + + } + + /// + /// + /// + /// + public void AssignToParent(PrimitiveOld prim) + { + + } + + #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 + SendXferPacketPacket send = new SendXferPacketPacket(); + + send.XferID.ID = xferID; + send.XferID.Packet = 1 + 2147483648; + send.DataPacket.Data = this.ConvertInventoryToBytes(); + + simClient.OutPacket(send); + } + + /// + /// + /// + /// + public byte[] ConvertInventoryToBytes() + { + System.Text.Encoding enc = System.Text.Encoding.ASCII; + byte[] result = new byte[0]; + List inventoryData = new List(); + int totallength = 0; + foreach (InventoryItem invItem in inventoryItems.Values) + { + byte[] data = enc.GetBytes(invItem.ExportString()); + inventoryData.Add(data); + totallength += data.Length; + } + //TODO: copy arrays into the single result array + + return result; + } + + /// + /// + /// + /// + public void CreateInventoryFromBytes(byte[] data) + { + + } + + #endregion + + #region Update viewers Methods + + /// + /// + /// + /// + public void SendFullUpdateForAllChildren(IClientAPI remoteClient) + { + this.SendFullUpdateToClient(remoteClient); + for (int i = 0; i < this.children.Count; i++) + { + if (this.children[i] is PrimitiveOld) + { + ((PrimitiveOld)this.children[i]).SendFullUpdateForAllChildren(remoteClient); + } + } + } + + /// + /// + /// + /// + public void SendFullUpdateToClient(IClientAPI remoteClient) + { + LLVector3 lPos; + if (this._physActor != null && this.physicsEnabled) + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + } + else + { + lPos = this.Pos; + } + + remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.primData, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags); + } + + /// + /// + /// + public void SendFullUpdateToAllClients() + { + List avatars = this.m_world.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + this.SendFullUpdateToClient(avatars[i].ControllingClient); + } + } + + /// + /// + /// + /// + public void SendTerseUpdateToClient(IClientAPI RemoteClient) + { + LLVector3 lPos; + Axiom.MathLib.Quaternion lRot; + if (this._physActor != null && this.physicsEnabled) //is this needed ? doesn't the property fields do this for us? + { + PhysicsVector pPos = this._physActor.Position; + lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z); + lRot = this._physActor.Orientation; + } + else + { + lPos = this.Pos; + lRot = this.rotation; + } + LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); + RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot); + } + + /// + /// + /// + public void SendTerseUpdateToALLClients() + { + List avatars = this.m_world.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + this.SendTerseUpdateToClient(avatars[i].ControllingClient); + } + } + + #endregion + + #region Create Methods + + /// + /// + /// + /// + /// + /// + public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID) + { + PrimData PData = new PrimData(); + this.primData = PData; + this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + + PData.OwnerID = ownerID; + PData.PCode = addPacket.ObjectData.PCode; + PData.PathBegin = addPacket.ObjectData.PathBegin; + PData.PathEnd = addPacket.ObjectData.PathEnd; + PData.PathScaleX = addPacket.ObjectData.PathScaleX; + PData.PathScaleY = addPacket.ObjectData.PathScaleY; + PData.PathShearX = addPacket.ObjectData.PathShearX; + PData.PathShearY = addPacket.ObjectData.PathShearY; + PData.PathSkew = addPacket.ObjectData.PathSkew; + PData.ProfileBegin = addPacket.ObjectData.ProfileBegin; + PData.ProfileEnd = addPacket.ObjectData.ProfileEnd; + PData.Scale = addPacket.ObjectData.Scale; + PData.PathCurve = addPacket.ObjectData.PathCurve; + PData.ProfileCurve = addPacket.ObjectData.ProfileCurve; + PData.ParentID = 0; + PData.ProfileHollow = addPacket.ObjectData.ProfileHollow; + PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; + PData.PathRevolutions = addPacket.ObjectData.PathRevolutions; + PData.PathTaperX = addPacket.ObjectData.PathTaperX; + PData.PathTaperY = addPacket.ObjectData.PathTaperY; + PData.PathTwist = addPacket.ObjectData.PathTwist; + PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; + LLVector3 pos1 = addPacket.ObjectData.RayEnd; + this.primData.FullID = this.uuid = LLUUID.Random(); + this.primData.LocalID = m_localId = (uint)(localID); + this.primData.Position = this.Pos = pos1; + + this.updateFlag = 1; + } + + /// + /// + /// + /// + public void CreateFromBytes(byte[] data) + { + + } + + /// + /// + /// + /// + public void CreateFromPrimData(PrimData primData) + { + this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false); + } + + /// + /// + /// + /// + /// + /// + /// + public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim) + { + + } + + public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) + { + // Console.WriteLine("moving prim to new location " + pos.X + " , " + pos.Y + " , " + pos.Z); + this.Pos = pos; + this.SendTerseUpdateToALLClients(); + } + + 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)primData.CreationDate; + proper.ObjectData[0].CreatorID = 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 = primData.OwnerMask; + proper.ObjectData[0].NextOwnerMask = primData.NextOwnerMask; + proper.ObjectData[0].GroupMask = primData.GroupMask; + proper.ObjectData[0].EveryoneMask = primData.EveryoneMask; + proper.ObjectData[0].BaseMask = primData.BaseMask; + + client.OutPacket(proper); + + } + + #endregion + + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 1d55c4d..f3d461a 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -214,12 +214,16 @@ namespace OpenSim.Region.Environment.Scenes /// public void SelectPrim(uint primLocalID, IClientAPI remoteClient) { - foreach (Entity ent in Entities.Values) + Console.WriteLine("prim selected :" + primLocalID); + foreach (EntityBase ent in Entities.Values) { - if (ent.LocalId == primLocalID) + if (ent is SceneObject) { - ((OpenSim.Region.Environment.Scenes.Primitive)ent).GetProperites(remoteClient); - break; + if (((SceneObject)ent).rootLocalID == primLocalID) + { + ((OpenSim.Region.Environment.Scenes.SceneObject)ent).GetProperites(remoteClient); + break; + } } } } @@ -228,7 +232,7 @@ namespace OpenSim.Region.Environment.Scenes { if (this.Entities.ContainsKey(objectID)) { - ((Primitive)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient); + ((PrimitiveOld)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient); } } @@ -266,7 +270,7 @@ namespace OpenSim.Region.Environment.Scenes { if (ent.LocalId == localID) { - ((OpenSim.Region.Environment.Scenes.Primitive)ent).UpdatePosition(pos); + ((OpenSim.Region.Environment.Scenes.PrimitiveOld)ent).UpdatePosition(pos); break; } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index dbf385d..2ff3976 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -63,12 +63,12 @@ namespace OpenSim.Region.Environment.Scenes private uint _primCount = 702000; private int storageCount; private Mutex updateLock; - + protected AuthenticateSessionsBase authenticateHandler; protected RegionCommsListener regionCommsHost; protected CommunicationsManager commsManager; - protected Dictionary capsHandlers = new Dictionary(); + protected Dictionary capsHandlers = new Dictionary(); protected BaseHttpServer httpListener; public ParcelManager parcelManager; @@ -121,21 +121,21 @@ namespace OpenSim.Region.Environment.Scenes scriptManager = new ScriptManager(this); eventManager = new EventManager(); - OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating new entitities instance"); - Entities = new Dictionary(); + OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs - creating new entitities instance"); + Entities = new Dictionary(); Avatars = new Dictionary(); Prims = new Dictionary(); - OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs - creating LandMap"); + OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs - creating LandMap"); Terrain = new TerrainEngine(); ScenePresence.LoadAnims(); this.httpListener = httpServer; - + } catch (Exception e) { - OpenSim.Framework.Console.MainLog.Instance.Error( "World.cs: Constructor failed with exception " + e.ToString()); + OpenSim.Framework.Console.MainLog.Instance.Error("World.cs: Constructor failed with exception " + e.ToString()); } } #endregion @@ -218,49 +218,7 @@ namespace OpenSim.Region.Environment.Scenes /// public bool Backup() { - /* - try - { - // Terrain backup routines - if (Terrain.tainted > 0) - { - Terrain.tainted = 0; - OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Terrain tainted, saving."); - localStorage.SaveMap(Terrain.getHeights1D()); - OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Terrain saved, informing Physics."); - lock (this.m_syncRoot) - { - phyScene.SetTerrain(Terrain.getHeights1D()); - } - } - - // Primitive backup routines - OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: Backup() - Backing up Primitives"); - foreach (libsecondlife.LLUUID UUID in Entities.Keys) - { - Entities[UUID].BackUp(); - } - - //Parcel backup routines - ParcelData[] parcels = new ParcelData[parcelManager.parcelList.Count]; - int i = 0; - foreach (OpenSim.Region.Parcel parcel in parcelManager.parcelList.Values) - { - parcels[i] = parcel.parcelData; - i++; - } - localStorage.SaveParcels(parcels); - - // Backup successful - return true; - } - catch (Exception e) - { - // Backup failed - OpenSim.Framework.Console.MainLog.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.HIGH, "World.cs: Backup() - Backup Failed with exception " + e.ToString()); - return false; - } - */ + return true; } #endregion @@ -432,7 +390,7 @@ namespace OpenSim.Region.Environment.Scenes { try { - OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs: LoadPrimsFromStorage() - Loading primitives"); + OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives"); this.localStorage.LoadPrimitives(this); } catch (Exception e) @@ -469,13 +427,12 @@ namespace OpenSim.Region.Environment.Scenes { try { - Primitive prim = new Primitive(m_regionHandle, this, addPacket, ownerID, this._primCount); - - this.Entities.Add(prim.uuid, prim); + SceneObject sceneOb = new SceneObject(m_regionHandle, this, addPacket, ownerID, this._primCount); + this.Entities.Add(sceneOb.rootUUID, sceneOb); this._primCount++; // Trigger event for listeners - eventManager.TriggerOnNewPrimitive(prim); + // eventManager.TriggerOnNewPrimitive(prim); } catch (Exception e) { @@ -500,11 +457,11 @@ namespace OpenSim.Region.Environment.Scenes client.OnChatFromViewer += this.SimChat; client.OnRequestWearables += this.InformClientOfNeighbours; client.OnAddPrim += this.AddNewPrim; - client.OnUpdatePrimPosition += this.UpdatePrimPosition; + //client.OnUpdatePrimPosition += this.UpdatePrimPosition; client.OnRequestMapBlocks += this.RequestMapBlocks; client.OnTeleportLocationRequest += this.RequestTeleportLocation; - //remoteClient.OnObjectSelect += this.SelectPrim; - client.OnGrapUpdate += this.MoveObject; + client.OnObjectSelect += this.SelectPrim; + // client.OnGrapUpdate += this.MoveObject; client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); @@ -523,39 +480,39 @@ namespace OpenSim.Region.Environment.Scenes { ScenePresence newAvatar = null; - OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); - newAvatar = new ScenePresence(client, this, this.m_regInfo); - OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Adding new avatar to world"); - OpenSim.Framework.Console.MainLog.Instance.Verbose( "World.cs:AddViewerAgent() - Starting RegionHandshake "); + OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent"); + newAvatar = new ScenePresence(client, this, this.m_regInfo); + OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Adding new avatar to world"); + OpenSim.Framework.Console.MainLog.Instance.Verbose("World.cs:AddViewerAgent() - Starting RegionHandshake "); - PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); - lock (this.m_syncRoot) + PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z); + lock (this.m_syncRoot) + { + newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); + } + + lock (Entities) + { + if (!Entities.ContainsKey(client.AgentId)) { - newAvatar.PhysActor = this.phyScene.AddAvatar(pVec); + this.Entities.Add(client.AgentId, newAvatar); } - - lock (Entities) + else { - if (!Entities.ContainsKey(client.AgentId)) - { - this.Entities.Add(client.AgentId, newAvatar); - } - else - { - Entities[client.AgentId] = newAvatar; - } + Entities[client.AgentId] = newAvatar; } - lock (Avatars) + } + lock (Avatars) + { + if (Avatars.ContainsKey(client.AgentId)) { - if (Avatars.ContainsKey(client.AgentId)) - { - Avatars[client.AgentId] = newAvatar; - } - else - { - this.Avatars.Add(client.AgentId, newAvatar); - } + Avatars[client.AgentId] = newAvatar; } + else + { + this.Avatars.Add(client.AgentId, newAvatar); + } + } } @@ -634,7 +591,7 @@ namespace OpenSim.Region.Environment.Scenes public void RegisterRegionWithComms() { GridInfo gridSettings = new GridInfo(); - this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo,gridSettings); + this.regionCommsHost = this.commsManager.GridServer.RegisterRegion(this.m_regInfo, gridSettings); if (this.regionCommsHost != null) { this.regionCommsHost.OnExpectUser += this.NewUserConnection; @@ -757,7 +714,9 @@ namespace OpenSim.Region.Environment.Scenes agent.child = true; this.commsManager.InterRegion.InformRegionOfChildAgent(regionHandle, agent); this.commsManager.InterRegion.ExpectAvatarCrossing(regionHandle, remoteClient.AgentId, position); + remoteClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4)); + } //remoteClient.SendTeleportCancel(); } @@ -771,7 +730,7 @@ namespace OpenSim.Region.Environment.Scenes /// public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position) { - return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position); + return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position); } #endregion diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index e06acbd..00ab194 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -44,7 +44,7 @@ namespace OpenSim.Region.Environment.Scenes { public abstract class SceneBase : IWorld { - public Dictionary Entities; + public Dictionary Entities; protected Dictionary m_clientThreads; protected ulong m_regionHandle; protected string m_regionName; diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index fa1bacb..ac887c0 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -15,7 +15,7 @@ namespace OpenSim.Region.Environment.Scenes public delegate void OnNewPresenceDelegate(ScenePresence presence); public event OnNewPresenceDelegate OnNewPresence; - public delegate void OnNewPrimitiveDelegate(Primitive prim); + public delegate void OnNewPrimitiveDelegate(PrimitiveOld prim); public event OnNewPrimitiveDelegate OnNewPrimitive; public delegate void OnRemovePresenceDelegate(libsecondlife.LLUUID uuid); @@ -29,7 +29,7 @@ namespace OpenSim.Region.Environment.Scenes } } - public void TriggerOnNewPrimitive(Primitive prim) + public void TriggerOnNewPrimitive(PrimitiveOld prim) { if (OnNewPrimitive != null) OnNewPrimitive(prim); diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index 88fb160..a228638 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs @@ -37,22 +37,46 @@ using OpenSim.Framework.Inventory; namespace OpenSim.Region.Environment.Scenes { - public class SceneObject : Entity + public class SceneObject : EntityBase { - private LLUUID rootUUID; - //private Dictionary ChildPrimitives = new Dictionary(); + + private Dictionary ChildPrimitives = new Dictionary(); //list of all primitive id's that are part of this group protected Primitive rootPrimitive; private Scene m_world; - protected ulong regionHandle; + protected ulong m_regionHandle; + private bool physicsEnabled = false; + private PhysicsScene m_PhysScene; + private PhysicsActor m_PhysActor; + + public LLUUID rootUUID + { + get + { + this.uuid = this.rootPrimitive.uuid; + return this.uuid; + } + } + + public uint rootLocalID + { + get + { + this.m_localId = this.rootPrimitive.LocalId; + return this.LocalId; + } + } /// /// /// - public SceneObject() + public SceneObject(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID) { + m_regionHandle = regionHandle; + m_world = world; + this.Pos = addPacket.ObjectData.RayEnd; + this.CreateFromPacket(addPacket, ownerID, localID); } - /// /// /// @@ -61,7 +85,9 @@ namespace OpenSim.Region.Environment.Scenes /// public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID agentID, uint localID) { - this.rootPrimitive = new Primitive( this.regionHandle, this.m_world, addPacket, agentID, localID); + this.rootPrimitive = new Primitive( this.m_regionHandle, this.m_world, addPacket, agentID, localID, true, this, this); + this.children.Add(rootPrimitive); + this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); } /// @@ -76,11 +102,19 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// - public override void update() + /// + /// + public Primitive HasChildPrim(LLUUID primID) { + if (this.ChildPrimitives.ContainsKey(primID)) + { + return this.ChildPrimitives[primID]; + } + return null; } + /// /// /// @@ -92,6 +126,18 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// + /// + /// + /// + public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) + { + this.Pos = pos; + this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient); + } + + /// + /// + /// /// public void GetProperites(IClientAPI client) { @@ -100,25 +146,25 @@ namespace OpenSim.Region.Environment.Scenes proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); proper.ObjectData[0].ItemID = LLUUID.Zero; - proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.primData.CreationDate; - proper.ObjectData[0].CreatorID = this.rootPrimitive.primData.OwnerID; + proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate; + proper.ObjectData[0].CreatorID = this.rootPrimitive.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 = this.rootPrimitive.primData.OwnerID; + proper.ObjectData[0].ObjectID = this.rootUUID; + proper.ObjectData[0].OwnerID = this.rootPrimitive.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.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; + proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask; + proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask; + proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask; + proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask; + proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask; client.OutPacket(proper); diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 6366fb8..502d8e6 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -31,8 +31,16 @@ using System.Text; namespace OpenSim.Physics.Manager { + public delegate void PositionUpdate(PhysicsVector position); + public delegate void VelocityUpdate(PhysicsVector velocity); + public delegate void OrientationUpdate(Axiom.MathLib.Quaternion orientation); + public abstract class PhysicsActor { + public event PositionUpdate OnPositionUpdate; + public event VelocityUpdate OnVelocityUpdate; + public event OrientationUpdate OnOrientationUpdate; + public static PhysicsActor Null { get -- cgit v1.1