Merge branch 'master' of https://github.com/worklist/hifi into 19483

This commit is contained in:
stojce 2014-01-23 00:54:05 +01:00
commit becbd4cb1c
19 changed files with 67 additions and 109 deletions

View file

@ -97,9 +97,6 @@ void Agent::run() {
// setup an Avatar for the script to use // setup an Avatar for the script to use
AvatarData scriptedAvatar; AvatarData scriptedAvatar;
// match the scripted avatar's UUID to the DataServerScriptingInterface UUID
scriptedAvatar.setUUID(_scriptEngine.getDataServerScriptingInterface().getUUID());
// give this AvatarData object to the script engine // give this AvatarData object to the script engine
_scriptEngine.setAvatarData(&scriptedAvatar, "Avatar"); _scriptEngine.setAvatarData(&scriptedAvatar, "Avatar");

View file

@ -71,7 +71,6 @@ foreach(EXTERNAL_SOURCE_SUBDIR ${EXTERNAL_SOURCE_SUBDIRS})
set(INTERFACE_SRCS ${INTERFACE_SRCS} ${SUBDIR_SRCS}) set(INTERFACE_SRCS ${INTERFACE_SRCS} ${SUBDIR_SRCS})
endforeach(EXTERNAL_SOURCE_SUBDIR) endforeach(EXTERNAL_SOURCE_SUBDIR)
find_package(Qt5Core REQUIRED) find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED) find_package(Qt5Gui REQUIRED)
find_package(Qt5Multimedia REQUIRED) find_package(Qt5Multimedia REQUIRED)
@ -81,7 +80,14 @@ find_package(Qt5Svg REQUIRED)
find_package(Qt5WebKit REQUIRED) find_package(Qt5WebKit REQUIRED)
find_package(Qt5WebKitWidgets REQUIRED) find_package(Qt5WebKitWidgets REQUIRED)
find_package(Qt5Xml REQUIRED) find_package(Qt5Xml REQUIRED)
find_package(Qt5UiTools REQUIRED)
# grab the ui files in resources/ui
file (GLOB_RECURSE QT_UI_FILES ui/*.ui)
# have qt5 wrap them and generate the appropriate header files
qt5_wrap_ui(QT_UI_HEADERS ${QT_UI_FILES})
# add them to the interface source files
set(INTERFACE_SRCS ${INTERFACE_SRCS} ${QT_UI_HEADERS})
if (APPLE) if (APPLE)
set(MACOSX_BUNDLE_BUNDLE_NAME Interface) set(MACOSX_BUNDLE_BUNDLE_NAME Interface)

View file

@ -2438,17 +2438,14 @@ void Application::updateAvatar(float deltaTime) {
// Get audio loudness data from audio input device // Get audio loudness data from audio input device
_myAvatar.getHead().setAudioLoudness(_audio.getLastInputLoudness()); _myAvatar.getHead().setAudioLoudness(_audio.getLastInputLoudness());
NodeList* nodeList = NodeList::getInstance();
// send head/hand data to the avatar mixer and voxel server // send head/hand data to the avatar mixer and voxel server
unsigned char broadcastString[MAX_PACKET_SIZE]; unsigned char broadcastString[MAX_PACKET_SIZE];
unsigned char* endOfBroadcastStringWrite = broadcastString; unsigned char* endOfBroadcastStringWrite = broadcastString;
endOfBroadcastStringWrite += populateTypeAndVersion(endOfBroadcastStringWrite, PACKET_TYPE_HEAD_DATA); endOfBroadcastStringWrite += populateTypeAndVersion(endOfBroadcastStringWrite, PACKET_TYPE_HEAD_DATA);
QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); // pack the NodeList owner UUID
memcpy(endOfBroadcastStringWrite, ownerUUID.constData(), ownerUUID.size()); endOfBroadcastStringWrite += NodeList::getInstance()->packOwnerUUID(endOfBroadcastStringWrite);
endOfBroadcastStringWrite += ownerUUID.size();
endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite); endOfBroadcastStringWrite += _myAvatar.getBroadcastData(endOfBroadcastStringWrite);
@ -3857,6 +3854,11 @@ void Application::setMenuShortcutsEnabled(bool enabled) {
void Application::attachNewHeadToNode(Node* newNode) { void Application::attachNewHeadToNode(Node* newNode) {
if (newNode->getLinkedData() == NULL) { if (newNode->getLinkedData() == NULL) {
newNode->setLinkedData(new Avatar(newNode)); newNode->setLinkedData(new Avatar(newNode));
// new UUID requires mesh and skeleton request to data-server
DataServerClient::getValuesForKeysAndUUID(QStringList() << DataServerKey::FaceMeshURL << DataServerKey::SkeletonURL,
newNode->getUUID(), Application::getInstance()->getProfile());
} }
} }

View file

@ -345,20 +345,11 @@ int Avatar::parseData(unsigned char* sourceBuffer, int numBytes) {
// change in position implies movement // change in position implies movement
glm::vec3 oldPosition = _position; glm::vec3 oldPosition = _position;
// change in UUID requires mesh and skeleton request to data-server
QUuid oldUuid = _uuid;
int bytesRead = AvatarData::parseData(sourceBuffer, numBytes); int bytesRead = AvatarData::parseData(sourceBuffer, numBytes);
const float MOVE_DISTANCE_THRESHOLD = 0.001f; const float MOVE_DISTANCE_THRESHOLD = 0.001f;
_moving = glm::distance(oldPosition, _position) > MOVE_DISTANCE_THRESHOLD; _moving = glm::distance(oldPosition, _position) > MOVE_DISTANCE_THRESHOLD;
if (oldUuid != _uuid && !_uuid.isNull()) {
DataServerClient::getValuesForKeysAndUUID(QStringList() << DataServerKey::FaceMeshURL << DataServerKey::SkeletonURL,
_uuid, Application::getInstance()->getProfile());
}
return bytesRead; return bytesRead;
} }

View file

@ -48,8 +48,8 @@ QString Profile::getUserString() const {
void Profile::setUUID(const QUuid& uuid) { void Profile::setUUID(const QUuid& uuid) {
_uuid = uuid; _uuid = uuid;
// when the UUID is changed we need set it appropriately on our avatar instance // when the UUID is changed we need set it appropriately on the NodeList instance
Application::getInstance()->getAvatar()->setUUID(_uuid); NodeList::getInstance()->setOwnerUUID(uuid);
} }
void Profile::setFaceModelURL(const QUrl& faceModelURL) { void Profile::setFaceModelURL(const QUrl& faceModelURL) {
@ -156,19 +156,15 @@ void Profile::processDataServerResponse(const QString& userString, const QString
Application::getInstance()->getProfile()->setFaceModelURL(QUrl(valueList[i])); Application::getInstance()->getProfile()->setFaceModelURL(QUrl(valueList[i]));
} else { } else {
// mesh URL for a UUID, find avatar in our list // mesh URL for a UUID, find avatar in our list
SharedNodePointer matchingNode = NodeList::getInstance()->nodeWithUUID(QUuid(userString));
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { if (matchingNode && matchingNode->getType() == NODE_TYPE_AGENT) {
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { qDebug() << "Changing mesh to" << valueList[i] << "for avatar with UUID"
Avatar* avatar = (Avatar *) node->getLinkedData(); << uuidStringWithoutCurlyBraces(matchingNode->getUUID());
if (avatar->getUUID() == QUuid(userString)) { Avatar* avatar = (Avatar *) matchingNode->getLinkedData();
qDebug() << "Changing mesh to" << valueList[i] << "for avatar with UUID"
<< uuidStringWithoutCurlyBraces(avatar->getUUID()); QMetaObject::invokeMethod(&avatar->getHead().getFaceModel(),
"setURL", Q_ARG(QUrl, QUrl(valueList[i])));
QMetaObject::invokeMethod(&avatar->getHead().getFaceModel(),
"setURL", Q_ARG(QUrl, QUrl(valueList[i])));
}
}
} }
} }
} else if (keyList[i] == DataServerKey::SkeletonURL) { } else if (keyList[i] == DataServerKey::SkeletonURL) {
@ -177,18 +173,15 @@ void Profile::processDataServerResponse(const QString& userString, const QString
Application::getInstance()->getProfile()->setSkeletonModelURL(QUrl(valueList[i])); Application::getInstance()->getProfile()->setSkeletonModelURL(QUrl(valueList[i]));
} else { } else {
// skeleton URL for a UUID, find avatar in our list // skeleton URL for a UUID, find avatar in our list
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) { SharedNodePointer matchingNode = NodeList::getInstance()->nodeWithUUID(QUuid(userString));
if (node->getLinkedData() != NULL && node->getType() == NODE_TYPE_AGENT) { if (matchingNode && matchingNode->getType() == NODE_TYPE_AGENT) {
Avatar* avatar = (Avatar *) node->getLinkedData(); qDebug() << "Changing skeleton to" << valueList[i] << "for avatar with UUID"
<< uuidStringWithoutCurlyBraces(matchingNode->getUUID());
if (avatar->getUUID() == QUuid(userString)) {
qDebug() << "Changing skeleton to" << valueList[i] << "for avatar with UUID" Avatar* avatar = (Avatar *) matchingNode->getLinkedData();
<< uuidStringWithoutCurlyBraces(avatar->getUUID());
QMetaObject::invokeMethod(&avatar->getSkeletonModel(),
QMetaObject::invokeMethod(&avatar->getSkeletonModel(), "setURL", "setURL", Q_ARG(QUrl, QUrl(valueList[i])));
Q_ARG(QUrl, QUrl(valueList[i])));
}
}
} }
} }
} else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position && } else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position &&

View file

@ -97,7 +97,7 @@ void LogDialog::initControls() {
} }
void LogDialog::showEvent(QShowEvent*) { void LogDialog::showEvent(QShowEvent*) {
connect(_logger, SIGNAL(logReceived(QString)), this, SLOT(appendLogLine(QString))); connect(_logger, SIGNAL(logReceived(QString)), this, SLOT(appendLogLine(QString)), Qt::QueuedConnection);
showLogData(); showLogData();
} }
@ -111,11 +111,9 @@ void LogDialog::resizeEvent(QResizeEvent*) {
void LogDialog::appendLogLine(QString logLine) { void LogDialog::appendLogLine(QString logLine) {
if (isVisible()) { if (isVisible()) {
_mutex.lock();
if (logLine.contains(_searchTerm, Qt::CaseInsensitive)) { if (logLine.contains(_searchTerm, Qt::CaseInsensitive)) {
_logTextBox->appendPlainText(logLine.simplified()); _logTextBox->appendPlainText(logLine.simplified());
} }
_mutex.unlock();
_logTextBox->ensureCursorVisible(); _logTextBox->ensureCursorVisible();
} }
} }
@ -140,12 +138,10 @@ void LogDialog::handleSearchTextChanged(const QString searchText) {
void LogDialog::showLogData() { void LogDialog::showLogData() {
_logTextBox->clear(); _logTextBox->clear();
_mutex.lock();
QStringList _logData = _logger->getLogData(); QStringList _logData = _logger->getLogData();
for (int i = 0; i < _logData.size(); ++i) { for (int i = 0; i < _logData.size(); ++i) {
appendLogLine(_logData[i]); appendLogLine(_logData[i]);
} }
_mutex.unlock();
} }
KeywordHighlighter::KeywordHighlighter(QTextDocument *parent) : QSyntaxHighlighter(parent), keywordFormat() { KeywordHighlighter::KeywordHighlighter(QTextDocument *parent) : QSyntaxHighlighter(parent), keywordFormat() {

View file

@ -60,7 +60,6 @@ private:
QCheckBox* _extraDebuggingBox; QCheckBox* _extraDebuggingBox;
QPushButton* _revealLogButton; QPushButton* _revealLogButton;
QPlainTextEdit* _logTextBox; QPlainTextEdit* _logTextBox;
QMutex _mutex;
QString _searchTerm; QString _searchTerm;
KeywordHighlighter* _highlighter; KeywordHighlighter* _highlighter;

View file

@ -6,48 +6,40 @@
// Copyright (c) 2013, 2014 High Fidelity, Inc. All rights reserved. // Copyright (c) 2013, 2014 High Fidelity, Inc. All rights reserved.
// //
#include <QApplication>
#include <QDesktopWidget>
#include <QTextBlock>
#include <QtGui> #include <QtGui>
#include <QtUiTools>
#include <QPushButton>
#include <QLabel>
#include <QFrame>
#include "Application.h" #include "Application.h"
#include "SharedUtil.h" #include "ui_updateDialog.h"
#include "UpdateDialog.h" #include "UpdateDialog.h"
UpdateDialog::UpdateDialog(QWidget *parent, const QString& releaseNotes, const QString& latestVersion, const QUrl& downloadURL) : UpdateDialog::UpdateDialog(QWidget *parent, const QString& releaseNotes, const QString& latestVersion, const QUrl& downloadURL) :
QWidget(parent, Qt::Widget), QDialog(parent),
_latestVersion(latestVersion), _latestVersion(latestVersion),
_downloadUrl(downloadURL) { _downloadUrl(downloadURL)
{
QUiLoader updateDialogLoader; Ui::Dialog dialogUI;
QWidget* updateDialog; dialogUI.setupUi(this);
QFile updateDialogUi("resources/ui/updateDialog.ui");
updateDialogUi.open(QFile::ReadOnly);
updateDialog = updateDialogLoader.load(&updateDialogUi, this);
QString updateRequired = QString("You are currently running build %1, the latest build released is %2. \ QString updateRequired = QString("You are currently running build %1, the latest build released is %2. \
Please download and install the most recent release to access the latest features and bug fixes.") Please download and install the most recent release to access the latest features and bug fixes.")
.arg(Application::getInstance()->applicationVersion(), latestVersion); .arg(Application::getInstance()->applicationVersion(), latestVersion);
setAttribute(Qt::WA_DeleteOnClose);
updateDialog->setAttribute(Qt::WA_DeleteOnClose); QPushButton* downloadButton = findChild<QPushButton*>("downloadButton");
QPushButton* skipButton = findChild<QPushButton*>("skipButton");
QPushButton* downloadButton = updateDialog->findChild<QPushButton*>("downloadButton"); QPushButton* closeButton = findChild<QPushButton*>("closeButton");
QPushButton* skipButton = updateDialog->findChild<QPushButton*>("skipButton"); QLabel* updateContent = findChild<QLabel*>("updateContent");
QPushButton* closeButton = updateDialog->findChild<QPushButton*>("closeButton");
QLabel* updateContent = updateDialog->findChild<QLabel*>("updateContent");
updateContent->setText(updateRequired); updateContent->setText(updateRequired);
connect(downloadButton, SIGNAL(released()), this, SLOT(handleDownload())); connect(downloadButton, SIGNAL(released()), this, SLOT(handleDownload()));
connect(skipButton, SIGNAL(released()), this, SLOT(handleSkip())); connect(skipButton, SIGNAL(released()), this, SLOT(handleSkip()));
connect(closeButton, SIGNAL(released()), this, SLOT(close())); connect(closeButton, SIGNAL(released()), this, SLOT(close()));
updateDialog->show();
QMetaObject::invokeMethod(this, "show", Qt::QueuedConnection);
} }
void UpdateDialog::handleDownload() { void UpdateDialog::handleDownload() {

View file

@ -11,7 +11,7 @@
#include <QWidget> #include <QWidget>
class UpdateDialog : public QWidget { class UpdateDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:

View file

@ -24,7 +24,6 @@ static const float fingerVectorRadix = 4; // bits of precision when converting f
AvatarData::AvatarData(Node* owningNode) : AvatarData::AvatarData(Node* owningNode) :
NodeData(owningNode), NodeData(owningNode),
_uuid(),
_handPosition(0,0,0), _handPosition(0,0,0),
_bodyYaw(-90.0), _bodyYaw(-90.0),
_bodyPitch(0.0), _bodyPitch(0.0),
@ -69,11 +68,6 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
_handData = new HandData(this); _handData = new HandData(this);
} }
// UUID
QByteArray uuidByteArray = _uuid.toRfc4122();
memcpy(destinationBuffer, uuidByteArray.constData(), uuidByteArray.size());
destinationBuffer += uuidByteArray.size();
// Body world position // Body world position
memcpy(destinationBuffer, &_position, sizeof(float) * 3); memcpy(destinationBuffer, &_position, sizeof(float) * 3);
destinationBuffer += sizeof(float) * 3; destinationBuffer += sizeof(float) * 3;
@ -180,11 +174,7 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
// push past the node session UUID // push past the node session UUID
sourceBuffer += NUM_BYTES_RFC4122_UUID; sourceBuffer += NUM_BYTES_RFC4122_UUID;
// user UUID
_uuid = QUuid::fromRfc4122(QByteArray((char*) sourceBuffer, NUM_BYTES_RFC4122_UUID));
sourceBuffer += NUM_BYTES_RFC4122_UUID;
// Body world position // Body world position
memcpy(&_position, sourceBuffer, sizeof(float) * 3); memcpy(&_position, sourceBuffer, sizeof(float) * 3);
sourceBuffer += sizeof(float) * 3; sourceBuffer += sizeof(float) * 3;

View file

@ -82,9 +82,6 @@ public:
int getBroadcastData(unsigned char* destinationBuffer); int getBroadcastData(unsigned char* destinationBuffer);
int parseData(unsigned char* sourceBuffer, int numBytes); int parseData(unsigned char* sourceBuffer, int numBytes);
QUuid& getUUID() { return _uuid; }
void setUUID(const QUuid& uuid) { _uuid = uuid; }
// Body Rotation // Body Rotation
float getBodyYaw() const { return _bodyYaw; } float getBodyYaw() const { return _bodyYaw; }
void setBodyYaw(float bodyYaw) { _bodyYaw = bodyYaw; } void setBodyYaw(float bodyYaw) { _bodyYaw = bodyYaw; }
@ -137,8 +134,6 @@ public:
} }
protected: protected:
QUuid _uuid;
glm::vec3 _position; glm::vec3 _position;
glm::vec3 _handPosition; glm::vec3 _handPosition;

View file

@ -7,15 +7,15 @@
// //
#include <DataServerClient.h> #include <DataServerClient.h>
#include <NodeList.h>
#include "DataServerScriptingInterface.h" #include "DataServerScriptingInterface.h"
DataServerScriptingInterface::DataServerScriptingInterface() : DataServerScriptingInterface::DataServerScriptingInterface()
_uuid(QUuid::createUuid())
{ {
} }
void DataServerScriptingInterface::setValueForKey(const QString& key, const QString& value) { void DataServerScriptingInterface::setValueForKey(const QString& key, const QString& value) {
DataServerClient::putValueForKeyAndUUID(key, value, _uuid); DataServerClient::putValueForKeyAndUUID(key, value, NodeList::getInstance()->getOwnerUUID());
} }

View file

@ -18,13 +18,8 @@ class DataServerScriptingInterface : public QObject {
public: public:
DataServerScriptingInterface(); DataServerScriptingInterface();
void refreshUUID() { _uuid = QUuid::createUuid(); }
const QUuid& getUUID() const { return _uuid; }
public slots: public slots:
void setValueForKey(const QString& key, const QString& value); void setValueForKey(const QString& key, const QString& value);
private:
QUuid _uuid;
}; };
#endif /* defined(__hifi__DataServerScriptingInterface__) */ #endif /* defined(__hifi__DataServerScriptingInterface__) */

View file

@ -41,6 +41,7 @@ static QScriptValue soundConstructor(QScriptContext* context, QScriptEngine* eng
ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, const QString& fileNameString, AbstractMenuInterface* menu, ScriptEngine::ScriptEngine(const QString& scriptContents, bool wantMenuItems, const QString& fileNameString, AbstractMenuInterface* menu,
AbstractControllerScriptingInterface* controllerScriptingInterface) : AbstractControllerScriptingInterface* controllerScriptingInterface) :
_dataServerScriptingInterface(),
_avatarData(NULL) _avatarData(NULL)
{ {
_scriptContents = scriptContents; _scriptContents = scriptContents;
@ -159,10 +160,6 @@ void ScriptEngine::registerGlobalObject(const QString& name, QObject* object) {
_engine.globalObject().setProperty(name, value); _engine.globalObject().setProperty(name, value);
} }
void ScriptEngine::preEvaluateReset() {
_dataServerScriptingInterface.refreshUUID();
}
void ScriptEngine::evaluate() { void ScriptEngine::evaluate() {
if (!_isInitialized) { if (!_isInitialized) {
init(); init();
@ -248,9 +245,7 @@ void ScriptEngine::run() {
numAvatarHeaderBytes = populateTypeAndVersion(avatarPacket, PACKET_TYPE_HEAD_DATA); numAvatarHeaderBytes = populateTypeAndVersion(avatarPacket, PACKET_TYPE_HEAD_DATA);
// pack the owner UUID for this script // pack the owner UUID for this script
QByteArray ownerUUID = nodeList->getOwnerUUID().toRfc4122(); numAvatarHeaderBytes += NodeList::getInstance()->packOwnerUUID(avatarPacket);
memcpy(avatarPacket + numAvatarHeaderBytes, ownerUUID.constData(), ownerUUID.size());
numAvatarHeaderBytes += ownerUUID.size();
} }
int numAvatarPacketBytes = _avatarData->getBroadcastData(avatarPacket + numAvatarHeaderBytes) + numAvatarHeaderBytes; int numAvatarPacketBytes = _avatarData->getBroadcastData(avatarPacket + numAvatarHeaderBytes) + numAvatarHeaderBytes;

View file

@ -74,7 +74,6 @@ signals:
void finished(const QString& fileNameString); void finished(const QString& fileNameString);
protected: protected:
void preEvaluateReset();
QString _scriptContents; QString _scriptContents;
bool _isFinished; bool _isFinished;

View file

@ -642,6 +642,12 @@ void NodeList::sendAssignment(Assignment& assignment) {
assignmentServerSocket->getPort()); assignmentServerSocket->getPort());
} }
int NodeList::packOwnerUUID(unsigned char* packetData) {
QByteArray rfcUUID = _ownerUUID.toRfc4122();
memcpy(packetData, rfcUUID.constData(), rfcUUID.size());
return rfcUUID.size();
}
int NodeList::fillPingPacket(unsigned char* buffer) { int NodeList::fillPingPacket(unsigned char* buffer) {
int numHeaderBytes = populateTypeAndVersion(buffer, PACKET_TYPE_PING); int numHeaderBytes = populateTypeAndVersion(buffer, PACKET_TYPE_PING);
uint64_t currentTime = usecTimestampNow(); uint64_t currentTime = usecTimestampNow();

View file

@ -96,6 +96,8 @@ public:
void setAssignmentServerSocket(const HifiSockAddr& serverSocket) { _assignmentServerSocket = serverSocket; } void setAssignmentServerSocket(const HifiSockAddr& serverSocket) { _assignmentServerSocket = serverSocket; }
void sendAssignment(Assignment& assignment); void sendAssignment(Assignment& assignment);
int packOwnerUUID(unsigned char* packetData);
int fillPingPacket(unsigned char* buffer); int fillPingPacket(unsigned char* buffer);
int fillPingReplyPacket(unsigned char* pingBuffer, unsigned char* replyBuffer); int fillPingReplyPacket(unsigned char* pingBuffer, unsigned char* replyBuffer);

View file

@ -20,7 +20,7 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
return 2; return 2;
case PACKET_TYPE_HEAD_DATA: case PACKET_TYPE_HEAD_DATA:
return 15; return 16;
case PACKET_TYPE_OCTREE_STATS: case PACKET_TYPE_OCTREE_STATS:
return 2; return 2;