From 2852cda727f86567c18c6fab193ed31195c9934c Mon Sep 17 00:00:00 2001 From: MW Date: Sun, 1 Jul 2007 21:04:33 +0000 Subject: 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. --- OpenSim/Region/Environment/Scenes/Primitive.cs | 53 +++++++++++++++++++--- .../Environment/Scenes/Scene.PacketHandlers.cs | 40 +++++++++++++++- OpenSim/Region/Environment/Scenes/Scene.cs | 18 +++++++- OpenSim/Region/Environment/Scenes/SceneObject.cs | 21 +++++++-- 4 files changed, 118 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index 97e7974..dd8bb02 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 f55c118..d8533b0 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 08adc84..77058cc 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 00df447..2c55a7d 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; -- cgit v1.1