mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 17:14:59 +02:00
move loading of voxel file to the persist thread so that assignment client will load voxel server faster
This commit is contained in:
parent
1513003ecd
commit
f0fc973db1
3 changed files with 33 additions and 23 deletions
|
@ -8,7 +8,9 @@
|
|||
// Threaded or non-threaded voxel persistence
|
||||
//
|
||||
|
||||
#include <QDebug>
|
||||
#include <NodeList.h>
|
||||
#include <PerfStat.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "VoxelPersistThread.h"
|
||||
|
@ -17,20 +19,43 @@
|
|||
VoxelPersistThread::VoxelPersistThread(VoxelTree* tree, const char* filename, int persistInterval) :
|
||||
_tree(tree),
|
||||
_filename(filename),
|
||||
_persistInterval(persistInterval) {
|
||||
_persistInterval(persistInterval),
|
||||
_initialLoad(false) {
|
||||
}
|
||||
|
||||
bool VoxelPersistThread::process() {
|
||||
|
||||
if (!_initialLoad) {
|
||||
_initialLoad = true;
|
||||
qDebug("loading voxels from file: %s...\n", _filename);
|
||||
|
||||
bool persistantFileRead = _tree->readFromSVOFile(_filename);
|
||||
if (persistantFileRead) {
|
||||
PerformanceWarning warn(true, "reaverageVoxelColors()", true);
|
||||
|
||||
// after done inserting all these voxels, then reaverage colors
|
||||
_tree->reaverageVoxelColors(_tree->rootNode);
|
||||
qDebug("Voxels reAveraged\n");
|
||||
}
|
||||
|
||||
_tree->clearDirtyBit(); // the tree is clean since we just loaded it
|
||||
qDebug("DONE loading voxels from file... fileRead=%s\n", debug::valueOf(persistantFileRead));
|
||||
unsigned long nodeCount = _tree->rootNode->getSubTreeNodeCount();
|
||||
unsigned long internalNodeCount = _tree->rootNode->getSubTreeInternalNodeCount();
|
||||
unsigned long leafNodeCount = _tree->rootNode->getSubTreeLeafNodeCount();
|
||||
qDebug("Nodes after loading scene %lu nodes %lu internal %lu leaves\n", nodeCount, internalNodeCount, leafNodeCount);
|
||||
}
|
||||
|
||||
uint64_t MSECS_TO_USECS = 1000;
|
||||
usleep(_persistInterval * MSECS_TO_USECS);
|
||||
|
||||
|
||||
// check the dirty bit and persist here...
|
||||
if (_tree->isDirty()) {
|
||||
printf("saving voxels to file %s...\n",_filename);
|
||||
qDebug("saving voxels to file %s...\n",_filename);
|
||||
_tree->writeToSVOFile(_filename);
|
||||
_tree->clearDirtyBit(); // tree is clean after saving
|
||||
printf("DONE saving voxels to file...\n");
|
||||
qDebug("DONE saving voxels to file...\n");
|
||||
}
|
||||
|
||||
return isStillRunning(); // keep running till they terminate us
|
||||
|
|
|
@ -28,6 +28,7 @@ private:
|
|||
VoxelTree* _tree;
|
||||
const char* _filename;
|
||||
int _persistInterval;
|
||||
bool _initialLoad;
|
||||
};
|
||||
|
||||
#endif // __voxel_server__VoxelPersistThread__
|
||||
|
|
|
@ -300,8 +300,7 @@ void VoxelServer::run() {
|
|||
}
|
||||
qDebug("wantVoxelPersist=%s\n", debug::valueOf(_wantVoxelPersist));
|
||||
|
||||
// if we want Voxel Persistence, load the local file now...
|
||||
bool persistantFileRead = false;
|
||||
// if we want Voxel Persistence, set up the local file and persist thread
|
||||
if (_wantVoxelPersist) {
|
||||
|
||||
// Check to see if the user passed in a command line option for setting packet send rate
|
||||
|
@ -314,25 +313,8 @@ void VoxelServer::run() {
|
|||
strcpy(_voxelPersistFilename, LOCAL_VOXELS_PERSIST_FILE);
|
||||
}
|
||||
|
||||
qDebug("loading voxels from file: %s...\n", _voxelPersistFilename);
|
||||
qDebug("voxelPersistFilename=%s\n", _voxelPersistFilename);
|
||||
|
||||
persistantFileRead = _serverTree.readFromSVOFile(_voxelPersistFilename);
|
||||
if (persistantFileRead) {
|
||||
PerformanceWarning warn(_shouldShowAnimationDebug,
|
||||
"persistVoxelsWhenDirty() - reaverageVoxelColors()", _shouldShowAnimationDebug);
|
||||
|
||||
// after done inserting all these voxels, then reaverage colors
|
||||
_serverTree.reaverageVoxelColors(_serverTree.rootNode);
|
||||
qDebug("Voxels reAveraged\n");
|
||||
}
|
||||
|
||||
_serverTree.clearDirtyBit(); // the tree is clean since we just loaded it
|
||||
qDebug("DONE loading voxels from file... fileRead=%s\n", debug::valueOf(persistantFileRead));
|
||||
unsigned long nodeCount = _serverTree.rootNode->getSubTreeNodeCount();
|
||||
unsigned long internalNodeCount = _serverTree.rootNode->getSubTreeInternalNodeCount();
|
||||
unsigned long leafNodeCount = _serverTree.rootNode->getSubTreeLeafNodeCount();
|
||||
qDebug("Nodes after loading scene %lu nodes %lu internal %lu leaves\n", nodeCount, internalNodeCount, leafNodeCount);
|
||||
|
||||
// now set up VoxelPersistThread
|
||||
_voxelPersistThread = new VoxelPersistThread(&_serverTree, _voxelPersistFilename);
|
||||
if (_voxelPersistThread) {
|
||||
|
@ -377,6 +359,8 @@ void VoxelServer::run() {
|
|||
if (_voxelServerPacketProcessor) {
|
||||
_voxelServerPacketProcessor->initialize(true);
|
||||
}
|
||||
|
||||
qDebug("Now running...\n");
|
||||
|
||||
// loop to send to nodes requesting data
|
||||
while (true) {
|
||||
|
|
Loading…
Reference in a new issue