From 711e6ca3f5b4dff11154f1db763cb1f766fb294c Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 14 Mar 2014 17:43:55 -0700 Subject: [PATCH 01/19] clean up casts and types to fix warnings in a cleaner way --- libraries/octree/src/OctreeSceneStats.cpp | 4 ++-- libraries/octree/src/OctreeSceneStats.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/octree/src/OctreeSceneStats.cpp b/libraries/octree/src/OctreeSceneStats.cpp index 5cf906d82d..a21ab60493 100644 --- a/libraries/octree/src/OctreeSceneStats.cpp +++ b/libraries/octree/src/OctreeSceneStats.cpp @@ -919,13 +919,13 @@ void OctreeSceneStats::trackIncomingOctreePacket(const QByteArray& packet, if (wantExtraDebugging) { qDebug() << "too many _missingSequenceNumbers:" << _missingSequenceNumbers.size(); } - foreach(unsigned int missingItem, _missingSequenceNumbers) { + foreach(uint16_t missingItem, _missingSequenceNumbers) { if (wantExtraDebugging) { qDebug() << "checking item:" << missingItem << "is it in need of pruning?"; qDebug() << "(_incomingLastSequence - MAX_MISSING_SEQUENCE_OLD_AGE):" << (_incomingLastSequence - MAX_MISSING_SEQUENCE_OLD_AGE); } - if (missingItem <= (unsigned int)std::max(0, (int)_incomingLastSequence - (int)MAX_MISSING_SEQUENCE_OLD_AGE)) { + if (missingItem <= std::max(0, _incomingLastSequence - MAX_MISSING_SEQUENCE_OLD_AGE)) { if (wantExtraDebugging) { qDebug() << "pruning really old missing sequence:" << missingItem; } diff --git a/libraries/octree/src/OctreeSceneStats.h b/libraries/octree/src/OctreeSceneStats.h index 2b39b3434c..866c5d0b85 100644 --- a/libraries/octree/src/OctreeSceneStats.h +++ b/libraries/octree/src/OctreeSceneStats.h @@ -269,7 +269,7 @@ private: unsigned int _incomingLate; /// out of order later than expected unsigned int _incomingReallyLate; /// out of order and later than MAX_MISSING_SEQUENCE_OLD_AGE late unsigned int _incomingPossibleDuplicate; /// out of order possibly a duplicate - QSet _missingSequenceNumbers; + QSet _missingSequenceNumbers; SimpleMovingAverage _incomingFlightTimeAverage; // features related items From c958ae8cfbdf4d502ad9e71630dd22783af83586 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 14 Mar 2014 17:47:19 -0700 Subject: [PATCH 02/19] fix LocalVoxelsOverlay types to match --- interface/src/ui/LocalVoxelsOverlay.cpp | 2 +- interface/src/ui/LocalVoxelsOverlay.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/LocalVoxelsOverlay.cpp b/interface/src/ui/LocalVoxelsOverlay.cpp index 9ad1428535..7eaf9ed5c5 100644 --- a/interface/src/ui/LocalVoxelsOverlay.cpp +++ b/interface/src/ui/LocalVoxelsOverlay.cpp @@ -41,7 +41,7 @@ void LocalVoxelsOverlay::update(float deltatime) { } _tree->lockForRead(); - if (_visible && _voxelCount != (int)_tree->getOctreeElementsCount()) { + if (_visible && _voxelCount != _tree->getOctreeElementsCount()) { _voxelCount = _tree->getOctreeElementsCount(); _voxelSystem->forceRedrawEntireTree(); } diff --git a/interface/src/ui/LocalVoxelsOverlay.h b/interface/src/ui/LocalVoxelsOverlay.h index c5582a54eb..2b3ba1f535 100644 --- a/interface/src/ui/LocalVoxelsOverlay.h +++ b/interface/src/ui/LocalVoxelsOverlay.h @@ -43,7 +43,7 @@ private: QString _treeName; StrongVoxelTreePointer _tree; // so that the tree doesn't get freed - int _voxelCount; + unsigned long _voxelCount; StrongVoxelSystemPointer _voxelSystem; }; From 0e7e337807e61290cc568bd80a0d20f885b184b6 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 14 Mar 2014 18:05:40 -0700 Subject: [PATCH 03/19] fixed uninitialized variable warning --- libraries/shared/src/ShapeCollider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/ShapeCollider.cpp b/libraries/shared/src/ShapeCollider.cpp index 7f36d948e8..e83e6842a9 100644 --- a/libraries/shared/src/ShapeCollider.cpp +++ b/libraries/shared/src/ShapeCollider.cpp @@ -313,7 +313,7 @@ bool capsuleCapsule(const CapsuleShape* capsuleA, const CapsuleShape* capsuleB, // Since there are only three comparisons to do we unroll the sort algorithm... // and use a fifth slot as temp during swap. - if (points[4] > points[2]) { + if (points[1] > points[2]) { points[4] = points[1]; points[1] = points[2]; points[2] = points[4]; From 2766860b52fec7f3ebf519f1ed15a7767e48714f Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 14 Mar 2014 18:11:22 -0700 Subject: [PATCH 04/19] fix some windows warnings in fsbinarystream.cpp --- interface/external/faceshift/src/fsbinarystream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/external/faceshift/src/fsbinarystream.cpp b/interface/external/faceshift/src/fsbinarystream.cpp index 0a2d41e4b3..96434afd9b 100644 --- a/interface/external/faceshift/src/fsbinarystream.cpp +++ b/interface/external/faceshift/src/fsbinarystream.cpp @@ -160,7 +160,7 @@ void fsBinaryStream::received(long int sz, const char *data) { new_end = m_end + sz; } - if (new_end > Size(m_buffer.size())) m_buffer.resize(1.5*new_end); + if (new_end > Size(m_buffer.size())) m_buffer.resize((new_end * 15 / 10)); // HIFI: to get 1.5 without warnings memcpy(&m_buffer[0] + m_end, data, sz); m_end += sz; @@ -172,7 +172,7 @@ static bool decodeInfo(fsTrackingData & _trackingData, const std::string &buffer success &= read_pod(_trackingData.m_timestamp, buffer, start); unsigned char tracking_successfull = 0; success &= read_pod( tracking_successfull, buffer, start ); - _trackingData.m_trackingSuccessful = bool(tracking_successfull); + _trackingData.m_trackingSuccessful = bool(tracking_successfull != 0); // HIFI: get rid of windows warning return success; } From c0ee3fa1f0bd1831cc8945a82d85568884bf5022 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 14 Mar 2014 18:14:54 -0700 Subject: [PATCH 05/19] fix unix warning --- libraries/shared/src/SharedUtil.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 70fac3efe4..e5aded2798 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -631,8 +631,7 @@ void debug::setDeadBeef(void* memoryVoid, int size) { } void debug::checkDeadBeef(void* memoryVoid, int size) { - unsigned char* memoryAt = (unsigned char*)memoryVoid; - assert(memcmp(memoryAt, DEADBEEF, std::min(size, DEADBEEF_SIZE)) != 0); + assert(memcmp((unsigned char*)memoryVoid, DEADBEEF, std::min(size, DEADBEEF_SIZE)) != 0); } // Safe version of glm::eulerAngles; uses the factorization method described in David Eberly's From c6f8d34ded2cc05966192a66eacf3dbfca723b0e Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 14 Mar 2014 18:16:38 -0700 Subject: [PATCH 06/19] fix unix warning --- libraries/shared/src/NodeList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/NodeList.cpp b/libraries/shared/src/NodeList.cpp index 263e29bc94..0cca9731b0 100644 --- a/libraries/shared/src/NodeList.cpp +++ b/libraries/shared/src/NodeList.cpp @@ -348,7 +348,7 @@ void NodeList::addSetOfNodeTypesToNodeInterestSet(const NodeSet& setOfNodeTypes) const uint32_t RFC_5389_MAGIC_COOKIE = 0x2112A442; const int NUM_BYTES_STUN_HEADER = 20; -const int NUM_STUN_REQUESTS_BEFORE_FALLBACK = 5; +const unsigned int NUM_STUN_REQUESTS_BEFORE_FALLBACK = 5; void NodeList::sendSTUNRequest() { const char STUN_SERVER_HOSTNAME[] = "stun.highfidelity.io"; From 1f775058717857b894df380076ca026d02bf3b37 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 14 Mar 2014 18:35:34 -0700 Subject: [PATCH 07/19] more unix warnings cleanup --- libraries/octree/src/Octree.cpp | 9 ++++----- libraries/octree/src/OctreePacketData.cpp | 2 +- libraries/octree/src/OctreePacketData.h | 14 +++++++------- libraries/octree/src/OctreeRenderer.cpp | 10 +++++----- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 4c8ed8c9f6..fc867ec698 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -807,13 +807,14 @@ int Octree::encodeTreeBitstream(OctreeElement* node, // write the octal code bool roomForOctalCode = false; // assume the worst - int codeLength; + int codeLength = 1; // assume root if (params.chopLevels) { unsigned char* newCode = chopOctalCode(node->getOctalCode(), params.chopLevels); roomForOctalCode = packetData->startSubTree(newCode); if (newCode) { delete newCode; + codeLength = numberOfThreeBitSectionsInCode(newCode); } else { codeLength = 1; } @@ -1559,14 +1560,13 @@ void Octree::copySubTreeIntoNewTree(OctreeElement* startNode, Octree* destinatio } static OctreePacketData packetData; - int bytesWritten = 0; while (!nodeBag.isEmpty()) { OctreeElement* subTree = nodeBag.extract(); packetData.reset(); // reset the packet between usage // ask our tree to write a bitsteam EncodeBitstreamParams params(INT_MAX, IGNORE_VIEW_FRUSTUM, WANT_COLOR, NO_EXISTS_BITS, chopLevels); - bytesWritten = encodeTreeBitstream(subTree, &packetData, nodeBag, params); + encodeTreeBitstream(subTree, &packetData, nodeBag, params); // ask destination tree to read the bitstream ReadBitstreamToTreeParams args(WANT_COLOR, NO_EXISTS_BITS); destinationTree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args); @@ -1595,7 +1595,6 @@ void Octree::copyFromTreeIntoSubTree(Octree* sourceTree, OctreeElement* destinat nodeBag.insert(sourceTree->_rootNode); static OctreePacketData packetData; - int bytesWritten = 0; while (!nodeBag.isEmpty()) { OctreeElement* subTree = nodeBag.extract(); @@ -1604,7 +1603,7 @@ void Octree::copyFromTreeIntoSubTree(Octree* sourceTree, OctreeElement* destinat // ask our tree to write a bitsteam EncodeBitstreamParams params(INT_MAX, IGNORE_VIEW_FRUSTUM, WANT_COLOR, NO_EXISTS_BITS); - bytesWritten = sourceTree->encodeTreeBitstream(subTree, &packetData, nodeBag, params); + sourceTree->encodeTreeBitstream(subTree, &packetData, nodeBag, params); // ask destination tree to read the bitstream bool wantImportProgress = true; diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index bb613f57c1..5123d0711a 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -23,7 +23,7 @@ OctreePacketData::OctreePacketData(bool enableCompression, int targetSize) { changeSettings(enableCompression, targetSize); // does reset... } -void OctreePacketData::changeSettings(bool enableCompression, int targetSize) { +void OctreePacketData::changeSettings(bool enableCompression, size_t targetSize) { _enableCompression = enableCompression; _targetSize = std::min(MAX_OCTREE_UNCOMRESSED_PACKET_SIZE, targetSize); reset(); diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index a71a3f893c..526cb7c65e 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -30,15 +30,15 @@ typedef uint16_t OCTREE_PACKET_INTERNAL_SECTION_SIZE; const int MAX_OCTREE_PACKET_SIZE = MAX_PACKET_SIZE; // this is overly conservative - sizeof(PacketType) is 8 bytes but a packed PacketType could be as small as one byte -const int OCTREE_PACKET_EXTRA_HEADERS_SIZE = sizeof(OCTREE_PACKET_FLAGS) +const size_t OCTREE_PACKET_EXTRA_HEADERS_SIZE = sizeof(OCTREE_PACKET_FLAGS) + sizeof(OCTREE_PACKET_SEQUENCE) + sizeof(OCTREE_PACKET_SENT_TIME); -const int MAX_OCTREE_PACKET_DATA_SIZE = MAX_PACKET_SIZE - (MAX_PACKET_HEADER_BYTES + OCTREE_PACKET_EXTRA_HEADERS_SIZE); +const size_t MAX_OCTREE_PACKET_DATA_SIZE = MAX_PACKET_SIZE - (MAX_PACKET_HEADER_BYTES + OCTREE_PACKET_EXTRA_HEADERS_SIZE); -const int MAX_OCTREE_UNCOMRESSED_PACKET_SIZE = MAX_OCTREE_PACKET_DATA_SIZE; +const size_t MAX_OCTREE_UNCOMRESSED_PACKET_SIZE = MAX_OCTREE_PACKET_DATA_SIZE; -const int MINIMUM_ATTEMPT_MORE_PACKING = sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE) + 40; -const int COMPRESS_PADDING = 15; +const size_t MINIMUM_ATTEMPT_MORE_PACKING = sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE) + 40; +const size_t COMPRESS_PADDING = 15; const int REASONABLE_NUMBER_OF_PACKING_ATTEMPTS = 5; const int PACKET_IS_COLOR_BIT = 0; @@ -69,7 +69,7 @@ public: ~OctreePacketData(); /// change compression and target size settings - void changeSettings(bool enableCompression = false, int targetSize = MAX_OCTREE_PACKET_DATA_SIZE); + void changeSettings(bool enableCompression = false, size_t targetSize = MAX_OCTREE_PACKET_DATA_SIZE); /// reset completely, all data is discarded void reset(); @@ -186,7 +186,7 @@ private: /// append a single byte, might fail if byte would cause packet to be too large bool append(unsigned char byte); - int _targetSize; + size_t _targetSize; bool _enableCompression; unsigned char _uncompressed[MAX_OCTREE_UNCOMRESSED_PACKET_SIZE]; diff --git a/libraries/octree/src/OctreeRenderer.cpp b/libraries/octree/src/OctreeRenderer.cpp index 8fdc2139af..1066e53845 100644 --- a/libraries/octree/src/OctreeRenderer.cpp +++ b/libraries/octree/src/OctreeRenderer.cpp @@ -57,9 +57,9 @@ void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const Shar bool showTimingDetails = false; // Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showTimingDetails, "OctreeRenderer::processDatagram()",showTimingDetails); - int packetLength = dataByteArray.size(); + size_t packetLength = dataByteArray.size(); PacketType command = packetTypeForPacket(dataByteArray); - int numBytesPacketHeader = numBytesForPacketHeader(dataByteArray); + size_t numBytesPacketHeader = numBytesForPacketHeader(dataByteArray); QUuid sourceUUID = uuidFromPacketHeader(dataByteArray); PacketType expectedType = getExpectedPacketType(); @@ -86,11 +86,11 @@ void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const Shar int flightTime = arrivedAt - sentAt + clockSkew; OCTREE_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0; - int dataBytes = packetLength - (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE); + size_t dataBytes = packetLength - (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE); if (extraDebugging) { qDebug("OctreeRenderer::processDatagram() ... Got Packet Section" - " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d", + " color:%s compressed:%s sequence: %u flight:%d usec size:%lu data:%lu", debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), sequence, flightTime, packetLength, dataBytes); } @@ -119,7 +119,7 @@ void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const Shar packetData.loadFinalizedContent(dataAt, sectionLength); if (extraDebugging) { qDebug("OctreeRenderer::processDatagram() ... Got Packet Section" - " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d" + " color:%s compressed:%s sequence: %u flight:%d usec size:%lu data:%lu" " subsection:%d sectionLength:%d uncompressed:%d", debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), sequence, flightTime, packetLength, dataBytes, subsection, sectionLength, From 0200ac9da868d624066b13440b9cb84ba550d364 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 14 Mar 2014 22:43:31 -0700 Subject: [PATCH 08/19] more unix warnings fixes --- interface/src/VoxelSystem.cpp | 14 +++++--------- interface/src/VoxelSystem.h | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index a8bdeb1114..6c4ed12e9e 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -243,7 +243,7 @@ VoxelSystem::~VoxelSystem() { // This is called by the main application thread on both the initialization of the application and when // the preferences dialog box is called/saved -void VoxelSystem::setMaxVoxels(int maxVoxels) { +void VoxelSystem::setMaxVoxels(unsigned long maxVoxels) { if (maxVoxels == _maxVoxels) { return; } @@ -550,7 +550,7 @@ int VoxelSystem::parseData(const QByteArray& packet) { int flightTime = arrivedAt - sentAt; OCTREE_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0; - int dataBytes = packet.size() - (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE); + size_t dataBytes = packet.size() - (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE); int subsection = 1; while (dataBytes > 0) { @@ -576,7 +576,7 @@ int VoxelSystem::parseData(const QByteArray& packet) { packetData.loadFinalizedContent(dataAt, sectionLength); if (Application::getInstance()->getLogger()->extraDebugging()) { qDebug("VoxelSystem::parseData() ... Got Packet Section" - " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%d" + " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%lu" " subsection:%d sectionLength:%d uncompressed:%d", debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), sequence, flightTime, packet.size(), dataBytes, subsection, sectionLength, @@ -919,13 +919,11 @@ void VoxelSystem::copyWrittenDataSegmentToReadArrays(glBufferIndex segmentStart, // Depending on if we're using per vertex normals, we will need more or less vertex points per voxel int vertexPointsPerVoxel = GLOBAL_NORMALS_VERTEX_POINTS_PER_VOXEL; - GLintptr segmentStartAt = segmentStart * vertexPointsPerVoxel * sizeof(GLfloat); GLsizeiptr segmentSizeBytes = segmentLength * vertexPointsPerVoxel * sizeof(GLfloat); GLfloat* readVerticesAt = _readVerticesArray + (segmentStart * vertexPointsPerVoxel); GLfloat* writeVerticesAt = _writeVerticesArray + (segmentStart * vertexPointsPerVoxel); memcpy(readVerticesAt, writeVerticesAt, segmentSizeBytes); - segmentStartAt = segmentStart * vertexPointsPerVoxel * sizeof(GLubyte); segmentSizeBytes = segmentLength * vertexPointsPerVoxel * sizeof(GLubyte); GLubyte* readColorsAt = _readColorsArray + (segmentStart * vertexPointsPerVoxel); GLubyte* writeColorsAt = _writeColorsArray + (segmentStart * vertexPointsPerVoxel); @@ -1958,10 +1956,8 @@ bool VoxelSystem::showAllSubTreeOperation(OctreeElement* element, void* extraDat // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not // consider that case. - ViewFrustum::location inLastCulledFrustum; - if (args->culledOnce && args->wantDeltaFrustums) { - inLastCulledFrustum = voxel->inFrustum(args->lastViewFrustum); + ViewFrustum::location inLastCulledFrustum = voxel->inFrustum(args->lastViewFrustum); // if this node is fully inside our last culled view frustum, then we don't need to recurse further if (inLastCulledFrustum == ViewFrustum::INSIDE) { @@ -2001,7 +1997,7 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData // If we've culled at least once, then we will use the status of this voxel in the last culled frustum to determine // how to proceed. If we've never culled, then we just consider all these voxels to be UNKNOWN so that we will not // consider that case. - ViewFrustum::location inLastCulledFrustum; + ViewFrustum::location inLastCulledFrustum = ViewFrustum::OUTSIDE; // assume outside, but should get reset to actual value if (args->culledOnce && args->wantDeltaFrustums) { inLastCulledFrustum = voxel->inFrustum(args->lastViewFrustum); diff --git a/interface/src/VoxelSystem.h b/interface/src/VoxelSystem.h index 49b47c6f25..bdc55450dd 100644 --- a/interface/src/VoxelSystem.h +++ b/interface/src/VoxelSystem.h @@ -67,7 +67,7 @@ public: ViewFrustum* getLastCulledViewFrustum() { return &_lastCulledViewFrustum; } - void setMaxVoxels(int maxVoxels); + void setMaxVoxels(unsigned long maxVoxels); long int getMaxVoxels() const { return _maxVoxels; } unsigned long getVoxelMemoryUsageRAM() const { return _memoryUsageRAM; } unsigned long getVoxelMemoryUsageVBO() const { return _memoryUsageVBO; } @@ -263,7 +263,7 @@ private: bool _usePrimitiveRenderer; ///< Flag primitive renderer for use PrimitiveRenderer* _renderer; ///< Voxel renderer - static const int _sNumOctantsPerHemiVoxel = 4; + static const unsigned int _sNumOctantsPerHemiVoxel = 4; static int _sCorrectedChildIndex[8]; static unsigned short _sSwizzledOcclusionBits[64]; ///< Swizzle value of bit pairs of the value of index static unsigned char _sOctantIndexToBitMask[8]; ///< Map octant index to partition mask From 61a905961e0116575cf4875eb2297d9a000533bc Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 14 Mar 2014 22:48:32 -0700 Subject: [PATCH 09/19] darnit I hate casts.. --- libraries/octree/src/OctreePacketData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index 5123d0711a..219d8612fc 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -369,7 +369,7 @@ bool OctreePacketData::compressContent() { QByteArray compressedData = qCompress(uncompressedData, uncompressedSize, MAX_COMPRESSION); - if (compressedData.size() < MAX_OCTREE_PACKET_DATA_SIZE) { + if (compressedData.size() < (int)MAX_OCTREE_PACKET_DATA_SIZE) { _compressedBytes = compressedData.size(); for (int i = 0; i < _compressedBytes; i++) { _compressed[i] = compressedData[i]; From 4a6cc99be672985d983ecba1e3b7c5fda98fe371 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Sat, 15 Mar 2014 21:30:45 -0700 Subject: [PATCH 10/19] slightly different approach to windows warning fix --- interface/external/faceshift/src/fsbinarystream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/external/faceshift/src/fsbinarystream.cpp b/interface/external/faceshift/src/fsbinarystream.cpp index 96434afd9b..85f3ac7e7f 100644 --- a/interface/external/faceshift/src/fsbinarystream.cpp +++ b/interface/external/faceshift/src/fsbinarystream.cpp @@ -160,7 +160,7 @@ void fsBinaryStream::received(long int sz, const char *data) { new_end = m_end + sz; } - if (new_end > Size(m_buffer.size())) m_buffer.resize((new_end * 15 / 10)); // HIFI: to get 1.5 without warnings + if (new_end > Size(m_buffer.size())) m_buffer.resize((int)(1.5f * (float)new_end)); // HIFI: to get 1.5 without warnings memcpy(&m_buffer[0] + m_end, data, sz); m_end += sz; From adb6ffe7c4eb8ea66cc57591bb086acda26bf490 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 15 Mar 2014 22:00:44 -0700 Subject: [PATCH 11/19] more warnings fixes --- animation-server/src/AnimationServer.cpp | 21 +++++++------------ assignment-client/src/audio/AudioMixer.cpp | 1 - .../src/octree/OctreeSendThread.cpp | 4 +--- interface/src/Util.cpp | 10 ++++----- libraries/voxels/src/VoxelTreeElement.cpp | 7 ++++--- 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/animation-server/src/AnimationServer.cpp b/animation-server/src/AnimationServer.cpp index b165590c30..1f0828ec17 100644 --- a/animation-server/src/AnimationServer.cpp +++ b/animation-server/src/AnimationServer.cpp @@ -40,13 +40,13 @@ bool waitForVoxelServer = true; const int ANIMATION_LISTEN_PORT = 40107; int ANIMATE_FPS = 60; double ANIMATE_FPS_IN_MILLISECONDS = 1000.0/ANIMATE_FPS; // determines FPS from our desired FPS -int ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000.0); // converts from milliseconds to usecs +quint64 ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000); // converts from milliseconds to usecs int PROCESSING_FPS = 60; double PROCESSING_FPS_IN_MILLISECONDS = 1000.0/PROCESSING_FPS; // determines FPS from our desired FPS int FUDGE_USECS = 650; // a little bit of fudge to actually do some processing -int PROCESSING_INTERVAL_USECS = (PROCESSING_FPS_IN_MILLISECONDS * 1000.0) - FUDGE_USECS; // converts from milliseconds to usecs +quint64 PROCESSING_INTERVAL_USECS = (PROCESSING_FPS_IN_MILLISECONDS * 1000) - FUDGE_USECS; // converts from milliseconds to usecs bool wantLocalDomain = false; @@ -611,9 +611,6 @@ void* animateVoxels(void* args) { } lastProcessTime = usecTimestampNow(); - int packetsStarting = 0; - int packetsEnding = 0; - // The while loop will be running at PROCESSING_FPS, but we only want to call these animation functions at // ANIMATE_FPS. So we check out last animate time and only call these if we've elapsed that time. quint64 now = usecTimestampNow(); @@ -627,8 +624,6 @@ void* animateVoxels(void* args) { animateLoopsPerAnimate++; lastAnimateTime = now; - packetsStarting = ::voxelEditPacketSender->packetsToSendCount(); - // some animations //sendVoxelBlinkMessage(); @@ -652,8 +647,6 @@ void* animateVoxels(void* args) { doBuildStreet(); } - packetsEnding = ::voxelEditPacketSender->packetsToSendCount(); - if (animationElapsed > ANIMATE_VOXELS_INTERVAL_USECS) { animationElapsed -= ANIMATE_VOXELS_INTERVAL_USECS; // credit ourselves one animation frame } else { @@ -670,9 +663,9 @@ void* animateVoxels(void* args) { processesPerAnimate++; } // dynamically sleep until we need to fire off the next set of voxels - quint64 usecToSleep = PROCESSING_INTERVAL_USECS - (usecTimestampNow() - lastProcessTime); - if (usecToSleep > PROCESSING_INTERVAL_USECS) { - usecToSleep = PROCESSING_INTERVAL_USECS; + quint64 usecToSleep = ::PROCESSING_INTERVAL_USECS - (usecTimestampNow() - lastProcessTime); + if (usecToSleep > ::PROCESSING_INTERVAL_USECS) { + usecToSleep = ::PROCESSING_INTERVAL_USECS; } if (usecToSleep > 0) { @@ -758,7 +751,7 @@ AnimationServer::AnimationServer(int &argc, char **argv) : } } printf("ANIMATE_FPS=%d\n",ANIMATE_FPS); - printf("ANIMATE_VOXELS_INTERVAL_USECS=%d\n",ANIMATE_VOXELS_INTERVAL_USECS); + printf("ANIMATE_VOXELS_INTERVAL_USECS=%llu\n",ANIMATE_VOXELS_INTERVAL_USECS); const char* processingFPSCommand = getCmdOption(argc, (const char**) argv, "--ProcessingFPS"); const char* processingIntervalCommand = getCmdOption(argc, (const char**) argv, "--ProcessingInterval"); @@ -774,7 +767,7 @@ AnimationServer::AnimationServer(int &argc, char **argv) : } } printf("PROCESSING_FPS=%d\n",PROCESSING_FPS); - printf("PROCESSING_INTERVAL_USECS=%d\n",PROCESSING_INTERVAL_USECS); + printf("PROCESSING_INTERVAL_USECS=%llu\n",PROCESSING_INTERVAL_USECS); nodeList->linkedDataCreateCallback = NULL; // do we need a callback? diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index 812acc8d70..4c745ef2eb 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -79,7 +79,6 @@ void AudioMixer::addBufferToMixForListeningNodeWithBuffer(PositionalAudioRingBuf if (bufferToAdd != listeningNodeBuffer) { // if the two buffer pointers do not match then these are different buffers - glm::vec3 listenerPosition = listeningNodeBuffer->getPosition(); glm::vec3 relativePosition = bufferToAdd->getPosition() - listeningNodeBuffer->getPosition(); glm::quat inverseOrientation = glm::inverse(listeningNodeBuffer->getOrientation()); diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index ef69771607..09ebb99298 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -54,15 +54,13 @@ bool OctreeSendThread::process() { nodeData = (OctreeQueryNode*) node->getLinkedData(); - int packetsSent = 0; - // Sometimes the node data has not yet been linked, in which case we can't really do anything if (nodeData) { bool viewFrustumChanged = nodeData->updateCurrentViewFrustum(); if (_myServer->wantsDebugSending() && _myServer->wantsVerboseDebug()) { printf("nodeData->updateCurrentViewFrustum() changed=%s\n", debug::valueOf(viewFrustumChanged)); } - packetsSent = packetDistributor(node, nodeData, viewFrustumChanged); + packetDistributor(node, nodeData, viewFrustumChanged); } } else { _nodeMissingCount++; diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 45b2c4a616..f54bfb9d00 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -535,7 +535,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("rand() stored in array usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("rand() stored in array usecs: %f, first result:%d", 1000.0f * elapsedMsecs / (float) numTests, iResults[0]); // Random number generation using randFloat() gettimeofday(&startTime, NULL); @@ -544,7 +544,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("randFloat() stored in array usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("randFloat() stored in array usecs: %f, first result: %f", 1000.0f * elapsedMsecs / (float) numTests, fResults[0]); // PowF function fTest = 1145323.2342f; @@ -567,8 +567,8 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("vector math usecs: %f [%f msecs total for %d tests]", - 1000.0f * elapsedMsecs / (float) numTests, elapsedMsecs, numTests); + qDebug("vector math usecs: %f [%f msecs total for %d tests], last result:%f", + 1000.0f * elapsedMsecs / (float) numTests, elapsedMsecs, numTests, distance); // Vec3 test glm::vec3 vecA(randVector()), vecB(randVector()); @@ -581,7 +581,7 @@ void runTimingTests() { } gettimeofday(&endTime, NULL); elapsedMsecs = diffclock(&startTime, &endTime); - qDebug("vec3 assign and dot() usecs: %f", 1000.0f * elapsedMsecs / (float) numTests); + qDebug("vec3 assign and dot() usecs: %f, last result:%f", 1000.0f * elapsedMsecs / (float) numTests, result); } float loadSetting(QSettings* settings, const char* name, float defaultValue) { diff --git a/libraries/voxels/src/VoxelTreeElement.cpp b/libraries/voxels/src/VoxelTreeElement.cpp index be6bd50e3d..debcfee987 100644 --- a/libraries/voxels/src/VoxelTreeElement.cpp +++ b/libraries/voxels/src/VoxelTreeElement.cpp @@ -178,13 +178,14 @@ void VoxelTreeElement::calculateAverageFromChildren() { bool VoxelTreeElement::collapseChildren() { // scan children, verify that they are ALL present and accounted for bool allChildrenMatch = true; // assume the best (ottimista) - int red,green,blue; + int red = 0; + int green = 0; + int blue = 0; for (int i = 0; i < NUMBER_OF_CHILDREN; i++) { VoxelTreeElement* childAt = getChildAtIndex(i); // if no child, child isn't a leaf, or child doesn't have a color if (!childAt || !childAt->isLeaf() || !childAt->isColored()) { - allChildrenMatch=false; - //qDebug("SADNESS child missing or not colored! i=%d\n",i); + allChildrenMatch = false; break; } else { if (i==0) { From 851764a7053c2501b9b03e4b5ce80043c5ddc7ab Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 15 Mar 2014 22:36:43 -0700 Subject: [PATCH 12/19] more warning fixes --- libraries/avatars/src/AvatarData.cpp | 2 +- libraries/avatars/src/HandData.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 518b10ddea..21de041343 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -288,7 +288,7 @@ int AvatarData::parseData(const QByteArray& packet) { // joint data int jointCount = *sourceBuffer++; _jointData.resize(jointCount); - unsigned char validity; + unsigned char validity = 0; // although always set below, this fixes a warning of potential uninitialized use int validityBit = 0; for (int i = 0; i < jointCount; i++) { if (validityBit == 0) { diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index 46dade6d64..15be4636a7 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -217,11 +217,12 @@ int HandData::decodeRemoteData(const QByteArray& dataByteArray) { palm.setActive(false); } - // One byte for error checking safety. - unsigned char requiredLength = (unsigned char)(sourceBuffer - startPosition); - unsigned char checkLength = *sourceBuffer++; - assert(checkLength == requiredLength); - + // One byte for error checking safety. Last byte contains the expected length (less itself) + // actualLength less expected byte = (sourceBuffer - startPosition) + // expectedLength less expected byte = (*sourceBuffer) + assert((unsigned char)(sourceBuffer - startPosition) == (unsigned char)(*sourceBuffer)); + sourceBuffer++; // skip the trailing byte which is expected length + return sourceBuffer - startPosition; } From 6f85cfdb2f153302948d53dbe4d826a9d118d57f Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 15 Mar 2014 23:00:03 -0700 Subject: [PATCH 13/19] more warnings fixes --- assignment-client/src/octree/OctreeQueryNode.h | 6 +++--- assignment-client/src/octree/OctreeSendThread.cpp | 2 +- libraries/octree/src/OctreePacketData.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/assignment-client/src/octree/OctreeQueryNode.h b/assignment-client/src/octree/OctreeQueryNode.h index 6d4dee300a..29fdea0da2 100644 --- a/assignment-client/src/octree/OctreeQueryNode.h +++ b/assignment-client/src/octree/OctreeQueryNode.h @@ -34,13 +34,13 @@ public: void writeToPacket(const unsigned char* buffer, int bytes); // writes to end of packet const unsigned char* getPacket() const { return _octreePacket; } - int getPacketLength() const { return (MAX_PACKET_SIZE - _octreePacketAvailableBytes); } + unsigned int getPacketLength() const { return (MAX_PACKET_SIZE - _octreePacketAvailableBytes); } bool isPacketWaiting() const { return _octreePacketWaiting; } bool packetIsDuplicate() const; bool shouldSuppressDuplicatePacket(); - int getAvailable() const { return _octreePacketAvailableBytes; } + unsigned int getAvailable() const { return _octreePacketAvailableBytes; } int getMaxSearchLevel() const { return _maxSearchLevel; } void resetMaxSearchLevel() { _maxSearchLevel = 1; } void incrementMaxSearchLevel() { _maxSearchLevel++; } @@ -92,7 +92,7 @@ private: bool _viewSent; unsigned char* _octreePacket; unsigned char* _octreePacketAt; - int _octreePacketAvailableBytes; + unsigned int _octreePacketAvailableBytes; bool _octreePacketWaiting; unsigned char* _lastOctreePacket; diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 09ebb99298..35e9869910 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -506,7 +506,7 @@ int OctreeSendThread::packetDistributor(const SharedNodePointer& node, OctreeQue } if (forceDebugging || (_myServer->wantsDebugSending() && _myServer->wantsVerboseDebug())) { - qDebug(">>>>>> calling writeToPacket() available=%d compressedSize=%d uncompressedSize=%d target=%d", + qDebug(">>>>>> calling writeToPacket() available=%d compressedSize=%d uncompressedSize=%d target=%lu", nodeData->getAvailable(), _packetData.getFinalizedSize(), _packetData.getUncompressedSize(), _packetData.getTargetSize()); } diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index 526cb7c65e..245f0668cd 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -168,7 +168,7 @@ public: bool isCompressed() const { return _enableCompression; } /// returns the target uncompressed size - int getTargetSize() const { return _targetSize; } + size_t getTargetSize() const { return _targetSize; } /// displays contents for debugging void debugContent(); From 08d89a4565b2632b1f18c4dec6da99dc1e65a6f0 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 15 Mar 2014 23:17:03 -0700 Subject: [PATCH 14/19] arg windows signedness warnings --- assignment-client/src/octree/OctreeQueryNode.cpp | 2 +- assignment-client/src/octree/OctreeQueryNode.h | 2 +- assignment-client/src/octree/OctreeSendThread.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assignment-client/src/octree/OctreeQueryNode.cpp b/assignment-client/src/octree/OctreeQueryNode.cpp index 8cb577d2f9..3d5fbefc1f 100644 --- a/assignment-client/src/octree/OctreeQueryNode.cpp +++ b/assignment-client/src/octree/OctreeQueryNode.cpp @@ -156,7 +156,7 @@ void OctreeQueryNode::resetOctreePacket(bool lastWasSurpressed) { _octreePacketWaiting = false; } -void OctreeQueryNode::writeToPacket(const unsigned char* buffer, int bytes) { +void OctreeQueryNode::writeToPacket(const unsigned char* buffer, unsigned int bytes) { // compressed packets include lead bytes which contain compressed size, this allows packing of // multiple compressed portions together if (_currentPacketIsCompressed) { diff --git a/assignment-client/src/octree/OctreeQueryNode.h b/assignment-client/src/octree/OctreeQueryNode.h index 29fdea0da2..2a976c6421 100644 --- a/assignment-client/src/octree/OctreeQueryNode.h +++ b/assignment-client/src/octree/OctreeQueryNode.h @@ -31,7 +31,7 @@ public: void resetOctreePacket(bool lastWasSurpressed = false); // resets octree packet to after "V" header - void writeToPacket(const unsigned char* buffer, 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; } unsigned int getPacketLength() const { return (MAX_PACKET_SIZE - _octreePacketAvailableBytes); } diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 35e9869910..0259c31374 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -492,7 +492,7 @@ int OctreeSendThread::packetDistributor(const SharedNodePointer& node, OctreeQue // if for some reason the finalized size is greater than our available size, then probably the "compressed" // form actually inflated beyond our padding, and in this case we will send the current packet, then // write to out new packet... - int writtenSize = _packetData.getFinalizedSize() + unsigned int writtenSize = _packetData.getFinalizedSize() + (nodeData->getCurrentPacketIsCompressed() ? sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE) : 0); From 5709a8893e56cabf5721c0a58aa45ec6668fc869 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 15 Mar 2014 23:19:16 -0700 Subject: [PATCH 15/19] more unix signedness warnings --- assignment-client/src/octree/OctreeQueryNode.h | 2 +- assignment-client/src/octree/OctreeSendThread.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/octree/OctreeQueryNode.h b/assignment-client/src/octree/OctreeQueryNode.h index 2a976c6421..e48b7aaff4 100644 --- a/assignment-client/src/octree/OctreeQueryNode.h +++ b/assignment-client/src/octree/OctreeQueryNode.h @@ -96,7 +96,7 @@ private: bool _octreePacketWaiting; unsigned char* _lastOctreePacket; - int _lastOctreePacketLength; + unsigned int _lastOctreePacketLength; int _duplicatePacketCount; quint64 _firstSuppressedPacket; diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 0259c31374..0c99e94c04 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -140,7 +140,7 @@ int OctreeSendThread::handlePacketSend(const SharedNodePointer& node, OctreeQuer if (nodeData->stats.isReadyToSend()) { // Send the stats message to the client unsigned char* statsMessage = nodeData->stats.getStatsMessage(); - int statsMessageLength = nodeData->stats.getStatsMessageLength(); + unsigned int statsMessageLength = nodeData->stats.getStatsMessageLength(); // If the size of the stats message and the voxel message will fit in a packet, then piggyback them if (nodeData->getPacketLength() + statsMessageLength < MAX_PACKET_SIZE) { From 7d7e1ff28ac0b47d71e38b46d8b62d59b46a6e0b Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 15 Mar 2014 23:37:52 -0700 Subject: [PATCH 16/19] one more crack at this signedness comparisons on unix --- assignment-client/src/octree/OctreeSendThread.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 0c99e94c04..498ddb9e2c 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -140,10 +140,11 @@ int OctreeSendThread::handlePacketSend(const SharedNodePointer& node, OctreeQuer if (nodeData->stats.isReadyToSend()) { // Send the stats message to the client unsigned char* statsMessage = nodeData->stats.getStatsMessage(); - unsigned int statsMessageLength = nodeData->stats.getStatsMessageLength(); + int statsMessageLength = nodeData->stats.getStatsMessageLength(); + int piggyBackSize = nodeData->getPacketLength() + statsMessageLength; // If the size of the stats message and the voxel message will fit in a packet, then piggyback them - if (nodeData->getPacketLength() + statsMessageLength < MAX_PACKET_SIZE) { + if (piggyBackSize < MAX_PACKET_SIZE) { // copy voxel message to back of stats message memcpy(statsMessage + statsMessageLength, nodeData->getPacket(), nodeData->getPacketLength()); From bd6b70ee32c6a88a03b82b4e081416688d9c4f4b Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sun, 16 Mar 2014 11:07:24 -0700 Subject: [PATCH 17/19] use unsigned int vs size_t, since that just seems more correct --- .../src/octree/OctreeSendThread.cpp | 2 +- interface/src/VoxelSystem.cpp | 4 ++-- libraries/octree/src/OctreePacketData.cpp | 2 +- libraries/octree/src/OctreePacketData.h | 16 ++++++++-------- libraries/octree/src/OctreeRenderer.cpp | 10 +++++----- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 498ddb9e2c..85839bc53f 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -507,7 +507,7 @@ int OctreeSendThread::packetDistributor(const SharedNodePointer& node, OctreeQue } if (forceDebugging || (_myServer->wantsDebugSending() && _myServer->wantsVerboseDebug())) { - qDebug(">>>>>> calling writeToPacket() available=%d compressedSize=%d uncompressedSize=%d target=%lu", + qDebug(">>>>>> calling writeToPacket() available=%d compressedSize=%d uncompressedSize=%d target=%u", nodeData->getAvailable(), _packetData.getFinalizedSize(), _packetData.getUncompressedSize(), _packetData.getTargetSize()); } diff --git a/interface/src/VoxelSystem.cpp b/interface/src/VoxelSystem.cpp index 6c4ed12e9e..4db5af3c04 100644 --- a/interface/src/VoxelSystem.cpp +++ b/interface/src/VoxelSystem.cpp @@ -550,7 +550,7 @@ int VoxelSystem::parseData(const QByteArray& packet) { int flightTime = arrivedAt - sentAt; OCTREE_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0; - size_t dataBytes = packet.size() - (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE); + unsigned int dataBytes = packet.size() - (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE); int subsection = 1; while (dataBytes > 0) { @@ -576,7 +576,7 @@ int VoxelSystem::parseData(const QByteArray& packet) { packetData.loadFinalizedContent(dataAt, sectionLength); if (Application::getInstance()->getLogger()->extraDebugging()) { qDebug("VoxelSystem::parseData() ... Got Packet Section" - " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%lu" + " color:%s compressed:%s sequence: %u flight:%d usec size:%d data:%u" " subsection:%d sectionLength:%d uncompressed:%d", debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), sequence, flightTime, packet.size(), dataBytes, subsection, sectionLength, diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index 219d8612fc..5bd4fdce49 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -23,7 +23,7 @@ OctreePacketData::OctreePacketData(bool enableCompression, int targetSize) { changeSettings(enableCompression, targetSize); // does reset... } -void OctreePacketData::changeSettings(bool enableCompression, size_t targetSize) { +void OctreePacketData::changeSettings(bool enableCompression, unsigned int targetSize) { _enableCompression = enableCompression; _targetSize = std::min(MAX_OCTREE_UNCOMRESSED_PACKET_SIZE, targetSize); reset(); diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index 245f0668cd..5d7a904a4c 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -30,15 +30,15 @@ typedef uint16_t OCTREE_PACKET_INTERNAL_SECTION_SIZE; const int MAX_OCTREE_PACKET_SIZE = MAX_PACKET_SIZE; // this is overly conservative - sizeof(PacketType) is 8 bytes but a packed PacketType could be as small as one byte -const size_t OCTREE_PACKET_EXTRA_HEADERS_SIZE = sizeof(OCTREE_PACKET_FLAGS) +const unsigned int OCTREE_PACKET_EXTRA_HEADERS_SIZE = sizeof(OCTREE_PACKET_FLAGS) + sizeof(OCTREE_PACKET_SEQUENCE) + sizeof(OCTREE_PACKET_SENT_TIME); -const size_t MAX_OCTREE_PACKET_DATA_SIZE = MAX_PACKET_SIZE - (MAX_PACKET_HEADER_BYTES + OCTREE_PACKET_EXTRA_HEADERS_SIZE); +const unsigned int MAX_OCTREE_PACKET_DATA_SIZE = MAX_PACKET_SIZE - (MAX_PACKET_HEADER_BYTES + OCTREE_PACKET_EXTRA_HEADERS_SIZE); -const size_t MAX_OCTREE_UNCOMRESSED_PACKET_SIZE = MAX_OCTREE_PACKET_DATA_SIZE; +const unsigned int MAX_OCTREE_UNCOMRESSED_PACKET_SIZE = MAX_OCTREE_PACKET_DATA_SIZE; -const size_t MINIMUM_ATTEMPT_MORE_PACKING = sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE) + 40; -const size_t COMPRESS_PADDING = 15; +const unsigned int MINIMUM_ATTEMPT_MORE_PACKING = sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE) + 40; +const unsigned int COMPRESS_PADDING = 15; const int REASONABLE_NUMBER_OF_PACKING_ATTEMPTS = 5; const int PACKET_IS_COLOR_BIT = 0; @@ -69,7 +69,7 @@ public: ~OctreePacketData(); /// change compression and target size settings - void changeSettings(bool enableCompression = false, size_t targetSize = MAX_OCTREE_PACKET_DATA_SIZE); + void changeSettings(bool enableCompression = false, unsigned int targetSize = MAX_OCTREE_PACKET_DATA_SIZE); /// reset completely, all data is discarded void reset(); @@ -168,7 +168,7 @@ public: bool isCompressed() const { return _enableCompression; } /// returns the target uncompressed size - size_t getTargetSize() const { return _targetSize; } + unsigned int getTargetSize() const { return _targetSize; } /// displays contents for debugging void debugContent(); @@ -186,7 +186,7 @@ private: /// append a single byte, might fail if byte would cause packet to be too large bool append(unsigned char byte); - size_t _targetSize; + unsigned int _targetSize; bool _enableCompression; unsigned char _uncompressed[MAX_OCTREE_UNCOMRESSED_PACKET_SIZE]; diff --git a/libraries/octree/src/OctreeRenderer.cpp b/libraries/octree/src/OctreeRenderer.cpp index 1066e53845..5d4543e3aa 100644 --- a/libraries/octree/src/OctreeRenderer.cpp +++ b/libraries/octree/src/OctreeRenderer.cpp @@ -57,9 +57,9 @@ void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const Shar bool showTimingDetails = false; // Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); PerformanceWarning warn(showTimingDetails, "OctreeRenderer::processDatagram()",showTimingDetails); - size_t packetLength = dataByteArray.size(); + unsigned int packetLength = dataByteArray.size(); PacketType command = packetTypeForPacket(dataByteArray); - size_t numBytesPacketHeader = numBytesForPacketHeader(dataByteArray); + unsigned int numBytesPacketHeader = numBytesForPacketHeader(dataByteArray); QUuid sourceUUID = uuidFromPacketHeader(dataByteArray); PacketType expectedType = getExpectedPacketType(); @@ -86,11 +86,11 @@ void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const Shar int flightTime = arrivedAt - sentAt + clockSkew; OCTREE_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0; - size_t dataBytes = packetLength - (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE); + unsigned int dataBytes = packetLength - (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE); if (extraDebugging) { qDebug("OctreeRenderer::processDatagram() ... Got Packet Section" - " color:%s compressed:%s sequence: %u flight:%d usec size:%lu data:%lu", + " color:%s compressed:%s sequence: %u flight:%d usec size:%u data:%u", debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), sequence, flightTime, packetLength, dataBytes); } @@ -119,7 +119,7 @@ void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const Shar packetData.loadFinalizedContent(dataAt, sectionLength); if (extraDebugging) { qDebug("OctreeRenderer::processDatagram() ... Got Packet Section" - " color:%s compressed:%s sequence: %u flight:%d usec size:%lu data:%lu" + " color:%s compressed:%s sequence: %u flight:%d usec size:%u data:%u" " subsection:%d sectionLength:%d uncompressed:%d", debug::valueOf(packetIsColored), debug::valueOf(packetIsCompressed), sequence, flightTime, packetLength, dataBytes, subsection, sectionLength, From f652df939966731edcce1c8bd88fea2c3016e82e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 17 Mar 2014 09:19:05 -0700 Subject: [PATCH 18/19] break on MTU size packets from domain-list, closes #2312 --- domain-server/src/DomainServer.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index a425052970..216d249858 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -423,17 +423,25 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif QDataStream broadcastDataStream(&broadcastPacket, QIODevice::Append); broadcastDataStream << node->getUUID(); + int numBroadcastPacketLeadBytes = broadcastDataStream.device()->pos(); + DomainServerNodeData* nodeData = reinterpret_cast(node->getLinkedData()); NodeList* nodeList = NodeList::getInstance(); + if (nodeInterestList.size() > 0) { // if the node has any interest types, send back those nodes as well foreach (const SharedNodePointer& otherNode, nodeList->getNodeHash()) { + + // reset our nodeByteArray and nodeDataStream + QByteArray nodeByteArray; + QDataStream nodeDataStream(&nodeByteArray, QIODevice::Append); + if (otherNode->getUUID() != node->getUUID() && nodeInterestList.contains(otherNode->getType())) { // don't send avatar nodes to other avatars, that will come from avatar mixer - broadcastDataStream << *otherNode.data(); + nodeDataStream << *otherNode.data(); // pack the secret that these two nodes will use to communicate with each other QUuid secretUUID = nodeData->getSessionSecretHash().value(otherNode->getUUID()); @@ -450,11 +458,26 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif } - broadcastDataStream << secretUUID; + nodeDataStream << secretUUID; + + if (broadcastPacket.size() + nodeByteArray.size() > MAX_PACKET_SIZE) { + // we need to break here and start a new packet + // so send the current one + + nodeList->writeDatagram(broadcastPacket, node, senderSockAddr); + + // reset the broadcastPacket structure + broadcastPacket.resize(numBroadcastPacketLeadBytes); + broadcastDataStream.device()->seek(numBroadcastPacketLeadBytes); + } + + // append the nodeByteArray to the current state of broadcastDataStream + broadcastPacket.append(nodeByteArray); } } } + // always write the last broadcastPacket nodeList->writeDatagram(broadcastPacket, node, senderSockAddr); } From 2478c995f201ca67a3bdd4965f48c3f351f6c041 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 17 Mar 2014 10:05:44 -0700 Subject: [PATCH 19/19] clarifications to BUILD to remove confusing instructions, closes #2327 --- BUILD.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/BUILD.md b/BUILD.md index 1bc5145704..e033916e08 100644 --- a/BUILD.md +++ b/BUILD.md @@ -104,9 +104,7 @@ We don't currently have a Windows installer, so before running Interface, you wi CMake will need to know where the headers and libraries for required external dependencies are. If you installed ZLIB using the installer, the FindZLIB cmake module will be able to find it. This isn't the case for the others. -You have the choice of setting a variable specific to each library, or having a folder using a defined structure that contains all of the libs. - -The recommended route is to place all of the dependencies in one place and set one ENV variable - HIFI_LIB_DIR. That ENV variable should point to a directory with the following structure: +The recommended route for CMake to find external dependencies is to place all of the dependencies in one folder and set one ENV variable - HIFI_LIB_DIR. That ENV variable should point to a directory with the following structure: root_lib_dir -> glm @@ -128,14 +126,6 @@ The recommended route is to place all of the dependencies in one place and set o For many of the external libraries where precompiled binaries are readily available you should be able to simply copy the extracted folder that you get from the download links provided at the top of the guide. Otherwise you may need to build from source and install the built product to this directory. The `root_lib_dir` in the above example can be wherever you choose on your system - as long as the environment variable HIFI_LIB_DIR is set to it. -Should you want to define a location for each library, these are the associated variables you will want to set: - -`GLM_ROOT_DIR, GLUT_ROOT_DIR, GLEW_ROOT_DIR` - -They can be set in your ENV or by passing them to the cmake command on the command line. (There is an example of this in the CMake section earlier in this guide.) - -Each of those designates the root directory that contains the sub-folders for each library. For example, if the GLEW_ROOT_DIR is `C:\libs\glew`, then we would expect to find an `include` folder and a `lib` folder inside `C:\libs\glew`. - *NOTE: Qt does not support 64-bit builds on Windows 7, so you must use the 32-bit version of libraries for interface.exe to run. The 32-bit version of the static library is the one linked by our CMake find modules* #### DLLs