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

slimupdates
John Hurliman 2010-03-16 11:50:22 -07:00
parent d722519b31
commit b4dcdffb50
5 changed files with 71 additions and 59 deletions

View File

@ -227,8 +227,12 @@ namespace OpenSim.Framework
{ {
get get
{ {
//m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length); //m_log.DebugFormat("[SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length);
return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); try { return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length); }
catch { }
m_log.Warn("[SHAPE]: Failed to decode texture, length=" + ((m_textureEntry != null) ? m_textureEntry.Length : 0));
return new Primitive.TextureEntry(null);
} }
set { m_textureEntry = value.GetBytes(); } set { m_textureEntry = value.GetBytes(); }

View File

@ -285,24 +285,22 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
return; return;
} }
byte[] assetData; byte[] assetData = null;
AssetBase oldAsset = null; AssetBase oldAsset = null;
if (BlendWithOldTexture) if (BlendWithOldTexture)
{ {
UUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID; Primitive.TextureEntryFace defaultFace = part.Shape.Textures.DefaultTexture;
oldAsset = scene.AssetService.Get(lastTextureID.ToString()); if (defaultFace != null)
if (oldAsset != null)
{ {
oldAsset = scene.AssetService.Get(defaultFace.TextureID.ToString());
if (oldAsset != null)
assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha); assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha);
} }
else
{
assetData = new byte[data.Length];
Array.Copy(data, assetData, data.Length);
} }
}
else if (assetData == null)
{ {
assetData = new byte[data.Length]; assetData = new byte[data.Length];
Array.Copy(data, assetData, data.Length); Array.Copy(data, assetData, data.Length);

View File

@ -251,13 +251,12 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
// if you want tree blocks on the map comment the above line and uncomment the below line // if you want tree blocks on the map comment the above line and uncomment the below line
//mapdotspot = Color.PaleGreen; //mapdotspot = Color.PaleGreen;
if (part.Shape.Textures == null) Primitive.TextureEntry textureEntry = part.Shape.Textures;
if (textureEntry == null || textureEntry.DefaultTexture == null)
continue; continue;
if (part.Shape.Textures.DefaultTexture == null) Color4 texcolor = textureEntry.DefaultTexture.RGBA;
continue;
Color4 texcolor = part.Shape.Textures.DefaultTexture.RGBA;
// Not sure why some of these are null, oh well. // Not sure why some of these are null, oh well.

View File

@ -203,18 +203,25 @@ namespace OpenSim.Region.DataSnapshot.Providers
{ {
string bestguess = string.Empty; string bestguess = string.Empty;
Dictionary<UUID, int> counts = new Dictionary<UUID, int>(); Dictionary<UUID, int> counts = new Dictionary<UUID, int>();
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 && Primitive.TextureEntry textures = shape.Textures;
sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_DefaultImage && if (textures != null)
sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_BlankImage &&
sog.RootPart.Shape.Textures.DefaultTexture.RGBA.A < 50)
{ {
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 (textures.FaceTextures != null)
{
foreach (Primitive.TextureEntryFace tentry in textures.FaceTextures)
{ {
if (tentry != null) if (tentry != null)
{ {
@ -224,8 +231,9 @@ namespace OpenSim.Region.DataSnapshot.Providers
counts.TryGetValue(tentry.TextureID, out c); counts.TryGetValue(tentry.TextureID, out c);
counts[tentry.TextureID] = c + 1; counts[tentry.TextureID] = c + 1;
// decrease the default texture count // decrease the default texture count
if (counts.ContainsKey(sog.RootPart.Shape.Textures.DefaultTexture.TextureID)) if (counts.ContainsKey(textures.DefaultTexture.TextureID))
counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] - 1; counts[textures.DefaultTexture.TextureID] = counts[textures.DefaultTexture.TextureID] - 1;
}
} }
} }
} }
@ -241,6 +249,8 @@ namespace OpenSim.Region.DataSnapshot.Providers
} }
} }
} }
}
return bestguess; return bestguess;
} }
} }

View File

@ -129,21 +129,22 @@ namespace OpenSim.Region.Framework.Scenes
try try
{ {
Primitive.TextureEntry textureEntry = part.Shape.Textures; Primitive.TextureEntry textureEntry = part.Shape.Textures;
if (textureEntry != null)
{
// Get the prim's default texture. This will be used for faces which don't have their own texture // Get the prim's default texture. This will be used for faces which don't have their own texture
if (textureEntry.DefaultTexture != null)
assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture; assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture;
// XXX: Not a great way to iterate through face textures, but there's no if (textureEntry.FaceTextures != null)
// other method available to tell how many faces there actually are {
//int i = 0; // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture)
foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
{ {
if (texture != null) if (texture != null)
{
//m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++);
assetUuids[texture.TextureID] = AssetType.Texture; assetUuids[texture.TextureID] = AssetType.Texture;
} }
} }
}
// If the prim is a sculpt then preserve this information too // If the prim is a sculpt then preserve this information too
if (part.Shape.SculptTexture != UUID.Zero) if (part.Shape.SculptTexture != UUID.Zero)