diff options
author | onefang | 2019-05-19 21:24:15 +1000 |
---|---|---|
committer | onefang | 2019-05-19 21:24:15 +1000 |
commit | 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch) | |
tree | a9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Framework/WearableCacheItem.cs | |
parent | Add a build script. (diff) | |
download | opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2 opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz |
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/WearableCacheItem.cs | 77 |
1 files changed, 71 insertions, 6 deletions
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs index 1aecf79..427e149 100644 --- a/OpenSim/Framework/WearableCacheItem.cs +++ b/OpenSim/Framework/WearableCacheItem.cs | |||
@@ -43,13 +43,14 @@ 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 | public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache) | 52 | |
53 | public static WearableCacheItem[] FromOSD(OSD pInput, IAssetCache dataCache) | ||
53 | { | 54 | { |
54 | List<WearableCacheItem> ret = new List<WearableCacheItem>(); | 55 | List<WearableCacheItem> ret = new List<WearableCacheItem>(); |
55 | if (pInput.Type == OSDType.Array) | 56 | if (pInput.Type == OSDType.Array) |
@@ -63,7 +64,7 @@ namespace OpenSim.Framework | |||
63 | CacheId = item["cacheid"].AsUUID(), | 64 | CacheId = item["cacheid"].AsUUID(), |
64 | TextureID = item["textureid"].AsUUID() | 65 | TextureID = item["textureid"].AsUUID() |
65 | }); | 66 | }); |
66 | 67 | ||
67 | if (dataCache != null && item.ContainsKey("assetdata")) | 68 | if (dataCache != null && item.ContainsKey("assetdata")) |
68 | { | 69 | { |
69 | AssetBase asset = new AssetBase(item["textureid"].AsUUID(),"BakedTexture",(sbyte)AssetType.Texture,UUID.Zero.ToString()); | 70 | AssetBase asset = new AssetBase(item["textureid"].AsUUID(),"BakedTexture",(sbyte)AssetType.Texture,UUID.Zero.ToString()); |
@@ -98,7 +99,8 @@ namespace OpenSim.Framework | |||
98 | return ret.ToArray(); | 99 | return ret.ToArray(); |
99 | 100 | ||
100 | } | 101 | } |
101 | public static OSD ToOSD(WearableCacheItem[] pcacheItems, IImprovedAssetCache dataCache) | 102 | |
103 | public static OSD ToOSD(WearableCacheItem[] pcacheItems, IAssetCache dataCache) | ||
102 | { | 104 | { |
103 | OSDArray arr = new OSDArray(); | 105 | OSDArray arr = new OSDArray(); |
104 | foreach (WearableCacheItem item in pcacheItems) | 106 | foreach (WearableCacheItem item in pcacheItems) |
@@ -111,7 +113,8 @@ namespace OpenSim.Framework | |||
111 | { | 113 | { |
112 | if (dataCache.Check(item.TextureID.ToString())) | 114 | if (dataCache.Check(item.TextureID.ToString())) |
113 | { | 115 | { |
114 | AssetBase assetItem = dataCache.Get(item.TextureID.ToString()); | 116 | AssetBase assetItem; |
117 | dataCache.Get(item.TextureID.ToString(), out assetItem); | ||
115 | if (assetItem != null) | 118 | if (assetItem != null) |
116 | { | 119 | { |
117 | itemmap.Add("assetdata", OSD.FromBinary(assetItem.Data)); | 120 | itemmap.Add("assetdata", OSD.FromBinary(assetItem.Data)); |
@@ -124,6 +127,68 @@ namespace OpenSim.Framework | |||
124 | } | 127 | } |
125 | return arr; | 128 | return arr; |
126 | } | 129 | } |
130 | |||
131 | public static OSDArray BakedToOSD(WearableCacheItem[] pcacheItems) | ||
132 | { | ||
133 | if (pcacheItems.Length < AvatarAppearance.BAKE_INDICES[AvatarAppearance.BAKE_INDICES.Length - 1]) | ||
134 | return null; | ||
135 | |||
136 | OSDArray arr = new OSDArray(); | ||
137 | |||
138 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | ||
139 | { | ||
140 | int idx = AvatarAppearance.BAKE_INDICES[i]; | ||
141 | |||
142 | WearableCacheItem item = pcacheItems[idx]; | ||
143 | |||
144 | OSDMap itemmap = new OSDMap(); | ||
145 | itemmap.Add("textureindex", OSD.FromUInteger(item.TextureIndex)); | ||
146 | itemmap.Add("cacheid", OSD.FromUUID(item.CacheId)); | ||
147 | itemmap.Add("textureid", OSD.FromUUID(item.TextureID)); | ||
148 | /* | ||
149 | if (item.TextureAsset != null) | ||
150 | { | ||
151 | itemmap.Add("assetdata", OSD.FromBinary(item.TextureAsset.Data)); | ||
152 | itemmap.Add("assetcreator", OSD.FromString(item.TextureAsset.CreatorID)); | ||
153 | itemmap.Add("assetname", OSD.FromString(item.TextureAsset.Name)); | ||
154 | } | ||
155 | */ | ||
156 | arr.Add(itemmap); | ||
157 | } | ||
158 | return arr; | ||
159 | } | ||
160 | |||
161 | public static WearableCacheItem[] BakedFromOSD(OSD pInput) | ||
162 | { | ||
163 | WearableCacheItem[] pcache = WearableCacheItem.GetDefaultCacheItem(); | ||
164 | |||
165 | if (pInput.Type == OSDType.Array) | ||
166 | { | ||
167 | OSDArray itemarray = (OSDArray)pInput; | ||
168 | foreach (OSDMap item in itemarray) | ||
169 | { | ||
170 | int idx = (int)item["textureindex"].AsUInteger(); | ||
171 | if (idx < 0 || idx > pcache.Length) | ||
172 | continue; | ||
173 | pcache[idx].CacheId = item["cacheid"].AsUUID(); | ||
174 | pcache[idx].TextureID = item["textureid"].AsUUID(); | ||
175 | /* | ||
176 | if (item.ContainsKey("assetdata")) | ||
177 | { | ||
178 | AssetBase asset = new AssetBase(item["textureid"].AsUUID(), "BakedTexture", (sbyte)AssetType.Texture, UUID.Zero.ToString()); | ||
179 | asset.Temporary = true; | ||
180 | asset.Local = true; | ||
181 | asset.Data = item["assetdata"].AsBinary(); | ||
182 | pcache[idx].TextureAsset = asset; | ||
183 | } | ||
184 | else | ||
185 | */ | ||
186 | pcache[idx].TextureAsset = null; | ||
187 | } | ||
188 | } | ||
189 | return pcache; | ||
190 | } | ||
191 | |||
127 | public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems) | 192 | public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems) |
128 | { | 193 | { |
129 | for (int i = 0; i < pcacheItems.Length; i++) | 194 | for (int i = 0; i < pcacheItems.Length; i++) |