debug cleanup

This commit is contained in:
ZappoMan 2014-08-22 10:54:00 -07:00
parent 17426a1c71
commit 75bb42fb73
8 changed files with 171 additions and 309 deletions

View file

@ -119,9 +119,6 @@ quint64 OctreeSendThread::_totalWastedBytes = 0;
quint64 OctreeSendThread::_totalPackets = 0; quint64 OctreeSendThread::_totalPackets = 0;
int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent) { int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytesSent, int& truePacketsSent) {
//qDebug() << "OctreeSendThread::handlePacketSend()....";
OctreeServer::didHandlePacketSend(this); OctreeServer::didHandlePacketSend(this);
// if we're shutting down, then exit early // if we're shutting down, then exit early
@ -140,7 +137,6 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
// this rate control savings. // this rate control savings.
if (nodeData->shouldSuppressDuplicatePacket()) { if (nodeData->shouldSuppressDuplicatePacket()) {
nodeData->resetOctreePacket(); // we still need to reset it though! nodeData->resetOctreePacket(); // we still need to reset it though!
//qDebug() << "OctreeSendThread::handlePacketSend().... SUPPRESS DUPLICATE!!!";
return packetsSent; // without sending... return packetsSent; // without sending...
} }
@ -183,13 +179,11 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
// actually send it // actually send it
OctreeServer::didCallWriteDatagram(this); OctreeServer::didCallWriteDatagram(this);
qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() with stats... statsMessageLength=" << statsMessageLength;
NodeList::getInstance()->writeDatagram((char*) statsMessage, statsMessageLength, _node); NodeList::getInstance()->writeDatagram((char*) statsMessage, statsMessageLength, _node);
packetSent = true; packetSent = true;
} else { } else {
// not enough room in the packet, send two packets // not enough room in the packet, send two packets
OctreeServer::didCallWriteDatagram(this); OctreeServer::didCallWriteDatagram(this);
qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() stats... statsMessageLength=" << statsMessageLength;
NodeList::getInstance()->writeDatagram((char*) statsMessage, statsMessageLength, _node); 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 // 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++; packetsSent++;
OctreeServer::didCallWriteDatagram(this); OctreeServer::didCallWriteDatagram(this);
qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() without stats... nodeData->getPacketLength()=" << nodeData->getPacketLength();
NodeList::getInstance()->writeDatagram((char*)nodeData->getPacket(), nodeData->getPacketLength(), _node); NodeList::getInstance()->writeDatagram((char*)nodeData->getPacket(), nodeData->getPacketLength(), _node);
packetSent = true; packetSent = true;
@ -249,7 +242,6 @@ qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() without st
if (nodeData->isPacketWaiting() && !nodeData->isShuttingDown()) { if (nodeData->isPacketWaiting() && !nodeData->isShuttingDown()) {
// just send the voxel packet // just send the voxel packet
OctreeServer::didCallWriteDatagram(this); OctreeServer::didCallWriteDatagram(this);
qDebug() << "OctreeSendThread::handlePacketSend().... writeDatagram() without stats... nodeData->getPacketLength()=" << nodeData->getPacketLength();
NodeList::getInstance()->writeDatagram((char*)nodeData->getPacket(), nodeData->getPacketLength(), _node); NodeList::getInstance()->writeDatagram((char*)nodeData->getPacket(), nodeData->getPacketLength(), _node);
packetSent = true; packetSent = true;
@ -415,23 +407,9 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
if (!nodeData->elementBag.isEmpty()) { if (!nodeData->elementBag.isEmpty()) {
OctreeElement* subTree = nodeData->elementBag.extract(); OctreeElement* subTree = nodeData->elementBag.extract();
qDebug() << "==============================================================="; // TODO: look into breaking early if the same subtree keeps repeating for inclusion...
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;
}
lastAttemptedSubTree = subTree; lastAttemptedSubTree = subTree;
/* TODO: Looking for a way to prevent locking and encoding a tree that is not /* TODO: Looking for a way to prevent locking and encoding a tree that is not
// going to result in any packets being sent... // going to result in any packets being sent...
// //
@ -481,69 +459,21 @@ if (subTree == _myServer->getOctree()->getRoot()) {
quint64 encodeStart = usecTimestampNow(); 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); bytesWritten = _myServer->getOctree()->encodeTreeBitstream(subTree, &_packetData, nodeData->elementBag, params);
qDebug() << "OctreeSendThread::packetDistributor()...";
qDebug() << " called _myServer->getOctree()->encodeTreeBitstream()...";
qDebug() << " bytesWritten=" << bytesWritten;
quint64 encodeEnd = usecTimestampNow(); quint64 encodeEnd = usecTimestampNow();
encodeElapsedUsec = (float)(encodeEnd - encodeStart); encodeElapsedUsec = (float)(encodeEnd - encodeStart);
// If after calling encodeTreeBitstream() there are no nodes left to send, then we know we've // 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 // sent the entire scene. We want to know this below so we'll actually write this content into
// the packet and send it // the packet and send it
qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__;
qDebug() << " nodeData->elementBag.isEmpty()=" << nodeData->elementBag.isEmpty();
completedScene = 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 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.getTargetSize() == MAX_OCTREE_PACKET_DATA_SIZE) {
if (_packetData.hasContent() && bytesWritten == 0 && if (_packetData.hasContent() && bytesWritten == 0 &&
params.stopReason == EncodeBitstreamParams::DIDNT_FIT) { params.stopReason == EncodeBitstreamParams::DIDNT_FIT) {
lastNodeDidntFit = true; lastNodeDidntFit = true;
qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__;
qDebug() << " -- trying to fill a full size packet --";
qDebug() << " lastNodeDidntFit=true";
} }
} else { } else {
// in compressed mode and we are trying to pack more... and we don't care if the _packetData has // 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++; extraPackingAttempts++;
if (bytesWritten == 0 && params.stopReason == EncodeBitstreamParams::DIDNT_FIT) { if (bytesWritten == 0 && params.stopReason == EncodeBitstreamParams::DIDNT_FIT) {
lastNodeDidntFit = true; 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 // If the bag was empty then we didn't even attempt to encode, and so we know the bytesWritten were 0
bytesWritten = 0; bytesWritten = 0;
somethingToSend = false; // this will cause us to drop out of the loop... 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 // 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. // mean we should send the previous packet contents and reset it.
if (completedScene || lastNodeDidntFit) { if (completedScene || lastNodeDidntFit) {
qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__;
qDebug() << " completedScene=" << completedScene;
qDebug() << " lastNodeDidntFit=" << lastNodeDidntFit;
if (_packetData.hasContent()) { if (_packetData.hasContent()) {
//qDebug() << " _packetData.hasContent()=" << _packetData.hasContent();
quint64 compressAndWriteStart = usecTimestampNow(); quint64 compressAndWriteStart = usecTimestampNow();
// if for some reason the finalized size is greater than our available size, then probably the "compressed" // 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() unsigned int writtenSize = _packetData.getFinalizedSize()
+ (nodeData->getCurrentPacketIsCompressed() ? sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE) : 0); + (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()) { if (writtenSize > nodeData->getAvailable()) {
qDebug() << "OctreeSendThread::packetDistributor()... line:" << __LINE__;
qDebug() << " compressed form expanded packet send it...";
qDebug() << " calling handlePacketSend()...";
packetsSentThisInterval += handlePacketSend(nodeData, trueBytesSent, truePacketsSent); 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 lastAttemptedSubTree = NULL; // reset this
nodeData->writeToPacket(_packetData.getFinalizedData(), _packetData.getFinalizedSize()); nodeData->writeToPacket(_packetData.getFinalizedData(), _packetData.getFinalizedSize());

View file

@ -65,7 +65,6 @@ void EntityItem::initFromEntityItemID(const EntityItemID& entityItemID) {
} }
EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) { EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) {
//qDebug() << "EntityItem::EntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties)....";
_type = EntityTypes::Unknown; _type = EntityTypes::Unknown;
_lastEdited = 0; _lastEdited = 0;
_lastUpdated = 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. // then our modelTreeElementExtraEncodeData should include data about which properties we need to append.
if (modelTreeElementExtraEncodeData && modelTreeElementExtraEncodeData->includedItems.contains(getEntityItemID())) { if (modelTreeElementExtraEncodeData && modelTreeElementExtraEncodeData->includedItems.contains(getEntityItemID())) {
requestedProperties = modelTreeElementExtraEncodeData->includedItems.value(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(); LevelDetails modelLevel = packetData->startLevel();
quint64 lastEdited = getLastEdited(); quint64 lastEdited = getLastEdited();
//qDebug() << "EntityItem::appendEntityData() ... lastEdited=" << lastEdited;
bool successIDFits = false; bool successIDFits = false;
bool successTypeFits = false; bool successTypeFits = false;
@ -183,7 +174,6 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
// PROP_POSITION // PROP_POSITION
if (requestedProperties.getHasProperty(PROP_POSITION)) { if (requestedProperties.getHasProperty(PROP_POSITION)) {
//qDebug() << "PROP_POSITION requested...";
LevelDetails propertyLevel = packetData->startLevel(); LevelDetails propertyLevel = packetData->startLevel();
successPropertyFits = packetData->appendPosition(getPosition()); successPropertyFits = packetData->appendPosition(getPosition());
if (successPropertyFits) { if (successPropertyFits) {
@ -192,18 +182,15 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
propertyCount++; propertyCount++;
packetData->endLevel(propertyLevel); packetData->endLevel(propertyLevel);
} else { } else {
//qDebug() << "PROP_POSITION didn't fit...";
packetData->discardLevel(propertyLevel); packetData->discardLevel(propertyLevel);
appendState = OctreeElement::PARTIAL; appendState = OctreeElement::PARTIAL;
} }
} else { } else {
//qDebug() << "PROP_POSITION NOT requested...";
propertiesDidntFit -= PROP_POSITION; propertiesDidntFit -= PROP_POSITION;
} }
// PROP_RADIUS // PROP_RADIUS
if (requestedProperties.getHasProperty(PROP_RADIUS)) { if (requestedProperties.getHasProperty(PROP_RADIUS)) {
//qDebug() << "PROP_RADIUS requested...";
LevelDetails propertyLevel = packetData->startLevel(); LevelDetails propertyLevel = packetData->startLevel();
successPropertyFits = packetData->appendValue(getRadius()); successPropertyFits = packetData->appendValue(getRadius());
if (successPropertyFits) { if (successPropertyFits) {
@ -212,18 +199,15 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
propertyCount++; propertyCount++;
packetData->endLevel(propertyLevel); packetData->endLevel(propertyLevel);
} else { } else {
//qDebug() << "PROP_RADIUS didn't fit...";
packetData->discardLevel(propertyLevel); packetData->discardLevel(propertyLevel);
appendState = OctreeElement::PARTIAL; appendState = OctreeElement::PARTIAL;
} }
} else { } else {
//qDebug() << "PROP_RADIUS NOT requested...";
propertiesDidntFit -= PROP_RADIUS; propertiesDidntFit -= PROP_RADIUS;
} }
// PROP_ROTATION // PROP_ROTATION
if (requestedProperties.getHasProperty(PROP_ROTATION)) { if (requestedProperties.getHasProperty(PROP_ROTATION)) {
//qDebug() << "PROP_ROTATION requested...";
LevelDetails propertyLevel = packetData->startLevel(); LevelDetails propertyLevel = packetData->startLevel();
successPropertyFits = packetData->appendValue(getRotation()); successPropertyFits = packetData->appendValue(getRotation());
if (successPropertyFits) { if (successPropertyFits) {
@ -232,12 +216,10 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
propertyCount++; propertyCount++;
packetData->endLevel(propertyLevel); packetData->endLevel(propertyLevel);
} else { } else {
//qDebug() << "PROP_ROTATION didn't fit...";
packetData->discardLevel(propertyLevel); packetData->discardLevel(propertyLevel);
appendState = OctreeElement::PARTIAL; appendState = OctreeElement::PARTIAL;
} }
} else { } else {
//qDebug() << "PROP_ROTATION NOT requested...";
propertiesDidntFit -= PROP_ROTATION; propertiesDidntFit -= PROP_ROTATION;
} }
@ -297,7 +279,6 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
LevelDetails propertyLevel = packetData->startLevel(); LevelDetails propertyLevel = packetData->startLevel();
successPropertyFits = packetData->appendValue(getDamping()); successPropertyFits = packetData->appendValue(getDamping());
if (successPropertyFits) { if (successPropertyFits) {
//qDebug() << "success writing PROP_DAMPING=" << getDamping();
propertyFlags |= PROP_DAMPING; propertyFlags |= PROP_DAMPING;
propertiesDidntFit -= PROP_DAMPING; propertiesDidntFit -= PROP_DAMPING;
propertyCount++; propertyCount++;
@ -305,11 +286,9 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
} else { } else {
packetData->discardLevel(propertyLevel); packetData->discardLevel(propertyLevel);
appendState = OctreeElement::PARTIAL; appendState = OctreeElement::PARTIAL;
//qDebug() << "didn't fit PROP_DAMPING=" << getDamping();
} }
} else { } else {
propertiesDidntFit -= PROP_DAMPING; propertiesDidntFit -= PROP_DAMPING;
//qDebug() << "not requested PROP_DAMPING=" << getDamping();
} }
// PROP_LIFETIME, // 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 the size of the PropertyFlags shrunk, we need to shift everything down to front of packet.
if (newPropertyFlagsLength < oldPropertyFlagsLength) { if (newPropertyFlagsLength < oldPropertyFlagsLength) {
int oldSize = packetData->getUncompressedSize(); int oldSize = packetData->getUncompressedSize();
const unsigned char* modelItemData = packetData->getUncompressedData(propertyFlagsOffset + oldPropertyFlagsLength); const unsigned char* modelItemData = packetData->getUncompressedData(propertyFlagsOffset + oldPropertyFlagsLength);
int modelItemDataLength = endOfEntityItemData - startOfEntityItemData; int modelItemDataLength = endOfEntityItemData - startOfEntityItemData;
int newEntityItemDataStart = propertyFlagsOffset + newPropertyFlagsLength; int newEntityItemDataStart = propertyFlagsOffset + newPropertyFlagsLength;
packetData->updatePriorBytes(newEntityItemDataStart, modelItemData, modelItemDataLength); packetData->updatePriorBytes(newEntityItemDataStart, modelItemData, modelItemDataLength);
int newSize = oldSize - (oldPropertyFlagsLength - newPropertyFlagsLength); int newSize = oldSize - (oldPropertyFlagsLength - newPropertyFlagsLength);
qDebug() << "EntityItem::appendEntityData()... SHRINKING CASE??? DID WE TEST THIS!!!! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<";
packetData->setUncompressedSize(newSize); packetData->setUncompressedSize(newSize);
} else { } 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 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 any part of the model items didn't fit, then the element is considered partial
if (appendState != OctreeElement::COMPLETED) { if (appendState != OctreeElement::COMPLETED) {
// add this item into our list for the next appendElementData() pass // add this item into our list for the next appendElementData() pass
modelTreeElementExtraEncodeData->includedItems.insert(getEntityItemID(), propertiesDidntFit); modelTreeElementExtraEncodeData->includedItems.insert(getEntityItemID(), propertiesDidntFit);
qDebug() << "EntityItem::appendEntityData() not complete... (appendState != OctreeElement::COMPLETED)";
//qDebug() << " propertiesDidntFit...";
//propertiesDidntFit.debugDumpBits();
} }
return appendState; return appendState;
@ -424,7 +389,11 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
bool wantDebug = false; bool wantDebug = false;
if (args.bitstreamVersion < VERSION_ENTITIES_SUPPORT_SPLIT_MTU) { 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; return 0;
} }
@ -455,14 +424,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
dataAt += encodedID.size(); dataAt += encodedID.size();
bytesRead += encodedID.size(); bytesRead += encodedID.size();
/**
ByteCountCoded<quint32> idCoder = encodedID;
encodedID = idCoder; // determine true length
dataAt += encodedID.size();
bytesRead += encodedID.size();
_id = idCoder;
**/
// type // type
QByteArray encodedType = originalDataBuffer.mid(bytesRead); // maximum possible size QByteArray encodedType = originalDataBuffer.mid(bytesRead); // maximum possible size
ByteCountCoded<quint32> typeCoder = encodedType; ByteCountCoded<quint32> typeCoder = encodedType;
@ -510,7 +471,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
quint64 updateDelta = updateDeltaCoder; quint64 updateDelta = updateDeltaCoder;
if (overwriteLocalData) { if (overwriteLocalData) {
_lastUpdated = _lastEdited + updateDelta; // don't adjust for clock skew since we already did that for _lastEdited _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 encodedUpdateDelta = updateDeltaCoder; // determine true length
dataAt += encodedUpdateDelta.size(); dataAt += encodedUpdateDelta.size();
@ -523,12 +483,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
bytesRead += propertyFlags.getEncodedLength(); bytesRead += propertyFlags.getEncodedLength();
/*
qDebug() << "EntityItem::readEntityDataFromBuffer() just read properties from buffer....";
qDebug() << " propertyFlags...";
propertyFlags.debugDumpBits();
*/
// PROP_POSITION // PROP_POSITION
if (propertyFlags.getHasProperty(PROP_POSITION)) { if (propertyFlags.getHasProperty(PROP_POSITION)) {
@ -604,12 +558,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
dataAt += sizeof(value); dataAt += sizeof(value);
bytesRead += sizeof(value); bytesRead += sizeof(value);
//qDebug() << "property included in buffer PROP_DAMPING=" << value;
if (overwriteLocalData) { if (overwriteLocalData) {
_damping = value; _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) { 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; bool somethingChanged = false;
if (properties._positionChanged || forceCopy) { if (properties._positionChanged || forceCopy) {
setPosition(properties._position / (float) TREE_SCALE); setPosition(properties._position / (float) TREE_SCALE);
@ -859,7 +805,6 @@ bool EntityItem::setProperties(const EntityItemProperties& properties, bool forc
if (properties._velocityChanged || forceCopy) { if (properties._velocityChanged || forceCopy) {
setVelocity(properties._velocity / (float) TREE_SCALE); setVelocity(properties._velocity / (float) TREE_SCALE);
//qDebug() << "EntityItem::setProperties() AFTER setVelocity() getVelocity()=" << getVelocity();
somethingChanged = true; somethingChanged = true;
} }
@ -872,8 +817,6 @@ bool EntityItem::setProperties(const EntityItemProperties& properties, bool forc
somethingChanged = true; somethingChanged = true;
} }
//qDebug() << ">>>>>>>>>>>>>>>>>>> EntityItem::setProperties(); <<<<<<<<<<<<<<<<<<<<<<<<< properties._dampingChanged=" << properties._dampingChanged;
if (properties._dampingChanged || forceCopy) { if (properties._dampingChanged || forceCopy) {
setDamping(properties._damping); setDamping(properties._damping);
somethingChanged = true; somethingChanged = true;

View file

@ -876,7 +876,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
EntityItemID& entityID, EntityItemProperties& properties) { EntityItemID& entityID, EntityItemProperties& properties) {
bool valid = false; bool valid = false;
bool wantDebug = true; bool wantDebug = false;
if (wantDebug) { if (wantDebug) {
qDebug() << "EntityItemProperties::decodeEntityEditPacket() bytesToRead=" << bytesToRead; qDebug() << "EntityItemProperties::decodeEntityEditPacket() bytesToRead=" << bytesToRead;
} }
@ -948,8 +948,6 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
valid = true; valid = true;
} }
//qDebug() << "EntityItemProperties::decodeEntityEditPacket() entityID=" << entityID;
// Entity Type... // Entity Type...
QByteArray encodedType((const char*)dataAt, (bytesToRead - processedBytes)); QByteArray encodedType((const char*)dataAt, (bytesToRead - processedBytes));
ByteCountCoded<quint32> typeCoder = encodedType; ByteCountCoded<quint32> typeCoder = encodedType;
@ -1087,10 +1085,6 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
properties.setModelURL(modelURLString); properties.setModelURL(modelURLString);
} }
if (wantDebug) {
qDebug() << "EntityItem EntityItem::decodeEntityEditPacket() model URL=" << properties.getModelURL();
}
// PROP_ANIMATION_URL // PROP_ANIMATION_URL
if (propertyFlags.getHasProperty(PROP_ANIMATION_URL)) { if (propertyFlags.getHasProperty(PROP_ANIMATION_URL)) {
// animationURL // animationURL
@ -1130,14 +1124,6 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
processedBytes += sizeof(animationIsPlaying); processedBytes += sizeof(animationIsPlaying);
properties.setAnimationIsPlaying(animationIsPlaying); properties.setAnimationIsPlaying(animationIsPlaying);
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const bool wantDebugging = false;
if (wantDebugging) {
qDebug("EntityItem::fromEditPacket()...");
qDebug() << " EntityItem id in packet:" << editID;
//newEntityItem.debugDump();
}
return valid; return valid;
} }
@ -1149,7 +1135,10 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityItemID, bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityItemID,
unsigned char* outputBuffer, size_t maxLength, size_t& outputLength) { unsigned char* outputBuffer, size_t maxLength, size_t& outputLength) {
const bool wantDebug = false;
if (wantDebug) {
qDebug() << "EntityItemProperties::encodeEraseEntityMessage()"; qDebug() << "EntityItemProperties::encodeEraseEntityMessage()";
}
unsigned char* copyAt = outputBuffer; unsigned char* copyAt = outputBuffer;
@ -1158,12 +1147,14 @@ bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityIt
copyAt += sizeof(numberOfIds); copyAt += sizeof(numberOfIds);
outputLength = sizeof(numberOfIds); outputLength = sizeof(numberOfIds);
if (wantDebug) {
qDebug() << " numberOfIds=" << numberOfIds; qDebug() << " numberOfIds=" << numberOfIds;
}
QUuid entityID = entityItemID.id; QUuid entityID = entityItemID.id;
QByteArray encodedEntityID = entityID.toRfc4122(); QByteArray encodedEntityID = entityID.toRfc4122();
{ if (wantDebug) {
QDebug debugA = qDebug(); QDebug debugA = qDebug();
debugA << " encodedEntityID contents:"; debugA << " encodedEntityID contents:";
outputBufferBits((unsigned char*)encodedEntityID.constData(), encodedEntityID.size(), &debugA); outputBufferBits((unsigned char*)encodedEntityID.constData(), encodedEntityID.size(), &debugA);
@ -1173,17 +1164,17 @@ bool EntityItemProperties::encodeEraseEntityMessage(const EntityItemID& entityIt
copyAt += NUM_BYTES_RFC4122_UUID; copyAt += NUM_BYTES_RFC4122_UUID;
outputLength += NUM_BYTES_RFC4122_UUID; outputLength += NUM_BYTES_RFC4122_UUID;
if (wantDebug) {
qDebug() << " entityID=" << entityID; qDebug() << " entityID=" << entityID;
qDebug() << " outputLength=" << outputLength; qDebug() << " outputLength=" << outputLength;
qDebug() << " NUM_BYTES_RFC4122_UUID=" << NUM_BYTES_RFC4122_UUID; qDebug() << " NUM_BYTES_RFC4122_UUID=" << NUM_BYTES_RFC4122_UUID;
qDebug() << " encodedEntityID.size()=" << encodedEntityID.size(); qDebug() << " encodedEntityID.size()=" << encodedEntityID.size();
{ {
QDebug debug = qDebug(); QDebug debug = qDebug();
debug << " edit data contents:"; debug << " edit data contents:";
outputBufferBits(outputBuffer, outputLength, &debug); outputBufferBits(outputBuffer, outputLength, &debug);
} }
}
return true; return true;
} }

View file

@ -763,10 +763,14 @@ void EntityTree::deleteEntity(const EntityItemID& entityID) {
void EntityTree::deleteEntities(QSet<EntityItemID> entityIDs) { void EntityTree::deleteEntities(QSet<EntityItemID> entityIDs) {
// NOTE: callers must lock the tree before using this method // NOTE: callers must lock the tree before using this method
const bool wantDebug = false;
if (wantDebug) {
qDebug() << "EntityTree::EntityTree::deleteEntities().... "; qDebug() << "EntityTree::EntityTree::deleteEntities().... ";
qDebug() << " entityIDs=" << entityIDs; qDebug() << " entityIDs=" << entityIDs;
qDebug() << " BEFORE map..."; qDebug() << " BEFORE map...";
debugDumpMap(); debugDumpMap();
}
DeleteEntityOperator theOperator(this); DeleteEntityOperator theOperator(this);
foreach(const EntityItemID& entityID, entityIDs) { foreach(const EntityItemID& entityID, entityIDs) {
@ -777,7 +781,6 @@ void EntityTree::deleteEntities(QSet<EntityItemID> entityIDs) {
recurseTreeWithOperator(&theOperator); recurseTreeWithOperator(&theOperator);
_isDirty = true; _isDirty = true;
bool wantDebug = false;
if (wantDebug) { if (wantDebug) {
foreach(const EntityItemID& entityID, entityIDs) { foreach(const EntityItemID& entityID, entityIDs) {
EntityTreeElement* containingElement = getContainingElement(entityID); EntityTreeElement* containingElement = getContainingElement(entityID);
@ -1095,7 +1098,7 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char
} }
case PacketTypeEntityAddOrEdit: { case PacketTypeEntityAddOrEdit: {
qDebug() << "EntityTree::processEditPacketData()...."; const bool wantDebug = false;
EntityItemID entityItemID; EntityItemID entityItemID;
EntityItemProperties properties; EntityItemProperties properties;
@ -1103,12 +1106,14 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char
bool validEditPacket = EntityItemProperties::decodeEntityEditPacket(editData, maxLength, bool validEditPacket = EntityItemProperties::decodeEntityEditPacket(editData, maxLength,
processedBytes, entityItemID, properties); processedBytes, entityItemID, properties);
if (wantDebug) {
qDebug() << "EntityTree::processEditPacketData().... "; qDebug() << "EntityTree::processEditPacketData().... ";
qDebug() << " validEditPacket=" << validEditPacket; qDebug() << " validEditPacket=" << validEditPacket;
qDebug() << " processedBytes=" << processedBytes; qDebug() << " processedBytes=" << processedBytes;
qDebug() << " entityItemID=" << entityItemID; qDebug() << " entityItemID=" << entityItemID;
qDebug() << " BEFORE map..."; qDebug() << " BEFORE map...";
debugDumpMap(); debugDumpMap();
}
// If we got a valid edit packet, then it could be a new entity or it could be an update to // 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 // an existing entity... handle appropriately
@ -1127,9 +1132,15 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char
} }
} else { } else {
// this is a new entity... assign a new entityID // 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); entityItemID = assignEntityID(entityItemID);
qDebug() << "EntityTree::processEditPacketData() ... AFTER assignEntityID()... entityItemID=" << entityItemID; if (wantDebug) {
qDebug() << "EntityTree::processEditPacketData() ... "
"AFTER assignEntityID()... entityItemID=" << entityItemID;
}
EntityItem* newEntity = addEntity(entityItemID, properties); EntityItem* newEntity = addEntity(entityItemID, properties);
if (newEntity) { if (newEntity) {

View file

@ -54,13 +54,13 @@ EntityTreeElement* EntityTreeElement::addChildAtIndex(int index) {
OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData* packetData, OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData* packetData,
EncodeBitstreamParams& params) const { EncodeBitstreamParams& params) const {
qDebug() << "START OF ELEMENT packetData->uncompressed size:" << packetData->getUncompressedSize();
bool wantDebug = false; bool wantDebug = false;
if (wantDebug) { if (wantDebug) {
qDebug() << "EntityTreeElement::appendElementData()"; qDebug() << "EntityTreeElement::appendElementData()";
qDebug() << " getAACube()=" << getAACube(); qDebug() << " getAACube()=" << getAACube();
qDebug() << " START OF ELEMENT packetData->uncompressed size:" << packetData->getUncompressedSize();
} }
OctreeElement::AppendState appendElementState = OctreeElement::COMPLETED; // assume the best... OctreeElement::AppendState appendElementState = OctreeElement::COMPLETED; // assume the best...
@ -83,7 +83,9 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
uint16_t actualNumberOfEntities = 0; uint16_t actualNumberOfEntities = 0;
QVector<uint16_t> indexesOfEntitiesToInclude; QVector<uint16_t> indexesOfEntitiesToInclude;
if (wantDebug) {
qDebug() << "EntityTreeElement::appendElementData() _entityItems->size()=" << _entityItems->size(); qDebug() << "EntityTreeElement::appendElementData() _entityItems->size()=" << _entityItems->size();
}
for (uint16_t i = 0; i < _entityItems->size(); i++) { for (uint16_t i = 0; i < _entityItems->size(); i++) {
EntityItem* entity = (*_entityItems)[i]; EntityItem* entity = (*_entityItems)[i];
@ -91,17 +93,22 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
if (hadElementExtraData) { if (hadElementExtraData) {
includeThisEntity = entityTreeElementExtraEncodeData->includedItems.contains(entity->getEntityItemID()); includeThisEntity = entityTreeElementExtraEncodeData->includedItems.contains(entity->getEntityItemID());
if (wantDebug) {
qDebug() << " hadElementExtraData=" << hadElementExtraData; qDebug() << " hadElementExtraData=" << hadElementExtraData;
qDebug() << " entity[" << i <<"].entityItemID=" << entity->getEntityItemID(); qDebug() << " entity[" << i <<"].entityItemID=" << entity->getEntityItemID();
qDebug() << " entity[" << i <<"].includeThisEntity=" << includeThisEntity; qDebug() << " entity[" << i <<"].includeThisEntity=" << includeThisEntity;
} }
}
if (includeThisEntity && params.viewFrustum) { if (includeThisEntity && params.viewFrustum) {
AACube entityCube = entity->getAACube(); AACube entityCube = entity->getAACube();
entityCube.scale(TREE_SCALE); entityCube.scale(TREE_SCALE);
if (params.viewFrustum->cubeInFrustum(entityCube) == ViewFrustum::OUTSIDE) { if (params.viewFrustum->cubeInFrustum(entityCube) == ViewFrustum::OUTSIDE) {
includeThisEntity = false; // out of view, don't include it 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(); int numberOfEntitiesOffset = packetData->getUncompressedByteOffset();
bool successAppendEntityCount = packetData->appendValue(numberOfEntities); bool successAppendEntityCount = packetData->appendValue(numberOfEntities);
if (wantDebug) {
qDebug() << " numberOfEntities=" << numberOfEntities; qDebug() << " numberOfEntities=" << numberOfEntities;
qDebug() << " successAppendEntityCount=" << successAppendEntityCount; qDebug() << " successAppendEntityCount=" << successAppendEntityCount;
qDebug() << "--- before child loop ---"; qDebug() << "--- before child loop ---";
qDebug() << " packetData->getUncompressedSize()=" << packetData->getUncompressedSize() << "line:" << __LINE__; qDebug() << " packetData->getUncompressedSize()=" << packetData->getUncompressedSize() << "line:" << __LINE__;
qDebug() << " packetData->getReservedBytes()=" << packetData->getReservedBytes(); qDebug() << " packetData->getReservedBytes()=" << packetData->getReservedBytes();
}
if (successAppendEntityCount) { if (successAppendEntityCount) {
if (true || wantDebug) { if (wantDebug) {
qDebug() << "EntityTreeElement::appendElementData()"; qDebug() << "EntityTreeElement::appendElementData()";
qDebug() << " indexesOfEntitiesToInclude loop.... numberOfEntities=" << numberOfEntities; qDebug() << " indexesOfEntitiesToInclude loop.... numberOfEntities=" << numberOfEntities;
} }
@ -130,46 +139,59 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
foreach (uint16_t i, indexesOfEntitiesToInclude) { foreach (uint16_t i, indexesOfEntitiesToInclude) {
EntityItem* entity = (*_entityItems)[i]; EntityItem* entity = (*_entityItems)[i];
if (true || wantDebug) { if (wantDebug) {
qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"].entityItemID=" << entity->getEntityItemID(); qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"].entityItemID=" << entity->getEntityItemID();
} }
LevelDetails entityLevel = packetData->startLevel(); LevelDetails entityLevel = packetData->startLevel();
if (wantDebug) {
qDebug() << "--- BEFORE entity ---"; qDebug() << "--- BEFORE entity ---";
qDebug() << " packetData->getUncompressedSize()=" << packetData->getUncompressedSize() << "line:" << __LINE__; qDebug() << " packetData->getUncompressedSize=" << packetData->getUncompressedSize() << "line:" << __LINE__;
qDebug() << " packetData->getReservedBytes()=" << packetData->getReservedBytes(); qDebug() << " packetData->getReservedBytes=" << packetData->getReservedBytes();
}
OctreeElement::AppendState appendEntityState = entity->appendEntityData(packetData, params, entityTreeElementExtraEncodeData); OctreeElement::AppendState appendEntityState = entity->appendEntityData(packetData,
params, entityTreeElementExtraEncodeData);
if (wantDebug) {
qDebug() << "--- AFTER entity ---"; qDebug() << "--- AFTER entity ---";
qDebug() << " packetData->getUncompressedSize()=" << packetData->getUncompressedSize() << "line:" << __LINE__; qDebug() << " packetData->getUncompressedSize=" << packetData->getUncompressedSize() << "line:" << __LINE__;
qDebug() << " packetData->getReservedBytes()=" << packetData->getReservedBytes(); qDebug() << " packetData->getReservedBytes=" << packetData->getReservedBytes();
}
// If none of this entity data was able to be appended, then discard it // If none of this entity data was able to be appended, then discard it
// and don't include it in our entity count // and don't include it in our entity count
if (appendEntityState == OctreeElement::NONE) { if (appendEntityState == OctreeElement::NONE) {
if (wantDebug) {
qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] DIDN'T FIT!!!"; qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] DIDN'T FIT!!!";
}
packetData->discardLevel(entityLevel); packetData->discardLevel(entityLevel);
} else { } else {
// If either ALL or some of it got appended, then end the level (commit it) // 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 // and include the entity in our final count of entities
packetData->endLevel(entityLevel); packetData->endLevel(entityLevel);
actualNumberOfEntities++; actualNumberOfEntities++;
if (wantDebug) {
qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] ALL OR SOME FIT!!!"; 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 the entity item got completely appended, then we can remove it from the extra encode data
if (appendEntityState == OctreeElement::COMPLETED) { if (appendEntityState == OctreeElement::COMPLETED) {
entityTreeElementExtraEncodeData->includedItems.remove(entity->getEntityItemID()); entityTreeElementExtraEncodeData->includedItems.remove(entity->getEntityItemID());
if (wantDebug) {
qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] IT ALL FIT!!!"; qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] IT ALL FIT!!!";
}
} else { } else {
if (wantDebug) {
if (appendEntityState == OctreeElement::NONE) { if (appendEntityState == OctreeElement::NONE) {
qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] DIDN'T FIT!!!"; qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] DIDN'T FIT!!!";
} else { } else {
qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] PARTIAL FIT!!!"; qDebug() << " indexesOfEntitiesToInclude.... entity[" << i <<"] PARTIAL FIT!!!";
} }
} }
}
// If any part of the entity items didn't fit, then the element is considered partial // If any part of the entity items didn't fit, then the element is considered partial
// NOTE: if the entity item didn't fit or only partially fit, then the entity item should have // NOTE: if the entity item didn't fit or only partially fit, then the entity item should have
@ -180,29 +202,37 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
} }
} }
if (wantDebug) {
qDebug() << "--- done with loop ---"; qDebug() << "--- done with loop ---";
qDebug() << " actualNumberOfEntities=" << actualNumberOfEntities; qDebug() << " actualNumberOfEntities=" << actualNumberOfEntities;
qDebug() << " numberOfEntities=" << numberOfEntities; qDebug() << " numberOfEntities=" << numberOfEntities;
qDebug() << " appendElementState=" << appendElementState; qDebug() << " appendElementState=" << appendElementState;
}
// If we were provided with extraEncodeData, and we allocated and/or got entityTreeElementExtraEncodeData // 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 // then we need to do some additional processing, namely make sure our extraEncodeData is up to date for
// this octree element. // this octree element.
if (extraEncodeData && entityTreeElementExtraEncodeData) { if (extraEncodeData && entityTreeElementExtraEncodeData) {
if (wantDebug) {
qDebug() << " handling extra encode data...."; 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 after processing we have some includedItems left in it, then make sure we re-add it back to our map
if (entityTreeElementExtraEncodeData->includedItems.size()) { if (entityTreeElementExtraEncodeData->includedItems.size()) {
extraEncodeData->insert(this, entityTreeElementExtraEncodeData); extraEncodeData->insert(this, entityTreeElementExtraEncodeData);
if (wantDebug) {
qDebug() << " RE INSERT OUR EXTRA DATA...."; qDebug() << " RE INSERT OUR EXTRA DATA....";
}
} else { } else {
// otherwise, clean things up... // otherwise, clean things up...
extraEncodeData->remove(this); extraEncodeData->remove(this);
delete entityTreeElementExtraEncodeData; delete entityTreeElementExtraEncodeData;
if (wantDebug) {
qDebug() << " REMOVE OUR EXTRA DATA...."; qDebug() << " REMOVE OUR EXTRA DATA....";
} }
} }
}
// Determine if no entities at all were able to fit // Determine if no entities at all were able to fit
bool noEntitiesFit = (numberOfEntities > 0 && actualNumberOfEntities == 0); bool noEntitiesFit = (numberOfEntities > 0 && actualNumberOfEntities == 0);
@ -212,14 +242,17 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
if (!noEntitiesFit && numberOfEntities != actualNumberOfEntities) { if (!noEntitiesFit && numberOfEntities != actualNumberOfEntities) {
successUpdateEntityCount = packetData->updatePriorBytes(numberOfEntitiesOffset, successUpdateEntityCount = packetData->updatePriorBytes(numberOfEntitiesOffset,
(const unsigned char*)&actualNumberOfEntities, sizeof(actualNumberOfEntities)); (const unsigned char*)&actualNumberOfEntities, sizeof(actualNumberOfEntities));
if (wantDebug) {
qDebug() << " UPDATE NUMER OF ENTITIES.... actualNumberOfEntities=" << actualNumberOfEntities; 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 // If we weren't able to update our entity count, or we couldn't fit any entities, then
// we should discard our element and return a result of NONE // we should discard our element and return a result of NONE
if (!successUpdateEntityCount || noEntitiesFit) { if (!successUpdateEntityCount || noEntitiesFit) {
packetData->discardLevel(elementLevel); packetData->discardLevel(elementLevel);
appendElementState = OctreeElement::NONE; appendElementState = OctreeElement::NONE;
if (wantDebug) {
qDebug() << " something went wrong... discardLevel().... appendElementState = OctreeElement::NONE;"; qDebug() << " something went wrong... discardLevel().... appendElementState = OctreeElement::NONE;";
qDebug() << " successUpdateEntityCount=" << successUpdateEntityCount; qDebug() << " successUpdateEntityCount=" << successUpdateEntityCount;
qDebug() << " noEntitiesFit=" << noEntitiesFit; qDebug() << " noEntitiesFit=" << noEntitiesFit;
@ -228,16 +261,19 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
} else { } else {
qDebug() << " what happened to extraEncodeData??"; qDebug() << " what happened to extraEncodeData??";
} }
}
} else { } else {
packetData->endLevel(elementLevel); packetData->endLevel(elementLevel);
if (wantDebug) {
qDebug() << " looks good endLevel().... appendElementState=" << appendElementState; qDebug() << " looks good endLevel().... appendElementState=" << appendElementState;
qDebug() << " successUpdateEntityCount=" << successUpdateEntityCount; qDebug() << " successUpdateEntityCount=" << successUpdateEntityCount;
qDebug() << " noEntitiesFit=" << noEntitiesFit; qDebug() << " noEntitiesFit=" << noEntitiesFit;
} }
}
if (wantDebug) {
qDebug() << "END OF ELEMENT packetData->uncompressed size:" << packetData->getUncompressedSize(); qDebug() << "END OF ELEMENT packetData->uncompressed size:" << packetData->getUncompressedSize();
}
return appendElementState; return appendElementState;
} }
@ -405,10 +441,6 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con
if (localDistance < distance) { if (localDistance < distance) {
distance = localDistance; distance = localDistance;
face = localFace; face = localFace;
//qDebug() << "about to set intersectedObject=" << entity;
//entity->debugDump();
*intersectedObject = (void*)entity; *intersectedObject = (void*)entity;
somethingIntersected = true; somethingIntersected = true;
} }
@ -417,10 +449,6 @@ bool EntityTreeElement::findDetailedRayIntersection(const glm::vec3& origin, con
} else if (localDistance < distance) { } else if (localDistance < distance) {
distance = localDistance; distance = localDistance;
face = localFace; face = localFace;
//qDebug() << "about to set intersectedObject=" << entity;
//entity->debugDump();
*intersectedObject = (void*)entity; *intersectedObject = (void*)entity;
somethingIntersected = true; somethingIntersected = true;
} }
@ -565,35 +593,13 @@ EntityItem* EntityTreeElement::getEntityWithEntityItemID(const EntityItemID& id)
return foundEntity; 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 EntityTreeElement::removeEntityWithEntityItemID(const EntityItemID& id) {
bool foundEntity = false; bool foundEntity = false;
uint16_t numberOfEntities = _entityItems->size(); uint16_t numberOfEntities = _entityItems->size();
for (uint16_t i = 0; i < numberOfEntities; i++) { for (uint16_t i = 0; i < numberOfEntities; i++) {
if ((*_entityItems)[i]->getEntityItemID() == id) { if ((*_entityItems)[i]->getEntityItemID() == id) {
foundEntity = true; 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); _entityItems->removeAt(i);
//qDebug() << "EntityTreeElement::removeEntityWithEntityItemID() AFTER _entityItems->removeAt(i); element=" << this << "entity=" << entityItem << "id=" << entityItem->getEntityItemID() << "bestFit=" << bestFitEntityBounds(entityItem);
break; break;
} }
} }
@ -606,10 +612,7 @@ bool EntityTreeElement::removeEntityItem(const EntityItem* entity) {
for (uint16_t i = 0; i < numberOfEntities; i++) { for (uint16_t i = 0; i < numberOfEntities; i++) {
if ((*_entityItems)[i] == entity) { if ((*_entityItems)[i] == entity) {
foundEntity = true; 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); _entityItems->removeAt(i);
//qDebug() << "EntityTreeElement::removeEntityItem() AFTER _entityItems->removeAt(i); element=" << this << "entity=" << entityItem << "id=" << entityItem->getEntityItemID() << "bestFit=" << bestFitEntityBounds(entityItem);
break; break;
} }
} }

View file

@ -33,14 +33,17 @@ Model properties:
// //
// REQUIRED TO DO: // REQUIRED TO DO:
0) test animation again... 1) random crashes on moving (I think things going out of bounds???)
2) some jutter with moving entities
1) verify lots of models in single element works 3) test animation again...
-- repro case - run editModelsExample.js -- create 10 models in the same octree element
4) clear all entities when changing domains?
5) what to do with entities
2) memory leaks??? 4) memory leaks???
3) Import/Export Models - verify it works. /copy/paste?? 5) Import/Export Models - verify it works. /copy/paste??
22a) void ModelItemProperties::copyFromNewModelItem(const ModelItem& modelItem); // XXX ??? Do we need this???? 22a) void ModelItemProperties::copyFromNewModelItem(const ModelItem& modelItem); // XXX ??? Do we need this????
22b) Local Entities Overlay - from Local Models Overlay 22b) Local Entities Overlay - from Local Models Overlay
22c) void ModelTree::sendModels(ModelEditPacketSender* packetSender, float x, float y, float z).... 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<ModelItem*>& foundModels)... DONE -- 22d) void ModelTree::findModelsInCube(const AACube& cube, QVector<ModelItem*>& foundModels)...
DONE -- 22e) void ModelTreeElement::getModelsInside(const AACube& box, QVector<ModelItem*>& foundModels)... DONE -- 22e) void ModelTreeElement::getModelsInside(const AACube& box, QVector<ModelItem*>& foundModels)...
4) support sitpoints and referentials.... 6) support sitpoints and referentials....
5) Referentials???? 7) Referentials????
For sitting points and referentials you can kill two birds with one stone. 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 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. Move model with another avatar.
Observe first avatar moving. 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??? 11) What happens if the edit properties don't fit in a single message MTU???
10) animations not always working????? 12) animations not always working?????
11) EntityItemProperties::decodeEntityEditPacket() doesn't include PROP_SCRIPT 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: // NICE TO DO:
@ -241,3 +247,5 @@ Model properties:
// SOLVED -- 0) render performance of models... // SOLVED -- 0) render performance of models...
// SOLVED -- a) make getModel() faster... consider storing the Model* in the actual EntityItem class // SOLVED -- a) make getModel() faster... consider storing the Model* in the actual EntityItem class
// SOLVED -- b) only call simulate when properties change // 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

