aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs79
1 files changed, 40 insertions, 39 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 11040b7..c88e1d7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3231,7 +3231,10 @@ namespace OpenSim.Region.Framework.Scenes
3231 /// <param name="face"></param> 3231 /// <param name="face"></param>
3232 public void SetFaceColor(Vector3 color, int face) 3232 public void SetFaceColor(Vector3 color, int face)
3233 { 3233 {
3234 Primitive.TextureEntry tex = Shape.Textures; 3234 // The only way to get a deep copy/ If we don't do this, we can
3235 // mever detect color changes further down.
3236 Byte[] buf = Shape.Textures.GetBytes();
3237 Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length);
3235 Color4 texcolor; 3238 Color4 texcolor;
3236 if (face >= 0 && face < GetNumberOfSides()) 3239 if (face >= 0 && face < GetNumberOfSides())
3237 { 3240 {
@@ -3240,8 +3243,7 @@ namespace OpenSim.Region.Framework.Scenes
3240 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); 3243 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
3241 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); 3244 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
3242 tex.FaceTextures[face].RGBA = texcolor; 3245 tex.FaceTextures[face].RGBA = texcolor;
3243 UpdateTexture(tex); 3246 UpdateTextureEntry(tex.GetBytes());
3244 TriggerScriptChangedEvent(Changed.COLOR);
3245 return; 3247 return;
3246 } 3248 }
3247 else if (face == ALL_SIDES) 3249 else if (face == ALL_SIDES)
@@ -3262,8 +3264,7 @@ namespace OpenSim.Region.Framework.Scenes
3262 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); 3264 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
3263 tex.DefaultTexture.RGBA = texcolor; 3265 tex.DefaultTexture.RGBA = texcolor;
3264 } 3266 }
3265 UpdateTexture(tex); 3267 UpdateTextureEntry(tex.GetBytes());
3266 TriggerScriptChangedEvent(Changed.COLOR);
3267 return; 3268 return;
3268 } 3269 }
3269 } 3270 }
@@ -4585,46 +4586,46 @@ namespace OpenSim.Region.Framework.Scenes
4585 } 4586 }
4586 4587
4587 /// <summary> 4588 /// <summary>
4588 /// Update the textures on the part.
4589 /// </summary>
4590 /// <remarks>
4591 /// Added to handle bug in libsecondlife's TextureEntry.ToBytes()
4592 /// not handling RGBA properly. Cycles through, and "fixes" the color
4593 /// info
4594 /// </remarks>
4595 /// <param name="tex"></param>
4596 public void UpdateTexture(Primitive.TextureEntry tex)
4597 {
4598 //Color4 tmpcolor;
4599 //for (uint i = 0; i < 32; i++)
4600 //{
4601 // if (tex.FaceTextures[i] != null)
4602 // {
4603 // tmpcolor = tex.GetFace((uint) i).RGBA;
4604 // tmpcolor.A = tmpcolor.A*255;
4605 // tmpcolor.R = tmpcolor.R*255;
4606 // tmpcolor.G = tmpcolor.G*255;
4607 // tmpcolor.B = tmpcolor.B*255;
4608 // tex.FaceTextures[i].RGBA = tmpcolor;
4609 // }
4610 //}
4611 //tmpcolor = tex.DefaultTexture.RGBA;
4612 //tmpcolor.A = tmpcolor.A*255;
4613 //tmpcolor.R = tmpcolor.R*255;
4614 //tmpcolor.G = tmpcolor.G*255;
4615 //tmpcolor.B = tmpcolor.B*255;
4616 //tex.DefaultTexture.RGBA = tmpcolor;
4617 UpdateTextureEntry(tex.GetBytes());
4618 }
4619
4620 /// <summary>
4621 /// Update the texture entry for this part. 4589 /// Update the texture entry for this part.
4622 /// </summary> 4590 /// </summary>
4623 /// <param name="textureEntry"></param> 4591 /// <param name="textureEntry"></param>
4624 public void UpdateTextureEntry(byte[] textureEntry) 4592 public void UpdateTextureEntry(byte[] textureEntry)
4625 { 4593 {
4594 Primitive.TextureEntry newTex = new Primitive.TextureEntry(textureEntry, 0, textureEntry.Length);
4595 Primitive.TextureEntry oldTex = Shape.Textures;
4596
4597 Changed changeFlags = 0;
4598
4599 for (int i = 0 ; i < GetNumberOfSides(); i++)
4600 {
4601 Primitive.TextureEntryFace newFace = newTex.DefaultTexture;
4602 Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture;
4603
4604 if (oldTex.FaceTextures[i] != null)
4605 oldFace = oldTex.FaceTextures[i];
4606 if (newTex.FaceTextures[i] != null)
4607 newFace = newTex.FaceTextures[i];
4608
4609 Color4 oldRGBA = oldFace.RGBA;
4610 Color4 newRGBA = newFace.RGBA;
4611
4612 if (oldRGBA.R != newRGBA.R ||
4613 oldRGBA.G != newRGBA.G ||
4614 oldRGBA.B != newRGBA.B ||
4615 oldRGBA.A != newRGBA.A)
4616 changeFlags |= Changed.COLOR;
4617
4618 if (oldFace.TextureID != newFace.TextureID)
4619 changeFlags |= Changed.TEXTURE;
4620
4621 // Max change, skip the rest of testing
4622 if (changeFlags == (Changed.TEXTURE | Changed.COLOR))
4623 break;
4624 }
4625
4626 m_shape.TextureEntry = textureEntry; 4626 m_shape.TextureEntry = textureEntry;
4627 TriggerScriptChangedEvent(Changed.TEXTURE); 4627 if (changeFlags != 0)
4628 TriggerScriptChangedEvent(changeFlags);
4628 UpdateFlag = UpdateRequired.FULL; 4629 UpdateFlag = UpdateRequired.FULL;
4629 ParentGroup.HasGroupChanged = true; 4630 ParentGroup.HasGroupChanged = true;
4630 4631