mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 06:53:59 +02:00
remove encode/deleting/start/done guards
This commit is contained in:
parent
1f88ede1aa
commit
af71359c60
2 changed files with 1 additions and 99 deletions
|
@ -355,15 +355,7 @@ void Octree::deleteOctalCodeFromTree(const unsigned char* codeBuffer, bool colla
|
|||
|
||||
OctreeElement* node = _rootNode;
|
||||
|
||||
// We can't encode and delete nodes at the same time, so we guard against deleting any node that is actively
|
||||
// being encoded. And we stick that code on our pendingDelete list.
|
||||
if (isEncoding(codeBuffer)) {
|
||||
queueForLaterDelete(codeBuffer);
|
||||
} else {
|
||||
startDeleting(codeBuffer);
|
||||
deleteOctalCodeFromTreeRecursion(node, &args);
|
||||
doneDeleting(codeBuffer);
|
||||
}
|
||||
deleteOctalCodeFromTreeRecursion(node, &args);
|
||||
}
|
||||
|
||||
void Octree::deleteOctalCodeFromTreeRecursion(OctreeElement* node, void* extraData) {
|
||||
|
@ -796,11 +788,8 @@ int Octree::encodeTreeBitstream(OctreeElement* node,
|
|||
return bytesWritten;
|
||||
}
|
||||
|
||||
startEncoding(node);
|
||||
|
||||
// If we're at a node that is out of view, then we can return, because no nodes below us will be in view!
|
||||
if (params.viewFrustum && !node->isInView(*params.viewFrustum)) {
|
||||
doneEncoding(node);
|
||||
params.stopReason = EncodeBitstreamParams::OUT_OF_VIEW;
|
||||
return bytesWritten;
|
||||
}
|
||||
|
@ -824,7 +813,6 @@ int Octree::encodeTreeBitstream(OctreeElement* node,
|
|||
|
||||
// If the octalcode couldn't fit, then we can return, because no nodes below us will fit...
|
||||
if (!roomForOctalCode) {
|
||||
doneEncoding(node);
|
||||
bag.insert(node); // add the node back to the bag so it will eventually get included
|
||||
params.stopReason = EncodeBitstreamParams::DIDNT_FIT;
|
||||
return bytesWritten;
|
||||
|
@ -867,8 +855,6 @@ int Octree::encodeTreeBitstream(OctreeElement* node,
|
|||
packetData->endSubTree();
|
||||
}
|
||||
|
||||
doneEncoding(node);
|
||||
|
||||
return bytesWritten;
|
||||
}
|
||||
|
||||
|
@ -1622,56 +1608,6 @@ void dumpSetContents(const char* name, std::set<unsigned char*> set) {
|
|||
*/
|
||||
}
|
||||
|
||||
void Octree::startEncoding(OctreeElement* node) {
|
||||
_encodeSetLock.lock();
|
||||
_codesBeingEncoded.insert(node->getOctalCode());
|
||||
_encodeSetLock.unlock();
|
||||
}
|
||||
|
||||
void Octree::doneEncoding(OctreeElement* node) {
|
||||
_encodeSetLock.lock();
|
||||
_codesBeingEncoded.erase(node->getOctalCode());
|
||||
_encodeSetLock.unlock();
|
||||
|
||||
// if we have any pending delete codes, then delete them now.
|
||||
emptyDeleteQueue();
|
||||
}
|
||||
|
||||
void Octree::startDeleting(const unsigned char* code) {
|
||||
_deleteSetLock.lock();
|
||||
_codesBeingDeleted.insert(code);
|
||||
_deleteSetLock.unlock();
|
||||
}
|
||||
|
||||
void Octree::doneDeleting(const unsigned char* code) {
|
||||
_deleteSetLock.lock();
|
||||
_codesBeingDeleted.erase(code);
|
||||
_deleteSetLock.unlock();
|
||||
}
|
||||
|
||||
bool Octree::isEncoding(const unsigned char* codeBuffer) {
|
||||
_encodeSetLock.lock();
|
||||
bool isEncoding = (_codesBeingEncoded.find(codeBuffer) != _codesBeingEncoded.end());
|
||||
_encodeSetLock.unlock();
|
||||
return isEncoding;
|
||||
}
|
||||
|
||||
void Octree::queueForLaterDelete(const unsigned char* codeBuffer) {
|
||||
_deletePendingSetLock.lock();
|
||||
_codesPendingDelete.insert(codeBuffer);
|
||||
_deletePendingSetLock.unlock();
|
||||
}
|
||||
|
||||
void Octree::emptyDeleteQueue() {
|
||||
_deletePendingSetLock.lock();
|
||||
for (std::set<const unsigned char*>::iterator i = _codesPendingDelete.begin(); i != _codesPendingDelete.end(); ++i) {
|
||||
const unsigned char* codeToDelete = *i;
|
||||
_codesBeingDeleted.erase(codeToDelete);
|
||||
deleteOctalCodeFromTree(codeToDelete, COLLAPSE_EMPTY_TREE);
|
||||
}
|
||||
_deletePendingSetLock.unlock();
|
||||
}
|
||||
|
||||
void Octree::cancelImport() {
|
||||
_stopImport = true;
|
||||
}
|
||||
|
|
|
@ -302,40 +302,6 @@ protected:
|
|||
bool _shouldReaverage;
|
||||
bool _stopImport;
|
||||
|
||||
/// Octal Codes of any subtrees currently being encoded. While any of these codes is being encoded, ancestors and
|
||||
/// descendants of them can not be deleted.
|
||||
std::set<const unsigned char*> _codesBeingEncoded;
|
||||
/// mutex lock to protect the encoding set
|
||||
QMutex _encodeSetLock;
|
||||
|
||||
/// Called to indicate that a OctreeElement is in the process of being encoded.
|
||||
void startEncoding(OctreeElement* node);
|
||||
/// Called to indicate that a OctreeElement is done being encoded.
|
||||
void doneEncoding(OctreeElement* node);
|
||||
/// Is the Octal Code currently being deleted?
|
||||
bool isEncoding(const unsigned char* codeBuffer);
|
||||
|
||||
/// Octal Codes of any subtrees currently being deleted. While any of these codes is being deleted, ancestors and
|
||||
/// descendants of them can not be encoded.
|
||||
std::set<const unsigned char*> _codesBeingDeleted;
|
||||
/// mutex lock to protect the deleting set
|
||||
QMutex _deleteSetLock;
|
||||
|
||||
/// Called to indicate that an octal code is in the process of being deleted.
|
||||
void startDeleting(const unsigned char* code);
|
||||
/// Called to indicate that an octal code is done being deleted.
|
||||
void doneDeleting(const unsigned char* code);
|
||||
/// Octal Codes that were attempted to be deleted but couldn't be because they were actively being encoded, and were
|
||||
/// instead queued for later delete
|
||||
std::set<const unsigned char*> _codesPendingDelete;
|
||||
/// mutex lock to protect the deleting set
|
||||
QMutex _deletePendingSetLock;
|
||||
|
||||
/// Adds an Octal Code to the set of codes that needs to be deleted
|
||||
void queueForLaterDelete(const unsigned char* codeBuffer);
|
||||
/// flushes out any Octal Codes that had to be queued
|
||||
void emptyDeleteQueue();
|
||||
|
||||
QReadWriteLock _lock;
|
||||
|
||||
/// This tree is receiving inbound viewer datagrams.
|
||||
|
|
Loading…
Reference in a new issue