From 342c9fb3a8783357ad65a5eda32a8c7893b0c7d5 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 19 Feb 2014 11:04:58 -0800 Subject: [PATCH 01/13] Fixing bad brace formatting. --- interface/src/avatar/Hand.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index efbdfa2438..00708c05d0 100644 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -125,8 +125,7 @@ void Hand::simulate(float deltaTime, bool isMine) { } } -void Hand::playSlaps(PalmData& palm, Avatar* avatar) -{ +void Hand::playSlaps(PalmData& palm, Avatar* avatar) { // Check for palm collisions glm::vec3 myPalmPosition = palm.getPosition(); float palmCollisionDistance = 0.1f; From caba4f9b9b36a9ad2c315f5633a795ff6719fa3f Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 20 Feb 2014 07:58:30 -0800 Subject: [PATCH 02/13] Fix for crash when CollisionList gets full. --- libraries/shared/src/CollisionInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/CollisionInfo.cpp b/libraries/shared/src/CollisionInfo.cpp index 5d74d591c6..f20ffe83e0 100644 --- a/libraries/shared/src/CollisionInfo.cpp +++ b/libraries/shared/src/CollisionInfo.cpp @@ -16,7 +16,7 @@ CollisionList::CollisionList(int maxSize) : CollisionInfo* CollisionList::getNewCollision() { // return pointer to existing CollisionInfo, or NULL of list is full - return (_size < _maxSize) ? &(_collisions[++_size]) : NULL; + return (_size < _maxSize) ? &(_collisions[_size++]) : NULL; } CollisionInfo* CollisionList::getCollision(int index) { From 5252f22d82f31a2c15605eb1165fd7f698f53b0f Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 4 Mar 2014 10:42:10 -0800 Subject: [PATCH 03/13] fix warning about signed/unsigned comparison --- libraries/avatars/src/HandData.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index e4bb187f28..0355a4c86b 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -178,7 +178,7 @@ int HandData::decodeRemoteData(const QByteArray& dataByteArray) { unsigned int numPalms = *sourceBuffer++; for (unsigned int handIndex = 0; handIndex < numPalms; ++handIndex) { - if (handIndex >= getNumPalms()) + if (handIndex >= (unsigned int)getNumPalms()) addNewPalm(); PalmData& palm = getPalms()[handIndex]; @@ -196,7 +196,7 @@ int HandData::decodeRemoteData(const QByteArray& dataByteArray) { palm.setSixenseID(handIndex); for (unsigned int fingerIndex = 0; fingerIndex < numFingers; ++fingerIndex) { - if (fingerIndex < palm.getNumFingers()) { + if (fingerIndex < (unsigned int)palm.getNumFingers()) { FingerData& finger = palm.getFingers()[fingerIndex]; glm::vec3 tipPosition; From 78b92516d9ec50b58bfab626c27fd7ffef0fa1aa Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 4 Mar 2014 10:43:49 -0800 Subject: [PATCH 04/13] fix warning about signed/unsigned comparison --- libraries/octree/src/AABox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/octree/src/AABox.cpp b/libraries/octree/src/AABox.cpp index 1313111765..97fd706c21 100644 --- a/libraries/octree/src/AABox.cpp +++ b/libraries/octree/src/AABox.cpp @@ -335,7 +335,7 @@ glm::vec3 AABox::getClosestPointOnFace(const glm::vec4& origin, const glm::vec4& secondAxisMaxPlane + thirdAxisMaxPlane + offset }; float minDistance = FLT_MAX; - for (int i = 0; i < sizeof(diagonals) / sizeof(diagonals[0]); i++) { + for (size_t i = 0; i < sizeof(diagonals) / sizeof(diagonals[0]); i++) { float divisor = glm::dot(direction, diagonals[i]); if (fabs(divisor) < EPSILON) { continue; // segment is parallel to diagonal plane From c8149f95a36a737dd7d3660126f50f07260a9184 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 4 Mar 2014 11:06:23 -0800 Subject: [PATCH 05/13] fix warning for unused variable (we forgot to use it) --- libraries/particles/src/ParticleCollisionSystem.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/particles/src/ParticleCollisionSystem.cpp b/libraries/particles/src/ParticleCollisionSystem.cpp index 2d272a8f1f..75125a396a 100644 --- a/libraries/particles/src/ParticleCollisionSystem.cpp +++ b/libraries/particles/src/ParticleCollisionSystem.cpp @@ -222,6 +222,7 @@ void ParticleCollisionSystem::updateCollisionWithAvatars(Particle* particle) { // while ramping it up to 1 when attenuationFactor = 0 damping = DAMPING + (1.f - attenuationFactor) * (1.f - DAMPING); } + collision->_damping = damping; } // HACK END From 1b2db1f7ab5cb129928808e6c1752ba27d305b34 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 4 Mar 2014 11:07:15 -0800 Subject: [PATCH 06/13] fix for warnings about signed/unsigned comparison --- libraries/octree/src/JurisdictionMap.cpp | 10 +++++----- libraries/octree/src/OctreeElement.cpp | 2 +- libraries/shared/src/OctalCode.cpp | 16 ++++++++-------- libraries/shared/src/OctalCode.h | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libraries/octree/src/JurisdictionMap.cpp b/libraries/octree/src/JurisdictionMap.cpp index 6dc5a22e73..0271c77012 100644 --- a/libraries/octree/src/JurisdictionMap.cpp +++ b/libraries/octree/src/JurisdictionMap.cpp @@ -50,7 +50,7 @@ void JurisdictionMap::copyContents(unsigned char* rootCodeIn, const std::vector< unsigned char* rootCode; std::vector endNodes; if (rootCodeIn) { - int bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(rootCodeIn)); + size_t bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(rootCodeIn)); rootCode = new unsigned char[bytes]; memcpy(rootCode, rootCodeIn, bytes); } else { @@ -60,7 +60,7 @@ void JurisdictionMap::copyContents(unsigned char* rootCodeIn, const std::vector< for (size_t i = 0; i < endNodesIn.size(); i++) { if (endNodesIn[i]) { - int bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(endNodesIn[i])); + size_t bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(endNodesIn[i])); unsigned char* endNodeCode = new unsigned char[bytes]; memcpy(endNodeCode, endNodesIn[i], bytes); endNodes.push_back(endNodeCode); @@ -133,7 +133,7 @@ void myDebugPrintOctalCode(const unsigned char* octalCode, bool withNewLine) { if (!octalCode) { printf("NULL"); } else { - for (int i = 0; i < bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode)); i++) { + for (size_t i = 0; i < bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode)); i++) { myDebugoutputBits(octalCode[i],false); } } @@ -293,7 +293,7 @@ int JurisdictionMap::packIntoMessage(unsigned char* destinationBuffer, int avail // add the root jurisdiction if (_rootOctalCode) { - int bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(_rootOctalCode)); + size_t bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(_rootOctalCode)); memcpy(destinationBuffer, &bytes, sizeof(bytes)); destinationBuffer += sizeof(bytes); memcpy(destinationBuffer, _rootOctalCode, bytes); @@ -306,7 +306,7 @@ int JurisdictionMap::packIntoMessage(unsigned char* destinationBuffer, int avail for (int i=0; i < endNodeCount; i++) { unsigned char* endNodeCode = _endNodes[i]; - int bytes = 0; + size_t bytes = 0; if (endNodeCode) { bytes = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(endNodeCode)); } diff --git a/libraries/octree/src/OctreeElement.cpp b/libraries/octree/src/OctreeElement.cpp index 67b96b4047..72ac5b14d6 100644 --- a/libraries/octree/src/OctreeElement.cpp +++ b/libraries/octree/src/OctreeElement.cpp @@ -44,7 +44,7 @@ void OctreeElement::init(unsigned char * octalCode) { _voxelNodeLeafCount++; // all nodes start as leaf nodes - int octalCodeLength = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode)); + size_t octalCodeLength = bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode)); if (octalCodeLength > sizeof(_octalCode)) { _octalCode.pointer = octalCode; _octcodePointer = true; diff --git a/libraries/shared/src/OctalCode.cpp b/libraries/shared/src/OctalCode.cpp index ff30dad47e..4edf7be1ed 100644 --- a/libraries/shared/src/OctalCode.cpp +++ b/libraries/shared/src/OctalCode.cpp @@ -35,7 +35,7 @@ void printOctalCode(const unsigned char* octalCode) { qDebug("NULL"); } else { QDebug continuedDebug = qDebug().nospace(); - for (int i = 0; i < bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode)); i++) { + for (size_t i = 0; i < bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode)); i++) { outputBits(octalCode[i], &continuedDebug); } } @@ -51,11 +51,11 @@ char sectionValue(const unsigned char* startByte, char startIndexInByte) { } } -int bytesRequiredForCodeLength(unsigned char threeBitCodes) { +size_t bytesRequiredForCodeLength(unsigned char threeBitCodes) { if (threeBitCodes == 0) { return 1; } else { - return 1 + (int)ceilf((threeBitCodes * 3) / 8.0f); + return 1 + ceilf((threeBitCodes * 3) / 8.0f); } } @@ -78,10 +78,10 @@ unsigned char* childOctalCode(const unsigned char* parentOctalCode, char childNu : 0; // get the number of bytes used by the parent octal code - int parentCodeBytes = bytesRequiredForCodeLength(parentCodeSections); + size_t parentCodeBytes = bytesRequiredForCodeLength(parentCodeSections); // child code will have one more section than the parent - int childCodeBytes = bytesRequiredForCodeLength(parentCodeSections + 1); + size_t childCodeBytes = bytesRequiredForCodeLength(parentCodeSections + 1); // create a new buffer to hold the new octal code unsigned char* newCode = new unsigned char[childCodeBytes]; @@ -175,8 +175,8 @@ OctalCodeComparison compareOctalCodes(const unsigned char* codeA, const unsigned OctalCodeComparison result = LESS_THAN; // assume it's shallower - int numberOfBytes = std::min(bytesRequiredForCodeLength(*codeA), bytesRequiredForCodeLength(*codeB)); - int compare = memcmp(codeA, codeB, numberOfBytes); + size_t numberOfBytes = std::min(bytesRequiredForCodeLength(*codeA), bytesRequiredForCodeLength(*codeB)); + size_t compare = memcmp(codeA, codeB, numberOfBytes); if (compare < 0) { result = LESS_THAN; @@ -367,7 +367,7 @@ QString octalCodeToHexString(const unsigned char* octalCode) { if (!octalCode) { output = "00"; } else { - for (int i = 0; i < bytesRequiredForCodeLength(*octalCode); i++) { + for (size_t i = 0; i < bytesRequiredForCodeLength(*octalCode); i++) { output.append(QString("%1").arg(octalCode[i], HEX_BYTE_SIZE, HEX_NUMBER_BASE, QChar('0')).toUpper()); } } diff --git a/libraries/shared/src/OctalCode.h b/libraries/shared/src/OctalCode.h index 36f3e74f63..c80aa82a2d 100644 --- a/libraries/shared/src/OctalCode.h +++ b/libraries/shared/src/OctalCode.h @@ -20,7 +20,7 @@ const int GREEN_INDEX = 1; const int BLUE_INDEX = 2; void printOctalCode(const unsigned char* octalCode); -int bytesRequiredForCodeLength(unsigned char threeBitCodes); +size_t bytesRequiredForCodeLength(unsigned char threeBitCodes); int branchIndexWithDescendant(const unsigned char* ancestorOctalCode, const unsigned char* descendantOctalCode); unsigned char* childOctalCode(const unsigned char* parentOctalCode, char childNumber); From 918cd39f5d1e78967d41f60128862b5b4cb6dad2 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 4 Mar 2014 11:18:58 -0800 Subject: [PATCH 07/13] adding warnings to linux build --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2560c6498f..135bfacb7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ IF (WIN32) include_directories(SYSTEM "externals/winsdk") add_definitions( -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS ) set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1 ") +ELSEIF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic") + #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") ENDIF(WIN32) set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_CMAKE_PREFIX_PATH} ) From 16a5af1a8ef184f40b0d617e48d9e595ed53a5d0 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 4 Mar 2014 11:53:08 -0800 Subject: [PATCH 08/13] fix warning about signed/unsigned comparison --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b21d660452..db5ba17578 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2161,7 +2161,7 @@ void Application::updateShadowMap() { rotation * (glm::mix(_viewFrustum.getNearBottomLeft(), _viewFrustum.getFarBottomLeft(), farScale) + translation), rotation * (glm::mix(_viewFrustum.getNearBottomRight(), _viewFrustum.getFarBottomRight(), farScale) + translation) }; glm::vec3 minima(FLT_MAX, FLT_MAX, FLT_MAX), maxima(-FLT_MAX, -FLT_MAX, -FLT_MAX); - for (int i = 0; i < sizeof(points) / sizeof(points[0]); i++) { + for (size_t i = 0; i < sizeof(points) / sizeof(points[0]); i++) { minima = glm::min(minima, points[i]); maxima = glm::max(maxima, points[i]); } From 2faaa5beefb84c636ed8000939af0b8f3375d9c4 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 4 Mar 2014 11:54:58 -0800 Subject: [PATCH 09/13] fix warnings about signed/unsigned comparison --- interface/src/BandwidthMeter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/BandwidthMeter.cpp b/interface/src/BandwidthMeter.cpp index d8081e186f..117d0b8ed1 100644 --- a/interface/src/BandwidthMeter.cpp +++ b/interface/src/BandwidthMeter.cpp @@ -129,7 +129,7 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { // Determine total float totalIn = 0.0f, totalOut = 0.0f; - for (int i = 0; i < N_CHANNELS; ++i) { + for (size_t i = 0; i < N_CHANNELS; ++i) { totalIn += inputStream(ChannelIndex(i)).getValue(); totalOut += outputStream(ChannelIndex(i)).getValue(); @@ -205,7 +205,7 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { // Render bars int xIn = 0, xOut = 0; - for (int i = 0; i < N_CHANNELS; ++i) { + for (size_t i = 0; i < N_CHANNELS; ++i) { ChannelIndex chIdx = ChannelIndex(i); int wIn = int(barWidth * inputStream(chIdx).getValue() * UNIT_SCALE / scaleMax); @@ -240,7 +240,7 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { // After rendering, indicate that no data has been sent/received since the last feed. // This way, the meters fall when not continuously fed. - for (int i = 0; i < N_CHANNELS; ++i) { + for (size_t i = 0; i < N_CHANNELS; ++i) { inputStream(ChannelIndex(i)).updateValue(0); outputStream(ChannelIndex(i)).updateValue(0); } From eec8affd84b962fd647638470589185f63bc92e5 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 4 Mar 2014 11:56:22 -0800 Subject: [PATCH 10/13] fix warning about unused variable --- interface/src/avatar/MyAvatar.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 51fcad20ae..5b208aac7d 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -103,9 +103,8 @@ void MyAvatar::update(float deltaTime) { // Update head mouse from faceshift if active Faceshift* faceshift = Application::getInstance()->getFaceshift(); if (faceshift->isActive()) { - glm::vec3 headVelocity = faceshift->getHeadAngularVelocity(); - // TODO? resurrect headMouse stuff? + //glm::vec3 headVelocity = faceshift->getHeadAngularVelocity(); //// sets how quickly head angular rotation moves the head mouse //const float HEADMOUSE_FACESHIFT_YAW_SCALE = 40.f; //const float HEADMOUSE_FACESHIFT_PITCH_SCALE = 30.f; From 0f586cc0fbae36400648842ebff00bc9af71cf9a Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 4 Mar 2014 12:03:48 -0800 Subject: [PATCH 11/13] fix warning about unused variable --- libraries/octree/src/Octree.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 05760ef675..7ff4c75622 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -224,10 +224,8 @@ int Octree::readNodeData(OctreeElement* destinationNode, const unsigned char* no } OctreeElement* childNodeAt = destinationNode->getChildAtIndex(i); - bool nodeWasDirty = false; bool nodeIsDirty = false; if (childNodeAt) { - nodeWasDirty = childNodeAt->isDirty(); bytesRead += childNodeAt->readElementDataFromBuffer(nodeData + bytesRead, bytesLeftToRead, args); childNodeAt->setSourceUUID(args.sourceUUID); From 455ef15754f613667d8fcf3a9178986125b59948 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 4 Mar 2014 12:05:00 -0800 Subject: [PATCH 12/13] fix warning about signed/unsigned comparison --- libraries/particles/src/ParticleTreeElement.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libraries/particles/src/ParticleTreeElement.cpp b/libraries/particles/src/ParticleTreeElement.cpp index 4930263d64..ee916dcf2f 100644 --- a/libraries/particles/src/ParticleTreeElement.cpp +++ b/libraries/particles/src/ParticleTreeElement.cpp @@ -234,7 +234,6 @@ void ParticleTreeElement::getParticles(const glm::vec3& searchPosition, float se uint16_t numberOfParticles = _particles->size(); for (uint16_t i = 0; i < numberOfParticles; i++) { const Particle* particle = &(*_particles)[i]; - glm::vec3 particlePosition = particle->getPosition(); float distance = glm::length(particle->getPosition() - searchPosition); if (distance < searchRadius + particle->getRadius()) { foundParticles.push_back(particle); @@ -294,15 +293,14 @@ int ParticleTreeElement::readElementDataFromBuffer(const unsigned char* data, in uint16_t numberOfParticles = 0; int expectedBytesPerParticle = Particle::expectedBytes(); - if (bytesLeftToRead >= sizeof(numberOfParticles)) { - + if (bytesLeftToRead >= (int)sizeof(numberOfParticles)) { // read our particles in.... numberOfParticles = *(uint16_t*)dataAt; dataAt += sizeof(numberOfParticles); - bytesLeftToRead -= sizeof(numberOfParticles); + bytesLeftToRead -= (int)sizeof(numberOfParticles); bytesRead += sizeof(numberOfParticles); - if (bytesLeftToRead >= (numberOfParticles * expectedBytesPerParticle)) { + if (bytesLeftToRead >= (int)(numberOfParticles * expectedBytesPerParticle)) { for (uint16_t i = 0; i < numberOfParticles; i++) { Particle tempParticle; int bytesForThisParticle = tempParticle.readParticleDataFromBuffer(dataAt, bytesLeftToRead, args); From 0b2c3997134fd54e76e781c68fd79702a3670153 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 6 Mar 2014 14:33:59 -0800 Subject: [PATCH 13/13] memcmp() returns a signed int! --- libraries/shared/src/OctalCode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/OctalCode.cpp b/libraries/shared/src/OctalCode.cpp index 4edf7be1ed..ba0a001fb9 100644 --- a/libraries/shared/src/OctalCode.cpp +++ b/libraries/shared/src/OctalCode.cpp @@ -176,7 +176,7 @@ OctalCodeComparison compareOctalCodes(const unsigned char* codeA, const unsigned OctalCodeComparison result = LESS_THAN; // assume it's shallower size_t numberOfBytes = std::min(bytesRequiredForCodeLength(*codeA), bytesRequiredForCodeLength(*codeB)); - size_t compare = memcmp(codeA, codeB, numberOfBytes); + int compare = memcmp(codeA, codeB, numberOfBytes); if (compare < 0) { result = LESS_THAN;