From 973479d1ac4e7f030f770a21512cdbbf6520489c Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 07:57:45 -0700 Subject: [PATCH 01/20] fix warning in ByteCountCoded<> --- libraries/shared/src/ByteCountCoding.h | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/libraries/shared/src/ByteCountCoding.h b/libraries/shared/src/ByteCountCoding.h index ada7e7a4cb..a05ec2be3b 100644 --- a/libraries/shared/src/ByteCountCoding.h +++ b/libraries/shared/src/ByteCountCoding.h @@ -59,23 +59,15 @@ template inline QByteArray& operator>>(QByteArray& in, ByteCountCode template inline QByteArray ByteCountCoded::encode() const { QByteArray output; - //qDebug() << "data="; - //outputBufferBits((const unsigned char*)&data, sizeof(data)); - - T totalBits = sizeof(data) * BITS_IN_BYTE; - //qDebug() << "totalBits=" << totalBits; - T valueBits = totalBits; + int totalBits = sizeof(data) * BITS_IN_BYTE; + int valueBits = totalBits; bool firstValueFound = false; T temp = data; T lastBitMask = (T)(1) << (totalBits - 1); - //qDebug() << "lastBitMask="; - //outputBufferBits((const unsigned char*)&lastBitMask, sizeof(lastBitMask)); - // determine the number of bits that the value takes - for (int bitAt = 0; bitAt < totalBits; bitAt++) { + for (size_t bitAt = 0; bitAt < totalBits; bitAt++) { T bitValue = (temp & lastBitMask) == lastBitMask; - //qDebug() << "bitValue[" << bitAt <<"]=" << bitValue; if (!firstValueFound) { if (bitValue == 0) { valueBits--; @@ -85,17 +77,12 @@ template inline QByteArray ByteCountCoded::encode() const { } temp = temp << 1; } - //qDebug() << "valueBits=" << valueBits; // calculate the number of total bytes, including our header // BITS_IN_BYTE-1 because we need to code the number of bytes in the header // + 1 because we always take at least 1 byte, even if number of bits is less than a bytes worth - int numberOfBytes = (valueBits / (BITS_IN_BYTE - 1)) + 1; - //qDebug() << "numberOfBytes=" << numberOfBytes; + size_t numberOfBytes = (valueBits / (BITS_IN_BYTE - 1)) + 1; - //int numberOfBits = numberOfBytes + valueBits; - //qDebug() << "numberOfBits=" << numberOfBits; - output.fill(0, numberOfBytes); // next pack the number of header bits in, the first N-1 to be set to 1, the last to be set to 0 From c5e02c4ec5c16dfc6dcd04fe40fea1a2d87fd1d1 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 07:58:49 -0700 Subject: [PATCH 02/20] removed unused lastAttemptedSubTree --- assignment-client/src/octree/OctreeSendThread.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 116a1dcc84..f905ae652f 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -394,8 +394,6 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus int extraPackingAttempts = 0; bool completedScene = false; - OctreeElement* lastAttemptedSubTree = NULL; - while (somethingToSend && packetsSentThisInterval < maxPacketsPerInterval && !nodeData->isShuttingDown()) { float lockWaitElapsedUsec = OctreeServer::SKIP_TIME; float encodeElapsedUsec = OctreeServer::SKIP_TIME; @@ -408,9 +406,6 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus if (!nodeData->elementBag.isEmpty()) { OctreeElement* subTree = nodeData->elementBag.extract(); - // TODO: look into breaking early if the same subtree keeps repeating for inclusion... - lastAttemptedSubTree = subTree; - /* TODO: Looking for a way to prevent locking and encoding a tree that is not // going to result in any packets being sent... // @@ -516,8 +511,6 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus packetsSentThisInterval += handlePacketSend(nodeData, trueBytesSent, truePacketsSent); } - lastAttemptedSubTree = NULL; // reset this - nodeData->writeToPacket(_packetData.getFinalizedData(), _packetData.getFinalizedSize()); extraPackingAttempts = 0; quint64 compressAndWriteEnd = usecTimestampNow(); From d10bd6857dc43e2b04af11e9c4b25d3539faa79b Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 08:02:38 -0700 Subject: [PATCH 03/20] add use of missingSet in release build to silence warning --- tests/networking/src/SequenceNumberStatsTests.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/networking/src/SequenceNumberStatsTests.cpp b/tests/networking/src/SequenceNumberStatsTests.cpp index ded67b1ab6..204c77eeb3 100644 --- a/tests/networking/src/SequenceNumberStatsTests.cpp +++ b/tests/networking/src/SequenceNumberStatsTests.cpp @@ -254,6 +254,9 @@ void SequenceNumberStatsTests::pruneTest() { const QSet& missingSet = stats.getMissingSet(); assert(missingSet.size() <= 1000); + if (missingSet.size() > 1000) { + qDebug() << "FAIL: missingSet larger than 1000."; + } for (int i = 0; i < 10; i++) { assert(missingSet.contains(highestSkipped2)); From 51b66bdee30ef3bad99117016029973c5f24d1ce Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 08:14:31 -0700 Subject: [PATCH 04/20] fixed warnings and converted several asserts to debug messages --- libraries/entities/src/EntityTree.cpp | 57 +++++++++++++++++++-------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 8cec19eddd..9a6e53b17a 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -79,7 +79,10 @@ void EntityTree::addEntityItem(EntityItem* entityItem) { // You should not call this on existing entities that are already part of the tree! Call updateEntity() EntityItemID entityID = entityItem->getEntityItemID(); EntityTreeElement* containingElement = getContainingElement(entityID); - assert(containingElement == NULL); // don't call addEntityItem() on existing entity items + if (containingElement) { + qDebug() << "UNEXPECTED!!!! don't call addEntityItem() on existing entity items. entityID=" << entityID; + return; + } // Recurse the tree and store the entity in the correct tree element AddEntityOperator theOperator(this, entityItem); @@ -95,14 +98,13 @@ bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProp // You should not call this on existing entities that are already part of the tree! Call updateEntity() EntityTreeElement* containingElement = getContainingElement(entityID); if (!containingElement) { - //assert(containingElement); // don't call updateEntity() on entity items that don't exist qDebug() << "UNEXPECTED!!!! EntityTree::updateEntity() entityID doesn't exist!!! entityID=" << entityID; return false; } EntityItem* existingEntity = containingElement->getEntityWithEntityItemID(entityID); if (!existingEntity) { - assert(existingEntity); // don't call updateEntity() on entity items that don't exist + qDebug() << "UNEXPECTED!!!! don't call updateEntity() on entity items that don't exist. entityID=" << entityID; return false; } @@ -118,8 +120,8 @@ bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProp containingElement = getContainingElement(entityID); if (!containingElement) { - qDebug() << "after updateEntity() we no longer have a containing element???"; - assert(containingElement); // don't call updateEntity() on entity items that don't exist + qDebug() << "UNEXPECTED!!!! after updateEntity() we no longer have a containing element??? entityID=" << entityID; + return false; } return true; @@ -127,19 +129,20 @@ bool EntityTree::updateEntity(const EntityItemID& entityID, const EntityItemProp EntityItem* EntityTree::addEntity(const EntityItemID& entityID, const EntityItemProperties& properties) { + EntityItem* result = NULL; + // NOTE: This method is used in the client and the server tree. In the client, it's possible to create EntityItems // that do not yet have known IDs. In the server tree however we don't want to have entities without known IDs. if (getIsServer() && !entityID.isKnownID) { - //assert(entityID.isKnownID); qDebug() << "UNEXPECTED!!! ----- EntityTree::addEntity()... (getIsSever() && !entityID.isKnownID)"; + return result; } - EntityItem* result = NULL; // You should not call this on existing entities that are already part of the tree! Call updateEntity() EntityTreeElement* containingElement = getContainingElement(entityID); if (containingElement) { - qDebug() << "UNEXPECTED!!! ----- EntityTree::addEntity()... entityID=" << entityID << "containingElement=" << containingElement; - assert(containingElement == NULL); // don't call addEntity() on existing entity items + qDebug() << "UNEXPECTED!!! ----- don't call addEntity() on existing entity items. entityID=" << entityID + << "containingElement=" << containingElement; return result; } @@ -239,9 +242,9 @@ void EntityTree::removeEntityFromSimulationLists(const EntityItemID& entityID) { /// based to known IDs. This means we don't have to recurse the tree to mark the changed path as dirty. void EntityTree::handleAddEntityResponse(const QByteArray& packet) { - //assert(getIsClient()); // we should only call this on client trees if (!getIsClient()) { qDebug() << "UNEXPECTED!!! EntityTree::handleAddEntityResponse() with !getIsClient() ***"; + return; } const unsigned char* dataAt = reinterpret_cast(packet.data()); @@ -430,8 +433,15 @@ EntityItem* EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) / } EntityItemID EntityTree::assignEntityID(const EntityItemID& entityItemID) { - assert(getIsServer()); // NOTE: this only operates on an server tree. - assert(!getContainingElement(entityItemID)); // NOTE: don't call this for existing entityIDs + if (!getIsServer()) { + qDebug() << "UNEXPECTED!!! assignEntityID should only be called on a server tree. entityItemID:" << entityItemID; + return entityItemID; + } + + if (getContainingElement(entityItemID)) { + qDebug() << "UNEXPECTED!!! don't call assignEntityID() for existing entityIDs. entityItemID:" << entityItemID; + return entityItemID; + } // The EntityItemID is responsible for assigning actual IDs and keeping track of them. return entityItemID.assignActualIDForToken(); @@ -440,7 +450,10 @@ EntityItemID EntityTree::assignEntityID(const EntityItemID& entityItemID) { int EntityTree::processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength, const unsigned char* editData, int maxLength, const SharedNodePointer& senderNode) { - assert(getIsServer()); // NOTE: this only operates on an server tree. + if (!getIsServer()) { + qDebug() << "UNEXPECTED!!! processEditPacketData() should only be called on a server tree."; + return 0; + } int processedBytes = 0; // we handle these types of "edit" packets @@ -969,9 +982,21 @@ EntityTreeElement* EntityTree::getContainingElement(const EntityItemID& entityIt // TODO: do we need to make this thread safe? Or is it acceptable as is void EntityTree::resetContainingElement(const EntityItemID& entityItemID, EntityTreeElement* element) { - assert(entityItemID.id != UNKNOWN_ENTITY_ID); - assert(entityItemID.creatorTokenID != UNKNOWN_ENTITY_TOKEN); - assert(element); + if (entityItemID.id == UNKNOWN_ENTITY_ID) { + //assert(entityItemID.id != UNKNOWN_ENTITY_ID); + qDebug() << "UNEXPECTED! resetContainingElement() called with UNKNOWN_ENTITY_ID. entityItemID:" << entityItemID; + return; + } + if (entityItemID.creatorTokenID == UNKNOWN_ENTITY_TOKEN) { + //assert(entityItemID.creatorTokenID != UNKNOWN_ENTITY_TOKEN); + qDebug() << "UNEXPECTED! resetContainingElement() called with UNKNOWN_ENTITY_TOKEN. entityItemID:" << entityItemID; + return; + } + if (!element) { + //assert(element); + qDebug() << "UNEXPECTED! resetContainingElement() called with NULL element. entityItemID:" << entityItemID; + return; + } // remove the old version with the creatorTokenID EntityItemID creatorTokenVersion; From 64479b067e501c98efa2aa8d691e03956513e230 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 08:21:23 -0700 Subject: [PATCH 05/20] fix more warnings, replace assert with debug message --- libraries/entities/src/EntityTypes.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/entities/src/EntityTypes.h b/libraries/entities/src/EntityTypes.h index f6e78275d3..8851b04b7e 100644 --- a/libraries/entities/src/EntityTypes.h +++ b/libraries/entities/src/EntityTypes.h @@ -64,7 +64,9 @@ private: // static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties); #define REGISTER_ENTITY_TYPE_WITH_FACTORY(x,y) static bool x##Registration = \ EntityTypes::registerEntityType(EntityTypes::x, #x, y); \ - assert(x##Registration); + if (!x##Registration) { \ + qDebug() << "UNEXPECTED: REGISTER_ENTITY_TYPE_WITH_FACTORY(" #x "," #y ") FAILED.!"; \ + } #endif // hifi_EntityTypes_h From e76ffb2ecbe18673e40f4c7483541fc6ca09f319 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 08:44:13 -0700 Subject: [PATCH 06/20] fixed another warning --- libraries/shared/src/ByteCountCoding.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/shared/src/ByteCountCoding.h b/libraries/shared/src/ByteCountCoding.h index a05ec2be3b..ddaa750e86 100644 --- a/libraries/shared/src/ByteCountCoding.h +++ b/libraries/shared/src/ByteCountCoding.h @@ -66,7 +66,7 @@ template inline QByteArray ByteCountCoded::encode() const { T lastBitMask = (T)(1) << (totalBits - 1); // determine the number of bits that the value takes - for (size_t bitAt = 0; bitAt < totalBits; bitAt++) { + for (int bitAt = 0; bitAt < totalBits; bitAt++) { T bitValue = (temp & lastBitMask) == lastBitMask; if (!firstValueFound) { if (bitValue == 0) { @@ -81,7 +81,7 @@ template inline QByteArray ByteCountCoded::encode() const { // calculate the number of total bytes, including our header // BITS_IN_BYTE-1 because we need to code the number of bytes in the header // + 1 because we always take at least 1 byte, even if number of bits is less than a bytes worth - size_t numberOfBytes = (valueBits / (BITS_IN_BYTE - 1)) + 1; + int numberOfBytes = (valueBits / (BITS_IN_BYTE - 1)) + 1; output.fill(0, numberOfBytes); From be8994f3a3bfafff5b92b7da24bb22737916353f Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 08:47:18 -0700 Subject: [PATCH 07/20] attempt to fix warning --- libraries/audio/src/AudioSourceNoise.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/audio/src/AudioSourceNoise.h b/libraries/audio/src/AudioSourceNoise.h index 26cb21a065..2262c695a9 100644 --- a/libraries/audio/src/AudioSourceNoise.h +++ b/libraries/audio/src/AudioSourceNoise.h @@ -48,7 +48,7 @@ public: _runningSum = 0; _index = 0; - _indexMask = (1 << _randomRows) - 1; + _indexMask = ((uint16_t)1 << _randomRows) - 1; _scale = 1.0f / ((_randomRows + 1) * (1 << (_randomBits - 1))); } From 4ae3360f838cd51ba96d40df69925040e42a0462 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 08:50:52 -0700 Subject: [PATCH 08/20] fix warning --- libraries/shared/src/PropertyFlags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/PropertyFlags.h b/libraries/shared/src/PropertyFlags.h index 846c4886b0..04fe1475f7 100644 --- a/libraries/shared/src/PropertyFlags.h +++ b/libraries/shared/src/PropertyFlags.h @@ -419,7 +419,7 @@ template inline PropertyFlags PropertyFlags::operator } template inline void PropertyFlags::shinkIfNeeded() { - bool maxFlagWas = _maxFlag; + int maxFlagWas = _maxFlag; while (_maxFlag >= 0) { if (_flags.testBit(_maxFlag)) { break; From a6178a137ff31933078f831ce2195536aea88d40 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 09:00:18 -0700 Subject: [PATCH 09/20] fix windows warnings --- interface/src/devices/DdeFaceTracker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index aab3e1deb4..b5cf1c3bd6 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -172,8 +172,8 @@ float DdeFaceTracker::getBlendshapeCoefficient(int index) const { return (index >= 0 && index < (int)_blendshapeCoefficients.size()) ? _blendshapeCoefficients[index] : 0.0f; } -static const float DDE_MIN_RANGE = -0.2; -static const float DDE_MAX_RANGE = 1.5; +static const float DDE_MIN_RANGE = -0.2f; +static const float DDE_MAX_RANGE = 1.5f; float rescaleCoef(float ddeCoef) { return (ddeCoef - DDE_MIN_RANGE) / (DDE_MAX_RANGE - DDE_MIN_RANGE); } From a95e5487fc9eddc04bc42bfef78aff8879b706ba Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 09:00:47 -0700 Subject: [PATCH 10/20] fix type signed/unsigned warning --- interface/src/devices/CaraFaceTracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/devices/CaraFaceTracker.cpp b/interface/src/devices/CaraFaceTracker.cpp index 9f056fab9b..bc2c4bb2d1 100644 --- a/interface/src/devices/CaraFaceTracker.cpp +++ b/interface/src/devices/CaraFaceTracker.cpp @@ -309,7 +309,7 @@ void CaraFaceTracker::bindTo(const QHostAddress& host, quint16 port) { } bool CaraFaceTracker::isActive() const { - static const int ACTIVE_TIMEOUT_USECS = 3000000; //3 secs + static const quint64 ACTIVE_TIMEOUT_USECS = 3000000; //3 secs return (usecTimestampNow() - _lastReceiveTimestamp < ACTIVE_TIMEOUT_USECS); } From d6ebbd86330d42f7dbd8206bd094f76afb8d0ff8 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 09:01:27 -0700 Subject: [PATCH 11/20] fixed use of uninitialized variable warning --- interface/src/MetavoxelSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/MetavoxelSystem.cpp b/interface/src/MetavoxelSystem.cpp index 903e443cda..2b41b1f0c9 100644 --- a/interface/src/MetavoxelSystem.cpp +++ b/interface/src/MetavoxelSystem.cpp @@ -1743,7 +1743,7 @@ int VoxelAugmentVisitor::visit(MetavoxelInfo& info) { for (int z = 0; z < expanded; z++) { const QRgb* colorY = colorZ; for (int y = 0; y < expanded; y++) { - int lastIndex; + int lastIndex = 0; const QRgb* colorX = colorY; for (int x = 0; x < expanded; x++) { int alpha0 = colorX[0] >> ALPHA_OFFSET; From 9c34aed36d1ff7b683c3533fc376419aabdd8192 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 09:02:48 -0700 Subject: [PATCH 12/20] fix type signed/unsigned warning --- interface/src/devices/DdeFaceTracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index b5cf1c3bd6..b9f7e338ca 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -122,7 +122,7 @@ void DdeFaceTracker::bindTo(const QHostAddress& host, quint16 port) { } bool DdeFaceTracker::isActive() const { - static const int ACTIVE_TIMEOUT_USECS = 3000000; //3 secs + static const quint64 ACTIVE_TIMEOUT_USECS = 3000000; //3 secs return (usecTimestampNow() - _lastReceiveTimestamp < ACTIVE_TIMEOUT_USECS); } From 04772f6e5dc909a01e3d12470216efa8024be5b5 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 09:09:18 -0700 Subject: [PATCH 13/20] fix more signed/unsigned warnings --- libraries/audio/src/InboundAudioStream.cpp | 2 +- libraries/audio/src/InboundAudioStream.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/audio/src/InboundAudioStream.cpp b/libraries/audio/src/InboundAudioStream.cpp index e12dbb42a9..cc474ea491 100644 --- a/libraries/audio/src/InboundAudioStream.cpp +++ b/libraries/audio/src/InboundAudioStream.cpp @@ -377,7 +377,7 @@ void InboundAudioStream::packetReceivedUpdateTimingStats() { // update our timegap stats and desired jitter buffer frames if necessary // discard the first few packets we receive since they usually have gaps that aren't represensative of normal jitter - const int NUM_INITIAL_PACKETS_DISCARD = 3; + const quint32 NUM_INITIAL_PACKETS_DISCARD = 3; quint64 now = usecTimestampNow(); if (_incomingSequenceNumberStats.getReceived() > NUM_INITIAL_PACKETS_DISCARD) { quint64 gap = now - _lastPacketReceivedTime; diff --git a/libraries/audio/src/InboundAudioStream.h b/libraries/audio/src/InboundAudioStream.h index ca9591a746..a395b1c6c8 100644 --- a/libraries/audio/src/InboundAudioStream.h +++ b/libraries/audio/src/InboundAudioStream.h @@ -33,7 +33,7 @@ const int STATS_FOR_STATS_PACKET_WINDOW_SECONDS = 30; // this controls the window size of the time-weighted avg of frames available. Every time the window fills up, // _currentJitterBufferFrames is updated with the time-weighted avg and the running time-weighted avg is reset. -const int FRAMES_AVAILABLE_STAT_WINDOW_USECS = 10 * USECS_PER_SECOND; +const quint64 FRAMES_AVAILABLE_STAT_WINDOW_USECS = 10 * USECS_PER_SECOND; // default values for members of the Settings struct const int DEFAULT_MAX_FRAMES_OVER_DESIRED = 10; From 95a63cf1314a571e3bb81f876ee9aacb6f131e84 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 09:14:52 -0700 Subject: [PATCH 14/20] fix windows warning and change QByteArray initializer to match documented prototype --- interface/src/ui/MetavoxelEditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index cf839f6800..0f5c8dd048 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1022,7 +1022,7 @@ void ImportHeightfieldTool::apply() { QByteArray color; if (buffer->getColor().isEmpty()) { - const int WHITE_VALUE = 0xFF; + const char WHITE_VALUE = 0xFF; color = QByteArray(height.size() * DataBlock::COLOR_BYTES, WHITE_VALUE); } else { color = buffer->getUnextendedColor(); From d92d2d57a0bec3e438198371bdb1eaf961c43c01 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 09:28:28 -0700 Subject: [PATCH 15/20] one more shot at these warnings --- interface/src/ui/MetavoxelEditor.cpp | 2 +- libraries/audio/src/AudioSourceNoise.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 0f5c8dd048..64cf12373d 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1022,7 +1022,7 @@ void ImportHeightfieldTool::apply() { QByteArray color; if (buffer->getColor().isEmpty()) { - const char WHITE_VALUE = 0xFF; + const unsigned char WHITE_VALUE = 0xFF; color = QByteArray(height.size() * DataBlock::COLOR_BYTES, WHITE_VALUE); } else { color = buffer->getUnextendedColor(); diff --git a/libraries/audio/src/AudioSourceNoise.h b/libraries/audio/src/AudioSourceNoise.h index 2262c695a9..fb83ac26aa 100644 --- a/libraries/audio/src/AudioSourceNoise.h +++ b/libraries/audio/src/AudioSourceNoise.h @@ -48,7 +48,7 @@ public: _runningSum = 0; _index = 0; - _indexMask = ((uint16_t)1 << _randomRows) - 1; + _indexMask = ((uint16_t)1 << _randomRows) - (uint16_t)1; _scale = 1.0f / ((_randomRows + 1) * (1 << (_randomBits - 1))); } From ac27c36c3da4d64010d9e34feca2263afd492243 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 09:40:44 -0700 Subject: [PATCH 16/20] one more shot at these warnings --- libraries/audio/src/AudioSourceNoise.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/audio/src/AudioSourceNoise.h b/libraries/audio/src/AudioSourceNoise.h index fb83ac26aa..3e71703893 100644 --- a/libraries/audio/src/AudioSourceNoise.h +++ b/libraries/audio/src/AudioSourceNoise.h @@ -48,7 +48,7 @@ public: _runningSum = 0; _index = 0; - _indexMask = ((uint16_t)1 << _randomRows) - (uint16_t)1; + _indexMask = (uint16_t)((1 << _randomRows) - 1); _scale = 1.0f / ((_randomRows + 1) * (1 << (_randomBits - 1))); } From c32d5db75cc72172a9064eaedecb362670c7b6e1 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Sat, 13 Sep 2014 15:32:21 -0700 Subject: [PATCH 17/20] fix bug with attachments being stretched --- interface/src/renderer/Model.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 85e4e9c94f..51e1249bd9 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -894,7 +894,21 @@ void Model::setScaleToFit(bool scaleToFit, const glm::vec3& dimensions) { } void Model::setScaleToFit(bool scaleToFit, float largestDimension) { - setScaleToFit(scaleToFit, glm::vec3(largestDimension, largestDimension, largestDimension)); + if (_scaleToFit != scaleToFit || glm::length(_scaleToFitDimensions) != largestDimension) { + _scaleToFit = scaleToFit; + + // we only need to do this work if we're "turning on" scale to fit. + if (scaleToFit) { + Extents modelMeshExtents = getUnscaledMeshExtents(); + float maxDimension = glm::distance(modelMeshExtents.maximum, modelMeshExtents.minimum); + float maxScale = largestDimension / maxDimension; + glm::vec3 modelMeshDimensions = modelMeshExtents.maximum - modelMeshExtents.minimum; + glm::vec3 dimensions = modelMeshDimensions * maxScale; + + _scaleToFitDimensions = dimensions; + _scaledToFit = false; // force rescaling + } + } } void Model::scaleToFit() { From fd9f64cb44cf4c07cea3f5d82fa032df32263820 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 15 Sep 2014 08:41:18 -0700 Subject: [PATCH 18/20] normalize all quats before packing --- libraries/shared/src/GLMHelpers.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/shared/src/GLMHelpers.cpp b/libraries/shared/src/GLMHelpers.cpp index 566983679b..0c7f126893 100644 --- a/libraries/shared/src/GLMHelpers.cpp +++ b/libraries/shared/src/GLMHelpers.cpp @@ -86,12 +86,13 @@ int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destina } int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput) { + glm::quat quatNormalized = glm::normalize(quatInput); const float QUAT_PART_CONVERSION_RATIO = (std::numeric_limits::max() / 2.f); uint16_t quatParts[4]; - quatParts[0] = floorf((quatInput.x + 1.f) * QUAT_PART_CONVERSION_RATIO); - quatParts[1] = floorf((quatInput.y + 1.f) * QUAT_PART_CONVERSION_RATIO); - quatParts[2] = floorf((quatInput.z + 1.f) * QUAT_PART_CONVERSION_RATIO); - quatParts[3] = floorf((quatInput.w + 1.f) * QUAT_PART_CONVERSION_RATIO); + quatParts[0] = floorf((quatNormalized.x + 1.f) * QUAT_PART_CONVERSION_RATIO); + quatParts[1] = floorf((quatNormalized.y + 1.f) * QUAT_PART_CONVERSION_RATIO); + quatParts[2] = floorf((quatNormalized.z + 1.f) * QUAT_PART_CONVERSION_RATIO); + quatParts[3] = floorf((quatNormalized.w + 1.f) * QUAT_PART_CONVERSION_RATIO); memcpy(buffer, &quatParts, sizeof(quatParts)); return sizeof(quatParts); From 6e9da9747e61f1614aa957b7fe9726bd627a25cc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 15 Sep 2014 13:25:50 -0700 Subject: [PATCH 19/20] add a missing update of having heard from the audio-mixer --- interface/src/DatagramProcessor.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/interface/src/DatagramProcessor.cpp b/interface/src/DatagramProcessor.cpp index 62f5b6453a..aed93ffa1a 100644 --- a/interface/src/DatagramProcessor.cpp +++ b/interface/src/DatagramProcessor.cpp @@ -45,16 +45,29 @@ void DatagramProcessor::processDatagrams() { _byteCount += incomingPacket.size(); if (nodeList->packetVersionAndHashMatch(incomingPacket)) { + + PacketType incomingType = packetTypeForPacket(incomingPacket); // only process this packet if we have a match on the packet version - switch (packetTypeForPacket(incomingPacket)) { + switch (incomingType) { case PacketTypeMixedAudio: case PacketTypeSilentAudioFrame: - QMetaObject::invokeMethod(&application->_audio, "addReceivedAudioToStream", Qt::QueuedConnection, - Q_ARG(QByteArray, incomingPacket)); - break; case PacketTypeAudioStreamStats: - QMetaObject::invokeMethod(&application->_audio, "parseAudioStreamStatsPacket", Qt::QueuedConnection, - Q_ARG(QByteArray, incomingPacket)); + if (incomingType != PacketTypeAudioStreamStats) { + QMetaObject::invokeMethod(&application->_audio, "addReceivedAudioToStream", Qt::QueuedConnection, + Q_ARG(QByteArray, incomingPacket)); + } else { + QMetaObject::invokeMethod(&application->_audio, "parseAudioStreamStatsPacket", Qt::QueuedConnection, + Q_ARG(QByteArray, incomingPacket)); + } + + // update having heard from the audio-mixer and record the bytes received + SharedNodePointer audioMixer = nodeList->sendingNodeForPacket(incomingPacket); + + if (audioMixer) { + audioMixer->setLastHeardMicrostamp(usecTimestampNow()); + audioMixer->recordBytesReceived(incomingPacket.size()); + } + break; case PacketTypeParticleAddResponse: // this will keep creatorTokenIDs to IDs mapped correctly From 193c125d666a4bb3ed9081d90c930a338c67265b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 15 Sep 2014 13:29:13 -0700 Subject: [PATCH 20/20] fix scope for switch case --- interface/src/DatagramProcessor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/src/DatagramProcessor.cpp b/interface/src/DatagramProcessor.cpp index aed93ffa1a..0889007c76 100644 --- a/interface/src/DatagramProcessor.cpp +++ b/interface/src/DatagramProcessor.cpp @@ -51,7 +51,7 @@ void DatagramProcessor::processDatagrams() { switch (incomingType) { case PacketTypeMixedAudio: case PacketTypeSilentAudioFrame: - case PacketTypeAudioStreamStats: + case PacketTypeAudioStreamStats: { if (incomingType != PacketTypeAudioStreamStats) { QMetaObject::invokeMethod(&application->_audio, "addReceivedAudioToStream", Qt::QueuedConnection, Q_ARG(QByteArray, incomingPacket)); @@ -69,6 +69,7 @@ void DatagramProcessor::processDatagrams() { } break; + } case PacketTypeParticleAddResponse: // this will keep creatorTokenIDs to IDs mapped correctly Particle::handleAddParticleResponse(incomingPacket);