private void rquery(RQueue _queue, Vector3 point, Point p, int depth, float range, float sqrange) { if (p == null) { return; } var axis = depth % 3; var distOnAxis = point[axis] - points[p.mid].pos[axis]; if (distOnAxis > 0) { if (distOnAxis <= range) { rquery(_queue, point, p.smaller, depth + 1, range, sqrange); } rquery(_queue, point, p.larger, depth + 1, range, sqrange); } else { if (distOnAxis >= -range) { rquery(_queue, point, p.larger, depth + 1, range, sqrange); } rquery(_queue, point, p.smaller, depth + 1, range, sqrange); } var sqdist = sqDist(point, p.mid); if (sqdist <= sqrange) { _queue.enqueue(new PriorityPoint(p.mid, sqdist)); } }
public int[] rquery(RQueue _queue, Vector3 point, float range) { _queue.reset(); _queue.enqueue(new PriorityPoint(-1, float.PositiveInfinity)); rquery(_queue, point, _root, 0, range, range * range); return((from node in _queue.Reverse() where (node.ipos >= 0) select points[node.ipos].id).ToArray()); }
public RWS() { InitializeComponent(); rq = RQueue.getInstance(); Timer tEQ = new Timer(); tEQ.Elapsed += new ElapsedEventHandler(ExecQueue); tEQ.Interval = 30000; tEQ.Enabled = true; }
/// <summary> /// Resends the current reliable packet, used if a reliable packet acknowledgement /// does not come through fast enough to guarantee delivery of the packet. /// </summary> public void ResendReliablePacket() { ReliableEntry rcmd = null; RQueue.GetCurrentReliableCommand(out rcmd); //If the sequence number from the one stored in the first field //of the ACK is the same as the one in the queue, remove it. if (rcmd != null) { m_Parent.DebugDump("Found a reliable packet on the queue, resending."); m_Parent.SendData(RemoteEP.Address.ToString(), RemoteEP.Port, rcmd.CommandPacket); } }
public static int SetupMaterialWithRenderQueue(Material material, RQueue render) { switch ((RQueue)material.GetFloat("_Queue")) { case RQueue.High: return(5); case RQueue.Mid: return(0); case RQueue.Low: return(-5); } return(0); }
/// <summary> /// This function is called internally when a command has been parsed and is ready to be processed /// by the UDP engine and possibly the host application. /// </summary> /// <param name="cmd">Object containing data about the command to be processed.</param> public void ProcessCompletedCommand(Command cmd) { //Client sent login details if (!Authed) { if (cmd.OPCode == GenesisConsts.OPCODE_LOGINDETAILS) { m_Parent.ConnectionAuthing(this, cmd); return; } } //Remote host sent us a ping if (cmd.OPCode == GenesisConsts.OPCODE_PING) { if (Authed) { m_Parent.DebugDump("Received ping from " + this.RemoteEP.ToString()); UpdateTimeout(); if (!Server) //If this is not a connection to a server { SendUnreliableCommand(0, GenesisConsts.OPCODE_PING, null); } } return; } //Server sent acknowledgement of our connection if (cmd.OPCode == GenesisConsts.OPCODE_LOGINACK) { if (cmd.Fields[0] == "OK") { Authed = true; m_Parent.DebugDump("Authenticated with " + this.RemoteEP.ToString() + " OK. Connected!"); //Send the authenticated event to the third party application m_Parent.AuthenticatedWithConnection(this, true, ""); } else { m_Parent.DebugDump("Authentication to " + this.RemoteEP.ToString() + " Failed!"); //Send the not authed event m_Parent.AuthenticatedWithConnection(this, false, cmd.Fields[1]); //Disconnect the connection (but don't send a disconnection packet back) m_Parent.RemoveConnection(this, false, cmd.Fields[1]); } return; } //Remote host disconnected from us if (cmd.OPCode == GenesisConsts.OPCODE_DISCONNECT) { m_Parent.RemoveConnection(this, false, cmd.Fields[0]); return; } //Reliable packet acknowledgement if (cmd.OPCode == GenesisConsts.OPCODE_RELIABLEACK) { m_Parent.DebugDump("Received reliable ACK for packet " + cmd.Fields[0] + "."); //Get the current reliable command ReliableEntry rcmd = null; RQueue.GetCurrentReliableCommand(out rcmd); //If the sequence number from the one stored in the first field //of the ACK is the same as the one in the queue, remove it. if (rcmd != null) { try { if (rcmd.SequenceNum == Convert.ToUInt32(cmd.Fields[0])) { RQueue.NextReliableCommand(); ReliableEntry next_rel = null; RQueue.GetCurrentReliableCommand(out next_rel); if (next_rel != null) { m_Parent.DebugDump("Moving reliable packet queue - next packet is " + next_rel.SequenceNum.ToString()); //Send the next reliable packet m_Parent.SendData(RemoteEP.Address.ToString(), RemoteEP.Port, next_rel.CommandPacket); } else { m_Parent.DebugDump("Moving reliable packet queue - no more packets on reliable queue."); } } } catch (Exception e) { m_Parent.DebugDump("Exception: " + e.Message); } } } //Give unrecognised commands to the application if (Authed) { m_Parent.CommandReceived(this, cmd); } }