diff --git a/libraries/models/src/ModelTree.cpp b/libraries/models/src/ModelTree.cpp index 4e92544f40..637079560b 100644 --- a/libraries/models/src/ModelTree.cpp +++ b/libraries/models/src/ModelTree.cpp @@ -108,6 +108,7 @@ bool FindAndUpdateModelOperator::PostRecursion(OctreeElement* element) { return !_found; // if we haven't yet found it, keep looking } +// TODO: improve this to not use multiple recursions void ModelTree::storeModel(const ModelItem& model, const SharedNodePointer& senderNode) { // First, look for the existing model in the tree.. FindAndUpdateModelOperator theOperator(model); @@ -118,8 +119,13 @@ void ModelTree::storeModel(const ModelItem& model, const SharedNodePointer& send AABox modelBox = model.getAABox(); ModelTreeElement* element = (ModelTreeElement*)getOrCreateChildElementContaining(model.getAABox()); element->storeModel(model); + + // In the case where we stored it, we also need to mark the entire "path" down to the model as + // having changed. Otherwise viewers won't see this change. So we call this recursion now that + // we know it will be found, this find/update will correctly mark the tree as changed. + recurseTreeWithOperator(&theOperator); } - // what else do we need to do here to get reaveraging to work + _isDirty = true; } diff --git a/libraries/models/src/ModelTree.h b/libraries/models/src/ModelTree.h index 10ef62c0a0..ddd8417db7 100644 --- a/libraries/models/src/ModelTree.h +++ b/libraries/models/src/ModelTree.h @@ -41,6 +41,8 @@ public: virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength, const unsigned char* editData, int maxLength, const SharedNodePointer& senderNode); + virtual bool recurseChildrenWithData() const { return false; } + virtual void update(); void storeModel(const ModelItem& model, const SharedNodePointer& senderNode = SharedNodePointer()); diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp index 128677ff2b..b352096673 100644 --- a/libraries/octree/src/Octree.cpp +++ b/libraries/octree/src/Octree.cpp @@ -1389,6 +1389,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element, keepDiggingDeeper = (inViewNotLeafCount > 0); if (continueThisLevel && keepDiggingDeeper) { + // at this point, we need to iterate the children who are in view, even if not colored // and we need to determine if there's a deeper tree below them that we care about. // @@ -1424,6 +1425,8 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element, int childTreeBytesOut = 0; + // TODO - UPDATE THIS COMMENT!!! + // // XXXBHG - Note, this seems like the correct logic here, if we included the color in this packet, then // the LOD logic determined that the child nodes would not be visible... and if so, we shouldn't recurse // them further. But... for some time now the code has included and recursed into these child nodes, which @@ -1433,7 +1436,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element, // // This only applies in the view frustum case, in other cases, like file save and copy/past where // no viewFrustum was requested, we still want to recurse the child tree. - if (!params.viewFrustum || !oneAtBit(childrenColoredBits, originalIndex)) { + if (recurseChildrenWithData() || !params.viewFrustum || !oneAtBit(childrenColoredBits, originalIndex)) { childTreeBytesOut = encodeTreeBitstreamRecursion(childElement, packetData, bag, params, thisLevel, nodeLocationThisView); } @@ -1519,16 +1522,6 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* element, } // end keepDiggingDeeper // At this point all our BitMasks are complete... so let's output them to see how they compare... - /** - printf("This Level's BitMasks: childInTree:"); - outputBits(childrenExistInTreeBits, false, true); - printf(" childInPacket:"); - outputBits(childrenExistInPacketBits, false, true); - printf(" childrenColored:"); - outputBits(childrenColoredBits, false, true); - qDebug(""); - **/ - // if we were unable to fit this level in our packet, then rewind and add it to the element bag for // sending later... if (continueThisLevel) { diff --git a/libraries/octree/src/Octree.h b/libraries/octree/src/Octree.h index 84212586f8..1e71884faa 100644 --- a/libraries/octree/src/Octree.h +++ b/libraries/octree/src/Octree.h @@ -209,6 +209,8 @@ public: virtual bool handlesEditPacketType(PacketType packetType) const { return false; } virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength, const unsigned char* editData, int maxLength, const SharedNodePointer& sourceNode) { return 0; } + + virtual bool recurseChildrenWithData() const { return true; } virtual void update() { }; // nothing to do by default