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

View file

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

View file

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