From 75bb42fb7396a362274c1303faca7d06831054c8 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Fri, 22 Aug 2014 10:54:00 -0700 Subject: [PATCH] debug cleanup --- .../src/octree/OctreeSendThread.cpp | 99 +--------- libraries/entities/src/EntityItem.cpp | 67 +------ .../entities/src/EntityItemProperties.cpp | 47 ++--- libraries/entities/src/EntityTree.cpp | 43 +++-- libraries/entities/src/EntityTreeElement.cpp | 175 +++++++++--------- libraries/entities/src/todo.txt | 36 ++-- libraries/octree/src/Octree.cpp | 5 +- libraries/octree/src/OctreePacketData.cpp | 8 +- 8 files changed, 171 insertions(+), 309 deletions(-) diff --git a/assignment-client/src/octree/OctreeSendThread.cpp b/assignment-client/src/octree/OctreeSendThread.cpp index 1c2c0db1e0..673bba2408 100644 --- a/assignment-client/src/octree/OctreeSendThread.cpp +++ b/assignment-client/src/octree/OctreeSendThread.cpp @@ -119,9 +119,6 @@ quint64 OctreeSendThread::_totalWastedBytes = 0; quint64 OctreeSendThread::_totalPackets = 0; int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent) { - -//qDebug() << "OctreeSendThread::handlePacketSend()...."; - OctreeServer::didHandlePacketSend(this); // if we're shutting down, then exit early @@ -140,7 +137,6 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes // this rate control savings. if (nodeData->shouldSuppressDuplicatePacket()) { nodeData->resetOctreePacket(); // we still need to reset it though! -//qDebug() << "OctreeSendThread::handlePacketSend().... SUPPRESS DUPLICATE!!!"; return packetsSent; // without sending... } @@ -183,13 +179,11 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes // actually send it OctreeServer::didCallWriteDatagram(this); -qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() with stats... statsMessageLength=" << statsMessageLength; NodeList::getInstance()->writeDatagram((char*) statsMessage, statsMessageLength, _node); packetSent = true; } else { // not enough room in the packet, send two packets OctreeServer::didCallWriteDatagram(this); -qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() stats... statsMessageLength=" << statsMessageLength; NodeList::getInstance()->writeDatagram((char*) statsMessage, statsMessageLength, _node); // since a stats message is only included on end of scene, don't consider any of these bytes "wasted", since @@ -219,7 +213,6 @@ qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() stats... s packetsSent++; OctreeServer::didCallWriteDatagram(this); -qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() without stats... nodeData->getPacketLength()=" << nodeData->getPacketLength(); NodeList::getInstance()->writeDatagram((char*)nodeData->getPacket(), nodeData->getPacketLength(), _node); packetSent = true; @@ -249,7 +242,6 @@ qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() without st if (nodeData->isPacketWaiting() && !nodeData->isShuttingDown()) { // just send the voxel packet OctreeServer::didCallWriteDatagram(this); -qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() without stats... nodeData->getPacketLength()=" << nodeData->getPacketLength(); NodeList::getInstance()->writeDatagram((char*)nodeData->getPacket(), nodeData->getPacketLength(), _node); packetSent = true; @@ -415,23 +407,9 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus if (!nodeData->elementBag.isEmpty()) { OctreeElement* subTree = nodeData->elementBag.extract(); -qDebug() << "==============================================================="; -if (subTree == _myServer->getOctree()->getRoot()) { - qDebug() << "OctreeSendThread::packetDistributor() subTree=ROOT"; -} else { - qDebug() << "==============================================================="; - qDebug() << "OctreeSendThread::packetDistributor() subTree=" << subTree; -} - - if (lastAttemptedSubTree == subTree) { - qDebug() << "SAME SUBTREE AS LAST TIME subTree=" << subTree << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"; - } else { - qDebug() << "NEW subTree=" << subTree; - } + // 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... // @@ -481,69 +459,21 @@ if (subTree == _myServer->getOctree()->getRoot()) { quint64 encodeStart = usecTimestampNow(); -qDebug() << "+++++++++++++++ BEFORE _myServer->getOctree()->encodeTreeBitstream(subTree...) +++++++++++++++"; -qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__; -qDebug() << " _packetData.getTargetSize()=" << _packetData.getTargetSize(); -qDebug() << " MAX_OCTREE_PACKET_DATA_SIZE=" << MAX_OCTREE_PACKET_DATA_SIZE; -qDebug() << " _packetData.hasContent()=" << _packetData.hasContent(); -qDebug() << " _packetData.getUncompressedSize()=" << _packetData.getUncompressedSize(); -qDebug() << " _packetData.getFinalizedSize()=" << _packetData.getFinalizedSize(); -qDebug() << " _packetData.isCompressed()=" << _packetData.isCompressed(); -qDebug() << " _packetData.getReservedBytes()=" << _packetData.getReservedBytes(); -qDebug() << " extraPackingAttempts=" << extraPackingAttempts; -qDebug() << " REASONABLE_NUMBER_OF_PACKING_ATTEMPTS=" << REASONABLE_NUMBER_OF_PACKING_ATTEMPTS; - bytesWritten = _myServer->getOctree()->encodeTreeBitstream(subTree, &_packetData, nodeData->elementBag, params); -qDebug() << "OctreeSendThread::packetDistributor()..."; -qDebug() << " called _myServer->getOctree()->encodeTreeBitstream()..."; -qDebug() << " bytesWritten=" << bytesWritten; - quint64 encodeEnd = usecTimestampNow(); encodeElapsedUsec = (float)(encodeEnd - encodeStart); // If after calling encodeTreeBitstream() there are no nodes left to send, then we know we've // sent the entire scene. We want to know this below so we'll actually write this content into // the packet and send it -qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__; -qDebug() << " nodeData->elementBag.isEmpty()=" << nodeData->elementBag.isEmpty(); completedScene = nodeData->elementBag.isEmpty(); -qDebug() << " completedScene=" << completedScene; -if (completedScene) { -qDebug() << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"; -qDebug() << "HELLO!!!! DID YOU EXPECT THE SCENE TO COMPLETE!!!!"; -qDebug() << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"; -} - - -qDebug() << "+++++++++++++++ lastNodeDidntFit logic +++++++++++++++"; -qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__; -qDebug() << " _packetData.getTargetSize()=" << _packetData.getTargetSize(); -qDebug() << " MAX_OCTREE_PACKET_DATA_SIZE=" << MAX_OCTREE_PACKET_DATA_SIZE; -qDebug() << " _packetData.hasContent()=" << _packetData.hasContent(); -qDebug() << " _packetData.getUncompressedSize()=" << _packetData.getUncompressedSize(); -qDebug() << " _packetData.getFinalizedSize()=" << _packetData.getFinalizedSize(); -qDebug() << " _packetData.isCompressed()=" << _packetData.isCompressed(); -qDebug() << " _packetData.getReservedBytes()=" << _packetData.getReservedBytes(); -qDebug() << " bytesWritten=" << bytesWritten; -qDebug() << " extraPackingAttempts=" << extraPackingAttempts; -qDebug() << " REASONABLE_NUMBER_OF_PACKING_ATTEMPTS=" << REASONABLE_NUMBER_OF_PACKING_ATTEMPTS; - - -if (params.stopReason == EncodeBitstreamParams::DIDNT_FIT) { - qDebug() << " params.stopReason == EncodeBitstreamParams::DIDNT_FIT"; -} else { - qDebug() << " params.stopReason=" << params.getStopReason(); -} // if we're trying to fill a full size packet, then we use this logic to determine if we have a DIDNT_FIT case. if (_packetData.getTargetSize() == MAX_OCTREE_PACKET_DATA_SIZE) { if (_packetData.hasContent() && bytesWritten == 0 && params.stopReason == EncodeBitstreamParams::DIDNT_FIT) { lastNodeDidntFit = true; -qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__; -qDebug() << " -- trying to fill a full size packet --"; -qDebug() << " lastNodeDidntFit=true"; } } else { // in compressed mode and we are trying to pack more... and we don't care if the _packetData has @@ -552,9 +482,6 @@ qDebug() << " lastNodeDidntFit=true"; extraPackingAttempts++; if (bytesWritten == 0 && params.stopReason == EncodeBitstreamParams::DIDNT_FIT) { lastNodeDidntFit = true; -qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__; -qDebug() << " -- in compressed mode and we are trying to pack more --"; -qDebug() << " lastNodeDidntFit=true"; } } @@ -564,10 +491,6 @@ qDebug() << " lastNodeDidntFit=true"; // If the bag was empty then we didn't even attempt to encode, and so we know the bytesWritten were 0 bytesWritten = 0; somethingToSend = false; // this will cause us to drop out of the loop... - -qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__; -qDebug() << " -- If the bag was empty then we didn't even attempt to encode, and so we know the bytesWritten were 0 --"; - } // If the last node didn't fit, but we're in compressed mode, then we actually want to see if we can fit a @@ -579,14 +502,7 @@ qDebug() << " -- If the bag was empty then we didn't even attempt to encode, // mean we should send the previous packet contents and reset it. if (completedScene || lastNodeDidntFit) { -qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__; -qDebug() << " completedScene=" << completedScene; -qDebug() << " lastNodeDidntFit=" << lastNodeDidntFit; - if (_packetData.hasContent()) { - -//qDebug() << " _packetData.hasContent()=" << _packetData.hasContent(); - quint64 compressAndWriteStart = usecTimestampNow(); // if for some reason the finalized size is greater than our available size, then probably the "compressed" @@ -595,23 +511,10 @@ qDebug() << " lastNodeDidntFit=" << lastNodeDidntFit; unsigned int writtenSize = _packetData.getFinalizedSize() + (nodeData->getCurrentPacketIsCompressed() ? sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE) : 0); -/* -qDebug() << " _packetData.getUncompressedSize()=" << _packetData.getUncompressedSize(); -qDebug() << " _packetData.getFinalizedSize()=" << _packetData.getFinalizedSize(); -qDebug() << " writtenSize=" << writtenSize; -qDebug() << " nodeData->getAvailable()=" << nodeData->getAvailable(); -*/ if (writtenSize > nodeData->getAvailable()) { -qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__; -qDebug() << " compressed form expanded packet send it..."; -qDebug() << " calling handlePacketSend()..."; packetsSentThisInterval += handlePacketSend(nodeData, trueBytesSent, truePacketsSent); } -qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__; -qDebug() << " WRITING the packetData to the node's packet...!!!"; -qDebug() << " _packetData.getFinalizedSize()=" << _packetData.getFinalizedSize(); -qDebug() << " called nodeData->writeToPacket(... _packetData.getFinalizedSize()... )"; lastAttemptedSubTree = NULL; // reset this nodeData->writeToPacket(_packetData.getFinalizedData(), _packetData.getFinalizedSize()); diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index ad965c10e8..6a071d50ba 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -65,7 +65,6 @@ void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) { } EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) { - //qDebug() << "EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties)...."; _type = EntityTypes::Unknown; _lastEdited = 0; _lastUpdated = 0; @@ -123,19 +122,11 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet // then our modelTreeElementExtraEncodeData should include data about which properties we need to append. if (modelTreeElementExtraEncodeData && modelTreeElementExtraEncodeData->includedItems.contains(getEntityItemID())) { requestedProperties = modelTreeElementExtraEncodeData->includedItems.value(getEntityItemID()); - - qDebug() << "EntityItem::appendEntityData() we have some previous encode data..."; - //qDebug() << " requestedProperties..."; - //requestedProperties.debugDumpBits(); } - //qDebug() << "requestedProperties="; - //requestedProperties.debugDumpBits(); - LevelDetails modelLevel = packetData->startLevel(); quint64 lastEdited = getLastEdited(); - //qDebug() << "EntityItem::appendEntityData() ... lastEdited=" << lastEdited; bool successIDFits = false; bool successTypeFits = false; @@ -183,7 +174,6 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet // PROP_POSITION if (requestedProperties.getHasProperty(PROP_POSITION)) { - //qDebug() << "PROP_POSITION requested..."; LevelDetails propertyLevel = packetData->startLevel(); successPropertyFits = packetData->appendPosition(getPosition()); if (successPropertyFits) { @@ -192,18 +182,15 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet propertyCount++; packetData->endLevel(propertyLevel); } else { - //qDebug() << "PROP_POSITION didn't fit..."; packetData->discardLevel(propertyLevel); appendState = OctreeElement::PARTIAL; } } else { - //qDebug() << "PROP_POSITION NOT requested..."; propertiesDidntFit -= PROP_POSITION; } // PROP_RADIUS if (requestedProperties.getHasProperty(PROP_RADIUS)) { - //qDebug() << "PROP_RADIUS requested..."; LevelDetails propertyLevel = packetData->startLevel(); successPropertyFits = packetData->appendValue(getRadius()); if (successPropertyFits) { @@ -212,18 +199,15 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet propertyCount++; packetData->endLevel(propertyLevel); } else { - //qDebug() << "PROP_RADIUS didn't fit..."; packetData->discardLevel(propertyLevel); appendState = OctreeElement::PARTIAL; } } else { - //qDebug() << "PROP_RADIUS NOT requested..."; propertiesDidntFit -= PROP_RADIUS; } // PROP_ROTATION if (requestedProperties.getHasProperty(PROP_ROTATION)) { - //qDebug() << "PROP_ROTATION requested..."; LevelDetails propertyLevel = packetData->startLevel(); successPropertyFits = packetData->appendValue(getRotation()); if (successPropertyFits) { @@ -232,12 +216,10 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet propertyCount++; packetData->endLevel(propertyLevel); } else { - //qDebug() << "PROP_ROTATION didn't fit..."; packetData->discardLevel(propertyLevel); appendState = OctreeElement::PARTIAL; } } else { - //qDebug() << "PROP_ROTATION NOT requested..."; propertiesDidntFit -= PROP_ROTATION; } @@ -297,7 +279,6 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet LevelDetails propertyLevel = packetData->startLevel(); successPropertyFits = packetData->appendValue(getDamping()); if (successPropertyFits) { - //qDebug() << "success writing PROP_DAMPING=" << getDamping(); propertyFlags |= PROP_DAMPING; propertiesDidntFit -= PROP_DAMPING; propertyCount++; @@ -305,11 +286,9 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet } else { packetData->discardLevel(propertyLevel); appendState = OctreeElement::PARTIAL; - //qDebug() << "didn't fit PROP_DAMPING=" << getDamping(); } } else { propertiesDidntFit -= PROP_DAMPING; - //qDebug() << "not requested PROP_DAMPING=" << getDamping(); } // PROP_LIFETIME, @@ -365,14 +344,11 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet // if the size of the PropertyFlags shrunk, we need to shift everything down to front of packet. if (newPropertyFlagsLength < oldPropertyFlagsLength) { int oldSize = packetData->getUncompressedSize(); - const unsigned char* modelItemData = packetData->getUncompressedData(propertyFlagsOffset + oldPropertyFlagsLength); int modelItemDataLength = endOfEntityItemData - startOfEntityItemData; int newEntityItemDataStart = propertyFlagsOffset + newPropertyFlagsLength; packetData->updatePriorBytes(newEntityItemDataStart, modelItemData, modelItemDataLength); - int newSize = oldSize - (oldPropertyFlagsLength - newPropertyFlagsLength); -qDebug() << "EntityItem::appendEntityData()... SHRINKING CASE??? DID WE TEST THIS!!!! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<"; packetData->setUncompressedSize(newSize); } else { @@ -385,21 +361,10 @@ qDebug() << "EntityItem::appendEntityData()... SHRINKING CASE??? DID WE TEST THI appendState = OctreeElement::NONE; // if we got here, then we didn't include the item } - //qDebug() << "propertyFlags="; - //propertyFlags.debugDumpBits(); - - //qDebug() << "propertiesDidntFit="; - //propertiesDidntFit.debugDumpBits(); - // If any part of the model items didn't fit, then the element is considered partial if (appendState != OctreeElement::COMPLETED) { // add this item into our list for the next appendElementData() pass modelTreeElementExtraEncodeData->includedItems.insert(getEntityItemID(), propertiesDidntFit); - - qDebug() << "EntityItem::appendEntityData() not complete... (appendState != OctreeElement::COMPLETED)"; - //qDebug() << " propertiesDidntFit..."; - //propertiesDidntFit.debugDumpBits(); - } return appendState; @@ -424,7 +389,11 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef bool wantDebug = false; if (args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU) { - qDebug() << "EntityItem::readEntityDataFromBuffer()... ERROR CASE...args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU"; + + // NOTE: This shouldn't happen. The only versions of the bit stream that didn't support split mtu buffers should + // be handled by the model subclass and shouldn't call this routine. + qDebug() << "EntityItem::readEntityDataFromBuffer()... " + "ERROR CASE...args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU"; return 0; } @@ -455,14 +424,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef dataAt += encodedID.size(); bytesRead += encodedID.size(); - /** - ByteCountCoded idCoder = encodedID; - encodedID = idCoder; // determine true length - dataAt += encodedID.size(); - bytesRead += encodedID.size(); - _id = idCoder; - **/ - // type QByteArray encodedType = originalDataBuffer.mid(bytesRead); // maximum possible size ByteCountCoded typeCoder = encodedType; @@ -510,7 +471,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef quint64 updateDelta = updateDeltaCoder; if (overwriteLocalData) { _lastUpdated = _lastEdited + updateDelta; // don't adjust for clock skew since we already did that for _lastEdited - //qDebug() << "%%%%%%%%%%%%%%%% EntityItem::readEntityDataFromBuffer() .... SETTING _lastUpdated=" << _lastUpdated; } encodedUpdateDelta = updateDeltaCoder; // determine true length dataAt += encodedUpdateDelta.size(); @@ -523,12 +483,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef bytesRead += propertyFlags.getEncodedLength(); -/* - qDebug() << "EntityItem::readEntityDataFromBuffer() just read properties from buffer...."; - qDebug() << " propertyFlags..."; - propertyFlags.debugDumpBits(); -*/ - // PROP_POSITION if (propertyFlags.getHasProperty(PROP_POSITION)) { @@ -604,12 +558,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef dataAt += sizeof(value); bytesRead += sizeof(value); - //qDebug() << "property included in buffer PROP_DAMPING=" << value; - if (overwriteLocalData) { _damping = value; - - //qDebug() << " overwriting local value... PROP_DAMPING=" << getDamping(); } } @@ -832,10 +782,6 @@ EntityItemProperties EntityItem::getProperties() const { } bool EntityItem::setProperties(const EntityItemProperties& properties, bool forceCopy) { - //qDebug() << "EntityItem::setProperties()... forceCopy=" << forceCopy; - //qDebug() << "EntityItem::setProperties() properties.getDamping()=" << properties.getDamping(); - //qDebug() << "EntityItem::setProperties() properties.getVelocity()=" << properties.getVelocity(); - bool somethingChanged = false; if (properties._positionChanged || forceCopy) { setPosition(properties._position / (float) TREE_SCALE); @@ -859,7 +805,6 @@ bool EntityItem::setProperties(const EntityItemProperties& properties, bool forc if (properties._velocityChanged || forceCopy) { setVelocity(properties._velocity / (float) TREE_SCALE); - //qDebug() << "EntityItem::setProperties() AFTER setVelocity() getVelocity()=" << getVelocity(); somethingChanged = true; } @@ -872,8 +817,6 @@ bool EntityItem::setProperties(const EntityItemProperties& properties, bool forc somethingChanged = true; } - //qDebug() << ">>>>>>>>>>>>>>>>>>> EntityItem::setProperties(); <<<<<<<<<<<<<<<<<<<<<<<<< properties._dampingChanged=" << properties._dampingChanged; - if (properties._dampingChanged || forceCopy) { setDamping(properties._damping); somethingChanged = true; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 405db34ab1..5f107f1a56 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -876,7 +876,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int EntityItemID& entityID, EntityItemProperties& properties) { bool valid = false; - bool wantDebug = true; + bool wantDebug = false; if (wantDebug) { qDebug() << "EntityItemProperties::decodeEntityEditPacket() bytesToRead=" << bytesToRead; } @@ -948,8 +948,6 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int valid = true; } - //qDebug() << "EntityItemProperties::decodeEntityEditPacket() entityID=" << entityID; - // Entity Type... QByteArray encodedType((const char*)dataAt, (bytesToRead - processedBytes)); ByteCountCoded typeCoder = encodedType; @@ -1087,10 +1085,6 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int properties.setModelURL(modelURLString); } - if (wantDebug) { - qDebug() << "EntityItem EntityItem::decodeEntityEditPacket() model URL=" << properties.getModelURL(); - } - // PROP_ANIMATION_URL if (propertyFlags.getHasProperty(PROP_ANIMATION_URL)) { // animationURL @@ -1130,15 +1124,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int processedBytes += sizeof(animationIsPlaying); properties.setAnimationIsPlaying(animationIsPlaying); } -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const bool wantDebugging = false; - if (wantDebugging) { - qDebug("EntityItem::fromEditPacket()..."); - qDebug() << " EntityItem id in packet:" << editID; - //newEntityItem.debugDump(); - } - return valid; } @@ -1149,7 +1135,10 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityItemID, unsigned char* outputBuffer, size_t maxLength, size_t& outputLength) { - qDebug() << "EntityItemProperties::encodeEraseEntityMessage()"; + const bool wantDebug = false; + if (wantDebug) { + qDebug() << "EntityItemProperties::encodeEraseEntityMessage()"; + } unsigned char* copyAt = outputBuffer; @@ -1158,12 +1147,14 @@ bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityIt copyAt += sizeof(numberOfIds); outputLength = sizeof(numberOfIds); - qDebug() << " numberOfIds=" << numberOfIds; + if (wantDebug) { + qDebug() << " numberOfIds=" << numberOfIds; + } QUuid entityID = entityItemID.id; QByteArray encodedEntityID = entityID.toRfc4122(); - { + if (wantDebug) { QDebug debugA = qDebug(); debugA << " encodedEntityID contents:"; outputBufferBits((unsigned char*)encodedEntityID.constData(), encodedEntityID.size(), &debugA); @@ -1173,16 +1164,16 @@ bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityIt copyAt += NUM_BYTES_RFC4122_UUID; outputLength += NUM_BYTES_RFC4122_UUID; - qDebug() << " entityID=" << entityID; - - qDebug() << " outputLength=" << outputLength; - qDebug() << " NUM_BYTES_RFC4122_UUID=" << NUM_BYTES_RFC4122_UUID; - qDebug() << " encodedEntityID.size()=" << encodedEntityID.size(); - - { - QDebug debug = qDebug(); - debug << " edit data contents:"; - outputBufferBits(outputBuffer, outputLength, &debug); + if (wantDebug) { + qDebug() << " entityID=" << entityID; + qDebug() << " outputLength=" << outputLength; + qDebug() << " NUM_BYTES_RFC4122_UUID=" << NUM_BYTES_RFC4122_UUID; + qDebug() << " encodedEntityID.size()=" << encodedEntityID.size(); + { + QDebug debug = qDebug(); + debug << " edit data contents:"; + outputBufferBits(outputBuffer, outputLength, &debug); + } } return true; diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 51bc0a86d3..c46ccb42bf 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -763,11 +763,15 @@ void EntityTree::deleteEntity(const EntityItemID& entityID) { void EntityTree::deleteEntities(QSet entityIDs) { // NOTE: callers must lock the tree before using this method - qDebug() << "EntityTree::EntityTree::deleteEntities().... "; - qDebug() << " entityIDs=" << entityIDs; - qDebug() << " BEFORE map..."; - debugDumpMap(); - + + const bool wantDebug = false; + if (wantDebug) { + qDebug() << "EntityTree::EntityTree::deleteEntities().... "; + qDebug() << " entityIDs=" << entityIDs; + qDebug() << " BEFORE map..."; + debugDumpMap(); + } + DeleteEntityOperator theOperator(this); foreach(const EntityItemID& entityID, entityIDs) { // First, look for the existing entity in the tree.. @@ -777,7 +781,6 @@ void EntityTree::deleteEntities(QSet entityIDs) { recurseTreeWithOperator(&theOperator); _isDirty = true; - bool wantDebug = false; if (wantDebug) { foreach(const EntityItemID& entityID, entityIDs) { EntityTreeElement* containingElement = getContainingElement(entityID); @@ -1095,20 +1098,22 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char } case PacketTypeEntityAddOrEdit: { - qDebug() << "EntityTree::processEditPacketData()...."; - + const bool wantDebug = false; + EntityItemID entityItemID; EntityItemProperties properties; bool validEditPacket = EntityItemProperties::decodeEntityEditPacket(editData, maxLength, processedBytes, entityItemID, properties); - qDebug() << "EntityTree::processEditPacketData().... "; - qDebug() << " validEditPacket=" << validEditPacket; - qDebug() << " processedBytes=" << processedBytes; - qDebug() << " entityItemID=" << entityItemID; - qDebug() << " BEFORE map..."; - debugDumpMap(); + if (wantDebug) { + qDebug() << "EntityTree::processEditPacketData().... "; + qDebug() << " validEditPacket=" << validEditPacket; + qDebug() << " processedBytes=" << processedBytes; + qDebug() << " entityItemID=" << entityItemID; + qDebug() << " BEFORE map..."; + debugDumpMap(); + } // If we got a valid edit packet, then it could be a new entity or it could be an update to // an existing entity... handle appropriately @@ -1127,9 +1132,15 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char } } else { // this is a new entity... assign a new entityID - qDebug() << "EntityTree::processEditPacketData() ... BEFORE assignEntityID()... entityItemID=" << entityItemID; + if (wantDebug) { + qDebug() << "EntityTree::processEditPacketData() ... " + "BEFORE assignEntityID()... entityItemID=" << entityItemID; + } entityItemID = assignEntityID(entityItemID); - qDebug() << "EntityTree::processEditPacketData() ... AFTER assignEntityID()... entityItemID=" << entityItemID; + if (wantDebug) { + qDebug() << "EntityTree::processEditPacketData() ... " + "AFTER assignEntityID()... entityItemID=" << entityItemID; + } EntityItem* newEntity = addEntity(entityItemID, properties); if (newEntity) { diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index dacaf8e9ae..63c0fb275e 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -54,13 +54,13 @@ EntityTreeElement* EntityTreeElement::addChildAtIndex(int index) { OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData* packetData, EncodeBitstreamParams& params) const { - qDebug() << "START OF ELEMENT packetData->uncompressed size:" << packetData->getUncompressedSize(); bool wantDebug = false; - if (wantDebug) { + if (wantDebug) { qDebug() << "EntityTreeElement::appendElementData()"; qDebug() << " getAACube()=" << getAACube(); + qDebug() << " START OF ELEMENT packetData->uncompressed size:" << packetData->getUncompressedSize(); } OctreeElement::AppendState appendElementState = OctreeElement::COMPLETED; // assume the best... @@ -83,7 +83,9 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData uint16_t actualNumberOfEntities = 0; QVector indexesOfEntitiesToInclude; - qDebug() << "EntityTreeElement::appendElementData() _entityItems->size()=" << _entityItems->size(); + if (wantDebug) { + qDebug() << "EntityTreeElement::appendElementData() _entityItems->size()=" << _entityItems->size(); + } for (uint16_t i = 0; i < _entityItems->size(); i++) { EntityItem* entity = (*_entityItems)[i]; @@ -91,9 +93,11 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData if (hadElementExtraData) { includeThisEntity = entityTreeElementExtraEncodeData->includedItems.contains(entity->getEntityItemID()); - qDebug() << " hadElementExtraData=" << hadElementExtraData; - qDebug() << " entity[" << i <<"].entityItemID=" << entity->getEntityItemID(); - qDebug() << " entity[" << i <<"].includeThisEntity=" << includeThisEntity; + if (wantDebug) { + qDebug() << " hadElementExtraData=" << hadElementExtraData; + qDebug() << " entity[" << i <<"].entityItemID=" << entity->getEntityItemID(); + qDebug() << " entity[" << i <<"].includeThisEntity=" << includeThisEntity; + } } if (includeThisEntity && params.viewFrustum) { @@ -101,7 +105,10 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData entityCube.scale(TREE_SCALE); if (params.viewFrustum->cubeInFrustum(entityCube) == ViewFrustum::OUTSIDE) { includeThisEntity = false; // out of view, don't include it - qDebug() << " entity[" << i <<"] cubeInFrustum(entityCube) == ViewFrustum::OUTSIDE ----> includeThisEntity=" << includeThisEntity; + if (wantDebug) { + qDebug() << " entity[" << i <<"] cubeInFrustum(entityCube) == ViewFrustum::OUTSIDE " + "includeThisEntity=" << includeThisEntity; + } } } @@ -114,15 +121,17 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData int numberOfEntitiesOffset = packetData->getUncompressedByteOffset(); bool successAppendEntityCount = packetData->appendValue(numberOfEntities); - qDebug() << " numberOfEntities=" << numberOfEntities; - qDebug() << " successAppendEntityCount=" << successAppendEntityCount; - qDebug() << "--- before child loop ---"; - qDebug() << " packetData->getUncompressedSize()=" << packetData->getUncompressedSize() << "line:" << __LINE__; - qDebug() << " packetData->getReservedBytes()=" << packetData->getReservedBytes(); - + if (wantDebug) { + qDebug() << " numberOfEntities=" << numberOfEntities; + qDebug() << " successAppendEntityCount=" << successAppendEntityCount; + qDebug() << "--- before child loop ---"; + qDebug() << " packetData->getUncompressedSize()=" << packetData->getUncompressedSize() << "line:" << __LINE__; + qDebug() << " packetData->getReservedBytes()=" << packetData->getReservedBytes(); + } + if (successAppendEntityCount) { - if (true || wantDebug) { + if (wantDebug) { qDebug() << "EntityTreeElement::appendElementData()"; qDebug() << " indexesOfEntitiesToInclude loop.... numberOfEntities=" << numberOfEntities; } @@ -130,44 +139,57 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData foreach (uint16_t i, indexesOfEntitiesToInclude) { EntityItem* entity = (*_entityItems)[i]; - if (true || wantDebug) { + if (wantDebug) { qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"].entityItemID=" << entity->getEntityItemID(); } LevelDetails entityLevel = packetData->startLevel(); - qDebug() << "--- BEFORE entity ---"; - qDebug() << " packetData->getUncompressedSize()=" << packetData->getUncompressedSize() << "line:" << __LINE__; - qDebug() << " packetData->getReservedBytes()=" << packetData->getReservedBytes(); - - OctreeElement::AppendState appendEntityState = entity->appendEntityData(packetData, params, entityTreeElementExtraEncodeData); - - qDebug() << "--- AFTER entity ---"; - qDebug() << " packetData->getUncompressedSize()=" << packetData->getUncompressedSize() << "line:" << __LINE__; - qDebug() << " packetData->getReservedBytes()=" << packetData->getReservedBytes(); + if (wantDebug) { + qDebug() << "--- BEFORE entity ---"; + qDebug() << " packetData->getUncompressedSize=" << packetData->getUncompressedSize() << "line:" << __LINE__; + qDebug() << " packetData->getReservedBytes=" << packetData->getReservedBytes(); + } + + OctreeElement::AppendState appendEntityState = entity->appendEntityData(packetData, + params, entityTreeElementExtraEncodeData); + if (wantDebug) { + qDebug() << "--- AFTER entity ---"; + qDebug() << " packetData->getUncompressedSize=" << packetData->getUncompressedSize() << "line:" << __LINE__; + qDebug() << " packetData->getReservedBytes=" << packetData->getReservedBytes(); + } + // If none of this entity data was able to be appended, then discard it // and don't include it in our entity count if (appendEntityState == OctreeElement::NONE) { - qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] DIDN'T FIT!!!"; + if (wantDebug) { + qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] DIDN'T FIT!!!"; + } packetData->discardLevel(entityLevel); } else { // If either ALL or some of it got appended, then end the level (commit it) // and include the entity in our final count of entities packetData->endLevel(entityLevel); actualNumberOfEntities++; - qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] ALL OR SOME FIT!!!"; + if (wantDebug) { + qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] ALL OR SOME FIT!!!"; + } } // If the entity item got completely appended, then we can remove it from the extra encode data if (appendEntityState == OctreeElement::COMPLETED) { entityTreeElementExtraEncodeData->includedItems.remove(entity->getEntityItemID()); - qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] IT ALL FIT!!!"; + if (wantDebug) { + qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] IT ALL FIT!!!"; + } } else { - if (appendEntityState == OctreeElement::NONE) { - qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] DIDN'T FIT!!!"; - } else { - qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] PARTIAL FIT!!!"; + if (wantDebug) { + if (appendEntityState == OctreeElement::NONE) { + qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] DIDN'T FIT!!!"; + } else { + qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] PARTIAL FIT!!!"; + } } } @@ -180,27 +202,35 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData } } - qDebug() << "--- done with loop ---"; - qDebug() << " actualNumberOfEntities=" << actualNumberOfEntities; - qDebug() << " numberOfEntities=" << numberOfEntities; - qDebug() << " appendElementState=" << appendElementState; - + if (wantDebug) { + qDebug() << "--- done with loop ---"; + qDebug() << " actualNumberOfEntities=" << actualNumberOfEntities; + qDebug() << " numberOfEntities=" << numberOfEntities; + qDebug() << " appendElementState=" << appendElementState; + } + // If we were provided with extraEncodeData, and we allocated and/or got entityTreeElementExtraEncodeData // then we need to do some additional processing, namely make sure our extraEncodeData is up to date for // this octree element. if (extraEncodeData && entityTreeElementExtraEncodeData) { - qDebug() << " handling extra encode data...."; + if (wantDebug) { + qDebug() << " handling extra encode data...."; + } // If after processing we have some includedItems left in it, then make sure we re-add it back to our map if (entityTreeElementExtraEncodeData->includedItems.size()) { extraEncodeData->insert(this, entityTreeElementExtraEncodeData); - qDebug() << " RE INSERT OUR EXTRA DATA...."; + if (wantDebug) { + qDebug() << " RE INSERT OUR EXTRA DATA...."; + } } else { // otherwise, clean things up... extraEncodeData->remove(this); delete entityTreeElementExtraEncodeData; - qDebug() << " REMOVE OUR EXTRA DATA...."; + if (wantDebug) { + qDebug() << " REMOVE OUR EXTRA DATA...."; + } } } @@ -212,7 +242,9 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData if (!noEntitiesFit && numberOfEntities != actualNumberOfEntities) { successUpdateEntityCount = packetData->updatePriorBytes(numberOfEntitiesOffset, (const unsigned char*)&actualNumberOfEntities, sizeof(actualNumberOfEntities)); - qDebug() << " UPDATE NUMER OF ENTITIES.... actualNumberOfEntities=" << actualNumberOfEntities; + if (wantDebug) { + qDebug() << " UPDATE NUMER OF ENTITIES.... actualNumberOfEntities=" << actualNumberOfEntities; + } } // If we weren't able to update our entity count, or we couldn't fit any entities, then @@ -220,24 +252,28 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData if (!successUpdateEntityCount || noEntitiesFit) { packetData->discardLevel(elementLevel); appendElementState = OctreeElement::NONE; - qDebug() << " something went wrong... discardLevel().... appendElementState = OctreeElement::NONE;"; - qDebug() << " successUpdateEntityCount=" << successUpdateEntityCount; - qDebug() << " noEntitiesFit=" << noEntitiesFit; - if (extraEncodeData) { - qDebug() << " do we still have extra data?? " << extraEncodeData->contains(this); - } else { - qDebug() << " what happened to extraEncodeData??"; + if (wantDebug) { + qDebug() << " something went wrong... discardLevel().... appendElementState = OctreeElement::NONE;"; + qDebug() << " successUpdateEntityCount=" << successUpdateEntityCount; + qDebug() << " noEntitiesFit=" << noEntitiesFit; + if (extraEncodeData) { + qDebug() << " do we still have extra data?? " << extraEncodeData->contains(this); + } else { + qDebug() << " what happened to extraEncodeData??"; + } } - - } else { packetData->endLevel(elementLevel); - qDebug() << " looks good endLevel().... appendElementState=" << appendElementState; - qDebug() << " successUpdateEntityCount=" << successUpdateEntityCount; - qDebug() << " noEntitiesFit=" << noEntitiesFit; + if (wantDebug) { + qDebug() << " looks good endLevel().... appendElementState=" << appendElementState; + qDebug() << " successUpdateEntityCount=" << successUpdateEntityCount; + qDebug() << " noEntitiesFit=" << noEntitiesFit; + } } - qDebug() << "END OF ELEMENT packetData->uncompressed size:" << packetData->getUncompressedSize(); + if (wantDebug) { + qDebug() << "END OF ELEMENT packetData->uncompressed size:" << packetData->getUncompressedSize(); + } return appendElementState; } @@ -405,10 +441,6 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con if (localDistance < distance) { distance = localDistance; face = localFace; - - //qDebug() << "about to set intersectedObject=" << entity; - //entity->debugDump(); - *intersectedObject = (void*)entity; somethingIntersected = true; } @@ -417,10 +449,6 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con } else if (localDistance < distance) { distance = localDistance; face = localFace; - - //qDebug() << "about to set intersectedObject=" << entity; - //entity->debugDump(); - *intersectedObject = (void*)entity; somethingIntersected = true; } @@ -565,35 +593,13 @@ EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id) return foundEntity; } -/* -bool EntityTreeElement::removeEntityWithID(uint32_t id) { - bool foundEntity = false; - uint16_t numberOfEntities = _entityItems->size(); - for (uint16_t i = 0; i < numberOfEntities; i++) { - if ((*_entityItems)[i]->getID() == id) { - foundEntity = true; - //EntityItem* entityItem = (*_entityItems)[i]; - //qDebug() << "EntityTreeElement::removeEntityWithID() BEFORE _entityItems->removeAt(i); element=" << this << "entity=" << entityItem << "id=" << entityItem->getEntityItemID() << "bestFit=" << bestFitEntityBounds(entityItem); - _entityItems->removeAt(i); - //qDebug() << "EntityTreeElement::removeEntityWithID() AFTER _entityItems->removeAt(i); element=" << this << "entity=" << entityItem << "id=" << entityItem->getEntityItemID() << "bestFit=" << bestFitEntityBounds(entityItem); - - break; - } - } - return foundEntity; -} -*/ - bool EntityTreeElement::removeEntityWithEntityItemID(const EntityItemID& id) { bool foundEntity = false; uint16_t numberOfEntities = _entityItems->size(); for (uint16_t i = 0; i < numberOfEntities; i++) { if ((*_entityItems)[i]->getEntityItemID() == id) { foundEntity = true; - //EntityItem* entityItem = (*_entityItems)[i]; - //qDebug() << "EntityTreeElement::removeEntityWithEntityItemID() BEFORE _entityItems->removeAt(i); element=" << this << "entity=" << entityItem << "id=" << entityItem->getEntityItemID() << "bestFit=" << bestFitEntityBounds(entityItem); _entityItems->removeAt(i); - //qDebug() << "EntityTreeElement::removeEntityWithEntityItemID() AFTER _entityItems->removeAt(i); element=" << this << "entity=" << entityItem << "id=" << entityItem->getEntityItemID() << "bestFit=" << bestFitEntityBounds(entityItem); break; } } @@ -606,10 +612,7 @@ bool EntityTreeElement::removeEntityItem(const EntityItem* entity) { for (uint16_t i = 0; i < numberOfEntities; i++) { if ((*_entityItems)[i] == entity) { foundEntity = true; - //EntityItem* entityItem = (*_entityItems)[i]; - //qDebug() << "EntityTreeElement::removeEntityItem() BEFORE _entityItems->removeAt(i); element=" << this << "entity=" << entityItem << "id=" << entityItem->getEntityItemID() << "bestFit=" << bestFitEntityBounds(entityItem); _entityItems->removeAt(i); - //qDebug() << "EntityTreeElement::removeEntityItem() AFTER _entityItems->removeAt(i); element=" << this << "entity=" << entityItem << "id=" << entityItem->getEntityItemID() << "bestFit=" << bestFitEntityBounds(entityItem); break; } } diff --git a/libraries/entities/src/todo.txt b/libraries/entities/src/todo.txt index ffff937458..482338f854 100644 --- a/libraries/entities/src/todo.txt +++ b/libraries/entities/src/todo.txt @@ -33,14 +33,17 @@ Model properties: // // REQUIRED TO DO: - 0) test animation again... - - 1) verify lots of models in single element works - -- repro case - run editModelsExample.js -- create 10 models in the same octree element + 1) random crashes on moving (I think things going out of bounds???) + 2) some jutter with moving entities + + 3) test animation again... + + 4) clear all entities when changing domains? + 5) what to do with entities - 2) memory leaks??? - 3) Import/Export Models - verify it works. /copy/paste?? + 4) memory leaks??? + 5) Import/Export Models - verify it works. /copy/paste?? 22a) void ModelItemProperties::copyFromNewModelItem(const ModelItem& modelItem); // XXX ??? Do we need this???? 22b) Local Entities Overlay - from Local Models Overlay 22c) void ModelTree::sendModels(ModelEditPacketSender* packetSender, float x, float y, float z).... @@ -48,8 +51,8 @@ Model properties: DONE -- 22d) void ModelTree::findModelsInCube(const AACube& cube, QVector& foundModels)... DONE -- 22e) void ModelTreeElement::getModelsInside(const AACube& box, QVector& foundModels)... - 4) support sitpoints and referentials.... - 5) Referentials???? + 6) support sitpoints and referentials.... + 7) Referentials???? For sitting points and referentials you can kill two birds with one stone. Put this model in world: http://highfidelity-public.s3-us-west-1.amazonaws.com/ozan/theater.fst @@ -59,15 +62,18 @@ Model properties: Move model with another avatar. Observe first avatar moving. - 6) verify shadows work + 8) verify shadows work - 7) Handle the ID -> UUID swap in old files to new files + 9) Handle the ID -> UUID swap in old files to new files - 8) Test models -> attachments logic + 10) Test models -> attachments logic - 9) What happens if the edit properties don't fit in a single message MTU??? - 10) animations not always working????? - 11) EntityItemProperties::decodeEntityEditPacket() doesn't include PROP_SCRIPT + 11) What happens if the edit properties don't fit in a single message MTU??? + 12) animations not always working????? + 13) EntityItemProperties::decodeEntityEditPacket() doesn't include PROP_SCRIPT + + 14) Make sure LOD logic honors the LOD settings for entities in "spanners/parent" cells. + 15) quickly do some edits... then change domains... watch the entities continue to exist in new domain and move around. // NICE TO DO: @@ -241,3 +247,5 @@ Model properties: // SOLVED -- 0) render performance of models... // SOLVED -- a) make getModel() faster... consider storing the Model* in the actual EntityItem class // SOLVED -- b) only call simulate when properties change +// SOLVED -- 1) verify lots of models in single element works +// -- repro case - run editModelsExample.js -- create 10 models in the same octree element diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 60fb71bf47..44e7749bac 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -1163,7 +1163,10 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element, // Make our local buffer large enough to handle writing at this level in case we need to. LevelDetails thisLevelKey = packetData->startLevel(); - int requiredBytes = sizeof(childrenDataBits) + sizeof(childrenExistInPacketBits) + sizeof(childrenExistInTreeBits); + int requiredBytes = sizeof(childrenDataBits) + sizeof(childrenExistInPacketBits); + if (params.includeExistsBits) { + requiredBytes += 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 diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index 9bf3755802..360745c865 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -61,7 +61,10 @@ bool OctreePacketData::append(const unsigned char* data, int length) { _bytesAvailable -= length; success = true; _dirty = true; - } else { + } + + const bool wantDebug = false; + if (wantDebug && !success) { qDebug() << "OctreePacketData::append(const unsigned char* data, int length) FAILING...."; qDebug() << " length=" << length; qDebug() << " _bytesAvailable=" << _bytesAvailable; @@ -130,10 +133,7 @@ bool OctreePacketData::updatePriorBitMask(int offset, unsigned char bitmask) { bool OctreePacketData::updatePriorBytes(int offset, const unsigned char* replacementBytes, int length) { bool success = false; if (length >= 0 && offset >= 0 && ((offset + length) <= _bytesInUse)) { - - // we probably need to use memmove!!! if (replacementBytes >= &_uncompressed[offset] && replacementBytes <= &_uncompressed[offset + length]) { - qDebug() << "OctreePacketData::updatePriorBytes()... buffers overlap!!! use memmove()"; memmove(&_uncompressed[offset], replacementBytes, length); // copy new content with overlap safety } else { memcpy(&_uncompressed[offset], replacementBytes, length); // copy new content