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
parent
d722519b31
commit
b4dcdffb50
|
@ -227,8 +227,12 @@ namespace OpenSim.Framework
|
|||
{
|
||||
get
|
||||
{
|
||||
//m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: get m_textureEntry length {0}", m_textureEntry.Length);
|
||||
return new Primitive.TextureEntry(m_textureEntry, 0, m_textureEntry.Length);
|
||||
//m_log.DebugFormat("[SHAPE]: get m_textureEntry length {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(); }
|
||||
|
|
|
@ -285,24 +285,22 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
|
|||
return;
|
||||
}
|
||||
|
||||
byte[] assetData;
|
||||
byte[] assetData = null;
|
||||
AssetBase oldAsset = null;
|
||||
|
||||
if (BlendWithOldTexture)
|
||||
{
|
||||
UUID lastTextureID = part.Shape.Textures.DefaultTexture.TextureID;
|
||||
oldAsset = scene.AssetService.Get(lastTextureID.ToString());
|
||||
if (oldAsset != null)
|
||||
Primitive.TextureEntryFace defaultFace = part.Shape.Textures.DefaultTexture;
|
||||
if (defaultFace != null)
|
||||
{
|
||||
assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
assetData = new byte[data.Length];
|
||||
Array.Copy(data, assetData, data.Length);
|
||||
oldAsset = scene.AssetService.Get(defaultFace.TextureID.ToString());
|
||||
|
||||
if (oldAsset != null)
|
||||
assetData = BlendTextures(data, oldAsset.Data, SetNewFrontAlpha, FrontAlpha);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (assetData == null)
|
||||
{
|
||||
assetData = new byte[data.Length];
|
||||
Array.Copy(data, assetData, data.Length);
|
||||
|
|
|
@ -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
|
||||
//mapdotspot = Color.PaleGreen;
|
||||
|
||||
if (part.Shape.Textures == null)
|
||||
Primitive.TextureEntry textureEntry = part.Shape.Textures;
|
||||
|
||||
if (textureEntry == null || textureEntry.DefaultTexture == null)
|
||||
continue;
|
||||
|
||||
if (part.Shape.Textures.DefaultTexture == null)
|
||||
continue;
|
||||
|
||||
Color4 texcolor = part.Shape.Textures.DefaultTexture.RGBA;
|
||||
Color4 texcolor = textureEntry.DefaultTexture.RGBA;
|
||||
|
||||
// Not sure why some of these are null, oh well.
|
||||
|
||||
|
|
|
@ -203,44 +203,54 @@ namespace OpenSim.Region.DataSnapshot.Providers
|
|||
{
|
||||
string bestguess = string.Empty;
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = 8;
|
||||
}
|
||||
|
||||
foreach (Primitive.TextureEntryFace tentry in sog.RootPart.Shape.Textures.FaceTextures)
|
||||
PrimitiveBaseShape shape = sog.RootPart.Shape;
|
||||
if (shape != null && shape.ProfileShape == ProfileShape.Square)
|
||||
{
|
||||
Primitive.TextureEntry textures = shape.Textures;
|
||||
if (textures != null)
|
||||
{
|
||||
if (tentry != null)
|
||||
if (textures.DefaultTexture != null &&
|
||||
textures.DefaultTexture.TextureID != UUID.Zero &&
|
||||
textures.DefaultTexture.TextureID != m_DefaultImage &&
|
||||
textures.DefaultTexture.TextureID != m_BlankImage &&
|
||||
textures.DefaultTexture.RGBA.A < 50f)
|
||||
{
|
||||
if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50)
|
||||
counts[textures.DefaultTexture.TextureID] = 8;
|
||||
}
|
||||
|
||||
if (textures.FaceTextures != null)
|
||||
{
|
||||
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<UUID, int> kv in counts)
|
||||
{
|
||||
if (kv.Value < min && kv.Value >= 1)
|
||||
{
|
||||
bestguess = kv.Key.ToString();
|
||||
min = kv.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Let's pick the most unique texture
|
||||
int min = 9999;
|
||||
foreach (KeyValuePair<UUID, int> kv in counts)
|
||||
{
|
||||
if (kv.Value < min && kv.Value >= 1)
|
||||
{
|
||||
bestguess = kv.Key.ToString();
|
||||
min = kv.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bestguess;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,19 +129,20 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
try
|
||||
{
|
||||
Primitive.TextureEntry textureEntry = part.Shape.Textures;
|
||||
|
||||
// Get the prim's default texture. This will be used for faces which don't have their own texture
|
||||
assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture;
|
||||
|
||||
// XXX: Not a great way to iterate through face textures, but there's no
|
||||
// other method available to tell how many faces there actually are
|
||||
//int i = 0;
|
||||
foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
|
||||
if (textureEntry != null)
|
||||
{
|
||||
if (texture != null)
|
||||
// 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;
|
||||
|
||||
if (textureEntry.FaceTextures != null)
|
||||
{
|
||||
//m_log.DebugFormat("[ARCHIVER]: Got face {0}", i++);
|
||||
assetUuids[texture.TextureID] = AssetType.Texture;
|
||||
// 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)
|
||||
{
|
||||
if (texture != null)
|
||||
assetUuids[texture.TextureID] = AssetType.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue