aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Attachments
diff options
context:
space:
mode:
authorMic Bowman2011-08-29 09:55:34 -0700
committerMic Bowman2011-08-29 09:55:34 -0700
commit648866b59761cfbd76e2bd267011c935812770d0 (patch)
tree4ff1227fb7fbe684b42deabd07de5831ae6497da /OpenSim/Region/CoreModules/Avatar/Attachments
parentBulletSim: add mesh representation. Use meshes for static objects and switch ... (diff)
parentMove GetMeshKey from buried inside Meshmerizer to a public method on Primitiv... (diff)
downloadopensim-SC_OLD-648866b59761cfbd76e2bd267011c935812770d0.zip
opensim-SC_OLD-648866b59761cfbd76e2bd267011c935812770d0.tar.gz
opensim-SC_OLD-648866b59761cfbd76e2bd267011c935812770d0.tar.bz2
opensim-SC_OLD-648866b59761cfbd76e2bd267011c935812770d0.tar.xz
Merge branch 'master' into bulletsim
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs61
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs21
2 files changed, 39 insertions, 43 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 3e1cb02..2d5eb18 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -167,13 +167,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
167 return AttachObject(sp, group, AttachmentPt, silent); 167 return AttachObject(sp, group, AttachmentPt, silent);
168 } 168 }
169 169
170 private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent) 170 private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent)
171 { 171 {
172// m_log.DebugFormat( 172// m_log.DebugFormat(
173// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", 173// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
174// group.Name, group.LocalId, sp.Name, AttachmentPt, silent); 174// group.Name, group.LocalId, sp.Name, AttachmentPt, silent);
175 175
176 if (sp.GetAttachments(AttachmentPt).Contains(group)) 176 if (sp.GetAttachments(attachmentPt).Contains(group))
177 { 177 {
178// m_log.WarnFormat( 178// m_log.WarnFormat(
179// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", 179// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
@@ -186,39 +186,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
186 186
187 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 187 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
188 // be removed when that functionality is implemented in opensim 188 // be removed when that functionality is implemented in opensim
189 AttachmentPt &= 0x7f; 189 attachmentPt &= 0x7f;
190 190
191 // If the attachment point isn't the same as the one previously used 191 // If the attachment point isn't the same as the one previously used
192 // set it's offset position = 0 so that it appears on the attachment point 192 // set it's offset position = 0 so that it appears on the attachment point
193 // and not in a weird location somewhere unknown. 193 // and not in a weird location somewhere unknown.
194 if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint()) 194 if (attachmentPt != 0 && attachmentPt != group.AttachmentPoint)
195 { 195 {
196 attachPos = Vector3.Zero; 196 attachPos = Vector3.Zero;
197 } 197 }
198 198
199 // AttachmentPt 0 means the client chose to 'wear' the attachment. 199 // AttachmentPt 0 means the client chose to 'wear' the attachment.
200 if (AttachmentPt == 0) 200 if (attachmentPt == 0)
201 { 201 {
202 // Check object for stored attachment point 202 // Check object for stored attachment point
203 AttachmentPt = (uint)group.GetAttachmentPoint(); 203 attachmentPt = group.AttachmentPoint;
204 } 204 }
205 205
206 // if we still didn't find a suitable attachment point....... 206 // if we still didn't find a suitable attachment point.......
207 if (AttachmentPt == 0) 207 if (attachmentPt == 0)
208 { 208 {
209 // Stick it on left hand with Zero Offset from the attachment point. 209 // Stick it on left hand with Zero Offset from the attachment point.
210 AttachmentPt = (uint)AttachmentPoint.LeftHand; 210 attachmentPt = (uint)AttachmentPoint.LeftHand;
211 attachPos = Vector3.Zero; 211 attachPos = Vector3.Zero;
212 } 212 }
213 213
214 group.SetAttachmentPoint((byte)AttachmentPt); 214 group.AttachmentPoint = attachmentPt;
215 group.AbsolutePosition = attachPos; 215 group.AbsolutePosition = attachPos;
216 216
217 // Remove any previous attachments 217 // Remove any previous attachments
218 UUID itemID = UUID.Zero; 218 UUID itemID = UUID.Zero;
219 foreach (SceneObjectGroup grp in sp.Attachments) 219 foreach (SceneObjectGroup grp in sp.Attachments)
220 { 220 {
221 if (grp.GetAttachmentPoint() == (byte)AttachmentPt) 221 if (grp.AttachmentPoint == attachmentPt)
222 { 222 {
223 itemID = grp.GetFromItemID(); 223 itemID = grp.GetFromItemID();
224 break; 224 break;
@@ -232,9 +232,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
232 if (itemID == UUID.Zero) 232 if (itemID == UUID.Zero)
233 itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID; 233 itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID;
234 234
235 ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); 235 ShowAttachInUserInventory(sp, attachmentPt, itemID, group);
236 236
237 AttachToAgent(sp, group, AttachmentPt, attachPos, silent); 237 AttachToAgent(sp, group, attachmentPt, attachPos, silent);
238 238
239 return true; 239 return true;
240 } 240 }
@@ -293,7 +293,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
293 } 293 }
294 294
295 private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 295 private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
296 ScenePresence sp, UUID itemID, uint AttachmentPt) 296 ScenePresence sp, UUID itemID, uint attachmentPt)
297 { 297 {
298 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 298 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
299 if (invAccess != null) 299 if (invAccess != null)
@@ -313,13 +313,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
313 // since scripts aren't running yet. So, clear it here. 313 // since scripts aren't running yet. So, clear it here.
314 objatt.HasGroupChanged = false; 314 objatt.HasGroupChanged = false;
315 bool tainted = false; 315 bool tainted = false;
316 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 316 if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
317 tainted = true; 317 tainted = true;
318 318
319 // This will throw if the attachment fails 319 // This will throw if the attachment fails
320 try 320 try
321 { 321 {
322 AttachObject(sp, objatt, AttachmentPt, false); 322 AttachObject(sp, objatt, attachmentPt, false);
323 } 323 }
324 catch (Exception e) 324 catch (Exception e)
325 { 325 {
@@ -348,7 +348,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
348 { 348 {
349 m_log.WarnFormat( 349 m_log.WarnFormat(
350 "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", 350 "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
351 itemID, sp.Name, AttachmentPt); 351 itemID, sp.Name, attachmentPt);
352 } 352 }
353 353
354 return objatt; 354 return objatt;
@@ -363,22 +363,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
363 /// <param name="att"></param> 363 /// <param name="att"></param>
364 /// <param name="sp"></param> 364 /// <param name="sp"></param>
365 /// <param name="itemID"></param> 365 /// <param name="itemID"></param>
366 /// <param name="AttachmentPt"></param> 366 /// <param name="attachmentPoint"></param>
367 /// <returns></returns> 367 /// <returns></returns>
368 private UUID ShowAttachInUserInventory( 368 private UUID ShowAttachInUserInventory(
369 SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt) 369 SceneObjectGroup att, ScenePresence sp, UUID itemID, uint attachmentPoint)
370 { 370 {
371// m_log.DebugFormat( 371// m_log.DebugFormat(
372// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})", 372// "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} {2} (item ID {3}) at {4}",
373// remoteClient.Name, att.Name, itemID); 373// sp.Name, att.Name, att.LocalId, itemID, AttachmentPt);
374 374
375 if (!att.IsDeleted) 375 if (!att.IsDeleted)
376 AttachmentPt = att.RootPart.AttachmentPoint; 376 attachmentPoint = att.AttachmentPoint;
377 377
378 InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); 378 InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID);
379 item = m_scene.InventoryService.GetItem(item); 379 item = m_scene.InventoryService.GetItem(item);
380 380
381 bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); 381 bool changed = sp.Appearance.SetAttachment((int)attachmentPoint, itemID, item.AssetID);
382 if (changed && m_scene.AvatarFactory != null) 382 if (changed && m_scene.AvatarFactory != null)
383 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); 383 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
384 384
@@ -547,7 +547,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
547 ); 547 );
548 548
549 group.RootPart.SetParentLocalId(0); 549 group.RootPart.SetParentLocalId(0);
550 group.RootPart.IsAttachment = false; 550 group.IsAttachment = false;
551 group.AbsolutePosition = group.RootPart.AttachedPos; 551 group.AbsolutePosition = group.RootPart.AttachedPos;
552 552
553 UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID); 553 UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID);
@@ -567,11 +567,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
567 // attachment. This is necessary in order to correctly save 567 // attachment. This is necessary in order to correctly save
568 // and retrieve GroupPosition information for the attachment. 568 // and retrieve GroupPosition information for the attachment.
569 // Finally, we restore the object's attachment status. 569 // Finally, we restore the object's attachment status.
570 byte attachmentPoint = sog.GetAttachmentPoint(); 570 uint attachmentPoint = sog.AttachmentPoint;
571 sog.UpdateGroupPosition(pos); 571 sog.UpdateGroupPosition(pos);
572 sog.RootPart.IsAttachment = false; 572 sog.IsAttachment = false;
573 sog.AbsolutePosition = sog.RootPart.AttachedPos; 573 sog.AbsolutePosition = sog.RootPart.AttachedPos;
574 sog.SetAttachmentPoint(attachmentPoint); 574 sog.AttachmentPoint = attachmentPoint;
575 sog.HasGroupChanged = true; 575 sog.HasGroupChanged = true;
576 } 576 }
577 577
@@ -594,14 +594,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
594 { 594 {
595 m_log.DebugFormat( 595 m_log.DebugFormat(
596 "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", 596 "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
597 grp.UUID, grp.GetAttachmentPoint()); 597 grp.UUID, grp.AttachmentPoint);
598 598
599 return; 599 return;
600 } 600 }
601 601
602 m_log.DebugFormat( 602 m_log.DebugFormat(
603 "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", 603 "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
604 grp.UUID, grp.GetAttachmentPoint()); 604 grp.UUID, grp.AttachmentPoint);
605 605
606 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); 606 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
607 607
@@ -666,10 +666,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
666 666
667 so.AbsolutePosition = attachOffset; 667 so.AbsolutePosition = attachOffset;
668 so.RootPart.AttachedPos = attachOffset; 668 so.RootPart.AttachedPos = attachOffset;
669 so.RootPart.IsAttachment = true; 669 so.IsAttachment = true;
670
671 so.RootPart.SetParentLocalId(avatar.LocalId); 670 so.RootPart.SetParentLocalId(avatar.LocalId);
672 so.SetAttachmentPoint(Convert.ToByte(attachmentpoint)); 671 so.AttachmentPoint = attachmentpoint;
673 672
674 avatar.AddAttachment(so); 673 avatar.AddAttachment(so);
675 674
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index b7d21fd..bb53601 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -110,7 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
110 Assert.That(attachments.Count, Is.EqualTo(1)); 110 Assert.That(attachments.Count, Is.EqualTo(1));
111 SceneObjectGroup attSo = attachments[0]; 111 SceneObjectGroup attSo = attachments[0];
112 Assert.That(attSo.Name, Is.EqualTo(attName)); 112 Assert.That(attSo.Name, Is.EqualTo(attName));
113 Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); 113 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
114 Assert.That(attSo.IsAttachment); 114 Assert.That(attSo.IsAttachment);
115 Assert.That(attSo.UsesPhysics, Is.False); 115 Assert.That(attSo.UsesPhysics, Is.False);
116 Assert.That(attSo.IsTemporary, Is.False); 116 Assert.That(attSo.IsTemporary, Is.False);
@@ -132,9 +132,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
132 UUID attAssetId = TestHelpers.ParseTail(0x3); 132 UUID attAssetId = TestHelpers.ParseTail(0x3);
133 string attName = "att"; 133 string attName = "att";
134 134
135 InventoryItemBase attItem 135 UserInventoryHelpers.CreateInventoryItem(
136 = UserInventoryHelpers.CreateInventoryItem( 136 scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
137 scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
138 137
139 m_attMod.RezSingleAttachmentFromInventory( 138 m_attMod.RezSingleAttachmentFromInventory(
140 m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); 139 m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
@@ -145,7 +144,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
145 Assert.That(attachments.Count, Is.EqualTo(1)); 144 Assert.That(attachments.Count, Is.EqualTo(1));
146 SceneObjectGroup attSo = attachments[0]; 145 SceneObjectGroup attSo = attachments[0];
147 Assert.That(attSo.Name, Is.EqualTo(attName)); 146 Assert.That(attSo.Name, Is.EqualTo(attName));
148 Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); 147 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
149 Assert.That(attSo.IsAttachment); 148 Assert.That(attSo.IsAttachment);
150 Assert.That(attSo.UsesPhysics, Is.False); 149 Assert.That(attSo.UsesPhysics, Is.False);
151 Assert.That(attSo.IsTemporary, Is.False); 150 Assert.That(attSo.IsTemporary, Is.False);
@@ -166,9 +165,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
166 UUID attAssetId = TestHelpers.ParseTail(0x3); 165 UUID attAssetId = TestHelpers.ParseTail(0x3);
167 string attName = "att"; 166 string attName = "att";
168 167
169 InventoryItemBase attItem 168 UserInventoryHelpers.CreateInventoryItem(
170 = UserInventoryHelpers.CreateInventoryItem( 169 scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
171 scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
172 170
173 UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( 171 UUID attSoId = m_attMod.RezSingleAttachmentFromInventory(
174 m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); 172 m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
@@ -198,9 +196,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
198 UUID attAssetId = TestHelpers.ParseTail(0x3); 196 UUID attAssetId = TestHelpers.ParseTail(0x3);
199 string attName = "att"; 197 string attName = "att";
200 198
201 InventoryItemBase attItem 199 UserInventoryHelpers.CreateInventoryItem(
202 = UserInventoryHelpers.CreateInventoryItem( 200 scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
203 scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
204 201
205 m_attMod.RezSingleAttachmentFromInventory( 202 m_attMod.RezSingleAttachmentFromInventory(
206 m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); 203 m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
@@ -242,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
242 Assert.That(attachments.Count, Is.EqualTo(1)); 239 Assert.That(attachments.Count, Is.EqualTo(1));
243 SceneObjectGroup attSo = attachments[0]; 240 SceneObjectGroup attSo = attachments[0];
244 Assert.That(attSo.Name, Is.EqualTo(attName)); 241 Assert.That(attSo.Name, Is.EqualTo(attName));
245 Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); 242 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
246 Assert.That(attSo.IsAttachment); 243 Assert.That(attSo.IsAttachment);
247 Assert.That(attSo.UsesPhysics, Is.False); 244 Assert.That(attSo.UsesPhysics, Is.False);
248 Assert.That(attSo.IsTemporary, Is.False); 245 Assert.That(attSo.IsTemporary, Is.False);