This commit is contained in:
Lucas Crisman 2014-01-31 16:52:57 -03:00
commit fd07449195
6 changed files with 34 additions and 53 deletions

View file

@ -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();

View file

@ -355,7 +355,7 @@ private:
VoxelSystem _voxels;
VoxelTree _clipboard; // if I copy/paste
VoxelImporter _voxelImporter;
VoxelImporter* _voxelImporter;
VoxelSystem _sharedVoxelSystem;
ViewFrustum _sharedVoxelSystemViewFrustum;

View file

@ -231,10 +231,6 @@ void ImportDialog::setLayout() {
widget = findChild<QWidget*>("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)) {

View file

@ -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) {

View file

@ -173,8 +173,8 @@ int AvatarData::parseData(const QByteArray& packet) {
}
// increment to push past the packet header
const unsigned char* sourceBuffer = reinterpret_cast<const unsigned char*>(packet.data());
const unsigned char* startPosition = sourceBuffer + numBytesForPacketHeader(packet);
const unsigned char* startPosition = reinterpret_cast<const unsigned char*>(packet.data());
const unsigned char* sourceBuffer = startPosition + numBytesForPacketHeader(packet);
// Body world position
memcpy(&_position, sourceBuffer, sizeof(float) * 3);

View file

@ -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<const unsigned char*>(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<const unsigned char*>(&twoByteHolder),
handPosition, fingerVectorRadix);
packetStream >> twoByteHolder;
unpackFloatVec3FromSignedTwoByteFixed(reinterpret_cast<const unsigned char*>(&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<const unsigned char*>(&twoByteHolder), tipPosition,
fingerVectorRadix);
packetStream >> twoByteHolder;
unpackFloatVec3FromSignedTwoByteFixed(reinterpret_cast<const unsigned char*>(&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) {