Merge branch 'master' of https://github.com/wayne-chen/hifi into loginOnLaunch

This commit is contained in:
Wayne Chen 2018-09-07 08:43:42 -07:00
commit e1541fd7e0
16 changed files with 95 additions and 35 deletions

View file

@ -146,7 +146,8 @@ Windows.Window {
Qt.WindowCloseButtonHint |
Qt.WindowMaximizeButtonHint |
Qt.WindowMinimizeButtonHint;
if ((flags & Desktop.ALWAYS_ON_TOP) === Desktop.ALWAYS_ON_TOP) {
// only use the always on top feature for non Windows OS
if (Qt.platform.os !== "windows" && (flags & Desktop.ALWAYS_ON_TOP)) {
nativeWindowFlags |= Qt.WindowStaysOnTopHint;
}
nativeWindow.flags = nativeWindowFlags;

View file

@ -530,9 +530,7 @@ Item {
maximumValue: 20.0
stepSize: 5
updateValueWhileDragging: true
Component.onCompleted: {
value = Users.getAvatarGain(uuid);
}
value: Users.getAvatarGain(uuid)
onValueChanged: {
updateGainFromQML(uuid, value, false);
}

View file

@ -238,7 +238,9 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
*/
QVariant Base3DOverlay::getProperty(const QString& property) {
if (property == "name") {
return _name;
return _nameLock.resultWithReadLock<QString>([&] {
return _name;
});
}
if (property == "position" || property == "start" || property == "p1" || property == "point") {
return vec3toVariant(getWorldPosition());
@ -346,6 +348,20 @@ void Base3DOverlay::setVisible(bool visible) {
notifyRenderVariableChange();
}
QString Base3DOverlay::getName() const {
return _nameLock.resultWithReadLock<QString>([&] {
return QString("Overlay:") + _name;
});
}
void Base3DOverlay::setName(QString name) {
_nameLock.withWriteLock([&] {
_name = name;
});
}
render::ItemKey Base3DOverlay::getKey() {
auto builder = render::ItemKey::Builder(Overlay::getKey());
@ -364,4 +380,4 @@ render::ItemKey Base3DOverlay::getKey() {
}
return builder.build();
}
}

View file

@ -29,8 +29,8 @@ public:
virtual OverlayID getOverlayID() const override { return OverlayID(getID().toString()); }
void setOverlayID(OverlayID overlayID) override { setID(overlayID); }
virtual QString getName() const override { return QString("Overlay:") + _name; }
void setName(QString name) { _name = name; }
virtual QString getName() const override;
void setName(QString name);
// getters
virtual bool is3D() const override { return true; }
@ -107,6 +107,7 @@ protected:
mutable bool _renderVariableDirty { true };
QString _name;
mutable ReadWriteLockable _nameLock;
};
#endif // hifi_Base3DOverlay_h

View file

@ -102,7 +102,7 @@ void CauterizedModel::createRenderItemSet() {
}
}
void CauterizedModel::updateClusterMatrices(bool triggerBlendshapes) {
void CauterizedModel::updateClusterMatrices() {
PerformanceTimer perfTimer("CauterizedModel::updateClusterMatrices");
if (!_needsUpdateClusterMatrices || !isLoaded()) {
@ -175,7 +175,7 @@ void CauterizedModel::updateClusterMatrices(bool triggerBlendshapes) {
// post the blender if we're not currently waiting for one to finish
auto modelBlender = DependencyManager::get<ModelBlender>();
if (triggerBlendshapes && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
if (_blendedVertexBuffersInitialized && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
modelBlender->noteRequiresBlend(getThisPointer());
}

View file

@ -33,7 +33,7 @@ public:
void createRenderItemSet() override;
virtual void updateClusterMatrices(bool triggerBlendshapes = true) override;
virtual void updateClusterMatrices() override;
void updateRenderItems() override;
const Model::MeshState& getCauterizeMeshState(int index) const;

View file

@ -976,7 +976,7 @@ bool Model::addToScene(const render::ScenePointer& scene,
render::Transaction& transaction,
render::Item::Status::Getters& statusGetters) {
if (!_addedToScene && isLoaded()) {
updateClusterMatrices(false);
updateClusterMatrices();
if (_modelMeshRenderItems.empty()) {
createRenderItemSet();
}
@ -1307,6 +1307,7 @@ void Blender::run() {
if (mesh.blendshapes.isEmpty()) {
continue;
}
vertices += mesh.vertices;
normalsAndTangents += mesh.normalsAndTangents;
glm::vec3* meshVertices = vertices.data() + offset;
@ -1486,7 +1487,7 @@ void Model::computeMeshPartLocalBounds() {
}
// virtual
void Model::updateClusterMatrices(bool triggerBlendshapes) {
void Model::updateClusterMatrices() {
DETAILED_PERFORMANCE_TIMER("Model::updateClusterMatrices");
if (!_needsUpdateClusterMatrices || !isLoaded()) {
@ -1515,7 +1516,7 @@ void Model::updateClusterMatrices(bool triggerBlendshapes) {
// post the blender if we're not currently waiting for one to finish
auto modelBlender = DependencyManager::get<ModelBlender>();
if (triggerBlendshapes && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
if (_blendedVertexBuffersInitialized && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
modelBlender->noteRequiresBlend(getThisPointer());
}
@ -1552,7 +1553,7 @@ void Model::setBlendedVertices(int blendNumber, const Geometry::WeakPointer& geo
const auto vertexCount = mesh.vertices.size();
const auto verticesSize = vertexCount * sizeof(glm::vec3);
const auto& buffer = _blendedVertexBuffers[i];
assert(buffer);
assert(buffer && _blendedVertexBuffersInitialized);
buffer->resize(mesh.vertices.size() * sizeof(glm::vec3) + mesh.normalsAndTangents.size() * sizeof(NormalType));
buffer->setSubData(0, verticesSize, (gpu::Byte*) vertices.constData() + index * sizeof(glm::vec3));
buffer->setSubData(verticesSize, mesh.normalsAndTangents.size() * sizeof(NormalType), (const gpu::Byte*) normalsAndTangents.data() + normalAndTangentIndex * sizeof(NormalType));
@ -1565,6 +1566,7 @@ void Model::setBlendedVertices(int blendNumber, const Geometry::WeakPointer& geo
void Model::deleteGeometry() {
_deleteGeometryCounter++;
_blendedVertexBuffers.clear();
_blendedVertexBuffersInitialized = false;
_meshStates.clear();
_rig.destroyAnimGraph();
_blendedBlendshapeCoefficients.clear();
@ -1630,6 +1632,7 @@ void Model::initializeBlendshapes(const FBXMesh& mesh, int index) {
_blendedVertexBuffers[index]->setSubData(0, verticesSize, (const gpu::Byte*) mesh.vertices.constData());
_blendedVertexBuffers[index]->setSubData(verticesSize, normalsAndTangents.size() * sizeof(NormalType), (const gpu::Byte*) normalsAndTangents.data());
mesh.normalsAndTangents = normalsAndTangents;
_blendedVertexBuffersInitialized = true;
}
void Model::createRenderItemSet() {

View file

@ -159,7 +159,7 @@ public:
bool getSnapModelToRegistrationPoint() { return _snapModelToRegistrationPoint; }
virtual void simulate(float deltaTime, bool fullUpdate = true);
virtual void updateClusterMatrices(bool triggerBlendshapes = true);
virtual void updateClusterMatrices();
/// Returns a reference to the shared geometry.
const Geometry::Pointer& getGeometry() const { return _renderGeometry; }
@ -345,6 +345,8 @@ public:
void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName);
void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName);
bool areBlendedVertexBuffersInitialized(int index) { return _blendedVertexBuffersInitialized; }
public slots:
void loadURLFinished(bool success);
@ -424,8 +426,9 @@ protected:
QUrl _url;
std::unordered_map<int, gpu::BufferPointer> _blendedVertexBuffers;
bool _blendedVertexBuffersInitialized { false };
QVector<QVector<QSharedPointer<Texture> > > _dilatedTextures;
QVector<QVector<QSharedPointer<Texture>>> _dilatedTextures;
QVector<float> _blendedBlendshapeCoefficients;
int _blendNumber;

View file

@ -31,7 +31,7 @@ int SoftAttachmentModel::getJointIndexOverride(int i) const {
// virtual
// use the _rigOverride matrices instead of the Model::_rig
void SoftAttachmentModel::updateClusterMatrices(bool triggerBlendshapes) {
void SoftAttachmentModel::updateClusterMatrices() {
if (!_needsUpdateClusterMatrices) {
return;
}
@ -78,7 +78,7 @@ void SoftAttachmentModel::updateClusterMatrices(bool triggerBlendshapes) {
// post the blender if we're not currently waiting for one to finish
auto modelBlender = DependencyManager::get<ModelBlender>();
if (triggerBlendshapes && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
if (_blendedVertexBuffersInitialized && modelBlender->shouldComputeBlendshapes() && geometry.hasBlendedMeshes() && _blendshapeCoefficients != _blendedBlendshapeCoefficients) {
_blendedBlendshapeCoefficients = _blendshapeCoefficients;
modelBlender->noteRequiresBlend(getThisPointer());
}

View file

@ -27,7 +27,7 @@ public:
~SoftAttachmentModel();
void updateRig(float deltaTime, glm::mat4 parentTransform) override;
void updateClusterMatrices(bool triggerBlendshapes = true) override;
void updateClusterMatrices() override;
protected:
int getJointIndexOverride(int i) const;

View file

@ -13,12 +13,19 @@
#include <QtQml/QQmlContext>
#include <QtCore/QThread>
#include <QtGui/QGuiApplication>
#include <QtQuick/QQuickWindow>
#include <DependencyManager.h>
#include <RegisteredMetaTypes.h>
#include "OffscreenUi.h"
#include "shared/QtHelpers.h"
#include "MainWindow.h"
#ifdef Q_OS_WIN
#include <WinUser.h>
#endif
static auto CONTENT_WINDOW_QML = QUrl("InteractiveWindow.qml");
@ -87,6 +94,12 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
connect(object, SIGNAL(windowClosed()), this, SIGNAL(closed()), Qt::QueuedConnection);
connect(object, SIGNAL(selfDestruct()), this, SLOT(close()), Qt::QueuedConnection);
#ifdef Q_OS_WIN
connect(object, SIGNAL(nativeWindowChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
connect(object, SIGNAL(interactiveWindowVisibleChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
connect(object, SIGNAL(presentationModeChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
#endif
QUrl sourceURL{ sourceUrl };
// If the passed URL doesn't correspond to a known scheme, assume it's a local file path
if (!KNOWN_SCHEMES.contains(sourceURL.scheme(), Qt::CaseInsensitive)) {
@ -279,6 +292,24 @@ int InteractiveWindow::getPresentationMode() const {
return _qmlWindow->property(PRESENTATION_MODE_PROPERTY).toInt();
}
#ifdef Q_OS_WIN
void InteractiveWindow::parentNativeWindowToMainWindow() {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "parentNativeWindowToMainWindow");
return;
}
if (_qmlWindow.isNull()) {
return;
}
const auto nativeWindowProperty = _qmlWindow->property("nativeWindow");
if (nativeWindowProperty.isNull() || !nativeWindowProperty.isValid()) {
return;
}
const auto nativeWindow = qvariant_cast<QQuickWindow*>(nativeWindowProperty);
SetWindowLongPtr((HWND)nativeWindow->winId(), GWLP_HWNDPARENT, (LONG)MainWindow::findMainWindow()->winId());
}
#endif
void InteractiveWindow::setPresentationMode(int presentationMode) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "setPresentationMode", Q_ARG(int, presentationMode));

View file

@ -84,6 +84,10 @@ private:
Q_INVOKABLE void setPresentationMode(int presentationMode);
Q_INVOKABLE int getPresentationMode() const;
#ifdef Q_OS_WIN
Q_INVOKABLE void parentNativeWindowToMainWindow();
#endif
public slots:
/**jsdoc

View file

@ -22,6 +22,7 @@
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QMimeData>
#include <QWindow>
#include <QDebug>
#include "ui/Logging.h"
@ -39,6 +40,18 @@ MainWindow::~MainWindow() {
qCDebug(uiLogging) << "Destroying main window";
}
QWindow* MainWindow::findMainWindow() {
auto windows = qApp->topLevelWindows();
QWindow* result = nullptr;
for (const auto& window : windows) {
if (window->objectName().contains("MainWindow")) {
result = window;
break;
}
}
return result;
}
void MainWindow::restoreGeometry() {
// Did not use setGeometry() on purpose,
// see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application

View file

@ -21,6 +21,8 @@ class MainWindow : public QMainWindow {
public:
explicit MainWindow(QWidget* parent = NULL);
~MainWindow();
static QWindow* findMainWindow();
public slots:
void restoreGeometry();

View file

@ -29,6 +29,7 @@
#include "ui/Logging.h"
#include <PointerManager.h>
#include "MainWindow.h"
/**jsdoc
* @namespace OffscreenFlags
@ -649,20 +650,7 @@ public:
}
private:
static QWindow* findMainWindow() {
auto windows = qApp->topLevelWindows();
QWindow* result = nullptr;
for (auto window : windows) {
if (window->objectName().contains("MainWindow")) {
result = window;
break;
}
}
return result;
}
QWindow* const _mainWindow { findMainWindow() };
QWindow* const _mainWindow { MainWindow::findMainWindow() };
QWindow* _hackWindow { nullptr };
};

View file

@ -192,7 +192,7 @@ namespace workload {
struct Data {
bool regulateViewRanges{ false }; // regulation is OFF by default
bool regulateViewRanges{ true }; // regulation is ON by default
} data;
struct DataExport {