Fix CHANGED_TEXTURE and CHANGED_COLOR.

avinationmerge
Melanie 2011-12-05 18:32:40 +01:00
parent 3281b99362
commit 2a8a46a32d
4 changed files with 67 additions and 66 deletions

View File

@ -355,7 +355,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
// I'm pretty sure noone whats to set fullbright true if it wasn't true before. // I'm pretty sure noone whats to set fullbright true if it wasn't true before.
// tmptex.DefaultTexture.Fullbright = true; // tmptex.DefaultTexture.Fullbright = true;
part.UpdateTexture(tmptex); part.UpdateTextureEntry(tmptex.GetBytes());
} }
if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0)) if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
@ -437,4 +437,4 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
#endregion #endregion
} }
} }

View File

@ -3231,7 +3231,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="face"></param> /// <param name="face"></param>
public void SetFaceColor(Vector3 color, int face) public void SetFaceColor(Vector3 color, int face)
{ {
Primitive.TextureEntry tex = Shape.Textures; // The only way to get a deep copy/ If we don't do this, we can
// mever detect color changes further down.
Byte[] buf = Shape.Textures.GetBytes();
Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length);
Color4 texcolor; Color4 texcolor;
if (face >= 0 && face < GetNumberOfSides()) if (face >= 0 && face < GetNumberOfSides())
{ {
@ -3240,8 +3243,7 @@ namespace OpenSim.Region.Framework.Scenes
texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
UpdateTexture(tex); UpdateTextureEntry(tex.GetBytes());
TriggerScriptChangedEvent(Changed.COLOR);
return; return;
} }
else if (face == ALL_SIDES) else if (face == ALL_SIDES)
@ -3262,8 +3264,7 @@ namespace OpenSim.Region.Framework.Scenes
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
} }
UpdateTexture(tex); UpdateTextureEntry(tex.GetBytes());
TriggerScriptChangedEvent(Changed.COLOR);
return; return;
} }
} }
@ -4584,47 +4585,47 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// Update the textures on the part.
/// </summary>
/// <remarks>
/// Added to handle bug in libsecondlife's TextureEntry.ToBytes()
/// not handling RGBA properly. Cycles through, and "fixes" the color
/// info
/// </remarks>
/// <param name="tex"></param>
public void UpdateTexture(Primitive.TextureEntry tex)
{
//Color4 tmpcolor;
//for (uint i = 0; i < 32; i++)
//{
// if (tex.FaceTextures[i] != null)
// {
// tmpcolor = tex.GetFace((uint) i).RGBA;
// tmpcolor.A = tmpcolor.A*255;
// tmpcolor.R = tmpcolor.R*255;
// tmpcolor.G = tmpcolor.G*255;
// tmpcolor.B = tmpcolor.B*255;
// tex.FaceTextures[i].RGBA = tmpcolor;
// }
//}
//tmpcolor = tex.DefaultTexture.RGBA;
//tmpcolor.A = tmpcolor.A*255;
//tmpcolor.R = tmpcolor.R*255;
//tmpcolor.G = tmpcolor.G*255;
//tmpcolor.B = tmpcolor.B*255;
//tex.DefaultTexture.RGBA = tmpcolor;
UpdateTextureEntry(tex.GetBytes());
}
/// <summary> /// <summary>
/// Update the texture entry for this part. /// Update the texture entry for this part.
/// </summary> /// </summary>
/// <param name="textureEntry"></param> /// <param name="textureEntry"></param>
public void UpdateTextureEntry(byte[] textureEntry) public void UpdateTextureEntry(byte[] textureEntry)
{ {
Primitive.TextureEntry newTex = new Primitive.TextureEntry(textureEntry, 0, textureEntry.Length);
Primitive.TextureEntry oldTex = Shape.Textures;
Changed changeFlags = 0;
for (int i = 0 ; i < GetNumberOfSides(); i++)
{
Primitive.TextureEntryFace newFace = newTex.DefaultTexture;
Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture;
if (oldTex.FaceTextures[i] != null)
oldFace = oldTex.FaceTextures[i];
if (newTex.FaceTextures[i] != null)
newFace = newTex.FaceTextures[i];
Color4 oldRGBA = oldFace.RGBA;
Color4 newRGBA = newFace.RGBA;
if (oldRGBA.R != newRGBA.R ||
oldRGBA.G != newRGBA.G ||
oldRGBA.B != newRGBA.B ||
oldRGBA.A != newRGBA.A)
changeFlags |= Changed.COLOR;
if (oldFace.TextureID != newFace.TextureID)
changeFlags |= Changed.TEXTURE;
// Max change, skip the rest of testing
if (changeFlags == (Changed.TEXTURE | Changed.COLOR))
break;
}
m_shape.TextureEntry = textureEntry; m_shape.TextureEntry = textureEntry;
TriggerScriptChangedEvent(Changed.TEXTURE); if (changeFlags != 0)
TriggerScriptChangedEvent(changeFlags);
UpdateFlag = UpdateRequired.FULL; UpdateFlag = UpdateRequired.FULL;
ParentGroup.HasGroupChanged = true; ParentGroup.HasGroupChanged = true;

View File

@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
texface.RGBA = new Color4(value.R,value.G,value.B,value.A); texface.RGBA = new Color4(value.R,value.G,value.B,value.A);
tex.FaceTextures[m_face] = texface; tex.FaceTextures[m_face] = texface;
m_parent.UpdateTexture(tex); m_parent.UpdateTextureEntry(tex.GetBytes());
} }
} }
@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
texface.TextureID = value; texface.TextureID = value;
tex.FaceTextures[m_face] = texface; tex.FaceTextures[m_face] = texface;
m_parent.UpdateTexture(tex); m_parent.UpdateTextureEntry(tex.GetBytes());
} }
} }
@ -97,7 +97,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
texface.Fullbright = value; texface.Fullbright = value;
tex.FaceTextures[m_face] = texface; tex.FaceTextures[m_face] = texface;
m_parent.UpdateTexture(tex); m_parent.UpdateTextureEntry(tex.GetBytes());
} }
} }
@ -110,7 +110,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
texface.Glow = (float) value; texface.Glow = (float) value;
tex.FaceTextures[m_face] = texface; tex.FaceTextures[m_face] = texface;
m_parent.UpdateTexture(tex); m_parent.UpdateTextureEntry(tex.GetBytes());
} }
} }
@ -123,7 +123,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)m_face);
texface.Shiny = value ? Shininess.High : Shininess.None; texface.Shiny = value ? Shininess.High : Shininess.None;
tex.FaceTextures[m_face] = texface; tex.FaceTextures[m_face] = texface;
m_parent.UpdateTexture(tex); m_parent.UpdateTextureEntry(tex.GetBytes());
} }
} }

