move metavoxels library to tbb concurrent map

This commit is contained in:
Stephen Birarda 2014-11-06 13:44:03 -08:00
parent e92376cf64
commit 948615afe5

View file

@ -43,10 +43,7 @@ SharedObjectPointer MetavoxelClientManager::findFirstRaySpannerIntersection(cons
SharedObjectPointer closestSpanner; SharedObjectPointer closestSpanner;
float closestDistance = FLT_MAX; float closestDistance = FLT_MAX;
NodeHashSnapshot snapshotHash = NodeList::getInstance()->getNodeHash().snapshot_table(); NodeList::getInstance()->eachNode([&](const SharedNodePointer& node){
for (auto it = snapshotHash.begin(); it != snapshotHash.end(); it++) {
SharedNodePointer node = it->second;
if (node->getType() == NodeType::MetavoxelServer) { if (node->getType() == NodeType::MetavoxelServer) {
QMutexLocker locker(&node->getMutex()); QMutexLocker locker(&node->getMutex());
MetavoxelClient* client = static_cast<MetavoxelClient*>(node->getLinkedData()); MetavoxelClient* client = static_cast<MetavoxelClient*>(node->getLinkedData());
@ -60,7 +57,8 @@ SharedObjectPointer MetavoxelClientManager::findFirstRaySpannerIntersection(cons
} }
} }
} }
} });
if (closestSpanner) { if (closestSpanner) {
distance = closestDistance; distance = closestDistance;
} }
@ -119,11 +117,7 @@ MetavoxelClient* MetavoxelClientManager::createClient(const SharedNodePointer& n
} }
void MetavoxelClientManager::guide(MetavoxelVisitor& visitor) { void MetavoxelClientManager::guide(MetavoxelVisitor& visitor) {
NodeHashSnapshot snapshotHash = NodeList::getInstance()->getNodeHash().snapshot_table(); NodeList::getInstance()->eachNode([&visitor](const SharedNodePointer& node){
for (auto it = snapshotHash.begin(); it != snapshotHash.end(); it++) {
SharedNodePointer node = it->second;
if (node->getType() == NodeType::MetavoxelServer) { if (node->getType() == NodeType::MetavoxelServer) {
QMutexLocker locker(&node->getMutex()); QMutexLocker locker(&node->getMutex());
MetavoxelClient* client = static_cast<MetavoxelClient*>(node->getLinkedData()); MetavoxelClient* client = static_cast<MetavoxelClient*>(node->getLinkedData());
@ -131,7 +125,7 @@ void MetavoxelClientManager::guide(MetavoxelVisitor& visitor) {
client->getDataCopy().guide(visitor); client->getDataCopy().guide(visitor);
} }
} }
} });
} }
MetavoxelUpdater::MetavoxelUpdater(MetavoxelClientManager* clientManager) : MetavoxelUpdater::MetavoxelUpdater(MetavoxelClientManager* clientManager) :