From b4dcdffb5094c488a98acbe675b333c3bd4cc570 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Tue, 16 Mar 2010 11:50:22 -0700 Subject: 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 --- OpenSim/Region/DataSnapshot/ObjectSnapshot.cs | 62 ++++++++++++++++----------- 1 file changed, 36 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/DataSnapshot') 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 { string bestguess = string.Empty; Dictionary counts = new Dictionary(); - if (sog.RootPart.Shape != null && sog.RootPart.Shape.ProfileShape == ProfileShape.Square && - sog.RootPart.Shape.Textures != null && sog.RootPart.Shape.Textures.FaceTextures != null) + + PrimitiveBaseShape shape = sog.RootPart.Shape; + if (shape != null && shape.ProfileShape == ProfileShape.Square) { - if (sog.RootPart.Shape.Textures.DefaultTexture.TextureID != UUID.Zero && - sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_DefaultImage && - sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_BlankImage && - sog.RootPart.Shape.Textures.DefaultTexture.RGBA.A < 50) + Primitive.TextureEntry textures = shape.Textures; + if (textures != null) { - counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = 8; - } + if (textures.DefaultTexture != null && + textures.DefaultTexture.TextureID != UUID.Zero && + textures.DefaultTexture.TextureID != m_DefaultImage && + textures.DefaultTexture.TextureID != m_BlankImage && + textures.DefaultTexture.RGBA.A < 50f) + { + counts[textures.DefaultTexture.TextureID] = 8; + } - foreach (Primitive.TextureEntryFace tentry in sog.RootPart.Shape.Textures.FaceTextures) - { - if (tentry != null) + if (textures.FaceTextures != null) { - if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50) + foreach (Primitive.TextureEntryFace tentry in textures.FaceTextures) { - int c = 0; - counts.TryGetValue(tentry.TextureID, out c); - counts[tentry.TextureID] = c + 1; - // decrease the default texture count - if (counts.ContainsKey(sog.RootPart.Shape.Textures.DefaultTexture.TextureID)) - counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] - 1; + if (tentry != null) + { + if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50) + { + int c = 0; + counts.TryGetValue(tentry.TextureID, out c); + counts[tentry.TextureID] = c + 1; + // decrease the default texture count + if (counts.ContainsKey(textures.DefaultTexture.TextureID)) + counts[textures.DefaultTexture.TextureID] = counts[textures.DefaultTexture.TextureID] - 1; + } + } } } - } - // Let's pick the most unique texture - int min = 9999; - foreach (KeyValuePair kv in counts) - { - if (kv.Value < min && kv.Value >= 1) + // Let's pick the most unique texture + int min = 9999; + foreach (KeyValuePair kv in counts) { - bestguess = kv.Key.ToString(); - min = kv.Value; + if (kv.Value < min && kv.Value >= 1) + { + bestguess = kv.Key.ToString(); + min = kv.Value; + } } } } + return bestguess; } } -- cgit v1.1