aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AvatarAppearance.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/AvatarAppearance.cs')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs107
1 files changed, 88 insertions, 19 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index e1725a9..79a66ab 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -53,7 +53,11 @@ namespace OpenSim.Framework
53 // should be only used as initial default value ( V1 viewers ) 53 // should be only used as initial default value ( V1 viewers )
54 public readonly static int VISUALPARAM_COUNT = 218; 54 public readonly static int VISUALPARAM_COUNT = 218;
55 55
56 public readonly static int TEXTURE_COUNT = 21; 56// public readonly static int TEXTURE_COUNT = 21
57 // 21 bad, make it be updated as libovm gets update
58 // also keeping in sync with it
59 public readonly static int TEXTURE_COUNT = Primitive.TextureEntry.MAX_FACES;
60
57 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; 61 public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
58 62
59 protected int m_serial = 0; 63 protected int m_serial = 0;
@@ -179,11 +183,16 @@ namespace OpenSim.Framework
179 m_attachments = new Dictionary<int, List<AvatarAttachment>>(); 183 m_attachments = new Dictionary<int, List<AvatarAttachment>>();
180 } 184 }
181 185
182 public AvatarAppearance(AvatarAppearance appearance) : this(appearance, true) 186 public AvatarAppearance(AvatarAppearance appearance): this(appearance, true,true)
183 { 187 {
184 } 188 }
185 189
186 public AvatarAppearance(AvatarAppearance appearance, bool copyWearables) 190 public AvatarAppearance(AvatarAppearance appearance, bool copyWearables)
191 : this(appearance, copyWearables, true)
192 {
193 }
194
195 public AvatarAppearance(AvatarAppearance appearance, bool copyWearables, bool copyBaked)
187 { 196 {
188// m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance"); 197// m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance");
189 198
@@ -202,21 +211,29 @@ namespace OpenSim.Framework
202 211
203 m_serial = appearance.Serial; 212 m_serial = appearance.Serial;
204 213
205 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
206 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
207 m_wearables[i] = new AvatarWearable();
208
209 if (copyWearables && (appearance.Wearables != null)) 214 if (copyWearables && (appearance.Wearables != null))
210 { 215 {
211 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 216 m_wearables = new AvatarWearable[appearance.Wearables.Length];
212 SetWearable(i,appearance.Wearables[i]); 217 for (int i = 0; i < appearance.Wearables.Length; i++)
218 {
219 m_wearables[i] = new AvatarWearable();
220 AvatarWearable wearable = appearance.Wearables[i];
221 for (int j = 0; j < wearable.Count; j++)
222 m_wearables[i].Add(wearable[j].ItemID, wearable[j].AssetID);
223 }
213 } 224 }
225 else
226 ClearWearables();
214 227
215 m_texture = null; 228 m_texture = null;
216 if (appearance.Texture != null) 229 if (appearance.Texture != null)
217 { 230 {
218 byte[] tbytes = appearance.Texture.GetBytes(); 231 byte[] tbytes = appearance.Texture.GetBytes();
219 m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length); 232 m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length);
233 if (copyBaked && appearance.m_cacheitems != null)
234 m_cacheitems = (WearableCacheItem[])appearance.m_cacheitems.Clone();
235 else
236 m_cacheitems = null;
220 } 237 }
221 238
222 m_visualparams = null; 239 m_visualparams = null;
@@ -234,9 +251,17 @@ namespace OpenSim.Framework
234 251
235 public void GetAssetsFrom(AvatarAppearance app) 252 public void GetAssetsFrom(AvatarAppearance app)
236 { 253 {
237 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 254 int len = m_wearables.Length;
255 if(len > app.m_wearables.Length)
256 len = app.m_wearables.Length;
257
258 for (int i = 0; i < len; i++)
238 { 259 {
239 for (int j = 0; j < m_wearables[i].Count; j++) 260 int count = m_wearables[i].Count;
261 if(count > app.m_wearables[i].Count)
262 count = app.m_wearables[i].Count;
263
264 for (int j = 0; j < count; j++)
240 { 265 {
241 UUID itemID = m_wearables[i][j].ItemID; 266 UUID itemID = m_wearables[i][j].ItemID;
242 UUID assetID = app.Wearables[i].GetAsset(itemID); 267 UUID assetID = app.Wearables[i].GetAsset(itemID);
@@ -249,8 +274,8 @@ namespace OpenSim.Framework
249 274
250 public void ClearWearables() 275 public void ClearWearables()
251 { 276 {
252 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; 277 m_wearables = new AvatarWearable[AvatarWearable.LEGACY_VERSION_MAX_WEARABLES];
253 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 278 for (int i = 0; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES; i++)
254 m_wearables[i] = new AvatarWearable(); 279 m_wearables[i] = new AvatarWearable();
255 } 280 }
256 281
@@ -457,11 +482,22 @@ namespace OpenSim.Framework
457// DEBUG ON 482// DEBUG ON
458// m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID); 483// m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID);
459// DEBUG OFF 484// DEBUG OFF
485 if (wearableId >= m_wearables.Length)
486 {
487 int currentLength = m_wearables.Length;
488 Array.Resize(ref m_wearables, wearableId + 1);
489 for (int i = currentLength ; i < m_wearables.Length ; i++)
490 m_wearables[i] = new AvatarWearable();
491 }
460 m_wearables[wearableId].Clear(); 492 m_wearables[wearableId].Clear();
493<<<<<<< HEAD
494 for (int i = 0; i < wearable.Count; i++)
495=======
461 int count = wearable.Count; 496 int count = wearable.Count;
462 if (count > AvatarWearable.MAX_WEARABLES) 497 if (count > AvatarWearable.MAX_WEARABLES)
463 count = AvatarWearable.MAX_WEARABLES; 498 count = AvatarWearable.MAX_WEARABLES;
464 for (int i = 0; i < count; i++) 499 for (int i = 0; i < count; i++)
500>>>>>>> master
465 m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID); 501 m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID);
466 } 502 }
467 503
@@ -701,7 +737,7 @@ namespace OpenSim.Framework
701 /// <summary> 737 /// <summary>
702 /// Create an OSDMap from the appearance data 738 /// Create an OSDMap from the appearance data
703 /// </summary> 739 /// </summary>
704 public OSDMap Pack() 740 public OSDMap Pack(EntityTransferContext ctx)
705 { 741 {
706 OSDMap data = new OSDMap(); 742 OSDMap data = new OSDMap();
707 743
@@ -709,9 +745,22 @@ namespace OpenSim.Framework
709 data["height"] = OSD.FromReal(m_avatarHeight); 745 data["height"] = OSD.FromReal(m_avatarHeight);
710 746
711 // Wearables 747 // Wearables
712 OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES); 748 //
713 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 749 // This will send as many or as few wearables as we have, unless a count
714 wears.Add(m_wearables[i].Pack()); 750 // is given. Used for legacy (pre 0.4) versions.
751 int count = ctx.WearablesCount;
752 if (ctx.WearablesCount == -1)
753 count = m_wearables.Length;
754 OSDArray wears = new OSDArray(count);
755 for (int i = 0; i < count; i++)
756 {
757 AvatarWearable dummyWearable = new AvatarWearable();
758
759 if (i < m_wearables.Length)
760 wears.Add(m_wearables[i].Pack());
761 else
762 wears.Add(dummyWearable.Pack());
763 }
715 data["wearables"] = wears; 764 data["wearables"] = wears;
716 765
717 // Avatar Textures 766 // Avatar Textures
@@ -725,6 +774,13 @@ namespace OpenSim.Framework
725 } 774 }
726 data["textures"] = textures; 775 data["textures"] = textures;
727 776
777 if (m_cacheitems != null)
778 {
779 OSDArray baked = WearableCacheItem.BakedToOSD(m_cacheitems);
780 if (baked != null)
781 data["bakedcache"] = baked;
782 }
783
728 // Visual Parameters 784 // Visual Parameters
729 OSDBinary visualparams = new OSDBinary(m_visualparams); 785 OSDBinary visualparams = new OSDBinary(m_visualparams);
730 data["visualparams"] = visualparams; 786 data["visualparams"] = visualparams;
@@ -760,9 +816,11 @@ namespace OpenSim.Framework
760 if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array) 816 if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array)
761 { 817 {
762 OSDArray wears = (OSDArray)(data["wearables"]); 818 OSDArray wears = (OSDArray)(data["wearables"]);
819
763 int count = wears.Count; 820 int count = wears.Count;
764 if (count > AvatarWearable.MAX_WEARABLES) 821
765 count = AvatarWearable.MAX_WEARABLES; 822 m_wearables = new AvatarWearable[count];
823
766 for (int i = 0; i < count; i++) 824 for (int i = 0; i < count; i++)
767 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); 825 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
768 } 826 }
@@ -789,6 +847,12 @@ namespace OpenSim.Framework
789 m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures"); 847 m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures");
790 } 848 }
791 849
850 if ((data != null) && (data["bakedcache"] != null) && (data["bakedcache"]).Type == OSDType.Array)
851 {
852 OSDArray bakedOSDArray = (OSDArray)(data["bakedcache"]);
853 m_cacheitems = WearableCacheItem.BakedFromOSD(bakedOSDArray);
854 }
855
792 // Visual Parameters 856 // Visual Parameters
793 SetDefaultParams(); 857 SetDefaultParams();
794 if ((data != null) && (data["visualparams"] != null)) 858 if ((data != null) && (data["visualparams"] != null))
@@ -1638,7 +1702,12 @@ namespace OpenSim.Framework
1638 BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247, 1702 BREAST_PHYSICS_LEFTRIGHT_MAX_EFFECT = 247,
1639 BREAST_PHYSICS_LEFTRIGHT_SPRING= 248, 1703 BREAST_PHYSICS_LEFTRIGHT_SPRING= 248,
1640 BREAST_PHYSICS_LEFTRIGHT_GAIN = 249, 1704 BREAST_PHYSICS_LEFTRIGHT_GAIN = 249,
1641 BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250 1705 BREAST_PHYSICS_LEFTRIGHT_DAMPING = 250,
1706
1707 // Ubit: 07/96/2013 new parameters
1708 _APPEARANCEMESSAGE_VERSION = 251, //ID 11000
1709
1710 SHAPE_HOVER = 252, //ID 11001
1642 } 1711 }
1643 #endregion 1712 #endregion
1644 } 1713 }