Merge branch 'master' of https://github.com/highfidelity/hifi into hdr

This commit is contained in:
samcake 2016-08-30 15:14:22 -07:00
commit d8c883b0fb
8 changed files with 183 additions and 51 deletions

View file

@ -121,9 +121,9 @@ DomainServer::DomainServer(int argc, char* argv[]) :
if (_type != NonMetaverse) { if (_type != NonMetaverse) {
// if we have a metaverse domain, we'll use an access token for API calls // if we have a metaverse domain, we'll use an access token for API calls
resetAccountManagerAccessToken(); resetAccountManagerAccessToken();
}
setupAutomaticNetworking(); setupAutomaticNetworking();
}
if (!getID().isNull() && _type != NonMetaverse) { if (!getID().isNull() && _type != NonMetaverse) {
// setup periodic heartbeats to metaverse API // setup periodic heartbeats to metaverse API

View file

@ -111,7 +111,7 @@ void DiscoverabilityManager::updateLocation() {
} }
// Update Steam // Update Steam
SteamClient::updateLocation(domainHandler.getHostname(), addressManager->currentFacingAddress()); SteamClient::updateLocation(domainHandler.getHostname(), addressManager->currentFacingShareableAddress());
} }
void DiscoverabilityManager::handleHeartbeatResponse(QNetworkReply& requestReply) { void DiscoverabilityManager::handleHeartbeatResponse(QNetworkReply& requestReply) {

View file

@ -140,17 +140,35 @@ QVariant parseBinaryFBXProperty(QDataStream& in, int& position) {
} }
} }
FBXNode parseBinaryFBXNode(QDataStream& in, int& position) { FBXNode parseBinaryFBXNode(QDataStream& in, int& position, bool has64BitPositions = false) {
qint32 endOffset; qint64 endOffset;
quint32 propertyCount; quint64 propertyCount;
quint32 propertyListLength; quint64 propertyListLength;
quint8 nameLength; quint8 nameLength;
in >> endOffset; // FBX 2016 and beyond uses 64bit positions in the node headers, pre-2016 used 32bit values
in >> propertyCount; // our code generally doesn't care about the size that much, so we will use 64bit values
in >> propertyListLength; // from here on out, but if the file is an older format we read the stream into temp 32bit
// values and then assign to our actual 64bit values.
if (has64BitPositions) {
in >> endOffset;
in >> propertyCount;
in >> propertyListLength;
position += sizeof(quint64) * 3;
} else {
qint32 tempEndOffset;
quint32 tempPropertyCount;
quint32 tempPropertyListLength;
in >> tempEndOffset;
in >> tempPropertyCount;
in >> tempPropertyListLength;
position += sizeof(quint32) * 3;
endOffset = tempEndOffset;
propertyCount = tempPropertyCount;
propertyListLength = tempPropertyListLength;
}
in >> nameLength; in >> nameLength;
position += sizeof(quint32) * 3 + sizeof(quint8); position += sizeof(quint8);
FBXNode node; FBXNode node;
const int MIN_VALID_OFFSET = 40; const int MIN_VALID_OFFSET = 40;
@ -166,7 +184,7 @@ FBXNode parseBinaryFBXNode(QDataStream& in, int& position) {
} }
while (endOffset > position) { while (endOffset > position) {
FBXNode child = parseBinaryFBXNode(in, position); FBXNode child = parseBinaryFBXNode(in, position, has64BitPositions);
if (child.name.isNull()) { if (child.name.isNull()) {
return node; return node;
@ -327,15 +345,24 @@ FBXNode FBXReader::parseFBX(QIODevice* device) {
// see http://code.blender.org/index.php/2013/08/fbx-binary-file-format-specification/ for an explanation // see http://code.blender.org/index.php/2013/08/fbx-binary-file-format-specification/ for an explanation
// of the FBX binary format // of the FBX binary format
// skip the rest of the header // The first 27 bytes contain the header.
const int HEADER_SIZE = 27; // Bytes 0 - 20: Kaydara FBX Binary \x00(file - magic, with 2 spaces at the end, then a NULL terminator).
in.skipRawData(HEADER_SIZE); // Bytes 21 - 22: [0x1A, 0x00](unknown but all observed files show these bytes).
int position = HEADER_SIZE; // Bytes 23 - 26 : unsigned int, the version number. 7300 for version 7.3 for example.
const int HEADER_BEFORE_VERSION = 23;
const quint32 VERSION_FBX2016 = 7500;
in.skipRawData(HEADER_BEFORE_VERSION);
int position = HEADER_BEFORE_VERSION;
quint32 fileVersion;
in >> fileVersion;
position += sizeof(fileVersion);
qDebug() << "fileVersion:" << fileVersion;
bool has64BitPositions = (fileVersion >= VERSION_FBX2016);
// parse the top-level node // parse the top-level node
FBXNode top; FBXNode top;
while (device->bytesAvailable()) { while (device->bytesAvailable()) {
FBXNode next = parseBinaryFBXNode(in, position); FBXNode next = parseBinaryFBXNode(in, position, has64BitPositions);
if (next.name.isNull()) { if (next.name.isNull()) {
return top; return top;

View file

@ -63,15 +63,31 @@ QUrl AddressManager::currentAddress() const {
} }
QUrl AddressManager::currentFacingAddress() const { QUrl AddressManager::currentFacingAddress() const {
QUrl hifiURL; auto hifiURL = currentAddress();
hifiURL.setPath(currentFacingPath());
hifiURL.setScheme(HIFI_URL_SCHEME); return hifiURL;
hifiURL.setHost(_host); }
if (_port != 0 && _port != DEFAULT_DOMAIN_SERVER_PORT) {
hifiURL.setPort(_port); QUrl AddressManager::currentShareableAddress() const {
if (!_shareablePlaceName.isEmpty()) {
// if we have a shareable place name use that instead of whatever the current host is
QUrl hifiURL;
hifiURL.setScheme(HIFI_URL_SCHEME);
hifiURL.setHost(_shareablePlaceName);
hifiURL.setPath(currentPath());
return hifiURL;
} else {
return currentAddress();
} }
}
QUrl AddressManager::currentFacingShareableAddress() const {
auto hifiURL = currentShareableAddress();
hifiURL.setPath(currentFacingPath()); hifiURL.setPath(currentFacingPath());
return hifiURL; return hifiURL;
@ -360,6 +376,7 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
LookupTrigger trigger = (LookupTrigger) reply.property(LOOKUP_TRIGGER_KEY).toInt(); LookupTrigger trigger = (LookupTrigger) reply.property(LOOKUP_TRIGGER_KEY).toInt();
// set our current root place id to the ID that came back // set our current root place id to the ID that came back
const QString PLACE_ID_KEY = "id"; const QString PLACE_ID_KEY = "id";
_rootPlaceID = rootMap[PLACE_ID_KEY].toUuid(); _rootPlaceID = rootMap[PLACE_ID_KEY].toUuid();
@ -368,6 +385,18 @@ void AddressManager::goToAddressFromObject(const QVariantMap& dataObject, const
const QString PLACE_NAME_KEY = "name"; const QString PLACE_NAME_KEY = "name";
QString placeName = rootMap[PLACE_NAME_KEY].toString(); QString placeName = rootMap[PLACE_NAME_KEY].toString();
if (placeName.isEmpty()) {
// we didn't get a set place name, check if there is a default or temporary domain name to use
const QString TEMPORARY_DOMAIN_NAME_KEY = "name";
const QString DEFAULT_DOMAIN_NAME_KEY = "default_place_name";
if (domainObject.contains(TEMPORARY_DOMAIN_NAME_KEY)) {
placeName = domainObject[TEMPORARY_DOMAIN_NAME_KEY].toString();
} else if (domainObject.contains(DEFAULT_DOMAIN_NAME_KEY)) {
placeName = domainObject[DEFAULT_DOMAIN_NAME_KEY].toString();
}
}
if (!placeName.isEmpty()) { if (!placeName.isEmpty()) {
if (setHost(placeName, trigger)) { if (setHost(placeName, trigger)) {
trigger = LookupTrigger::Internal; trigger = LookupTrigger::Internal;
@ -651,6 +680,9 @@ bool AddressManager::setHost(const QString& host, LookupTrigger trigger, quint16
_port = port; _port = port;
// any host change should clear the shareable place name
_shareablePlaceName.clear();
if (host != _host) { if (host != _host) {
_host = host; _host = host;
emit hostChanged(_host); emit hostChanged(_host);
@ -701,13 +733,67 @@ void AddressManager::refreshPreviousLookup() {
} }
void AddressManager::copyAddress() { void AddressManager::copyAddress() {
QApplication::clipboard()->setText(currentAddress().toString()); // assume that the address is being copied because the user wants a shareable address
QApplication::clipboard()->setText(currentShareableAddress().toString());
} }
void AddressManager::copyPath() { void AddressManager::copyPath() {
QApplication::clipboard()->setText(currentPath()); QApplication::clipboard()->setText(currentPath());
} }
void AddressManager::handleShareableNameAPIResponse(QNetworkReply& requestReply) {
// make sure that this response is for the domain we're currently connected to
auto domainID = DependencyManager::get<NodeList>()->getDomainHandler().getUUID();
if (requestReply.url().toString().contains(uuidStringWithoutCurlyBraces(domainID))) {
// check for a name or default name in the API response
QJsonObject responseObject = QJsonDocument::fromJson(requestReply.readAll()).object();
QJsonObject domainObject = responseObject["domain"].toObject();
const QString DOMAIN_NAME_KEY = "name";
const QString DOMAIN_DEFAULT_PLACE_NAME_KEY = "default_place_name";
bool shareableNameChanged { false };
if (domainObject[DOMAIN_NAME_KEY].isString()) {
_shareablePlaceName = domainObject[DOMAIN_NAME_KEY].toString();
shareableNameChanged = true;
} else if (domainObject[DOMAIN_DEFAULT_PLACE_NAME_KEY].isString()) {
_shareablePlaceName = domainObject[DOMAIN_DEFAULT_PLACE_NAME_KEY].toString();
shareableNameChanged = true;
}
if (shareableNameChanged) {
qDebug() << "AddressManager shareable name changed to" << _shareablePlaceName;
}
}
}
void AddressManager::lookupShareableNameForDomainID(const QUuid& domainID) {
// if we get to a domain via IP/hostname, often the address is only reachable by this client
// and not by other clients on the LAN or Internet
// to work around this we use the ID to lookup the default place name, and if it exists we
// then use that for Steam join/invite or copiable address
// it only makes sense to lookup a shareable default name if we don't have a place name
if (_placeName.isEmpty()) {
JSONCallbackParameters callbackParams;
// no error callback handling
// in the case of an error we simply assume there is no default place name
callbackParams.jsonCallbackReceiver = this;
callbackParams.jsonCallbackMethod = "handleShareableNameAPIResponse";
DependencyManager::get<AccountManager>()->sendRequest(GET_DOMAIN_ID.arg(uuidStringWithoutCurlyBraces(domainID)),
AccountManagerAuth::None,
QNetworkAccessManager::GetOperation,
callbackParams);
}
}
void AddressManager::addCurrentAddressToHistory(LookupTrigger trigger) { void AddressManager::addCurrentAddressToHistory(LookupTrigger trigger) {
// if we're cold starting and this is called for the first address (from settings) we don't do anything // if we're cold starting and this is called for the first address (from settings) we don't do anything

View file

@ -60,6 +60,8 @@ public:
QUrl currentAddress() const; QUrl currentAddress() const;
QUrl currentFacingAddress() const; QUrl currentFacingAddress() const;
QUrl currentShareableAddress() const;
QUrl currentFacingShareableAddress() const;
QString currentPath(bool withOrientation = true) const; QString currentPath(bool withOrientation = true) const;
QString currentFacingPath() const; QString currentFacingPath() const;
@ -102,6 +104,8 @@ public slots:
void copyAddress(); void copyAddress();
void copyPath(); void copyPath();
void lookupShareableNameForDomainID(const QUuid& domainID);
signals: signals:
void lookupResultsFinished(); void lookupResultsFinished();
void lookupResultIsOffline(); void lookupResultIsOffline();
@ -125,6 +129,8 @@ private slots:
void handleAPIResponse(QNetworkReply& requestReply); void handleAPIResponse(QNetworkReply& requestReply);
void handleAPIError(QNetworkReply& errorReply); void handleAPIError(QNetworkReply& errorReply);
void handleShareableNameAPIResponse(QNetworkReply& requestReply);
private: private:
void goToAddressFromObject(const QVariantMap& addressMap, const QNetworkReply& reply); void goToAddressFromObject(const QVariantMap& addressMap, const QNetworkReply& reply);
@ -155,6 +161,8 @@ private:
PositionGetter _positionGetter; PositionGetter _positionGetter;
OrientationGetter _orientationGetter; OrientationGetter _orientationGetter;
QString _shareablePlaceName;
QStack<QUrl> _backStack; QStack<QUrl> _backStack;
QStack<QUrl> _forwardStack; QStack<QUrl> _forwardStack;
quint64 _lastBackPush = 0; quint64 _lastBackPush = 0;

View file

@ -539,6 +539,10 @@ void NodeList::processDomainServerList(QSharedPointer<ReceivedMessage> message)
if (!_domainHandler.isConnected()) { if (!_domainHandler.isConnected()) {
_domainHandler.setUUID(domainUUID); _domainHandler.setUUID(domainUUID);
_domainHandler.setIsConnected(true); _domainHandler.setIsConnected(true);
// in case we didn't use a place name to get to this domain,
// give the address manager a chance to lookup a default one now
DependencyManager::get<AddressManager>()->lookupShareableNameForDomainID(domainUUID);
} else if (_domainHandler.getUUID() != domainUUID) { } else if (_domainHandler.getUUID() != domainUUID) {
// Recieved packet from different domain. // Recieved packet from different domain.
qWarning() << "IGNORING DomainList packet from" << domainUUID << "while connected to" << _domainHandler.getUUID(); qWarning() << "IGNORING DomainList packet from" << domainUUID << "while connected to" << _domainHandler.getUUID();

View file

@ -81,28 +81,43 @@ QScriptValue PointerEvent::toScriptValue(QScriptEngine* engine, const PointerEve
direction.setProperty("z", event._direction.z); direction.setProperty("z", event._direction.z);
obj.setProperty("pos3D", direction); obj.setProperty("pos3D", direction);
bool isPrimaryButton = false;
bool isSecondaryButton = false;
bool isTertiaryButton = false;
switch (event._button) { switch (event._button) {
case NoButtons: case NoButtons:
obj.setProperty("button", "None"); obj.setProperty("button", "None");
break; break;
case PrimaryButton: case PrimaryButton:
obj.setProperty("button", "Primary"); obj.setProperty("button", "Primary");
isPrimaryButton = true;
break; break;
case SecondaryButton: case SecondaryButton:
obj.setProperty("button", "Secondary"); obj.setProperty("button", "Secondary");
isSecondaryButton = true;
break; break;
case TertiaryButton: case TertiaryButton:
obj.setProperty("button", "Tertiary"); obj.setProperty("button", "Tertiary");
isTertiaryButton = true;
break; break;
} }
obj.setProperty("isLeftButton", areFlagsSet(event._buttons, PrimaryButton)); if (isPrimaryButton) {
obj.setProperty("isRightButton", areFlagsSet(event._buttons, SecondaryButton)); obj.setProperty("isPrimaryButton", isPrimaryButton);
obj.setProperty("isMiddleButton", areFlagsSet(event._buttons, TertiaryButton)); obj.setProperty("isLeftButton", isPrimaryButton);
}
if (isSecondaryButton) {
obj.setProperty("isSecondaryButton", isSecondaryButton);
obj.setProperty("isRightButton", isSecondaryButton);
}
if (isTertiaryButton) {
obj.setProperty("isTertiaryButton", isTertiaryButton);
obj.setProperty("isMiddleButton", isTertiaryButton);
}
obj.setProperty("isPrimaryButton", areFlagsSet(event._buttons, PrimaryButton)); obj.setProperty("isPrimaryHeld", areFlagsSet(event._buttons, PrimaryButton));
obj.setProperty("isSecondaryButton", areFlagsSet(event._buttons, SecondaryButton)); obj.setProperty("isSecondaryHeld", areFlagsSet(event._buttons, SecondaryButton));
obj.setProperty("isTertiaryButton", areFlagsSet(event._buttons, TertiaryButton)); obj.setProperty("isTertiaryHeld", areFlagsSet(event._buttons, TertiaryButton));
return obj; return obj;
} }
@ -146,9 +161,9 @@ void PointerEvent::fromScriptValue(const QScriptValue& object, PointerEvent& eve
event._button = NoButtons; event._button = NoButtons;
} }
bool primary = object.property("isPrimary").toBool() || object.property("isLeftButton").toBool(); bool primary = object.property("isPrimaryHeld").toBool();
bool secondary = object.property("isSecondary").toBool() || object.property("isRightButton").toBool(); bool secondary = object.property("isSecondaryHeld").toBool();
bool tertiary = object.property("isTertiary").toBool() || object.property("isMiddleButton").toBool(); bool tertiary = object.property("isTertiaryHeld").toBool();
event._buttons = 0; event._buttons = 0;
if (primary) { if (primary) {
event._buttons |= PrimaryButton; event._buttons |= PrimaryButton;

View file

@ -1319,6 +1319,11 @@ function MyController(hand) {
this.searchEnter = function() { this.searchEnter = function() {
mostRecentSearchingHand = this.hand; mostRecentSearchingHand = this.hand;
var rayPickInfo = this.calcRayPickInfo(this.hand);
if (rayPickInfo.entityID || rayPickInfo.overlayID) {
this.intersectionDistance = rayPickInfo.distance;
this.searchSphereDistance = this.intersectionDistance;
}
}; };
this.search = function(deltaTime, timestamp) { this.search = function(deltaTime, timestamp) {
@ -1426,10 +1431,7 @@ function MyController(hand) {
pos3D: rayPickInfo.intersection, pos3D: rayPickInfo.intersection,
normal: rayPickInfo.normal, normal: rayPickInfo.normal,
direction: rayPickInfo.searchRay.direction, direction: rayPickInfo.searchRay.direction,
button: "None", button: "None"
isPrimaryButton: false,
isSecondaryButton: false,
isTertiaryButton: false
}; };
this.hoverEntity = entity; this.hoverEntity = entity;
@ -1449,10 +1451,7 @@ function MyController(hand) {
pos3D: rayPickInfo.intersection, pos3D: rayPickInfo.intersection,
normal: rayPickInfo.normal, normal: rayPickInfo.normal,
direction: rayPickInfo.searchRay.direction, direction: rayPickInfo.searchRay.direction,
button: "None", button: "None"
isPrimaryButton: false,
isSecondaryButton: false,
isTertiaryButton: false
}; };
Entities.sendMouseMoveOnEntity(entity, pointerEvent); Entities.sendMouseMoveOnEntity(entity, pointerEvent);
@ -2124,9 +2123,7 @@ function MyController(hand) {
normal: intersectInfo.normal, normal: intersectInfo.normal,
direction: intersectInfo.searchRay.direction, direction: intersectInfo.searchRay.direction,
button: "Primary", button: "Primary",
isPrimaryButton: true, isPrimaryHeld: true
isSecondaryButton: false,
isTertiaryButton: false
}; };
Entities.sendMousePressOnEntity(this.grabbedEntity, pointerEvent); Entities.sendMousePressOnEntity(this.grabbedEntity, pointerEvent);
@ -2152,15 +2149,12 @@ function MyController(hand) {
pos3D: intersectInfo.point, pos3D: intersectInfo.point,
normal: intersectInfo.normal, normal: intersectInfo.normal,
direction: intersectInfo.searchRay.direction, direction: intersectInfo.searchRay.direction,
button: "Primary", button: "Primary"
isPrimaryButton: false,
isSecondaryButton: false,
isTertiaryButton: false
}; };
} else { } else {
pointerEvent = this.touchingEnterPointerEvent; pointerEvent = this.touchingEnterPointerEvent;
pointerEvent.button = "Primary"; pointerEvent.button = "Primary";
pointerEvent.isPrimaryButton = false; pointerEvent.isPrimaryHeld = false;
} }
Entities.sendMouseReleaseOnEntity(this.grabbedEntity, pointerEvent); Entities.sendMouseReleaseOnEntity(this.grabbedEntity, pointerEvent);
@ -2197,9 +2191,7 @@ function MyController(hand) {
normal: intersectInfo.normal, normal: intersectInfo.normal,
direction: intersectInfo.searchRay.direction, direction: intersectInfo.searchRay.direction,
button: "NoButtons", button: "NoButtons",
isPrimaryButton: true, isPrimaryHeld: true
isSecondaryButton: false,
isTertiaryButton: false
}; };
var POINTER_PRESS_TO_MOVE_DELAY = 0.15; // seconds var POINTER_PRESS_TO_MOVE_DELAY = 0.15; // seconds