View File

@ -1540,7 +1540,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
else if (face == ScriptBaseClass.ALL_SIDES) else if (face == ScriptBaseClass.ALL_SIDES)
@ -1561,7 +1561,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
} }
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
@ -1586,7 +1586,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
tex.CreateFace((uint) face); tex.CreateFace((uint) face);
tex.FaceTextures[face].TexMapType = textype; tex.FaceTextures[face].TexMapType = textype;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
else if (face == ScriptBaseClass.ALL_SIDES) else if (face == ScriptBaseClass.ALL_SIDES)
@ -1599,7 +1599,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
tex.DefaultTexture.TexMapType = textype; tex.DefaultTexture.TexMapType = textype;
} }
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
} }
@ -1614,7 +1614,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
tex.CreateFace((uint) face); tex.CreateFace((uint) face);
tex.FaceTextures[face].Glow = glow; tex.FaceTextures[face].Glow = glow;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
else if (face == ScriptBaseClass.ALL_SIDES) else if (face == ScriptBaseClass.ALL_SIDES)
@ -1627,7 +1627,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
tex.DefaultTexture.Glow = glow; tex.DefaultTexture.Glow = glow;
} }
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
} }
@ -1664,7 +1664,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
tex.CreateFace((uint) face); tex.CreateFace((uint) face);
tex.FaceTextures[face].Shiny = sval; tex.FaceTextures[face].Shiny = sval;
tex.FaceTextures[face].Bump = bump; tex.FaceTextures[face].Bump = bump;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
else if (face == ScriptBaseClass.ALL_SIDES) else if (face == ScriptBaseClass.ALL_SIDES)
@ -1679,7 +1679,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
tex.DefaultTexture.Shiny = sval; tex.DefaultTexture.Shiny = sval;
tex.DefaultTexture.Bump = bump; tex.DefaultTexture.Bump = bump;
} }
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
} }
@ -1694,7 +1694,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
tex.CreateFace((uint) face); tex.CreateFace((uint) face);
tex.FaceTextures[face].Fullbright = bright; tex.FaceTextures[face].Fullbright = bright;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
else if (face == ScriptBaseClass.ALL_SIDES) else if (face == ScriptBaseClass.ALL_SIDES)
@ -1707,7 +1707,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
tex.DefaultTexture.Fullbright = bright; tex.DefaultTexture.Fullbright = bright;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
} }
@ -1776,7 +1776,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
else if (face == ScriptBaseClass.ALL_SIDES) else if (face == ScriptBaseClass.ALL_SIDES)
@ -1800,7 +1800,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
} }
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
} }
@ -1969,7 +1969,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
texface.TextureID = textureID; texface.TextureID = textureID;
tex.FaceTextures[face] = texface; tex.FaceTextures[face] = texface;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
else if (face == ScriptBaseClass.ALL_SIDES) else if (face == ScriptBaseClass.ALL_SIDES)
@ -1982,7 +1982,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
tex.DefaultTexture.TextureID = textureID; tex.DefaultTexture.TextureID = textureID;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
} }
@ -2007,7 +2007,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
texface.RepeatU = (float)u; texface.RepeatU = (float)u;
texface.RepeatV = (float)v; texface.RepeatV = (float)v;
tex.FaceTextures[face] = texface; tex.FaceTextures[face] = texface;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
if (face == ScriptBaseClass.ALL_SIDES) if (face == ScriptBaseClass.ALL_SIDES)
@ -2022,7 +2022,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
tex.DefaultTexture.RepeatU = (float)u; tex.DefaultTexture.RepeatU = (float)u;
tex.DefaultTexture.RepeatV = (float)v; tex.DefaultTexture.RepeatV = (float)v;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
} }
@ -2046,7 +2046,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
texface.OffsetU = (float)u; texface.OffsetU = (float)u;
texface.OffsetV = (float)v; texface.OffsetV = (float)v;
tex.FaceTextures[face] = texface; tex.FaceTextures[face] = texface;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
if (face == ScriptBaseClass.ALL_SIDES) if (face == ScriptBaseClass.ALL_SIDES)
@ -2061,7 +2061,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
tex.DefaultTexture.OffsetU = (float)u; tex.DefaultTexture.OffsetU = (float)u;
tex.DefaultTexture.OffsetV = (float)v; tex.DefaultTexture.OffsetV = (float)v;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
} }
@ -2084,7 +2084,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
texface.Rotation = (float)rotation; texface.Rotation = (float)rotation;
tex.FaceTextures[face] = texface; tex.FaceTextures[face] = texface;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
if (face == ScriptBaseClass.ALL_SIDES) if (face == ScriptBaseClass.ALL_SIDES)
@ -2097,7 +2097,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
tex.DefaultTexture.Rotation = (float)rotation; tex.DefaultTexture.Rotation = (float)rotation;
part.UpdateTexture(tex); part.UpdateTextureEntry(tex.GetBytes());
return; return;
} }
} }