aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-27 00:33:24 +0100
committerJustin Clark-Casey (justincc)2011-08-27 00:33:24 +0100
commit1615e7d29fb6961a3ffe791fde4318f819c1a4b7 (patch)
tree5daf5feb054615ff95ec17f7226a377f03df31ab /OpenSim/Region
parentrefactor: camel case AttachmentPoint method arg as per code standards (diff)
downloadopensim-SC_OLD-1615e7d29fb6961a3ffe791fde4318f819c1a4b7.zip
opensim-SC_OLD-1615e7d29fb6961a3ffe791fde4318f819c1a4b7.tar.gz
opensim-SC_OLD-1615e7d29fb6961a3ffe791fde4318f819c1a4b7.tar.bz2
opensim-SC_OLD-1615e7d29fb6961a3ffe791fde4318f819c1a4b7.tar.xz
Eliminate duplicate AttachmentPoint properties by always using the one stored in the root part's state field.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs42
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Sound/SoundModule.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs36
4 files changed, 41 insertions, 44 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index d9259b3..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;
@@ -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.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
@@ -668,7 +668,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
668 so.RootPart.AttachedPos = attachOffset; 668 so.RootPart.AttachedPos = attachOffset;
669 so.IsAttachment = true; 669 so.IsAttachment = true;
670 so.RootPart.SetParentLocalId(avatar.LocalId); 670 so.RootPart.SetParentLocalId(avatar.LocalId);
671 so.SetAttachmentPoint(Convert.ToByte(attachmentpoint)); 671 so.AttachmentPoint = attachmentpoint;
672 672
673 avatar.AddAttachment(so); 673 avatar.AddAttachment(so);
674 674
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 790a651..bb53601 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -111,7 +111,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
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.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); 113 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
114 Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest));
115 Assert.That(attSo.IsAttachment); 114 Assert.That(attSo.IsAttachment);
116 Assert.That(attSo.UsesPhysics, Is.False); 115 Assert.That(attSo.UsesPhysics, Is.False);
117 Assert.That(attSo.IsTemporary, Is.False); 116 Assert.That(attSo.IsTemporary, Is.False);
@@ -146,7 +145,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
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.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); 147 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
149 Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest));
150 Assert.That(attSo.IsAttachment); 148 Assert.That(attSo.IsAttachment);
151 Assert.That(attSo.UsesPhysics, Is.False); 149 Assert.That(attSo.UsesPhysics, Is.False);
152 Assert.That(attSo.IsTemporary, Is.False); 150 Assert.That(attSo.IsTemporary, Is.False);
@@ -242,7 +240,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
242 SceneObjectGroup attSo = attachments[0]; 240 SceneObjectGroup attSo = attachments[0];
243 Assert.That(attSo.Name, Is.EqualTo(attName)); 241 Assert.That(attSo.Name, Is.EqualTo(attName));
244 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); 242 Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
245 Assert.That(attSo.GetAttachmentPoint(), 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);
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index 09c0ebb..22ffcd6 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
81 81
82 if (grp.IsAttachment) 82 if (grp.IsAttachment)
83 { 83 {
84 if (grp.GetAttachmentPoint() > 30) // HUD 84 if (grp.AttachmentPoint > 30) // HUD
85 { 85 {
86 if (sp.ControllingClient.AgentId != grp.OwnerID) 86 if (sp.ControllingClient.AgentId != grp.OwnerID)
87 return; 87 return;
@@ -115,7 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
115 { 115 {
116 SceneObjectGroup grp = part.ParentGroup; 116 SceneObjectGroup grp = part.ParentGroup;
117 117
118 if (grp.IsAttachment && grp.GetAttachmentPoint() > 30) 118 if (grp.IsAttachment && grp.AttachmentPoint > 30)
119 { 119 {
120 objectID = ownerID; 120 objectID = ownerID;
121 parentID = ownerID; 121 parentID = ownerID;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 34f484d..c453366 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -166,7 +166,24 @@ namespace OpenSim.Region.Framework.Scenes
166 /// <remarks> 166 /// <remarks>
167 /// 0 if we're not attached to anything 167 /// 0 if we're not attached to anything
168 /// </remarks> 168 /// </remarks>
169 public uint AttachmentPoint; 169 public uint AttachmentPoint
170 {
171 get
172 {
173 return m_rootPart.Shape.State;
174 }
175
176 set
177 {
178 IsAttachment = value != 0;
179 m_rootPart.Shape.State = (byte)value;
180 }
181 }
182
183 public void ClearPartAttachmentData()
184 {
185 AttachmentPoint = 0;
186 }
170 187
171 /// <summary> 188 /// <summary>
172 /// Is this scene object phantom? 189 /// Is this scene object phantom?
@@ -976,23 +993,6 @@ namespace OpenSim.Region.Framework.Scenes
976 } 993 }
977 } 994 }
978 995
979 public byte GetAttachmentPoint()
980 {
981 return m_rootPart.Shape.State;
982 }
983
984 public void SetAttachmentPoint(uint point)
985 {
986 AttachmentPoint = point;
987 IsAttachment = point != 0;
988 m_rootPart.Shape.State = (byte)point;
989 }
990
991 public void ClearPartAttachmentData()
992 {
993 SetAttachmentPoint((Byte)0);
994 }
995
996 /// <summary> 996 /// <summary>
997 /// 997 ///
998 /// </summary> 998 /// </summary>