From b6fe83965ac3f7d760a11c3d99b512ce22c2cf96 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 2 Aug 2024 03:11:00 +1000 Subject: [PATCH] * Fixes a subtle bug with TextureEntryFace where the face bits is incorrect. This is because it only uses 32-bits, the official viewer uses 64-bits, and the overflow matters. * Adds a .Valid property to TextureEntryFace - sometimes it is not, and will throw exceptions if you actually try use anything in this class. At least have the ability to check first. --- LibreMetaverse/Primitives/TextureEntry.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/LibreMetaverse/Primitives/TextureEntry.cs b/LibreMetaverse/Primitives/TextureEntry.cs index 7f2605f5..5d34278b 100644 --- a/LibreMetaverse/Primitives/TextureEntry.cs +++ b/LibreMetaverse/Primitives/TextureEntry.cs @@ -212,6 +212,14 @@ namespace OpenMetaverse #region Properties + public bool Valid + { + get + { + return DefaultTexture != null; + } + } + /// internal byte material { @@ -721,18 +729,18 @@ namespace OpenMetaverse return; uint bitfieldSize = 0; - uint faceBits = 0; + UInt64 faceBits = 0; int i = pos; #region Texture DefaultTexture.TextureID = new UUID(data, i); i += 16; - + while (ReadFaceBitfield(data, ref i, ref faceBits, ref bitfieldSize)) { UUID tmpUUID = new UUID(data, i); i += 16; - + for (uint face = 0, bit = 1; face < bitfieldSize; face++, bit <<= 1) { if ((faceBits & bit) != 0) @@ -1198,7 +1206,7 @@ namespace OpenMetaverse array[i] = uint.MaxValue; } - private bool ReadFaceBitfield(byte[] data, ref int pos, ref uint faceBits, ref uint bitfieldSize) + private bool ReadFaceBitfield(byte[] data, ref int pos, ref UInt64 faceBits, ref uint bitfieldSize) { faceBits = 0; bitfieldSize = 0;