aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs135
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs18
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs4
3 files changed, 104 insertions, 53 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 3a2a393..0a15963 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Framework
58 public const int TEXTURE_COUNT_PV7 = 26; 58 public const int TEXTURE_COUNT_PV7 = 26;
59 public const int BAKES_COUNT_PV7 = 6; 59 public const int BAKES_COUNT_PV7 = 6;
60 public const int MAXWEARABLE_PV7 = 16; 60 public const int MAXWEARABLE_PV7 = 16;
61 public const int MAXWEARABLE_LEGACY = 14; 61 public const int MAXWEARABLE_LEGACY = 15;
62 62
63 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20, 40, 41, 42, 43, 44 }; 63 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20, 40, 41, 42, 43, 44 };
64 64
@@ -739,8 +739,6 @@ namespace OpenSim.Framework
739 return data; 739 return data;
740 740
741 bool sendPV8 = false; 741 bool sendPV8 = false;
742 if(ctx != null)
743 sendPV8 = ctx.OutboundVersion >= 0.8;
744 742
745 // Wearables 743 // Wearables
746 OSDArray wears; 744 OSDArray wears;
@@ -749,31 +747,33 @@ namespace OpenSim.Framework
749 count = MAXWEARABLE_LEGACY; 747 count = MAXWEARABLE_LEGACY;
750 else 748 else
751 { 749 {
752 int wbcount = ctx.WearablesCount; 750 if(ctx.OutboundVersion >= 0.8)
753 if (wbcount == -1)
754 wbcount = m_wearables.Length;
755
756 count = wbcount;
757 if(count > MAXWEARABLE_PV7)
758 { 751 {
752 sendPV8 = true;
753 count = m_wearables.Length;
754 }
755 else if (ctx.OutboundVersion >= 0.6)
759 count = MAXWEARABLE_PV7; 756 count = MAXWEARABLE_PV7;
760 if(sendPV8) 757 else
761 { 758 count = MAXWEARABLE_LEGACY;
762 wears = new OSDArray(wbcount - MAXWEARABLE_PV7);
763 for (int i = MAXWEARABLE_PV7; i < wbcount; ++i)
764 wears.Add(m_wearables[i].Pack());
765 759
766 data["wrbls8"] = wears; 760 if (sendPV8 && count > MAXWEARABLE_PV7)
767 } 761 {
762 wears = new OSDArray(count - MAXWEARABLE_PV7);
763 for (int i = MAXWEARABLE_PV7; i < count; ++i)
764 wears.Add(m_wearables[i].Pack());
765
766 data["wrbls8"] = wears;
767 count = MAXWEARABLE_PV7;
768 } 768 }
769 } 769 }
770 770
771 wears = new OSDArray(count); 771 wears = new OSDArray(count);
772 for (int i = 0; i < count; i++) 772 for (int i = 0; i < count; ++i)
773 wears.Add(m_wearables[i].Pack()); 773 wears.Add(m_wearables[i].Pack());
774 data["wearables"] = wears; 774 data["wearables"] = wears;
775 775
776 // Avatar Textures and preferences hover 776 // Avatar Textures
777 OSDArray textures; 777 OSDArray textures;
778 if (sendPV8) 778 if (sendPV8)
779 { 779 {
@@ -783,7 +783,7 @@ namespace OpenSim.Framework
783 else 783 else
784 { 784 {
785 textures = new OSDArray(TEXTURE_COUNT_PV7); 785 textures = new OSDArray(TEXTURE_COUNT_PV7);
786 for (uint i = 0; i < TEXTURE_COUNT_PV7; i++) 786 for (uint i = 0; i < TEXTURE_COUNT_PV7; ++i)
787 textures.Add(OSD.FromUUID(m_texture.GetFace(i).TextureID)); 787 textures.Add(OSD.FromUUID(m_texture.GetFace(i).TextureID));
788 data["textures"] = textures; 788 data["textures"] = textures;
789 } 789 }
@@ -814,6 +814,64 @@ namespace OpenSim.Framework
814 return data; 814 return data;
815 } 815 }
816 816
817 public OSDMap PackForNotecard()
818 {
819 OSDMap data = new OSDMap();
820
821 data["serial"] = OSD.FromInteger(m_serial);
822 data["height"] = OSD.FromReal(m_avatarHeight);
823 data["aphz"] = OSD.FromReal(AvatarPreferencesHoverZ);
824
825 // old regions may not like missing/empty wears
826 OSDArray wears = new OSDArray(MAXWEARABLE_LEGACY);
827 for (int i = 0; i< MAXWEARABLE_LEGACY; ++i)
828 wears.Add(new OSDArray());
829 data["wearables"] = wears;
830
831 // Avatar Textures
832 OSDArray textures;
833
834 // allow old regions to still see something
835 textures = new OSDArray(TEXTURE_COUNT_PV7);
836 textures.Add(OSD.FromUUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE));
837 for (uint i = 1; i < TEXTURE_COUNT_PV7; ++i)
838 textures.Add(OSD.FromUUID(m_texture.GetFace(i).TextureID));
839 data["textures"] = textures;
840
841 bool needExtra = false;
842 for (int i = BAKES_COUNT_PV7; i < BAKE_INDICES.Length; ++i)
843 {
844 int idx = BAKE_INDICES[i];
845 if (m_texture.FaceTextures[idx] == null)
846 continue;
847 if (m_texture.FaceTextures[idx].TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE ||
848 m_texture.FaceTextures[idx].TextureID == UUID.Zero)
849 continue;
850 needExtra = true;
851 }
852
853 if (needExtra)
854 {
855 byte[] te = m_texture.GetBakesBytes();
856 data["te8"] = OSD.FromBinary(te);
857 }
858
859 // Visual Parameters
860 OSDBinary visualparams = new OSDBinary(m_visualparams);
861 data["visualparams"] = visualparams;
862
863 lock (m_attachments)
864 {
865 // Attachments
866 OSDArray attachs = new OSDArray(m_attachments.Count);
867 foreach (AvatarAttachment attach in GetAttachments())
868 attachs.Add(attach.Pack());
869 data["attachments"] = attachs;
870 }
871
872 return data;
873 }
874
817 /// <summary> 875 /// <summary>
818 /// Unpack and OSDMap and initialize the appearance 876 /// Unpack and OSDMap and initialize the appearance
819 /// from it 877 /// from it
@@ -855,22 +913,27 @@ namespace OpenSim.Framework
855 if (data.TryGetValue("wearables", out tmpOSD) && (tmpOSD is OSDArray)) 913 if (data.TryGetValue("wearables", out tmpOSD) && (tmpOSD is OSDArray))
856 { 914 {
857 OSDArray wears = (OSDArray)tmpOSD; 915 OSDArray wears = (OSDArray)tmpOSD;
858 m_wearables = new AvatarWearable[wears.Count + wears8Count]; 916 if(wears.Count + wears8Count > 0)
859
860 for (int i = 0; i < wears.Count; ++i)
861 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
862 if (wears8Count > 0)
863 { 917 {
864 for (int i = 0; i < wears8Count; ++i) 918 m_wearables = new AvatarWearable[wears.Count + wears8Count];
865 m_wearables[i + wears.Count] = new AvatarWearable((OSDArray)wears8[i]); 919
920 for (int i = 0; i < wears.Count; ++i)
921 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
922 if (wears8Count > 0)
923 {
924 for (int i = 0; i < wears8Count; ++i)
925 m_wearables[i + wears.Count] = new AvatarWearable((OSDArray)wears8[i]);
926 }
866 } 927 }
867 } 928 }
868 else 929
930 if (data.TryGetValue("te8", out tmpOSD))
869 { 931 {
870 m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables"); 932 byte[] teb = tmpOSD.AsBinary();
933 Primitive.TextureEntry te = new Primitive.TextureEntry(teb, 0, teb.Length);
934 m_texture = te;
871 } 935 }
872 936 else if (data.TryGetValue("textures", out tmpOSD) && (tmpOSD is OSDArray))
873 if (data.TryGetValue("textures", out tmpOSD) && (tmpOSD is OSDArray))
874 { 937 {
875 OSDArray textures = (OSDArray)tmpOSD; 938 OSDArray textures = (OSDArray)tmpOSD;
876 for (int i = 0; i < textures.Count && i < TEXTURE_COUNT_PV7; ++i) 939 for (int i = 0; i < textures.Count && i < TEXTURE_COUNT_PV7; ++i)
@@ -880,12 +943,6 @@ namespace OpenSim.Framework
880 m_texture.CreateFace((uint)i).TextureID = tmpOSD.AsUUID(); 943 m_texture.CreateFace((uint)i).TextureID = tmpOSD.AsUUID();
881 } 944 }
882 } 945 }
883 if (data.TryGetValue("te8", out tmpOSD))
884 {
885 byte[] teb = tmpOSD.AsBinary();
886 Primitive.TextureEntry te = new Primitive.TextureEntry(teb, 0, teb.Length);
887 m_texture = te;
888 }
889 946
890 if (data.TryGetValue("bakedcache", out tmpOSD) && (tmpOSD is OSDArray)) 947 if (data.TryGetValue("bakedcache", out tmpOSD) && (tmpOSD is OSDArray))
891 { 948 {
@@ -965,13 +1022,13 @@ namespace OpenSim.Framework
965 } 1022 }
966 1023
967 // also check baked 1024 // also check baked
968 for(int i = BAKES_COUNT_PV7; i < BAKE_INDICES.Length; i++) 1025 for (int i = BAKES_COUNT_PV7; i < BAKE_INDICES.Length; i++)
969 { 1026 {
970 int idx = BAKE_INDICES[i]; 1027 int idx = BAKE_INDICES[i];
971 if (m_texture.FaceTextures[idx] == null) 1028 if (m_texture.FaceTextures[idx] == null)
972 continue; 1029 continue;
973 UUID tid = m_texture.FaceTextures[idx].TextureID; 1030 if (m_texture.FaceTextures[idx].TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE ||
974 if(tid == AppearanceManager.DEFAULT_AVATAR_TEXTURE || tid == UUID.Zero) 1031 m_texture.FaceTextures[idx].TextureID == UUID.Zero)
975 continue; 1032 continue;
976 return false; 1033 return false;
977 } 1034 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index ebd281e..a4d873e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3456,10 +3456,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3456 return SaveAppearanceToNotecard(m_host.OwnerID, notecard); 3456 return SaveAppearanceToNotecard(m_host.OwnerID, notecard);
3457 } 3457 }
3458 3458
3459 public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard) 3459 public LSL_Key osAgentSaveAppearance(LSL_Key avatarKey, string notecard)
3460 { 3460 {
3461 CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance"); 3461 CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
3462 3462
3463 UUID avatarId;
3464 if (!UUID.TryParse(avatarKey, out avatarId))
3465 return new LSL_Key(UUID.Zero.ToString());
3466
3463 return SaveAppearanceToNotecard(avatarId, notecard); 3467 return SaveAppearanceToNotecard(avatarId, notecard);
3464 } 3468 }
3465 3469
@@ -3470,8 +3474,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3470 if (appearanceModule != null) 3474 if (appearanceModule != null)
3471 { 3475 {
3472 appearanceModule.SaveBakedTextures(sp.UUID); 3476 appearanceModule.SaveBakedTextures(sp.UUID);
3473 EntityTransferContext ctx = new EntityTransferContext(); 3477 OSDMap appearancePacked = sp.Appearance.PackForNotecard();
3474 OSDMap appearancePacked = sp.Appearance.Pack(ctx);
3475 3478
3476 TaskInventoryItem item 3479 TaskInventoryItem item
3477 = SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true); 3480 = SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
@@ -3494,15 +3497,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3494 return SaveAppearanceToNotecard(sp, notecard); 3497 return SaveAppearanceToNotecard(sp, notecard);
3495 } 3498 }
3496 3499
3497 protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecard)
3498 {
3499 UUID avatarId;
3500 if (!UUID.TryParse(rawAvatarId, out avatarId))
3501 return new LSL_Key(UUID.Zero.ToString());
3502
3503 return SaveAppearanceToNotecard(avatarId, notecard);
3504 }
3505
3506 /// <summary> 3500 /// <summary>
3507 /// Get the gender as specified in avatar appearance for a given avatar key 3501 /// Get the gender as specified in avatar appearance for a given avatar key
3508 /// </summary> 3502 /// </summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 40e8204..f981e89 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -451,9 +451,9 @@ namespace OpenSim.Region.ScriptEngine.Shared
451 double scale; 451 double scale;
452 double invscale; 452 double invscale;
453 453
454 if ((angle + 1f) > 0.05f) 454 if ((angle + 1.0) > 0.0005)
455 { 455 {
456 if ((1f - angle) >= 0.05f) 456 if ((1f - angle) >= 0.0005)
457 { 457 {
458 // slerp 458 // slerp
459 double theta = Math.Acos(angle); 459 double theta = Math.Acos(angle);