mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 20:58:38 +02:00
merge from upstream
This commit is contained in:
commit
441b5a20d8
20 changed files with 364 additions and 182 deletions
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": 1.3,
|
"version": 1.4,
|
||||||
"settings": [
|
"settings": [
|
||||||
{
|
{
|
||||||
"name": "metaverse",
|
"name": "metaverse",
|
||||||
|
@ -72,6 +72,76 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "descriptors",
|
||||||
|
"label": "Description",
|
||||||
|
"help": "This data will be queryable from your server. It may be collected by High Fidelity and used to share your domain with others.",
|
||||||
|
"settings": [
|
||||||
|
{
|
||||||
|
"name": "description",
|
||||||
|
"label": "Description",
|
||||||
|
"help": "A description of your domain (256 character limit)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "maturity",
|
||||||
|
"label": "Maturity",
|
||||||
|
"help": "A maturity rating, available as a guideline for content on your domain.",
|
||||||
|
"default": "unrated",
|
||||||
|
"type": "select",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"value": "unrated",
|
||||||
|
"label": "Unrated"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "everyone",
|
||||||
|
"label": "Everyone"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "teen",
|
||||||
|
"label": "Teen (13+)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "mature",
|
||||||
|
"label": "Mature (17+)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "adult",
|
||||||
|
"label": "Adult (18+)"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "hosts",
|
||||||
|
"label": "Hosts",
|
||||||
|
"type": "table",
|
||||||
|
"help": "Usernames of hosts who can reliably show your domain to new visitors.",
|
||||||
|
"numbered": false,
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "host",
|
||||||
|
"label": "Username",
|
||||||
|
"can_set": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tags",
|
||||||
|
"label": "Tags",
|
||||||
|
"type": "table",
|
||||||
|
"help": "Common categories under which your domain falls.",
|
||||||
|
"numbered": false,
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "tag",
|
||||||
|
"label": "Tag",
|
||||||
|
"can_set": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "security",
|
"name": "security",
|
||||||
"label": "Security",
|
"label": "Security",
|
||||||
|
|
132
domain-server/src/DomainMetadata.cpp
Normal file
132
domain-server/src/DomainMetadata.cpp
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
//
|
||||||
|
// DomainMetadata.cpp
|
||||||
|
// domain-server/src
|
||||||
|
//
|
||||||
|
// Created by Zach Pomerantz on 5/25/2016.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
#include "DomainMetadata.h"
|
||||||
|
|
||||||
|
#include <HifiConfigVariantMap.h>
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
#include <LimitedNodeList.h>
|
||||||
|
|
||||||
|
#include "DomainServerNodeData.h"
|
||||||
|
|
||||||
|
const QString DomainMetadata::USERS = "users";
|
||||||
|
const QString DomainMetadata::USERS_NUM_TOTAL = "num_users";
|
||||||
|
const QString DomainMetadata::USERS_NUM_ANON = "num_anon_users";
|
||||||
|
const QString DomainMetadata::USERS_HOSTNAMES = "user_hostnames";
|
||||||
|
// users metadata will appear as (JSON):
|
||||||
|
// { "num_users": Number,
|
||||||
|
// "num_anon_users": Number,
|
||||||
|
// "user_hostnames": { <HOSTNAME>: Number }
|
||||||
|
// }
|
||||||
|
|
||||||
|
const QString DomainMetadata::DESCRIPTORS = "descriptors";
|
||||||
|
const QString DomainMetadata::DESCRIPTORS_DESCRIPTION = "description";
|
||||||
|
const QString DomainMetadata::DESCRIPTORS_CAPACITY = "capacity"; // parsed from security
|
||||||
|
const QString DomainMetadata::DESCRIPTORS_RESTRICTION = "restriction"; // parsed from ACL
|
||||||
|
const QString DomainMetadata::DESCRIPTORS_MATURITY = "maturity";
|
||||||
|
const QString DomainMetadata::DESCRIPTORS_HOSTS = "hosts";
|
||||||
|
const QString DomainMetadata::DESCRIPTORS_TAGS = "tags";
|
||||||
|
// descriptors metadata will appear as (JSON):
|
||||||
|
// { "capacity": Number,
|
||||||
|
// TODO: "hours": String, // UTF-8 representation of the week, split into 15" segments
|
||||||
|
// "restriction": String, // enum of either open, hifi, or acl
|
||||||
|
// "maturity": String, // enum corresponding to ESRB ratings
|
||||||
|
// "hosts": [ String ], // capped list of usernames
|
||||||
|
// "description": String, // capped description
|
||||||
|
// TODO: "img": {
|
||||||
|
// "src": String,
|
||||||
|
// "type": String,
|
||||||
|
// "size": Number,
|
||||||
|
// "updated_at": Number,
|
||||||
|
// },
|
||||||
|
// "tags": [ String ], // capped list of tags
|
||||||
|
// }
|
||||||
|
|
||||||
|
// metadata will appear as (JSON):
|
||||||
|
// { users: <USERS>, descriptors: <DESCRIPTORS> }
|
||||||
|
//
|
||||||
|
// it is meant to be sent to and consumed by an external API
|
||||||
|
|
||||||
|
DomainMetadata::DomainMetadata() {
|
||||||
|
_metadata[USERS] = {};
|
||||||
|
_metadata[DESCRIPTORS] = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void DomainMetadata::setDescriptors(QVariantMap& settings) {
|
||||||
|
const QString CAPACITY = "security.maximum_user_capacity";
|
||||||
|
const QVariant* capacityVariant = valueForKeyPath(settings, CAPACITY);
|
||||||
|
unsigned int capacity = capacityVariant ? capacityVariant->toUInt() : 0;
|
||||||
|
|
||||||
|
// TODO: Keep parity with ACL development.
|
||||||
|
const QString RESTRICTION = "security.restricted_access";
|
||||||
|
const QString RESTRICTION_OPEN = "open";
|
||||||
|
// const QString RESTRICTION_HIFI = "hifi";
|
||||||
|
const QString RESTRICTION_ACL = "acl";
|
||||||
|
const QVariant* isRestrictedVariant = valueForKeyPath(settings, RESTRICTION);
|
||||||
|
bool isRestricted = isRestrictedVariant ? isRestrictedVariant->toBool() : false;
|
||||||
|
QString restriction = isRestricted ? RESTRICTION_ACL : RESTRICTION_OPEN;
|
||||||
|
|
||||||
|
QVariantMap descriptors = settings[DESCRIPTORS].toMap();
|
||||||
|
descriptors[DESCRIPTORS_CAPACITY] = capacity;
|
||||||
|
descriptors[DESCRIPTORS_RESTRICTION] = restriction;
|
||||||
|
_metadata[DESCRIPTORS] = descriptors;
|
||||||
|
|
||||||
|
#if DEV_BUILD || PR_BUILD
|
||||||
|
qDebug() << "Domain metadata descriptors set:" << descriptors;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void DomainMetadata::updateUsers() {
|
||||||
|
static const QString DEFAULT_HOSTNAME = "*";
|
||||||
|
|
||||||
|
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
int numConnected = 0;
|
||||||
|
int numConnectedAnonymously = 0;
|
||||||
|
QVariantMap userHostnames;
|
||||||
|
|
||||||
|
// figure out the breakdown of currently connected interface clients
|
||||||
|
nodeList->eachNode([&numConnected, &numConnectedAnonymously, &userHostnames](const SharedNodePointer& node) {
|
||||||
|
auto linkedData = node->getLinkedData();
|
||||||
|
if (linkedData) {
|
||||||
|
auto nodeData = static_cast<DomainServerNodeData*>(linkedData);
|
||||||
|
|
||||||
|
if (!nodeData->wasAssigned()) {
|
||||||
|
++numConnected;
|
||||||
|
|
||||||
|
if (nodeData->getUsername().isEmpty()) {
|
||||||
|
++numConnectedAnonymously;
|
||||||
|
}
|
||||||
|
|
||||||
|
// increment the count for this hostname (or the default if we don't have one)
|
||||||
|
auto placeName = nodeData->getPlaceName();
|
||||||
|
auto hostname = placeName.isEmpty() ? DEFAULT_HOSTNAME : placeName;
|
||||||
|
userHostnames[hostname] = userHostnames[hostname].toInt() + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
QVariantMap users = {
|
||||||
|
{ USERS_NUM_TOTAL, numConnected },
|
||||||
|
{ USERS_NUM_ANON, numConnectedAnonymously },
|
||||||
|
{ USERS_HOSTNAMES, userHostnames }};
|
||||||
|
_metadata[USERS] = users;
|
||||||
|
|
||||||
|
#if DEV_BUILD || PR_BUILD
|
||||||
|
qDebug() << "Domain metadata users updated:" << users;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void DomainMetadata::usersChanged() {
|
||||||
|
++_tic;
|
||||||
|
|
||||||
|
#if DEV_BUILD || PR_BUILD
|
||||||
|
qDebug() << "Domain metadata users change detected";
|
||||||
|
#endif
|
||||||
|
}
|
65
domain-server/src/DomainMetadata.h
Normal file
65
domain-server/src/DomainMetadata.h
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
//
|
||||||
|
// DomainMetadata.h
|
||||||
|
// domain-server/src
|
||||||
|
//
|
||||||
|
// Created by Zach Pomerantz on 5/25/2016.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
|
||||||
|
#ifndef hifi_DomainMetadata_h
|
||||||
|
#define hifi_DomainMetadata_h
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <QVariantMap>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
class DomainMetadata : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
static const QString USERS;
|
||||||
|
static const QString USERS_NUM_TOTAL;
|
||||||
|
static const QString USERS_NUM_ANON;
|
||||||
|
static const QString USERS_HOSTNAMES;
|
||||||
|
|
||||||
|
static const QString DESCRIPTORS;
|
||||||
|
static const QString DESCRIPTORS_DESCRIPTION;
|
||||||
|
static const QString DESCRIPTORS_CAPACITY;
|
||||||
|
static const QString DESCRIPTORS_HOURS;
|
||||||
|
static const QString DESCRIPTORS_RESTRICTION;
|
||||||
|
static const QString DESCRIPTORS_MATURITY;
|
||||||
|
static const QString DESCRIPTORS_HOSTS;
|
||||||
|
static const QString DESCRIPTORS_TAGS;
|
||||||
|
static const QString DESCRIPTORS_IMG;
|
||||||
|
static const QString DESCRIPTORS_IMG_SRC;
|
||||||
|
static const QString DESCRIPTORS_IMG_TYPE;
|
||||||
|
static const QString DESCRIPTORS_IMG_SIZE;
|
||||||
|
static const QString DESCRIPTORS_IMG_UPDATED_AT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DomainMetadata();
|
||||||
|
|
||||||
|
// Returns the last set metadata
|
||||||
|
// If connected users have changed, metadata may need to be updated
|
||||||
|
// this should be checked by storing tic = getTic() between calls
|
||||||
|
// and testing it for equality before the next get (tic == getTic())
|
||||||
|
QJsonObject get() { return QJsonObject::fromVariantMap(_metadata); }
|
||||||
|
QJsonObject getUsers() { return QJsonObject::fromVariantMap(_metadata[USERS].toMap()); }
|
||||||
|
QJsonObject getDescriptors() { return QJsonObject::fromVariantMap(_metadata[DESCRIPTORS].toMap()); }
|
||||||
|
|
||||||
|
uint32_t getTic() { return _tic; }
|
||||||
|
|
||||||
|
void setDescriptors(QVariantMap& settings);
|
||||||
|
void updateUsers();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void usersChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QVariantMap _metadata;
|
||||||
|
uint32_t _tic{ 0 };
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_DomainMetadata_h
|
|
@ -94,6 +94,10 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
qRegisterMetaType<DomainServerWebSessionData>("DomainServerWebSessionData");
|
qRegisterMetaType<DomainServerWebSessionData>("DomainServerWebSessionData");
|
||||||
qRegisterMetaTypeStreamOperators<DomainServerWebSessionData>("DomainServerWebSessionData");
|
qRegisterMetaTypeStreamOperators<DomainServerWebSessionData>("DomainServerWebSessionData");
|
||||||
|
|
||||||
|
// update the metadata when a user (dis)connects
|
||||||
|
connect(this, &DomainServer::userConnected, &_metadata, &DomainMetadata::usersChanged);
|
||||||
|
connect(this, &DomainServer::userDisconnected, &_metadata, &DomainMetadata::usersChanged);
|
||||||
|
|
||||||
// make sure we hear about newly connected nodes from our gatekeeper
|
// make sure we hear about newly connected nodes from our gatekeeper
|
||||||
connect(&_gatekeeper, &DomainGatekeeper::connectedNode, this, &DomainServer::handleConnectedNode);
|
connect(&_gatekeeper, &DomainGatekeeper::connectedNode, this, &DomainServer::handleConnectedNode);
|
||||||
|
|
||||||
|
@ -119,6 +123,9 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
|
|
||||||
optionallyGetTemporaryName(args);
|
optionallyGetTemporaryName(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update the metadata with current descriptors
|
||||||
|
_metadata.setDescriptors(_settingsManager.getSettingsMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
DomainServer::~DomainServer() {
|
DomainServer::~DomainServer() {
|
||||||
|
@ -774,12 +781,16 @@ QUrl DomainServer::oauthAuthorizationURL(const QUuid& stateUUID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::handleConnectedNode(SharedNodePointer newNode) {
|
void DomainServer::handleConnectedNode(SharedNodePointer newNode) {
|
||||||
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(newNode->getLinkedData());
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(newNode->getLinkedData());
|
|
||||||
|
|
||||||
// reply back to the user with a PacketType::DomainList
|
// reply back to the user with a PacketType::DomainList
|
||||||
sendDomainListToNode(newNode, nodeData->getSendingSockAddr());
|
sendDomainListToNode(newNode, nodeData->getSendingSockAddr());
|
||||||
|
|
||||||
|
// if this node is a user (unassigned Agent), signal
|
||||||
|
if (newNode->getType() == NodeType::Agent && !nodeData->wasAssigned()) {
|
||||||
|
emit userConnected();
|
||||||
|
}
|
||||||
|
|
||||||
// send out this node to our other connected nodes
|
// send out this node to our other connected nodes
|
||||||
broadcastNewNode(newNode);
|
broadcastNewNode(newNode);
|
||||||
}
|
}
|
||||||
|
@ -1073,22 +1084,19 @@ void DomainServer::performIPAddressUpdate(const HifiSockAddr& newPublicSockAddr)
|
||||||
sendHeartbeatToMetaverse(newPublicSockAddr.getAddress().toString());
|
sendHeartbeatToMetaverse(newPublicSockAddr.getAddress().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DomainServer::sendHeartbeatToMetaverse(const QString& networkAddress) {
|
void DomainServer::sendHeartbeatToMetaverse(const QString& networkAddress) {
|
||||||
const QString DOMAIN_UPDATE = "/api/v1/domains/%1";
|
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
const QUuid& domainID = nodeList->getSessionUUID();
|
const QUuid& domainID = nodeList->getSessionUUID();
|
||||||
|
|
||||||
// setup the domain object to send to the data server
|
// Setup the domain object to send to the data server
|
||||||
const QString PUBLIC_NETWORK_ADDRESS_KEY = "network_address";
|
|
||||||
const QString AUTOMATIC_NETWORKING_KEY = "automatic_networking";
|
|
||||||
|
|
||||||
QJsonObject domainObject;
|
QJsonObject domainObject;
|
||||||
|
|
||||||
if (!networkAddress.isEmpty()) {
|
if (!networkAddress.isEmpty()) {
|
||||||
|
static const QString PUBLIC_NETWORK_ADDRESS_KEY = "network_address";
|
||||||
domainObject[PUBLIC_NETWORK_ADDRESS_KEY] = networkAddress;
|
domainObject[PUBLIC_NETWORK_ADDRESS_KEY] = networkAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const QString AUTOMATIC_NETWORKING_KEY = "automatic_networking";
|
||||||
domainObject[AUTOMATIC_NETWORKING_KEY] = _automaticNetworkingSetting;
|
domainObject[AUTOMATIC_NETWORKING_KEY] = _automaticNetworkingSetting;
|
||||||
|
|
||||||
// add a flag to indicate if this domain uses restricted access - for now that will exclude it from listings
|
// add a flag to indicate if this domain uses restricted access - for now that will exclude it from listings
|
||||||
|
@ -1098,38 +1106,18 @@ void DomainServer::sendHeartbeatToMetaverse(const QString& networkAddress) {
|
||||||
NodePermissions anonymousPermissions = _settingsManager.getPermissionsForName(NodePermissions::standardNameAnonymous);
|
NodePermissions anonymousPermissions = _settingsManager.getPermissionsForName(NodePermissions::standardNameAnonymous);
|
||||||
domainObject[RESTRICTED_ACCESS_FLAG] = !anonymousPermissions.canConnectToDomain;
|
domainObject[RESTRICTED_ACCESS_FLAG] = !anonymousPermissions.canConnectToDomain;
|
||||||
|
|
||||||
// figure out the breakdown of currently connected interface clients
|
// Add the metadata to the heartbeat
|
||||||
int numConnectedUnassigned = 0;
|
|
||||||
QJsonObject userHostnames;
|
|
||||||
|
|
||||||
static const QString DEFAULT_HOSTNAME = "*";
|
|
||||||
|
|
||||||
nodeList->eachNode([&numConnectedUnassigned, &userHostnames](const SharedNodePointer& node) {
|
|
||||||
if (node->getLinkedData()) {
|
|
||||||
auto nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
|
||||||
|
|
||||||
if (!nodeData->wasAssigned()) {
|
|
||||||
++numConnectedUnassigned;
|
|
||||||
|
|
||||||
// increment the count for this hostname (or the default if we don't have one)
|
|
||||||
auto hostname = nodeData->getPlaceName().isEmpty() ? DEFAULT_HOSTNAME : nodeData->getPlaceName();
|
|
||||||
userHostnames[hostname] = userHostnames[hostname].toInt() + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
static const QString DOMAIN_HEARTBEAT_KEY = "heartbeat";
|
static const QString DOMAIN_HEARTBEAT_KEY = "heartbeat";
|
||||||
static const QString HEARTBEAT_NUM_USERS_KEY = "num_users";
|
auto tic = _metadata.getTic();
|
||||||
static const QString HEARTBEAT_USER_HOSTNAMES_KEY = "user_hostnames";
|
if (_metadataTic != tic) {
|
||||||
|
_metadataTic = tic;
|
||||||
|
_metadata.updateUsers();
|
||||||
|
}
|
||||||
|
domainObject[DOMAIN_HEARTBEAT_KEY] = _metadata.getUsers();
|
||||||
|
|
||||||
QJsonObject heartbeatObject;
|
QString domainUpdateJSON = QString("{\"domain\":%1}").arg(QString(QJsonDocument(domainObject).toJson(QJsonDocument::Compact)));
|
||||||
heartbeatObject[HEARTBEAT_NUM_USERS_KEY] = numConnectedUnassigned;
|
|
||||||
heartbeatObject[HEARTBEAT_USER_HOSTNAMES_KEY] = userHostnames;
|
|
||||||
|
|
||||||
domainObject[DOMAIN_HEARTBEAT_KEY] = heartbeatObject;
|
|
||||||
|
|
||||||
QString domainUpdateJSON = QString("{\"domain\": %1 }").arg(QString(QJsonDocument(domainObject).toJson()));
|
|
||||||
|
|
||||||
|
static const QString DOMAIN_UPDATE = "/api/v1/domains/%1";
|
||||||
DependencyManager::get<AccountManager>()->sendRequest(DOMAIN_UPDATE.arg(uuidStringWithoutCurlyBraces(domainID)),
|
DependencyManager::get<AccountManager>()->sendRequest(DOMAIN_UPDATE.arg(uuidStringWithoutCurlyBraces(domainID)),
|
||||||
AccountManagerAuth::Required,
|
AccountManagerAuth::Required,
|
||||||
QNetworkAccessManager::PutOperation,
|
QNetworkAccessManager::PutOperation,
|
||||||
|
@ -1925,11 +1913,10 @@ void DomainServer::nodeAdded(SharedNodePointer node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainServer::nodeKilled(SharedNodePointer node) {
|
void DomainServer::nodeKilled(SharedNodePointer node) {
|
||||||
|
|
||||||
// if this peer connected via ICE then remove them from our ICE peers hash
|
// if this peer connected via ICE then remove them from our ICE peers hash
|
||||||
_gatekeeper.removeICEPeer(node->getUUID());
|
_gatekeeper.removeICEPeer(node->getUUID());
|
||||||
|
|
||||||
DomainServerNodeData* nodeData = reinterpret_cast<DomainServerNodeData*>(node->getLinkedData());
|
DomainServerNodeData* nodeData = static_cast<DomainServerNodeData*>(node->getLinkedData());
|
||||||
|
|
||||||
if (nodeData) {
|
if (nodeData) {
|
||||||
// if this node's UUID matches a static assignment we need to throw it back in the assignment queue
|
// if this node's UUID matches a static assignment we need to throw it back in the assignment queue
|
||||||
|
@ -1941,15 +1928,22 @@ void DomainServer::nodeKilled(SharedNodePointer node) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this node was an Agent ask DomainServerNodeData to potentially remove the interpolation we stored
|
|
||||||
nodeData->removeOverrideForKey(USERNAME_UUID_REPLACEMENT_STATS_KEY,
|
|
||||||
uuidStringWithoutCurlyBraces(node->getUUID()));
|
|
||||||
|
|
||||||
// cleanup the connection secrets that we set up for this node (on the other nodes)
|
// cleanup the connection secrets that we set up for this node (on the other nodes)
|
||||||
foreach (const QUuid& otherNodeSessionUUID, nodeData->getSessionSecretHash().keys()) {
|
foreach (const QUuid& otherNodeSessionUUID, nodeData->getSessionSecretHash().keys()) {
|
||||||
SharedNodePointer otherNode = DependencyManager::get<LimitedNodeList>()->nodeWithUUID(otherNodeSessionUUID);
|
SharedNodePointer otherNode = DependencyManager::get<LimitedNodeList>()->nodeWithUUID(otherNodeSessionUUID);
|
||||||
if (otherNode) {
|
if (otherNode) {
|
||||||
reinterpret_cast<DomainServerNodeData*>(otherNode->getLinkedData())->getSessionSecretHash().remove(node->getUUID());
|
static_cast<DomainServerNodeData*>(otherNode->getLinkedData())->getSessionSecretHash().remove(node->getUUID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node->getType() == NodeType::Agent) {
|
||||||
|
// if this node was an Agent ask DomainServerNodeData to remove the interpolation we potentially stored
|
||||||
|
nodeData->removeOverrideForKey(USERNAME_UUID_REPLACEMENT_STATS_KEY,
|
||||||
|
uuidStringWithoutCurlyBraces(node->getUUID()));
|
||||||
|
|
||||||
|
// if this node is a user (unassigned Agent), signal
|
||||||
|
if (!nodeData->wasAssigned()) {
|
||||||
|
emit userDisconnected();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <LimitedNodeList.h>
|
#include <LimitedNodeList.h>
|
||||||
|
|
||||||
#include "DomainGatekeeper.h"
|
#include "DomainGatekeeper.h"
|
||||||
|
#include "DomainMetadata.h"
|
||||||
#include "DomainServerSettingsManager.h"
|
#include "DomainServerSettingsManager.h"
|
||||||
#include "DomainServerWebSessionData.h"
|
#include "DomainServerWebSessionData.h"
|
||||||
#include "WalletTransaction.h"
|
#include "WalletTransaction.h"
|
||||||
|
@ -91,6 +92,8 @@ private slots:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void iceServerChanged();
|
void iceServerChanged();
|
||||||
|
void userConnected();
|
||||||
|
void userDisconnected();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupNodeListAndAssignments(const QUuid& sessionUUID = QUuid::createUuid());
|
void setupNodeListAndAssignments(const QUuid& sessionUUID = QUuid::createUuid());
|
||||||
|
@ -169,6 +172,9 @@ private:
|
||||||
|
|
||||||
DomainServerSettingsManager _settingsManager;
|
DomainServerSettingsManager _settingsManager;
|
||||||
|
|
||||||
|
DomainMetadata _metadata;
|
||||||
|
uint32_t _metadataTic{ 0 };
|
||||||
|
|
||||||
HifiSockAddr _iceServerSocket;
|
HifiSockAddr _iceServerSocket;
|
||||||
std::unique_ptr<NLPacket> _iceServerHeartbeatPacket;
|
std::unique_ptr<NLPacket> _iceServerHeartbeatPacket;
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ void DomainServerSettingsManager::setupConfigMap(const QStringList& argumentList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldVersion < 1.3) {
|
if (oldVersion < 1.4) {
|
||||||
// This was prior to the permissions-grid in the domain-server settings page
|
// This was prior to the permissions-grid in the domain-server settings page
|
||||||
bool isRestrictedAccess = valueOrDefaultValueForKeyPath(RESTRICTED_ACCESS_SETTINGS_KEYPATH).toBool();
|
bool isRestrictedAccess = valueOrDefaultValueForKeyPath(RESTRICTED_ACCESS_SETTINGS_KEYPATH).toBool();
|
||||||
QStringList allowedUsers = valueOrDefaultValueForKeyPath(ALLOWED_USERS_SETTINGS_KEYPATH).toStringList();
|
QStringList allowedUsers = valueOrDefaultValueForKeyPath(ALLOWED_USERS_SETTINGS_KEYPATH).toStringList();
|
||||||
|
|
|
@ -261,6 +261,7 @@ Window {
|
||||||
HifiControls.Button {
|
HifiControls.Button {
|
||||||
text: "Load Defaults"
|
text: "Load Defaults"
|
||||||
color: hifi.buttons.black
|
color: hifi.buttons.black
|
||||||
|
height: 26
|
||||||
onClicked: loadDefaults()
|
onClicked: loadDefaults()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,6 @@ Avatar::Avatar(RigPointer rig) :
|
||||||
_acceleration(0.0f),
|
_acceleration(0.0f),
|
||||||
_lastAngularVelocity(0.0f),
|
_lastAngularVelocity(0.0f),
|
||||||
_lastOrientation(),
|
_lastOrientation(),
|
||||||
_leanScale(0.5f),
|
|
||||||
_worldUpDirection(DEFAULT_UP_DIRECTION),
|
_worldUpDirection(DEFAULT_UP_DIRECTION),
|
||||||
_moving(false),
|
_moving(false),
|
||||||
_initialized(false),
|
_initialized(false),
|
||||||
|
|
|
@ -210,7 +210,6 @@ protected:
|
||||||
glm::vec3 _angularAcceleration;
|
glm::vec3 _angularAcceleration;
|
||||||
glm::quat _lastOrientation;
|
glm::quat _lastOrientation;
|
||||||
|
|
||||||
float _leanScale;
|
|
||||||
glm::vec3 _worldUpDirection;
|
glm::vec3 _worldUpDirection;
|
||||||
float _stringLength;
|
float _stringLength;
|
||||||
bool _moving; ///< set when position is changing
|
bool _moving; ///< set when position is changing
|
||||||
|
|
|
@ -54,8 +54,6 @@ Head::Head(Avatar* owningAvatar) :
|
||||||
_deltaPitch(0.0f),
|
_deltaPitch(0.0f),
|
||||||
_deltaYaw(0.0f),
|
_deltaYaw(0.0f),
|
||||||
_deltaRoll(0.0f),
|
_deltaRoll(0.0f),
|
||||||
_deltaLeanSideways(0.0f),
|
|
||||||
_deltaLeanForward(0.0f),
|
|
||||||
_isCameraMoving(false),
|
_isCameraMoving(false),
|
||||||
_isLookingAtMe(false),
|
_isLookingAtMe(false),
|
||||||
_lookingAtMeStarted(0),
|
_lookingAtMeStarted(0),
|
||||||
|
@ -70,7 +68,6 @@ void Head::init() {
|
||||||
|
|
||||||
void Head::reset() {
|
void Head::reset() {
|
||||||
_baseYaw = _basePitch = _baseRoll = 0.0f;
|
_baseYaw = _basePitch = _baseRoll = 0.0f;
|
||||||
_leanForward = _leanSideways = 0.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
|
@ -118,13 +115,6 @@ void Head::simulate(float deltaTime, bool isMine, bool billboard) {
|
||||||
auto eyeTracker = DependencyManager::get<EyeTracker>();
|
auto eyeTracker = DependencyManager::get<EyeTracker>();
|
||||||
_isEyeTrackerConnected = eyeTracker->isTracking();
|
_isEyeTrackerConnected = eyeTracker->isTracking();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Twist the upper body to follow the rotation of the head, but only do this with my avatar,
|
|
||||||
// since everyone else will see the full joint rotations for other people.
|
|
||||||
const float BODY_FOLLOW_HEAD_YAW_RATE = 0.1f;
|
|
||||||
const float BODY_FOLLOW_HEAD_FACTOR = 0.66f;
|
|
||||||
float currentTwist = getTorsoTwist();
|
|
||||||
setTorsoTwist(currentTwist + (getFinalYaw() * BODY_FOLLOW_HEAD_FACTOR - currentTwist) * BODY_FOLLOW_HEAD_YAW_RATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(_isFaceTrackerConnected || billboard)) {
|
if (!(_isFaceTrackerConnected || billboard)) {
|
||||||
|
@ -301,17 +291,13 @@ void Head::applyEyelidOffset(glm::quat headOrientation) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::relaxLean(float deltaTime) {
|
void Head::relax(float deltaTime) {
|
||||||
// restore rotation, lean to neutral positions
|
// restore rotation, lean to neutral positions
|
||||||
const float LEAN_RELAXATION_PERIOD = 0.25f; // seconds
|
const float LEAN_RELAXATION_PERIOD = 0.25f; // seconds
|
||||||
float relaxationFactor = 1.0f - glm::min(deltaTime / LEAN_RELAXATION_PERIOD, 1.0f);
|
float relaxationFactor = 1.0f - glm::min(deltaTime / LEAN_RELAXATION_PERIOD, 1.0f);
|
||||||
_deltaYaw *= relaxationFactor;
|
_deltaYaw *= relaxationFactor;
|
||||||
_deltaPitch *= relaxationFactor;
|
_deltaPitch *= relaxationFactor;
|
||||||
_deltaRoll *= relaxationFactor;
|
_deltaRoll *= relaxationFactor;
|
||||||
_leanSideways *= relaxationFactor;
|
|
||||||
_leanForward *= relaxationFactor;
|
|
||||||
_deltaLeanSideways *= relaxationFactor;
|
|
||||||
_deltaLeanForward *= relaxationFactor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::setScale (float scale) {
|
void Head::setScale (float scale) {
|
||||||
|
@ -419,8 +405,3 @@ float Head::getFinalPitch() const {
|
||||||
float Head::getFinalRoll() const {
|
float Head::getFinalRoll() const {
|
||||||
return glm::clamp(_baseRoll + _deltaRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL);
|
return glm::clamp(_baseRoll + _deltaRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Head::addLeanDeltas(float sideways, float forward) {
|
|
||||||
_deltaLeanSideways += sideways;
|
|
||||||
_deltaLeanForward += forward;
|
|
||||||
}
|
|
||||||
|
|
|
@ -59,8 +59,6 @@ public:
|
||||||
glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
glm::vec3 getRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
||||||
glm::vec3 getUpDirection() const { return getOrientation() * IDENTITY_UP; }
|
glm::vec3 getUpDirection() const { return getOrientation() * IDENTITY_UP; }
|
||||||
glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FRONT; }
|
glm::vec3 getFrontDirection() const { return getOrientation() * IDENTITY_FRONT; }
|
||||||
float getFinalLeanSideways() const { return _leanSideways + _deltaLeanSideways; }
|
|
||||||
float getFinalLeanForward() const { return _leanForward + _deltaLeanForward; }
|
|
||||||
|
|
||||||
glm::quat getEyeRotation(const glm::vec3& eyePosition) const;
|
glm::quat getEyeRotation(const glm::vec3& eyePosition) const;
|
||||||
|
|
||||||
|
@ -91,8 +89,7 @@ public:
|
||||||
virtual float getFinalYaw() const;
|
virtual float getFinalYaw() const;
|
||||||
virtual float getFinalRoll() const;
|
virtual float getFinalRoll() const;
|
||||||
|
|
||||||
void relaxLean(float deltaTime);
|
void relax(float deltaTime);
|
||||||
void addLeanDeltas(float sideways, float forward);
|
|
||||||
|
|
||||||
float getTimeWithoutTalking() const { return _timeWithoutTalking; }
|
float getTimeWithoutTalking() const { return _timeWithoutTalking; }
|
||||||
|
|
||||||
|
@ -132,10 +129,6 @@ private:
|
||||||
float _deltaYaw;
|
float _deltaYaw;
|
||||||
float _deltaRoll;
|
float _deltaRoll;
|
||||||
|
|
||||||
// delta lean angles for lean perturbations (driven by collisions)
|
|
||||||
float _deltaLeanSideways;
|
|
||||||
float _deltaLeanForward;
|
|
||||||
|
|
||||||
bool _isCameraMoving;
|
bool _isCameraMoving;
|
||||||
bool _isLookingAtMe;
|
bool _isLookingAtMe;
|
||||||
quint64 _lookingAtMeStarted;
|
quint64 _lookingAtMeStarted;
|
||||||
|
|
|
@ -190,9 +190,6 @@ MyAvatar::MyAvatar(RigPointer rig) :
|
||||||
if (!headData->getBlendshapeCoefficients().isEmpty()) {
|
if (!headData->getBlendshapeCoefficients().isEmpty()) {
|
||||||
_headData->setBlendshapeCoefficients(headData->getBlendshapeCoefficients());
|
_headData->setBlendshapeCoefficients(headData->getBlendshapeCoefficients());
|
||||||
}
|
}
|
||||||
// head lean
|
|
||||||
_headData->setLeanForward(headData->getLeanForward());
|
|
||||||
_headData->setLeanSideways(headData->getLeanSideways());
|
|
||||||
// head orientation
|
// head orientation
|
||||||
_headData->setLookAtPosition(headData->getLookAtPosition());
|
_headData->setLookAtPosition(headData->getLookAtPosition());
|
||||||
}
|
}
|
||||||
|
@ -237,7 +234,7 @@ QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll) {
|
||||||
void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
|
void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
|
||||||
|
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "reset", Q_ARG(bool, andRecenter));
|
QMetaObject::invokeMethod(this, "reset", Q_ARG(bool, andRecenter), Q_ARG(bool, andReload), Q_ARG(bool, andHead));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +303,7 @@ void MyAvatar::update(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Head* head = getHead();
|
Head* head = getHead();
|
||||||
head->relaxLean(deltaTime);
|
head->relax(deltaTime);
|
||||||
updateFromTrackers(deltaTime);
|
updateFromTrackers(deltaTime);
|
||||||
|
|
||||||
// Get audio loudness data from audio input device
|
// Get audio loudness data from audio input device
|
||||||
|
@ -574,16 +571,6 @@ void MyAvatar::updateFromTrackers(float deltaTime) {
|
||||||
head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView);
|
head->setDeltaYaw(estimatedRotation.y * magnifyFieldOfView);
|
||||||
head->setDeltaRoll(estimatedRotation.z);
|
head->setDeltaRoll(estimatedRotation.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update torso lean distance based on accelerometer data
|
|
||||||
const float TORSO_LENGTH = 0.5f;
|
|
||||||
glm::vec3 relativePosition = estimatedPosition - glm::vec3(0.0f, -TORSO_LENGTH, 0.0f);
|
|
||||||
|
|
||||||
const float MAX_LEAN = 45.0f;
|
|
||||||
head->setLeanSideways(glm::clamp(glm::degrees(atanf(relativePosition.x * _leanScale / TORSO_LENGTH)),
|
|
||||||
-MAX_LEAN, MAX_LEAN));
|
|
||||||
head->setLeanForward(glm::clamp(glm::degrees(atanf(relativePosition.z * _leanScale / TORSO_LENGTH)),
|
|
||||||
-MAX_LEAN, MAX_LEAN));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 MyAvatar::getLeftHandPosition() const {
|
glm::vec3 MyAvatar::getLeftHandPosition() const {
|
||||||
|
@ -692,7 +679,6 @@ void MyAvatar::saveData() {
|
||||||
|
|
||||||
settings.setValue("headPitch", getHead()->getBasePitch());
|
settings.setValue("headPitch", getHead()->getBasePitch());
|
||||||
|
|
||||||
settings.setValue("leanScale", _leanScale);
|
|
||||||
settings.setValue("scale", _targetScale);
|
settings.setValue("scale", _targetScale);
|
||||||
|
|
||||||
settings.setValue("fullAvatarURL",
|
settings.setValue("fullAvatarURL",
|
||||||
|
@ -809,7 +795,6 @@ void MyAvatar::loadData() {
|
||||||
|
|
||||||
getHead()->setBasePitch(loadSetting(settings, "headPitch", 0.0f));
|
getHead()->setBasePitch(loadSetting(settings, "headPitch", 0.0f));
|
||||||
|
|
||||||
_leanScale = loadSetting(settings, "leanScale", 0.05f);
|
|
||||||
_targetScale = loadSetting(settings, "scale", 1.0f);
|
_targetScale = loadSetting(settings, "scale", 1.0f);
|
||||||
setScale(glm::vec3(_targetScale));
|
setScale(glm::vec3(_targetScale));
|
||||||
|
|
||||||
|
@ -1271,13 +1256,13 @@ void MyAvatar::prepareForPhysicsSimulation() {
|
||||||
void MyAvatar::harvestResultsFromPhysicsSimulation(float deltaTime) {
|
void MyAvatar::harvestResultsFromPhysicsSimulation(float deltaTime) {
|
||||||
glm::vec3 position = getPosition();
|
glm::vec3 position = getPosition();
|
||||||
glm::quat orientation = getOrientation();
|
glm::quat orientation = getOrientation();
|
||||||
if (_characterController.isEnabled()) {
|
if (_characterController.isEnabledAndReady()) {
|
||||||
_characterController.getPositionAndOrientation(position, orientation);
|
_characterController.getPositionAndOrientation(position, orientation);
|
||||||
}
|
}
|
||||||
nextAttitude(position, orientation);
|
nextAttitude(position, orientation);
|
||||||
_bodySensorMatrix = _follow.postPhysicsUpdate(*this, _bodySensorMatrix);
|
_bodySensorMatrix = _follow.postPhysicsUpdate(*this, _bodySensorMatrix);
|
||||||
|
|
||||||
if (_characterController.isEnabled()) {
|
if (_characterController.isEnabledAndReady()) {
|
||||||
setVelocity(_characterController.getLinearVelocity() + _characterController.getFollowVelocity());
|
setVelocity(_characterController.getLinearVelocity() + _characterController.getFollowVelocity());
|
||||||
} else {
|
} else {
|
||||||
setVelocity(getVelocity() + _characterController.getFollowVelocity());
|
setVelocity(getVelocity() + _characterController.getFollowVelocity());
|
||||||
|
@ -1660,7 +1645,7 @@ void MyAvatar::updatePosition(float deltaTime) {
|
||||||
|
|
||||||
vec3 velocity = getVelocity();
|
vec3 velocity = getVelocity();
|
||||||
const float MOVING_SPEED_THRESHOLD_SQUARED = 0.0001f; // 0.01 m/s
|
const float MOVING_SPEED_THRESHOLD_SQUARED = 0.0001f; // 0.01 m/s
|
||||||
if (!_characterController.isEnabled()) {
|
if (!_characterController.isEnabledAndReady()) {
|
||||||
// _characterController is not in physics simulation but it can still compute its target velocity
|
// _characterController is not in physics simulation but it can still compute its target velocity
|
||||||
updateMotors();
|
updateMotors();
|
||||||
_characterController.computeNewVelocity(deltaTime, velocity);
|
_characterController.computeNewVelocity(deltaTime, velocity);
|
||||||
|
@ -1834,6 +1819,16 @@ void MyAvatar::updateMotionBehaviorFromMenu() {
|
||||||
_motionBehaviors &= ~AVATAR_MOTION_SCRIPTED_MOTOR_ENABLED;
|
_motionBehaviors &= ~AVATAR_MOTION_SCRIPTED_MOTOR_ENABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setCharacterControllerEnabled(menu->isOptionChecked(MenuOption::EnableCharacterController));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyAvatar::setCharacterControllerEnabled(bool enabled) {
|
||||||
|
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "setCharacterControllerEnabled", Q_ARG(bool, enabled));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool ghostingAllowed = true;
|
bool ghostingAllowed = true;
|
||||||
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
|
EntityTreeRenderer* entityTreeRenderer = qApp->getEntities();
|
||||||
if (entityTreeRenderer) {
|
if (entityTreeRenderer) {
|
||||||
|
@ -1842,12 +1837,11 @@ void MyAvatar::updateMotionBehaviorFromMenu() {
|
||||||
ghostingAllowed = zone->getGhostingAllowed();
|
ghostingAllowed = zone->getGhostingAllowed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool checked = menu->isOptionChecked(MenuOption::EnableCharacterController);
|
_characterController.setEnabled(ghostingAllowed ? enabled : true);
|
||||||
if (!ghostingAllowed) {
|
}
|
||||||
checked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
_characterController.setEnabled(checked);
|
bool MyAvatar::getCharacterControllerEnabled() {
|
||||||
|
return _characterController.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::clearDriveKeys() {
|
void MyAvatar::clearDriveKeys() {
|
||||||
|
@ -2055,14 +2049,17 @@ bool MyAvatar::FollowHelper::shouldActivateVertical(const MyAvatar& myAvatar, co
|
||||||
|
|
||||||
void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix, bool hasDriveInput) {
|
void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix, bool hasDriveInput) {
|
||||||
_desiredBodyMatrix = desiredBodyMatrix;
|
_desiredBodyMatrix = desiredBodyMatrix;
|
||||||
if (!isActive(Rotation) && shouldActivateRotation(myAvatar, desiredBodyMatrix, currentBodyMatrix)) {
|
|
||||||
activate(Rotation);
|
if (myAvatar.getHMDLeanRecenterEnabled()) {
|
||||||
}
|
if (!isActive(Rotation) && shouldActivateRotation(myAvatar, desiredBodyMatrix, currentBodyMatrix)) {
|
||||||
if (!isActive(Horizontal) && shouldActivateHorizontal(myAvatar, desiredBodyMatrix, currentBodyMatrix)) {
|
activate(Rotation);
|
||||||
activate(Horizontal);
|
}
|
||||||
}
|
if (!isActive(Horizontal) && shouldActivateHorizontal(myAvatar, desiredBodyMatrix, currentBodyMatrix)) {
|
||||||
if (!isActive(Vertical) && (shouldActivateVertical(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
activate(Horizontal);
|
||||||
activate(Vertical);
|
}
|
||||||
|
if (!isActive(Vertical) && (shouldActivateVertical(myAvatar, desiredBodyMatrix, currentBodyMatrix) || hasDriveInput)) {
|
||||||
|
activate(Vertical);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 desiredWorldMatrix = myAvatar.getSensorToWorldMatrix() * _desiredBodyMatrix;
|
glm::mat4 desiredWorldMatrix = myAvatar.getSensorToWorldMatrix() * _desiredBodyMatrix;
|
||||||
|
|
|
@ -69,7 +69,6 @@ class MyAvatar : public Avatar {
|
||||||
Q_PROPERTY(AudioListenerMode audioListenerModeCustom READ getAudioListenerModeCustom)
|
Q_PROPERTY(AudioListenerMode audioListenerModeCustom READ getAudioListenerModeCustom)
|
||||||
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
|
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
|
||||||
|
|
||||||
|
|
||||||
Q_PROPERTY(glm::vec3 leftHandPosition READ getLeftHandPosition)
|
Q_PROPERTY(glm::vec3 leftHandPosition READ getLeftHandPosition)
|
||||||
Q_PROPERTY(glm::vec3 rightHandPosition READ getRightHandPosition)
|
Q_PROPERTY(glm::vec3 rightHandPosition READ getRightHandPosition)
|
||||||
Q_PROPERTY(glm::vec3 leftHandTipPosition READ getLeftHandTipPosition)
|
Q_PROPERTY(glm::vec3 leftHandTipPosition READ getLeftHandTipPosition)
|
||||||
|
@ -84,6 +83,9 @@ class MyAvatar : public Avatar {
|
||||||
|
|
||||||
Q_PROPERTY(float energy READ getEnergy WRITE setEnergy)
|
Q_PROPERTY(float energy READ getEnergy WRITE setEnergy)
|
||||||
|
|
||||||
|
Q_PROPERTY(bool hmdLeanRecenterEnabled READ getHMDLeanRecenterEnabled WRITE setHMDLeanRecenterEnabled)
|
||||||
|
Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MyAvatar(RigPointer rig);
|
explicit MyAvatar(RigPointer rig);
|
||||||
~MyAvatar();
|
~MyAvatar();
|
||||||
|
@ -123,9 +125,6 @@ public:
|
||||||
|
|
||||||
void setRealWorldFieldOfView(float realWorldFov) { _realWorldFieldOfView.set(realWorldFov); }
|
void setRealWorldFieldOfView(float realWorldFov) { _realWorldFieldOfView.set(realWorldFov); }
|
||||||
|
|
||||||
void setLeanScale(float scale) { _leanScale = scale; }
|
|
||||||
float getLeanScale() const { return _leanScale; }
|
|
||||||
|
|
||||||
Q_INVOKABLE glm::vec3 getDefaultEyePosition() const;
|
Q_INVOKABLE glm::vec3 getDefaultEyePosition() const;
|
||||||
|
|
||||||
float getRealWorldFieldOfView() { return _realWorldFieldOfView.get(); }
|
float getRealWorldFieldOfView() { return _realWorldFieldOfView.get(); }
|
||||||
|
@ -163,6 +162,9 @@ public:
|
||||||
Q_INVOKABLE bool getClearOverlayWhenDriving() const { return _clearOverlayWhenDriving; }
|
Q_INVOKABLE bool getClearOverlayWhenDriving() const { return _clearOverlayWhenDriving; }
|
||||||
Q_INVOKABLE void setClearOverlayWhenDriving(bool on) { _clearOverlayWhenDriving = on; }
|
Q_INVOKABLE void setClearOverlayWhenDriving(bool on) { _clearOverlayWhenDriving = on; }
|
||||||
|
|
||||||
|
Q_INVOKABLE void setHMDLeanRecenterEnabled(bool value) { _hmdLeanRecenterEnabled = value; }
|
||||||
|
Q_INVOKABLE bool getHMDLeanRecenterEnabled() const { return _hmdLeanRecenterEnabled; }
|
||||||
|
|
||||||
// get/set avatar data
|
// get/set avatar data
|
||||||
void saveData();
|
void saveData();
|
||||||
void loadData();
|
void loadData();
|
||||||
|
@ -264,6 +266,9 @@ public:
|
||||||
controller::Pose getLeftHandControllerPoseInAvatarFrame() const;
|
controller::Pose getLeftHandControllerPoseInAvatarFrame() const;
|
||||||
controller::Pose getRightHandControllerPoseInAvatarFrame() const;
|
controller::Pose getRightHandControllerPoseInAvatarFrame() const;
|
||||||
|
|
||||||
|
Q_INVOKABLE void setCharacterControllerEnabled(bool enabled);
|
||||||
|
Q_INVOKABLE bool getCharacterControllerEnabled();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void increaseSize();
|
void increaseSize();
|
||||||
void decreaseSize();
|
void decreaseSize();
|
||||||
|
@ -470,6 +475,8 @@ private:
|
||||||
ThreadSafeValueCache<controller::Pose> _leftHandControllerPoseInSensorFrameCache { controller::Pose() };
|
ThreadSafeValueCache<controller::Pose> _leftHandControllerPoseInSensorFrameCache { controller::Pose() };
|
||||||
ThreadSafeValueCache<controller::Pose> _rightHandControllerPoseInSensorFrameCache { controller::Pose() };
|
ThreadSafeValueCache<controller::Pose> _rightHandControllerPoseInSensorFrameCache { controller::Pose() };
|
||||||
|
|
||||||
|
bool _hmdLeanRecenterEnabled = true;
|
||||||
|
|
||||||
float AVATAR_MOVEMENT_ENERGY_CONSTANT { 0.001f };
|
float AVATAR_MOVEMENT_ENERGY_CONSTANT { 0.001f };
|
||||||
float AUDIO_ENERGY_CONSTANT { 0.000001f };
|
float AUDIO_ENERGY_CONSTANT { 0.000001f };
|
||||||
float MAX_AVATAR_MOVEMENT_PER_FRAME { 30.0f };
|
float MAX_AVATAR_MOVEMENT_PER_FRAME { 30.0f };
|
||||||
|
|
|
@ -106,10 +106,6 @@ void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
||||||
MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar);
|
MyAvatar* myAvatar = static_cast<MyAvatar*>(_owningAvatar);
|
||||||
|
|
||||||
Rig::HeadParameters headParams;
|
Rig::HeadParameters headParams;
|
||||||
headParams.enableLean = qApp->isHMDMode();
|
|
||||||
headParams.leanSideways = head->getFinalLeanSideways();
|
|
||||||
headParams.leanForward = head->getFinalLeanForward();
|
|
||||||
headParams.torsoTwist = head->getTorsoTwist();
|
|
||||||
|
|
||||||
if (qApp->isHMDMode()) {
|
if (qApp->isHMDMode()) {
|
||||||
headParams.isInHMD = true;
|
headParams.isInHMD = true;
|
||||||
|
@ -131,7 +127,6 @@ void SkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
||||||
headParams.worldHeadOrientation = head->getFinalOrientationInWorldFrame();
|
headParams.worldHeadOrientation = head->getFinalOrientationInWorldFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
headParams.leanJointIndex = geometry.leanJointIndex;
|
|
||||||
headParams.neckJointIndex = geometry.neckJointIndex;
|
headParams.neckJointIndex = geometry.neckJointIndex;
|
||||||
headParams.isTalking = head->getTimeWithoutTalking() <= 1.5f;
|
headParams.isTalking = head->getTimeWithoutTalking() <= 1.5f;
|
||||||
|
|
||||||
|
|
|
@ -129,16 +129,6 @@ void setupPreferences() {
|
||||||
preference->setStep(1);
|
preference->setStep(1);
|
||||||
preferences->addPreference(preference);
|
preferences->addPreference(preference);
|
||||||
}
|
}
|
||||||
{
|
|
||||||
auto getter = [=]()->float { return myAvatar->getLeanScale(); };
|
|
||||||
auto setter = [=](float value) { myAvatar->setLeanScale(value); };
|
|
||||||
auto preference = new SpinnerPreference(AVATAR_TUNING, "Lean scale (applies to Faceshift users)", getter, setter);
|
|
||||||
preference->setMin(0);
|
|
||||||
preference->setMax(99.9f);
|
|
||||||
preference->setDecimals(2);
|
|
||||||
preference->setStep(1);
|
|
||||||
preferences->addPreference(preference);
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
auto getter = [=]()->float { return myAvatar->getUniformScale(); };
|
auto getter = [=]()->float { return myAvatar->getUniformScale(); };
|
||||||
auto setter = [=](float value) { myAvatar->setTargetScaleVerbose(value); }; // The hell?
|
auto setter = [=](float value) { myAvatar->setTargetScaleVerbose(value); }; // The hell?
|
||||||
|
|
|
@ -931,11 +931,6 @@ glm::quat Rig::getJointDefaultRotationInParentFrame(int jointIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rig::updateFromHeadParameters(const HeadParameters& params, float dt) {
|
void Rig::updateFromHeadParameters(const HeadParameters& params, float dt) {
|
||||||
if (params.enableLean) {
|
|
||||||
updateLeanJoint(params.leanJointIndex, params.leanSideways, params.leanForward, params.torsoTwist);
|
|
||||||
} else {
|
|
||||||
_animVars.unset("lean");
|
|
||||||
}
|
|
||||||
updateNeckJoint(params.neckJointIndex, params);
|
updateNeckJoint(params.neckJointIndex, params);
|
||||||
|
|
||||||
_animVars.set("isTalking", params.isTalking);
|
_animVars.set("isTalking", params.isTalking);
|
||||||
|
@ -953,15 +948,6 @@ static const glm::vec3 X_AXIS(1.0f, 0.0f, 0.0f);
|
||||||
static const glm::vec3 Y_AXIS(0.0f, 1.0f, 0.0f);
|
static const glm::vec3 Y_AXIS(0.0f, 1.0f, 0.0f);
|
||||||
static const glm::vec3 Z_AXIS(0.0f, 0.0f, 1.0f);
|
static const glm::vec3 Z_AXIS(0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
void Rig::updateLeanJoint(int index, float leanSideways, float leanForward, float torsoTwist) {
|
|
||||||
if (isIndexValid(index)) {
|
|
||||||
glm::quat absRot = (glm::angleAxis(-RADIANS_PER_DEGREE * leanSideways, Z_AXIS) *
|
|
||||||
glm::angleAxis(-RADIANS_PER_DEGREE * leanForward, X_AXIS) *
|
|
||||||
glm::angleAxis(RADIANS_PER_DEGREE * torsoTwist, Y_AXIS));
|
|
||||||
_animVars.set("lean", absRot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rig::computeHeadNeckAnimVars(const AnimPose& hmdPose, glm::vec3& headPositionOut, glm::quat& headOrientationOut,
|
void Rig::computeHeadNeckAnimVars(const AnimPose& hmdPose, glm::vec3& headPositionOut, glm::quat& headOrientationOut,
|
||||||
glm::vec3& neckPositionOut, glm::quat& neckOrientationOut) const {
|
glm::vec3& neckPositionOut, glm::quat& neckOrientationOut) const {
|
||||||
|
|
||||||
|
|
|
@ -42,15 +42,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HeadParameters {
|
struct HeadParameters {
|
||||||
float leanSideways = 0.0f; // degrees
|
|
||||||
float leanForward = 0.0f; // degrees
|
|
||||||
float torsoTwist = 0.0f; // degrees
|
|
||||||
bool enableLean = false;
|
|
||||||
glm::quat worldHeadOrientation = glm::quat(); // world space (-z forward)
|
glm::quat worldHeadOrientation = glm::quat(); // world space (-z forward)
|
||||||
glm::quat rigHeadOrientation = glm::quat(); // rig space (-z forward)
|
glm::quat rigHeadOrientation = glm::quat(); // rig space (-z forward)
|
||||||
glm::vec3 rigHeadPosition = glm::vec3(); // rig space
|
glm::vec3 rigHeadPosition = glm::vec3(); // rig space
|
||||||
bool isInHMD = false;
|
bool isInHMD = false;
|
||||||
int leanJointIndex = -1;
|
|
||||||
int neckJointIndex = -1;
|
int neckJointIndex = -1;
|
||||||
bool isTalking = false;
|
bool isTalking = false;
|
||||||
};
|
};
|
||||||
|
@ -222,7 +217,6 @@ protected:
|
||||||
void applyOverridePoses();
|
void applyOverridePoses();
|
||||||
void buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& absolutePosesOut);
|
void buildAbsoluteRigPoses(const AnimPoseVec& relativePoses, AnimPoseVec& absolutePosesOut);
|
||||||
|
|
||||||
void updateLeanJoint(int index, float leanSideways, float leanForward, float torsoTwist);
|
|
||||||
void updateNeckJoint(int index, const HeadParameters& params);
|
void updateNeckJoint(int index, const HeadParameters& params);
|
||||||
void computeHeadNeckAnimVars(const AnimPose& hmdPose, glm::vec3& headPositionOut, glm::quat& headOrientationOut,
|
void computeHeadNeckAnimVars(const AnimPose& hmdPose, glm::vec3& headPositionOut, glm::quat& headOrientationOut,
|
||||||
glm::vec3& neckPositionOut, glm::quat& neckOrientationOut) const;
|
glm::vec3& neckPositionOut, glm::quat& neckOrientationOut) const;
|
||||||
|
|
|
@ -31,9 +31,6 @@ HeadData::HeadData(AvatarData* owningAvatar) :
|
||||||
_baseYaw(0.0f),
|
_baseYaw(0.0f),
|
||||||
_basePitch(0.0f),
|
_basePitch(0.0f),
|
||||||
_baseRoll(0.0f),
|
_baseRoll(0.0f),
|
||||||
_leanSideways(0.0f),
|
|
||||||
_leanForward(0.0f),
|
|
||||||
_torsoTwist(0.0f),
|
|
||||||
_lookAtPosition(0.0f, 0.0f, 0.0f),
|
_lookAtPosition(0.0f, 0.0f, 0.0f),
|
||||||
_audioLoudness(0.0f),
|
_audioLoudness(0.0f),
|
||||||
_isFaceTrackerConnected(false),
|
_isFaceTrackerConnected(false),
|
||||||
|
@ -132,12 +129,6 @@ QJsonObject HeadData::toJson() const {
|
||||||
if (getRawOrientation() != quat()) {
|
if (getRawOrientation() != quat()) {
|
||||||
headJson[JSON_AVATAR_HEAD_ROTATION] = toJsonValue(getRawOrientation());
|
headJson[JSON_AVATAR_HEAD_ROTATION] = toJsonValue(getRawOrientation());
|
||||||
}
|
}
|
||||||
if (getLeanForward() != 0.0f) {
|
|
||||||
headJson[JSON_AVATAR_HEAD_LEAN_FORWARD] = getLeanForward();
|
|
||||||
}
|
|
||||||
if (getLeanSideways() != 0.0f) {
|
|
||||||
headJson[JSON_AVATAR_HEAD_LEAN_SIDEWAYS] = getLeanSideways();
|
|
||||||
}
|
|
||||||
auto lookat = getLookAtPosition();
|
auto lookat = getLookAtPosition();
|
||||||
if (lookat != vec3()) {
|
if (lookat != vec3()) {
|
||||||
vec3 relativeLookAt = glm::inverse(_owningAvatar->getOrientation()) *
|
vec3 relativeLookAt = glm::inverse(_owningAvatar->getOrientation()) *
|
||||||
|
@ -171,12 +162,6 @@ void HeadData::fromJson(const QJsonObject& json) {
|
||||||
if (json.contains(JSON_AVATAR_HEAD_ROTATION)) {
|
if (json.contains(JSON_AVATAR_HEAD_ROTATION)) {
|
||||||
setOrientation(quatFromJsonValue(json[JSON_AVATAR_HEAD_ROTATION]));
|
setOrientation(quatFromJsonValue(json[JSON_AVATAR_HEAD_ROTATION]));
|
||||||
}
|
}
|
||||||
if (json.contains(JSON_AVATAR_HEAD_LEAN_FORWARD)) {
|
|
||||||
setLeanForward((float)json[JSON_AVATAR_HEAD_LEAN_FORWARD].toDouble());
|
|
||||||
}
|
|
||||||
if (json.contains(JSON_AVATAR_HEAD_LEAN_SIDEWAYS)) {
|
|
||||||
setLeanSideways((float)json[JSON_AVATAR_HEAD_LEAN_SIDEWAYS].toDouble());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (json.contains(JSON_AVATAR_HEAD_LOOKAT)) {
|
if (json.contains(JSON_AVATAR_HEAD_LOOKAT)) {
|
||||||
auto relativeLookAt = vec3FromJsonValue(json[JSON_AVATAR_HEAD_LOOKAT]);
|
auto relativeLookAt = vec3FromJsonValue(json[JSON_AVATAR_HEAD_LOOKAT]);
|
||||||
|
|
|
@ -68,17 +68,6 @@ public:
|
||||||
const glm::vec3& getLookAtPosition() const { return _lookAtPosition; }
|
const glm::vec3& getLookAtPosition() const { return _lookAtPosition; }
|
||||||
void setLookAtPosition(const glm::vec3& lookAtPosition) { _lookAtPosition = lookAtPosition; }
|
void setLookAtPosition(const glm::vec3& lookAtPosition) { _lookAtPosition = lookAtPosition; }
|
||||||
|
|
||||||
|
|
||||||
float getLeanSideways() const { return _leanSideways; }
|
|
||||||
float getLeanForward() const { return _leanForward; }
|
|
||||||
float getTorsoTwist() const { return _torsoTwist; }
|
|
||||||
virtual float getFinalLeanSideways() const { return _leanSideways; }
|
|
||||||
virtual float getFinalLeanForward() const { return _leanForward; }
|
|
||||||
|
|
||||||
void setLeanSideways(float leanSideways) { _leanSideways = leanSideways; }
|
|
||||||
void setLeanForward(float leanForward) { _leanForward = leanForward; }
|
|
||||||
void setTorsoTwist(float torsoTwist) { _torsoTwist = torsoTwist; }
|
|
||||||
|
|
||||||
friend class AvatarData;
|
friend class AvatarData;
|
||||||
|
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
|
@ -89,9 +78,6 @@ protected:
|
||||||
float _baseYaw;
|
float _baseYaw;
|
||||||
float _basePitch;
|
float _basePitch;
|
||||||
float _baseRoll;
|
float _baseRoll;
|
||||||
float _leanSideways;
|
|
||||||
float _leanForward;
|
|
||||||
float _torsoTwist;
|
|
||||||
|
|
||||||
glm::vec3 _lookAtPosition;
|
glm::vec3 _lookAtPosition;
|
||||||
float _audioLoudness;
|
float _audioLoudness;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <atomic>
|
||||||
#include <btBulletDynamicsCommon.h>
|
#include <btBulletDynamicsCommon.h>
|
||||||
#include <BulletDynamics/Character/btCharacterControllerInterface.h>
|
#include <BulletDynamics/Character/btCharacterControllerInterface.h>
|
||||||
|
|
||||||
|
@ -105,8 +106,9 @@ public:
|
||||||
|
|
||||||
void setLocalBoundingBox(const glm::vec3& corner, const glm::vec3& scale);
|
void setLocalBoundingBox(const glm::vec3& corner, const glm::vec3& scale);
|
||||||
|
|
||||||
|
bool isEnabled() const { return _enabled; } // thread-safe
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
bool isEnabled() const { return _enabled && _dynamicsWorld; }
|
bool isEnabledAndReady() const { return _enabled && _dynamicsWorld; }
|
||||||
|
|
||||||
bool getRigidBodyLocation(glm::vec3& avatarRigidBodyPosition, glm::quat& avatarRigidBodyRotation);
|
bool getRigidBodyLocation(glm::vec3& avatarRigidBodyPosition, glm::quat& avatarRigidBodyRotation);
|
||||||
|
|
||||||
|
@ -167,7 +169,7 @@ protected:
|
||||||
btQuaternion _followAngularDisplacement;
|
btQuaternion _followAngularDisplacement;
|
||||||
btVector3 _linearAcceleration;
|
btVector3 _linearAcceleration;
|
||||||
|
|
||||||
bool _enabled;
|
std::atomic_bool _enabled;
|
||||||
State _state;
|
State _state;
|
||||||
bool _isPushingUp;
|
bool _isPushingUp;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue