aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorUbitUmarov2019-09-15 16:49:58 +0100
committerUbitUmarov2019-09-15 16:49:58 +0100
commit63b0bd7f6b6b110a565cdb0e2e896d473c096a76 (patch)
tree27b24cebc63179be67a53098692016289b2ecfee /OpenSim/Framework
parentallow particles scale max to be 7.96m, supported by protocol (diff)
downloadopensim-SC-63b0bd7f6b6b110a565cdb0e2e896d473c096a76.zip
opensim-SC-63b0bd7f6b6b110a565cdb0e2e896d473c096a76.tar.gz
opensim-SC-63b0bd7f6b6b110a565cdb0e2e896d473c096a76.tar.bz2
opensim-SC-63b0bd7f6b6b110a565cdb0e2e896d473c096a76.tar.xz
fix saving appearence to notecard, so they can work on older regions
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs135
1 files changed, 96 insertions, 39 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 }