aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
authorTeravus Ovares2008-04-27 14:37:51 +0000
committerTeravus Ovares2008-04-27 14:37:51 +0000
commitf71871bca3f2a6a3b49634963c6754b2acba27cd (patch)
tree63fd08f44d1787c1dd1af63009a49f433a7dad91 /OpenSim/Region/Environment/Scenes
parentThank you Melanie for implementing (diff)
downloadopensim-SC-f71871bca3f2a6a3b49634963c6754b2acba27cd.zip
opensim-SC-f71871bca3f2a6a3b49634963c6754b2acba27cd.tar.gz
opensim-SC-f71871bca3f2a6a3b49634963c6754b2acba27cd.tar.bz2
opensim-SC-f71871bca3f2a6a3b49634963c6754b2acba27cd.tar.xz
* More attachment stuff, reworked some of the inventory routines to be what I need them to be for attachments.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs27
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs133
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs22
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectPart.cs9
5 files changed, 161 insertions, 32 deletions
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
322 // Calls attach with a Zero position 322 // Calls attach with a Zero position
323 AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero); 323 AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, LLVector3.Zero);
324 } 324 }
325 public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt,
326 uint ItemFlags, uint NextOwnerMask)
327 {
328 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, itemID, LLVector3.Zero, LLVector3.Zero, LLUUID.Zero, (byte)1, true,
329 (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer),
330 (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer),
331 (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer),
332 ItemFlags, false, false, remoteClient.AgentId, true);
333
334 if (objatt != null)
335 {
336 AttachObject(remoteClient,objatt.LocalId,AttachmentPt,new LLQuaternion(0,0,0,1),objatt.AbsolutePosition);
337 objatt.ScheduleGroupForFullUpdate();
338 }
339
340 }
325 341
326 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos) 342 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos)
327 { 343 {
@@ -338,14 +354,25 @@ namespace OpenSim.Region.Environment.Scenes
338 // Check object for stored attachment point 354 // Check object for stored attachment point
339 AttachmentPt = (uint)group.GetAttachmentPoint(); 355 AttachmentPt = (uint)group.GetAttachmentPoint();
340 356
357
341 // if we still didn't find a suitable attachment point....... 358 // if we still didn't find a suitable attachment point.......
342 if (AttachmentPt == 0) 359 if (AttachmentPt == 0)
343 { 360 {
344 AttachmentPt = (uint)AttachmentPoint.LeftHand; 361 AttachmentPt = (uint)AttachmentPoint.LeftHand;
362 attachPos = LLVector3.Zero;
345 } 363 }
346 364
365
347 } 366 }
348 367
368 // Saves and gets assetID
369 if (group.GetFromAssetID() == LLUUID.Zero)
370 {
371 LLUUID newAssetID = m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId);
372
373 // sets assetID so client can show asset as 'attached' in inventory
374 group.SetFromAssetID(newAssetID);
375 }
349 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos); 376 group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos);
350 377
351 } 378 }
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
1002 } 1002 }
1003 } 1003 }
1004 } 1004 }
1005 public LLUUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID AgentId)
1006 {
1007 SceneObjectGroup objectGroup = grp;
1008 if (objectGroup != null)
1009 {
1010 string sceneObjectXml = objectGroup.ToXmlString();
1011
1012 CachedUserInfo userInfo =
1013 CommsManager.UserProfileCacheService.GetUserDetails(AgentId);
1014 if (userInfo != null)
1015 {
1016 AssetBase asset = CreateAsset(
1017 objectGroup.GetPartName(objectGroup.LocalId),
1018 objectGroup.GetPartDescription(objectGroup.LocalId),
1019 (sbyte)InventoryType.Object,
1020 (sbyte)AssetType.Object,
1021 Helpers.StringToField(sceneObjectXml));
1022 AssetCache.AddAsset(asset);
1023
1024 InventoryItemBase item = new InventoryItemBase();
1025 item.Creator = objectGroup.RootPart.CreatorID;
1026 item.Owner = remoteClient.AgentId;
1027 item.ID = LLUUID.Random();
1028 item.AssetID = asset.FullID;
1029 item.Description = asset.Description;
1030 item.Name = asset.Name;
1031 item.AssetType = asset.Type;
1032 item.InvType = asset.InvType;
1033
1034 // Sticking it in root folder for now.. objects folder later?
1035
1036 item.Folder = userInfo.RootFolder.ID;// DeRezPacket.AgentBlock.DestinationID;
1037 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1038 if (remoteClient.AgentId != objectGroup.RootPart.OwnerID)
1039 {
1040 item.BasePermissions = objectGroup.RootPart.NextOwnerMask;
1041 item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask;
1042 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1043 }
1044 else
1045 {
1046 item.BasePermissions = objectGroup.RootPart.BaseMask;
1047 item.CurrentPermissions = objectGroup.RootPart.OwnerMask;
1048 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1049 }
1050
1051 userInfo.AddItem(remoteClient.AgentId, item);
1052 remoteClient.SendInventoryItemCreateUpdate(item);
1053 return item.AssetID;
1054 }
1055 return LLUUID.Zero;
1056 }
1057 return LLUUID.Zero;
1058
1059 }
1005 1060
1006 /// <summary> 1061 /// <summary>
1007 /// Rez an object into a scene 1062 /// Event Handler Rez an object into a scene
1063 /// Calls the non-void event handler
1008 /// </summary> 1064 /// </summary>
1009 /// <param name="remoteClient"></param> 1065 /// <param name="remoteClient"></param>
1010 /// <param name="itemID"></param> 1066 /// <param name="itemID"></param>
@@ -1025,6 +1081,38 @@ namespace OpenSim.Region.Environment.Scenes
1025 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, 1081 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags,
1026 bool RezSelected, bool RemoveItem, LLUUID fromTaskID) 1082 bool RezSelected, bool RemoveItem, LLUUID fromTaskID)
1027 { 1083 {
1084 SceneObjectGroup sog = RezObject(remoteClient, itemID, RayEnd, RayStart,
1085 RayTargetID, BypassRayCast, RayEndIsIntersection,
1086 EveryoneMask, GroupMask, NextOwnerMask, ItemFlags,
1087 RezSelected, RemoveItem, fromTaskID, false);
1088 }
1089
1090
1091
1092 /// <summary>
1093 /// Returns SceneObjectGroup or null from asset request.
1094 /// </summary>
1095 /// <param name="remoteClient"></param>
1096 /// <param name="itemID"></param>
1097 /// <param name="RayEnd"></param>
1098 /// <param name="RayStart"></param>
1099 /// <param name="RayTargetID"></param>
1100 /// <param name="BypassRayCast"></param>
1101 /// <param name="RayEndIsIntersection"></param>
1102 /// <param name="EveryoneMask"></param>
1103 /// <param name="GroupMask"></param>
1104 /// <param name="NextOwnerMask"></param>
1105 /// <param name="ItemFlags"></param>
1106 /// <param name="RezSelected"></param>
1107 /// <param name="RemoveItem"></param>
1108 /// <param name="fromTaskID"></param>
1109 /// <param name="difference"></param>
1110 /// <returns></returns>
1111 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, LLUUID itemID, LLVector3 RayEnd, LLVector3 RayStart,
1112 LLUUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1113 uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags,
1114 bool RezSelected, bool RemoveItem, LLUUID fromTaskID, bool attachment)
1115 {
1028 // Work out position details 1116 // Work out position details
1029 byte bRayEndIsIntersection = (byte)0; 1117 byte bRayEndIsIntersection = (byte)0;
1030 1118
@@ -1042,9 +1130,9 @@ namespace OpenSim.Region.Environment.Scenes
1042 RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1), 1130 RayStart, RayEnd, RayTargetID, new LLQuaternion(0, 0, 0, 1),
1043 BypassRayCast, bRayEndIsIntersection); 1131 BypassRayCast, bRayEndIsIntersection);
1044 1132
1045 if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos)) 1133 if (!PermissionsMngr.CanRezObject(remoteClient.AgentId, pos) && !attachment)
1046 { 1134 {
1047 return; 1135 return null;
1048 } 1136 }
1049 1137
1050 // Rez object 1138 // Rez object
@@ -1064,7 +1152,14 @@ namespace OpenSim.Region.Environment.Scenes
1064 SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData); 1152 SceneObjectGroup group = new SceneObjectGroup(this, m_regionHandle, xmlData);
1065 group.ResetIDs(); 1153 group.ResetIDs();
1066 AddEntity(group); 1154 AddEntity(group);
1067 group.AbsolutePosition = pos; 1155
1156 // if attachment we set it's asset id so object updates can reflect that
1157 // if not, we set it's position in world.
1158 if (!attachment)
1159 group.AbsolutePosition = pos;
1160 else
1161 group.SetFromAssetID(itemID);
1162
1068 SceneObjectPart rootPart = group.GetChildPart(group.UUID); 1163 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
1069 1164
1070 // Since renaming the item in the inventory does not affect the name stored 1165 // Since renaming the item in the inventory does not affect the name stored
@@ -1092,34 +1187,18 @@ namespace OpenSim.Region.Environment.Scenes
1092 group.ApplyPhysics(m_physicalPrim); 1187 group.ApplyPhysics(m_physicalPrim);
1093 group.StartScripts(); 1188 group.StartScripts();
1094 1189
1095 //bool UsePhysics = (((rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) > 0)&& m_physicalPrim); 1190
1096 //if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) 1191 if (!attachment)
1097 //{ 1192 rootPart.ScheduleFullUpdate();
1098 //PrimitiveBaseShape pbs = rootPart.Shape; 1193
1099 //rootPart.PhysActor = PhysicsScene.AddPrimShape( 1194 return rootPart.ParentGroup;
1100 //rootPart.Name,
1101 //pbs,
1102 //new PhysicsVector(rootPart.AbsolutePosition.X, rootPart.AbsolutePosition.Y,
1103 // rootPart.AbsolutePosition.Z),
1104 //new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z),
1105 //new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X,
1106 // rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics);
1107
1108 // rootPart.DoPhysicsPropertyUpdate(UsePhysics, true);
1109
1110 // }
1111 //
1112 rootPart.ScheduleFullUpdate();
1113 } 1195 }
1114 } 1196 }
1115 } 1197 }
1116 } 1198 }
1199 return null;
1117 } 1200 }
1118 1201
1119 public void RezSingleAttachment(IClientAPI remoteClient, LLUUID itemID, uint AttachmentPt, 1202
1120 uint ItemFlags, uint NextOwnerMask)
1121 {
1122 Console.WriteLine("RezSingleAttachment: unimplemented yet");
1123 }
1124 } 1203 }
1125} 1204}
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
1559 client.OnGrabUpdate += m_innerScene.MoveObject; 1559 client.OnGrabUpdate += m_innerScene.MoveObject;
1560 client.OnDeRezObject += DeRezObject; 1560 client.OnDeRezObject += DeRezObject;
1561 client.OnRezObject += RezObject; 1561 client.OnRezObject += RezObject;
1562 client.OnRezSingleAttachmentFromInv += RezSingleAttachment; 1562 client.OnRezSingleAttachmentFromInv += m_innerScene.RezSingleAttachment;
1563 client.OnObjectAttach += m_innerScene.AttachObject; 1563 client.OnObjectAttach += m_innerScene.AttachObject;
1564 client.OnObjectDetach += m_innerScene.DetachObject; 1564 client.OnObjectDetach += m_innerScene.DetachObject;
1565 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; 1565 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;
30using System.Drawing; 30using System.Drawing;
31using System.IO; 31using System.IO;
32using System.Xml; 32using System.Xml;
33using System.Xml.Serialization;
33using Axiom.Math; 34using Axiom.Math;
34using libsecondlife; 35using libsecondlife;
35using libsecondlife.Packets; 36using libsecondlife.Packets;
@@ -89,6 +90,7 @@ namespace OpenSim.Region.Environment.Scenes
89 /// since the group's last persistent backup 90 /// since the group's last persistent backup
90 /// </summary> 91 /// </summary>
91 public bool HasGroupChanged = false; 92 public bool HasGroupChanged = false;
93
92 94
93 95
94 private LLVector3 lastPhysGroupPos; 96 private LLVector3 lastPhysGroupPos;
@@ -484,6 +486,26 @@ namespace OpenSim.Region.Environment.Scenes
484 { 486 {
485 } 487 }
486 488
489 public void SetFromAssetID(LLUUID AssetId)
490 {
491 lock (m_parts)
492 {
493 foreach (SceneObjectPart part in m_parts.Values)
494 {
495 part.fromAssetID = AssetId;
496 }
497 }
498 }
499
500 public LLUUID GetFromAssetID()
501 {
502 if (m_rootPart != null)
503 {
504 return m_rootPart.fromAssetID;
505 }
506 return LLUUID.Zero;
507 }
508
487 /// <summary> 509 /// <summary>
488 /// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes. 510 /// Hooks this object up to the backup event so that it is persisted to the database when the update thread executes.
489 /// </summary> 511 /// </summary>
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
104 [XmlIgnore] public uint m_attachmentPoint = (byte)0; 104 [XmlIgnore] public uint m_attachmentPoint = (byte)0;
105 [XmlIgnore] public LLUUID m_attachedAvatar = LLUUID.Zero; 105 [XmlIgnore] public LLUUID m_attachedAvatar = LLUUID.Zero;
106 [XmlIgnore] public LLVector3 m_attachedPos = LLVector3.Zero; 106 [XmlIgnore] public LLVector3 m_attachedPos = LLVector3.Zero;
107 [XmlIgnore] public LLUUID fromAssetID = LLUUID.Zero;
107 108
108 public Int32 CreationDate; 109 public Int32 CreationDate;
109 public uint ParentID = 0; 110 public uint ParentID = 0;
@@ -2251,7 +2252,7 @@ namespace OpenSim.Region.Environment.Scenes
2251 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; 2252 byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
2252 remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, lPos, clientFlags, m_uuid, 2253 remoteClient.SendPrimitiveToClient(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, lPos, clientFlags, m_uuid,
2253 OwnerID, 2254 OwnerID,
2254 m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation, m_IsAttachment, m_attachmentPoint); 2255 m_text, color, ParentID, m_particleSystem, lRot, m_clickAction, m_TextureAnimation, m_IsAttachment, m_attachmentPoint,fromAssetID);
2255 } 2256 }
2256 2257
2257 /// Terse updates 2258 /// Terse updates
@@ -2297,7 +2298,7 @@ namespace OpenSim.Region.Environment.Scenes
2297 LLQuaternion mRot = RotationOffset; 2298 LLQuaternion mRot = RotationOffset;
2298 if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0) 2299 if ((ObjectFlags & (uint) LLObject.ObjectFlags.Physics) == 0)
2299 { 2300 {
2300 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State); 2301 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State, fromAssetID);
2301 } 2302 }
2302 else 2303 else
2303 { 2304 {
@@ -2312,13 +2313,13 @@ namespace OpenSim.Region.Environment.Scenes
2312 LLQuaternion mRot = RotationOffset; 2313 LLQuaternion mRot = RotationOffset;
2313 if (m_IsAttachment) 2314 if (m_IsAttachment)
2314 { 2315 {
2315 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, (byte)((m_attachmentPoint % 16) * 16 + (m_attachmentPoint / 16))); 2316 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, (byte)((m_attachmentPoint % 16) * 16 + (m_attachmentPoint / 16)),fromAssetID);
2316 } 2317 }
2317 else 2318 else
2318 { 2319 {
2319 if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0) 2320 if ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) == 0)
2320 { 2321 {
2321 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State); 2322 remoteClient.SendPrimTerseUpdate(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, lPos, mRot, Shape.State, fromAssetID);
2322 } 2323 }
2323 else 2324 else
2324 { 2325 {