aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/WearableCacheItem.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/WearableCacheItem.cs')
-rw-r--r--OpenSim/Framework/WearableCacheItem.cs70
1 files changed, 67 insertions, 3 deletions
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs
index 1aecf79..af28abc 100644
--- a/OpenSim/Framework/WearableCacheItem.cs
+++ b/OpenSim/Framework/WearableCacheItem.cs
@@ -43,12 +43,13 @@ namespace OpenSim.Framework
43 43
44 public static WearableCacheItem[] GetDefaultCacheItem() 44 public static WearableCacheItem[] GetDefaultCacheItem()
45 { 45 {
46 int itemmax = 21; 46 int itemmax = AvatarAppearance.TEXTURE_COUNT;
47 WearableCacheItem[] retitems = new WearableCacheItem[itemmax]; 47 WearableCacheItem[] retitems = new WearableCacheItem[itemmax];
48 for (uint i=0;i<itemmax;i++) 48 for (uint i=0;i<itemmax;i++)
49 retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i + 1}; 49 retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i};
50 return retitems; 50 return retitems;
51 } 51 }
52
52 public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache) 53 public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache)
53 { 54 {
54 List<WearableCacheItem> ret = new List<WearableCacheItem>(); 55 List<WearableCacheItem> ret = new List<WearableCacheItem>();
@@ -98,6 +99,7 @@ namespace OpenSim.Framework
98 return ret.ToArray(); 99 return ret.ToArray();
99 100
100 } 101 }
102
101 public static OSD ToOSD(WearableCacheItem[] pcacheItems, IImprovedAssetCache dataCache) 103 public static OSD ToOSD(WearableCacheItem[] pcacheItems, IImprovedAssetCache dataCache)
102 { 104 {
103 OSDArray arr = new OSDArray(); 105 OSDArray arr = new OSDArray();
@@ -124,6 +126,68 @@ namespace OpenSim.Framework
124 } 126 }
125 return arr; 127 return arr;
126 } 128 }
129
130 public static OSDArray BakedToOSD(WearableCacheItem[] pcacheItems)
131 {
132 if (pcacheItems.Length < AvatarAppearance.BAKE_INDICES[AvatarAppearance.BAKE_INDICES.Length - 1])
133 return null;
134
135 OSDArray arr = new OSDArray();
136
137 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
138 {
139 int idx = AvatarAppearance.BAKE_INDICES[i];
140
141 WearableCacheItem item = pcacheItems[idx];
142
143 OSDMap itemmap = new OSDMap();
144 itemmap.Add("textureindex", OSD.FromUInteger(item.TextureIndex));
145 itemmap.Add("cacheid", OSD.FromUUID(item.CacheId));
146 itemmap.Add("textureid", OSD.FromUUID(item.TextureID));
147/*
148 if (item.TextureAsset != null)
149 {
150 itemmap.Add("assetdata", OSD.FromBinary(item.TextureAsset.Data));
151 itemmap.Add("assetcreator", OSD.FromString(item.TextureAsset.CreatorID));
152 itemmap.Add("assetname", OSD.FromString(item.TextureAsset.Name));
153 }
154 */
155 arr.Add(itemmap);
156 }
157 return arr;
158 }
159
160 public static WearableCacheItem[] BakedFromOSD(OSD pInput)
161 {
162 WearableCacheItem[] pcache = WearableCacheItem.GetDefaultCacheItem();
163
164 if (pInput.Type == OSDType.Array)
165 {
166 OSDArray itemarray = (OSDArray)pInput;
167 foreach (OSDMap item in itemarray)
168 {
169 int idx = (int)item["textureindex"].AsUInteger();
170 if (idx < 0 || idx > pcache.Length)
171 continue;
172 pcache[idx].CacheId = item["cacheid"].AsUUID();
173 pcache[idx].TextureID = item["textureid"].AsUUID();
174/*
175 if (item.ContainsKey("assetdata"))
176 {
177 AssetBase asset = new AssetBase(item["textureid"].AsUUID(), "BakedTexture", (sbyte)AssetType.Texture, UUID.Zero.ToString());
178 asset.Temporary = true;
179 asset.Local = true;
180 asset.Data = item["assetdata"].AsBinary();
181 pcache[idx].TextureAsset = asset;
182 }
183 else
184 */
185 pcache[idx].TextureAsset = null;
186 }
187 }
188 return pcache;
189 }
190
127 public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems) 191 public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems)
128 { 192 {
129 for (int i = 0; i < pcacheItems.Length; i++) 193 for (int i = 0; i < pcacheItems.Length; i++)