diff --git a/OpenMetaverse/Interfaces/INetworkManager.cs b/OpenMetaverse/Interfaces/INetworkManager.cs new file mode 100644 index 00000000..9efd87fb --- /dev/null +++ b/OpenMetaverse/Interfaces/INetworkManager.cs @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2008, openmetaverse.org + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the openmetaverse.org nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using OpenMetaverse.Packets; + +namespace OpenMetaverse +{ + public interface INetworkManager + { + event NetworkManager.LoginCallback OnLogin; + event NetworkManager.ConnectedCallback OnConnected; + event NetworkManager.DisconnectedCallback OnDisconnected; + + Simulator CurrentSim { get; } + uint CircuitCode { get; } + bool Connected { get; } + + void RegisterCallback(PacketType type, NetworkManager.PacketCallback callback); + void RegisterEventCallback(string capsEvent, Caps.EventQueueCallback callback); + void RegisterLoginResponseCallback(NetworkManager.LoginResponseCallback callback, string[] options); + + void SendPacket(Packet packet, Simulator sim); + void SendPacket(Packet packet); + + bool Login(LoginParams loginParams); + void Logout(); + } +} diff --git a/OpenMetaverse/InventoryNode.cs b/OpenMetaverse/InventoryNode.cs deleted file mode 100644 index 3eff410f..00000000 --- a/OpenMetaverse/InventoryNode.cs +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2007-2008, openmetaverse.org - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the openmetaverse.org nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenMetaverse -{ - public class InventoryNode - { - private InventoryBase data; - private InventoryNode parent; - private InventoryNodeDictionary nodes; - - /// - public InventoryBase Data - { - get { return data; } - set { data = value; } - } - - /// - public InventoryNode Parent - { - get { return parent; } - set { parent = value; } - } - - /// - public InventoryNodeDictionary Nodes - { - get - { - if (nodes == null) - nodes = new InventoryNodeDictionary(this); - - return nodes; - } - set { nodes = value; } - } - - /// - /// - /// - public InventoryNode() - { - } - - /// - /// - /// - /// - public InventoryNode(InventoryBase data) - { - this.data = data; - } - - public InventoryNode(InventoryBase data, InventoryNode parent) - { - this.data = data; - this.parent = parent; - - if (parent != null) - { - // Add this node to the collection of parent nodes - lock (parent.Nodes.SyncRoot) parent.Nodes.Add(data.UUID, this); - } - } - - /// - /// - /// - /// - public override string ToString() - { - if (this.Data == null) return "[Empty Node]"; - return this.Data.ToString(); - } - } -} diff --git a/OpenMetaverse/InventoryNodeDictionary.cs b/OpenMetaverse/InventoryNodeDictionary.cs deleted file mode 100644 index c7d4f9a8..00000000 --- a/OpenMetaverse/InventoryNodeDictionary.cs +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2007-2008, openmetaverse.org - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the openmetaverse.org nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenMetaverse -{ - public class InventoryNodeDictionary - { - protected Dictionary Dictionary = new Dictionary(); - protected InventoryNode parent; - protected object syncRoot = new object(); - - public InventoryNode Parent - { - get { return parent; } - set { parent = value; } - } - - public object SyncRoot { get { return syncRoot; } } - - public int Count { get { return Dictionary.Count; } } - - public InventoryNodeDictionary(InventoryNode parentNode) - { - parent = parentNode; - } - - public InventoryNode this[UUID key] - { - get { return (InventoryNode)this.Dictionary[key]; } - set - { - value.Parent = parent; - lock (syncRoot) this.Dictionary[key] = value; - } - } - - public ICollection Keys { get { return this.Dictionary.Keys; } } - public ICollection Values { get { return this.Dictionary.Values; } } - - public void Add(UUID key, InventoryNode value) - { - value.Parent = parent; - lock (syncRoot) this.Dictionary.Add(key, value); - } - - public void Remove(UUID key) - { - lock (syncRoot) this.Dictionary.Remove(key); - } - - public bool Contains(UUID key) - { - return this.Dictionary.ContainsKey(key); - } - } -} diff --git a/OpenMetaverse/Login.cs b/OpenMetaverse/Login.cs index 9c739ec9..2ef9f0ca 100644 --- a/OpenMetaverse/Login.cs +++ b/OpenMetaverse/Login.cs @@ -329,7 +329,7 @@ namespace OpenMetaverse } } - public partial class NetworkManager + public partial class NetworkManager : INetworkManager { #region Delegates diff --git a/OpenMetaverse/NetworkManager.cs b/OpenMetaverse/NetworkManager.cs index 6904314a..763da5b5 100644 --- a/OpenMetaverse/NetworkManager.cs +++ b/OpenMetaverse/NetworkManager.cs @@ -48,19 +48,9 @@ namespace OpenMetaverse /// outgoing traffic and deserializes incoming traffic, and provides /// instances of delegates for network-related events. /// - public partial class NetworkManager + public partial class NetworkManager : INetworkManager { - /// - /// Holds a simulator reference and a packet, these structs are put in - /// the packet inbox for decoding - /// - public struct IncomingPacket - { - /// Reference to the simulator that this packet came from - public Simulator Simulator; - /// The packet that needs to be processed - public Packet Packet; - } + #region Enums /// /// Explains why a simulator or the grid disconnected from us @@ -77,6 +67,26 @@ namespace OpenMetaverse SimShutdown } + #endregion Enums + + #region Structs + + /// + /// Holds a simulator reference and a packet, these structs are put in + /// the packet inbox for decoding + /// + public struct IncomingPacket + { + /// Reference to the simulator that this packet came from + public Simulator Simulator; + /// The packet that needs to be processed + public Packet Packet; + } + + #endregion Structs + + #region Delegates + /// /// Coupled with RegisterCallback(), this is triggered whenever a packet /// of a registered type is received @@ -135,6 +145,10 @@ namespace OpenMetaverse /// Simulator this event queue is tied to public delegate void EventQueueRunningCallback(Simulator simulator); + #endregion Delegates + + #region Events + /// /// Event raised when the client was able to connected successfully. /// @@ -175,21 +189,35 @@ namespace OpenMetaverse /// public event EventQueueRunningCallback OnEventQueueRunning; - /// Uniquely identifier associated with our connections to + #endregion Events + + #region Properties + + /// Unique identifier associated with our connections to /// simulators - public uint CircuitCode; + public uint CircuitCode + { + get { return _CircuitCode; } + set { _CircuitCode = value; } + } /// The simulator that the logged in avatar is currently /// occupying - public Simulator CurrentSim = null; + public Simulator CurrentSim + { + get { return _CurrentSim; } + set { _CurrentSim = value; } + } + /// Shows whether the network layer is logged in to the + /// grid or not + public bool Connected { get { return connected; } } + /// Number of packets in the incoming queue + public int InboxCount { get { return PacketInbox.Count; } } + + #endregion Properties + /// All of the simulators we are currently connected to public List Simulators = new List(); - /// - /// Shows whether the network layer is logged in to the grid or not - /// - public bool Connected { get { return connected; } } - public int InboxCount { get { return PacketInbox.Count; } } - /// Handlers for incoming capability events internal CapsEventDictionary CapsEvents; /// Handlers for incoming packets @@ -199,6 +227,8 @@ namespace OpenMetaverse private GridClient Client; private Timer DisconnectTimer; + private uint _CircuitCode; + private Simulator _CurrentSim = null; private bool connected = false; /// @@ -211,7 +241,7 @@ namespace OpenMetaverse PacketEvents = new PacketEventDictionary(client); CapsEvents = new CapsEventDictionary(client); - + // Register the internal callbacks RegisterCallback(PacketType.RegionHandshake, new PacketCallback(RegionHandshakeHandler)); RegisterCallback(PacketType.StartPingCheck, new PacketCallback(StartPingCheckHandler)); diff --git a/OpenMetaverse/ObjectPool.cs b/OpenMetaverse/ObjectPool.cs new file mode 100644 index 00000000..3cf1dd2d --- /dev/null +++ b/OpenMetaverse/ObjectPool.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Net; + +namespace OpenMetaverse +{ + // this class encapsulates a single packet that + // is either sent or received by a UDP socket + public class UDPPacketBuffer + { + /// Size of the byte array used to store raw packet data + public const int BUFFER_SIZE = 2048; + /// Size of the temporary buffer for zerodecoding and + /// zeroencoding this packet + public const int ZERO_BUFFER_SIZE = 4096; + /// Raw packet data buffer + public byte[] Data; + /// Temporary buffer used for zerodecoding and zeroencoding + /// this packet + public byte[] ZeroData; + /// Length of the data to transmit + public int DataLength; + /// EndPoint of the remote host + public EndPoint RemoteEndPoint; + + /// + /// Create an allocated UDP packet buffer for receiving a packet + /// + public UDPPacketBuffer() + { + Data = new byte[UDPPacketBuffer.BUFFER_SIZE]; + ZeroData = new byte[UDPPacketBuffer.ZERO_BUFFER_SIZE]; + // Will be modified later by BeginReceiveFrom() + RemoteEndPoint = (EndPoint)new IPEndPoint(Settings.BIND_ADDR, 0); + } + + /// + /// Create an allocated UDP packet buffer for sending a packet + /// + /// EndPoint of the remote host + public UDPPacketBuffer(IPEndPoint endPoint) + { + Data = new byte[UDPPacketBuffer.BUFFER_SIZE]; + ZeroData = new byte[UDPPacketBuffer.ZERO_BUFFER_SIZE]; + RemoteEndPoint = (EndPoint)endPoint; + } + + /// + /// Create an allocated UDP packet buffer for receiving a packet + /// + /// EndPoint of the remote host + /// True to allocate space for the raw packet + /// buffer, otherwise false + /// True to allocate space for zerodecoding + /// or zeroencoding, otherwise false + public UDPPacketBuffer(EndPoint endPoint, bool allocate, bool allocateZero) + { + if (allocate) Data = new byte[UDPPacketBuffer.BUFFER_SIZE]; + if (allocateZero) ZeroData = new byte[UDPPacketBuffer.ZERO_BUFFER_SIZE]; + RemoteEndPoint = endPoint; + } + } + + /// + /// Object pool for packet buffers. This is used to allocate memory for all + /// incoming and outgoing packets, and zerocoding buffers for those packets + /// + public class PacketBufferPool : ObjectPoolBase + { + private IPEndPoint EndPoint; + + /// + /// Initialize the object pool in client mode + /// + /// Server to connect to + /// + /// + public PacketBufferPool(IPEndPoint endPoint, int itemsPerSegment, int minSegments) + : base() + { + EndPoint = endPoint; + Initialize(itemsPerSegment, minSegments, true, 1000 * 60 * 5); + } + + /// + /// Initialize the object pool in server mode + /// + /// + /// + public PacketBufferPool(int itemsPerSegment, int minSegments) + : base() + { + EndPoint = null; + Initialize(itemsPerSegment, minSegments, true, 1000 * 60 * 5); + } + + /// + /// Returns a packet buffer with EndPoint set if the buffer is in + /// client mode, or with EndPoint set to null in server mode + /// + /// Initialized UDPPacketBuffer object + protected override UDPPacketBuffer GetObjectInstance() + { + if (EndPoint != null) + // Client mode + return new UDPPacketBuffer(EndPoint); + else + // Server mode + return new UDPPacketBuffer(); + } + } + + public static class Pool + { + public static PacketBufferPool PoolInstance; + + /// + /// Default constructor + /// + static Pool() + { + PoolInstance = new PacketBufferPool(new IPEndPoint(Settings.BIND_ADDR, 0), 16, 1); + } + + /// + /// Check a packet buffer out of the pool + /// + /// A packet buffer object + public static WrappedObject CheckOut() + { + return PoolInstance.CheckOut(); + } + } +} diff --git a/OpenMetaverse/ObjectPoolBase.cs b/OpenMetaverse/ObjectPoolBase.cs index 3a7399e0..ee6b6f85 100644 --- a/OpenMetaverse/ObjectPoolBase.cs +++ b/OpenMetaverse/ObjectPoolBase.cs @@ -226,6 +226,8 @@ namespace OpenMetaverse if (_disposed) throw new ObjectDisposedException("ObjectPoolBase"); + if (allowSegmentToBeCleanedUp) + Logger.Log("Creating new object pool segment", Helpers.LogLevel.Info); // This method is called inside a lock, so no interlocked stuff required. int segmentToAdd = _activeSegment; diff --git a/OpenMetaverse/Types.cs b/OpenMetaverse/Types.cs index 3befbbd8..98b4a238 100644 --- a/OpenMetaverse/Types.cs +++ b/OpenMetaverse/Types.cs @@ -2345,7 +2345,7 @@ namespace OpenMetaverse /// Converts this quaternion to a 3x3 row-major matrix /// /// A matrix representation of this quaternion - public Matrix3 ToMatrix() + public Matrix3 ToMatrix3() { // From the Matrix and Quaternion FAQ: http://www.j3d.org/matrix_faq/matrfaq_latest.html @@ -2379,12 +2379,68 @@ namespace OpenMetaverse return m; } + /// + /// Converts this quaternion to a 4x4 row-major matrix + /// + /// A matrix representation of this quaternion + public Matrix4 ToMatrix4() + { + // From the Matrix and Quaternion FAQ: http://www.j3d.org/matrix_faq/matrfaq_latest.html + + Matrix4 m; + float xx, xy, xz, xw, yy, yz, yw, zz, zw; + + xx = X * X; + xy = X * Y; + xz = X * Z; + xw = X * W; + + yy = Y * Y; + yz = Y * Z; + yw = Y * W; + + zz = Z * Z; + zw = Z * W; + + m.M11 = 1f - 2f * (yy + zz); + m.M12 = 2f * (xy + zw); + m.M13 = 2f * (xz - yw); + m.M14 = 0f; + + m.M21 = 2f * (xy - zw); + m.M22 = 1f - 2f * (xx + zz); + m.M23 = 2f * (yz + xw); + m.M24 = 0f; + + m.M31 = 2f * (xz + yw); + m.M32 = 2f * (yz - xw); + m.M33 = 1f - 2f * (xx + yy); + m.M34 = 0f; + + m.M41 = m.M42 = m.M43 = 0f; + m.M44 = 1f; + + return m; + } + + /// + /// Construct this quaternion from an axis angle + /// + /// Angle + /// X component of axis + /// Y component of axis + /// Z component of axis public void SetQuaternion(float angle, float x, float y, float z) { Vector3 vec = new Vector3(x, y, z); SetQuaternion(angle, vec); } + /// + /// Construct this quaternion from an axis angle + /// + /// Angle + /// Axis public void SetQuaternion(float angle, Vector3 vec) { vec = Vector3.Norm(vec); @@ -2636,7 +2692,7 @@ namespace OpenMetaverse public Matrix3(Quaternion q) { - this = q.ToMatrix(); + this = q.ToMatrix3(); } public Matrix3(float roll, float pitch, float yaw) @@ -3113,10 +3169,16 @@ namespace OpenMetaverse M44 = m44; } - //public Matrix4(Quaternion q) - //{ - // this = q.ToMatrix4(); - //} + public Matrix4(Quaternion q) + { + this = q.ToMatrix4(); + } + + public Matrix4(float roll, float pitch, float yaw) + { + M11 = M12 = M13 = M14 = M21 = M22 = M23 = M24 = M31 = M32 = M33 = M34 = M41 = M42 = M43 = M44 = 0f; + FromEulers(roll, pitch, yaw); + } public Matrix4(Matrix3 m) { @@ -3192,5 +3254,51 @@ namespace OpenMetaverse } #endregion Constructors + + #region Public Methods + + /// + /// Construct this matrix from euler rotation values + /// + /// X euler angle + /// Y euler angle + /// Z euler angle + public void FromEulers(float roll, float pitch, float yaw) + { + // From the Matrix and Quaternion FAQ: http://www.j3d.org/matrix_faq/matrfaq_latest.html + + float a, b, c, d, e, f; + float ad, bd; + + a = (float)Math.Cos(roll); + b = (float)Math.Sin(roll); + c = (float)Math.Cos(pitch); + d = (float)Math.Sin(pitch); + e = (float)Math.Cos(yaw); + f = (float)Math.Sin(yaw); + + ad = a * d; + bd = b * d; + + M11 = c * e; + M12 = -c * f; + M13 = d; + M14 = 0f; + + M21 = bd * e + a * f; + M22 = -bd * f + a * e; + M23 = -b * c; + M24 = 0f; + + M31 = -ad * e + b * f; + M32 = ad * f + b * e; + M33 = a * c; + M34 = 0f; + + M41 = M42 = M43 = 0f; + M44 = 1f; + } + + #endregion Public Methods } } diff --git a/OpenMetaverse/UDPBase.cs b/OpenMetaverse/UDPBase.cs index bb23e1f3..af69046c 100644 --- a/OpenMetaverse/UDPBase.cs +++ b/OpenMetaverse/UDPBase.cs @@ -32,90 +32,6 @@ using System.Threading; namespace OpenMetaverse { - // this class encapsulates a single packet that - // is either sent or received by a UDP socket - public class UDPPacketBuffer - { - // size of the buffer - public const int BUFFER_SIZE = 2048; - /// Size of the temporary buffer for zerodecoding and - /// zeroencoding this packet - public const int ZERO_BUFFER_SIZE = 4096; - // the buffer itself - public byte[] Data; - /// Temporary buffer used for zerodecoding and zeroencoding - /// this packet - public byte[] ZeroData; - // length of data to transmit - public int DataLength; - // the (IP)Endpoint of the remote host - // this will be filled in by the call to udpSocket.BeginReceiveFrom - public EndPoint RemoteEndPoint; - - /// - /// Create an allocated UDP packet buffer for receiving a packet - /// - public UDPPacketBuffer() - { - Data = new byte[UDPPacketBuffer.BUFFER_SIZE]; - ZeroData = new byte[UDPPacketBuffer.ZERO_BUFFER_SIZE]; - // Will be modified later by BeginReceiveFrom() - RemoteEndPoint = (EndPoint)new IPEndPoint(Settings.BIND_ADDR, 0); - } - - public UDPPacketBuffer(IPEndPoint endPoint, bool allocate) - { - if (allocate) Data = new byte[UDPPacketBuffer.BUFFER_SIZE]; - ZeroData = new byte[UDPPacketBuffer.ZERO_BUFFER_SIZE]; - RemoteEndPoint = (EndPoint)endPoint; - } - - public UDPPacketBuffer(EndPoint endPoint, bool allocate, bool allocateZero) - { - if (allocate) Data = new byte[UDPPacketBuffer.BUFFER_SIZE]; - if (allocateZero) ZeroData = new byte[UDPPacketBuffer.ZERO_BUFFER_SIZE]; - RemoteEndPoint = endPoint; - } - } - - public class PacketBufferPool : ObjectPoolBase - { - private IPEndPoint EndPoint; - - /// - /// Initialize the object pool in client mode - /// - /// Server to connect to - /// - /// - public PacketBufferPool(IPEndPoint endPoint, int itemsPerSegment, int minSegments) - : base() - { - EndPoint = endPoint; - Initialize(itemsPerSegment, minSegments, true, 1000 * 60 * 5); - } - - /// - /// Initialize the object pool in server mode - /// - /// - /// - public PacketBufferPool(int itemsPerSegment, int minSegments) - : base() - { - EndPoint = null; - Initialize(itemsPerSegment, minSegments, true, 1000 * 60 * 5); - } - - protected override UDPPacketBuffer GetObjectInstance() - { - if (EndPoint != null) - return new UDPPacketBuffer(EndPoint, true); - else - return new UDPPacketBuffer(); - } - } - /// /// /// @@ -132,8 +48,6 @@ namespace OpenMetaverse // the UDP socket private Socket udpSocket; - private PacketBufferPool _bufferPool; - // the ReaderWriterLock is used solely for the purposes of shutdown (Stop()). // since there are potentially many "reader" threads in the internal .NET IOCP // thread pool, this is a cheaper synchronization primitive than using @@ -152,7 +66,7 @@ namespace OpenMetaverse // which we use to ensure that the threads exit cleanly. Note that // we need this because the threads will potentially still need to process // data even after the socket is closed. - private volatile int rwOperationCount = 0; + private int rwOperationCount = 0; // the all important shutdownFlag. This is synchronized through the ReaderWriterLock. private volatile bool shutdownFlag = true; @@ -168,7 +82,6 @@ namespace OpenMetaverse public UDPBase(int port) { udpPort = port; - _bufferPool = new PacketBufferPool(new IPEndPoint(Settings.BIND_ADDR, udpPort), 64, 1); } /// @@ -179,7 +92,6 @@ namespace OpenMetaverse { remoteEndPoint = endPoint; udpPort = 0; - _bufferPool = new PacketBufferPool(endPoint, 64, 1); } /// @@ -278,21 +190,21 @@ namespace OpenMetaverse Interlocked.Increment(ref rwOperationCount); // allocate a packet buffer - WrappedObject buf = _bufferPool.CheckOut(); + WrappedObject wrappedBuffer = Pool.CheckOut(); //UDPPacketBuffer buf = new UDPPacketBuffer(); try { // kick off an async read udpSocket.BeginReceiveFrom( - buf.Instance.Data, + wrappedBuffer.Instance.Data, //buf.Data, 0, UDPPacketBuffer.BUFFER_SIZE, SocketFlags.None, - ref buf.Instance.RemoteEndPoint, + ref wrappedBuffer.Instance.RemoteEndPoint, new AsyncCallback(AsyncEndReceive), - buf); + wrappedBuffer); } catch (SocketException) { diff --git a/Programs/PrimWorkshop/frmPrimWorkshop.cs b/Programs/PrimWorkshop/frmPrimWorkshop.cs index 6a1183e9..c9b1b5d6 100644 --- a/Programs/PrimWorkshop/frmPrimWorkshop.cs +++ b/Programs/PrimWorkshop/frmPrimWorkshop.cs @@ -146,7 +146,7 @@ namespace PrimWorkshop // Using euler angles because I have no clue what I'm doing float roll, pitch, yaw; - Matrix3 rotation = prim.Rotation.ToMatrix(); + Matrix3 rotation = prim.Rotation.ToMatrix3(); rotation.GetEulerAngles(out roll, out pitch, out yaw); Gl.glRotatef(roll * 57.2957795f, 1f, 0f, 0f); diff --git a/Programs/examples/TestClient/Commands/DetectBotCommand.cs b/Programs/examples/TestClient/Commands/DetectBotCommand.cs deleted file mode 100644 index 1bc07188..00000000 --- a/Programs/examples/TestClient/Commands/DetectBotCommand.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using OpenMetaverse; -using OpenMetaverse.Packets; - -namespace OpenMetaverse.TestClient -{ - public class DetectBotCommand : Command - { - public DetectBotCommand(TestClient testClient) - { - Name = "detectbot"; - Description = "Runs in the background, reporting any potential bots"; - Category = CommandCategory.TestClient; - - testClient.Avatars.OnAvatarAppearance += new AvatarManager.AvatarAppearanceCallback(Avatars_OnAvatarAppearance); - } - - public override string Execute(string[] args, UUID fromAgentID) - { - return "This command is always running"; - } - - void Avatars_OnAvatarAppearance(UUID avatarID, bool isTrial, LLObject.TextureEntryFace defaultTexture, LLObject.TextureEntryFace[] faceTextures, System.Collections.Generic.List visualParams) - { - if (IsNullOrZero(faceTextures[(int)AppearanceManager.TextureIndex.EyesBaked]) && - IsNullOrZero(faceTextures[(int)AppearanceManager.TextureIndex.HeadBaked]) && - IsNullOrZero(faceTextures[(int)AppearanceManager.TextureIndex.LowerBaked]) && - IsNullOrZero(faceTextures[(int)AppearanceManager.TextureIndex.SkirtBaked]) && - IsNullOrZero(faceTextures[(int)AppearanceManager.TextureIndex.UpperBaked])) - { - Console.WriteLine("Avatar " + avatarID.ToString() + " may be a bot"); - } - } - - private bool IsNullOrZero(LLObject.TextureEntryFace face) - { - return (face == null || face.TextureID == UUID.Zero); - } - } -}