From 401af6ad4a16a39e1460abaf30df1a1170069087 Mon Sep 17 00:00:00 2001 From: MW Date: Fri, 13 Jul 2007 19:01:09 +0000 Subject: [PATCH] Prim Copying (both CTRL+D and shift-drag) should now work. --- .../Region/Environment/Scenes/Primitive.cs | 18 +++- .../Scenes/Scene.PacketHandlers.cs | 84 ++++++++++--------- .../Region/Environment/Scenes/SceneObject.cs | 8 +- 3 files changed, 66 insertions(+), 44 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index ab5037393f..e20870fb50 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs @@ -163,21 +163,33 @@ namespace OpenSim.Region.Environment.Scenes dupe.inventoryItems = this.inventoryItems; dupe.m_Parent = parent; dupe.m_RootParent = rootParent; - // TODO: Copy this properly. + dupe.m_Shape = this.m_Shape.Copy(); dupe.children = new List(); uint newLocalID = this.m_world.PrimIDAllocate(); dupe.uuid = LLUUID.Random(); dupe.LocalId = newLocalID; + dupe.m_regionHandle = this.m_regionHandle; + + if (parent is SceneObject) + { + dupe.m_isRootPrim = true; + dupe.ParentID = 0; + } + else + { + dupe.m_isRootPrim = false; + dupe.ParentID = ((Primitive)parent).LocalId; + } dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z); dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); - dupe.Pos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); + dupe.m_pos = new LLVector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); rootParent.AddChildToList(dupe); foreach (Primitive prim in this.children) { - Primitive primClone = prim.Copy(this, rootParent); + Primitive primClone = prim.Copy(dupe, rootParent); dupe.children.Add(primClone); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 14bf87c3d1..b86e5c8cb8 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -139,7 +139,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void SimChat(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) { - // Console.WriteLine("Chat message"); + // Console.WriteLine("Chat message"); ScenePresence avatar = null; m_clientManager.ForEachClient(delegate(IClientAPI client) @@ -149,7 +149,7 @@ namespace OpenSim.Region.Environment.Scenes { avatar = this.Avatars[client.AgentId]; // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y)); - dis = (int) avatar.Pos.GetDistanceTo(fromPos); + dis = (int)avatar.Pos.GetDistanceTo(fromPos); //Console.WriteLine("found avatar at " +dis); } @@ -194,7 +194,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void RezObject(AssetBase primAsset, LLVector3 pos) { - + } /// @@ -204,7 +204,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void DeRezObject(Packet packet, IClientAPI simClient) { - + } /// @@ -213,7 +213,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void SendAvatarsToClient(IClientAPI remoteClient) { - + } /// @@ -239,7 +239,15 @@ namespace OpenSim.Region.Environment.Scenes if (originPrim != null) { - //SceneObject copy = originPrim.Copy(); + SceneObject copy = originPrim.Copy(); + copy.Pos = copy.Pos + offset; + this.Entities.Add(copy.rootUUID, copy); + + List avatars = this.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); + } } else @@ -256,7 +264,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void LinkObjects(uint parentPrim, List childPrims) { - SceneObject parenPrim = null; + SceneObject parenPrim = null; foreach (EntityBase ent in Entities.Values) { if (ent is SceneObject) @@ -328,7 +336,7 @@ namespace OpenSim.Region.Environment.Scenes { if (((SceneObject)ent).rootLocalID == primLocalID) { - ((SceneObject)ent).GetProperites(remoteClient); + ((SceneObject)ent).GetProperites(remoteClient); break; } } @@ -342,7 +350,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void PrimDescription(uint primLocalID, string description) { - Primitive prim = null; + Primitive prim = null; foreach (EntityBase ent in Entities.Values) { if (ent is SceneObject) @@ -350,7 +358,7 @@ namespace OpenSim.Region.Environment.Scenes prim = ((SceneObject)ent).HasChildPrim(primLocalID); if (prim != null) { - prim.Description = description; + prim.Description = description; break; } } @@ -381,19 +389,19 @@ namespace OpenSim.Region.Environment.Scenes public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) { - Primitive prim = null; - foreach (EntityBase ent in Entities.Values) - { - if (ent is SceneObject) - { - prim = ((SceneObject)ent).HasChildPrim(objectID); - if (prim != null) - { - ((SceneObject)ent).GrapMovement(offset, pos, remoteClient); - break; - } - } - } + Primitive prim = null; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + prim = ((SceneObject)ent).HasChildPrim(objectID); + if (prim != null) + { + ((SceneObject)ent).GrapMovement(offset, pos, remoteClient); + break; + } + } + } /* if (this.Entities.ContainsKey(objectID)) { @@ -412,7 +420,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) { - + } /// @@ -423,18 +431,18 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) { - Primitive prim = null; - foreach (EntityBase ent in Entities.Values) - { - if (ent is SceneObject) - { - prim = ((SceneObject)ent).HasChildPrim(localID); - if (prim != null) - { - prim.UpdateTextureEntry(texture); - } - } - } + Primitive prim = null; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObject) + { + prim = ((SceneObject)ent).HasChildPrim(localID); + if (prim != null) + { + prim.UpdateTextureEntry(texture); + } + } + } } /// @@ -494,7 +502,7 @@ namespace OpenSim.Region.Environment.Scenes prim = ((SceneObject)ent).HasChildPrim(localID); if (prim != null) { - prim.UpdateGroupMouseRotation( pos, rot); + prim.UpdateGroupMouseRotation(pos, rot); break; } } @@ -532,7 +540,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) { - //Console.WriteLine("trying to update single prim rotation"); + //Console.WriteLine("trying to update single prim rotation"); Primitive prim = null; foreach (EntityBase ent in Entities.Values) { diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index e979186557..d507a98e2c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs @@ -117,11 +117,13 @@ namespace OpenSim.Region.Environment.Scenes dupe.m_world = this.m_world; dupe.m_regionHandle = this.m_regionHandle; - Primitive newRoot = this.rootPrimitive.Copy((EntityBase)dupe, dupe); + Primitive newRoot = this.rootPrimitive.Copy(dupe, dupe); dupe.rootPrimitive = newRoot; - dupe.rootPrimitive.Pos =( this.Pos + new LLVector3(0,0,1)); + dupe.children.Add(dupe.rootPrimitive); + dupe.rootPrimitive.Pos = this.Pos; dupe.Rotation = this.Rotation; - + LLUUID rootu= dupe.rootUUID; + uint rooti = dupe.rootLocalID; return dupe; }