From f71871bca3f2a6a3b49634963c6754b2acba27cd Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 27 Apr 2008 14:37:51 +0000 Subject: * More attachment stuff, reworked some of the inventory routines to be what I need them to be for attachments. --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 27 +++++ .../Region/Environment/Scenes/Scene.Inventory.cs | 133 ++++++++++++++++----- OpenSim/Region/Environment/Scenes/Scene.cs | 2 +- .../Region/Environment/Scenes/SceneObjectGroup.cs | 22 ++++ .../Region/Environment/Scenes/SceneObjectPart.cs | 9 +- 5 files changed, 161 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index cbe5798..e76cf70 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -322,6 +322,22 @@ namespace OpenSim.Region.Environment.Scenes // Calls attach with a Zero position AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero); } + public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt, + uint ItemFlags, uint NextOwnerMask) + { + SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, itemID, LLVector3.Zero, LLVector3.Zero, LLUUID.Zero, (byte)1, true, + (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), + (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), + (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), + ItemFlags, false, false, remoteClient.AgentId, true); + + if (objatt != null) + { + AttachObject(remoteClient,objatt.LocalId,AttachmentPt,new LLQuaternion(0,0,0,1),objatt.AbsolutePosition); + objatt.ScheduleGroupForFullUpdate(); + } + + } public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos) { @@ -338,14 +354,25 @@ namespace OpenSim.Region.Environment.Scenes // Check object for stored attachment point AttachmentPt = (uint)group.GetAttachmentPoint(); + // if we still didn't find a suitable attachment point....... if (AttachmentPt == 0) { AttachmentPt = (uint)AttachmentPoint.LeftHand; + attachPos = LLVector3.Zero; } + } + // Saves and gets assetID + if (group.GetFromAssetID() == LLUUID.Zero) + { + LLUUID newAssetID = m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId); + + // sets assetID so client can show asset as 'attached' in inventory + group.SetFromAssetID(newAssetID); + } group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 67d3dfb..a3e26b4 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1002,9 +1002,65 @@ namespace OpenSim.Region.Environment.Scenes } } } + public LLUUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID AgentId) + { + SceneObjectGroup objectGroup = grp; + if (objectGroup != null) + { + string sceneObjectXml = objectGroup.ToXmlString(); + + CachedUserInfo userInfo = + CommsManager.UserProfileCacheService.GetUserDetails(AgentId); + if (userInfo != null) + { + AssetBase asset = CreateAsset( + objectGroup.GetPartName(objectGroup.LocalId), + objectGroup.GetPartDescription(objectGroup.LocalId), + (sbyte)InventoryType.Object, + (sbyte)AssetType.Object, + Helpers.StringToField(sceneObjectXml)); + AssetCache.AddAsset(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.Creator = objectGroup.RootPart.CreatorID; + item.Owner = remoteClient.AgentId; + item.ID = LLUUID.Random(); + item.AssetID = asset.FullID; + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + item.InvType = asset.InvType; + + // Sticking it in root folder for now.. objects folder later? + + item.Folder = userInfo.RootFolder.ID;// DeRezPacket.AgentBlock.DestinationID; + item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; + if (remoteClient.AgentId != objectGroup.RootPart.OwnerID) + { + item.BasePermissions = objectGroup.RootPart.NextOwnerMask; + item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask; + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; + } + else + { + item.BasePermissions = objectGroup.RootPart.BaseMask; + item.CurrentPermissions = objectGroup.RootPart.OwnerMask; + item.NextPermissions = objectGroup.RootPart.NextOwnerMask; + } + + userInfo.AddItem(remoteClient.AgentId, item); + remoteClient.SendInventoryItemCreateUpdate(item); + return item.AssetID; + } + return LLUUID.Zero; + } + return LLUUID.Zero; + + } /// - /// Rez an object into a scene + /// Event Handler Rez an object into a scene + /// Calls the non-void event handler /// /// /// @@ -1025,6 +1081,38 @@ namespace OpenSim.Region.Environment.Scenes uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, bool RezSelected, bool RemoveItem, LLUUID fromTaskID) { + SceneObjectGroup sog = RezObject(remoteClient, itemID, RayEnd, RayStart, + RayTargetID, BypassRayCast, RayEndIsIntersection, + EveryoneMask, GroupMask, NextOwnerMask, ItemFlags, + RezSelected, RemoveItem, fromTaskID, false); + } + + + + /// + /// Returns SceneObjectGroup or null from asset request. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 RayEnd, LLVector3 RayStart, + LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, + uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, + bool RezSelected, bool RemoveItem, LLUUID fromTaskID, bool attachment) + { // Work out position details byte bRayEndIsIntersection = (byte)0; @@ -1042,9 +1130,9 @@ namespace OpenSim.Region.Environment.Scenes RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), BypassRayCast, bRayEndIsIntersection); - if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos)) + if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos) && !attachment) { - return; + return null; } // Rez object @@ -1064,7 +1152,14 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); group.ResetIDs(); AddEntity(group); - group.AbsolutePosition = pos; + + // if attachment we set it's asset id so object updates can reflect that + // if not, we set it's position in world. + if (!attachment) + group.AbsolutePosition = pos; + else + group.SetFromAssetID(itemID); + SceneObjectPart rootPart = group.GetChildPart(group.UUID); // Since renaming the item in the inventory does not affect the name stored @@ -1092,34 +1187,18 @@ namespace OpenSim.Region.Environment.Scenes group.ApplyPhysics(m_physicalPrim); group.StartScripts(); - //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim); - //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) - //{ - //PrimitiveBaseShape pbs = rootPart.Shape; - //rootPart.PhysActor = PhysicsScene.AddPrimShape( - //rootPart.Name, - //pbs, - //new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y, - // rootPart.AbsolutePosition.Z), - //new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), - //new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, - // rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); - - // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); - - // } - // - rootPart.ScheduleFullUpdate(); + + if (!attachment) + rootPart.ScheduleFullUpdate(); + + return rootPart.ParentGroup; } } } } + return null; } - public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt, - uint ItemFlags, uint NextOwnerMask) - { - Console.WriteLine("RezSingleAttachment: unimplemented yet"); - } + } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index b16b4aa..a9fa93e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1559,7 +1559,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnGrabUpdate += m_innerScene.MoveObject; client.OnDeRezObject += DeRezObject; client.OnRezObject += RezObject; - client.OnRezSingleAttachmentFromInv += RezSingleAttachment; + client.OnRezSingleAttachmentFromInv += m_innerScene.RezSingleAttachment; client.OnObjectAttach += m_innerScene.AttachObject; client.OnObjectDetach += m_innerScene.DetachObject; client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 7596e24..2493ed8 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Drawing; using System.IO; using System.Xml; +using System.Xml.Serialization; using Axiom.Math; using libsecondlife; using libsecondlife.Packets; @@ -89,6 +90,7 @@ namespace OpenSim.Region.Environment.Scenes /// since the group's last persistent backup /// public bool HasGroupChanged = false; + private LLVector3 lastPhysGroupPos; @@ -484,6 +486,26 @@ namespace OpenSim.Region.Environment.Scenes { } + public void SetFromAssetID(LLUUID AssetId) + { + lock (m_parts) + { + foreach (SceneObjectPart part in m_parts.Values) + { + part.fromAssetID = AssetId; + } + } + } + + public LLUUID GetFromAssetID() + { + if (m_rootPart != null) + { + return m_rootPart.fromAssetID; + } + return LLUUID.Zero; + } + /// /// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes. /// diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 50c96e1..0db9b91 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -104,6 +104,7 @@ namespace OpenSim.Region.Environment.Scenes [XmlIgnore] public uint m_attachmentPoint = (byte)0; [XmlIgnore] public LLUUID m_attachedAvatar = LLUUID.Zero; [XmlIgnore] public LLVector3 m_attachedPos = LLVector3.Zero; + [XmlIgnore] public LLUUID fromAssetID = LLUUID.Zero; public Int32 CreationDate; public uint ParentID = 0; @@ -2251,7 +2252,7 @@ namespace OpenSim.Region.Environment.Scenes byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, lPos, clientFlags, m_uuid, OwnerID, - m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation, m_IsAttachment, m_attachmentPoint); + m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation, m_IsAttachment, m_attachmentPoint,fromAssetID); } /// Terse updates @@ -2297,7 +2298,7 @@ namespace OpenSim.Region.Environment.Scenes LLQuaternion mRot = RotationOffset; if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) { - remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State); + remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State, fromAssetID); } else { @@ -2312,13 +2313,13 @@ namespace OpenSim.Region.Environment.Scenes LLQuaternion mRot = RotationOffset; if (m_IsAttachment) { - remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, (byte)((m_attachmentPoint % 16) * 16 + (m_attachmentPoint / 16))); + remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, (byte)((m_attachmentPoint % 16) * 16 + (m_attachmentPoint / 16)),fromAssetID); } else { if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) { - remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State); + remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State, fromAssetID); } else { -- cgit v1.1