diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8e022183df..4947fb008f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -117,11 +117,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : _frameCount(0), _fps(120.0f), _justStarted(true), - _voxelImporter(_window), + _voxelImporter(NULL), _wantToKillLocalVoxels(false), _audioScope(256, 200, true), - _avatarManager(), - _myAvatar(NULL), + _myAvatar(), _profile(QString()), _mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)), _mouseX(0), @@ -1673,7 +1672,12 @@ void Application::exportVoxels() { } void Application::importVoxels() { - if (_voxelImporter.exec()) { + if (!_voxelImporter) { + _voxelImporter = new VoxelImporter(_window); + _voxelImporter->init(_settings); + } + + if (_voxelImporter->exec()) { qDebug("[DEBUG] Import succeeded."); } else { qDebug("[DEBUG] Import failed."); @@ -1813,8 +1817,6 @@ void Application::init() { _sharedVoxelSystem.changeTree(&_clipboard); delete tmpTree; - _voxelImporter.init(_settings); - _environment.init(); _glowEffect.init(); diff --git a/interface/src/Application.h b/interface/src/Application.h index d43b624e59..c83437949c 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -355,7 +355,7 @@ private: VoxelSystem _voxels; VoxelTree _clipboard; // if I copy/paste - VoxelImporter _voxelImporter; + VoxelImporter* _voxelImporter; VoxelSystem _sharedVoxelSystem; ViewFrustum _sharedVoxelSystemViewFrustum; diff --git a/interface/src/ImportDialog.cpp b/interface/src/ImportDialog.cpp index 28e39f1abd..ac7853629c 100644 --- a/interface/src/ImportDialog.cpp +++ b/interface/src/ImportDialog.cpp @@ -231,10 +231,6 @@ void ImportDialog::setLayout() { widget = findChild("treeView"); widget->setAttribute(Qt::WA_MacShowFocusRect, false); - // remove reference to treeView - widget = NULL; - widget->deleteLater(); - switchToResourcesParentIfRequired(); QFile styleSheet("resources/styles/import_dialog.qss"); if (styleSheet.open(QIODevice::ReadOnly)) { diff --git a/interface/src/VoxelImporter.cpp b/interface/src/VoxelImporter.cpp index 0011b0abb7..653d04cee4 100644 --- a/interface/src/VoxelImporter.cpp +++ b/interface/src/VoxelImporter.cpp @@ -24,15 +24,15 @@ private: const QString SETTINGS_GROUP_NAME = "VoxelImport"; const QString IMPORT_DIALOG_SETTINGS_KEY = "ImportDialogSettings"; -VoxelImporter::VoxelImporter(QWidget* parent) - : QObject(parent), - _voxelTree(true), - _importDialog(parent), - _currentTask(NULL), - _nextTask(NULL) { - - connect(&_importDialog, SIGNAL(currentChanged(QString)), SLOT(preImport())); - connect(&_importDialog, SIGNAL(accepted()), SLOT(import())); +VoxelImporter::VoxelImporter(QWidget* parent) : + QObject(parent), + _voxelTree(true), + _importDialog(parent), + _currentTask(NULL), + _nextTask(NULL) +{ + connect(&_importDialog, &QFileDialog::currentChanged, this, &VoxelImporter::preImport); + connect(&_importDialog, &QFileDialog::accepted, this, &VoxelImporter::import); } void VoxelImporter::saveSettings(QSettings* settings) { diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index c337f2ab95..98afa76107 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -173,8 +173,8 @@ int AvatarData::parseData(const QByteArray& packet) { } // increment to push past the packet header - const unsigned char* sourceBuffer = reinterpret_cast(packet.data()); - const unsigned char* startPosition = sourceBuffer + numBytesForPacketHeader(packet); + const unsigned char* startPosition = reinterpret_cast(packet.data()); + const unsigned char* sourceBuffer = startPosition + numBytesForPacketHeader(packet); // Body world position memcpy(&_position, sourceBuffer, sizeof(float) * 3); diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index d947b894aa..cca8ad45cb 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -162,29 +162,21 @@ int HandData::encodeRemoteData(unsigned char* destinationBuffer) { int HandData::decodeRemoteData(const QByteArray& dataByteArray) { QDataStream packetStream(dataByteArray); - quint8 numHands; - packetStream >> numHands; + const unsigned char* startPosition; + const unsigned char* sourceBuffer = startPosition = reinterpret_cast(dataByteArray.data()); + unsigned int numHands = *sourceBuffer++; for (unsigned int handIndex = 0; handIndex < numHands; ++handIndex) { if (handIndex >= getNumPalms()) addNewPalm(); PalmData& palm = getPalms()[handIndex]; - + glm::vec3 handPosition; glm::vec3 handNormal; - qint16 twoByteHolder; + sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, handPosition, fingerVectorRadix); + sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, handNormal, fingerVectorRadix); + unsigned int numFingers = *sourceBuffer++; - packetStream >> twoByteHolder; - unpackFloatVec3FromSignedTwoByteFixed(reinterpret_cast(&twoByteHolder), - handPosition, fingerVectorRadix); - - packetStream >> twoByteHolder; - unpackFloatVec3FromSignedTwoByteFixed(reinterpret_cast(&twoByteHolder), - handNormal, fingerVectorRadix); - - quint8 numFingers; - packetStream >> numFingers; - palm.setRawPosition(handPosition); palm.setRawNormal(handNormal); palm.setActive(true); @@ -195,18 +187,12 @@ int HandData::decodeRemoteData(const QByteArray& dataByteArray) { for (unsigned int fingerIndex = 0; fingerIndex < numFingers; ++fingerIndex) { if (fingerIndex < palm.getNumFingers()) { FingerData& finger = palm.getFingers()[fingerIndex]; - + glm::vec3 tipPosition; glm::vec3 rootPosition; + sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, tipPosition, fingerVectorRadix); + sourceBuffer += unpackFloatVec3FromSignedTwoByteFixed(sourceBuffer, rootPosition, fingerVectorRadix); - packetStream >> twoByteHolder; - unpackFloatVec3FromSignedTwoByteFixed(reinterpret_cast(&twoByteHolder), tipPosition, - fingerVectorRadix); - - packetStream >> twoByteHolder; - unpackFloatVec3FromSignedTwoByteFixed(reinterpret_cast(&twoByteHolder), rootPosition, - fingerVectorRadix); - finger.setRawTipPosition(tipPosition); finger.setRawRootPosition(rootPosition); finger.setActive(true); @@ -225,14 +211,11 @@ int HandData::decodeRemoteData(const QByteArray& dataByteArray) { } // One byte for error checking safety. - unsigned char requiredLength = packetStream.device()->pos(); - - unsigned char checkLength; - packetStream >> checkLength; - + unsigned char requiredLength = (unsigned char)(sourceBuffer - startPosition); + unsigned char checkLength = *sourceBuffer++; assert(checkLength == requiredLength); - - return packetStream.device()->pos(); + + return sourceBuffer - startPosition; } void HandData::setFingerTrailLength(unsigned int length) {