diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 90 |
1 files changed, 49 insertions, 41 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 24322a1..c8b39a4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -3178,7 +3178,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3178 | /// <param name="face"></param> | 3178 | /// <param name="face"></param> |
3179 | public void SetFaceColor(Vector3 color, int face) | 3179 | public void SetFaceColor(Vector3 color, int face) |
3180 | { | 3180 | { |
3181 | Primitive.TextureEntry tex = Shape.Textures; | 3181 | // The only way to get a deep copy/ If we don't do this, we can |
3182 | // mever detect color changes further down. | ||
3183 | Byte[] buf = Shape.Textures.GetBytes(); | ||
3184 | Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length); | ||
3182 | Color4 texcolor; | 3185 | Color4 texcolor; |
3183 | if (face >= 0 && face < GetNumberOfSides()) | 3186 | if (face >= 0 && face < GetNumberOfSides()) |
3184 | { | 3187 | { |
@@ -3187,8 +3190,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3187 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | 3190 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); |
3188 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | 3191 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); |
3189 | tex.FaceTextures[face].RGBA = texcolor; | 3192 | tex.FaceTextures[face].RGBA = texcolor; |
3190 | UpdateTexture(tex); | 3193 | UpdateTextureEntry(tex.GetBytes()); |
3191 | TriggerScriptChangedEvent(Changed.COLOR); | ||
3192 | return; | 3194 | return; |
3193 | } | 3195 | } |
3194 | else if (face == ALL_SIDES) | 3196 | else if (face == ALL_SIDES) |
@@ -3209,8 +3211,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3209 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | 3211 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); |
3210 | tex.DefaultTexture.RGBA = texcolor; | 3212 | tex.DefaultTexture.RGBA = texcolor; |
3211 | } | 3213 | } |
3212 | UpdateTexture(tex); | 3214 | UpdateTextureEntry(tex.GetBytes()); |
3213 | TriggerScriptChangedEvent(Changed.COLOR); | ||
3214 | return; | 3215 | return; |
3215 | } | 3216 | } |
3216 | } | 3217 | } |
@@ -3272,9 +3273,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3272 | if (hasHollow) ret += 1; | 3273 | if (hasHollow) ret += 1; |
3273 | break; | 3274 | break; |
3274 | case PrimType.SCULPT: | 3275 | case PrimType.SCULPT: |
3275 | ret = 1; | 3276 | // Special mesh handling |
3277 | if (Shape.SculptType == (byte)SculptType.Mesh) | ||
3278 | ret = 8; // if it's a mesh then max 8 faces | ||
3279 | else | ||
3280 | ret = 1; // if it's a sculpt then max 1 face | ||
3276 | break; | 3281 | break; |
3277 | } | 3282 | } |
3283 | |||
3278 | return ret; | 3284 | return ret; |
3279 | } | 3285 | } |
3280 | 3286 | ||
@@ -3287,6 +3293,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3287 | { | 3293 | { |
3288 | if (Shape.SculptEntry) | 3294 | if (Shape.SculptEntry) |
3289 | return PrimType.SCULPT; | 3295 | return PrimType.SCULPT; |
3296 | |||
3290 | if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) | 3297 | if ((Shape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) |
3291 | { | 3298 | { |
3292 | if (Shape.PathCurve == (byte)Extrusion.Straight) | 3299 | if (Shape.PathCurve == (byte)Extrusion.Straight) |
@@ -4532,48 +4539,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
4532 | } | 4539 | } |
4533 | 4540 | ||
4534 | /// <summary> | 4541 | /// <summary> |
4535 | /// Update the textures on the part. | ||
4536 | /// </summary> | ||
4537 | /// <remarks> | ||
4538 | /// Added to handle bug in libsecondlife's TextureEntry.ToBytes() | ||
4539 | /// not handling RGBA properly. Cycles through, and "fixes" the color | ||
4540 | /// info | ||
4541 | /// </remarks> | ||
4542 | /// <param name="tex"></param> | ||
4543 | public void UpdateTexture(Primitive.TextureEntry tex) | ||
4544 | { | ||
4545 | //Color4 tmpcolor; | ||
4546 | //for (uint i = 0; i < 32; i++) | ||
4547 | //{ | ||
4548 | // if (tex.FaceTextures[i] != null) | ||
4549 | // { | ||
4550 | // tmpcolor = tex.GetFace((uint) i).RGBA; | ||
4551 | // tmpcolor.A = tmpcolor.A*255; | ||
4552 | // tmpcolor.R = tmpcolor.R*255; | ||
4553 | // tmpcolor.G = tmpcolor.G*255; | ||
4554 | // tmpcolor.B = tmpcolor.B*255; | ||
4555 | // tex.FaceTextures[i].RGBA = tmpcolor; | ||
4556 | // } | ||
4557 | //} | ||
4558 | //tmpcolor = tex.DefaultTexture.RGBA; | ||
4559 | //tmpcolor.A = tmpcolor.A*255; | ||
4560 | //tmpcolor.R = tmpcolor.R*255; | ||
4561 | //tmpcolor.G = tmpcolor.G*255; | ||
4562 | //tmpcolor.B = tmpcolor.B*255; | ||
4563 | //tex.DefaultTexture.RGBA = tmpcolor; | ||
4564 | UpdateTextureEntry(tex.GetBytes()); | ||
4565 | } | ||
4566 | |||
4567 | /// <summary> | ||
4568 | /// Update the texture entry for this part. | 4542 | /// Update the texture entry for this part. |
4569 | /// </summary> | 4543 | /// </summary> |
4570 | /// <param name="textureEntry"></param> | 4544 | /// <param name="textureEntry"></param> |
4571 | public void UpdateTextureEntry(byte[] textureEntry) | 4545 | public void UpdateTextureEntry(byte[] textureEntry) |
4572 | { | 4546 | { |
4573 | m_shape.TextureEntry = textureEntry; | 4547 | Primitive.TextureEntry newTex = new Primitive.TextureEntry(textureEntry, 0, textureEntry.Length); |
4574 | TriggerScriptChangedEvent(Changed.TEXTURE); | 4548 | Primitive.TextureEntry oldTex = Shape.Textures; |
4575 | 4549 | ||
4550 | Changed changeFlags = 0; | ||
4551 | |||
4552 | for (int i = 0 ; i < GetNumberOfSides(); i++) | ||
4553 | { | ||
4554 | Primitive.TextureEntryFace newFace = newTex.DefaultTexture; | ||
4555 | Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture; | ||
4556 | |||
4557 | if (oldTex.FaceTextures[i] != null) | ||
4558 | oldFace = oldTex.FaceTextures[i]; | ||
4559 | if (newTex.FaceTextures[i] != null) | ||
4560 | newFace = newTex.FaceTextures[i]; | ||
4561 | |||
4562 | Color4 oldRGBA = oldFace.RGBA; | ||
4563 | Color4 newRGBA = newFace.RGBA; | ||
4564 | |||
4565 | if (oldRGBA.R != newRGBA.R || | ||
4566 | oldRGBA.G != newRGBA.G || | ||
4567 | oldRGBA.B != newRGBA.B || | ||
4568 | oldRGBA.A != newRGBA.A) | ||
4569 | changeFlags |= Changed.COLOR; | ||
4570 | |||
4571 | if (oldFace.TextureID != newFace.TextureID) | ||
4572 | changeFlags |= Changed.TEXTURE; | ||
4573 | |||
4574 | // Max change, skip the rest of testing | ||
4575 | if (changeFlags == (Changed.TEXTURE | Changed.COLOR)) | ||
4576 | break; | ||
4577 | } | ||
4578 | |||
4579 | m_shape.TextureEntry = textureEntry; | ||
4580 | if (changeFlags != 0) | ||
4581 | TriggerScriptChangedEvent(changeFlags); | ||
4582 | UpdateFlag = UpdateRequired.FULL; | ||
4576 | ParentGroup.HasGroupChanged = true; | 4583 | ParentGroup.HasGroupChanged = true; |
4584 | |||
4577 | //This is madness.. | 4585 | //This is madness.. |
4578 | //ParentGroup.ScheduleGroupForFullUpdate(); | 4586 | //ParentGroup.ScheduleGroupForFullUpdate(); |
4579 | //This is sparta | 4587 | //This is sparta |