PR comments

This commit is contained in:
atlante45 2013-08-21 12:06:47 -07:00
parent 9fb864a699
commit 9003a7d40b
3 changed files with 18 additions and 19 deletions

View file

@ -81,6 +81,8 @@ const int STARTUP_JITTER_SAMPLES = PACKET_LENGTH_SAMPLES_PER_CHANNEL / 2;
// Startup optimistically with small jitter buffer that
// will start playback on the second received audio packet.
static const float CLIPBOARD_TREE_SCALE = 1.0f;
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
fprintf(stdout, "%s", message.toLocal8Bit().constData());
LogDisplay::instance.addMessage(message.toLocal8Bit().constData());
@ -94,7 +96,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
_frameCount(0),
_fps(120.0f),
_justStarted(true),
_clipboard(1),
_clipboard(CLIPBOARD_TREE_SCALE),
_voxelImporter(_window),
_wantToKillLocalVoxels(false),
_audioScope(256, 200, true),

View file

@ -11,6 +11,7 @@
#include <QFileInfo>
#include <QThreadPool>
static const int IMPORT_SYSTEM_SCALE = 1.0f;
static const int MAX_VOXELS_PER_IMPORT = 2000000;
class ImportTask : public QObject, public QRunnable {
@ -25,10 +26,10 @@ private:
VoxelImporter::VoxelImporter(QWidget* parent)
: QObject(parent),
_voxelSystem(new VoxelSystem(1, MAX_VOXELS_PER_IMPORT)),
_voxelSystem(IMPORT_SYSTEM_SCALE, MAX_VOXELS_PER_IMPORT),
_initialized(false),
_importWaiting(false),
_importDialog(parent, _voxelSystem),
_importDialog(parent, &_voxelSystem),
_currentTask(NULL),
_nextTask(NULL) {
@ -45,16 +46,13 @@ VoxelImporter::~VoxelImporter() {
if (_currentTask) {
disconnect(_currentTask, 0, 0, 0);
connect(_currentTask, SIGNAL(destroyed()), _voxelSystem, SLOT(deleteLater()));
_voxelSystem->cancelImport();
_voxelSystem.cancelImport();
_currentTask = NULL;
} else if (_initialized) {
delete _voxelSystem;
}
}
void VoxelImporter::reset() {
_voxelSystem->killLocalVoxels();
_voxelSystem.killLocalVoxels();
_importDialog.reset();
_filename = "";
_importWaiting = false;
@ -65,16 +63,15 @@ void VoxelImporter::reset() {
}
if (_currentTask) {
_voxelSystem->cancelImport();
_voxelSystem.cancelImport();
}
}
int VoxelImporter::exec() {
if (!_initialized) {
_voxelSystem->init();
_importViewFrustum.setKeyholeRadius(100000.0f);
_voxelSystem.init();
_importViewFrustum.calculate();
_voxelSystem->setViewFrustum(&_importViewFrustum);
_voxelSystem.setViewFrustum(&_importViewFrustum);
_initialized = true;
}
reset();
@ -105,11 +102,11 @@ int VoxelImporter::preImport() {
delete _nextTask;
}
_nextTask = new ImportTask(_voxelSystem, _filename);
_nextTask = new ImportTask(&_voxelSystem, _filename);
connect(_nextTask, SIGNAL(destroyed()), SLOT(launchTask()));
if (_currentTask != NULL) {
_voxelSystem->cancelImport();
_voxelSystem.cancelImport();
} else {
launchTask();
}
@ -141,12 +138,12 @@ int VoxelImporter::import() {
delete _nextTask;
}
_nextTask = new ImportTask(_voxelSystem, _filename);
_nextTask = new ImportTask(&_voxelSystem, _filename);
connect(_nextTask, SIGNAL(destroyed()), SLOT(launchTask()));
connect(_nextTask, SIGNAL(destroyed()), &_importDialog, SLOT(accept()));
if (_currentTask != NULL) {
_voxelSystem->cancelImport();
_voxelSystem.cancelImport();
} else {
launchTask();
}
@ -156,7 +153,7 @@ int VoxelImporter::import() {
void VoxelImporter::launchTask() {
if (_nextTask != NULL) {
_voxelSystem->killLocalVoxels();
_voxelSystem.killLocalVoxels();
_currentTask = _nextTask;
_nextTask = NULL;
QThreadPool::globalInstance()->start(_currentTask);

View file

@ -25,7 +25,7 @@ public:
void reset();
bool getImportWaiting() const { return _importWaiting; }
VoxelSystem* getVoxelSystem() const { return _voxelSystem; }
VoxelSystem* getVoxelSystem() { return &_voxelSystem; }
bool getimportIntoClipboard() const { return _importDialog.getImportIntoClipboard(); }
public slots:
@ -37,7 +37,7 @@ private slots:
void launchTask();
private:
VoxelSystem* _voxelSystem;
VoxelSystem _voxelSystem;
ViewFrustum _importViewFrustum;
bool _initialized;
bool _importWaiting;