diff options
author | Justin Clark-Casey (justincc) | 2014-05-01 22:24:21 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-05-01 22:24:21 +0100 |
commit | c31d93cb6f478062332c6a04fd1c357bb11205ee (patch) | |
tree | f0894436d88091db8b134ca99501589432a99673 | |
parent | minor: Use Vector2.Zero constant and only set in condition branch where it wa... (diff) | |
download | opensim-SC-c31d93cb6f478062332c6a04fd1c357bb11205ee.zip opensim-SC-c31d93cb6f478062332c6a04fd1c357bb11205ee.tar.gz opensim-SC-c31d93cb6f478062332c6a04fd1c357bb11205ee.tar.bz2 opensim-SC-c31d93cb6f478062332c6a04fd1c357bb11205ee.tar.xz |
Fix issue where only one of multiple attachments on the same attachpoint for NPCs would be seen by other viewers.
It appears that at least Singularity 1.8.5 (but probably others) rely on attachment FromItemIDs being different to display more than one.
This commit resolves this by generating random IDs instead of always using UUID.Zero for NPCs.
Resolves http://opensimulator.org/mantis/view.php?id=7110
4 files changed, 74 insertions, 7 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 3ab837d..7cb5b53 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -5304,10 +5304,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5304 | //update.JointType = 0; | 5304 | //update.JointType = 0; |
5305 | update.Material = data.Material; | 5305 | update.Material = data.Material; |
5306 | update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim | 5306 | update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim |
5307 | |||
5307 | if (data.ParentGroup.IsAttachment) | 5308 | if (data.ParentGroup.IsAttachment) |
5308 | { | 5309 | { |
5309 | update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID); | 5310 | update.NameValue |
5311 | = Util.StringToBytes256( | ||
5312 | string.Format("AttachItemID STRING RW SV {0}", data.ParentGroup.FromItemID)); | ||
5313 | |||
5310 | update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16)); | 5314 | update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16)); |
5315 | |||
5316 | // m_log.DebugFormat( | ||
5317 | // "[LLCLIENTVIEW]: Sending NameValue {0} for {1} {2} to {3}", | ||
5318 | // Util.UTF8.GetString(update.NameValue), data.Name, data.LocalId, Name); | ||
5319 | // | ||
5320 | // m_log.DebugFormat( | ||
5321 | // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}", | ||
5322 | // update.State, data.Name, data.LocalId, Name); | ||
5311 | } | 5323 | } |
5312 | else | 5324 | else |
5313 | { | 5325 | { |
@@ -5318,10 +5330,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5318 | update.State = data.ParentGroup.RootPart.Shape.State; | 5330 | update.State = data.ParentGroup.RootPart.Shape.State; |
5319 | } | 5331 | } |
5320 | 5332 | ||
5321 | // m_log.DebugFormat( | ||
5322 | // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}", | ||
5323 | // update.State, data.Name, data.LocalId, Name); | ||
5324 | |||
5325 | update.ObjectData = objectData; | 5333 | update.ObjectData = objectData; |
5326 | update.ParentID = data.ParentID; | 5334 | update.ParentID = data.ParentID; |
5327 | update.PathBegin = data.Shape.PathBegin; | 5335 | update.PathBegin = data.Shape.PathBegin; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index c3846d9..e9b2f4f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -991,6 +991,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
991 | 991 | ||
992 | return null; | 992 | return null; |
993 | } | 993 | } |
994 | else if (itemID == UUID.Zero) | ||
995 | { | ||
996 | // We need to have a FromItemID for multiple attachments on a single attach point to appear. This is | ||
997 | // true on Singularity 1.8.5 and quite possibly other viewers as well. As NPCs don't have an inventory | ||
998 | // we will satisfy this requirement by inserting a random UUID. | ||
999 | objatt.FromItemID = UUID.Random(); | ||
1000 | } | ||
994 | 1001 | ||
995 | if (DebugLevel > 0) | 1002 | if (DebugLevel > 0) |
996 | m_log.DebugFormat( | 1003 | m_log.DebugFormat( |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 8a2da6e..03c6265 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -178,8 +178,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
178 | acd.lastname = lastname; | 178 | acd.lastname = lastname; |
179 | acd.ServiceURLs = new Dictionary<string, object>(); | 179 | acd.ServiceURLs = new Dictionary<string, object>(); |
180 | 180 | ||
181 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, | 181 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); |
182 | true); | ||
183 | acd.Appearance = npcAppearance; | 182 | acd.Appearance = npcAppearance; |
184 | 183 | ||
185 | /* | 184 | /* |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index ddd4525..e82351e 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -199,6 +199,59 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
199 | } | 199 | } |
200 | 200 | ||
201 | [Test] | 201 | [Test] |
202 | public void TestCreateWithMultiAttachments() | ||
203 | { | ||
204 | TestHelpers.InMethod(); | ||
205 | // TestHelpers.EnableLogging(); | ||
206 | |||
207 | SetUpScene(); | ||
208 | // m_attMod.DebugLevel = 1; | ||
209 | |||
210 | UUID userId = TestHelpers.ParseTail(0x1); | ||
211 | UserAccountHelpers.CreateUserWithInventory(m_scene, userId); | ||
212 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
213 | |||
214 | InventoryItemBase att1Item | ||
215 | = UserInventoryHelpers.CreateInventoryItem( | ||
216 | m_scene, "att1", TestHelpers.ParseTail(0x2), TestHelpers.ParseTail(0x3), sp.UUID, InventoryType.Object); | ||
217 | InventoryItemBase att2Item | ||
218 | = UserInventoryHelpers.CreateInventoryItem( | ||
219 | m_scene, "att2", TestHelpers.ParseTail(0x12), TestHelpers.ParseTail(0x13), sp.UUID, InventoryType.Object); | ||
220 | |||
221 | m_attMod.RezSingleAttachmentFromInventory(sp, att1Item.ID, (uint)AttachmentPoint.Chest); | ||
222 | m_attMod.RezSingleAttachmentFromInventory(sp, att2Item.ID, (uint)AttachmentPoint.Chest | 0x80); | ||
223 | |||
224 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); | ||
225 | |||
226 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
227 | |||
228 | // Check scene presence status | ||
229 | Assert.That(npc.HasAttachments(), Is.True); | ||
230 | List<SceneObjectGroup> attachments = npc.GetAttachments(); | ||
231 | Assert.That(attachments.Count, Is.EqualTo(2)); | ||
232 | |||
233 | // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item | ||
234 | // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC. | ||
235 | // Assert.That(attSo.Name, Is.EqualTo(attName)); | ||
236 | |||
237 | TestAttachedObject(attachments[0], AttachmentPoint.Chest, npc.UUID); | ||
238 | TestAttachedObject(attachments[1], AttachmentPoint.Chest, npc.UUID); | ||
239 | |||
240 | // Attached objects on the same point must have different FromItemIDs to be shown to other avatars, at least | ||
241 | // on Singularity 1.8.5. Otherwise, only one (the first ObjectUpdate sent) appears. | ||
242 | Assert.AreNotEqual(attachments[0].FromItemID, attachments[1].FromItemID); | ||
243 | } | ||
244 | |||
245 | private void TestAttachedObject(SceneObjectGroup attSo, AttachmentPoint attPoint, UUID ownerId) | ||
246 | { | ||
247 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)attPoint)); | ||
248 | Assert.That(attSo.IsAttachment); | ||
249 | Assert.That(attSo.UsesPhysics, Is.False); | ||
250 | Assert.That(attSo.IsTemporary, Is.False); | ||
251 | Assert.That(attSo.OwnerID, Is.EqualTo(ownerId)); | ||
252 | } | ||
253 | |||
254 | [Test] | ||
202 | public void TestLoadAppearance() | 255 | public void TestLoadAppearance() |
203 | { | 256 | { |
204 | TestHelpers.InMethod(); | 257 | TestHelpers.InMethod(); |