diff --git a/OpenMetaverse/Helpers.cs b/OpenMetaverse/Helpers.cs index bc4188c4..74294126 100644 --- a/OpenMetaverse/Helpers.cs +++ b/OpenMetaverse/Helpers.cs @@ -591,6 +591,19 @@ namespace OpenMetaverse } } + /// + /// Converts a byte array to a string containing hexadecimal characters + /// + /// The byte array to convert to a string + /// The name of the field to prepend to each + /// line of the string + /// A string containing hexadecimal characters on multiple + /// lines. Each line is prepended with the field name + public static string FieldToHexString(byte[] bytes, string fieldName) + { + return FieldToHexString(bytes, bytes.Length, fieldName); + } + /// /// Converts a byte array to a string containing hexadecimal characters /// diff --git a/OpenMetaverse/Simulator.cs b/OpenMetaverse/Simulator.cs index aeb9bd2c..693b177f 100644 --- a/OpenMetaverse/Simulator.cs +++ b/OpenMetaverse/Simulator.cs @@ -841,7 +841,7 @@ namespace OpenMetaverse { packet = Packet.BuildPacket(buffer.Data, ref packetEnd, buffer.ZeroData); } - catch (MalformedDataException ex) + catch (MalformedDataException) { Logger.Log(String.Format("Malformed data, cannot parse packet:\n{0}", Helpers.FieldToHexString(buffer.Data, buffer.DataLength, null)), Helpers.LogLevel.Error); diff --git a/OpenMetaverse/TerrainManager.cs b/OpenMetaverse/TerrainManager.cs index 471c240f..ce1cbbb2 100644 --- a/OpenMetaverse/TerrainManager.cs +++ b/OpenMetaverse/TerrainManager.cs @@ -823,9 +823,10 @@ namespace OpenMetaverse if (x >= PATCHES_PER_EDGE || y >= PATCHES_PER_EDGE) { - Logger.Log("Invalid LayerData land packet, x = " + x + ", y = " + y + ", dc_offset = " + - header.DCOffset + ", range = " + header.Range + ", quant_wbits = " + header.QuantWBits + - ", patchids = " + header.PatchIDs + ", count = " + count, Helpers.LogLevel.Warning, Client); + Logger.Log(String.Format( + "Invalid LayerData land packet, x={0}, y={1}, dc_offset={2}, range={3}, quant_wbits={4}, patchids={5}, count={6}", + x, y, header.DCOffset, header.Range, header.QuantWBits, header.PatchIDs, count), + Helpers.LogLevel.Warning, Client); return; } diff --git a/OpenMetaverse/Types/Quaternion.cs b/OpenMetaverse/Types/Quaternion.cs index a7a537fc..57e26b1b 100644 --- a/OpenMetaverse/Types/Quaternion.cs +++ b/OpenMetaverse/Types/Quaternion.cs @@ -114,12 +114,12 @@ namespace OpenMetaverse public float Length() { - return (float)Math.Sqrt(W * W + X * X + Y * Y + Z * Z); + return (float)Math.Sqrt(X * X + Y * Y + Z * Z + W * W); } public float LengthSquared() { - return (W * W + X * X + Y * Y + Z * Z); + return (X * X + Y * Y + Z * Z + W * W); } /// @@ -315,6 +315,33 @@ namespace OpenMetaverse } } + /// + /// Conver this quaternion to an angle around an axis + /// + /// Unit vector describing the axis + /// Angle around the axis, in radians + public void GetAxisAngle(out Vector3 axis, out float angle) + { + axis = new Vector3(); + float scale = (float)Math.Sqrt(X * X + Y * Y + Z * Z); + + if (scale < Single.Epsilon || W > 1.0f || W < -1.0f) + { + angle = 0.0f; + axis.X = 0.0f; + axis.Y = 1.0f; + axis.Z = 0.0f; + } + else + { + angle = 2.0f * (float)Math.Acos(W); + float ooscale = 1f / scale; + axis.X = X * ooscale; + axis.Y = Y * ooscale; + axis.Z = Z * ooscale; + } + } + #endregion Public Methods #region Static Methods diff --git a/Programs/examples/TestClient/TestClient.cs b/Programs/examples/TestClient/TestClient.cs index af544fa8..c72418a9 100644 --- a/Programs/examples/TestClient/TestClient.cs +++ b/Programs/examples/TestClient/TestClient.cs @@ -29,8 +29,6 @@ namespace OpenMetaverse.TestClient private Vector3 left = new Vector3(0.9999f, 0, 0); private Vector3 up = new Vector3(0, 0, 0.9999f); private System.Timers.Timer updateTimer; - public Inventory InventoryStore; - public Inventory LibraryStore; /// /// diff --git a/bin/openjpeg-libsl.dll b/bin/openjpeg-libsl.dll deleted file mode 100644 index b3e89105..00000000 Binary files a/bin/openjpeg-libsl.dll and /dev/null differ