moved _sequenceNumber to OctreeSendThread

This commit is contained in:
wangyix 2014-05-23 09:47:08 -07:00
parent a0ed76a29f
commit 2dd78b36db
5 changed files with 26 additions and 16 deletions

View file

@ -38,7 +38,7 @@ OctreeQueryNode::OctreeQueryNode() :
_lastClientOctreeSizeScale(DEFAULT_OCTREE_SIZE_SCALE), _lastClientOctreeSizeScale(DEFAULT_OCTREE_SIZE_SCALE),
_lodChanged(false), _lodChanged(false),
_lodInitialized(false), _lodInitialized(false),
_sequenceNumber(0), //_sequenceNumber(0),
_lastRootTimestamp(0), _lastRootTimestamp(0),
_myPacketType(PacketTypeUnknown), _myPacketType(PacketTypeUnknown),
_isShuttingDown(false) _isShuttingDown(false)
@ -161,7 +161,8 @@ void OctreeQueryNode::init() {
resetOctreePacket(true); // don't bump sequence resetOctreePacket(true); // don't bump sequence
} }
void OctreeQueryNode::resetOctreePacket(bool lastWasSurpressed) {
void OctreeQueryNode::resetOctreePacket(OCTREE_PACKET_SEQUENCE sequenceNumber) {
// if shutting down, return immediately // if shutting down, return immediately
if (_isShuttingDown) { if (_isShuttingDown) {
return; return;
@ -197,14 +198,18 @@ void OctreeQueryNode::resetOctreePacket(bool lastWasSurpressed) {
_octreePacketAt += sizeof(OCTREE_PACKET_FLAGS); _octreePacketAt += sizeof(OCTREE_PACKET_FLAGS);
_octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_FLAGS); _octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_FLAGS);
// pack in sequence number // pack in sequence number
OCTREE_PACKET_SEQUENCE* sequenceAt = (OCTREE_PACKET_SEQUENCE*)_octreePacketAt; OCTREE_PACKET_SEQUENCE* sequenceAt = (OCTREE_PACKET_SEQUENCE*)_octreePacketAt;
*sequenceAt = _sequenceNumber; *sequenceAt = sequenceNumber;
_octreePacketAt += sizeof(OCTREE_PACKET_SEQUENCE); _octreePacketAt += sizeof(OCTREE_PACKET_SEQUENCE);
_octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_SEQUENCE); _octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_SEQUENCE);
/*
if (!(lastWasSurpressed || _lastOctreePacketLength == (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE))) { if (!(lastWasSurpressed || _lastOctreePacketLength == (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE))) {
qDebug() << "_sequenceNumber is now " << _sequenceNumber << " ***********************************************";
_sequenceNumber++; _sequenceNumber++;
} }*/
// pack in timestamp // pack in timestamp
OCTREE_PACKET_SENT_TIME now = usecTimestampNow(); OCTREE_PACKET_SENT_TIME now = usecTimestampNow();

View file

@ -35,11 +35,11 @@ public:
void init(); // called after creation to set up some virtual items void init(); // called after creation to set up some virtual items
virtual PacketType getMyPacketType() const = 0; virtual PacketType getMyPacketType() const = 0;
void resetOctreePacket(bool lastWasSurpressed = false); // resets octree packet to after "V" header void resetOctreePacket(OCTREE_PACKET_SEQUENCE sequenceNumber); // resets octree packet to after "V" header
void writeToPacket(const unsigned char* buffer, unsigned int bytes); // writes to end of packet void writeToPacket(const unsigned char* buffer, unsigned int bytes); // writes to end of packet
const unsigned char* getPacket() const { return _octreePacket; } const unsigned char* getPacket() const { return _octreePacket; }
unsigned int getPacketLength() const { return (MAX_PACKET_SIZE - _octreePacketAvailableBytes); } unsigned int getPacketLength() const { return (MAX_PACKET_SIZE - _octreePacketAvailableBytes); }
bool isPacketWaiting() const { return _octreePacketWaiting; } bool isPacketWaiting() const { return _octreePacketWaiting; }
@ -135,8 +135,9 @@ private:
float _lastClientOctreeSizeScale; float _lastClientOctreeSizeScale;
bool _lodChanged; bool _lodChanged;
bool _lodInitialized; bool _lodInitialized;
OCTREE_PACKET_SEQUENCE _sequenceNumber; //OCTREE_PACKET_SEQUENCE _sequenceNumber;
quint64 _lastRootTimestamp; quint64 _lastRootTimestamp;
PacketType _myPacketType; PacketType _myPacketType;

View file

@ -9,8 +9,6 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include <QMutexLocker>
#include <NodeList.h> #include <NodeList.h>
#include <PacketHeaders.h> #include <PacketHeaders.h>
#include <PerfStat.h> #include <PerfStat.h>
@ -30,7 +28,8 @@ OctreeSendThread::OctreeSendThread(const SharedAssignmentPointer& myAssignment,
_nodeUUID(node->getUUID()), _nodeUUID(node->getUUID()),
_packetData(), _packetData(),
_nodeMissingCount(0), _nodeMissingCount(0),
_isShuttingDown(false) _isShuttingDown(false),
_sequenceNumber(0)
{ {
QString safeServerName("Octree"); QString safeServerName("Octree");
if (_myServer) { if (_myServer) {
@ -129,7 +128,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
return 0; return 0;
} }
bool debug = _myServer->wantsDebugSending(); bool debug = _myServer->wantsDebugSending();
quint64 now = usecTimestampNow(); quint64 now = usecTimestampNow();
bool packetSent = false; // did we send a packet? bool packetSent = false; // did we send a packet?
@ -139,7 +138,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
// obscure the packet and not send it. This allows the callers and upper level logic to not need to know about // obscure the packet and not send it. This allows the callers and upper level logic to not need to know about
// this rate control savings. // this rate control savings.
if (nodeData->shouldSuppressDuplicatePacket()) { if (nodeData->shouldSuppressDuplicatePacket()) {
nodeData->resetOctreePacket(true); // we still need to reset it though! nodeData->resetOctreePacket(_sequenceNumber); // we still need to reset it though!
return packetsSent; // without sending... return packetsSent; // without sending...
} }
@ -244,7 +243,10 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
trueBytesSent += nodeData->getPacketLength(); trueBytesSent += nodeData->getPacketLength();
truePacketsSent++; truePacketsSent++;
packetsSent++; packetsSent++;
nodeData->resetOctreePacket();
_sequenceNumber++;
nodeData->resetOctreePacket(_sequenceNumber);
} }
return packetsSent; return packetsSent;
@ -284,7 +286,7 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
if (nodeData->isPacketWaiting()) { if (nodeData->isPacketWaiting()) {
packetsSentThisInterval += handlePacketSend(nodeData, trueBytesSent, truePacketsSent); packetsSentThisInterval += handlePacketSend(nodeData, trueBytesSent, truePacketsSent);
} else { } else {
nodeData->resetOctreePacket(); nodeData->resetOctreePacket(_sequenceNumber);
} }
int targetSize = MAX_OCTREE_PACKET_DATA_SIZE; int targetSize = MAX_OCTREE_PACKET_DATA_SIZE;
if (wantCompression) { if (wantCompression) {

View file

@ -55,6 +55,8 @@ private:
int _nodeMissingCount; int _nodeMissingCount;
bool _isShuttingDown; bool _isShuttingDown;
OCTREE_PACKET_SEQUENCE _sequenceNumber;
}; };
#endif // hifi_OctreeSendThread_h #endif // hifi_OctreeSendThread_h

View file

@ -11,7 +11,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
var alwaysLook = true; // if you want the mouse look to happen only when you click, change this to false var alwaysLook = false; // if you want the mouse look to happen only when you click, change this to false
var isMouseDown = false; var isMouseDown = false;
var lastX = 0; var lastX = 0;
var lastY = 0; var lastY = 0;