From 2852cda727f86567c18c6fab193ed31195c9934c Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 1 Jul 2007 21:04:33 +0000 Subject: [PATCH] More work on SceneObject/Primitive and building (Linking is a work in progress as is all). Committing now as I've finished for the night and will be continued tomorrow. --- .../General/Interfaces/IClientAPI.cs | 4 +- .../General/Types/PrimitiveBaseShape.cs | 5 +- OpenSim/Region/ClientStack/ClientView.API.cs | 11 ++-- .../Region/Environment/Scenes/Primitive.cs | 53 ++++++++++++++++--- .../Scenes/Scene.PacketHandlers.cs | 40 +++++++++++++- OpenSim/Region/Environment/Scenes/Scene.cs | 18 ++++++- .../Region/Environment/Scenes/SceneObject.cs | 21 ++++++-- 7 files changed, 129 insertions(+), 23 deletions(-) diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs index 2110b74c98..d62247ccc7 100644 --- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs +++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs @@ -163,8 +163,8 @@ namespace OpenSim.Framework.Interfaces void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint); void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID , uint flags); void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags); - void SendPrimitiveToClient2(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID); - void SendPrimitiveToClient2(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID); + void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID); + void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID); void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation); } } diff --git a/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs b/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs index 094a8a0437..7c8de16ec8 100644 --- a/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/General/Types/PrimitiveBaseShape.cs @@ -36,7 +36,6 @@ namespace OpenSim.Framework.Types public LLVector3 Scale; public byte PathCurve; public byte ProfileCurve; - public uint ParentID = 0; public ushort ProfileHollow; public sbyte PathRadiusOffset; public byte PathRevolutions; @@ -73,13 +72,13 @@ namespace OpenSim.Framework.Types } - public static PrimitiveBaseShape DefaultCube() + public static PrimitiveBaseShape DefaultBox() { PrimitiveBaseShape primShape = new PrimitiveBaseShape(); + primShape.type = ShapeType.Box; primShape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); primShape.PCode = 9; - primShape.ParentID = 0; primShape.PathBegin = 0; primShape.PathEnd = 0; primShape.PathScaleX = 0; diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs index 7a9c6cf1c1..51f02da270 100644 --- a/OpenSim/Region/ClientStack/ClientView.API.cs +++ b/OpenSim/Region/ClientStack/ClientView.API.cs @@ -629,7 +629,7 @@ namespace OpenSim.Region.ClientStack } - public void SendPrimitiveToClient2(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID) + public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); outPacket.RegionData.RegionHandle = regionHandle; @@ -639,6 +639,8 @@ namespace OpenSim.Region.ClientStack outPacket.ObjectData[0].ID = localID; outPacket.ObjectData[0].FullID = objectID; outPacket.ObjectData[0].OwnerID = ownerID; + outPacket.ObjectData[0].Text = enc.GetBytes(text); + outPacket.ObjectData[0].ParentID = parentID; byte[] pb = pos.GetBytes(); Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); byte[] rot = rotation.GetBytes(); @@ -646,7 +648,7 @@ namespace OpenSim.Region.ClientStack OutPacket(outPacket); } - public void SendPrimitiveToClient2(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID) + public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) { ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); outPacket.RegionData.RegionHandle = regionHandle; @@ -656,6 +658,8 @@ namespace OpenSim.Region.ClientStack outPacket.ObjectData[0].ID = localID; outPacket.ObjectData[0].FullID = objectID; outPacket.ObjectData[0].OwnerID = ownerID; + outPacket.ObjectData[0].Text = enc.GetBytes(text); + outPacket.ObjectData[0].ParentID = parentID; byte[] pb = pos.GetBytes(); Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); @@ -876,6 +880,7 @@ namespace OpenSim.Region.ClientStack LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID); objectData.TextureEntry = ntex.ToBytes(); objectData.OwnerID = primData.OwnerID; + objectData.ParentID = primData.ParentID; objectData.PCode = primData.PCode; objectData.PathBegin = primData.PathBegin; objectData.PathEnd = primData.PathEnd; @@ -889,7 +894,6 @@ namespace OpenSim.Region.ClientStack 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; @@ -916,7 +920,6 @@ namespace OpenSim.Region.ClientStack 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; diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index 97e79746c6..dd8bb02e1e 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs @@ -22,8 +22,18 @@ namespace OpenSim.Region.Environment.Scenes private Dictionary inventoryItems; private string description = ""; + + public string SitName = ""; + public string TouchName = ""; + public string Text = ""; + + public LLUUID CreatorID; public LLUUID OwnerID; + public LLUUID LastOwnerID; public Int32 CreationDate; + + public uint ParentID = 0; + public uint OwnerMask = FULL_MASK_PERMISSIONS; public uint NextOwnerMask = FULL_MASK_PERMISSIONS; public uint GroupMask = FULL_MASK_PERMISSIONS; @@ -32,9 +42,9 @@ namespace OpenSim.Region.Environment.Scenes private PrimitiveBaseShape m_Shape; - private SceneObject m_RootParent; - private bool isRootPrim; - private EntityBase m_Parent; + public SceneObject m_RootParent; + public bool isRootPrim; + public EntityBase m_Parent; public override LLVector3 Pos { @@ -51,7 +61,7 @@ namespace OpenSim.Region.Environment.Scenes } set { - this.m_pos = value - m_Parent.Pos; //should we being subtracting the parent position + this.m_pos = m_Parent.Pos - value; //should we being subtracting the parent position } } @@ -108,6 +118,8 @@ namespace OpenSim.Region.Environment.Scenes { this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; this.OwnerID = ownerID; + this.CreatorID = this.OwnerID; + this.LastOwnerID = LLUUID.Zero; this.Pos = addPacket.ObjectData.RayEnd; this.uuid = LLUUID.Random(); this.m_localId = (uint)(localID); @@ -128,7 +140,6 @@ namespace OpenSim.Region.Environment.Scenes 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; @@ -142,7 +153,37 @@ namespace OpenSim.Region.Environment.Scenes public void AddToChildren(SceneObject linkObject) { + // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); + //TODO check permissions + this.children.Add(linkObject.rootPrimitive); + linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent); + this.m_world.DeleteEntity(linkObject.rootUUID); + linkObject.rootPrimitive = null; + } + + public void SetNewParent(Primitive newParent, SceneObject rootParent) + { + LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); + //Console.WriteLine("have a new parent and my old position is " + this.Pos.X + " , " + this.Pos.Y + " , " + this.Pos.Z); + this.isRootPrim = false; + this.m_Parent = newParent; + this.ParentID = newParent.LocalId; + this.SetRootParent(rootParent); + // Console.WriteLine("have a new parent and its position is " + this.m_Parent.Pos.X + " , " + this.m_Parent.Pos.Y + " , " + this.m_Parent.Pos.Z); + this.Pos = oldPos; + // Console.WriteLine("have a new parent so my new offset position is " + this.Pos.X + " , " + this.Pos.Y + " , " + this.Pos.Z); + this.updateFlag = 1; + + } + + public void SetRootParent(SceneObject newRoot) + { + this.m_RootParent = newRoot; + foreach (Primitive child in children) + { + child.SetRootParent(newRoot); + } } /// @@ -187,7 +228,7 @@ namespace OpenSim.Region.Environment.Scenes LLVector3 lPos; lPos = this.Pos; - 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); + remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags, this.uuid, this.OwnerID, this.Text, this.ParentID); } /// diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index f55c118ae9..d8533b07cb 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -193,8 +193,41 @@ namespace OpenSim.Region.Environment.Scenes /// public void LinkObjects(uint parentPrim, List childPrims) { - + SceneObject parenPrim = null; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + if (((SceneObject)ent).rootLocalID == parentPrim) + { + parenPrim = (SceneObject)ent; + break; + } + } + } + List children = new List(); + if (parenPrim != null) + { + for (int i = 0; i < childPrims.Count; i++) + { + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + if (((SceneObject)ent).rootLocalID == childPrims[i]) + { + children.Add((SceneObject)ent); + } + } + } + } + } + + foreach (SceneObject sceneObj in children) + { + parenPrim.AddNewChildPrims(sceneObj); + } } /// @@ -275,7 +308,10 @@ namespace OpenSim.Region.Environment.Scenes { if (this.Entities.ContainsKey(objectID)) { - ((PrimitiveOld)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient); + if (this.Entities[objectID] is SceneObject) + { + ((SceneObject)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient); + } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 08adc84a53..77058ccadd 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -461,10 +461,11 @@ namespace OpenSim.Region.Environment.Scenes client.OnRequestMapBlocks += this.RequestMapBlocks; client.OnTeleportLocationRequest += this.RequestTeleportLocation; client.OnObjectSelect += this.SelectPrim; - // client.OnGrapUpdate += this.MoveObject; + client.OnGrapUpdate += this.MoveObject; client.OnNameFromUUIDRequest += this.commsManager.HandleUUIDNameRequest; client.OnObjectDescription += this.PrimDescription; client.OnObjectName += this.PrimName; + client.OnLinkObjects += this.LinkObjects; /* remoteClient.OnParcelPropertiesRequest += new ParcelPropertiesRequest(parcelManager.handleParcelPropertiesRequest); remoteClient.OnParcelDivideRequest += new ParcelDivideRequest(parcelManager.handleParcelDivideRequest); @@ -585,6 +586,21 @@ namespace OpenSim.Region.Environment.Scenes #endregion + /// + /// + /// + /// + /// + public bool DeleteEntity(LLUUID entID) + { + if (this.Entities.ContainsKey(entID)) + { + this.Entities.Remove(entID); + return true; + } + return false; + } + #region RegionCommsHost /// diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index 00df44718a..2c55a7d11c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs @@ -41,7 +41,7 @@ namespace OpenSim.Region.Environment.Scenes { private System.Text.Encoding enc = System.Text.Encoding.ASCII; private Dictionary ChildPrimitives = new Dictionary(); //list of all primitive id's that are part of this group - protected Primitive rootPrimitive; + public Primitive rootPrimitive; private Scene m_world; protected ulong m_regionHandle; @@ -99,6 +99,16 @@ namespace OpenSim.Region.Environment.Scenes } + + /// + /// + /// + /// + public void AddNewChildPrims(SceneObject primObject) + { + this.rootPrimitive.AddToChildren(primObject); + } + /// /// /// @@ -145,6 +155,7 @@ namespace OpenSim.Region.Environment.Scenes public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) { this.Pos = pos; + this.rootPrimitive.Pos = pos; this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient); } @@ -161,17 +172,17 @@ namespace OpenSim.Region.Environment.Scenes proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); proper.ObjectData[0].ItemID = LLUUID.Zero; proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate; - proper.ObjectData[0].CreatorID = this.rootPrimitive.OwnerID; + proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID; 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].LastOwnerID = this.rootPrimitive.LastOwnerID; proper.ObjectData[0].ObjectID = this.rootUUID; proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID; - proper.ObjectData[0].TouchName = new byte[0]; + proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0"); proper.ObjectData[0].TextureID = new byte[0]; - proper.ObjectData[0].SitName = new byte[0]; + proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName +"\0") ; proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name +"\0"); proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description +"\0"); proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask;