From 960e9eb2f4c976561acd4343f91cecf6a5bd9b34 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 19 Aug 2014 09:43:09 -0700 Subject: [PATCH] debugging tweaks --- libraries/entities/src/EntityItem.cpp | 2 +- libraries/entities/src/EntityTreeElement.cpp | 7 ++++- libraries/entities/src/EntityTypes.cpp | 4 +-- libraries/octree/src/Octree.cpp | 33 ++++++++++++-------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 809673e27f..a16677047d 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -421,7 +421,7 @@ int EntityItem::expectedBytes() { int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args) { - bool wantDebug = false; + bool wantDebug = true; if (args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU) { qDebug() << "EntityItem::readEntityDataFromBuffer()... ERROR CASE...args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU"; diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index ec4f6787fe..9b227f3fea 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -631,7 +631,7 @@ bool EntityTreeElement::removeEntityItem(const EntityItem* entity) { int EntityTreeElement::readElementDataFromBuffer(const unsigned char* data, int bytesLeftToRead, ReadBitstreamToTreeParams& args) { -bool wantDebug = false; +bool wantDebug = true; if (wantDebug) { qDebug() << "EntityTreeElement::readElementDataFromBuffer()"; qDebug() << " getAACube()=" << getAACube(); @@ -645,6 +645,11 @@ if (wantDebug) { "bitstreamVersion=" << (int)args.bitstreamVersion << " bytesLeftToRead=" << bytesLeftToRead; return 0; } + + if (this == _myTree->getRoot() && args.bitstreamVersion >= VERSION_ROOT_ELEMENT_HAS_DATA) { + qDebug() << "ROOT ELEMENT: -------- NOW READING ROOT DATA ---------"; + } + const unsigned char* dataAt = data; int bytesRead = 0; diff --git a/libraries/entities/src/EntityTypes.cpp b/libraries/entities/src/EntityTypes.cpp index e02043a78e..8638398bfb 100644 --- a/libraries/entities/src/EntityTypes.cpp +++ b/libraries/entities/src/EntityTypes.cpp @@ -75,7 +75,7 @@ bool EntityTypes::registerEntityType(EntityType entityType, const char* name, En } EntityItem* EntityTypes::constructEntityItem(EntityType entityType, const EntityItemID& entityID, const EntityItemProperties& properties) { - bool wantDebug = false; + bool wantDebug = true; if (wantDebug) { qDebug() << "EntityTypes::constructEntityItem(EntityType entityType, const EntityItemID& entityID, const EntityItemProperties& properties)"; qDebug() << " entityType=" << entityType; @@ -96,7 +96,7 @@ EntityItem* EntityTypes::constructEntityItem(EntityType entityType, const Entity EntityItem* EntityTypes::constructEntityItem(const unsigned char* data, int bytesToRead, ReadBitstreamToTreeParams& args) { - bool wantDebug = false; + bool wantDebug = true; //qDebug() << "EntityTypes::constructEntityItem(const unsigned char* data, int bytesToRead)"; //qDebug() << "EntityTypes::constructEntityItem(const unsigned char* data, int bytesToRead).... CALLED BUT NOT IMPLEMENTED!!!"; diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index b61a9e614b..be445b7b4d 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -236,7 +236,7 @@ OctreeElement* Octree::createMissingElement(OctreeElement* lastParentElement, co int Octree::readElementData(OctreeElement* destinationElement, const unsigned char* nodeData, int bytesLeftToRead, ReadBitstreamToTreeParams& args) { -bool wantDebug = false; +bool wantDebug = true; if (wantDebug) { qDebug() << "Octree::readElementData()"; qDebug() << " destinationElement->getAACube()=" << destinationElement->getAACube(); @@ -324,16 +324,20 @@ if (wantDebug) { // if this is the root, and there is more data to read, allow it to read it's element data... if (destinationElement == _rootElement && rootElementHasData() && (bytesLeftToRead - bytesRead) > 0) { // tell the element to read the subsequent data -if (wantDebug) { - qDebug() << "Octree::readElementData().... reading element data for root element....."; -} + if (wantDebug) { + qDebug() << "Octree::readElementData().... reading element data for root element....."; + qDebug() << " bytesRead=" << bytesRead; + qDebug() << " bytesLeftToRead - bytesRead=" << bytesLeftToRead - bytesRead; + qDebug() << " READING ROOT DATA...."; + } + bytesRead += _rootElement->readElementDataFromBuffer(nodeData + bytesRead, bytesLeftToRead - bytesRead, args); } -if (wantDebug) { - qDebug() << "Octree::readElementData()"; - qDebug() << " bytesRead=" << bytesLeftToRead; -} + if (wantDebug) { + qDebug() << "Octree::readElementData()"; + qDebug() << " bytesRead=" << bytesLeftToRead; + } return bytesRead; } @@ -341,7 +345,7 @@ if (wantDebug) { void Octree::readBitstreamToTree(const unsigned char * bitstream, unsigned long int bufferSizeBytes, ReadBitstreamToTreeParams& args) { -bool wantDebug = false; +bool wantDebug = true; if (wantDebug) { qDebug() << "Octree::readBitstreamToTree()"; qDebug() << " bufferSizeBytes=" << bufferSizeBytes; @@ -1220,9 +1224,8 @@ qDebug() << " packetData->getReservedBytes()=" << packetData->getReservedByte // Make our local buffer large enough to handle writing at this level in case we need to. LevelDetails thisLevelKey = packetData->startLevel(); - bool continueThisLevel = packetData->reserveBytes(sizeof(childrenDataBits) - + sizeof(childrenExistInPacketBits) - + sizeof(childrenExistInTreeBits)); + int requiredBytes = sizeof(childrenDataBits) + sizeof(childrenExistInPacketBits) + sizeof(childrenExistInTreeBits); + bool continueThisLevel = packetData->reserveBytes(requiredBytes); // If we can't reserve our minimum bytes then we can discard this level and return as if none of this level fits if (!continueThisLevel) { @@ -1772,6 +1775,7 @@ qDebug() << " continueThisLevel=" << continueThisLevel; // If we made it this far, then we've written all of our child data... if this element is the root // element, then we also allow the root element to write out it's data... if (continueThisLevel && element == _rootElement && rootElementHasData()) { + qDebug() << " ---- ROOT ELEMENT HANDLING ---- line:" << __LINE__; int bytesBeforeChild = packetData->getUncompressedSize(); qDebug() << " bytesBeforeChild=" << bytesBeforeChild; @@ -1788,6 +1792,9 @@ qDebug() << " allOfRootFit=" << allOfRootFit; qDebug() << " ----------- root DID (partially or fully) fit ------"; qDebug() << " packetData->endLevel(rootDataLevelKey)... line:" << __LINE__; continueThisLevel = packetData->endLevel(rootDataLevelKey); + if (!continueThisLevel) { + qDebug() << " UNEXPECTED ROOT ELEMENT -- could not packetData->endLevel(rootDataLevelKey) -- line:" << __LINE__; + } } else { qDebug() << " ----------- root didn't fit ------"; qDebug() << " packetData->discardLevel(rootDataLevelKey)... line:" << __LINE__; @@ -1879,7 +1886,7 @@ bool Octree::readFromSVOFile(const char* fileName) { unsigned long fileLength = file.tellg(); file.seekg( 0, std::ios::beg ); -bool wantDebug = false; +bool wantDebug = true; if (wantDebug) { qDebug() << "Octree::readFromSVOFile()"; qDebug() << " fileLength=" << fileLength;