Merge branch 'master' of https://github.com/highfidelity/hifi into spectator-camera

This commit is contained in:
Zach Fox 2017-06-19 10:31:31 -07:00
commit 08eb07242d
36 changed files with 101 additions and 84 deletions

View file

@ -12,12 +12,19 @@ elseif ($ENV{QT_CMAKE_PREFIX_PATH})
set(QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH})
endif ()
set(QUAZIP_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_PREFIX_PATH=${QT_CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_NAME_DIR:PATH=<INSTALL_DIR>/lib -DZLIB_ROOT=${ZLIB_ROOT} -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
if (APPLE)
else ()
set(QUAZIP_CMAKE_ARGS ${QUAZIP_CMAKE_ARGS} -DCMAKE_CXX_STANDARD=11)
endif ()
ExternalProject_Add(
${EXTERNAL_NAME}
URL https://s3-us-west-1.amazonaws.com/hifi-production/dependencies/quazip-0.7.2.zip
URL_MD5 2955176048a31262c09259ca8d309d19
BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DCMAKE_PREFIX_PATH=${QT_CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_NAME_DIR:PATH=<INSTALL_DIR>/lib -DZLIB_ROOT=${ZLIB_ROOT} -DCMAKE_POSITION_INDEPENDENT_CODE=ON
CMAKE_ARGS ${QUAZIP_CMAKE_ARGS}
LOG_DOWNLOAD 1
LOG_CONFIGURE 1
LOG_BUILD 1

View file

@ -353,6 +353,14 @@ FocusScope {
showDesktop();
}
function ensureTitleBarVisible(targetWindow) {
// Reposition window to ensure that title bar is vertically inside window.
if (targetWindow.frame && targetWindow.frame.decoration) {
var topMargin = -targetWindow.frame.decoration.anchors.topMargin; // Frame's topMargin is a negative value.
targetWindow.y = Math.max(targetWindow.y, topMargin);
}
}
function centerOnVisible(item) {
var targetWindow = d.getDesktopWindow(item);
if (!targetWindow) {
@ -375,11 +383,12 @@ FocusScope {
targetWindow.x = newX;
targetWindow.y = newY;
ensureTitleBarVisible(targetWindow);
// If we've noticed that our recommended desktop rect has changed, record that change here.
if (recommendedRect != newRecommendedRect) {
recommendedRect = newRecommendedRect;
}
}
function repositionOnVisible(item) {
@ -394,7 +403,6 @@ FocusScope {
return;
}
var oldRecommendedRect = recommendedRect;
var oldRecommendedDimmensions = { x: oldRecommendedRect.width, y: oldRecommendedRect.height };
var newRecommendedRect = Controller.getRecommendedOverlayRect();
@ -426,7 +434,6 @@ FocusScope {
newPosition.y = -1
}
if (newPosition.x === -1 && newPosition.y === -1) {
var originRelativeX = (targetWindow.x - oldRecommendedRect.x);
var originRelativeY = (targetWindow.y - oldRecommendedRect.y);
@ -444,6 +451,8 @@ FocusScope {
}
targetWindow.x = newPosition.x;
targetWindow.y = newPosition.y;
ensureTitleBarVisible(targetWindow);
}
Component { id: messageDialogBuilder; MessageDialog { } }

View file

@ -590,14 +590,11 @@ Item {
console.log("This avatar is no longer present. goToUserInDomain() failed.");
return;
}
var vector = Vec3.subtract(avatar.position, MyAvatar.position);
var distance = Vec3.length(vector);
var target = Vec3.multiply(Vec3.normalize(vector), distance - 2.0);
// FIXME: We would like the avatar to recompute the avatar's "maybe fly" test at the new position, so that if high enough up,
// the avatar goes into fly mode rather than falling. However, that is not exposed to Javascript right now.
// FIXME: it would be nice if this used the same teleport steps and smoothing as in the teleport.js script.
// Note, however, that this script allows teleporting to a person in the air, while teleport.js is going to a grounded target.
MyAvatar.orientation = Quat.lookAtSimple(MyAvatar.position, avatar.position);
MyAvatar.position = Vec3.sum(MyAvatar.position, target);
MyAvatar.position = Vec3.sum(avatar.position, Vec3.multiplyQbyV(avatar.orientation, {x: 0, y: 0, z: -2}));
MyAvatar.orientation = Quat.multiply(avatar.orientation, {y: 1});
}
}

View file

@ -956,7 +956,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// Make sure we don't time out during slow operations at startup
updateHeartbeat();
connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
connect(this, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
// hook up bandwidth estimator
QSharedPointer<BandwidthRecorder> bandwidthRecorder = DependencyManager::get<BandwidthRecorder>();
@ -1450,7 +1450,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
});
sendStatsTimer->start();
// Periodically check for count of nearby avatars
static int lastCountOfNearbyAvatars = -1;
QTimer* checkNearbyAvatarsTimer = new QTimer(this);
@ -1645,7 +1644,7 @@ void Application::updateHeartbeat() const {
static_cast<DeadlockWatchdogThread*>(_deadlockWatchdogThread)->updateHeartbeat();
}
void Application::aboutToQuit() {
void Application::onAboutToQuit() {
emit beforeAboutToQuit();
foreach(auto inputPlugin, PluginManager::getInstance()->getInputPlugins()) {

View file

@ -399,7 +399,7 @@ private slots:
void showDesktop();
void clearDomainOctreeDetails();
void clearDomainAvatars();
void aboutToQuit();
void onAboutToQuit();
void resettingDomain();

View file

@ -440,17 +440,27 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) {
touchEvent->setTouchPoints(touchPoints);
touchEvent->setTouchPointStates(touchPointState);
// Send mouse events to the Web surface so that HTML dialog elements work with mouse press and hover.
// FIXME: Scroll bar dragging is a bit unstable in the tablet (content can jump up and down at times).
// This may be improved in Qt 5.8. Release notes: "Cleaned up touch and mouse event delivery".
//
// In Qt 5.9 mouse events must be sent before touch events to make sure some QtQuick components will
// receive mouse events
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
if (!(this->_pressed && event.getType() == PointerEvent::Move)) {
QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier);
QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent);
}
#endif
QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent);
if (this->_pressed && event.getType() == PointerEvent::Move) {
#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0)
if (this->_pressed && event.getType() == PointerEvent::Move) {
return;
}
// Send mouse events to the Web surface so that HTML dialog elements work with mouse press and hover.
// FIXME: Scroll bar dragging is a bit unstable in the tablet (content can jump up and down at times).
// This may be improved in Qt 5.8. Release notes: "Cleaned up touch and mouse event delivery".
QMouseEvent* mouseEvent = new QMouseEvent(mouseType, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier);
QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent);
#endif
}
void Web3DOverlay::handlePointerEventAsMouse(const PointerEvent& event) {

View file

@ -87,6 +87,12 @@ FileCache::~FileCache() {
}
void FileCache::initialize() {
Lock lock(_mutex);
if (_initialized) {
qCWarning(file_cache) << "File cache already initialized";
return;
}
QDir dir(_dirpath.c_str());
if (dir.exists()) {
@ -120,21 +126,24 @@ FilePointer FileCache::addFile(Metadata&& metadata, const std::string& filepath)
file->_cache = this;
emit dirty();
Lock lock(_filesMutex);
_files[file->getKey()] = file;
}
return file;
}
FilePointer FileCache::writeFile(const char* data, File::Metadata&& metadata, bool overwrite) {
assert(_initialized);
Lock lock(_mutex);
FilePointer file;
if (!_initialized) {
qCWarning(file_cache) << "File cache used before initialization";
return file;
}
std::string filepath = getFilepath(metadata.key);
Lock lock(_filesMutex);
// if file already exists, return it
FilePointer file = getFile(metadata.key);
file = getFile(metadata.key);
if (file) {
if (!overwrite) {
qCWarning(file_cache, "[%s] Attempted to overwrite %s", _dirname.c_str(), metadata.key.c_str());
@ -158,12 +167,15 @@ FilePointer FileCache::writeFile(const char* data, File::Metadata&& metadata, bo
return file;
}
FilePointer FileCache::getFile(const Key& key) {
assert(_initialized);
Lock lock(_mutex);
FilePointer file;
Lock lock(_filesMutex);
if (!_initialized) {
qCWarning(file_cache) << "File cache used before initialization";
return file;
}
// check if file exists
const auto it = _files.find(key);
@ -172,7 +184,10 @@ FilePointer FileCache::getFile(const Key& key) {
if (file) {
file->touch();
// if it exists, it is active - remove it from the cache
removeUnusedFile(file);
if (_unusedFiles.erase(file)) {
_numUnusedFiles -= 1;
_unusedFilesSize -= file->getLength();
}
qCDebug(file_cache, "[%s] Found %s", _dirname.c_str(), key.c_str());
emit dirty();
} else {
@ -188,31 +203,19 @@ std::string FileCache::getFilepath(const Key& key) {
return _dirpath + DIR_SEP + key + EXT_SEP + _ext;
}
// This is a non-public function that uses the mutex because it's
// essentially a public function specifically to a File object
void FileCache::addUnusedFile(const FilePointer& file) {
{
Lock lock(_filesMutex);
_files[file->getKey()] = file;
}
{
Lock lock(_unusedFilesMutex);
_unusedFiles.insert(file);
_numUnusedFiles += 1;
_unusedFilesSize += file->getLength();
}
Lock lock(_mutex);
_files[file->getKey()] = file;
_unusedFiles.insert(file);
_numUnusedFiles += 1;
_unusedFilesSize += file->getLength();
clean();
emit dirty();
}
void FileCache::removeUnusedFile(const FilePointer& file) {
Lock lock(_unusedFilesMutex);
if (_unusedFiles.erase(file)) {
_numUnusedFiles -= 1;
_unusedFilesSize -= file->getLength();
}
}
size_t FileCache::getOverbudgetAmount() const {
size_t result = 0;
@ -241,20 +244,13 @@ void FileCache::eject(const FilePointer& file) {
const auto& length = file->getLength();
const auto& key = file->getKey();
{
Lock lock(_filesMutex);
if (0 != _files.erase(key)) {
_numTotalFiles -= 1;
_totalFilesSize -= length;
}
if (0 != _files.erase(key)) {
_numTotalFiles -= 1;
_totalFilesSize -= length;
}
{
Lock unusedLock(_unusedFilesMutex);
if (0 != _unusedFiles.erase(file)) {
_numUnusedFiles -= 1;
_unusedFilesSize -= length;
}
if (0 != _unusedFiles.erase(file)) {
_numUnusedFiles -= 1;
_unusedFilesSize -= length;
}
}
@ -266,7 +262,6 @@ void FileCache::clean() {
return;
}
Lock unusedLock(_unusedFilesMutex);
using Queue = std::priority_queue<FilePointer, std::vector<FilePointer>, FilePointerComparator>;
Queue queue;
for (const auto& file : _unusedFiles) {
@ -283,18 +278,19 @@ void FileCache::clean() {
}
void FileCache::wipe() {
Lock unusedFilesLock(_unusedFilesMutex);
Lock lock(_mutex);
while (!_unusedFiles.empty()) {
eject(*_unusedFiles.begin());
}
}
void FileCache::clear() {
Lock lock(_mutex);
// Eliminate any overbudget files
clean();
// Mark everything remaining as persisted
Lock unusedFilesLock(_unusedFilesMutex);
// Mark everything remaining as persisted while effectively ejecting from the cache
for (auto& file : _unusedFiles) {
file->_shouldPersist = true;
file->_cache = nullptr;
@ -329,4 +325,4 @@ File::~File() {
void File::touch() {
utime(_filepath.c_str(), nullptr);
_modified = std::max<int64_t>(QFileInfo(_filepath.c_str()).lastRead().toMSecsSinceEpoch(), _modified);
}
}

View file

@ -108,7 +108,6 @@ private:
FilePointer addFile(Metadata&& metadata, const std::string& filepath);
void addUnusedFile(const FilePointer& file);
void removeUnusedFile(const FilePointer& file);
void clean();
void clear();
// Remove a file from the cache
@ -125,16 +124,14 @@ private:
std::atomic<size_t> _totalFilesSize { 0 };
std::atomic<size_t> _unusedFilesSize { 0 };
std::string _ext;
std::string _dirname;
std::string _dirpath;
const std::string _ext;
const std::string _dirname;
const std::string _dirpath;
bool _initialized { false };
Mutex _mutex;
Map _files;
Mutex _filesMutex;
Set _unusedFiles;
Mutex _unusedFilesMutex;
};
class File : public QObject {

View file

@ -144,7 +144,9 @@ function onMessage(message) {
isDomainOpen(Settings.getValue("previousSnapshotDomainID"), function (canShare) {
var isGif = fileExtensionMatches(message.data, "gif");
isLoggedIn = Account.isLoggedIn();
isUploadingPrintableStill = canShare && Account.isLoggedIn() && !isGif;
if (!isGif) {
isUploadingPrintableStill = canShare && Account.isLoggedIn();
}
if (canShare) {
if (isLoggedIn) {
print('Sharing snapshot with audience "for_url":', message.data);

View file

@ -103,7 +103,7 @@ function getControllerLocation(controllerHand) {
const STRING_PULL_SOUND_URL = Script.resolvePath('Bow_draw.1.L.wav');
const ARROW_HIT_SOUND_URL = Script.resolvePath('Arrow_impact1.L.wav');
const ARROW_MODEL_URL = Script.resolvePath('arrow.fbx');
const ARROW_MODEL_URL = Script.resolvePath('models/arrow.baked.fbx');
const ARROW_DIMENSIONS = {
x: 0.20,
y: 0.19,

View file

@ -37,7 +37,7 @@ var userData = {
var id = Entities.addEntity({
"position": MyAvatar.position,
"collisionsWillMove": 1,
"compoundShapeURL": Script.resolvePath("bow_collision_hull.obj"),
"compoundShapeURL": Script.resolvePath("models/bow_collision_hull.obj"),
"created": "2016-09-01T23:57:55Z",
"dimensions": {
"x": 0.039999999105930328,
@ -50,7 +50,7 @@ var id = Entities.addEntity({
"y": -9.8,
"z": 0
},
"modelURL": Script.resolvePath("bow-deadly.fbx"),
"modelURL": Script.resolvePath("models/bow-deadly.baked.fbx"),
"name": "Hifi-Bow",
"rotation": {
"w": 0.9718012809753418,

View file

@ -114,7 +114,7 @@ SHORTBOW_ENTITIES =
"id": "{04288f77-64df-4323-ac38-9c1960a393a5}",
"lastEdited": 1487893058314990,
"lastEditedBy": "{fce8028a-4bac-43e8-96ff-4c7286ea4ab3}",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-button.fbx",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-button.baked.fbx",
"name": "SB.StartButton",
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
"parentID": "{0cd1f1f7-53b9-4c15-bf25-42c0760d16f0}",
@ -758,7 +758,7 @@ SHORTBOW_ENTITIES =
"id": "{d4c8f577-944d-4d50-ac85-e56387c0ef0a}",
"lastEdited": 1487892440231278,
"lastEditedBy": "{91f193dd-829a-4b33-ab27-e9a26160634a}",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-platform.fbx",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-platform.baked.fbx",
"name": "SB.Platform",
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
"parentID": "{0cd1f1f7-53b9-4c15-bf25-42c0760d16f0}",
@ -794,7 +794,7 @@ SHORTBOW_ENTITIES =
"id": "{0cd1f1f7-53b9-4c15-bf25-42c0760d16f0}",
"lastEdited": 1487892440231832,
"lastEditedBy": "{91f193dd-829a-4b33-ab27-e9a26160634a}",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-scoreboard.fbx",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-scoreboard.baked.fbx",
"name": "SB.Scoreboard",
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
"queryAACube": {

View file

@ -96,7 +96,7 @@
"id": "{04288f77-64df-4323-ac38-9c1960a393a5}",
"lastEdited": 1487893058314990,
"lastEditedBy": "{fce8028a-4bac-43e8-96ff-4c7286ea4ab3}",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-button.fbx",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-button.baked.fbx",
"name": "SB.StartButton",
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
"parentID": "{0cd1f1f7-53b9-4c15-bf25-42c0760d16f0}",
@ -740,7 +740,7 @@
"id": "{d4c8f577-944d-4d50-ac85-e56387c0ef0a}",
"lastEdited": 1487892440231278,
"lastEditedBy": "{91f193dd-829a-4b33-ab27-e9a26160634a}",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-platform.fbx",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-platform.baked.fbx",
"name": "SB.Platform",
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
"parentID": "{0cd1f1f7-53b9-4c15-bf25-42c0760d16f0}",
@ -776,7 +776,7 @@
"id": "{0cd1f1f7-53b9-4c15-bf25-42c0760d16f0}",
"lastEdited": 1487892440231832,
"lastEditedBy": "{91f193dd-829a-4b33-ab27-e9a26160634a}",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-scoreboard.fbx",
"modelURL": "file:///c:/Users/ryanh/dev/hifi/unpublishedScripts/marketplace/shortbow/models/shortbow-scoreboard.baked.fbx",
"name": "SB.Scoreboard",
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
"queryAACube": {

View file

@ -131,7 +131,7 @@ var baseEnemyProperties = {
},
"lifetime": 30,
"id": "{ed8f7339-8bbd-4750-968e-c3ceb9d64721}",
"modelURL": Script.resolvePath("models/Amber.fbx"),
"modelURL": Script.resolvePath("models/Amber.baked.fbx"),
"owningAvatarID": "{00000000-0000-0000-0000-000000000000}",
"queryAACube": {
"scale": 1.0999215841293335,
@ -290,7 +290,7 @@ ShortbowGameManager.prototype = {
"position": props.position,
"rotation": props.rotation,
"collisionsWillMove": 1,
"compoundShapeURL": Script.resolvePath("bow/bow_collision_hull.obj"),
"compoundShapeURL": Script.resolvePath("bow/models/bow_collision_hull.obj"),
"created": "2016-09-01T23:57:55Z",
"dimensions": {
"x": 0.039999999105930328,
@ -303,7 +303,7 @@ ShortbowGameManager.prototype = {
"y": -9.8,
"z": 0
},
"modelURL": Script.resolvePath("bow/bow-deadly.fbx"),
"modelURL": Script.resolvePath("bow/models/bow-deadly.baked.fbx"),
"name": "WG.Hifi-Bow",
"script": Script.resolvePath("bow/bow.js"),
"shapeType": "compound",