Changeset 10174 for OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp
- Timestamp:
- 05/11/09 13:39:12 (4 years ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp
r10171 r10174 446 446 break; 447 447 } 448 449 //Getting CURL Environment Variables (If found rewrite OSG Options) 450 osg::ref_ptr<FileCache> fileCache = osgDB::Registry::instance()->getFileCache(); 448 451 449 452 450 do … … 482 480 483 481 bool readFromFileCache = false; 484 482 483 osg::ref_ptr<FileCache> fileCache = osgDB::Registry::instance()->getFileCache(); 484 osg::ref_ptr<FileLocationCallback> fileLocationCallback = osgDB::Registry::instance()->getFileLocationCallback(); 485 485 486 if (databaseRequest.valid()) 486 487 { 488 if (databaseRequest->_loadOptions.valid()) 489 { 490 if (databaseRequest->_loadOptions->getFileCache()) fileCache = databaseRequest->_loadOptions->getFileCache(); 491 if (databaseRequest->_loadOptions->getFileLocationCallback()) fileLocationCallback = databaseRequest->_loadOptions->getFileLocationCallback(); 492 } 493 494 // disable the FileCache if the fileLocationCallback tells us that it isn't required for this request. 495 if (fileLocationCallback.valid() && !fileLocationCallback->useFileCache()) fileCache = 0; 496 497 487 498 // check if databaseRequest is still relevant 488 499 if ((_pager->_frameNumber-databaseRequest->_frameNumberLastRequest)<=1) … … 493 504 { 494 505 case(HANDLE_ALL_REQUESTS): 506 { 495 507 // do nothing as this thread can handle the load 496 if ( osgDB::containsServerAddress(databaseRequest->_fileName))508 if (fileCache.valid() && fileCache->isFileAppropriateForFileCache(databaseRequest->_fileName)) 497 509 { 498 if (fileCache .valid() && fileCache->existsInCache(databaseRequest->_fileName))510 if (fileCache->existsInCache(databaseRequest->_fileName)) 499 511 { 500 512 readFromFileCache = true; … … 502 514 } 503 515 break; 504 516 } 505 517 case(HANDLE_NON_HTTP): 518 { 506 519 // check the cache first 507 if (osgDB::containsServerAddress(databaseRequest->_fileName)) 520 bool isHighLatencyFileRequest = false; 521 522 if (fileLocationCallback.valid()) 523 { 524 isHighLatencyFileRequest = fileLocationCallback->fileLocation(databaseRequest->_fileName, databaseRequest->_loadOptions.get()) == FileLocationCallback::REMOTE_FILE; 525 } 526 else if (fileCache.valid() && fileCache->isFileAppropriateForFileCache(databaseRequest->_fileName)) 527 { 528 isHighLatencyFileRequest = true; 529 } 530 531 if (isHighLatencyFileRequest) 508 532 { 509 533 if (fileCache.valid() && fileCache->existsInCache(databaseRequest->_fileName)) … … 519 543 } 520 544 break; 521 545 } 522 546 case(HANDLE_ONLY_HTTP): 523 // make sure the request is a http request 524 if (!osgDB::containsServerAddress(databaseRequest->_fileName)) 525 { 526 osg::notify(osg::NOTICE)<<_name<<": Help we have request we shouldn't have "<<databaseRequest->_fileName<<std::endl; 527 databaseRequest = 0; 528 } 547 { 548 // accept all requests, as we'll assume only high latency requests will have got here. 529 549 break; 550 } 530 551 } 531 552 } … … 555 576 556 577 if (databaseRequest->_loadedModel.valid() && 557 osgDB::containsServerAddress(databaseRequest->_fileName) &&558 578 fileCache.valid() && 579 fileCache->isFileAppropriateForFileCache(databaseRequest->_fileName) && 559 580 !readFromFileCache) 560 581 { … … 1231 1252 void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* group, 1232 1253 float priority, const osg::FrameStamp* framestamp, 1233 osg::ref_ptr<osg::Referenced>& databaseRequest)1234 {1235 requestNodeFile(fileName,group,priority,framestamp,databaseRequest,Registry::instance()->getOptions());1236 }1237 1238 void DatabasePager::requestNodeFile(const std::string& fileName,osg::Group* group,1239 float priority, const osg::FrameStamp* framestamp,1240 1254 osg::ref_ptr<osg::Referenced>& databaseRequestRef, 1241 Options* loadOptions) 1242 { 1255 const osg::Referenced* options) 1256 { 1257 osgDB::Options* loadOptions = dynamic_cast<osgDB::Options*>(const_cast<osg::Referenced*>(options)); 1258 if (!loadOptions) 1259 { 1260 loadOptions = Registry::instance()->getOptions(); 1261 1262 osg::notify(osg::NOTICE)<<"Using options from Registry "<<std::endl; 1263 } 1264 else 1265 { 1266 osg::notify(osg::NOTICE)<<"options from requestNodeFile "<<std::endl; 1267 } 1268 1269 1243 1270 if (!_acceptNewRequests) return; 1244 1271
