aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorTeravus Ovares2008-04-27 20:10:28 +0000
committerTeravus Ovares2008-04-27 20:10:28 +0000
commit911e63765c7cea748b5ae2227f5c1d6ff131d329 (patch)
treef95eeffb4974a9b3f6ded4a46bdc240278a336b0 /OpenSim/Region/Environment
parentMinor svn, formatting cleanup. (diff)
downloadopensim-SC_OLD-911e63765c7cea748b5ae2227f5c1d6ff131d329.zip
opensim-SC_OLD-911e63765c7cea748b5ae2227f5c1d6ff131d329.tar.gz
opensim-SC_OLD-911e63765c7cea748b5ae2227f5c1d6ff131d329.tar.bz2
opensim-SC_OLD-911e63765c7cea748b5ae2227f5c1d6ff131d329.tar.xz
* Single Attachments now work from inventory. You can attach from inventory and detach from inventory.
* Detaching from right clicking in world, detaches to your inventory. * If you go up to a prim and attach it from in world, it appears in your inventory. * Attachment placement is saved when you detach them. * Choosing wear remembers your last attachment point from inventory. * Wrote a method to update an inventory item's asset and sends the updated inventory item to the Client * Wrote a recursive method to find the folder of a known existing inventory item. * Removed a block on physics object position on creation. This might crash a region or two, let us know via Mantis if your region crashes because of a physics out of bounds error. * Drop doesn't work. The menu item doesn't even come up. Don't know why :P.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs70
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.Inventory.cs99
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs6
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs26
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs10
5 files changed, 195 insertions, 16 deletions
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index e76cf70..104ae48 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -304,7 +304,9 @@ namespace OpenSim.Region.Environment.Scenes
304 if (((SceneObjectGroup)obj).LocalId == objectLocalID) 304 if (((SceneObjectGroup)obj).LocalId == objectLocalID)
305 { 305 {
306 SceneObjectGroup group = (SceneObjectGroup)obj; 306 SceneObjectGroup group = (SceneObjectGroup)obj;
307 group.DetachToGround(); 307
308 //group.DetachToGround();
309 DetachSingleAttachmentToInv(group.GetFromAssetID(),remoteClient);
308 } 310 }
309 } 311 }
310 } 312 }
@@ -339,6 +341,33 @@ namespace OpenSim.Region.Environment.Scenes
339 341
340 } 342 }
341 343
344 // What makes this method odd and unique is it tries to detach using an LLUUID.... Yay for standards.
345 // To LocalId or LLUUID, *THAT* is the question. How now Brown LLUUID??
346 public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient)
347 {
348
349 if (itemID == LLUUID.Zero) // If this happened, someone made a mistake....
350 return;
351
352 List<EntityBase> EntityList = GetEntities();
353
354 foreach (EntityBase obj in EntityList)
355 {
356 if (obj is SceneObjectGroup)
357 {
358 if (((SceneObjectGroup)obj).GetFromAssetID() == itemID)
359 {
360 SceneObjectGroup group = (SceneObjectGroup)obj;
361 group.DetachToInventoryPrep();
362 m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
363 m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(),group.OwnerID);
364 m_parentScene.DeleteSceneObjectGroup(group);
365 }
366 }
367 }
368
369 }
370
342 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos) 371 public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos)
343 { 372 {
344 List<EntityBase> EntityList = GetEntities(); 373 List<EntityBase> EntityList = GetEntities();
@@ -349,21 +378,36 @@ namespace OpenSim.Region.Environment.Scenes
349 if (((SceneObjectGroup)obj).LocalId == objectLocalID) 378 if (((SceneObjectGroup)obj).LocalId == objectLocalID)
350 { 379 {
351 SceneObjectGroup group = (SceneObjectGroup)obj; 380 SceneObjectGroup group = (SceneObjectGroup)obj;
381
382 // If the attachment point isn't the same as the one previously used
383 // set it's offset position = 0 so that it appears on the attachment point
384 // and not in a weird location somewhere unknown.
385 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint())
386 {
387
388 attachPos = LLVector3.Zero;
389 }
390
391 // AttachmentPt 0 means the client chose to 'wear' the attachment.
352 if (AttachmentPt == 0) 392 if (AttachmentPt == 0)
353 { 393 {
394
354 // Check object for stored attachment point 395 // Check object for stored attachment point
355 AttachmentPt = (uint)group.GetAttachmentPoint(); 396 AttachmentPt = (uint)group.GetAttachmentPoint();
397
356 398
399 }
357 400
358 // if we still didn't find a suitable attachment point....... 401 // if we still didn't find a suitable attachment point.......
359 if (AttachmentPt == 0) 402 if (AttachmentPt == 0)
360 { 403 {
361 AttachmentPt = (uint)AttachmentPoint.LeftHand; 404 // Stick it on left hand with Zero Offset from the attachment point.
362 attachPos = LLVector3.Zero; 405 AttachmentPt = (uint)AttachmentPoint.LeftHand;
363 } 406 attachPos = LLVector3.Zero;
364
365
366 } 407 }
408 m_log.Debug("[ATTACH]: Using attachpoint: " + AttachmentPt.ToString());
409
410
367 411
368 // Saves and gets assetID 412 // Saves and gets assetID
369 if (group.GetFromAssetID() == LLUUID.Zero) 413 if (group.GetFromAssetID() == LLUUID.Zero)
@@ -1071,12 +1115,12 @@ namespace OpenSim.Region.Environment.Scenes
1071 if (group != null) 1115 if (group != null)
1072 { 1116 {
1073 LLVector3 oldPos = group.AbsolutePosition; 1117 LLVector3 oldPos = group.AbsolutePosition;
1074 if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos)) 1118 if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos) && !group.RootPart.m_IsAttachment)
1075 { 1119 {
1076 group.SendGroupTerseUpdate(); 1120 group.SendGroupTerseUpdate();
1077 return; 1121 return;
1078 } 1122 }
1079 if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) 1123 if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID) || group.RootPart.m_IsAttachment)
1080 { 1124 {
1081 group.UpdateSinglePosition(pos, localID); 1125 group.UpdateSinglePosition(pos, localID);
1082 } 1126 }
@@ -1102,12 +1146,12 @@ namespace OpenSim.Region.Environment.Scenes
1102 } 1146 }
1103 else 1147 else
1104 { 1148 {
1105 if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos)) 1149 if (!PermissionsMngr.CanObjectEntry(remoteClient.AgentId, oldPos, pos) && !group.RootPart.m_IsAttachment)
1106 { 1150 {
1107 group.SendGroupTerseUpdate(); 1151 group.SendGroupTerseUpdate();
1108 return; 1152 return;
1109 } 1153 }
1110 if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID)) 1154 if (PermissionsMngr.CanEditObjectPosition(remoteClient.AgentId, group.UUID) || group.RootPart.m_IsAttachment)
1111 { 1155 {
1112 group.UpdateGroupPosition(pos); 1156 group.UpdateGroupPosition(pos);
1113 } 1157 }
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index a3e26b4..b5e2c40 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -1002,6 +1002,93 @@ namespace OpenSim.Region.Environment.Scenes
1002 } 1002 }
1003 } 1003 }
1004 } 1004 }
1005 public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID assetID, 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 Queue<InventoryFolderImpl> searchfolders = new Queue<InventoryFolderImpl>();
1017 searchfolders.Enqueue(userInfo.RootFolder);
1018
1019 LLUUID foundFolder = userInfo.RootFolder.ID;
1020
1021 // search through folders to find the asset.
1022 while (searchfolders.Count > 0)
1023 {
1024
1025 InventoryFolderImpl fld = searchfolders.Dequeue();
1026 lock (fld)
1027 {
1028 if (fld != null)
1029 {
1030 if (fld.Items.ContainsKey(assetID))
1031 {
1032 foundFolder = fld.ID;
1033 searchfolders.Clear();
1034 break;
1035 }
1036 else
1037 {
1038 foreach (InventoryFolderImpl subfld in fld.SubFolders.Values)
1039 {
1040 searchfolders.Enqueue(subfld);
1041 }
1042 }
1043 }
1044 }
1045 }
1046 AssetBase asset = CreateAsset(
1047 objectGroup.GetPartName(objectGroup.LocalId),
1048 objectGroup.GetPartDescription(objectGroup.LocalId),
1049 (sbyte)InventoryType.Object,
1050 (sbyte)AssetType.Object,
1051 Helpers.StringToField(sceneObjectXml));
1052 AssetCache.AddAsset(asset);
1053
1054 InventoryItemBase item = new InventoryItemBase();
1055 item.Creator = objectGroup.RootPart.CreatorID;
1056 item.Owner = agentID;
1057 item.ID = assetID;
1058 item.AssetID = asset.FullID;
1059 item.Description = asset.Description;
1060 item.Name = asset.Name;
1061 item.AssetType = asset.Type;
1062 item.InvType = asset.InvType;
1063
1064 // Sticking it in root folder for now.. objects folder later?
1065
1066 item.Folder = foundFolder;// DeRezPacket.AgentBlock.DestinationID;
1067 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1068 if (agentID != objectGroup.RootPart.OwnerID)
1069 {
1070 item.BasePermissions = objectGroup.RootPart.NextOwnerMask;
1071 item.CurrentPermissions = objectGroup.RootPart.NextOwnerMask;
1072 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1073 }
1074 else
1075 {
1076 item.BasePermissions = objectGroup.RootPart.BaseMask;
1077 item.CurrentPermissions = objectGroup.RootPart.OwnerMask;
1078 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1079 }
1080
1081 userInfo.AddItem(agentID, item);
1082
1083 // this gets called when the agent loggs off!
1084 if (remoteClient != null)
1085 {
1086 remoteClient.SendInventoryItemCreateUpdate(item);
1087 }
1088
1089 }
1090 }
1091 }
1005 public LLUUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID AgentId) 1092 public LLUUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID AgentId)
1006 { 1093 {
1007 SceneObjectGroup objectGroup = grp; 1094 SceneObjectGroup objectGroup = grp;
@@ -1184,7 +1271,17 @@ namespace OpenSim.Region.Environment.Scenes
1184 } 1271 }
1185 1272
1186 rootPart.TrimPermissions(); 1273 rootPart.TrimPermissions();
1187 group.ApplyPhysics(m_physicalPrim); 1274
1275 if (!attachment)
1276 {
1277 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
1278 {
1279 group.RootPart.Shape.State = (byte)0;
1280 }
1281 group.ApplyPhysics(m_physicalPrim);
1282 }
1283
1284
1188 group.StartScripts(); 1285 group.StartScripts();
1189 1286
1190 1287
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index a9fa93e..f94aec7 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1471,6 +1471,11 @@ namespace OpenSim.Region.Environment.Scenes
1471 ScenePresence sp = GetScenePresence(grp.OwnerID); 1471 ScenePresence sp = GetScenePresence(grp.OwnerID);
1472 if (sp != null) 1472 if (sp != null)
1473 { 1473 {
1474 // hack assetID until we get assetID into the XML format.
1475 // LastOwnerID is used for group deeding, so when you do stuff
1476 // with the deeded object, it goes back to them
1477
1478 grp.SetFromAssetID(grp.RootPart.LastOwnerID);
1474 m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition); 1479 m_innerScene.AttachObject(sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition);
1475 } 1480 }
1476 } 1481 }
@@ -1560,6 +1565,7 @@ namespace OpenSim.Region.Environment.Scenes
1560 client.OnDeRezObject += DeRezObject; 1565 client.OnDeRezObject += DeRezObject;
1561 client.OnRezObject += RezObject; 1566 client.OnRezObject += RezObject;
1562 client.OnRezSingleAttachmentFromInv += m_innerScene.RezSingleAttachment; 1567 client.OnRezSingleAttachmentFromInv += m_innerScene.RezSingleAttachment;
1568 client.OnDetachAttachmentIntoInv += m_innerScene.DetachSingleAttachmentToInv;
1563 client.OnObjectAttach += m_innerScene.AttachObject; 1569 client.OnObjectAttach += m_innerScene.AttachObject;
1564 client.OnObjectDetach += m_innerScene.DetachObject; 1570 client.OnObjectDetach += m_innerScene.DetachObject;
1565 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; 1571 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest;
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 2493ed8..ba318a8 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -663,9 +663,11 @@ namespace OpenSim.Region.Environment.Scenes
663 { 663 {
664 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); 664 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor);
665 m_rootPart.PhysActor = null; 665 m_rootPart.PhysActor = null;
666 AbsolutePosition = AttachOffset; 666
667 m_rootPart.m_attachedPos = AttachOffset;
668 } 667 }
668
669 AbsolutePosition = AttachOffset;
670 m_rootPart.m_attachedPos = AttachOffset;
669 m_rootPart.m_IsAttachment = true; 671 m_rootPart.m_IsAttachment = true;
670 672
671 m_rootPart.SetParentLocalId(avatar.LocalId); 673 m_rootPart.SetParentLocalId(avatar.LocalId);
@@ -702,6 +704,26 @@ namespace OpenSim.Region.Environment.Scenes
702 AttachToBackup(); 704 AttachToBackup();
703 m_rootPart.ScheduleFullUpdate(); 705 m_rootPart.ScheduleFullUpdate();
704 } 706 }
707 public void DetachToInventoryPrep()
708 {
709 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar);
710 //LLVector3 detachedpos = new LLVector3(127f, 127f, 127f);
711 if (avatar != null)
712 {
713 //detachedpos = avatar.AbsolutePosition;
714 avatar.RemoveAttachment(this);
715 }
716
717 m_rootPart.m_attachedAvatar = LLUUID.Zero;
718 m_rootPart.SetParentLocalId(0);
719 //m_rootPart.SetAttachmentPoint((byte)0);
720 m_rootPart.m_IsAttachment = false;
721 AbsolutePosition = m_rootPart.m_attachedPos;
722 //m_rootPart.ApplyPhysics(m_rootPart.ObjectFlags, m_scene.m_physicalPrim);
723 //AttachToBackup();
724 //m_rootPart.ScheduleFullUpdate();
725
726 }
705 /// <summary> 727 /// <summary>
706 /// 728 ///
707 /// </summary> 729 /// </summary>
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 0849698..74e9cdc 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -1906,6 +1906,15 @@ namespace OpenSim.Region.Environment.Scenes
1906 1906
1907 internal void Close() 1907 internal void Close()
1908 { 1908 {
1909 lock (m_attachments)
1910 {
1911 foreach (SceneObjectGroup grp in m_attachments)
1912 {
1913 // ControllingClient may be null at this point!
1914 m_scene.m_innerScene.DetachSingleAttachmentToInv(grp.GetFromAssetID(), ControllingClient);
1915 }
1916 m_attachments.Clear();
1917 }
1909 lock (m_knownPrimUUID) 1918 lock (m_knownPrimUUID)
1910 { 1919 {
1911 m_knownPrimUUID.Clear(); 1920 m_knownPrimUUID.Clear();
@@ -1972,6 +1981,7 @@ namespace OpenSim.Region.Environment.Scenes
1972 gobj.RootPart.SetParentLocalId(0); 1981 gobj.RootPart.SetParentLocalId(0);
1973 gobj.RootPart.m_IsAttachment = false; 1982 gobj.RootPart.m_IsAttachment = false;
1974 gobj.AbsolutePosition = gobj.RootPart.m_attachedPos; 1983 gobj.AbsolutePosition = gobj.RootPart.m_attachedPos;
1984 gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
1975 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj); 1985 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj);
1976 } 1986 }
1977 } 1987 }