View file

@ -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. // Make our local buffer large enough to handle writing at this level in case we need to.
LevelDetails thisLevelKey = packetData->startLevel(); 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); 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 we can't reserve our minimum bytes then we can discard this level and return as if none of this level fits

View file

@ -61,7 +61,10 @@ bool OctreePacketData::append(const unsigned char* data, int length) {
_bytesAvailable -= length; _bytesAvailable -= length;
success = true; success = true;
_dirty = true; _dirty = true;
} else { }
const bool wantDebug = false;
if (wantDebug && !success) {
qDebug() << "OctreePacketData::append(const unsigned char* data, int length) FAILING...."; qDebug() << "OctreePacketData::append(const unsigned char* data, int length) FAILING....";
qDebug() << " length=" << length; qDebug() << " length=" << length;
qDebug() << " _bytesAvailable=" << _bytesAvailable; 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 OctreePacketData::updatePriorBytes(int offset, const unsigned char* replacementBytes, int length) {
bool success = false; bool success = false;
if (length >= 0 && offset >= 0 && ((offset + length) <= _bytesInUse)) { if (length >= 0 && offset >= 0 && ((offset + length) <= _bytesInUse)) {
// we probably need to use memmove!!!
if (replacementBytes >= &_uncompressed[offset] && replacementBytes <= &_uncompressed[offset + length]) { 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 memmove(&_uncompressed[offset], replacementBytes, length); // copy new content with overlap safety
} else { } else {
memcpy(&_uncompressed[offset], replacementBytes, length); // copy new content memcpy(&_uncompressed[offset], replacementBytes, length); // copy new content