moved _sequenceNumber back to OctreeQueryNode

instead added incrementSequenceNumber() to OctreeQueryNode for
sendthread to use
This commit is contained in:
wangyix 2014-05-23 10:09:46 -07:00
parent a6d0384c3b
commit 87d927d447
4 changed files with 16 additions and 17 deletions

View file

@ -38,7 +38,7 @@ OctreeQueryNode::OctreeQueryNode() :
_lastClientOctreeSizeScale(DEFAULT_OCTREE_SIZE_SCALE),
_lodChanged(false),
_lodInitialized(false),
//_sequenceNumber(0),
_sequenceNumber(0),
_lastRootTimestamp(0),
_myPacketType(PacketTypeUnknown),
_isShuttingDown(false)
@ -158,11 +158,11 @@ bool OctreeQueryNode::shouldSuppressDuplicatePacket() {
void OctreeQueryNode::init() {
_myPacketType = getMyPacketType();
resetOctreePacket(true); // don't bump sequence
resetOctreePacket(); // don't bump sequence
}
void OctreeQueryNode::resetOctreePacket(OCTREE_PACKET_SEQUENCE sequenceNumber) {
void OctreeQueryNode::resetOctreePacket() {
// if shutting down, return immediately
if (_isShuttingDown) {
return;
@ -201,12 +201,11 @@ void OctreeQueryNode::resetOctreePacket(OCTREE_PACKET_SEQUENCE sequenceNumber) {
// pack in sequence number
OCTREE_PACKET_SEQUENCE* sequenceAt = (OCTREE_PACKET_SEQUENCE*)_octreePacketAt;
*sequenceAt = sequenceNumber;
*sequenceAt = _sequenceNumber;
_octreePacketAt += sizeof(OCTREE_PACKET_SEQUENCE);
_octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_SEQUENCE);
/*
if (!(lastWasSurpressed || _lastOctreePacketLength == (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE))) {
qDebug() << "_sequenceNumber is now " << _sequenceNumber << " ***********************************************";
_sequenceNumber++;
}*/
@ -370,3 +369,6 @@ void OctreeQueryNode::dumpOutOfView() {
}
}
void OctreeQueryNode::incrementSequenceNumber() {
_sequenceNumber++;
}

View file

@ -35,7 +35,7 @@ public:
void init(); // called after creation to set up some virtual items
virtual PacketType getMyPacketType() const = 0;
void resetOctreePacket(OCTREE_PACKET_SEQUENCE sequenceNumber); // resets octree packet to after "V" header
void resetOctreePacket(); // resets octree packet to after "V" header
void writeToPacket(const unsigned char* buffer, unsigned int bytes); // writes to end of packet
@ -99,6 +99,8 @@ public:
void nodeKilled();
void forceNodeShutdown();
bool isShuttingDown() const { return _isShuttingDown; }
void incrementSequenceNumber();
private slots:
void sendThreadFinished();
@ -136,7 +138,7 @@ private:
bool _lodChanged;
bool _lodInitialized;
//OCTREE_PACKET_SEQUENCE _sequenceNumber;
OCTREE_PACKET_SEQUENCE _sequenceNumber;
quint64 _lastRootTimestamp;

View file

@ -28,8 +28,7 @@ OctreeSendThread::OctreeSendThread(const SharedAssignmentPointer& myAssignment,
_nodeUUID(node->getUUID()),
_packetData(),
_nodeMissingCount(0),
_isShuttingDown(false),
_sequenceNumber(0)
_isShuttingDown(false)
{
QString safeServerName("Octree");
if (_myServer) {
@ -138,7 +137,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
// this rate control savings.
if (nodeData->shouldSuppressDuplicatePacket()) {
nodeData->resetOctreePacket(_sequenceNumber); // we still need to reset it though!
nodeData->resetOctreePacket(); // we still need to reset it though!
return packetsSent; // without sending...
}
@ -243,10 +242,8 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
trueBytesSent += nodeData->getPacketLength();
truePacketsSent++;
packetsSent++;
_sequenceNumber++;
nodeData->resetOctreePacket(_sequenceNumber);
nodeData->incrementSequenceNumber();
nodeData->resetOctreePacket();
}
return packetsSent;
@ -286,7 +283,7 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
if (nodeData->isPacketWaiting()) {
packetsSentThisInterval += handlePacketSend(nodeData, trueBytesSent, truePacketsSent);
} else {
nodeData->resetOctreePacket(_sequenceNumber);
nodeData->resetOctreePacket();
}
int targetSize = MAX_OCTREE_PACKET_DATA_SIZE;
if (wantCompression) {

View file

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