mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 03:17:06 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
c78f4184df
6 changed files with 53 additions and 12 deletions
|
@ -1347,8 +1347,9 @@ void Application::timer() {
|
||||||
// ask the node list to check in with the domain server
|
// ask the node list to check in with the domain server
|
||||||
NodeList::getInstance()->sendDomainServerCheckIn();
|
NodeList::getInstance()->sendDomainServerCheckIn();
|
||||||
|
|
||||||
// give the MyAvatar object position to the Profile so it can propagate to the data-server
|
// give the MyAvatar object position, orientation to the Profile so it can propagate to the data-server
|
||||||
_profile.updatePosition(_myAvatar.getPosition());
|
_profile.updatePosition(_myAvatar.getPosition());
|
||||||
|
_profile.updateOrientation(_myAvatar.getOrientation());
|
||||||
}
|
}
|
||||||
|
|
||||||
static glm::vec3 getFaceVector(BoxFace face) {
|
static glm::vec3 getFaceVector(BoxFace face) {
|
||||||
|
|
|
@ -175,25 +175,35 @@ void DataServerClient::processSendFromDataServer(unsigned char* packetData, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position
|
} else if (keyList[i] == DataServerKey::Domain && keyList[i + 1] == DataServerKey::Position &&
|
||||||
&& valueList[i] != " " && valueList[i + 1] != " ") {
|
keyList[i + 2] == DataServerKey::Orientation && valueList[i] != " " &&
|
||||||
|
valueList[i + 1] != " " && valueList[i + 2] != " ") {
|
||||||
|
|
||||||
QStringList coordinateItems = valueList[i + 1].split(',');
|
QStringList coordinateItems = valueList[i + 1].split(',');
|
||||||
|
QStringList orientationItems = valueList[i + 2].split(',');
|
||||||
|
|
||||||
if (coordinateItems.size() == 3) {
|
if (coordinateItems.size() == 3 && orientationItems.size() == 3) {
|
||||||
|
|
||||||
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
// send a node kill request, indicating to other clients that they should play the "disappeared" effect
|
||||||
NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
|
NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
|
||||||
|
|
||||||
qDebug() << "Changing domain to" << valueList[i].toLocal8Bit().constData() <<
|
qDebug() << "Changing domain to" << valueList[i].toLocal8Bit().constData() <<
|
||||||
"and position to" << valueList[i + 1].toLocal8Bit().constData() <<
|
", position to" << valueList[i + 1].toLocal8Bit().constData() <<
|
||||||
|
", and orientation to" << valueList[i + 2].toLocal8Bit().constData() <<
|
||||||
"to go to" << userString << "\n";
|
"to go to" << userString << "\n";
|
||||||
|
|
||||||
NodeList::getInstance()->setDomainHostname(valueList[i]);
|
NodeList::getInstance()->setDomainHostname(valueList[i]);
|
||||||
|
|
||||||
glm::vec3 newPosition(coordinateItems[0].toFloat(),
|
// orient the user to face the target
|
||||||
coordinateItems[1].toFloat(),
|
glm::quat newOrientation = glm::quat(glm::radians(glm::vec3(orientationItems[0].toFloat(),
|
||||||
coordinateItems[2].toFloat());
|
orientationItems[1].toFloat(), orientationItems[2].toFloat()))) *
|
||||||
|
glm::angleAxis(180.0f, 0.0f, 1.0f, 0.0f);
|
||||||
|
Application::getInstance()->getAvatar()->setOrientation(newOrientation);
|
||||||
|
|
||||||
|
// move the user a couple units away
|
||||||
|
const float DISTANCE_TO_USER = 2.0f;
|
||||||
|
glm::vec3 newPosition = glm::vec3(coordinateItems[0].toFloat(), coordinateItems[1].toFloat(),
|
||||||
|
coordinateItems[2].toFloat()) - newOrientation * IDENTITY_FRONT * DISTANCE_TO_USER;
|
||||||
Application::getInstance()->getAvatar()->setPosition(newPosition);
|
Application::getInstance()->getAvatar()->setPosition(newPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ namespace DataServerKey {
|
||||||
const QString FaceMeshURL = "mesh";
|
const QString FaceMeshURL = "mesh";
|
||||||
const QString SkeletonURL = "skeleton";
|
const QString SkeletonURL = "skeleton";
|
||||||
const QString Position = "position";
|
const QString Position = "position";
|
||||||
|
const QString Orientation = "orientation";
|
||||||
const QString UUID = "uuid";
|
const QString UUID = "uuid";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -999,7 +999,8 @@ void Menu::goToUser() {
|
||||||
int dialogReturn = userDialog.exec();
|
int dialogReturn = userDialog.exec();
|
||||||
if (dialogReturn == QDialog::Accepted && !userDialog.textValue().isEmpty()) {
|
if (dialogReturn == QDialog::Accepted && !userDialog.textValue().isEmpty()) {
|
||||||
// there's a username entered by the user, make a request to the data-server
|
// there's a username entered by the user, make a request to the data-server
|
||||||
DataServerClient::getValuesForKeysAndUserString((QStringList() << DataServerKey::Domain << DataServerKey::Position),
|
DataServerClient::getValuesForKeysAndUserString(
|
||||||
|
QStringList() << DataServerKey::Domain << DataServerKey::Position << DataServerKey::Orientation,
|
||||||
userDialog.textValue());
|
userDialog.textValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ Profile::Profile(const QString &username) :
|
||||||
_uuid(),
|
_uuid(),
|
||||||
_lastDomain(),
|
_lastDomain(),
|
||||||
_lastPosition(0.0, 0.0, 0.0),
|
_lastPosition(0.0, 0.0, 0.0),
|
||||||
|
_lastOrientationSend(0),
|
||||||
_faceModelURL()
|
_faceModelURL()
|
||||||
{
|
{
|
||||||
if (!_username.isEmpty()) {
|
if (!_username.isEmpty()) {
|
||||||
|
@ -69,6 +70,10 @@ void Profile::updateDomain(const QString& domain) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QByteArray createByteArray(const glm::vec3& vector) {
|
||||||
|
return QByteArray::number(vector.x) + ',' + QByteArray::number(vector.y) + ',' + QByteArray::number(vector.z);
|
||||||
|
}
|
||||||
|
|
||||||
void Profile::updatePosition(const glm::vec3 position) {
|
void Profile::updatePosition(const glm::vec3 position) {
|
||||||
if (_lastPosition != position) {
|
if (_lastPosition != position) {
|
||||||
|
|
||||||
|
@ -90,12 +95,29 @@ void Profile::updatePosition(const glm::vec3 position) {
|
||||||
gettimeofday(&lastPositionSend, NULL);
|
gettimeofday(&lastPositionSend, NULL);
|
||||||
|
|
||||||
// send the changed position to the data-server
|
// send the changed position to the data-server
|
||||||
QString positionString = QString("%1,%2,%3").arg(position.x).arg(position.y).arg(position.z);
|
DataServerClient::putValueForKey(DataServerKey::Position, createByteArray(position).constData());
|
||||||
DataServerClient::putValueForKey(DataServerKey::Position, positionString.toLocal8Bit().constData());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Profile::updateOrientation(const glm::quat& orientation) {
|
||||||
|
glm::vec3 eulerAngles = safeEulerAngles(orientation);
|
||||||
|
if (_lastOrientation == eulerAngles) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const uint64_t DATA_SERVER_ORIENTATION_UPDATE_INTERVAL_USECS = 5 * 1000 * 1000;
|
||||||
|
const float DATA_SERVER_ORIENTATION_CHANGE_THRESHOLD_DEGREES = 5.0f;
|
||||||
|
|
||||||
|
uint64_t now = usecTimestampNow();
|
||||||
|
if (now - _lastOrientationSend >= DATA_SERVER_ORIENTATION_UPDATE_INTERVAL_USECS &&
|
||||||
|
glm::distance(_lastOrientation, eulerAngles) >= DATA_SERVER_ORIENTATION_CHANGE_THRESHOLD_DEGREES) {
|
||||||
|
DataServerClient::putValueForKey(DataServerKey::Orientation, createByteArray(eulerAngles).constData());
|
||||||
|
|
||||||
|
_lastOrientation = eulerAngles;
|
||||||
|
_lastOrientationSend = now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Profile::saveData(QSettings* settings) {
|
void Profile::saveData(QSettings* settings) {
|
||||||
settings->beginGroup("Profile");
|
settings->beginGroup("Profile");
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,14 @@
|
||||||
#ifndef __hifi__Profile__
|
#ifndef __hifi__Profile__
|
||||||
#define __hifi__Profile__
|
#define __hifi__Profile__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
#include <QtCore/QUuid>
|
#include <QtCore/QUuid>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
class Profile {
|
class Profile {
|
||||||
public:
|
public:
|
||||||
|
@ -34,6 +37,7 @@ public:
|
||||||
|
|
||||||
void updateDomain(const QString& domain);
|
void updateDomain(const QString& domain);
|
||||||
void updatePosition(const glm::vec3 position);
|
void updatePosition(const glm::vec3 position);
|
||||||
|
void updateOrientation(const glm::quat& orientation);
|
||||||
|
|
||||||
QString getLastDomain() const { return _lastDomain; }
|
QString getLastDomain() const { return _lastDomain; }
|
||||||
const glm::vec3& getLastPosition() const { return _lastPosition; }
|
const glm::vec3& getLastPosition() const { return _lastPosition; }
|
||||||
|
@ -45,6 +49,8 @@ private:
|
||||||
QUuid _uuid;
|
QUuid _uuid;
|
||||||
QString _lastDomain;
|
QString _lastDomain;
|
||||||
glm::vec3 _lastPosition;
|
glm::vec3 _lastPosition;
|
||||||
|
glm::vec3 _lastOrientation;
|
||||||
|
uint64_t _lastOrientationSend;
|
||||||
QUrl _faceModelURL;
|
QUrl _faceModelURL;
|
||||||
QUrl _skeletonModelURL;
|
QUrl _skeletonModelURL;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue