From 2dd78b36dbc578b02dda9aac47dca8acfe9efd98 Mon Sep 17 00:00:00 2001 From: wangyix Date: Fri, 23 May 2014 09:47:08 -0700 Subject: [PATCH] moved _sequenceNumber to OctreeSendThread --- assignment-client/src/octree/OctreeQueryNode.cpp | 13 +++++++++---- assignment-client/src/octree/OctreeQueryNode.h | 9 +++++---- .../src/octree/OctreeSendThread.cpp | 16 +++++++++------- assignment-client/src/octree/OctreeSendThread.h | 2 ++ examples/lookWithMouse.js | 2 +- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/assignment-client/src/octree/OctreeQueryNode.cpp b/assignment-client/src/octree/OctreeQueryNode.cpp index 10d30ad1ae..d630705f64 100644 --- a/assignment-client/src/octree/OctreeQueryNode.cpp +++ b/assignment-client/src/octree/OctreeQueryNode.cpp @@ -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) @@ -161,7 +161,8 @@ void OctreeQueryNode::init() { resetOctreePacket(true); // don't bump sequence } -void OctreeQueryNode::resetOctreePacket(bool lastWasSurpressed) { + +void OctreeQueryNode::resetOctreePacket(OCTREE_PACKET_SEQUENCE sequenceNumber) { // if shutting down, return immediately if (_isShuttingDown) { return; @@ -197,14 +198,18 @@ void OctreeQueryNode::resetOctreePacket(bool lastWasSurpressed) { _octreePacketAt += sizeof(OCTREE_PACKET_FLAGS); _octreePacketAvailableBytes -= sizeof(OCTREE_PACKET_FLAGS); + // 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++; - } + }*/ + // pack in timestamp OCTREE_PACKET_SENT_TIME now = usecTimestampNow(); diff --git a/assignment-client/src/octree/OctreeQueryNode.h b/assignment-client/src/octree/OctreeQueryNode.h index 7b42208f16..ce50617fd4 100644 --- a/assignment-client/src/octree/OctreeQueryNode.h +++ b/assignment-client/src/octree/OctreeQueryNode.h @@ -35,11 +35,11 @@ public: void init(); // called after creation to set up some virtual items 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 - const unsigned char* getPacket() const { return _octreePacket; } + const unsigned char* getPacket() const { return _octreePacket; } unsigned int getPacketLength() const { return (MAX_PACKET_SIZE - _octreePacketAvailableBytes); } bool isPacketWaiting() const { return _octreePacketWaiting; } @@ -135,8 +135,9 @@ private: float _lastClientOctreeSizeScale; bool _lodChanged; bool _lodInitialized; - - OCTREE_PACKET_SEQUENCE _sequenceNumber; + + //OCTREE_PACKET_SEQUENCE _sequenceNumber; + quint64 _lastRootTimestamp; PacketType _myPacketType; diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index d8a9f3d1ea..4a8948197a 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -9,8 +9,6 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include - #include #include #include @@ -30,7 +28,8 @@ OctreeSendThread::OctreeSendThread(const SharedAssignmentPointer& myAssignment, _nodeUUID(node->getUUID()), _packetData(), _nodeMissingCount(0), - _isShuttingDown(false) + _isShuttingDown(false), + _sequenceNumber(0) { QString safeServerName("Octree"); if (_myServer) { @@ -129,7 +128,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes return 0; } - bool debug = _myServer->wantsDebugSending(); + bool debug = _myServer->wantsDebugSending(); quint64 now = usecTimestampNow(); 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 // this rate control savings. 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... } @@ -244,7 +243,10 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes trueBytesSent += nodeData->getPacketLength(); truePacketsSent++; packetsSent++; - nodeData->resetOctreePacket(); + + _sequenceNumber++; + + nodeData->resetOctreePacket(_sequenceNumber); } return packetsSent; @@ -284,7 +286,7 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus if (nodeData->isPacketWaiting()) { packetsSentThisInterval += handlePacketSend(nodeData, trueBytesSent, truePacketsSent); } else { - nodeData->resetOctreePacket(); + nodeData->resetOctreePacket(_sequenceNumber); } int targetSize = MAX_OCTREE_PACKET_DATA_SIZE; if (wantCompression) { diff --git a/assignment-client/src/octree/OctreeSendThread.h b/assignment-client/src/octree/OctreeSendThread.h index d8eed27802..95e7e2226a 100644 --- a/assignment-client/src/octree/OctreeSendThread.h +++ b/assignment-client/src/octree/OctreeSendThread.h @@ -55,6 +55,8 @@ private: int _nodeMissingCount; bool _isShuttingDown; + + OCTREE_PACKET_SEQUENCE _sequenceNumber; }; #endif // hifi_OctreeSendThread_h diff --git a/examples/lookWithMouse.js b/examples/lookWithMouse.js index 256a3ea67c..2fe12cce24 100644 --- a/examples/lookWithMouse.js +++ b/examples/lookWithMouse.js @@ -11,7 +11,7 @@ // 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 lastX = 0; var lastY = 0;