diff options
Diffstat (limited to 'OpenSim')
8 files changed, 439 insertions, 34 deletions
diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs index 4fa604f..5536564 100644 --- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Collections.Specialized; | 31 | using System.Collections.Specialized; |
31 | using System.Drawing; | 32 | using System.Drawing; |
32 | using System.Drawing.Imaging; | 33 | using System.Drawing.Imaging; |
@@ -50,6 +51,7 @@ namespace OpenSim.Capabilities.Handlers | |||
50 | { | 51 | { |
51 | public class UploadBakedTextureHandler | 52 | public class UploadBakedTextureHandler |
52 | { | 53 | { |
54 | |||
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
54 | 56 | ||
55 | private Caps m_HostCapsObj; | 57 | private Caps m_HostCapsObj; |
@@ -79,9 +81,9 @@ namespace OpenSim.Capabilities.Handlers | |||
79 | { | 81 | { |
80 | string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; | 82 | string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; |
81 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); | 83 | string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); |
82 | 84 | ||
83 | BakedTextureUploader uploader = | 85 | BakedTextureUploader uploader = |
84 | new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener); | 86 | new BakedTextureUploader(capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_HostCapsObj.AgentID); |
85 | uploader.OnUpLoad += BakedTextureUploaded; | 87 | uploader.OnUpLoad += BakedTextureUploaded; |
86 | 88 | ||
87 | m_HostCapsObj.HttpListener.AddStreamHandler( | 89 | m_HostCapsObj.HttpListener.AddStreamHandler( |
@@ -125,6 +127,7 @@ namespace OpenSim.Capabilities.Handlers | |||
125 | asset.Temporary = true; | 127 | asset.Temporary = true; |
126 | asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are | 128 | asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are |
127 | m_assetService.Store(asset); | 129 | m_assetService.Store(asset); |
130 | |||
128 | } | 131 | } |
129 | } | 132 | } |
130 | 133 | ||
@@ -137,15 +140,19 @@ namespace OpenSim.Capabilities.Handlers | |||
137 | private string uploaderPath = String.Empty; | 140 | private string uploaderPath = String.Empty; |
138 | private UUID newAssetID; | 141 | private UUID newAssetID; |
139 | private IHttpServer httpListener; | 142 | private IHttpServer httpListener; |
143 | private UUID AgentId = UUID.Zero; | ||
140 | 144 | ||
141 | public BakedTextureUploader(string path, IHttpServer httpServer) | 145 | public BakedTextureUploader(string path, IHttpServer httpServer, UUID uUID) |
142 | { | 146 | { |
143 | newAssetID = UUID.Random(); | 147 | newAssetID = UUID.Random(); |
144 | uploaderPath = path; | 148 | uploaderPath = path; |
145 | httpListener = httpServer; | 149 | httpListener = httpServer; |
150 | AgentId = uUID; | ||
146 | // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID); | 151 | // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID); |
147 | } | 152 | } |
148 | 153 | ||
154 | |||
155 | |||
149 | /// <summary> | 156 | /// <summary> |
150 | /// Handle raw uploaded baked texture data. | 157 | /// Handle raw uploaded baked texture data. |
151 | /// </summary> | 158 | /// </summary> |
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 4df4fb6..ffc3527 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -66,7 +66,9 @@ namespace OpenSim.Framework | |||
66 | protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f); | 66 | protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f); |
67 | protected float m_avatarFeetOffset = 0; | 67 | protected float m_avatarFeetOffset = 0; |
68 | protected float m_avatarAnimOffset = 0; | 68 | protected float m_avatarAnimOffset = 0; |
69 | protected WearableCacheItem[] cacheitems; | 69 | protected WearableCacheItem[] m_cacheitems; |
70 | protected bool m_cacheItemsDirty = true; | ||
71 | |||
70 | public virtual int Serial | 72 | public virtual int Serial |
71 | { | 73 | { |
72 | get { return m_serial; } | 74 | get { return m_serial; } |
@@ -118,8 +120,14 @@ namespace OpenSim.Framework | |||
118 | 120 | ||
119 | public virtual WearableCacheItem[] WearableCacheItems | 121 | public virtual WearableCacheItem[] WearableCacheItems |
120 | { | 122 | { |
121 | get { return cacheitems; } | 123 | get { return m_cacheitems; } |
122 | set { cacheitems = value; } | 124 | set { m_cacheitems = value; } |
125 | } | ||
126 | |||
127 | public virtual bool WearableCacheItemsDirty | ||
128 | { | ||
129 | get { return m_cacheItemsDirty; } | ||
130 | set { m_cacheItemsDirty = value; } | ||
123 | } | 131 | } |
124 | 132 | ||
125 | public AvatarAppearance() | 133 | public AvatarAppearance() |
diff --git a/OpenSim/Framework/WearableCacheItem.cs b/OpenSim/Framework/WearableCacheItem.cs index 83b1346..1aecf79 100644 --- a/OpenSim/Framework/WearableCacheItem.cs +++ b/OpenSim/Framework/WearableCacheItem.cs | |||
@@ -26,14 +26,132 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
31 | using OpenMetaverse.StructuredData; | ||
30 | 32 | ||
31 | namespace OpenSim.Framework | 33 | namespace OpenSim.Framework |
32 | { | 34 | { |
35 | [Serializable] | ||
33 | public class WearableCacheItem | 36 | public class WearableCacheItem |
34 | { | 37 | { |
35 | public uint TextureIndex { get; set; } | 38 | public uint TextureIndex { get; set; } |
36 | public UUID CacheId { get; set; } | 39 | public UUID CacheId { get; set; } |
37 | public UUID TextureID { get; set; } | 40 | public UUID TextureID { get; set; } |
41 | public AssetBase TextureAsset { get; set; } | ||
42 | |||
43 | |||
44 | public static WearableCacheItem[] GetDefaultCacheItem() | ||
45 | { | ||
46 | int itemmax = 21; | ||
47 | WearableCacheItem[] retitems = new WearableCacheItem[itemmax]; | ||
48 | for (uint i=0;i<itemmax;i++) | ||
49 | retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i + 1}; | ||
50 | return retitems; | ||
51 | } | ||
52 | public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache) | ||
53 | { | ||
54 | List<WearableCacheItem> ret = new List<WearableCacheItem>(); | ||
55 | if (pInput.Type == OSDType.Array) | ||
56 | { | ||
57 | OSDArray itemarray = (OSDArray) pInput; | ||
58 | foreach (OSDMap item in itemarray) | ||
59 | { | ||
60 | ret.Add(new WearableCacheItem() | ||
61 | { | ||
62 | TextureIndex = item["textureindex"].AsUInteger(), | ||
63 | CacheId = item["cacheid"].AsUUID(), | ||
64 | TextureID = item["textureid"].AsUUID() | ||
65 | }); | ||
66 | |||
67 | if (dataCache != null && item.ContainsKey("assetdata")) | ||
68 | { | ||
69 | AssetBase asset = new AssetBase(item["textureid"].AsUUID(),"BakedTexture",(sbyte)AssetType.Texture,UUID.Zero.ToString()); | ||
70 | asset.Temporary = true; | ||
71 | asset.Data = item["assetdata"].AsBinary(); | ||
72 | dataCache.Cache(asset); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | else if (pInput.Type == OSDType.Map) | ||
77 | { | ||
78 | OSDMap item = (OSDMap) pInput; | ||
79 | ret.Add(new WearableCacheItem(){ | ||
80 | TextureIndex = item["textureindex"].AsUInteger(), | ||
81 | CacheId = item["cacheid"].AsUUID(), | ||
82 | TextureID = item["textureid"].AsUUID() | ||
83 | }); | ||
84 | if (dataCache != null && item.ContainsKey("assetdata")) | ||
85 | { | ||
86 | string assetCreator = item["assetcreator"].AsString(); | ||
87 | string assetName = item["assetname"].AsString(); | ||
88 | AssetBase asset = new AssetBase(item["textureid"].AsUUID(), assetName, (sbyte)AssetType.Texture, assetCreator); | ||
89 | asset.Temporary = true; | ||
90 | asset.Data = item["assetdata"].AsBinary(); | ||
91 | dataCache.Cache(asset); | ||
92 | } | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | return new WearableCacheItem[0]; | ||
97 | } | ||
98 | return ret.ToArray(); | ||
99 | |||
100 | } | ||
101 | public static OSD ToOSD(WearableCacheItem[] pcacheItems, IImprovedAssetCache dataCache) | ||
102 | { | ||
103 | OSDArray arr = new OSDArray(); | ||
104 | foreach (WearableCacheItem item in pcacheItems) | ||
105 | { | ||
106 | OSDMap itemmap = new OSDMap(); | ||
107 | itemmap.Add("textureindex", OSD.FromUInteger(item.TextureIndex)); | ||
108 | itemmap.Add("cacheid", OSD.FromUUID(item.CacheId)); | ||
109 | itemmap.Add("textureid", OSD.FromUUID(item.TextureID)); | ||
110 | if (dataCache != null) | ||
111 | { | ||
112 | if (dataCache.Check(item.TextureID.ToString())) | ||
113 | { | ||
114 | AssetBase assetItem = dataCache.Get(item.TextureID.ToString()); | ||
115 | if (assetItem != null) | ||
116 | { | ||
117 | itemmap.Add("assetdata", OSD.FromBinary(assetItem.Data)); | ||
118 | itemmap.Add("assetcreator", OSD.FromString(assetItem.CreatorID)); | ||
119 | itemmap.Add("assetname", OSD.FromString(assetItem.Name)); | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | arr.Add(itemmap); | ||
124 | } | ||
125 | return arr; | ||
126 | } | ||
127 | public static WearableCacheItem SearchTextureIndex(uint pTextureIndex,WearableCacheItem[] pcacheItems) | ||
128 | { | ||
129 | for (int i = 0; i < pcacheItems.Length; i++) | ||
130 | { | ||
131 | if (pcacheItems[i].TextureIndex == pTextureIndex) | ||
132 | return pcacheItems[i]; | ||
133 | } | ||
134 | return null; | ||
135 | } | ||
136 | public static WearableCacheItem SearchTextureCacheId(UUID pCacheId, WearableCacheItem[] pcacheItems) | ||
137 | { | ||
138 | for (int i = 0; i < pcacheItems.Length; i++) | ||
139 | { | ||
140 | if (pcacheItems[i].CacheId == pCacheId) | ||
141 | return pcacheItems[i]; | ||
142 | } | ||
143 | return null; | ||
144 | } | ||
145 | public static WearableCacheItem SearchTextureTextureId(UUID pTextureId, WearableCacheItem[] pcacheItems) | ||
146 | { | ||
147 | for (int i = 0; i < pcacheItems.Length; i++) | ||
148 | { | ||
149 | if (pcacheItems[i].TextureID == pTextureId) | ||
150 | return pcacheItems[i]; | ||
151 | } | ||
152 | return null; | ||
153 | } | ||
38 | } | 154 | } |
155 | |||
156 | |||
39 | } | 157 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 3b0ccd7..6bed95f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | ||
30 | using System.Collections.Specialized; | 31 | using System.Collections.Specialized; |
31 | using System.Drawing; | 32 | using System.Drawing; |
32 | using System.Drawing.Imaging; | 33 | using System.Drawing.Imaging; |
@@ -53,8 +54,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")] | 54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")] |
54 | public class UploadBakedTextureModule : INonSharedRegionModule | 55 | public class UploadBakedTextureModule : INonSharedRegionModule |
55 | { | 56 | { |
56 | // private static readonly ILog m_log = | 57 | private static readonly ILog m_log = |
57 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 58 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
58 | 59 | ||
59 | /// <summary> | 60 | /// <summary> |
60 | /// For historical reasons this is fixed, but there | 61 | /// For historical reasons this is fixed, but there |
@@ -64,31 +65,195 @@ namespace OpenSim.Region.ClientStack.Linden | |||
64 | private Scene m_scene; | 65 | private Scene m_scene; |
65 | private bool m_persistBakedTextures; | 66 | private bool m_persistBakedTextures; |
66 | 67 | ||
68 | private IBakedTextureModule m_BakedTextureModule; | ||
69 | |||
67 | public void Initialise(IConfigSource source) | 70 | public void Initialise(IConfigSource source) |
68 | { | 71 | { |
69 | IConfig appearanceConfig = source.Configs["Appearance"]; | 72 | IConfig appearanceConfig = source.Configs["Appearance"]; |
70 | if (appearanceConfig != null) | 73 | if (appearanceConfig != null) |
71 | m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); | 74 | m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); |
75 | |||
76 | |||
72 | } | 77 | } |
73 | 78 | ||
74 | public void AddRegion(Scene s) | 79 | public void AddRegion(Scene s) |
75 | { | 80 | { |
76 | m_scene = s; | 81 | m_scene = s; |
82 | |||
77 | } | 83 | } |
78 | 84 | ||
79 | public void RemoveRegion(Scene s) | 85 | public void RemoveRegion(Scene s) |
80 | { | 86 | { |
87 | s.EventManager.OnRegisterCaps -= RegisterCaps; | ||
88 | s.EventManager.OnNewPresence -= RegisterNewPresence; | ||
89 | s.EventManager.OnRemovePresence -= DeRegisterPresence; | ||
90 | m_BakedTextureModule = null; | ||
91 | m_scene = null; | ||
81 | } | 92 | } |
82 | 93 | ||
94 | |||
95 | |||
83 | public void RegionLoaded(Scene s) | 96 | public void RegionLoaded(Scene s) |
84 | { | 97 | { |
85 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | 98 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; |
99 | m_scene.EventManager.OnNewPresence += RegisterNewPresence; | ||
100 | m_scene.EventManager.OnRemovePresence += DeRegisterPresence; | ||
101 | |||
102 | } | ||
103 | |||
104 | private void DeRegisterPresence(UUID agentId) | ||
105 | { | ||
106 | ScenePresence presence = null; | ||
107 | if (m_scene.TryGetScenePresence(agentId, out presence)) | ||
108 | { | ||
109 | presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; | ||
110 | } | ||
111 | |||
112 | } | ||
113 | |||
114 | private void RegisterNewPresence(ScenePresence presence) | ||
115 | { | ||
116 | presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings; | ||
117 | |||
118 | } | ||
119 | |||
120 | private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) | ||
121 | { | ||
122 | int maxCacheitemsLoop = cacheItems.Length; | ||
123 | if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES) | ||
124 | { | ||
125 | maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES; | ||
126 | m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES); | ||
127 | } | ||
128 | |||
129 | m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
130 | if (cacheItems.Length > 0) | ||
131 | { | ||
132 | m_log.Debug("[Cacheitems]: " + cacheItems.Length); | ||
133 | for (int iter = 0; iter < maxCacheitemsLoop; iter++) | ||
134 | { | ||
135 | m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + | ||
136 | cacheItems[iter].TextureID); | ||
137 | } | ||
138 | |||
139 | ScenePresence p = null; | ||
140 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) | ||
141 | { | ||
142 | |||
143 | WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; | ||
144 | if (existingitems == null) | ||
145 | { | ||
146 | if (m_BakedTextureModule != null) | ||
147 | { | ||
148 | WearableCacheItem[] savedcache = null; | ||
149 | try | ||
150 | { | ||
151 | if (p.Appearance.WearableCacheItemsDirty) | ||
152 | { | ||
153 | savedcache = m_BakedTextureModule.Get(p.UUID); | ||
154 | p.Appearance.WearableCacheItems = savedcache; | ||
155 | p.Appearance.WearableCacheItemsDirty = false; | ||
156 | } | ||
157 | |||
158 | } | ||
159 | /* | ||
160 | * The following Catch types DO NOT WORK with m_BakedTextureModule.Get | ||
161 | * it jumps to the General Packet Exception Handler if you don't catch Exception! | ||
162 | * | ||
163 | catch (System.Net.Sockets.SocketException) | ||
164 | { | ||
165 | cacheItems = null; | ||
166 | } | ||
167 | catch (WebException) | ||
168 | { | ||
169 | cacheItems = null; | ||
170 | } | ||
171 | catch (InvalidOperationException) | ||
172 | { | ||
173 | cacheItems = null; | ||
174 | } */ | ||
175 | catch (Exception) | ||
176 | { | ||
177 | // The service logs a sufficient error message. | ||
178 | } | ||
179 | |||
180 | |||
181 | if (savedcache != null) | ||
182 | existingitems = savedcache; | ||
183 | } | ||
184 | } | ||
185 | // Existing items null means it's a fully new appearance | ||
186 | if (existingitems == null) | ||
187 | { | ||
188 | |||
189 | for (int i = 0; i < maxCacheitemsLoop; i++) | ||
190 | { | ||
191 | if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) | ||
192 | { | ||
193 | cacheItems[i].TextureID = | ||
194 | textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; | ||
195 | if (m_scene.AssetService != null) | ||
196 | cacheItems[i].TextureAsset = | ||
197 | m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); | ||
198 | } | ||
199 | else | ||
200 | { | ||
201 | m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length); | ||
202 | } | ||
203 | |||
204 | |||
205 | } | ||
206 | } | ||
207 | else | ||
208 | |||
209 | |||
210 | { | ||
211 | // for each uploaded baked texture | ||
212 | for (int i = 0; i < maxCacheitemsLoop; i++) | ||
213 | { | ||
214 | if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) | ||
215 | { | ||
216 | cacheItems[i].TextureID = | ||
217 | textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; | ||
218 | } | ||
219 | else | ||
220 | { | ||
221 | m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | for (int i = 0; i < maxCacheitemsLoop; i++) | ||
226 | { | ||
227 | if (cacheItems[i].TextureAsset == null) | ||
228 | { | ||
229 | cacheItems[i].TextureAsset = | ||
230 | m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); | ||
231 | } | ||
232 | } | ||
233 | } | ||
234 | |||
235 | |||
236 | |||
237 | p.Appearance.WearableCacheItems = cacheItems; | ||
238 | |||
239 | |||
240 | |||
241 | if (m_BakedTextureModule != null) | ||
242 | { | ||
243 | m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems); | ||
244 | p.Appearance.WearableCacheItemsDirty = true; | ||
245 | |||
246 | } | ||
247 | } | ||
248 | } | ||
86 | } | 249 | } |
87 | 250 | ||
88 | public void PostInitialise() | 251 | public void PostInitialise() |
89 | { | 252 | { |
90 | } | 253 | } |
91 | 254 | ||
255 | |||
256 | |||
92 | public void Close() { } | 257 | public void Close() { } |
93 | 258 | ||
94 | public string Name { get { return "UploadBakedTextureModule"; } } | 259 | public string Name { get { return "UploadBakedTextureModule"; } } |
@@ -100,15 +265,23 @@ namespace OpenSim.Region.ClientStack.Linden | |||
100 | 265 | ||
101 | public void RegisterCaps(UUID agentID, Caps caps) | 266 | public void RegisterCaps(UUID agentID, Caps caps) |
102 | { | 267 | { |
268 | UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler( | ||
269 | caps, m_scene.AssetService, m_persistBakedTextures); | ||
270 | |||
271 | |||
272 | |||
103 | caps.RegisterHandler( | 273 | caps.RegisterHandler( |
104 | "UploadBakedTexture", | 274 | "UploadBakedTexture", |
105 | new RestStreamHandler( | 275 | new RestStreamHandler( |
106 | "POST", | 276 | "POST", |
107 | "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, | 277 | "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, |
108 | new UploadBakedTextureHandler( | 278 | avatarhandler.UploadBakedTexture, |
109 | caps, m_scene.AssetService, m_persistBakedTextures).UploadBakedTexture, | ||
110 | "UploadBakedTexture", | 279 | "UploadBakedTexture", |
111 | agentID.ToString())); | 280 | agentID.ToString())); |
281 | |||
282 | |||
283 | |||
284 | |||
112 | } | 285 | } |
113 | } | 286 | } |
114 | } \ No newline at end of file | 287 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index d18b026..d46adb8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -3629,7 +3629,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3629 | 3629 | ||
3630 | avp.Sender.IsTrial = false; | 3630 | avp.Sender.IsTrial = false; |
3631 | avp.Sender.ID = agentID; | 3631 | avp.Sender.ID = agentID; |
3632 | //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); | 3632 | m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); |
3633 | OutPacket(avp, ThrottleOutPacketType.State); | 3633 | OutPacket(avp, ThrottleOutPacketType.State); |
3634 | } | 3634 | } |
3635 | 3635 | ||
@@ -11725,32 +11725,134 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11725 | // var item = fac.GetBakedTextureFaces(AgentId); | 11725 | // var item = fac.GetBakedTextureFaces(AgentId); |
11726 | //WearableCacheItem[] items = fac.GetCachedItems(AgentId); | 11726 | //WearableCacheItem[] items = fac.GetCachedItems(AgentId); |
11727 | 11727 | ||
11728 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | 11728 | IAssetService cache = m_scene.AssetService; |
11729 | if (cache == null) | 11729 | IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); |
11730 | //bakedTextureModule = null; | ||
11731 | int maxWearablesLoop = cachedtex.WearableData.Length; | ||
11732 | if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES) | ||
11733 | maxWearablesLoop = AvatarWearable.MAX_WEARABLES; | ||
11734 | |||
11735 | if (bakedTextureModule != null && cache != null) | ||
11730 | { | 11736 | { |
11731 | for (int i = 0; i < cachedtex.WearableData.Length; i++) | 11737 | // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid |
11738 | |||
11739 | WearableCacheItem[] cacheItems = null; | ||
11740 | ScenePresence p = m_scene.GetScenePresence(AgentId); | ||
11741 | if (p.Appearance != null) | ||
11742 | if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty) | ||
11743 | { | ||
11744 | try | ||
11745 | { | ||
11746 | cacheItems = bakedTextureModule.Get(AgentId); | ||
11747 | p.Appearance.WearableCacheItems = cacheItems; | ||
11748 | p.Appearance.WearableCacheItemsDirty = false; | ||
11749 | } | ||
11750 | |||
11751 | /* | ||
11752 | * The following Catch types DO NOT WORK, it jumps to the General Packet Exception Handler if you don't catch Exception! | ||
11753 | * | ||
11754 | catch (System.Net.Sockets.SocketException) | ||
11755 | { | ||
11756 | cacheItems = null; | ||
11757 | } | ||
11758 | catch (WebException) | ||
11759 | { | ||
11760 | cacheItems = null; | ||
11761 | } | ||
11762 | catch (InvalidOperationException) | ||
11763 | { | ||
11764 | cacheItems = null; | ||
11765 | } */ | ||
11766 | catch (Exception) | ||
11767 | { | ||
11768 | cacheItems = null; | ||
11769 | } | ||
11770 | |||
11771 | } | ||
11772 | else if (p.Appearance.WearableCacheItems != null) | ||
11773 | { | ||
11774 | cacheItems = p.Appearance.WearableCacheItems; | ||
11775 | } | ||
11776 | |||
11777 | if (cache != null && cacheItems != null) | ||
11732 | { | 11778 | { |
11733 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | 11779 | foreach (WearableCacheItem item in cacheItems) |
11734 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; | 11780 | { |
11735 | cachedresp.WearableData[i].TextureID = UUID.Zero; //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); | 11781 | |
11736 | cachedresp.WearableData[i].HostName = new byte[0]; | 11782 | if (cache.GetCached(item.TextureID.ToString()) == null) |
11783 | { | ||
11784 | item.TextureAsset.Temporary = true; | ||
11785 | cache.Store(item.TextureAsset); | ||
11786 | } | ||
11787 | |||
11788 | |||
11789 | } | ||
11790 | } | ||
11791 | |||
11792 | if (cacheItems != null) | ||
11793 | { | ||
11794 | |||
11795 | for (int i = 0; i < maxWearablesLoop; i++) | ||
11796 | { | ||
11797 | WearableCacheItem item = | ||
11798 | WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex,cacheItems); | ||
11799 | |||
11800 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | ||
11801 | cachedresp.WearableData[i].TextureIndex= cachedtex.WearableData[i].TextureIndex; | ||
11802 | cachedresp.WearableData[i].HostName = new byte[0]; | ||
11803 | if (item != null && cachedtex.WearableData[i].ID == item.CacheId) | ||
11804 | { | ||
11805 | |||
11806 | cachedresp.WearableData[i].TextureID = item.TextureID; | ||
11807 | } | ||
11808 | else | ||
11809 | { | ||
11810 | cachedresp.WearableData[i].TextureID = UUID.Zero; | ||
11811 | } | ||
11812 | } | ||
11813 | } | ||
11814 | else | ||
11815 | { | ||
11816 | for (int i = 0; i < maxWearablesLoop; i++) | ||
11817 | { | ||
11818 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | ||
11819 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; | ||
11820 | cachedresp.WearableData[i].TextureID = UUID.Zero; | ||
11821 | //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); | ||
11822 | cachedresp.WearableData[i].HostName = new byte[0]; | ||
11823 | } | ||
11737 | } | 11824 | } |
11738 | } | 11825 | } |
11739 | else | 11826 | else |
11740 | { | 11827 | { |
11741 | for (int i = 0; i < cachedtex.WearableData.Length; i++) | 11828 | if (cache == null) |
11742 | { | 11829 | { |
11743 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | 11830 | for (int i = 0; i < maxWearablesLoop; i++) |
11744 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; | 11831 | { |
11832 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | ||
11833 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; | ||
11834 | cachedresp.WearableData[i].TextureID = UUID.Zero; | ||
11835 | //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); | ||
11836 | cachedresp.WearableData[i].HostName = new byte[0]; | ||
11837 | } | ||
11838 | } | ||
11839 | else | ||
11840 | { | ||
11841 | for (int i = 0; i < maxWearablesLoop; i++) | ||
11842 | { | ||
11843 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | ||
11844 | cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; | ||
11745 | 11845 | ||
11746 | 11846 | ||
11747 | 11847 | ||
11748 | if (cache.Check(cachedtex.WearableData[i].ID.ToString())) | 11848 | if (cache.GetCached(cachedresp.WearableData[i].TextureID.ToString()) == null) |
11749 | cachedresp.WearableData[i].TextureID = UUID.Zero; | 11849 | cachedresp.WearableData[i].TextureID = UUID.Zero; |
11750 | //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); | 11850 | //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); |
11751 | else | 11851 | else |
11752 | cachedresp.WearableData[i].TextureID = UUID.Zero; // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); | 11852 | cachedresp.WearableData[i].TextureID = UUID.Zero; |
11753 | cachedresp.WearableData[i].HostName = new byte[0]; | 11853 | // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); |
11854 | cachedresp.WearableData[i].HostName = new byte[0]; | ||
11855 | } | ||
11754 | } | 11856 | } |
11755 | } | 11857 | } |
11756 | cachedresp.Header.Zerocoded = true; | 11858 | cachedresp.Header.Zerocoded = true; |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 3080023..27cf204 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -205,10 +205,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
205 | // ((ScenePresence)sp).SetSize(box,off); | 205 | // ((ScenePresence)sp).SetSize(box,off); |
206 | 206 | ||
207 | } | 207 | } |
208 | //if (cacheItems.Length > 0) | 208 | |
209 | //{ | ||
210 | sp.Appearance.WearableCacheItems = cacheItems; | ||
211 | //} | ||
212 | // Process the baked texture array | 209 | // Process the baked texture array |
213 | if (textureEntry != null) | 210 | if (textureEntry != null) |
214 | { | 211 | { |
@@ -284,8 +281,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
284 | public WearableCacheItem[] GetCachedItems(UUID agentId) | 281 | public WearableCacheItem[] GetCachedItems(UUID agentId) |
285 | { | 282 | { |
286 | ScenePresence sp = m_scene.GetScenePresence(agentId); | 283 | ScenePresence sp = m_scene.GetScenePresence(agentId); |
287 | Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = GetBakedTextureFaces(sp); | ||
288 | |||
289 | WearableCacheItem[] items = sp.Appearance.WearableCacheItems; | 284 | WearableCacheItem[] items = sp.Appearance.WearableCacheItems; |
290 | //foreach (WearableCacheItem item in items) | 285 | //foreach (WearableCacheItem item in items) |
291 | //{ | 286 | //{ |
diff --git a/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs index d63898a..21ed44f 100644 --- a/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs | |||
@@ -13,7 +13,7 @@ namespace OpenSim.Services.Interfaces | |||
13 | { | 13 | { |
14 | public interface IBakedTextureModule | 14 | public interface IBakedTextureModule |
15 | { | 15 | { |
16 | AssetBase[] Get(UUID id); | 16 | WearableCacheItem[] Get(UUID id); |
17 | void Store(UUID id, AssetBase[] data); | 17 | void Store(UUID id, WearableCacheItem[] data); |
18 | } | 18 | } |
19 | } | 19 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cdba282..a90bee4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2738,6 +2738,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2738 | return; | 2738 | return; |
2739 | } | 2739 | } |
2740 | 2740 | ||
2741 | m_lastSize = Appearance.AvatarSize; | ||
2742 | |||
2741 | int count = 0; | 2743 | int count = 0; |
2742 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 2744 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
2743 | { | 2745 | { |