diff options
author | John Hurliman | 2010-03-16 11:50:22 -0700 |
---|---|---|
committer | John Hurliman | 2010-03-16 11:50:22 -0700 |
commit | b4dcdffb5094c488a98acbe675b333c3bd4cc570 (patch) | |
tree | 14998b10e4d13d2dd933a5d5e014db1f4bb07b43 /OpenSim/Region | |
parent | * Fixing the SimianGrid friend connector enabled detection since the friends ... (diff) | |
download | opensim-SC-b4dcdffb5094c488a98acbe675b333c3bd4cc570.zip opensim-SC-b4dcdffb5094c488a98acbe675b333c3bd4cc570.tar.gz opensim-SC-b4dcdffb5094c488a98acbe675b333c3bd4cc570.tar.bz2 opensim-SC-b4dcdffb5094c488a98acbe675b333c3bd4cc570.tar.xz |
Fixed several unhandled exceptions and performance issues with PrimitiveBaseShape.Textures. This really should be moved from a property to a method if it is going to decode a byte[] into a TextureEntry each time
Diffstat (limited to 'OpenSim/Region')
4 files changed, 60 insertions, 52 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 643764f..678e772 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |||
@@ -285,24 +285,22 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | 287 | ||
288 | byte[] assetData; | 288 | byte[] assetData = null; |
289 | AssetBase oldAsset = null; | 289 | AssetBase oldAsset = null; |
290 | 290 | ||
291 | if (BlendWithOldTexture) | 291 | if (BlendWithOldTexture) |
292 | { | 292 | { |
293 | UUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID; | 293 | Primitive.TextureEntryFace defaultFace = part.Shape.Textures.DefaultTexture; |
294 | oldAsset = scene.AssetService.Get(lastTextureID.ToString()); | 294 | if (defaultFace != null) |
295 | if (oldAsset != null) | ||
296 | { | ||
297 | assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha); | ||
298 | } | ||
299 | else | ||
300 | { | 295 | { |
301 | assetData = new byte[data.Length]; | 296 | oldAsset = scene.AssetService.Get(defaultFace.TextureID.ToString()); |
302 | Array.Copy(data, assetData, data.Length); | 297 | |
298 | if (oldAsset != null) | ||
299 | assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha); | ||
303 | } | 300 | } |
304 | } | 301 | } |
305 | else | 302 | |
303 | if (assetData == null) | ||
306 | { | 304 | { |
307 | assetData = new byte[data.Length]; | 305 | assetData = new byte[data.Length]; |
308 | Array.Copy(data, assetData, data.Length); | 306 | Array.Copy(data, assetData, data.Length); |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs index 285d36a..b71b5f6 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapImageModule.cs | |||
@@ -251,13 +251,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
251 | // if you want tree blocks on the map comment the above line and uncomment the below line | 251 | // if you want tree blocks on the map comment the above line and uncomment the below line |
252 | //mapdotspot = Color.PaleGreen; | 252 | //mapdotspot = Color.PaleGreen; |
253 | 253 | ||
254 | if (part.Shape.Textures == null) | 254 | Primitive.TextureEntry textureEntry = part.Shape.Textures; |
255 | continue; | ||
256 | 255 | ||
257 | if (part.Shape.Textures.DefaultTexture == null) | 256 | if (textureEntry == null || textureEntry.DefaultTexture == null) |
258 | continue; | 257 | continue; |
259 | 258 | ||
260 | Color4 texcolor = part.Shape.Textures.DefaultTexture.RGBA; | 259 | Color4 texcolor = textureEntry.DefaultTexture.RGBA; |
261 | 260 | ||
262 | // Not sure why some of these are null, oh well. | 261 | // Not sure why some of these are null, oh well. |
263 | 262 | ||
diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs index 76dac61..f441aa9 100644 --- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs | |||
@@ -203,44 +203,54 @@ namespace OpenSim.Region.DataSnapshot.Providers | |||
203 | { | 203 | { |
204 | string bestguess = string.Empty; | 204 | string bestguess = string.Empty; |
205 | Dictionary<UUID, int> counts = new Dictionary<UUID, int>(); | 205 | Dictionary<UUID, int> counts = new Dictionary<UUID, int>(); |
206 | if (sog.RootPart.Shape != null && sog.RootPart.Shape.ProfileShape == ProfileShape.Square && | 206 | |
207 | sog.RootPart.Shape.Textures != null && sog.RootPart.Shape.Textures.FaceTextures != null) | 207 | PrimitiveBaseShape shape = sog.RootPart.Shape; |
208 | if (shape != null && shape.ProfileShape == ProfileShape.Square) | ||
208 | { | 209 | { |
209 | if (sog.RootPart.Shape.Textures.DefaultTexture.TextureID != UUID.Zero && | 210 | Primitive.TextureEntry textures = shape.Textures; |
210 | sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_DefaultImage && | 211 | if (textures != null) |
211 | sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_BlankImage && | ||
212 | sog.RootPart.Shape.Textures.DefaultTexture.RGBA.A < 50) | ||
213 | { | 212 | { |
214 | counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = 8; | 213 | if (textures.DefaultTexture != null && |
215 | } | 214 | textures.DefaultTexture.TextureID != UUID.Zero && |
215 | textures.DefaultTexture.TextureID != m_DefaultImage && | ||
216 | textures.DefaultTexture.TextureID != m_BlankImage && | ||
217 | textures.DefaultTexture.RGBA.A < 50f) | ||
218 | { | ||
219 | counts[textures.DefaultTexture.TextureID] = 8; | ||
220 | } | ||
216 | 221 | ||
217 | foreach (Primitive.TextureEntryFace tentry in sog.RootPart.Shape.Textures.FaceTextures) | 222 | if (textures.FaceTextures != null) |
218 | { | ||
219 | if (tentry != null) | ||
220 | { | 223 | { |
221 | if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50) | 224 | foreach (Primitive.TextureEntryFace tentry in textures.FaceTextures) |
222 | { | 225 | { |
223 | int c = 0; | 226 | if (tentry != null) |
224 | counts.TryGetValue(tentry.TextureID, out c); | 227 | { |
225 | counts[tentry.TextureID] = c + 1; | 228 | if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50) |
226 | // decrease the default texture count | 229 | { |
227 | if (counts.ContainsKey(sog.RootPart.Shape.Textures.DefaultTexture.TextureID)) | 230 | int c = 0; |
228 | counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] - 1; | 231 | counts.TryGetValue(tentry.TextureID, out c); |
232 | counts[tentry.TextureID] = c + 1; | ||
233 | // decrease the default texture count | ||
234 | if (counts.ContainsKey(textures.DefaultTexture.TextureID)) | ||
235 | counts[textures.DefaultTexture.TextureID] = counts[textures.DefaultTexture.TextureID] - 1; | ||
236 | } | ||
237 | } | ||
229 | } | 238 | } |
230 | } | 239 | } |
231 | } | ||
232 | 240 | ||
233 | // Let's pick the most unique texture | 241 | // Let's pick the most unique texture |
234 | int min = 9999; | 242 | int min = 9999; |
235 | foreach (KeyValuePair<UUID, int> kv in counts) | 243 | foreach (KeyValuePair<UUID, int> kv in counts) |
236 | { | ||
237 | if (kv.Value < min && kv.Value >= 1) | ||
238 | { | 244 | { |
239 | bestguess = kv.Key.ToString(); | 245 | if (kv.Value < min && kv.Value >= 1) |
240 | min = kv.Value; | 246 | { |
247 | bestguess = kv.Key.ToString(); | ||
248 | min = kv.Value; | ||
249 | } | ||
241 | } | 250 | } |
242 | } | 251 | } |
243 | } | 252 | } |
253 | |||
244 | return bestguess; | 254 | return bestguess; |
245 | } | 255 | } |
246 | } | 256 | } |
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 4a1f648..0ec3cc3 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -129,19 +129,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
129 | try | 129 | try |
130 | { | 130 | { |
131 | Primitive.TextureEntry textureEntry = part.Shape.Textures; | 131 | Primitive.TextureEntry textureEntry = part.Shape.Textures; |
132 | 132 | if (textureEntry != null) | |
133 | // Get the prim's default texture. This will be used for faces which don't have their own texture | ||
134 | assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture; | ||
135 | |||
136 | // XXX: Not a great way to iterate through face textures, but there's no | ||
137 | // other method available to tell how many faces there actually are | ||
138 | //int i = 0; | ||
139 | foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) | ||
140 | { | 133 | { |
141 | if (texture != null) | 134 | // Get the prim's default texture. This will be used for faces which don't have their own texture |
135 | if (textureEntry.DefaultTexture != null) | ||
136 | assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture; | ||
137 | |||
138 | if (textureEntry.FaceTextures != null) | ||
142 | { | 139 | { |
143 | //m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++); | 140 | // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture) |
144 | assetUuids[texture.TextureID] = AssetType.Texture; | 141 | foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) |
142 | { | ||
143 | if (texture != null) | ||
144 | assetUuids[texture.TextureID] = AssetType.Texture; | ||
145 | } | ||
145 | } | 146 | } |
146 | } | 147 | } |
147 | 148 | ||