mirror of
https://github.com/lubosz/overte.git
synced 2025-08-28 19:06:33 +02:00
Merge branch 'master' into 21249
This commit is contained in:
commit
2108300272
80 changed files with 2015 additions and 1482 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 150" style="enable-background:new 0 0 50 150;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#414042;}
|
||||
|
@ -8,21 +8,16 @@
|
|||
.st2{fill:#1398BB;}
|
||||
.st3{fill:#31D8FF;}
|
||||
</style>
|
||||
<g id="Layer_1">
|
||||
<path class="st0" d="M33.72,85.08l-9.15-9.15l-0.74-0.74l0.74-0.74l9.35-9.35c0.59-0.59,0.59-1.56,0-2.15
|
||||
c-0.29-0.29-0.67-0.45-1.08-0.45c-0.41,0-0.79,0.16-1.08,0.45L19.52,75.19l12.04,12.04c0.29,0.29,0.67,0.45,1.08,0.45
|
||||
c0.41,0,0.79-0.16,1.08-0.45C34.31,86.64,34.31,85.67,33.72,85.08z"/>
|
||||
<path class="st1" d="M33.72,33.45l-9.15-9.15l-0.74-0.74l0.74-0.74l9.35-9.35c0.59-0.59,0.59-1.56,0-2.15
|
||||
c-0.29-0.29-0.67-0.45-1.08-0.45c-0.41,0-0.79,0.16-1.08,0.45L19.52,23.56L31.56,35.6c0.29,0.29,0.67,0.45,1.08,0.45
|
||||
c0.41,0,0.79-0.16,1.08-0.45C34.31,35.01,34.31,34.04,33.72,33.45z"/>
|
||||
<path class="st2" d="M17.99,124.82l12.78,12.78c1,1,2.63,1,3.63,0c1-1,1-2.63,0-3.63l-9.15-9.15l9.35-9.35c1-1,1-2.63,0-3.63
|
||||
c-1-1-2.63-1-3.63,0L17.99,124.82z"/>
|
||||
<path class="st3" d="M32.79,112.13c0.41,0,0.79,0.16,1.08,0.45c0.59,0.59,0.59,1.56,0,2.15l-9.35,9.35l-0.74,0.74l0.74,0.74
|
||||
l9.15,9.15c0.59,0.59,0.59,1.56,0,2.15c-0.29,0.29-0.67,0.45-1.08,0.45c-0.41,0-0.79-0.16-1.08-0.45l-12.04-12.04l12.24-12.24
|
||||
C32,112.29,32.38,112.13,32.79,112.13 M32.79,111.08c-0.66,0-1.31,0.25-1.82,0.75l-12.98,12.98l12.78,12.78
|
||||
c0.5,0.5,1.16,0.75,1.82,0.75c0.66,0,1.31-0.25,1.82-0.75c1-1,1-2.63,0-3.63l-9.15-9.15l9.35-9.35c1-1,1-2.63,0-3.63
|
||||
C34.1,111.34,33.44,111.08,32.79,111.08L32.79,111.08z"/>
|
||||
</g>
|
||||
<path class="st0" d="M33.4,87.4L22.1,76.1l-0.9-0.9l0.9-0.9l11.5-11.5c0.7-0.7,0.7-1.9,0-2.7c-0.3-0.3-0.8-0.5-1.3-0.5
|
||||
s-1,0.2-1.3,0.5L15.9,75.2l14.9,14.9c0.4,0.4,0.8,0.6,1.3,0.6c0.5,0,1-0.2,1.3-0.6C34.2,89.3,34.2,88.2,33.4,87.4z"/>
|
||||
<path class="st1" d="M33.4,37.1L22.1,25.8l-0.9-0.9l0.9-0.9l11.5-11.5c0.7-0.7,0.7-1.9,0-2.7c-0.3-0.4-0.8-0.6-1.3-0.6
|
||||
s-1,0.2-1.3,0.6L15.9,24.9l14.9,14.9c0.4,0.4,0.8,0.5,1.3,0.5c0.5,0,1-0.2,1.3-0.5C34.2,39,34.2,37.8,33.4,37.1z"/>
|
||||
<path class="st2" d="M14.1,124.8l15.8,15.8c1.2,1.2,3.2,1.2,4.5,0c1.2-1.2,1.2-3.2,0-4.5L23,124.8l11.5-11.5c1.2-1.2,1.2-3.2,0-4.5
|
||||
c-1.2-1.2-3.2-1.2-4.5,0L14.1,124.8z"/>
|
||||
<path class="st3" d="M32.4,109.2c0.5,0,1,0.2,1.3,0.6c0.7,0.7,0.7,1.9,0,2.7l-11.5,11.5l-0.9,0.9l0.9,0.9l11.3,11.3
|
||||
c0.7,0.7,0.7,1.9,0,2.7c-0.4,0.4-0.8,0.6-1.3,0.6s-1-0.2-1.3-0.6l-14.9-14.9L31,109.7C31.4,109.4,31.9,109.2,32.4,109.2 M32.4,107.9
|
||||
c-0.8,0-1.6,0.3-2.2,0.9l-16,16l15.8,15.8c0.6,0.6,1.4,0.9,2.2,0.9s1.6-0.3,2.2-0.9c1.2-1.2,1.2-3.2,0-4.5l-11.3-11.3l11.5-11.6
|
||||
c1.2-1.2,1.2-3.2,0-4.5C34,108.2,33.2,107.9,32.4,107.9L32.4,107.9z"/>
|
||||
<g id="Layer_2">
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.5 KiB |
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 150" style="enable-background:new 0 0 50 150;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#414042;}
|
||||
|
@ -8,21 +8,16 @@
|
|||
.st2{fill:#1398BB;}
|
||||
.st3{fill:#31D8FF;}
|
||||
</style>
|
||||
<g id="Layer_1">
|
||||
<path class="st0" d="M21.12,62.95c-0.29-0.29-0.67-0.45-1.08-0.45c-0.41,0-0.79,0.16-1.08,0.45c-0.59,0.59-0.59,1.56,0,2.15
|
||||
l9.35,9.35l0.74,0.74l-0.74,0.74l-9.15,9.15c-0.59,0.59-0.59,1.56,0,2.15c0.29,0.29,0.67,0.45,1.08,0.45
|
||||
c0.41,0,0.79-0.16,1.08-0.45l12.04-12.04L21.12,62.95z"/>
|
||||
<path class="st1" d="M21.12,11.32c-0.29-0.29-0.67-0.45-1.08-0.45c-0.41,0-0.79,0.16-1.08,0.45c-0.59,0.59-0.59,1.56,0,2.15
|
||||
l9.35,9.35l0.74,0.74l-0.74,0.74l-9.15,9.15c-0.59,0.59-0.59,1.56,0,2.15c0.29,0.29,0.67,0.45,1.08,0.45
|
||||
c0.41,0,0.79-0.16,1.08-0.45l12.04-12.04L21.12,11.32z"/>
|
||||
<path class="st2" d="M34.9,124.82L22.11,137.6c-1,1-2.63,1-3.63,0c-1-1-1-2.63,0-3.63l9.15-9.15l-9.35-9.35c-1-1-1-2.63,0-3.63
|
||||
c1-1,2.63-1,3.63,0L34.9,124.82z"/>
|
||||
<path class="st3" d="M20.1,112.13c0.41,0,0.79,0.16,1.08,0.45l12.24,12.24l-12.04,12.04c-0.29,0.29-0.67,0.45-1.08,0.45
|
||||
c-0.41,0-0.79-0.16-1.08-0.45c-0.59-0.59-0.59-1.56,0-2.15l9.15-9.15l0.74-0.74l-0.74-0.74l-9.35-9.35c-0.59-0.59-0.59-1.56,0-2.15
|
||||
C19.31,112.29,19.69,112.13,20.1,112.13 M20.1,111.08c-0.66,0-1.31,0.25-1.82,0.75c-1,1-1,2.63,0,3.63l9.35,9.35l-9.15,9.15
|
||||
c-1,1-1,2.63,0,3.63c0.5,0.5,1.16,0.75,1.82,0.75s1.31-0.25,1.82-0.75l12.78-12.78l-12.98-12.98
|
||||
C21.41,111.34,20.76,111.08,20.1,111.08L20.1,111.08z"/>
|
||||
</g>
|
||||
<path class="st0" d="M21.1,60.1c-0.4-0.4-0.8-0.5-1.3-0.5s-1,0.2-1.3,0.5c-0.7,0.7-0.7,1.9,0,2.7l11.5,11.5l0.9,0.9l-0.9,0.9
|
||||
L18.6,87.4c-0.7,0.7-0.7,1.9,0,2.7c0.4,0.3,0.8,0.6,1.3,0.6s1-0.2,1.3-0.6l14.9-14.9L21.1,60.1z"/>
|
||||
<path class="st1" d="M21.1,9.8c-0.4-0.4-0.8-0.6-1.3-0.6s-1,0.2-1.3,0.6c-0.7,0.7-0.7,1.9,0,2.7L29.9,24l0.9,0.9l-0.9,0.9L18.6,37.1
|
||||
c-0.7,0.7-0.7,1.9,0,2.7c0.4,0.4,0.8,0.5,1.3,0.5s1-0.2,1.3-0.5l14.9-14.9L21.1,9.8z"/>
|
||||
<path class="st2" d="M38,124.8l-15.8,15.8c-1.2,1.2-3.2,1.2-4.5,0c-1.2-1.2-1.2-3.2,0-4.5L29,124.8l-11.5-11.5
|
||||
c-1.2-1.2-1.2-3.2,0-4.5c1.2-1.2,3.2-1.2,4.5,0L38,124.8z"/>
|
||||
<path class="st3" d="M19.7,109.2c0.5,0,1,0.2,1.3,0.6l15.1,15.1l-14.9,14.9c-0.4,0.4-0.8,0.6-1.3,0.6s-1-0.2-1.3-0.6
|
||||
c-0.7-0.7-0.7-1.9,0-2.7l11.3-11.3l0.9-0.9l-0.9-0.9l-11.5-11.5c-0.7-0.7-0.7-1.9,0-2.7C18.8,109.4,19.2,109.2,19.7,109.2
|
||||
M19.7,107.9c-0.8,0-1.6,0.3-2.2,0.9c-1.2,1.2-1.2,3.2,0,4.5L29,124.8l-11.3,11.3c-1.2,1.2-1.2,3.2,0,4.5c0.6,0.6,1.4,0.9,2.2,0.9
|
||||
s1.6-0.3,2.2-0.9L38,124.8l-16-16C21.4,108.2,20.5,107.9,19.7,107.9L19.7,107.9z"/>
|
||||
<g id="Layer_2">
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.5 KiB |
|
@ -542,7 +542,7 @@ ScrollingWindow {
|
|||
Item {
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
HifiControls.Button {
|
||||
HifiControls.QueuedButton {
|
||||
id: uploadButton
|
||||
anchors.right: parent.right
|
||||
|
||||
|
@ -552,22 +552,7 @@ ScrollingWindow {
|
|||
height: 30
|
||||
width: 155
|
||||
|
||||
onClicked: uploadClickedTimer.running = true
|
||||
|
||||
// For some reason trigginer an API that enters
|
||||
// an internal event loop directly from the button clicked
|
||||
// trigger below causes the appliction to behave oddly.
|
||||
// Most likely because the button onClicked handling is never
|
||||
// completed until the function returns.
|
||||
// FIXME find a better way of handling the input dialogs that
|
||||
// doesn't trigger this.
|
||||
Timer {
|
||||
id: uploadClickedTimer
|
||||
interval: 5
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: uploadClicked();
|
||||
}
|
||||
onClickedQueued: uploadClicked()
|
||||
}
|
||||
|
||||
Item {
|
||||
|
|
43
interface/resources/qml/controls-uit/QueuedButton.qml
Normal file
43
interface/resources/qml/controls-uit/QueuedButton.qml
Normal file
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// QueuedButton.qml
|
||||
// -- original Button.qml + signal timer workaround --ht
|
||||
// Created by David Rowe on 16 Feb 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
|
||||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4 as Original
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import "../styles-uit"
|
||||
import "." as HifiControls
|
||||
|
||||
HifiControls.Button {
|
||||
// FIXME: THIS WORKAROUND MIGRATED/CONSOLIDATED FROM RUNNINGSCRIPTS.QML
|
||||
|
||||
// For some reason trigginer an API that enters
|
||||
// an internal event loop directly from the button clicked
|
||||
// trigger below causes the appliction to behave oddly.
|
||||
// Most likely because the button onClicked handling is never
|
||||
// completed until the function returns.
|
||||
// FIXME find a better way of handling the input dialogs that
|
||||
// doesn't trigger this.
|
||||
|
||||
// NOTE: dialogs that need to use this workaround can connect via
|
||||
// onQueuedClicked: ...
|
||||
// instead of:
|
||||
// onClicked: ...
|
||||
|
||||
signal clickedQueued()
|
||||
Timer {
|
||||
id: fromTimer
|
||||
interval: 5
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: clickedQueued()
|
||||
}
|
||||
onClicked: fromTimer.running = true
|
||||
}
|
53
interface/resources/qml/controls/TabletWebButton.qml
Normal file
53
interface/resources/qml/controls/TabletWebButton.qml
Normal file
|
@ -0,0 +1,53 @@
|
|||
//
|
||||
// TabletWebButton.qml
|
||||
//
|
||||
// Created by Dante Ruiz on 2017/4/13
|
||||
// Copyright 2015 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
|
||||
//
|
||||
|
||||
import Hifi 1.0
|
||||
import QtQuick 2.4
|
||||
import "../styles-uit"
|
||||
|
||||
Rectangle {
|
||||
property alias text: label.text
|
||||
property alias pixelSize: label.font.pixelSize;
|
||||
property bool selected: false
|
||||
property bool hovered: false
|
||||
property bool enabled: false
|
||||
property int spacing: 2
|
||||
property var action: function () {}
|
||||
property string enabledColor: hifi.colors.blueHighlight
|
||||
property string disabledColor: hifi.colors.blueHighlight
|
||||
property string highlightColor: hifi.colors.blueHighlight;
|
||||
width: label.width + 64
|
||||
height: 32
|
||||
color: hifi.colors.white
|
||||
HifiConstants { id: hifi }
|
||||
RalewaySemiBold {
|
||||
id: label;
|
||||
color: enabledColor
|
||||
font.pixelSize: 15;
|
||||
anchors {
|
||||
horizontalCenter: parent.horizontalCenter;
|
||||
verticalCenter: parent.verticalCenter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Rectangle {
|
||||
id: indicator
|
||||
width: parent.width
|
||||
height: selected ? 3 : 1
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
color: hifi.colors.blueHighlight
|
||||
visible: parent.selected || hovered
|
||||
}
|
||||
}
|
|
@ -2,97 +2,81 @@ import QtQuick 2.5
|
|||
import QtQuick.Controls 1.4
|
||||
import QtWebEngine 1.2
|
||||
import QtWebChannel 1.0
|
||||
import HFTabletWebEngineProfile 1.0
|
||||
import "../controls-uit" as HiFiControls
|
||||
import "../styles" as HifiStyles
|
||||
import "../styles-uit"
|
||||
import HFWebEngineProfile 1.0
|
||||
import HFTabletWebEngineProfile 1.0
|
||||
import "../"
|
||||
import "."
|
||||
Item {
|
||||
id: web
|
||||
HifiConstants { id: hifi }
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
property var parentStackItem: null
|
||||
property int headerHeight: 38
|
||||
property int headerHeight: 70
|
||||
property string url
|
||||
property string address: url //for compatibility
|
||||
property alias address: displayUrl.text //for compatibility
|
||||
property string scriptURL
|
||||
property alias eventBridge: eventBridgeWrapper.eventBridge
|
||||
property bool keyboardEnabled: HMD.active
|
||||
property bool keyboardRaised: false
|
||||
property bool punctuationMode: false
|
||||
property bool isDesktop: false
|
||||
property WebEngineView view: loader.currentView
|
||||
|
||||
|
||||
property int currentPage: -1 // used as a model for repeater
|
||||
property alias pagesModel: pagesModel
|
||||
|
||||
Row {
|
||||
Rectangle {
|
||||
id: buttons
|
||||
HifiConstants { id: hifi }
|
||||
HifiStyles.HifiConstants { id: hifistyles }
|
||||
height: headerHeight
|
||||
spacing: 4
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 8
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 8
|
||||
HiFiGlyphs {
|
||||
id: back;
|
||||
enabled: currentPage >= 0
|
||||
text: hifi.glyphs.backward
|
||||
color: enabled ? hifistyles.colors.text : hifistyles.colors.disabledText
|
||||
size: 48
|
||||
MouseArea { anchors.fill: parent; onClicked: goBack() }
|
||||
}
|
||||
|
||||
HiFiGlyphs {
|
||||
id: forward;
|
||||
enabled: currentPage < pagesModel.count - 1
|
||||
text: hifi.glyphs.forward
|
||||
color: enabled ? hifistyles.colors.text : hifistyles.colors.disabledText
|
||||
size: 48
|
||||
MouseArea { anchors.fill: parent; onClicked: goForward() }
|
||||
}
|
||||
|
||||
HiFiGlyphs {
|
||||
id: reload;
|
||||
enabled: view != null;
|
||||
text: (view !== null && view.loading) ? hifi.glyphs.close : hifi.glyphs.reload
|
||||
color: enabled ? hifistyles.colors.text : hifistyles.colors.disabledText
|
||||
size: 48
|
||||
MouseArea { anchors.fill: parent; onClicked: reloadPage(); }
|
||||
}
|
||||
|
||||
}
|
||||
width: parent.width
|
||||
height: parent.headerHeight
|
||||
color: hifi.colors.white
|
||||
|
||||
TextField {
|
||||
id: addressBar
|
||||
height: 30
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 8
|
||||
anchors.left: buttons.right
|
||||
anchors.leftMargin: 0
|
||||
anchors.verticalCenter: buttons.verticalCenter
|
||||
focus: true
|
||||
text: address
|
||||
Component.onCompleted: ScriptDiscoveryService.scriptsModelFilter.filterRegExp = new RegExp("^.*$", "i")
|
||||
Row {
|
||||
id: nav
|
||||
anchors {
|
||||
top: parent.top
|
||||
topMargin: 10
|
||||
horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
spacing: 120
|
||||
|
||||
TabletWebButton {
|
||||
id: back
|
||||
enabledColor: hifi.colors.baseGray
|
||||
enabled: false
|
||||
text: "BACK"
|
||||
|
||||
Keys.onPressed: {
|
||||
switch (event.key) {
|
||||
case Qt.Key_Enter:
|
||||
case Qt.Key_Return:
|
||||
event.accepted = true;
|
||||
if (text.indexOf("http") != 0) {
|
||||
text = "http://" + text;
|
||||
}
|
||||
//root.hidePermissionsBar();
|
||||
web.keyboardRaised = false;
|
||||
gotoPage(text);
|
||||
break;
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: goBack()
|
||||
hoverEnabled: true
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TabletWebButton {
|
||||
id: close
|
||||
enabledColor: hifi.colors.darkGray
|
||||
text: "CLOSE"
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: closeWebEngine()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RalewaySemiBold {
|
||||
id: displayUrl
|
||||
color: hifi.colors.baseGray
|
||||
font.pixelSize: 12
|
||||
anchors {
|
||||
top: nav.bottom
|
||||
horizontalCenter: parent.horizontalCenter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,15 +84,30 @@ Item {
|
|||
ListModel {
|
||||
id: pagesModel
|
||||
onCountChanged: {
|
||||
currentPage = count - 1
|
||||
currentPage = count - 1;
|
||||
if (currentPage > 0) {
|
||||
back.enabledColor = hifi.colors.darkGray;
|
||||
} else {
|
||||
back.enabledColor = hifi.colors.baseGray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
if (currentPage > 0) {
|
||||
currentPage--;
|
||||
} else if (parentStackItem) {
|
||||
if (webview.canGoBack) {
|
||||
pagesModel.remove(currentPage);
|
||||
webview.goBack();
|
||||
} else if (currentPage > 0) {
|
||||
pagesModel.remove(currentPage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function closeWebEngine() {
|
||||
if (parentStackItem) {
|
||||
parentStackItem.pop();
|
||||
} else {
|
||||
web.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,18 +129,20 @@ Item {
|
|||
|
||||
function urlAppend(url) {
|
||||
var lurl = decodeURIComponent(url)
|
||||
if (lurl[lurl.length - 1] !== "/")
|
||||
if (lurl[lurl.length - 1] !== "/") {
|
||||
lurl = lurl + "/"
|
||||
if (currentPage === -1 || pagesModel.get(currentPage).webUrl !== lurl) {
|
||||
pagesModel.append({webUrl: lurl})
|
||||
}
|
||||
if (currentPage === -1 || (pagesModel.get(currentPage).webUrl !== lurl && !timer.running)) {
|
||||
timer.start();
|
||||
pagesModel.append({webUrl: lurl});
|
||||
}
|
||||
}
|
||||
|
||||
onCurrentPageChanged: {
|
||||
if (currentPage >= 0 && currentPage < pagesModel.count && loader.item !== null) {
|
||||
loader.item.url = pagesModel.get(currentPage).webUrl
|
||||
web.url = loader.item.url
|
||||
web.address = loader.item.url
|
||||
if (currentPage >= 0 && currentPage < pagesModel.count) {
|
||||
webview.url = pagesModel.get(currentPage).webUrl;
|
||||
web.url = webview.url;
|
||||
web.address = webview.url;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,45 +156,110 @@ Item {
|
|||
property var eventBridge;
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
Timer {
|
||||
id: timer
|
||||
interval: 100
|
||||
running: false
|
||||
repeat: false
|
||||
onTriggered: timer.stop();
|
||||
}
|
||||
|
||||
property WebEngineView currentView: null
|
||||
|
||||
|
||||
|
||||
WebEngineView {
|
||||
id: webview
|
||||
objectName: "webEngineView"
|
||||
x: 0
|
||||
y: 0
|
||||
width: parent.width
|
||||
height: parent.height - web.headerHeight
|
||||
asynchronous: true
|
||||
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height - web.headerHeight : parent.height - web.headerHeight
|
||||
anchors.top: buttons.bottom
|
||||
active: false
|
||||
source: "../TabletBrowser.qml"
|
||||
onStatusChanged: {
|
||||
if (loader.status === Loader.Ready) {
|
||||
currentView = item.webView
|
||||
item.webView.userScriptUrl = web.scriptURL
|
||||
if (currentPage >= 0) {
|
||||
//we got something to load already
|
||||
item.url = pagesModel.get(currentPage).webUrl
|
||||
web.address = loader.item.url
|
||||
profile: HFTabletWebEngineProfile {
|
||||
id: webviewTabletProfile
|
||||
storageName: "qmlTabletWebEngine"
|
||||
}
|
||||
|
||||
property string userScriptUrl: ""
|
||||
|
||||
// creates a global EventBridge object.
|
||||
WebEngineScript {
|
||||
id: createGlobalEventBridge
|
||||
sourceCode: eventBridgeJavaScriptToInject
|
||||
injectionPoint: WebEngineScript.DocumentCreation
|
||||
worldId: WebEngineScript.MainWorld
|
||||
}
|
||||
|
||||
// detects when to raise and lower virtual keyboard
|
||||
WebEngineScript {
|
||||
id: raiseAndLowerKeyboard
|
||||
injectionPoint: WebEngineScript.Deferred
|
||||
sourceUrl: resourceDirectoryUrl + "/html/raiseAndLowerKeyboard.js"
|
||||
worldId: WebEngineScript.MainWorld
|
||||
}
|
||||
|
||||
// User script.
|
||||
WebEngineScript {
|
||||
id: userScript
|
||||
sourceUrl: webview.userScriptUrl
|
||||
injectionPoint: WebEngineScript.DocumentReady // DOM ready but page load may not be finished.
|
||||
worldId: WebEngineScript.MainWorld
|
||||
}
|
||||
|
||||
userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard, userScript ]
|
||||
|
||||
property string newUrl: ""
|
||||
|
||||
webChannel.registeredObjects: [eventBridgeWrapper]
|
||||
|
||||
Component.onCompleted: {
|
||||
// Ensure the JS from the web-engine makes it to our logging
|
||||
webview.javaScriptConsoleMessage.connect(function(level, message, lineNumber, sourceID) {
|
||||
console.log("Web Entity JS message: " + sourceID + " " + lineNumber + " " + message);
|
||||
});
|
||||
|
||||
webview.profile.httpUserAgent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36";
|
||||
web.address = url;
|
||||
}
|
||||
|
||||
onFeaturePermissionRequested: {
|
||||
grantFeaturePermission(securityOrigin, feature, true);
|
||||
}
|
||||
|
||||
onLoadingChanged: {
|
||||
keyboardRaised = false;
|
||||
punctuationMode = false;
|
||||
keyboard.resetShiftMode(false);
|
||||
|
||||
// Required to support clicking on "hifi://" links
|
||||
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
||||
urlAppend(loadRequest.url.toString())
|
||||
var url = loadRequest.url.toString();
|
||||
if (urlHandler.canHandleUrl(url)) {
|
||||
if (urlHandler.handleUrl(url)) {
|
||||
root.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onNewViewRequested: {
|
||||
request.openIn(webview);
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
web.isDesktop = (typeof desktop !== "undefined");
|
||||
address = url;
|
||||
loader.active = true
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
Keys.onPressed: {
|
||||
switch(event.key) {
|
||||
case Qt.Key_L:
|
||||
if (event.modifiers == Qt.ControlModifier) {
|
||||
event.accepted = true
|
||||
addressBar.selectAll()
|
||||
addressBar.forceActiveFocus()
|
||||
}
|
||||
break;
|
||||
case Qt.Key_L:
|
||||
if (event.modifiers == Qt.ControlModifier) {
|
||||
event.accepted = true
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import "../../hifi/tablet/tabletWindows/preferences"
|
|||
Preference {
|
||||
id: root
|
||||
property alias text: dataTextField.text
|
||||
property alias buttonText: button.text
|
||||
property alias placeholderText: dataTextField.placeholderText
|
||||
property var browser;
|
||||
height: control.height + hifi.dimensions.controlInterlineHeight
|
||||
|
@ -58,28 +57,46 @@ Preference {
|
|||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
height: Math.max(dataTextField.controlHeight, button.height)
|
||||
height: dataTextField.controlHeight + bookmarkAvatarButton.height + hifi.dimensions.contentSpacing.y
|
||||
|
||||
TextField {
|
||||
id: dataTextField
|
||||
label: root.label
|
||||
placeholderText: root.placeholderText
|
||||
text: preference.value
|
||||
label: root.label
|
||||
colorScheme: dataTextField.acceptableInput ? hifi.colorSchemes.dark : hifi.colorSchemes.light
|
||||
validator: RegExpValidator {
|
||||
regExp: /.*\.(?:fst).*\?*/ig
|
||||
}
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: button.left
|
||||
rightMargin: hifi.dimensions.contentSpacing.x
|
||||
bottom: parent.bottom
|
||||
right: parent.right
|
||||
bottom: bookmarkAvatarButton.top
|
||||
bottomMargin: hifi.dimensions.contentSpacing.y
|
||||
}
|
||||
colorScheme: hifi.colorSchemes.dark
|
||||
}
|
||||
|
||||
QueuedButton {
|
||||
id: bookmarkAvatarButton
|
||||
text: "Bookmark Avatar"
|
||||
width: 140
|
||||
visible: dataTextField.acceptableInput
|
||||
anchors {
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
rightMargin: hifi.dimensions.contentSpacing.x
|
||||
}
|
||||
onClickedQueued: ApplicationInterface.loadAddAvatarBookmarkDialog()
|
||||
}
|
||||
|
||||
Button {
|
||||
id: button
|
||||
text: "Browse"
|
||||
id: browseAvatarsButton
|
||||
text: "Browse Avatars"
|
||||
width: 140
|
||||
anchors {
|
||||
right: parent.right
|
||||
verticalCenter: dataTextField.verticalCenter
|
||||
left: dataTextField.acceptableInput ? bookmarkAvatarButton.right : parent.left
|
||||
bottom: parent.bottom
|
||||
leftMargin: dataTextField.acceptableInput ? hifi.dimensions.contentSpacing.x : 0
|
||||
}
|
||||
onClicked: {
|
||||
if (typeof desktop !== "undefined") {
|
||||
|
@ -103,5 +120,6 @@ Preference {
|
|||
eventBridge: tabletRoot.eventBridge
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,41 +219,18 @@ ScrollingWindow {
|
|||
Row {
|
||||
spacing: hifi.dimensions.contentSpacing.x
|
||||
|
||||
HifiControls.Button {
|
||||
HifiControls.QueuedButton {
|
||||
text: "from URL"
|
||||
color: hifi.buttons.black
|
||||
height: 26
|
||||
onClicked: fromUrlTimer.running = true
|
||||
|
||||
// For some reason trigginer an API that enters
|
||||
// an internal event loop directly from the button clicked
|
||||
// trigger below causes the appliction to behave oddly.
|
||||
// Most likely because the button onClicked handling is never
|
||||
// completed until the function returns.
|
||||
// FIXME find a better way of handling the input dialogs that
|
||||
// doesn't trigger this.
|
||||
Timer {
|
||||
id: fromUrlTimer
|
||||
interval: 5
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: ApplicationInterface.loadScriptURLDialog();
|
||||
}
|
||||
onClickedQueued: ApplicationInterface.loadScriptURLDialog()
|
||||
}
|
||||
|
||||
HifiControls.Button {
|
||||
HifiControls.QueuedButton {
|
||||
text: "from Disk"
|
||||
color: hifi.buttons.black
|
||||
height: 26
|
||||
onClicked: fromDiskTimer.running = true
|
||||
|
||||
Timer {
|
||||
id: fromDiskTimer
|
||||
interval: 5
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: ApplicationInterface.loadDialog();
|
||||
}
|
||||
onClickedQueued: ApplicationInterface.loadDialog()
|
||||
}
|
||||
|
||||
HifiControls.Button {
|
||||
|
|
|
@ -20,8 +20,10 @@ import "../toolbars"
|
|||
import "../../styles-uit" as HifiStyles
|
||||
import "../../controls-uit" as HifiControls
|
||||
|
||||
// references HMD, AddressManager, AddressBarDialog from root context
|
||||
|
||||
StackView {
|
||||
id: root
|
||||
id: root;
|
||||
HifiConstants { id: hifi }
|
||||
HifiStyles.HifiConstants { id: hifiStyleConstants }
|
||||
initialItem: addressBarDialog
|
||||
|
@ -34,24 +36,16 @@ StackView {
|
|||
property string metaverseBase: addressBarDialog.metaverseServerUrl + "/api/v1/";
|
||||
|
||||
property var tablet: null;
|
||||
property bool isDesktop: false;
|
||||
|
||||
Component { id: tabletStoryCard; TabletStoryCard {} }
|
||||
Component { id: tabletWebView; TabletWebView {} }
|
||||
Component.onCompleted: {
|
||||
root.currentItem.focus = true;
|
||||
root.currentItem.forceActiveFocus();
|
||||
addressLine.focus = true;
|
||||
addressLine.forceActiveFocus();
|
||||
fillDestinations();
|
||||
updateLocationText(false);
|
||||
fillDestinations();
|
||||
addressLine.focus = !HMD.active;
|
||||
root.parentChanged.connect(center);
|
||||
center();
|
||||
isDesktop = (typeof desktop !== "undefined");
|
||||
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
|
||||
if (desktop) {
|
||||
root.title = "GOTO";
|
||||
}
|
||||
}
|
||||
Component.onDestruction: {
|
||||
root.parentChanged.disconnect(center);
|
||||
|
@ -68,9 +62,9 @@ StackView {
|
|||
}
|
||||
function goCard(targetString) {
|
||||
if (0 !== targetString.indexOf('hifi://')) {
|
||||
var card = tabletStoryCard.createObject();
|
||||
card.setUrl(addressBarDialog.metaverseServerUrl + targetString);
|
||||
card.eventBridge = root.eventBridge;
|
||||
var card = tabletWebView.createObject();
|
||||
card.url = addressBarDialog.metaverseServerUrl + targetString;
|
||||
card.parentStackItem = root;
|
||||
root.push(card);
|
||||
return;
|
||||
}
|
||||
|
@ -78,8 +72,6 @@ StackView {
|
|||
toggleOrGo(true, targetString);
|
||||
clearAddressLineTimer.start();
|
||||
}
|
||||
|
||||
property bool isCursorVisible: false // Override default cursor visibility.
|
||||
|
||||
|
||||
AddressBarDialog {
|
||||
|
@ -102,16 +94,11 @@ StackView {
|
|||
onMetaverseServerUrlChanged: updateLocationTextTimer.start();
|
||||
Rectangle {
|
||||
id: navBar
|
||||
width: 480
|
||||
height: 70
|
||||
width: parent.width
|
||||
height: 50;
|
||||
color: hifiStyleConstants.colors.white
|
||||
anchors {
|
||||
top: parent.top
|
||||
right: parent.right
|
||||
rightMargin: 0
|
||||
left: parent.left
|
||||
leftMargin: 0
|
||||
}
|
||||
anchors.top: parent.top;
|
||||
anchors.left: parent.left;
|
||||
|
||||
ToolbarButton {
|
||||
id: homeButton
|
||||
|
@ -129,8 +116,14 @@ StackView {
|
|||
}
|
||||
ToolbarButton {
|
||||
id: backArrow;
|
||||
buttonState: addressBarDialog.backEnabled;
|
||||
imageURL: "../../../images/backward.svg";
|
||||
onClicked: addressBarDialog.loadBack();
|
||||
buttonEnabled: addressBarDialog.backEnabled;
|
||||
onClicked: {
|
||||
if (buttonEnabled) {
|
||||
addressBarDialog.loadBack();
|
||||
}
|
||||
}
|
||||
anchors {
|
||||
left: homeButton.right
|
||||
verticalCenter: parent.verticalCenter
|
||||
|
@ -138,8 +131,14 @@ StackView {
|
|||
}
|
||||
ToolbarButton {
|
||||
id: forwardArrow;
|
||||
buttonState: addressBarDialog.forwardEnabled;
|
||||
imageURL: "../../../images/forward.svg";
|
||||
onClicked: addressBarDialog.loadForward();
|
||||
buttonEnabled: addressBarDialog.forwardEnabled;
|
||||
onClicked: {
|
||||
if (buttonEnabled) {
|
||||
addressBarDialog.loadForward();
|
||||
}
|
||||
}
|
||||
anchors {
|
||||
left: backArrow.right
|
||||
verticalCenter: parent.verticalCenter
|
||||
|
@ -149,85 +148,80 @@ StackView {
|
|||
|
||||
Rectangle {
|
||||
id: addressBar
|
||||
width: 480
|
||||
width: parent.width
|
||||
height: 70
|
||||
color: hifiStyleConstants.colors.white
|
||||
anchors {
|
||||
top: navBar.bottom
|
||||
right: parent.right
|
||||
rightMargin: 16
|
||||
left: parent.left
|
||||
leftMargin: 16
|
||||
top: navBar.bottom;
|
||||
left: parent.left;
|
||||
}
|
||||
|
||||
property int inputAreaHeight: 70
|
||||
property int inputAreaStep: (height - inputAreaHeight) / 2
|
||||
|
||||
HifiStyles.RalewayLight {
|
||||
id: notice;
|
||||
font.pixelSize: hifi.fonts.pixelSize * 0.50;
|
||||
font.pixelSize: hifi.fonts.pixelSize * 0.7;
|
||||
anchors {
|
||||
top: parent.top
|
||||
topMargin: parent.inputAreaStep + 12
|
||||
left: addressLine.left
|
||||
right: addressLine.right
|
||||
top: parent.top;
|
||||
left: addressLineContainer.left;
|
||||
right: addressLineContainer.right;
|
||||
}
|
||||
}
|
||||
|
||||
HifiStyles.FiraSansRegular {
|
||||
id: location;
|
||||
anchors {
|
||||
left: addressLineContainer.left;
|
||||
leftMargin: 8;
|
||||
verticalCenter: addressLineContainer.verticalCenter;
|
||||
}
|
||||
font.pixelSize: addressLine.font.pixelSize;
|
||||
color: "gray";
|
||||
clip: true;
|
||||
anchors.fill: addressLine;
|
||||
visible: addressLine.text.length === 0
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: addressLine
|
||||
focus: true
|
||||
width: addressLineContainer.width - addressLineContainer.anchors.leftMargin - addressLineContainer.anchors.rightMargin;
|
||||
anchors {
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
leftMargin: 16
|
||||
rightMargin: 16
|
||||
topMargin: parent.inputAreaStep + (2 * hifi.layout.spacing)
|
||||
bottomMargin: parent.inputAreaStep
|
||||
left: addressLineContainer.left;
|
||||
leftMargin: 8;
|
||||
verticalCenter: addressLineContainer.verticalCenter;
|
||||
}
|
||||
font.pixelSize: hifi.fonts.pixelSize * 0.75
|
||||
cursorVisible: false
|
||||
onTextChanged: {
|
||||
filterChoicesByText();
|
||||
updateLocationText(text.length > 0);
|
||||
if (!isCursorVisible && text.length > 0) {
|
||||
isCursorVisible = true;
|
||||
cursorVisible = true;
|
||||
}
|
||||
}
|
||||
onAccepted: {
|
||||
addressBarDialog.keyboardEnabled = false;
|
||||
}
|
||||
onActiveFocusChanged: {
|
||||
cursorVisible = isCursorVisible && focus;
|
||||
}
|
||||
MouseArea {
|
||||
// If user clicks in address bar show cursor to indicate ability to enter address.
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
isCursorVisible = true;
|
||||
parent.cursorVisible = true;
|
||||
parent.focus = true;
|
||||
parent.forceActiveFocus();
|
||||
addressBarDialog.keyboardEnabled = HMD.active
|
||||
tabletRoot.playButtonClickSound();
|
||||
}
|
||||
toggleOrGo();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: addressLine
|
||||
id: addressLineContainer;
|
||||
height: 40;
|
||||
anchors {
|
||||
top: notice.bottom;
|
||||
topMargin: 2;
|
||||
left: parent.left;
|
||||
leftMargin: 16;
|
||||
right: parent.right;
|
||||
rightMargin: 16;
|
||||
}
|
||||
color: hifiStyleConstants.colors.lightGray
|
||||
opacity: 0.1
|
||||
MouseArea {
|
||||
anchors.fill: parent;
|
||||
onClicked: {
|
||||
if (!addressLine.focus || !HMD.active) {
|
||||
addressLine.focus = true;
|
||||
addressLine.forceActiveFocus();
|
||||
addressBarDialog.keyboardEnabled = HMD.active;
|
||||
}
|
||||
tabletRoot.playButtonClickSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
|
@ -347,13 +341,12 @@ StackView {
|
|||
|
||||
Timer {
|
||||
// Delay clearing address line so as to avoid flicker of "not connected" being displayed after entering an address.
|
||||
id: clearAddressLineTimer
|
||||
running: false
|
||||
interval: 100 // ms
|
||||
repeat: false
|
||||
id: clearAddressLineTimer;
|
||||
running: false;
|
||||
interval: 100; // ms
|
||||
repeat: false;
|
||||
onTriggered: {
|
||||
addressLine.text = "";
|
||||
isCursorVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -535,7 +528,7 @@ StackView {
|
|||
|
||||
function updateLocationText(enteringAddress) {
|
||||
if (enteringAddress) {
|
||||
notice.text = "Go to a place, @user, path or network address";
|
||||
notice.text = "Go To a place, @user, path, or network address:";
|
||||
notice.color = hifiStyleConstants.colors.baseGrayHighlight;
|
||||
} else {
|
||||
notice.text = AddressManager.isConnected ? "Your location:" : "Not Connected";
|
||||
|
@ -545,46 +538,14 @@ StackView {
|
|||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
updateLocationText(false);
|
||||
if (visible) {
|
||||
addressLine.forceActiveFocus();
|
||||
fillDestinations();
|
||||
}
|
||||
}
|
||||
|
||||
function toggleOrGo(fromSuggestions, address) {
|
||||
if (address !== undefined && address !== "") {
|
||||
addressBarDialog.loadAddress(address, fromSuggestions)
|
||||
}
|
||||
|
||||
if (addressLine.text !== "") {
|
||||
addressBarDialog.loadAddress(addressLine.text, fromSuggestions)
|
||||
}
|
||||
|
||||
if (isDesktop) {
|
||||
tablet.gotoHomeScreen();
|
||||
} else {
|
||||
HMD.closeTablet();
|
||||
}
|
||||
|
||||
tabletRoot.shown = false;
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
switch (event.key) {
|
||||
case Qt.Key_Escape:
|
||||
case Qt.Key_Back:
|
||||
tabletRoot.shown = false
|
||||
clearAddressLineTimer.start();
|
||||
event.accepted = true
|
||||
break
|
||||
case Qt.Key_Enter:
|
||||
case Qt.Key_Return:
|
||||
toggleOrGo()
|
||||
clearAddressLineTimer.start();
|
||||
event.accepted = true
|
||||
break
|
||||
addressBarDialog.loadAddress(address, fromSuggestions);
|
||||
clearAddressLineTimer.start();
|
||||
} else if (addressLine.text !== "") {
|
||||
addressBarDialog.loadAddress(addressLine.text, fromSuggestions);
|
||||
clearAddressLineTimer.start();
|
||||
}
|
||||
DialogsManager.hideAddressBar();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
//
|
||||
// TabletAddressDialog.qml
|
||||
//
|
||||
// Created by Dante Ruiz on 2017/04/24
|
||||
// Copyright 2015 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
|
||||
//
|
||||
|
||||
import Hifi 1.0
|
||||
import QtQuick 2.4
|
||||
import QtGraphicalEffects 1.0
|
||||
import "../../controls"
|
||||
import "../../styles"
|
||||
import "../../windows"
|
||||
import "../"
|
||||
import "../toolbars"
|
||||
import "../../styles-uit" as HifiStyles
|
||||
import "../../controls-uit" as HifiControlsUit
|
||||
import "../../controls" as HifiControls
|
||||
|
||||
|
||||
Rectangle {
|
||||
id: cardRoot
|
||||
HifiStyles.HifiConstants { id: hifi }
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
property string address: ""
|
||||
property alias eventBridge: webview.eventBridge
|
||||
function setUrl(url) {
|
||||
cardRoot.address = url;
|
||||
webview.url = url;
|
||||
}
|
||||
|
||||
HifiControls.TabletWebView {
|
||||
id: webview
|
||||
parentStackItem: root
|
||||
anchors {
|
||||
top: parent.top
|
||||
right: parent.right
|
||||
left: parent.left
|
||||
bottom: parent.bottom
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@ import QtQuick.Controls 1.4
|
|||
|
||||
StateImage {
|
||||
id: button
|
||||
|
||||
property bool buttonEnabled: true
|
||||
property bool isActive: false
|
||||
property bool isEntered: false
|
||||
|
||||
|
@ -39,30 +41,37 @@ StateImage {
|
|||
}
|
||||
|
||||
function updateState() {
|
||||
if (!button.isEntered && !button.isActive) {
|
||||
buttonState = imageOffOut;
|
||||
} else if (!button.isEntered && button.isActive) {
|
||||
buttonState = imageOnOut;
|
||||
} else if (button.isEntered && !button.isActive) {
|
||||
buttonState = imageOffIn;
|
||||
if (buttonEnabled) {
|
||||
if (!button.isEntered && !button.isActive) {
|
||||
buttonState = imageOffOut;
|
||||
} else if (!button.isEntered && button.isActive) {
|
||||
buttonState = imageOnOut;
|
||||
} else if (button.isEntered && !button.isActive) {
|
||||
buttonState = imageOffIn;
|
||||
} else {
|
||||
buttonState = imageOnIn;
|
||||
}
|
||||
} else {
|
||||
buttonState = imageOnIn;
|
||||
buttonState = 0;
|
||||
}
|
||||
}
|
||||
|
||||
onIsActiveChanged: updateState();
|
||||
onButtonEnabledChanged: updateState();
|
||||
|
||||
Timer {
|
||||
id: asyncClickSender
|
||||
interval: 10
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: button.clicked();
|
||||
onTriggered: {
|
||||
button.clicked();
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
hoverEnabled: true
|
||||
hoverEnabled: buttonEnabled
|
||||
anchors.fill: parent
|
||||
onClicked: asyncClickSender.start();
|
||||
onEntered: {
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include <AssetUpload.h>
|
||||
#include <AutoUpdater.h>
|
||||
#include <AudioInjectorManager.h>
|
||||
#include <AvatarBookmarks.h>
|
||||
#include <CursorManager.h>
|
||||
#include <DebugDraw.h>
|
||||
#include <DeferredLightingEffect.h>
|
||||
|
@ -81,6 +82,7 @@
|
|||
#include <controllers/StateController.h>
|
||||
#include <UserActivityLoggerScriptingInterface.h>
|
||||
#include <LogHandler.h>
|
||||
#include "LocationBookmarks.h"
|
||||
#include <MainWindow.h>
|
||||
#include <MappingRequest.h>
|
||||
#include <MessagesClient.h>
|
||||
|
@ -530,6 +532,8 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
DependencyManager::set<EntityScriptServerLogClient>();
|
||||
DependencyManager::set<LimitlessVoiceRecognitionScriptingInterface>();
|
||||
DependencyManager::set<OctreeStatsProvider>(nullptr, qApp->getOcteeSceneStats());
|
||||
DependencyManager::set<AvatarBookmarks>();
|
||||
DependencyManager::set<LocationBookmarks>();
|
||||
|
||||
return previousSessionCrashed;
|
||||
}
|
||||
|
@ -703,8 +707,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
usleep(USECS_PER_MSEC * 50); // 20hz
|
||||
}
|
||||
|
||||
_bookmarks = new Bookmarks(); // Before setting up the menu
|
||||
|
||||
// start the nodeThread so its event loop is running
|
||||
QThread* nodeThread = new QThread(this);
|
||||
nodeThread->setObjectName("NodeList Thread");
|
||||
|
@ -1122,19 +1124,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
return qApp->isHMDMode() ? 1 : 0;
|
||||
});
|
||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_FULL_SCREEN_MIRROR, []() -> float {
|
||||
return qApp->getCamera()->getMode() == CAMERA_MODE_MIRROR ? 1 : 0;
|
||||
return qApp->getCamera().getMode() == CAMERA_MODE_MIRROR ? 1 : 0;
|
||||
});
|
||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_FIRST_PERSON, []() -> float {
|
||||
return qApp->getCamera()->getMode() == CAMERA_MODE_FIRST_PERSON ? 1 : 0;
|
||||
return qApp->getCamera().getMode() == CAMERA_MODE_FIRST_PERSON ? 1 : 0;
|
||||
});
|
||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_THIRD_PERSON, []() -> float {
|
||||
return qApp->getCamera()->getMode() == CAMERA_MODE_THIRD_PERSON ? 1 : 0;
|
||||
return qApp->getCamera().getMode() == CAMERA_MODE_THIRD_PERSON ? 1 : 0;
|
||||
});
|
||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_ENTITY, []() -> float {
|
||||
return qApp->getCamera()->getMode() == CAMERA_MODE_ENTITY ? 1 : 0;
|
||||
return qApp->getCamera().getMode() == CAMERA_MODE_ENTITY ? 1 : 0;
|
||||
});
|
||||
_applicationStateDevice->setInputVariant(STATE_CAMERA_INDEPENDENT, []() -> float {
|
||||
return qApp->getCamera()->getMode() == CAMERA_MODE_INDEPENDENT ? 1 : 0;
|
||||
return qApp->getCamera().getMode() == CAMERA_MODE_INDEPENDENT ? 1 : 0;
|
||||
});
|
||||
_applicationStateDevice->setInputVariant(STATE_SNAP_TURN, []() -> float {
|
||||
return qApp->getMyAvatar()->getSnapTurn() ? 1 : 0;
|
||||
|
@ -1420,11 +1422,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
connect(DependencyManager::get<AudioClient>().data(), &AudioClient::mutedByMixer, this, onMutedByMixer);
|
||||
|
||||
// Track when the address bar is opened
|
||||
auto onAddressBarToggled = [this]() {
|
||||
auto onAddressBarShown = [this]() {
|
||||
// Record time
|
||||
UserActivityLogger::getInstance().logAction("opened_address_bar", { { "uptime_ms", _sessionRunTimer.elapsed() } });
|
||||
};
|
||||
connect(DependencyManager::get<DialogsManager>().data(), &DialogsManager::addressBarToggled, this, onAddressBarToggled);
|
||||
connect(DependencyManager::get<DialogsManager>().data(), &DialogsManager::addressBarShown, this, onAddressBarShown);
|
||||
|
||||
// Make sure we don't time out during slow operations at startup
|
||||
updateHeartbeat();
|
||||
|
@ -1783,14 +1785,23 @@ void Application::cleanupBeforeQuit() {
|
|||
DependencyManager::destroy<AudioClient>();
|
||||
DependencyManager::destroy<AudioInjectorManager>();
|
||||
|
||||
// shutdown render engine
|
||||
_main3DScene = nullptr;
|
||||
_renderEngine = nullptr;
|
||||
|
||||
qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
// remove avatars from physics engine
|
||||
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
|
||||
VectorOfMotionStates motionStates;
|
||||
DependencyManager::get<AvatarManager>()->getObjectsToRemoveFromPhysics(motionStates);
|
||||
_physicsEngine->removeObjects(motionStates);
|
||||
DependencyManager::get<AvatarManager>()->deleteAllAvatars();
|
||||
|
||||
_physicsEngine->setCharacterController(nullptr);
|
||||
|
||||
// shutdown render engine
|
||||
_main3DScene = nullptr;
|
||||
_renderEngine = nullptr;
|
||||
|
||||
DependencyManager::destroy<Preferences>();
|
||||
|
||||
_entityClipboard->eraseAllOctreeElements();
|
||||
|
@ -1802,14 +1813,6 @@ Application::~Application() {
|
|||
_octreeProcessor.terminate();
|
||||
_entityEditSender.terminate();
|
||||
|
||||
_physicsEngine->setCharacterController(nullptr);
|
||||
|
||||
// remove avatars from physics engine
|
||||
DependencyManager::get<AvatarManager>()->clearOtherAvatars();
|
||||
VectorOfMotionStates motionStates;
|
||||
DependencyManager::get<AvatarManager>()->getObjectsToRemoveFromPhysics(motionStates);
|
||||
_physicsEngine->removeObjects(motionStates);
|
||||
DependencyManager::get<AvatarManager>()->deleteAllAvatars();
|
||||
|
||||
DependencyManager::destroy<AvatarManager>();
|
||||
DependencyManager::destroy<AnimationCache>();
|
||||
|
@ -2009,6 +2012,8 @@ void Application::initializeUi() {
|
|||
rootContext->setContextProperty("Settings", SettingsScriptingInterface::getInstance());
|
||||
rootContext->setContextProperty("ScriptDiscoveryService", DependencyManager::get<ScriptEngines>().data());
|
||||
rootContext->setContextProperty("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
||||
rootContext->setContextProperty("AvatarBookmarks", DependencyManager::get<AvatarBookmarks>().data());
|
||||
rootContext->setContextProperty("LocationBookmarks", DependencyManager::get<LocationBookmarks>().data());
|
||||
|
||||
// Caches
|
||||
rootContext->setContextProperty("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
||||
|
@ -2436,7 +2441,7 @@ void Application::resizeGL() {
|
|||
// Possible change in aspect ratio
|
||||
{
|
||||
QMutexLocker viewLocker(&_viewMutex);
|
||||
loadViewFrustum(_myCamera, _viewFrustum);
|
||||
_myCamera.loadViewFrustum(_viewFrustum);
|
||||
}
|
||||
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
|
@ -4521,7 +4526,7 @@ void Application::update(float deltaTime) {
|
|||
// to the server.
|
||||
{
|
||||
QMutexLocker viewLocker(&_viewMutex);
|
||||
loadViewFrustum(_myCamera, _viewFrustum);
|
||||
_myCamera.loadViewFrustum(_viewFrustum);
|
||||
}
|
||||
|
||||
quint64 now = usecTimestampNow();
|
||||
|
@ -4849,24 +4854,6 @@ QRect Application::getDesirableApplicationGeometry() const {
|
|||
return applicationGeometry;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// loadViewFrustum()
|
||||
//
|
||||
// Description: this will load the view frustum bounds for EITHER the head
|
||||
// or the "myCamera".
|
||||
//
|
||||
void Application::loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum) {
|
||||
// We will use these below, from either the camera or head vectors calculated above
|
||||
viewFrustum.setProjection(camera.getProjection());
|
||||
|
||||
// Set the viewFrustum up with the correct position and orientation of the camera
|
||||
viewFrustum.setPosition(camera.getPosition());
|
||||
viewFrustum.setOrientation(camera.getOrientation());
|
||||
|
||||
// Ask the ViewFrustum class to calculate our corners
|
||||
viewFrustum.calculate();
|
||||
}
|
||||
|
||||
glm::vec3 Application::getSunDirection() const {
|
||||
// Sun direction is in fact just the location of the sun relative to the origin
|
||||
auto skyStage = DependencyManager::get<SceneScriptingInterface>()->getSkyStage();
|
||||
|
@ -5038,7 +5025,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
|||
// load the view frustum
|
||||
{
|
||||
QMutexLocker viewLocker(&_viewMutex);
|
||||
loadViewFrustum(theCamera, _displayViewFrustum);
|
||||
theCamera.loadViewFrustum(_displayViewFrustum);
|
||||
}
|
||||
|
||||
// TODO fix shadows and make them use the GPU library
|
||||
|
@ -5055,7 +5042,7 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
|||
transaction.resetItem(BackgroundRenderData::_item, backgroundRenderPayload);
|
||||
}
|
||||
|
||||
// Assuming nothing get's rendered through that
|
||||
// Assuming nothing gets rendered through that
|
||||
if (!selfAvatarOnly) {
|
||||
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderEntities()) {
|
||||
// render models...
|
||||
|
@ -5111,6 +5098,8 @@ void Application::displaySide(RenderArgs* renderArgs, Camera& theCamera, bool se
|
|||
QMutexLocker viewLocker(&_viewMutex);
|
||||
renderArgs->setViewFrustum(_displayViewFrustum);
|
||||
}
|
||||
renderArgs->_cameraMode = (int8_t)theCamera.getMode(); // HACK
|
||||
renderArgs->_scene = getMain3DScene();
|
||||
_renderEngine->getRenderContext()->args = renderArgs;
|
||||
|
||||
// Before the deferred pass, let's try to use the render engine
|
||||
|
@ -5494,6 +5483,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
||||
scriptEngine->registerGlobalObject("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
|
||||
scriptEngine->registerGlobalObject("AudioScope", DependencyManager::get<AudioScope>().data());
|
||||
scriptEngine->registerGlobalObject("AvatarBookmarks", DependencyManager::get<AvatarBookmarks>().data());
|
||||
scriptEngine->registerGlobalObject("LocationBookmarks", DependencyManager::get<LocationBookmarks>().data());
|
||||
|
||||
// Caches
|
||||
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
||||
|
@ -6359,7 +6350,6 @@ void Application::loadLODToolsDialog() {
|
|||
} else {
|
||||
tablet->pushOntoStack("../../hifi/dialogs/TabletLODTools.qml");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -6409,6 +6399,11 @@ void Application::toggleEntityScriptServerLogDialog() {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::loadAddAvatarBookmarkDialog() const {
|
||||
auto avatarBookmarks = DependencyManager::get<AvatarBookmarks>();
|
||||
avatarBookmarks->addBookmark();
|
||||
}
|
||||
|
||||
void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) {
|
||||
postLambdaEvent([notify, includeAnimated, aspectRatio, this] {
|
||||
QMediaPlayer* player = new QMediaPlayer();
|
||||
|
|
|
@ -52,8 +52,7 @@
|
|||
|
||||
#include "avatar/MyAvatar.h"
|
||||
#include "BandwidthRecorder.h"
|
||||
#include "Bookmarks.h"
|
||||
#include "Camera.h"
|
||||
#include "FancyCamera.h"
|
||||
#include "ConnectionMonitor.h"
|
||||
#include "gpu/Context.h"
|
||||
#include "Menu.h"
|
||||
|
@ -175,8 +174,8 @@ public:
|
|||
|
||||
bool isThrottleRendering() const;
|
||||
|
||||
Camera* getCamera() { return &_myCamera; }
|
||||
const Camera* getCamera() const { return &_myCamera; }
|
||||
Camera& getCamera() { return _myCamera; }
|
||||
const Camera& getCamera() const { return _myCamera; }
|
||||
// Represents the current view frustum of the avatar.
|
||||
void copyViewFrustum(ViewFrustum& viewOut) const;
|
||||
// Represents the view frustum of the current rendering pass,
|
||||
|
@ -261,7 +260,6 @@ public:
|
|||
glm::mat4 getEyeProjection(int eye) const;
|
||||
|
||||
QRect getDesirableApplicationGeometry() const;
|
||||
Bookmarks* getBookmarks() const { return _bookmarks; }
|
||||
|
||||
virtual bool canAcceptURL(const QString& url) const override;
|
||||
virtual bool acceptURL(const QString& url, bool defaultUpload = false) override;
|
||||
|
@ -270,7 +268,7 @@ public:
|
|||
int getMaxOctreePacketsPerSecond() const;
|
||||
|
||||
render::ScenePointer getMain3DScene() override { return _main3DScene; }
|
||||
render::ScenePointer getMain3DScene() const { return _main3DScene; }
|
||||
const render::ScenePointer& getMain3DScene() const { return _main3DScene; }
|
||||
render::EnginePointer getRenderEngine() override { return _renderEngine; }
|
||||
gpu::ContextPointer getGPUContext() const { return _gpuContext; }
|
||||
|
||||
|
@ -280,7 +278,7 @@ public:
|
|||
|
||||
float getAvatarSimrate() const { return _avatarSimCounter.rate(); }
|
||||
float getAverageSimsPerSecond() const { return _simCounter.rate(); }
|
||||
|
||||
|
||||
void takeSnapshot(bool notify, bool includeAnimated = false, float aspectRatio = 0.0f);
|
||||
void shareSnapshot(const QString& filename, const QUrl& href = QUrl(""));
|
||||
|
||||
|
@ -330,6 +328,7 @@ public slots:
|
|||
void toggleEntityScriptServerLogDialog();
|
||||
void toggleRunningScriptsWidget() const;
|
||||
Q_INVOKABLE void showAssetServerWidget(QString filePath = "");
|
||||
Q_INVOKABLE void loadAddAvatarBookmarkDialog() const;
|
||||
|
||||
void showDialog(const QString& desktopURL, const QString& tabletURL, const QString& name) const;
|
||||
|
||||
|
@ -463,7 +462,6 @@ private:
|
|||
void updateDialogs(float deltaTime) const;
|
||||
|
||||
void queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions, bool forceResend = false);
|
||||
static void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum);
|
||||
|
||||
glm::vec3 getSunDirection() const;
|
||||
|
||||
|
@ -559,7 +557,7 @@ private:
|
|||
SimpleMovingAverage _avatarSimsPerSecond {10};
|
||||
int _avatarSimsPerSecondReport {0};
|
||||
quint64 _lastAvatarSimsPerSecondUpdate {0};
|
||||
Camera _myCamera; // My view onto the world
|
||||
FancyCamera _myCamera; // My view onto the world
|
||||
|
||||
Setting::Handle<QString> _previousScriptLocation;
|
||||
Setting::Handle<float> _fieldOfView;
|
||||
|
@ -599,8 +597,6 @@ private:
|
|||
|
||||
bool _aboutToQuit;
|
||||
|
||||
Bookmarks* _bookmarks;
|
||||
|
||||
bool _notifiedPacketVersionMismatchThisDomain;
|
||||
|
||||
QThread _settingsThread;
|
||||
|
|
81
interface/src/AvatarBookmarks.cpp
Normal file
81
interface/src/AvatarBookmarks.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
//
|
||||
// AvatarBookmarks.cpp
|
||||
// interface/src
|
||||
//
|
||||
// Created by Triplelexx on 23/03/17.
|
||||
// Copyright 2017 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 <QAction>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardPaths>
|
||||
#include <QQmlContext>
|
||||
|
||||
#include <Application.h>
|
||||
#include <OffscreenUi.h>
|
||||
#include <avatar/AvatarManager.h>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Menu.h"
|
||||
|
||||
#include "AvatarBookmarks.h"
|
||||
#include <QtQuick/QQuickWindow>
|
||||
|
||||
AvatarBookmarks::AvatarBookmarks() {
|
||||
_bookmarksFilename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + AVATARBOOKMARKS_FILENAME;
|
||||
readFromFile();
|
||||
}
|
||||
|
||||
void AvatarBookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) {
|
||||
// Add menus/actions
|
||||
auto bookmarkAction = menubar->addActionToQMenuAndActionHash(menu, MenuOption::BookmarkAvatar);
|
||||
QObject::connect(bookmarkAction, SIGNAL(triggered()), this, SLOT(addBookmark()), Qt::QueuedConnection);
|
||||
_bookmarksMenu = menu->addMenu(MenuOption::AvatarBookmarks);
|
||||
_deleteBookmarksAction = menubar->addActionToQMenuAndActionHash(menu, MenuOption::DeleteAvatarBookmark);
|
||||
QObject::connect(_deleteBookmarksAction, SIGNAL(triggered()), this, SLOT(deleteBookmark()), Qt::QueuedConnection);
|
||||
|
||||
Bookmarks::setupMenus(menubar, menu);
|
||||
Bookmarks::sortActions(menubar, _bookmarksMenu);
|
||||
}
|
||||
|
||||
void AvatarBookmarks::changeToBookmarkedAvatar() {
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
const QString& address = action->data().toString();
|
||||
|
||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
myAvatar->useFullAvatarURL(address);
|
||||
}
|
||||
|
||||
void AvatarBookmarks::addBookmark() {
|
||||
bool ok = false;
|
||||
auto bookmarkName = OffscreenUi::getText(OffscreenUi::ICON_PLACEMARK, "Bookmark Avatar", "Name", QString(), &ok);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
bookmarkName = bookmarkName.trimmed().replace(QRegExp("(\r\n|[\r\n\t\v ])+"), " ");
|
||||
if (bookmarkName.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
const QString& bookmarkAddress = myAvatar->getSkeletonModelURL().toString();
|
||||
Bookmarks::addBookmarkToFile(bookmarkName, bookmarkAddress);
|
||||
}
|
||||
|
||||
void AvatarBookmarks::addBookmarkToMenu(Menu* menubar, const QString& name, const QString& address) {
|
||||
QAction* changeAction = _bookmarksMenu->newAction();
|
||||
changeAction->setData(address);
|
||||
connect(changeAction, SIGNAL(triggered()), this, SLOT(changeToBookmarkedAvatar()));
|
||||
if (!_isMenuSorted) {
|
||||
menubar->addActionToQMenuAndActionHash(_bookmarksMenu, changeAction, name, 0, QAction::NoRole);
|
||||
} else {
|
||||
// TODO: this is aggressive but other alternatives have proved less fruitful so far.
|
||||
menubar->addActionToQMenuAndActionHash(_bookmarksMenu, changeAction, name, 0, QAction::NoRole);
|
||||
Bookmarks::sortActions(menubar, _bookmarksMenu);
|
||||
}
|
||||
}
|
40
interface/src/AvatarBookmarks.h
Normal file
40
interface/src/AvatarBookmarks.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// AvatarBookmarks.h
|
||||
// interface/src
|
||||
//
|
||||
// Created by Triplelexx on 23/03/17.
|
||||
// Copyright 2017 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_AvatarBookmarks_h
|
||||
#define hifi_AvatarBookmarks_h
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include "Bookmarks.h"
|
||||
|
||||
class AvatarBookmarks: public Bookmarks, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
AvatarBookmarks();
|
||||
|
||||
void setupMenus(Menu* menubar, MenuWrapper* menu) override;
|
||||
|
||||
public slots:
|
||||
void addBookmark();
|
||||
|
||||
protected:
|
||||
void addBookmarkToMenu(Menu* menubar, const QString& name, const QString& address) override;
|
||||
|
||||
private:
|
||||
const QString AVATARBOOKMARKS_FILENAME = "avatarbookmarks.json";
|
||||
|
||||
private slots:
|
||||
void changeToBookmarkedAvatar();
|
||||
};
|
||||
|
||||
#endif // hifi_AvatarBookmarks_h
|
|
@ -11,14 +11,10 @@
|
|||
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
#include <QFile>
|
||||
#include <QInputDialog>
|
||||
#include <QJsonDocument>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <AddressManager.h>
|
||||
#include <Application.h>
|
||||
#include <OffscreenUi.h>
|
||||
|
||||
|
@ -27,15 +23,69 @@
|
|||
#include "InterfaceLogging.h"
|
||||
|
||||
#include "Bookmarks.h"
|
||||
#include <QtQuick/QQuickWindow>
|
||||
|
||||
Bookmarks::Bookmarks() :
|
||||
_isMenuSorted(false)
|
||||
{
|
||||
}
|
||||
|
||||
const QString Bookmarks::HOME_BOOKMARK = "Home";
|
||||
void Bookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) {
|
||||
// Enable/Disable menus as needed
|
||||
enableMenuItems(_bookmarks.count() > 0);
|
||||
|
||||
// Load Bookmarks
|
||||
for (auto it = _bookmarks.begin(); it != _bookmarks.end(); ++it) {
|
||||
QString bookmarkName = it.key();
|
||||
QString bookmarkAddress = it.value().toString();
|
||||
addBookmarkToMenu(menubar, bookmarkName, bookmarkAddress);
|
||||
}
|
||||
}
|
||||
|
||||
Bookmarks::Bookmarks() {
|
||||
_bookmarksFilename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + BOOKMARKS_FILENAME;
|
||||
readFromFile();
|
||||
void Bookmarks::deleteBookmark() {
|
||||
QStringList bookmarkList;
|
||||
QList<QAction*> menuItems = _bookmarksMenu->actions();
|
||||
for (int i = 0; i < menuItems.count(); ++i) {
|
||||
bookmarkList.append(menuItems[i]->text());
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
auto bookmarkName = OffscreenUi::getItem(OffscreenUi::ICON_PLACEMARK, "Delete Bookmark", "Select the bookmark to delete", bookmarkList, 0, false, &ok);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
bookmarkName = bookmarkName.trimmed();
|
||||
if (bookmarkName.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeBookmarkFromMenu(Menu::getInstance(), bookmarkName);
|
||||
remove(bookmarkName);
|
||||
|
||||
if (_bookmarksMenu->actions().count() == 0) {
|
||||
enableMenuItems(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Bookmarks::addBookmarkToFile(const QString& bookmarkName, const QString& bookmarkAddress) {
|
||||
Menu* menubar = Menu::getInstance();
|
||||
if (contains(bookmarkName)) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
auto duplicateBookmarkMessage = offscreenUi->createMessageBox(OffscreenUi::ICON_WARNING, "Duplicate Bookmark",
|
||||
"The bookmark name you entered already exists in your list.",
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
duplicateBookmarkMessage->setProperty("informativeText", "Would you like to overwrite it?");
|
||||
|
||||
auto result = offscreenUi->waitForMessageBoxResult(duplicateBookmarkMessage);
|
||||
if (result != QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
removeBookmarkFromMenu(menubar, bookmarkName);
|
||||
}
|
||||
|
||||
addBookmarkToMenu(menubar, bookmarkName, bookmarkAddress);
|
||||
insert(bookmarkName, bookmarkAddress); // Overwrites any item with the same bookmarkName.
|
||||
enableMenuItems(true);
|
||||
}
|
||||
|
||||
void Bookmarks::insert(const QString& name, const QString& address) {
|
||||
|
@ -64,6 +114,33 @@ bool Bookmarks::contains(const QString& name) const {
|
|||
return _bookmarks.contains(name);
|
||||
}
|
||||
|
||||
bool Bookmarks::sortOrder(QAction* a, QAction* b) {
|
||||
return a->text().toLower().localeAwareCompare(b->text().toLower()) < 0;
|
||||
}
|
||||
|
||||
void Bookmarks::sortActions(Menu* menubar, MenuWrapper* menu) {
|
||||
QList<QAction*> actions = menu->actions();
|
||||
qSort(actions.begin(), actions.end(), sortOrder);
|
||||
for (QAction* action : menu->actions()) {
|
||||
menu->removeAction(action);
|
||||
}
|
||||
for (QAction* action : actions) {
|
||||
menu->addAction(action);
|
||||
}
|
||||
_isMenuSorted = true;
|
||||
}
|
||||
|
||||
int Bookmarks::getMenuItemLocation(QList<QAction*> actions, const QString& name) const {
|
||||
int menuItemLocation = 0;
|
||||
for (QAction* action : actions) {
|
||||
if (name.toLower().localeAwareCompare(action->text().toLower()) < 0) {
|
||||
menuItemLocation = actions.indexOf(action);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return menuItemLocation;
|
||||
}
|
||||
|
||||
QString Bookmarks::addressForBookmark(const QString& name) const {
|
||||
return _bookmarks.value(name).toString();
|
||||
}
|
||||
|
@ -99,108 +176,6 @@ void Bookmarks::persistToFile() {
|
|||
saveFile.write(data);
|
||||
}
|
||||
|
||||
void Bookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) {
|
||||
// Add menus/actions
|
||||
auto bookmarkAction = menubar->addActionToQMenuAndActionHash(menu, MenuOption::BookmarkLocation);
|
||||
QObject::connect(bookmarkAction, SIGNAL(triggered()), this, SLOT(bookmarkLocation()), Qt::QueuedConnection);
|
||||
auto setHomeAction = menubar->addActionToQMenuAndActionHash(menu, MenuOption::SetHomeLocation);
|
||||
QObject::connect(setHomeAction, SIGNAL(triggered()), this, SLOT(setHomeLocation()), Qt::QueuedConnection);
|
||||
_bookmarksMenu = menu->addMenu(MenuOption::Bookmarks);
|
||||
_deleteBookmarksAction = menubar->addActionToQMenuAndActionHash(menu, MenuOption::DeleteBookmark);
|
||||
QObject::connect(_deleteBookmarksAction, SIGNAL(triggered()), this, SLOT(deleteBookmark()), Qt::QueuedConnection);
|
||||
|
||||
// Enable/Disable menus as needed
|
||||
enableMenuItems(_bookmarks.count() > 0);
|
||||
|
||||
// Load bookmarks
|
||||
for (auto it = _bookmarks.begin(); it != _bookmarks.end(); ++it ) {
|
||||
QString bookmarkName = it.key();
|
||||
QString bookmarkAddress = it.value().toString();
|
||||
addLocationToMenu(menubar, bookmarkName, bookmarkAddress);
|
||||
}
|
||||
}
|
||||
|
||||
void Bookmarks::bookmarkLocation() {
|
||||
bool ok = false;
|
||||
auto bookmarkName = OffscreenUi::getText(OffscreenUi::ICON_PLACEMARK, "Bookmark Location", "Name", QString(), &ok);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
bookmarkName = bookmarkName.trimmed().replace(QRegExp("(\r\n|[\r\n\t\v ])+"), " ");
|
||||
if (bookmarkName.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
QString bookmarkAddress = addressManager->currentAddress().toString();
|
||||
|
||||
Menu* menubar = Menu::getInstance();
|
||||
if (contains(bookmarkName)) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
auto duplicateBookmarkMessage = offscreenUi->createMessageBox(OffscreenUi::ICON_WARNING, "Duplicate Bookmark",
|
||||
"The bookmark name you entered already exists in your list.",
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
duplicateBookmarkMessage->setProperty("informativeText", "Would you like to overwrite it?");
|
||||
|
||||
auto result = offscreenUi->waitForMessageBoxResult(duplicateBookmarkMessage);
|
||||
if (result != QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
removeLocationFromMenu(menubar, bookmarkName);
|
||||
}
|
||||
|
||||
addLocationToMenu(menubar, bookmarkName, bookmarkAddress);
|
||||
insert(bookmarkName, bookmarkAddress); // Overwrites any item with the same bookmarkName.
|
||||
|
||||
enableMenuItems(true);
|
||||
}
|
||||
|
||||
void Bookmarks::setHomeLocation() {
|
||||
Menu* menubar = Menu::getInstance();
|
||||
QString bookmarkName = HOME_BOOKMARK;
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
QString bookmarkAddress = addressManager->currentAddress().toString();
|
||||
|
||||
addLocationToMenu(menubar, bookmarkName, bookmarkAddress);
|
||||
insert(bookmarkName, bookmarkAddress); // Overwrites any item with the same bookmarkName.
|
||||
|
||||
enableMenuItems(true);
|
||||
}
|
||||
|
||||
void Bookmarks::teleportToBookmark() {
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
QString address = action->data().toString();
|
||||
DependencyManager::get<AddressManager>()->handleLookupString(address);
|
||||
}
|
||||
|
||||
void Bookmarks::deleteBookmark() {
|
||||
|
||||
QStringList bookmarkList;
|
||||
QList<QAction*> menuItems = _bookmarksMenu->actions();
|
||||
for (int i = 0; i < menuItems.count(); i += 1) {
|
||||
bookmarkList.append(menuItems[i]->text());
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
auto bookmarkName = OffscreenUi::getItem(OffscreenUi::ICON_PLACEMARK, "Delete Bookmark", "Select the bookmark to delete", bookmarkList, 0, false, &ok);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
bookmarkName = bookmarkName.trimmed();
|
||||
if (bookmarkName.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeLocationFromMenu(Menu::getInstance(), bookmarkName);
|
||||
remove(bookmarkName);
|
||||
|
||||
if (_bookmarksMenu->actions().count() == 0) {
|
||||
enableMenuItems(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Bookmarks::enableMenuItems(bool enabled) {
|
||||
if (_bookmarksMenu) {
|
||||
_bookmarksMenu->setEnabled(enabled);
|
||||
|
@ -210,17 +185,6 @@ void Bookmarks::enableMenuItems(bool enabled) {
|
|||
}
|
||||
}
|
||||
|
||||
void Bookmarks::addLocationToMenu(Menu* menubar, QString& name, QString& address) {
|
||||
QAction* teleportAction = _bookmarksMenu->newAction();
|
||||
teleportAction->setData(address);
|
||||
connect(teleportAction, SIGNAL(triggered()), this, SLOT(teleportToBookmark()));
|
||||
|
||||
menubar->addActionToQMenuAndActionHash(_bookmarksMenu, teleportAction,
|
||||
name, 0, QAction::NoRole);
|
||||
}
|
||||
|
||||
void Bookmarks::removeLocationFromMenu(Menu* menubar, QString& name) {
|
||||
void Bookmarks::removeBookmarkFromMenu(Menu* menubar, const QString& name) {
|
||||
menubar->removeAction(_bookmarksMenu, name);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,37 +27,35 @@ class Bookmarks: public QObject {
|
|||
public:
|
||||
Bookmarks();
|
||||
|
||||
void setupMenus(Menu* menubar, MenuWrapper* menu);
|
||||
|
||||
virtual void setupMenus(Menu* menubar, MenuWrapper* menu);
|
||||
QString addressForBookmark(const QString& name) const;
|
||||
|
||||
static const QString HOME_BOOKMARK;
|
||||
protected:
|
||||
virtual void addBookmarkToFile(const QString& bookmarkName, const QString& bookmarkAddress);
|
||||
virtual void addBookmarkToMenu(Menu* menubar, const QString& name, const QString& address) = 0;
|
||||
void enableMenuItems(bool enabled);
|
||||
void readFromFile();
|
||||
void insert(const QString& name, const QString& address); // Overwrites any existing entry with same name.
|
||||
void sortActions(Menu* menubar, MenuWrapper* menu);
|
||||
int getMenuItemLocation(QList<QAction*> actions, const QString& name) const;
|
||||
|
||||
private slots:
|
||||
void bookmarkLocation();
|
||||
void setHomeLocation();
|
||||
void teleportToBookmark();
|
||||
void deleteBookmark();
|
||||
|
||||
private:
|
||||
QVariantMap _bookmarks; // { name: address, ... }
|
||||
|
||||
QVariantMap _bookmarks; // { name: url, ... }
|
||||
QPointer<MenuWrapper> _bookmarksMenu;
|
||||
QPointer<QAction> _deleteBookmarksAction;
|
||||
|
||||
const QString BOOKMARKS_FILENAME = "bookmarks.json";
|
||||
QString _bookmarksFilename;
|
||||
|
||||
void insert(const QString& name, const QString& address); // Overwrites any existing entry with same name.
|
||||
bool _isMenuSorted;
|
||||
|
||||
protected slots:
|
||||
void deleteBookmark();
|
||||
|
||||
private:
|
||||
void remove(const QString& name);
|
||||
bool contains(const QString& name) const;
|
||||
static bool sortOrder(QAction* a, QAction* b);
|
||||
|
||||
void readFromFile();
|
||||
void persistToFile();
|
||||
|
||||
void enableMenuItems(bool enabled);
|
||||
void addLocationToMenu(Menu* menubar, QString& name, QString& address);
|
||||
void removeLocationFromMenu(Menu* menubar, QString& name);
|
||||
void removeBookmarkFromMenu(Menu* menubar, const QString& name);
|
||||
};
|
||||
|
||||
#endif // hifi_Bookmarks_h
|
||||
#endif // hifi_Bookmarks_h
|
||||
|
|
|
@ -98,18 +98,7 @@ void Camera::setMode(CameraMode mode) {
|
|||
emit modeUpdated(modeToString(mode));
|
||||
}
|
||||
|
||||
QUuid Camera::getCameraEntity() const {
|
||||
if (_cameraEntity != nullptr) {
|
||||
return _cameraEntity->getID();
|
||||
}
|
||||
return QUuid();
|
||||
};
|
||||
|
||||
void Camera::setCameraEntity(QUuid entityID) {
|
||||
_cameraEntity = qApp->getEntities()->getTree()->findEntityByID(entityID);
|
||||
}
|
||||
|
||||
void Camera::setProjection(const glm::mat4& projection) {
|
||||
void Camera::setProjection(const glm::mat4& projection) {
|
||||
_projection = projection;
|
||||
}
|
||||
|
||||
|
@ -119,7 +108,7 @@ PickRay Camera::computePickRay(float x, float y) {
|
|||
|
||||
void Camera::setModeString(const QString& mode) {
|
||||
CameraMode targetMode = stringToMode(mode);
|
||||
|
||||
|
||||
switch (targetMode) {
|
||||
case CAMERA_MODE_FIRST_PERSON:
|
||||
Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, true);
|
||||
|
@ -139,7 +128,7 @@ void Camera::setModeString(const QString& mode) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
qApp->cameraMenuChanged();
|
||||
|
||||
if (_mode != targetMode) {
|
||||
|
@ -177,12 +166,6 @@ void Camera::loadViewFrustum(ViewFrustum& frustum) const {
|
|||
frustum.calculate();
|
||||
}
|
||||
|
||||
ViewFrustum Camera::toViewFrustum() const {
|
||||
ViewFrustum result;
|
||||
loadViewFrustum(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
QVariantMap Camera::getViewFrustum() {
|
||||
ViewFrustum frustum;
|
||||
loadViewFrustum(frustum);
|
||||
|
|
|
@ -43,15 +43,11 @@ class Camera : public QObject {
|
|||
* @property position {Vec3} The position of the camera.
|
||||
* @property orientation {Quat} The orientation of the camera.
|
||||
* @property mode {string} The current camera mode.
|
||||
* @property cameraEntity {EntityID} The position and rotation properties of
|
||||
* the entity specified by this ID are then used as the camera's position and
|
||||
* orientation. Only works when <code>mode</code> is "entity".
|
||||
* @property frustum {Object} The frustum of the camera.
|
||||
*/
|
||||
Q_PROPERTY(glm::vec3 position READ getPosition WRITE setPosition)
|
||||
Q_PROPERTY(glm::quat orientation READ getOrientation WRITE setOrientation)
|
||||
Q_PROPERTY(QString mode READ getModeString WRITE setModeString)
|
||||
Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity)
|
||||
Q_PROPERTY(QVariantMap frustum READ getViewFrustum CONSTANT)
|
||||
|
||||
public:
|
||||
|
@ -65,9 +61,6 @@ public:
|
|||
void setMode(CameraMode m);
|
||||
|
||||
void loadViewFrustum(ViewFrustum& frustum) const;
|
||||
ViewFrustum toViewFrustum() const;
|
||||
|
||||
EntityItemPointer getCameraEntityPointer() const { return _cameraEntity; }
|
||||
|
||||
const glm::mat4& getTransform() const { return _transform; }
|
||||
void setTransform(const glm::mat4& transform);
|
||||
|
@ -87,9 +80,6 @@ public slots:
|
|||
glm::quat getOrientation() const { return _orientation; }
|
||||
void setOrientation(const glm::quat& orientation);
|
||||
|
||||
QUuid getCameraEntity() const;
|
||||
void setCameraEntity(QUuid entityID);
|
||||
|
||||
/**jsdoc
|
||||
* Compute a {PickRay} based on the current camera configuration and the position x,y on the screen.
|
||||
* @function Camera.computePickRay
|
||||
|
@ -143,7 +133,6 @@ private:
|
|||
glm::quat _orientation;
|
||||
bool _isKeepLookingAt{ false };
|
||||
glm::vec3 _lookingAt;
|
||||
EntityItemPointer _cameraEntity;
|
||||
};
|
||||
|
||||
#endif // hifi_Camera_h
|
||||
|
|
25
interface/src/FancyCamera.cpp
Normal file
25
interface/src/FancyCamera.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// FancyCamera.cpp
|
||||
// interface/src
|
||||
//
|
||||
// Copyright 2017 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 "FancyCamera.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
|
||||
QUuid FancyCamera::getCameraEntity() const {
|
||||
if (_cameraEntity != nullptr) {
|
||||
return _cameraEntity->getID();
|
||||
}
|
||||
return QUuid();
|
||||
};
|
||||
|
||||
void FancyCamera::setCameraEntity(QUuid entityID) {
|
||||
_cameraEntity = qApp->getEntities()->getTree()->findEntityByID(entityID);
|
||||
}
|
43
interface/src/FancyCamera.h
Normal file
43
interface/src/FancyCamera.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// FancyCamera.h
|
||||
// interface/src
|
||||
//
|
||||
// Copyright 2017 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_FancyCamera_h
|
||||
#define hifi_FancyCamera_h
|
||||
|
||||
#include "Camera.h"
|
||||
|
||||
#include <EntityItem.h>
|
||||
|
||||
// TODO: come up with a better name than "FancyCamera"
|
||||
class FancyCamera : public Camera {
|
||||
Q_OBJECT
|
||||
|
||||
/**jsdoc
|
||||
* @namespace Camera
|
||||
* @property cameraEntity {EntityID} The position and rotation properties of
|
||||
* the entity specified by this ID are then used as the camera's position and
|
||||
* orientation. Only works when <code>mode</code> is "entity".
|
||||
*/
|
||||
Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity)
|
||||
|
||||
public:
|
||||
FancyCamera() : Camera() {}
|
||||
|
||||
EntityItemPointer getCameraEntityPointer() const { return _cameraEntity; }
|
||||
|
||||
public slots:
|
||||
QUuid getCameraEntity() const;
|
||||
void setCameraEntity(QUuid entityID);
|
||||
|
||||
private:
|
||||
EntityItemPointer _cameraEntity;
|
||||
};
|
||||
|
||||
#endif // hifi_FancyCamera_h
|
88
interface/src/LocationBookmarks.cpp
Normal file
88
interface/src/LocationBookmarks.cpp
Normal file
|
@ -0,0 +1,88 @@
|
|||
//
|
||||
// LocationBookmarks.cpp
|
||||
// interface/src
|
||||
//
|
||||
// Created by Triplelexx on 23/03/17.
|
||||
// Copyright 2017 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 <QAction>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <AddressManager.h>
|
||||
#include <Application.h>
|
||||
#include <OffscreenUi.h>
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "Menu.h"
|
||||
|
||||
#include "LocationBookmarks.h"
|
||||
#include <QtQuick/QQuickWindow>
|
||||
|
||||
const QString LocationBookmarks::HOME_BOOKMARK = "Home";
|
||||
|
||||
LocationBookmarks::LocationBookmarks() {
|
||||
_bookmarksFilename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + LOCATIONBOOKMARKS_FILENAME;
|
||||
readFromFile();
|
||||
}
|
||||
|
||||
void LocationBookmarks::setupMenus(Menu* menubar, MenuWrapper* menu) {
|
||||
// Add menus/actions
|
||||
auto bookmarkAction = menubar->addActionToQMenuAndActionHash(menu, MenuOption::BookmarkLocation);
|
||||
QObject::connect(bookmarkAction, SIGNAL(triggered()), this, SLOT(addBookmark()), Qt::QueuedConnection);
|
||||
auto setHomeAction = menubar->addActionToQMenuAndActionHash(menu, MenuOption::SetHomeLocation);
|
||||
QObject::connect(setHomeAction, SIGNAL(triggered()), this, SLOT(setHomeLocation()), Qt::QueuedConnection);
|
||||
_bookmarksMenu = menu->addMenu(MenuOption::LocationBookmarks);
|
||||
_deleteBookmarksAction = menubar->addActionToQMenuAndActionHash(menu, MenuOption::DeleteBookmark);
|
||||
QObject::connect(_deleteBookmarksAction, SIGNAL(triggered()), this, SLOT(deleteBookmark()), Qt::QueuedConnection);
|
||||
|
||||
Bookmarks::setupMenus(menubar, menu);
|
||||
Bookmarks::sortActions(menubar, _bookmarksMenu);
|
||||
}
|
||||
|
||||
void LocationBookmarks::setHomeLocation() {
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
QString bookmarkAddress = addressManager->currentAddress().toString();
|
||||
Bookmarks::addBookmarkToFile(HOME_BOOKMARK, bookmarkAddress);
|
||||
}
|
||||
|
||||
void LocationBookmarks::teleportToBookmark() {
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
QString address = action->data().toString();
|
||||
DependencyManager::get<AddressManager>()->handleLookupString(address);
|
||||
}
|
||||
|
||||
void LocationBookmarks::addBookmark() {
|
||||
bool ok = false;
|
||||
auto bookmarkName = OffscreenUi::getText(OffscreenUi::ICON_PLACEMARK, "Bookmark Location", "Name", QString(), &ok);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
bookmarkName = bookmarkName.trimmed().replace(QRegExp("(\r\n|[\r\n\t\v ])+"), " ");
|
||||
if (bookmarkName.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
QString bookmarkAddress = addressManager->currentAddress().toString();
|
||||
Bookmarks::addBookmarkToFile(bookmarkName, bookmarkAddress);
|
||||
}
|
||||
|
||||
void LocationBookmarks::addBookmarkToMenu(Menu* menubar, const QString& name, const QString& address) {
|
||||
QAction* teleportAction = _bookmarksMenu->newAction();
|
||||
teleportAction->setData(address);
|
||||
connect(teleportAction, SIGNAL(triggered()), this, SLOT(teleportToBookmark()));
|
||||
if (!_isMenuSorted) {
|
||||
menubar->addActionToQMenuAndActionHash(_bookmarksMenu, teleportAction, name, 0, QAction::NoRole);
|
||||
} else {
|
||||
// TODO: this is aggressive but other alternatives have proved less fruitful so far.
|
||||
menubar->addActionToQMenuAndActionHash(_bookmarksMenu, teleportAction, name, 0, QAction::NoRole);
|
||||
Bookmarks::sortActions(menubar, _bookmarksMenu);
|
||||
}
|
||||
}
|
42
interface/src/LocationBookmarks.h
Normal file
42
interface/src/LocationBookmarks.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
//
|
||||
// LocationBookmarks.h
|
||||
// interface/src
|
||||
//
|
||||
// Created by Triplelexx on 23/03/17.
|
||||
// Copyright 2017 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_LocationBookmarks_h
|
||||
#define hifi_LocationBookmarks_h
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include "Bookmarks.h"
|
||||
|
||||
class LocationBookmarks : public Bookmarks, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
LocationBookmarks();
|
||||
|
||||
void setupMenus(Menu* menubar, MenuWrapper* menu) override;
|
||||
static const QString HOME_BOOKMARK;
|
||||
|
||||
public slots:
|
||||
void addBookmark();
|
||||
|
||||
protected:
|
||||
void addBookmarkToMenu(Menu* menubar, const QString& name, const QString& address) override;
|
||||
|
||||
private:
|
||||
const QString LOCATIONBOOKMARKS_FILENAME = "bookmarks.json";
|
||||
|
||||
private slots:
|
||||
void setHomeLocation();
|
||||
void teleportToBookmark();
|
||||
};
|
||||
|
||||
#endif // hifi_LocationBookmarks_h
|
|
@ -32,6 +32,7 @@
|
|||
#include "assets/ATPAssetMigrator.h"
|
||||
#include "audio/AudioScope.h"
|
||||
#include "avatar/AvatarManager.h"
|
||||
#include "AvatarBookmarks.h"
|
||||
#include "devices/DdeFaceTracker.h"
|
||||
#include "devices/Faceshift.h"
|
||||
#include "MainWindow.h"
|
||||
|
@ -40,6 +41,7 @@
|
|||
#include "ui/DialogsManager.h"
|
||||
#include "ui/StandAloneJSConsole.h"
|
||||
#include "InterfaceLogging.h"
|
||||
#include "LocationBookmarks.h"
|
||||
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
#include "SpeechRecognizer.h"
|
||||
|
@ -194,6 +196,9 @@ Menu::Menu() {
|
|||
0, // QML Qt::Key_Apostrophe,
|
||||
qApp, SLOT(resetSensors()));
|
||||
|
||||
// Avatar > AvatarBookmarks related menus -- Note: the AvatarBookmarks class adds its own submenus here.
|
||||
auto avatarBookmarks = DependencyManager::get<AvatarBookmarks>();
|
||||
avatarBookmarks->setupMenus(this, avatarMenu);
|
||||
|
||||
// Display menu ----------------------------------
|
||||
// FIXME - this is not yet matching Alan's spec because it doesn't have
|
||||
|
@ -254,10 +259,11 @@ Menu::Menu() {
|
|||
|
||||
// Navigate > Show Address Bar
|
||||
addActionToQMenuAndActionHash(navigateMenu, MenuOption::AddressBar, Qt::CTRL | Qt::Key_L,
|
||||
dialogsManager.data(), SLOT(toggleAddressBar()));
|
||||
dialogsManager.data(), SLOT(showAddressBar()));
|
||||
|
||||
// Navigate > Bookmark related menus -- Note: the Bookmark class adds its own submenus here.
|
||||
qApp->getBookmarks()->setupMenus(this, navigateMenu);
|
||||
// Navigate > LocationBookmarks related menus -- Note: the LocationBookmarks class adds its own submenus here.
|
||||
auto locationBookmarks = DependencyManager::get<LocationBookmarks>();
|
||||
locationBookmarks->setupMenus(this, navigateMenu);
|
||||
|
||||
// Navigate > Copy Address [advanced]
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
|
|
|
@ -47,10 +47,11 @@ namespace MenuOption {
|
|||
const QString AudioTools = "Show Level Meter";
|
||||
const QString AutoMuteAudio = "Auto Mute Microphone";
|
||||
const QString AvatarReceiveStats = "Show Receive Stats";
|
||||
const QString AvatarBookmarks = "Avatar Bookmarks";
|
||||
const QString Back = "Back";
|
||||
const QString BinaryEyelidControl = "Binary Eyelid Control";
|
||||
const QString BookmarkAvatar = "Bookmark Avatar";
|
||||
const QString BookmarkLocation = "Bookmark Location";
|
||||
const QString Bookmarks = "Bookmarks";
|
||||
const QString CalibrateCamera = "Calibrate Camera";
|
||||
const QString CameraEntityMode = "Entity Mode";
|
||||
const QString CenterPlayerInView = "Center Player In View";
|
||||
|
@ -78,6 +79,7 @@ namespace MenuOption {
|
|||
const QString DeadlockInterface = "Deadlock Interface";
|
||||
const QString DecreaseAvatarSize = "Decrease Avatar Size";
|
||||
const QString DefaultSkybox = "Default Skybox";
|
||||
const QString DeleteAvatarBookmark = "Delete Avatar Bookmark...";
|
||||
const QString DeleteBookmark = "Delete Bookmark...";
|
||||
const QString DisableActivityLogger = "Disable Activity Logger";
|
||||
const QString DisableEyelidAdjustment = "Disable Eyelid Adjustment";
|
||||
|
@ -89,6 +91,7 @@ namespace MenuOption {
|
|||
const QString DisplayModelElementChildProxies = "Display Model Element Children";
|
||||
const QString DisplayModelElementProxy = "Display Model Element Bounds";
|
||||
const QString DisplayDebugTimingDetails = "Display Timing Details";
|
||||
const QString LocationBookmarks = "Bookmarks";
|
||||
const QString DontDoPrecisionPicking = "Don't Do Precision Picking";
|
||||
const QString DontRenderEntitiesAsScene = "Don't Render Entities as Scene";
|
||||
const QString EchoLocalAudio = "Echo Local Audio";
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
//
|
||||
// Physics.cpp
|
||||
// interface/src
|
||||
//
|
||||
// Copyright 2013 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 <glm/glm.hpp>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "Util.h"
|
||||
#include "world.h"
|
||||
#include "Physics.h"
|
||||
|
||||
//
|
||||
// Applies static friction: maxVelocity is the largest velocity for which there
|
||||
// there is friction, and strength is the amount of friction force applied to reduce
|
||||
// velocity.
|
||||
//
|
||||
void applyStaticFriction(float deltaTime, glm::vec3& velocity, float maxVelocity, float strength) {
|
||||
float v = glm::length(velocity);
|
||||
if (v < maxVelocity) {
|
||||
velocity *= glm::clamp((1.0f - deltaTime * strength * (1.0f - v / maxVelocity)), 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Applies velocity damping, with a strength value for linear and squared velocity damping
|
||||
//
|
||||
|
||||
void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, float squaredStrength) {
|
||||
if (squaredStrength == 0.0f) {
|
||||
velocity *= glm::clamp(1.0f - deltaTime * linearStrength, 0.0f, 1.0f);
|
||||
} else {
|
||||
velocity *= glm::clamp(1.0f - deltaTime * (linearStrength + glm::length(velocity) * squaredStrength), 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
void applyDampedSpring(float deltaTime, glm::vec3& velocity, glm::vec3& position, glm::vec3& targetPosition, float k, float damping) {
|
||||
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
//
|
||||
// Physics.h
|
||||
// interface/src
|
||||
//
|
||||
// Created by Philip on 4/25/13.
|
||||
// Copyright 2013 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_Physics_h
|
||||
#define hifi_Physics_h
|
||||
|
||||
void applyStaticFriction(float deltaTime, glm::vec3& velocity, float maxVelocity, float strength);
|
||||
void applyDamping(float deltaTime, glm::vec3& velocity, float linearStrength, float squaredStrength);
|
||||
|
||||
#endif // hifi_Physics_h
|
|
@ -9,44 +9,32 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <vector>
|
||||
#include "Avatar.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <QWindow>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <glm/gtx/vector_angle.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <QtCore/QThread>
|
||||
#include <glm/gtx/transform.hpp>
|
||||
#include <glm/gtx/vector_query.hpp>
|
||||
|
||||
#include <DeferredLightingEffect.h>
|
||||
#include <GeometryUtil.h>
|
||||
#include <LODManager.h>
|
||||
#include <EntityTreeRenderer.h>
|
||||
#include <NodeList.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <OctreeUtils.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PerfStat.h>
|
||||
#include <Rig.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <TextRenderer3D.h>
|
||||
#include <TextureCache.h>
|
||||
#include <VariantMapToScriptValue.h>
|
||||
#include <DebugDraw.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "Avatar.h"
|
||||
#include "AvatarManager.h"
|
||||
#include "AvatarMotionState.h"
|
||||
#include "Head.h"
|
||||
#include "Camera.h"
|
||||
#include "Menu.h"
|
||||
#include "Physics.h"
|
||||
#include "Util.h"
|
||||
#include "world.h"
|
||||
#include "InterfaceLogging.h"
|
||||
#include "SceneScriptingInterface.h"
|
||||
#include "SoftAttachmentModel.h"
|
||||
#include <Rig.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -71,7 +59,8 @@ namespace render {
|
|||
auto avatarPtr = static_pointer_cast<Avatar>(avatar);
|
||||
if (avatarPtr->isInitialized() && args) {
|
||||
PROFILE_RANGE_BATCH(*args->_batch, "renderAvatarPayload");
|
||||
avatarPtr->render(args, qApp->getCamera()->getPosition());
|
||||
// TODO AVATARS_RENDERER: remove need for qApp
|
||||
avatarPtr->render(args);
|
||||
}
|
||||
}
|
||||
template <> uint32_t metaFetchMetaSubItems(const AvatarSharedPointer& avatar, ItemIDs& subItems) {
|
||||
|
@ -85,7 +74,7 @@ namespace render {
|
|||
}
|
||||
}
|
||||
|
||||
Avatar::Avatar(RigPointer rig) :
|
||||
Avatar::Avatar(QThread* thread, RigPointer rig) :
|
||||
AvatarData(),
|
||||
_skeletonOffset(0.0f),
|
||||
_bodyYawDelta(0.0f),
|
||||
|
@ -96,11 +85,19 @@ Avatar::Avatar(RigPointer rig) :
|
|||
_lastOrientation(),
|
||||
_worldUpDirection(DEFAULT_UP_DIRECTION),
|
||||
_moving(false),
|
||||
_smoothPositionTime(SMOOTH_TIME_POSITION),
|
||||
_smoothPositionTimer(std::numeric_limits<float>::max()),
|
||||
_smoothOrientationTime(SMOOTH_TIME_ORIENTATION),
|
||||
_smoothOrientationTimer(std::numeric_limits<float>::max()),
|
||||
_smoothPositionInitial(),
|
||||
_smoothPositionTarget(),
|
||||
_smoothOrientationInitial(),
|
||||
_smoothOrientationTarget(),
|
||||
_initialized(false),
|
||||
_voiceSphereID(GeometryCache::UNKNOWN_ID)
|
||||
{
|
||||
// we may have been created in the network thread, but we live in the main thread
|
||||
moveToThread(qApp->thread());
|
||||
moveToThread(thread);
|
||||
|
||||
setScale(glm::vec3(1.0f)); // avatar scale is uniform
|
||||
|
||||
|
@ -120,7 +117,7 @@ Avatar::Avatar(RigPointer rig) :
|
|||
Avatar::~Avatar() {
|
||||
assert(isDead()); // mark dead before calling the dtor
|
||||
|
||||
auto treeRenderer = qApp->getEntities();
|
||||
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
||||
if (entityTree) {
|
||||
entityTree->withWriteLock([&] {
|
||||
|
@ -229,7 +226,7 @@ void Avatar::updateAvatarEntities() {
|
|||
return; // wait until MyAvatar gets an ID before doing this.
|
||||
}
|
||||
|
||||
auto treeRenderer = qApp->getEntities();
|
||||
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();
|
||||
EntityTreePointer entityTree = treeRenderer ? treeRenderer->getTree() : nullptr;
|
||||
if (!entityTree) {
|
||||
return;
|
||||
|
@ -349,6 +346,33 @@ void Avatar::simulate(float deltaTime, bool inView) {
|
|||
_simulationInViewRate.increment();
|
||||
}
|
||||
|
||||
if (!isMyAvatar()) {
|
||||
if (_smoothPositionTimer < _smoothPositionTime) {
|
||||
// Smooth the remote avatar movement.
|
||||
_smoothPositionTimer += deltaTime;
|
||||
if (_smoothPositionTimer < _smoothPositionTime) {
|
||||
AvatarData::setPosition(
|
||||
lerp(_smoothPositionInitial,
|
||||
_smoothPositionTarget,
|
||||
easeInOutQuad(glm::clamp(_smoothPositionTimer / _smoothPositionTime, 0.0f, 1.0f)))
|
||||
);
|
||||
updateAttitude();
|
||||
}
|
||||
}
|
||||
|
||||
if (_smoothOrientationTimer < _smoothOrientationTime) {
|
||||
// Smooth the remote avatar movement.
|
||||
_smoothOrientationTimer += deltaTime;
|
||||
if (_smoothOrientationTimer < _smoothOrientationTime) {
|
||||
AvatarData::setOrientation(
|
||||
slerp(_smoothOrientationInitial,
|
||||
_smoothOrientationTarget,
|
||||
easeInOutQuad(glm::clamp(_smoothOrientationTimer / _smoothOrientationTime, 0.0f, 1.0f)))
|
||||
);
|
||||
updateAttitude();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PerformanceTimer perfTimer("simulate");
|
||||
{
|
||||
|
@ -483,7 +507,7 @@ static TextRenderer3D* textRenderer(TextRendererType type) {
|
|||
return displayNameRenderer;
|
||||
}
|
||||
|
||||
void Avatar::addToScene(AvatarSharedPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
void Avatar::addToScene(AvatarSharedPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
auto avatarPayload = new render::Payload<AvatarData>(self);
|
||||
auto avatarPayloadPointer = Avatar::PayloadPointer(avatarPayload);
|
||||
_renderItemID = scene->allocateID();
|
||||
|
@ -495,7 +519,7 @@ void Avatar::addToScene(AvatarSharedPointer self, std::shared_ptr<render::Scene>
|
|||
}
|
||||
}
|
||||
|
||||
void Avatar::removeFromScene(AvatarSharedPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
void Avatar::removeFromScene(AvatarSharedPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
transaction.removeItem(_renderItemID);
|
||||
render::Item::clearID(_renderItemID);
|
||||
_skeletonModel->removeFromScene(scene, transaction);
|
||||
|
@ -543,11 +567,13 @@ void Avatar::postUpdate(float deltaTime) {
|
|||
}
|
||||
}
|
||||
|
||||
void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
|
||||
auto& batch = *renderArgs->_batch;
|
||||
void Avatar::render(RenderArgs* renderArgs) {
|
||||
auto& batch = *(renderArgs->_batch);
|
||||
PROFILE_RANGE_BATCH(batch, __FUNCTION__);
|
||||
|
||||
if (glm::distance(DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition(), getPosition()) < 10.0f) {
|
||||
glm::vec3 viewPos = renderArgs->getViewFrustum().getPosition();
|
||||
const float MAX_DISTANCE_SQUARED_FOR_SHOWING_POINTING_LASERS = 100.0f; // 10^2
|
||||
if (glm::distance2(viewPos, getPosition()) < MAX_DISTANCE_SQUARED_FOR_SHOWING_POINTING_LASERS) {
|
||||
auto geometryCache = DependencyManager::get<GeometryCache>();
|
||||
|
||||
// render pointing lasers
|
||||
|
@ -606,23 +632,16 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
|
|||
}
|
||||
}
|
||||
|
||||
{ // simple frustum check
|
||||
ViewFrustum frustum;
|
||||
if (renderArgs->_renderMode == RenderArgs::SHADOW_RENDER_MODE) {
|
||||
qApp->copyShadowViewFrustum(frustum);
|
||||
} else {
|
||||
qApp->copyDisplayViewFrustum(frustum);
|
||||
}
|
||||
if (!frustum.sphereIntersectsFrustum(getPosition(), getBoundingRadius())) {
|
||||
return;
|
||||
}
|
||||
ViewFrustum frustum = renderArgs->getViewFrustum();
|
||||
if (!frustum.sphereIntersectsFrustum(getPosition(), getBoundingRadius())) {
|
||||
return;
|
||||
}
|
||||
|
||||
glm::vec3 toTarget = cameraPosition - getPosition();
|
||||
glm::vec3 toTarget = frustum.getPosition() - getPosition();
|
||||
float distanceToTarget = glm::length(toTarget);
|
||||
|
||||
{
|
||||
fixupModelsInScene();
|
||||
fixupModelsInScene(renderArgs->_scene);
|
||||
|
||||
if (renderArgs->_renderMode != RenderArgs::SHADOW_RENDER_MODE) {
|
||||
// add local lights
|
||||
|
@ -651,8 +670,7 @@ void Avatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
|
|||
const float DISPLAYNAME_DISTANCE = 20.0f;
|
||||
setShowDisplayName(distanceToTarget < DISPLAYNAME_DISTANCE);
|
||||
|
||||
auto cameraMode = qApp->getCamera()->getMode();
|
||||
if (!isMyAvatar() || cameraMode != CAMERA_MODE_FIRST_PERSON) {
|
||||
if (!isMyAvatar() || renderArgs->_cameraMode != (int8_t)CAMERA_MODE_FIRST_PERSON) {
|
||||
auto& frustum = renderArgs->getViewFrustum();
|
||||
auto textPosition = getDisplayNamePosition();
|
||||
if (frustum.pointIntersectsFrustum(textPosition)) {
|
||||
|
@ -677,12 +695,11 @@ glm::quat Avatar::computeRotationFromBodyToWorldUp(float proportion) const {
|
|||
return glm::angleAxis(angle * proportion, axis);
|
||||
}
|
||||
|
||||
void Avatar::fixupModelsInScene() {
|
||||
void Avatar::fixupModelsInScene(const render::ScenePointer& scene) {
|
||||
_attachmentsToDelete.clear();
|
||||
|
||||
// check to see if when we added our models to the scene they were ready, if they were not ready, then
|
||||
// fix them up in the scene
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
render::Transaction transaction;
|
||||
if (_skeletonModel->isRenderable() && _skeletonModel->needsFixupInScene()) {
|
||||
_skeletonModel->removeFromScene(scene, transaction);
|
||||
|
@ -1361,13 +1378,31 @@ glm::quat Avatar::getUncachedRightPalmRotation() const {
|
|||
}
|
||||
|
||||
void Avatar::setPosition(const glm::vec3& position) {
|
||||
AvatarData::setPosition(position);
|
||||
updateAttitude();
|
||||
if (isMyAvatar()) {
|
||||
// This is the local avatar, no need to handle any position smoothing.
|
||||
AvatarData::setPosition(position);
|
||||
updateAttitude();
|
||||
return;
|
||||
}
|
||||
|
||||
// Whether or not there is an existing smoothing going on, just reset the smoothing timer and set the starting position as the avatar's current position, then smooth to the new position.
|
||||
_smoothPositionInitial = getPosition();
|
||||
_smoothPositionTarget = position;
|
||||
_smoothPositionTimer = 0.0f;
|
||||
}
|
||||
|
||||
void Avatar::setOrientation(const glm::quat& orientation) {
|
||||
AvatarData::setOrientation(orientation);
|
||||
updateAttitude();
|
||||
if (isMyAvatar()) {
|
||||
// This is the local avatar, no need to handle any position smoothing.
|
||||
AvatarData::setOrientation(orientation);
|
||||
updateAttitude();
|
||||
return;
|
||||
}
|
||||
|
||||
// Whether or not there is an existing smoothing going on, just reset the smoothing timer and set the starting position as the avatar's current position, then smooth to the new position.
|
||||
_smoothOrientationInitial = getOrientation();
|
||||
_smoothOrientationTarget = orientation;
|
||||
_smoothOrientationTimer = 0.0f;
|
||||
}
|
||||
|
||||
void Avatar::updatePalms() {
|
||||
|
@ -1437,8 +1472,7 @@ QList<QVariant> Avatar::getSkeleton() {
|
|||
return QList<QVariant>();
|
||||
}
|
||||
|
||||
void Avatar::addToScene(AvatarSharedPointer myHandle) {
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
void Avatar::addToScene(AvatarSharedPointer myHandle, const render::ScenePointer& scene) {
|
||||
if (scene) {
|
||||
render::Transaction transaction;
|
||||
auto nodelist = DependencyManager::get<NodeList>();
|
||||
|
@ -1452,8 +1486,9 @@ void Avatar::addToScene(AvatarSharedPointer myHandle) {
|
|||
qCWarning(interfaceapp) << "AvatarManager::addAvatar() : Unexpected null scene, possibly during application shutdown";
|
||||
}
|
||||
}
|
||||
void Avatar::ensureInScene(AvatarSharedPointer self) {
|
||||
|
||||
void Avatar::ensureInScene(AvatarSharedPointer self, const render::ScenePointer& scene) {
|
||||
if (!render::Item::isValidID(_renderItemID)) {
|
||||
addToScene(self);
|
||||
addToScene(self, scene);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,17 +14,15 @@
|
|||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QtCore/QUuid>
|
||||
|
||||
#include <AvatarData.h>
|
||||
#include <ShapeInfo.h>
|
||||
|
||||
#include <render/Scene.h>
|
||||
|
||||
|
||||
#include "Head.h"
|
||||
#include "SkeletonModel.h"
|
||||
#include "world.h"
|
||||
#include "Rig.h"
|
||||
#include <ThreadSafeValueCache.h>
|
||||
|
||||
|
@ -68,7 +66,7 @@ class Avatar : public AvatarData {
|
|||
Q_PROPERTY(glm::vec3 skeletonOffset READ getSkeletonOffset WRITE setSkeletonOffset)
|
||||
|
||||
public:
|
||||
explicit Avatar(RigPointer rig = nullptr);
|
||||
explicit Avatar(QThread* thread, RigPointer rig = nullptr);
|
||||
~Avatar();
|
||||
|
||||
typedef render::Payload<AvatarData> Payload;
|
||||
|
@ -79,12 +77,12 @@ public:
|
|||
void simulate(float deltaTime, bool inView);
|
||||
virtual void simulateAttachments(float deltaTime);
|
||||
|
||||
virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPosition);
|
||||
virtual void render(RenderArgs* renderArgs);
|
||||
|
||||
void addToScene(AvatarSharedPointer self, std::shared_ptr<render::Scene> scene,
|
||||
void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene,
|
||||
render::Transaction& transaction);
|
||||
|
||||
void removeFromScene(AvatarSharedPointer self, std::shared_ptr<render::Scene> scene,
|
||||
void removeFromScene(AvatarSharedPointer self, const render::ScenePointer& scene,
|
||||
render::Transaction& transaction);
|
||||
|
||||
void updateRenderItem(render::Transaction& transaction);
|
||||
|
@ -230,6 +228,16 @@ public:
|
|||
|
||||
bool hasNewJointData() const { return _hasNewJointData; }
|
||||
|
||||
inline float easeInOutQuad(float lerpValue) {
|
||||
assert(!((lerpValue < 0.0f) || (lerpValue > 1.0f)));
|
||||
|
||||
if (lerpValue < 0.5f) {
|
||||
return (2.0f * lerpValue * lerpValue);
|
||||
}
|
||||
|
||||
return (lerpValue*(4.0f - 2.0f * lerpValue) - 1.0f);
|
||||
}
|
||||
|
||||
public slots:
|
||||
|
||||
// FIXME - these should be migrated to use Pose data instead
|
||||
|
@ -244,6 +252,9 @@ public slots:
|
|||
protected:
|
||||
friend class AvatarManager;
|
||||
|
||||
const float SMOOTH_TIME_POSITION = 0.125f;
|
||||
const float SMOOTH_TIME_ORIENTATION = 0.075f;
|
||||
|
||||
virtual const QString& getSessionDisplayNameForTransport() const override { return _empty; } // Save a tiny bit of bandwidth. Mixer won't look at what we send.
|
||||
QString _empty{};
|
||||
virtual void maybeUpdateSessionDisplayNameFromTransport(const QString& sessionDisplayName) override { _sessionDisplayName = sessionDisplayName; } // don't use no-op setter!
|
||||
|
@ -292,7 +303,7 @@ protected:
|
|||
Transform calculateDisplayNameTransform(const ViewFrustum& view, const glm::vec3& textPosition) const;
|
||||
void renderDisplayName(gpu::Batch& batch, const ViewFrustum& view, const glm::vec3& textPosition) const;
|
||||
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const;
|
||||
virtual void fixupModelsInScene();
|
||||
virtual void fixupModelsInScene(const render::ScenePointer& scene);
|
||||
|
||||
virtual void updatePalms();
|
||||
|
||||
|
@ -303,8 +314,8 @@ protected:
|
|||
ThreadSafeValueCache<glm::vec3> _rightPalmPositionCache { glm::vec3() };
|
||||
ThreadSafeValueCache<glm::quat> _rightPalmRotationCache { glm::quat() };
|
||||
|
||||
void addToScene(AvatarSharedPointer self);
|
||||
void ensureInScene(AvatarSharedPointer self);
|
||||
void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene);
|
||||
void ensureInScene(AvatarSharedPointer self, const render::ScenePointer& scene);
|
||||
bool isInScene() const { return render::Item::isValidID(_renderItemID); }
|
||||
|
||||
// Some rate tracking support
|
||||
|
@ -313,6 +324,15 @@ protected:
|
|||
RateCounter<> _skeletonModelSimulationRate;
|
||||
RateCounter<> _jointDataSimulationRate;
|
||||
|
||||
// Smoothing data for blending from one position/orientation to another on remote agents.
|
||||
float _smoothPositionTime;
|
||||
float _smoothPositionTimer;
|
||||
float _smoothOrientationTime;
|
||||
float _smoothOrientationTimer;
|
||||
glm::vec3 _smoothPositionInitial;
|
||||
glm::vec3 _smoothPositionTarget;
|
||||
glm::quat _smoothOrientationInitial;
|
||||
glm::quat _smoothOrientationTarget;
|
||||
|
||||
private:
|
||||
class AvatarEntityDataHash {
|
||||
|
|
|
@ -69,7 +69,7 @@ void AvatarManager::registerMetaTypes(QScriptEngine* engine) {
|
|||
|
||||
AvatarManager::AvatarManager(QObject* parent) :
|
||||
_avatarsToFade(),
|
||||
_myAvatar(std::make_shared<MyAvatar>(std::make_shared<Rig>()))
|
||||
_myAvatar(std::make_shared<MyAvatar>(qApp->thread(), std::make_shared<Rig>()))
|
||||
{
|
||||
// register a meta type for the weak pointer we'll use for the owning avatar mixer for each avatar
|
||||
qRegisterMetaType<QWeakPointer<Node> >("NodeWeakPointer");
|
||||
|
@ -105,7 +105,7 @@ void AvatarManager::init() {
|
|||
this, &AvatarManager::updateAvatarRenderStatus, Qt::QueuedConnection);
|
||||
|
||||
if (_shouldRender) {
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||
render::Transaction transaction;
|
||||
_myAvatar->addToScene(_myAvatar, scene, transaction);
|
||||
scene->enqueueTransaction(transaction);
|
||||
|
@ -198,7 +198,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
|||
|
||||
// for ALL avatars...
|
||||
if (_shouldRender) {
|
||||
avatar->ensureInScene(avatar);
|
||||
avatar->ensureInScene(avatar, qApp->getMain3DScene());
|
||||
}
|
||||
if (!avatar->getMotionState()) {
|
||||
ShapeInfo shapeInfo;
|
||||
|
@ -306,12 +306,10 @@ void AvatarManager::simulateAvatarFades(float deltaTime) {
|
|||
if (avatar->getTargetScale() <= MIN_FADE_SCALE) {
|
||||
// fading to zero is such a rare event we push unique transaction for each one
|
||||
if (avatar->isInScene()) {
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||
render::Transaction transaction;
|
||||
avatar->removeFromScene(*itr, scene, transaction);
|
||||
if (scene) {
|
||||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
|
||||
// only remove from _avatarsToFade if we're sure its motionState has been removed from PhysicsEngine
|
||||
|
@ -329,7 +327,7 @@ void AvatarManager::simulateAvatarFades(float deltaTime) {
|
|||
}
|
||||
|
||||
AvatarSharedPointer AvatarManager::newSharedAvatar() {
|
||||
return std::make_shared<Avatar>(std::make_shared<Rig>());
|
||||
return std::make_shared<Avatar>(qApp->thread(), std::make_shared<Rig>());
|
||||
}
|
||||
|
||||
void AvatarManager::processAvatarDataPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
||||
|
@ -343,19 +341,19 @@ void AvatarManager::processAvatarDataPacket(QSharedPointer<ReceivedMessage> mess
|
|||
if (avatar->isInScene()) {
|
||||
if (!_shouldRender) {
|
||||
// rare transition so we process the transaction immediately
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||
render::Transaction transaction;
|
||||
avatar->removeFromScene(avatar, scene, transaction);
|
||||
if (scene) {
|
||||
render::Transaction transaction;
|
||||
avatar->removeFromScene(avatar, scene, transaction);
|
||||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
}
|
||||
} else if (_shouldRender) {
|
||||
// very rare transition so we process the transaction immediately
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||
render::Transaction transaction;
|
||||
avatar->addToScene(avatar, scene, transaction);
|
||||
if (scene) {
|
||||
render::Transaction transaction;
|
||||
avatar->addToScene(avatar, scene, transaction);
|
||||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +392,7 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar
|
|||
void AvatarManager::clearOtherAvatars() {
|
||||
// Remove other avatars from the world but don't actually remove them from _avatarHash
|
||||
// each will either be removed on timeout or will re-added to the world on receipt of update.
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||
render::Transaction transaction;
|
||||
|
||||
QReadLocker locker(&_hashLock);
|
||||
|
@ -414,9 +412,7 @@ void AvatarManager::clearOtherAvatars() {
|
|||
}
|
||||
++avatarIterator;
|
||||
}
|
||||
if (scene) {
|
||||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
scene->enqueueTransaction(transaction);
|
||||
_myAvatar->clearLookAtTargetAvatar();
|
||||
}
|
||||
|
||||
|
@ -522,7 +518,7 @@ void AvatarManager::handleCollisionEvents(const CollisionEvents& collisionEvents
|
|||
|
||||
void AvatarManager::updateAvatarRenderStatus(bool shouldRenderAvatars) {
|
||||
_shouldRender = shouldRenderAvatars;
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
const render::ScenePointer& scene = qApp->getMain3DScene();
|
||||
render::Transaction transaction;
|
||||
if (_shouldRender) {
|
||||
for (auto avatarData : _avatarHash) {
|
||||
|
@ -535,9 +531,7 @@ void AvatarManager::updateAvatarRenderStatus(bool shouldRenderAvatars) {
|
|||
avatar->removeFromScene(avatar, scene, transaction);
|
||||
}
|
||||
}
|
||||
if (scene) {
|
||||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
scene->enqueueTransaction(transaction);
|
||||
}
|
||||
|
||||
AvatarSharedPointer AvatarManager::getAvatarBySessionID(const QUuid& sessionID) const {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <shared/RateCounter.h>
|
||||
|
||||
#include "Avatar.h"
|
||||
#include "MyAvatar.h"
|
||||
#include "AvatarMotionState.h"
|
||||
#include "ScriptAvatar.h"
|
||||
|
||||
|
@ -42,6 +43,7 @@ public:
|
|||
void init();
|
||||
|
||||
std::shared_ptr<MyAvatar> getMyAvatar() { return _myAvatar; }
|
||||
glm::vec3 getMyAvatarPosition() const { return _myAvatar->getPosition(); }
|
||||
|
||||
// Null/Default-constructed QUuids will return MyAvatar
|
||||
Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) override { return new ScriptAvatar(getAvatarBySessionID(avatarID)); }
|
||||
|
@ -110,7 +112,7 @@ private:
|
|||
|
||||
QVector<AvatarSharedPointer> _avatarsToFade;
|
||||
|
||||
SetOfAvatarMotionStates _motionStatesThatMightUpdate;
|
||||
QSet<AvatarMotionState*> _motionStatesThatMightUpdate;
|
||||
VectorOfMotionStates _motionStatesToRemoveFromPhysics;
|
||||
SetOfMotionStates _motionStatesToAddToPhysics;
|
||||
|
||||
|
|
|
@ -83,6 +83,4 @@ protected:
|
|||
uint32_t _dirtyFlags;
|
||||
};
|
||||
|
||||
typedef QSet<AvatarMotionState*> SetOfAvatarMotionStates;
|
||||
|
||||
#endif // hifi_AvatarMotionState_h
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include "AvatarActionHold.h"
|
||||
#include "Menu.h"
|
||||
#include "MyAvatar.h"
|
||||
#include "Physics.h"
|
||||
#include "Util.h"
|
||||
#include "InterfaceLogging.h"
|
||||
#include "DebugDraw.h"
|
||||
|
@ -83,8 +82,8 @@ const float MyAvatar::ZOOM_MIN = 0.5f;
|
|||
const float MyAvatar::ZOOM_MAX = 25.0f;
|
||||
const float MyAvatar::ZOOM_DEFAULT = 1.5f;
|
||||
|
||||
MyAvatar::MyAvatar(RigPointer rig) :
|
||||
Avatar(rig),
|
||||
MyAvatar::MyAvatar(QThread* thread, RigPointer rig) :
|
||||
Avatar(thread, rig),
|
||||
_wasPushing(false),
|
||||
_isPushing(false),
|
||||
_isBeingPushed(false),
|
||||
|
@ -260,7 +259,7 @@ void MyAvatar::simulateAttachments(float deltaTime) {
|
|||
}
|
||||
|
||||
QByteArray MyAvatar::toByteArrayStateful(AvatarDataDetail dataDetail) {
|
||||
CameraMode mode = qApp->getCamera()->getMode();
|
||||
CameraMode mode = qApp->getCamera().getMode();
|
||||
_globalPosition = getPosition();
|
||||
_globalBoundingBoxDimensions.x = _characterController.getCapsuleRadius();
|
||||
_globalBoundingBoxDimensions.y = _characterController.getCapsuleHalfHeight();
|
||||
|
@ -752,13 +751,12 @@ controller::Pose MyAvatar::getRightHandTipPose() const {
|
|||
}
|
||||
|
||||
// virtual
|
||||
void MyAvatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) {
|
||||
void MyAvatar::render(RenderArgs* renderArgs) {
|
||||
// don't render if we've been asked to disable local rendering
|
||||
if (!_shouldRender) {
|
||||
return; // exit early
|
||||
}
|
||||
|
||||
Avatar::render(renderArgs, cameraPosition);
|
||||
Avatar::render(renderArgs);
|
||||
}
|
||||
|
||||
void MyAvatar::overrideAnimation(const QString& url, float fps, bool loop, float firstFrame, float lastFrame) {
|
||||
|
@ -927,8 +925,7 @@ void MyAvatar::setEnableDebugDrawIKTargets(bool isEnabled) {
|
|||
}
|
||||
|
||||
void MyAvatar::setEnableMeshVisible(bool isEnabled) {
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
_skeletonModel->setVisibleInScene(isEnabled, scene);
|
||||
_skeletonModel->setVisibleInScene(isEnabled, qApp->getMain3DScene());
|
||||
}
|
||||
|
||||
void MyAvatar::setUseAnimPreAndPostRotations(bool isEnabled) {
|
||||
|
@ -1079,7 +1076,7 @@ void MyAvatar::updateLookAtTargetAvatar() {
|
|||
_targetAvatarPosition = glm::vec3(0.0f);
|
||||
|
||||
glm::vec3 lookForward = getHead()->getFinalOrientationInWorldFrame() * IDENTITY_FORWARD;
|
||||
glm::vec3 cameraPosition = qApp->getCamera()->getPosition();
|
||||
glm::vec3 cameraPosition = qApp->getCamera().getPosition();
|
||||
|
||||
float smallestAngleTo = glm::radians(DEFAULT_FIELD_OF_VIEW_DEGREES) / 2.0f;
|
||||
const float KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR = 1.3f;
|
||||
|
@ -1225,8 +1222,7 @@ void MyAvatar::clearJointsData() {
|
|||
|
||||
void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
|
||||
Avatar::setSkeletonModelURL(skeletonModelURL);
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
_skeletonModel->setVisibleInScene(true, scene);
|
||||
_skeletonModel->setVisibleInScene(true, qApp->getMain3DScene());
|
||||
_headBoneSet.clear();
|
||||
}
|
||||
|
||||
|
@ -1275,7 +1271,7 @@ void MyAvatar::setAttachmentData(const QVector<AttachmentData>& attachmentData)
|
|||
}
|
||||
|
||||
glm::vec3 MyAvatar::getSkeletonPosition() const {
|
||||
CameraMode mode = qApp->getCamera()->getMode();
|
||||
CameraMode mode = qApp->getCamera().getMode();
|
||||
if (mode == CAMERA_MODE_THIRD_PERSON || mode == CAMERA_MODE_INDEPENDENT) {
|
||||
// The avatar is rotated PI about the yAxis, so we have to correct for it
|
||||
// to get the skeleton offset contribution in the world-frame.
|
||||
|
@ -1540,7 +1536,7 @@ void MyAvatar::attach(const QString& modelURL, const QString& jointName,
|
|||
Avatar::attach(modelURL, jointName, translation, rotation, scale, isSoft, allowDuplicates, useSaved);
|
||||
}
|
||||
|
||||
void MyAvatar::setVisibleInSceneIfReady(Model* model, render::ScenePointer scene, bool visible) {
|
||||
void MyAvatar::setVisibleInSceneIfReady(Model* model, const render::ScenePointer& scene, bool visible) {
|
||||
if (model->isActive() && model->isRenderable()) {
|
||||
model->setVisibleInScene(visible, scene);
|
||||
}
|
||||
|
@ -1634,8 +1630,7 @@ void MyAvatar::postUpdate(float deltaTime) {
|
|||
|
||||
Avatar::postUpdate(deltaTime);
|
||||
|
||||
render::ScenePointer scene = qApp->getMain3DScene();
|
||||
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderAvatars() && _skeletonModel->initWhenReady(scene)) {
|
||||
if (DependencyManager::get<SceneScriptingInterface>()->shouldRenderAvatars() && _skeletonModel->initWhenReady(qApp->getMain3DScene())) {
|
||||
initHeadBones();
|
||||
_skeletonModel->setCauterizeBoneSet(_headBoneSet);
|
||||
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
||||
|
@ -1704,13 +1699,13 @@ void MyAvatar::preDisplaySide(RenderArgs* renderArgs) {
|
|||
const float RENDER_HEAD_CUTOFF_DISTANCE = 0.3f;
|
||||
|
||||
bool MyAvatar::cameraInsideHead() const {
|
||||
const glm::vec3 cameraPosition = qApp->getCamera()->getPosition();
|
||||
const glm::vec3 cameraPosition = qApp->getCamera().getPosition();
|
||||
return glm::length(cameraPosition - getHeadPosition()) < (RENDER_HEAD_CUTOFF_DISTANCE * getUniformScale());
|
||||
}
|
||||
|
||||
bool MyAvatar::shouldRenderHead(const RenderArgs* renderArgs) const {
|
||||
bool defaultMode = renderArgs->_renderMode == RenderArgs::DEFAULT_RENDER_MODE;
|
||||
bool firstPerson = qApp->getCamera()->getMode() == CAMERA_MODE_FIRST_PERSON;
|
||||
bool firstPerson = qApp->getCamera().getMode() == CAMERA_MODE_FIRST_PERSON;
|
||||
bool insideHead = cameraInsideHead();
|
||||
return !defaultMode || !firstPerson || !insideHead;
|
||||
}
|
||||
|
@ -2265,7 +2260,7 @@ glm::vec3 MyAvatar::getPositionForAudio() {
|
|||
case AudioListenerMode::FROM_HEAD:
|
||||
return getHead()->getPosition();
|
||||
case AudioListenerMode::FROM_CAMERA:
|
||||
return qApp->getCamera()->getPosition();
|
||||
return qApp->getCamera().getPosition();
|
||||
case AudioListenerMode::CUSTOM:
|
||||
return _customListenPosition;
|
||||
}
|
||||
|
@ -2277,7 +2272,7 @@ glm::quat MyAvatar::getOrientationForAudio() {
|
|||
case AudioListenerMode::FROM_HEAD:
|
||||
return getHead()->getFinalOrientationInWorldFrame();
|
||||
case AudioListenerMode::FROM_CAMERA:
|
||||
return qApp->getCamera()->getOrientation();
|
||||
return qApp->getCamera().getOrientation();
|
||||
case AudioListenerMode::CUSTOM:
|
||||
return _customListenOrientation;
|
||||
}
|
||||
|
@ -2367,7 +2362,7 @@ void MyAvatar::FollowHelper::decrementTimeRemaining(float dt) {
|
|||
}
|
||||
|
||||
bool MyAvatar::FollowHelper::shouldActivateRotation(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const {
|
||||
auto cameraMode = qApp->getCamera()->getMode();
|
||||
auto cameraMode = qApp->getCamera().getMode();
|
||||
if (cameraMode == CAMERA_MODE_THIRD_PERSON) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -2515,8 +2510,8 @@ void MyAvatar::setAway(bool value) {
|
|||
glm::mat4 MyAvatar::computeCameraRelativeHandControllerMatrix(const glm::mat4& controllerSensorMatrix) const {
|
||||
|
||||
// Fetch the current camera transform.
|
||||
glm::mat4 cameraWorldMatrix = qApp->getCamera()->getTransform();
|
||||
if (qApp->getCamera()->getMode() == CAMERA_MODE_MIRROR) {
|
||||
glm::mat4 cameraWorldMatrix = qApp->getCamera().getTransform();
|
||||
if (qApp->getCamera().getMode() == CAMERA_MODE_MIRROR) {
|
||||
cameraWorldMatrix *= createMatFromScaleQuatAndPos(vec3(-1.0f, 1.0f, 1.0f), glm::quat(), glm::vec3());
|
||||
}
|
||||
|
||||
|
@ -2561,7 +2556,7 @@ glm::quat MyAvatar::getAbsoluteJointRotationInObjectFrame(int index) const {
|
|||
Transform avatarTransform;
|
||||
Transform::mult(avatarTransform, getParentTransform(success), getLocalTransform());
|
||||
glm::mat4 invAvatarMat = avatarTransform.getInverseMatrix();
|
||||
return glmExtractRotation(invAvatarMat * qApp->getCamera()->getTransform());
|
||||
return glmExtractRotation(invAvatarMat * qApp->getCamera().getTransform());
|
||||
}
|
||||
default: {
|
||||
return Avatar::getAbsoluteJointRotationInObjectFrame(index);
|
||||
|
@ -2598,7 +2593,7 @@ glm::vec3 MyAvatar::getAbsoluteJointTranslationInObjectFrame(int index) const {
|
|||
Transform avatarTransform;
|
||||
Transform::mult(avatarTransform, getParentTransform(success), getLocalTransform());
|
||||
glm::mat4 invAvatarMat = avatarTransform.getInverseMatrix();
|
||||
return extractTranslation(invAvatarMat * qApp->getCamera()->getTransform());
|
||||
return extractTranslation(invAvatarMat * qApp->getCamera().getTransform());
|
||||
}
|
||||
default: {
|
||||
return Avatar::getAbsoluteJointTranslationInObjectFrame(index);
|
||||
|
|
|
@ -146,7 +146,7 @@ public:
|
|||
};
|
||||
Q_ENUM(DriveKeys)
|
||||
|
||||
explicit MyAvatar(RigPointer rig);
|
||||
explicit MyAvatar(QThread* thread, RigPointer rig);
|
||||
~MyAvatar();
|
||||
|
||||
void registerMetaTypes(QScriptEngine* engine);
|
||||
|
@ -525,7 +525,7 @@ private:
|
|||
|
||||
void simulate(float deltaTime);
|
||||
void updateFromTrackers(float deltaTime);
|
||||
virtual void render(RenderArgs* renderArgs, const glm::vec3& cameraPositio) override;
|
||||
virtual void render(RenderArgs* renderArgs) override;
|
||||
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const override;
|
||||
void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; setEnableMeshVisible(shouldRender); }
|
||||
bool getShouldRenderLocally() const { return _shouldRender; }
|
||||
|
@ -551,7 +551,7 @@ private:
|
|||
// These are made private for MyAvatar so that you will use the "use" methods instead
|
||||
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL) override;
|
||||
|
||||
void setVisibleInSceneIfReady(Model* model, render::ScenePointer scene, bool visiblity);
|
||||
void setVisibleInSceneIfReady(Model* model, const render::ScenePointer& scene, bool visiblity);
|
||||
|
||||
// derive avatar body position and orientation from the current HMD Sensor location.
|
||||
// results are in HMD frame
|
||||
|
|
|
@ -34,9 +34,13 @@ void HFTabletWebEngineRequestInterceptor::interceptRequest(QWebEngineUrlRequestI
|
|||
QString bearerTokenString = "Bearer " + accountManager->getAccountInfo().getAccessToken().token;
|
||||
info.setHttpHeader(OAUTH_AUTHORIZATION_HEADER.toLocal8Bit(), bearerTokenString.toLocal8Bit());
|
||||
}
|
||||
}
|
||||
|
||||
static const QString USER_AGENT = "User-Agent";
|
||||
QString tokenString = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36";
|
||||
info.setHttpHeader(USER_AGENT.toLocal8Bit(), tokenString.toLocal8Bit());
|
||||
static const QString USER_AGENT = "User-Agent";
|
||||
QString tokenString = "Chrome/48.0 (HighFidelityInterface)";
|
||||
info.setHttpHeader(USER_AGENT.toLocal8Bit(), tokenString.toLocal8Bit());
|
||||
} else {
|
||||
static const QString USER_AGENT = "User-Agent";
|
||||
QString tokenString = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36";
|
||||
info.setHttpHeader(USER_AGENT.toLocal8Bit(), tokenString.toLocal8Bit());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,15 +16,24 @@
|
|||
#include "ui/DialogsManager.h"
|
||||
|
||||
DialogsManagerScriptingInterface::DialogsManagerScriptingInterface() {
|
||||
connect(DependencyManager::get<DialogsManager>().data(), &DialogsManager::addressBarToggled,
|
||||
this, &DialogsManagerScriptingInterface::addressBarToggled);
|
||||
connect(DependencyManager::get<DialogsManager>().data(), &DialogsManager::addressBarShown,
|
||||
this, &DialogsManagerScriptingInterface::addressBarShown);
|
||||
}
|
||||
|
||||
void DialogsManagerScriptingInterface::toggleAddressBar() {
|
||||
|
||||
DialogsManagerScriptingInterface* DialogsManagerScriptingInterface::getInstance() {
|
||||
static DialogsManagerScriptingInterface sharedInstance;
|
||||
return &sharedInstance;
|
||||
}
|
||||
|
||||
void DialogsManagerScriptingInterface::showAddressBar() {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<DialogsManager>().data(),
|
||||
"toggleAddressBar", Qt::QueuedConnection);
|
||||
"showAddressBar", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void DialogsManagerScriptingInterface::hideAddressBar() {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<DialogsManager>().data(),
|
||||
"hideAddressBar", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void DialogsManagerScriptingInterface::showFeed() {
|
||||
|
|
|
@ -18,13 +18,14 @@ class DialogsManagerScriptingInterface : public QObject {
|
|||
Q_OBJECT
|
||||
public:
|
||||
DialogsManagerScriptingInterface();
|
||||
static DialogsManagerScriptingInterface* getInstance();
|
||||
Q_INVOKABLE void showFeed();
|
||||
|
||||
public slots:
|
||||
void toggleAddressBar();
|
||||
void showAddressBar();
|
||||
void hideAddressBar();
|
||||
|
||||
signals:
|
||||
void addressBarToggled();
|
||||
void addressBarShown(bool visible);
|
||||
};
|
||||
|
||||
|
|
|
@ -105,9 +105,9 @@ QScriptValue HMDScriptingInterface::getHUDLookAtPosition3D(QScriptContext* conte
|
|||
}
|
||||
|
||||
bool HMDScriptingInterface::getHUDLookAtPosition3D(glm::vec3& result) const {
|
||||
Camera* camera = qApp->getCamera();
|
||||
glm::vec3 position = camera->getPosition();
|
||||
glm::quat orientation = camera->getOrientation();
|
||||
const Camera& camera = qApp->getCamera();
|
||||
glm::vec3 position = camera.getPosition();
|
||||
glm::quat orientation = camera.getOrientation();
|
||||
|
||||
glm::vec3 direction = orientation * glm::vec3(0.0f, 0.0f, -1.0f);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "DependencyManager.h"
|
||||
#include "AddressManager.h"
|
||||
#include "DialogsManager.h"
|
||||
#include "LocationBookmarks.h"
|
||||
|
||||
HIFI_QML_DEF(AddressBarDialog)
|
||||
|
||||
|
@ -52,7 +53,8 @@ void AddressBarDialog::loadAddress(const QString& address, bool fromSuggestions)
|
|||
|
||||
void AddressBarDialog::loadHome() {
|
||||
qDebug() << "Called LoadHome";
|
||||
QString homeLocation = qApp->getBookmarks()->addressForBookmark(Bookmarks::HOME_BOOKMARK);
|
||||
auto locationBookmarks = DependencyManager::get<LocationBookmarks>();
|
||||
QString homeLocation = locationBookmarks->addressForBookmark(LocationBookmarks::HOME_BOOKMARK);
|
||||
const QString DEFAULT_HOME_LOCATION = "localhost";
|
||||
if (homeLocation == "") {
|
||||
homeLocation = DEFAULT_HOME_LOCATION;
|
||||
|
|
|
@ -46,49 +46,32 @@ void DialogsManager::maybeCreateDialog(QPointer<T>& member) {
|
|||
}
|
||||
}
|
||||
|
||||
void DialogsManager::toggleAddressBar() {
|
||||
auto hmd = DependencyManager::get<HMDScriptingInterface>();
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
if (tablet->getToolbarMode()) {
|
||||
if (tablet->isPathLoaded(TABLET_ADDRESS_DIALOG)) {
|
||||
tablet->gotoHomeScreen();
|
||||
emit addressBarToggled();
|
||||
} else {
|
||||
tablet->loadQMLSource(TABLET_ADDRESS_DIALOG);
|
||||
emit addressBarToggled();
|
||||
}
|
||||
} else {
|
||||
if (hmd->getShouldShowTablet()) {
|
||||
if (tablet->isPathLoaded(TABLET_ADDRESS_DIALOG) && _closeAddressBar) {
|
||||
tablet->gotoHomeScreen();
|
||||
hmd->closeTablet();
|
||||
_closeAddressBar = false;
|
||||
emit addressBarToggled();
|
||||
} else {
|
||||
tablet->loadQMLSource(TABLET_ADDRESS_DIALOG);
|
||||
_closeAddressBar = true;
|
||||
emit addressBarToggled();
|
||||
}
|
||||
} else {
|
||||
tablet->loadQMLSource(TABLET_ADDRESS_DIALOG);
|
||||
hmd->openTablet();
|
||||
_closeAddressBar = true;
|
||||
emit addressBarToggled();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void DialogsManager::showAddressBar() {
|
||||
auto hmd = DependencyManager::get<HMDScriptingInterface>();
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
tablet->loadQMLSource(TABLET_ADDRESS_DIALOG);
|
||||
|
||||
if (!tablet->isPathLoaded(TABLET_ADDRESS_DIALOG)) {
|
||||
tablet->loadQMLSource(TABLET_ADDRESS_DIALOG);
|
||||
}
|
||||
if (!hmd->getShouldShowTablet()) {
|
||||
hmd->openTablet();
|
||||
}
|
||||
qApp->setKeyboardFocusOverlay(hmd->getCurrentTabletScreenID());
|
||||
emit addressBarShown(true);
|
||||
}
|
||||
|
||||
void DialogsManager::hideAddressBar() {
|
||||
auto hmd = DependencyManager::get<HMDScriptingInterface>();
|
||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||
auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
|
||||
if (tablet->isPathLoaded(TABLET_ADDRESS_DIALOG)) {
|
||||
tablet->gotoHomeScreen();
|
||||
hmd->closeTablet();
|
||||
}
|
||||
qApp->setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
|
||||
emit addressBarShown(false);
|
||||
}
|
||||
|
||||
void DialogsManager::showFeed() {
|
||||
|
|
|
@ -41,8 +41,8 @@ public:
|
|||
void emitAddressBarShown(bool visible) { emit addressBarShown(visible); }
|
||||
|
||||
public slots:
|
||||
void toggleAddressBar();
|
||||
void showAddressBar();
|
||||
void hideAddressBar();
|
||||
void showFeed();
|
||||
void setDomainConnectionFailureVisibility(bool visible);
|
||||
void toggleLoginDialog();
|
||||
|
@ -57,7 +57,6 @@ public slots:
|
|||
void showUpdateDialog();
|
||||
|
||||
signals:
|
||||
void addressBarToggled();
|
||||
void addressBarShown(bool visible);
|
||||
void setUseFeed(bool useFeed);
|
||||
|
||||
|
|
|
@ -40,6 +40,9 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) {
|
|||
QJsonObject userStoryObject;
|
||||
QJsonObject detailsObject;
|
||||
detailsObject.insert("image_url", imageUrl);
|
||||
if (dataObject.contains("shareable_url")) {
|
||||
detailsObject.insert("shareable_url", dataObject.value("shareable_url").toString());
|
||||
}
|
||||
QString pickledDetails = QJsonDocument(detailsObject).toJson();
|
||||
userStoryObject.insert("details", pickledDetails);
|
||||
userStoryObject.insert("thumbnail_url", thumbnailUrl);
|
||||
|
|
|
@ -31,7 +31,7 @@ QVariant Billboardable::getProperty(const QString &property) {
|
|||
void Billboardable::pointTransformAtCamera(Transform& transform, glm::quat offsetRotation) {
|
||||
if (isFacingAvatar()) {
|
||||
glm::vec3 billboardPos = transform.getTranslation();
|
||||
glm::vec3 cameraPos = qApp->getCamera()->getPosition();
|
||||
glm::vec3 cameraPos = qApp->getCamera().getPosition();
|
||||
glm::vec3 look = cameraPos - billboardPos;
|
||||
float elevation = -asinf(look.y / glm::length(look));
|
||||
float azimuth = atan2f(look.x, look.z);
|
||||
|
|
|
@ -58,13 +58,13 @@ void ModelOverlay::update(float deltatime) {
|
|||
_isLoaded = _model->isActive();
|
||||
}
|
||||
|
||||
bool ModelOverlay::addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
bool ModelOverlay::addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
Volume3DOverlay::addToScene(overlay, scene, transaction);
|
||||
_model->addToScene(scene, transaction);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ModelOverlay::removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
void ModelOverlay::removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
Volume3DOverlay::removeFromScene(overlay, scene, transaction);
|
||||
_model->removeFromScene(scene, transaction);
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ public:
|
|||
|
||||
virtual ModelOverlay* createClone() const override;
|
||||
|
||||
virtual bool addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
||||
virtual bool addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
|
||||
void locationChanged(bool tellPhysics) override;
|
||||
|
||||
|
|
|
@ -196,13 +196,13 @@ float Overlay::updatePulse() {
|
|||
return _pulse;
|
||||
}
|
||||
|
||||
bool Overlay::addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
bool Overlay::addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
_renderItemID = scene->allocateID();
|
||||
transaction.resetItem(_renderItemID, std::make_shared<Overlay::Payload>(overlay));
|
||||
return true;
|
||||
}
|
||||
|
||||
void Overlay::removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
void Overlay::removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
transaction.removeItem(_renderItemID);
|
||||
render::Item::clearID(_renderItemID);
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ public:
|
|||
virtual AABox getBounds() const = 0;
|
||||
virtual bool supportsGetProperty() const { return true; }
|
||||
|
||||
virtual bool addToScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction);
|
||||
virtual void removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::Scene> scene, render::Transaction& transaction);
|
||||
virtual bool addToScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction);
|
||||
virtual void removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction);
|
||||
|
||||
virtual const render::ShapeKey getShapeKey() { return render::ShapeKey::Builder::ownPipeline(); }
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@ void Web3DOverlay::loadSourceURL() {
|
|||
_webSurface->getRootContext()->setContextProperty("AvatarInputs", AvatarInputs::getInstance());
|
||||
_webSurface->getRootContext()->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance());
|
||||
_webSurface->getRootContext()->setContextProperty("AvatarList", DependencyManager::get<AvatarManager>().data());
|
||||
_webSurface->getRootContext()->setContextProperty("DialogsManager", DialogsManagerScriptingInterface::getInstance());
|
||||
|
||||
_webSurface->getRootContext()->setContextProperty("pathToFonts", "../../");
|
||||
tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data());
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
Q_INVOKABLE QVector<QUuid> getAvatarIdentifiers();
|
||||
|
||||
// Null/Default-constructed QUuids will return MyAvatar
|
||||
virtual ScriptAvatarData* getAvatar(QUuid avatarID) { return new ScriptAvatarData(getAvatarBySessionID(avatarID)); }
|
||||
Q_INVOKABLE virtual ScriptAvatarData* getAvatar(QUuid avatarID) { return new ScriptAvatarData(getAvatarBySessionID(avatarID)); }
|
||||
|
||||
virtual AvatarSharedPointer getAvatarBySessionID(const QUuid& sessionID) const { return findAvatar(sessionID); }
|
||||
int numberOfAvatarsInRange(const glm::vec3& position, float rangeMeters);
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace render {
|
|||
// Mixin class for implementing basic single item rendering
|
||||
class SimpleRenderableEntityItem {
|
||||
public:
|
||||
bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
_myItem = scene->allocateID();
|
||||
|
||||
auto renderData = std::make_shared<RenderableEntityItemProxy>(self, _myItem);
|
||||
|
@ -69,7 +69,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
transaction.removeItem(_myItem);
|
||||
render::Item::clearID(_myItem);
|
||||
}
|
||||
|
@ -99,8 +99,8 @@ private:
|
|||
|
||||
#define SIMPLE_RENDERABLE() \
|
||||
public: \
|
||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override { return _renderHelper.addToScene(self, scene, transaction); } \
|
||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override { _renderHelper.removeFromScene(self, scene, transaction); } \
|
||||
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override { return _renderHelper.addToScene(self, scene, transaction); } \
|
||||
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override { _renderHelper.removeFromScene(self, scene, transaction); } \
|
||||
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); _renderHelper.notifyChanged(); } \
|
||||
virtual void dimensionsChanged() override { EntityItem::dimensionsChanged(); _renderHelper.notifyChanged(); } \
|
||||
void checkFading() { \
|
||||
|
|
|
@ -27,7 +27,7 @@ RenderableLightEntityItem::RenderableLightEntityItem(const EntityItemID& entityI
|
|||
{
|
||||
}
|
||||
|
||||
bool RenderableLightEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
bool RenderableLightEntityItem::addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
_myItem = scene->allocateID();
|
||||
|
||||
auto renderItem = std::make_shared<LightPayload>();
|
||||
|
@ -51,7 +51,7 @@ void RenderableLightEntityItem::somethingChangedNotification() {
|
|||
LightEntityItem::somethingChangedNotification();
|
||||
}
|
||||
|
||||
void RenderableLightEntityItem::removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
void RenderableLightEntityItem::removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
transaction.removeItem(_myItem);
|
||||
render::Item::clearID(_myItem);
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ public:
|
|||
|
||||
void updateLightFromEntity(render::Transaction& transaction);
|
||||
|
||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
||||
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
|
||||
virtual void somethingChangedNotification() override;
|
||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
|
||||
virtual void locationChanged(bool tellPhysics = true) override;
|
||||
|
||||
|
|
|
@ -91,13 +91,13 @@ bool RenderableModelEntityItem::setProperties(const EntityItemProperties& proper
|
|||
return somethingChanged;
|
||||
}
|
||||
|
||||
int RenderableModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
int RenderableModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, int bytesLeftToRead,
|
||||
ReadBitstreamToTreeParams& args,
|
||||
EntityPropertyFlags& propertyFlags, bool overwriteLocalData,
|
||||
bool& somethingChanged) {
|
||||
QString oldModelURL = getModelURL();
|
||||
int bytesRead = ModelEntityItem::readEntitySubclassDataFromBuffer(data, bytesLeftToRead,
|
||||
args, propertyFlags,
|
||||
int bytesRead = ModelEntityItem::readEntitySubclassDataFromBuffer(data, bytesLeftToRead,
|
||||
args, propertyFlags,
|
||||
overwriteLocalData, somethingChanged);
|
||||
if (oldModelURL != getModelURL()) {
|
||||
_needsModelReload = true;
|
||||
|
@ -137,7 +137,7 @@ void RenderableModelEntityItem::remapTextures() {
|
|||
if (!_model) {
|
||||
return; // nothing to do if we don't have a model
|
||||
}
|
||||
|
||||
|
||||
if (!_model->isLoaded()) {
|
||||
return; // nothing to do if the model has not yet loaded
|
||||
}
|
||||
|
@ -189,16 +189,16 @@ public:
|
|||
RenderableModelEntityItemMeta(EntityItemPointer entity) : entity(entity){ }
|
||||
typedef render::Payload<RenderableModelEntityItemMeta> Payload;
|
||||
typedef Payload::DataPointer Pointer;
|
||||
|
||||
|
||||
EntityItemPointer entity;
|
||||
};
|
||||
|
||||
namespace render {
|
||||
template <> const ItemKey payloadGetKey(const RenderableModelEntityItemMeta::Pointer& payload) {
|
||||
template <> const ItemKey payloadGetKey(const RenderableModelEntityItemMeta::Pointer& payload) {
|
||||
return ItemKey::Builder::opaqueShape().withTypeMeta();
|
||||
}
|
||||
|
||||
template <> const Item::Bound payloadGetBound(const RenderableModelEntityItemMeta::Pointer& payload) {
|
||||
|
||||
template <> const Item::Bound payloadGetBound(const RenderableModelEntityItemMeta::Pointer& payload) {
|
||||
if (payload && payload->entity) {
|
||||
bool success;
|
||||
auto result = payload->entity->getAABox(success);
|
||||
|
@ -228,7 +228,7 @@ namespace render {
|
|||
}
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
||||
bool RenderableModelEntityItem::addToScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) {
|
||||
_myMetaItem = scene->allocateID();
|
||||
|
||||
|
@ -249,7 +249,7 @@ bool RenderableModelEntityItem::addToScene(EntityItemPointer self, std::shared_p
|
|||
return true;
|
||||
}
|
||||
|
||||
void RenderableModelEntityItem::removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
||||
void RenderableModelEntityItem::removeFromScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) {
|
||||
transaction.removeItem(_myMetaItem);
|
||||
render::Item::clearID(_myMetaItem);
|
||||
|
@ -437,7 +437,7 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
_model->renderDebugMeshBoxes(batch);
|
||||
#endif
|
||||
|
||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
|
||||
// FIXME: this seems like it could be optimized if we tracked our last known visible state in
|
||||
// the renderable item. As it stands now the model checks it's visible/invisible state
|
||||
|
@ -502,11 +502,11 @@ ModelPointer RenderableModelEntityItem::getModel(QSharedPointer<EntityTreeRender
|
|||
_myRenderer = renderer;
|
||||
}
|
||||
assert(_myRenderer == renderer); // you should only ever render on one renderer
|
||||
|
||||
|
||||
if (!_myRenderer || QThread::currentThread() != _myRenderer->thread()) {
|
||||
return _model;
|
||||
}
|
||||
|
||||
|
||||
_needsModelReload = false; // this is the reload
|
||||
|
||||
// If we have a URL, then we will want to end up returning a model...
|
||||
|
@ -526,7 +526,7 @@ ModelPointer RenderableModelEntityItem::getModel(QSharedPointer<EntityTreeRender
|
|||
// If we have no URL, then we can delete any model we do have...
|
||||
} else if (_model) {
|
||||
// remove from scene
|
||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
render::Transaction transaction;
|
||||
_model->removeFromScene(scene, transaction);
|
||||
scene->enqueueTransaction(transaction);
|
||||
|
@ -552,7 +552,7 @@ void RenderableModelEntityItem::update(const quint64& now) {
|
|||
properties.setLastEdited(usecTimestampNow()); // we must set the edit time since we're editing it
|
||||
auto extents = _model->getMeshExtents();
|
||||
properties.setDimensions(extents.maximum - extents.minimum);
|
||||
qCDebug(entitiesrenderer) << "Autoresizing" << (!getName().isEmpty() ? getName() : getModelURL())
|
||||
qCDebug(entitiesrenderer) << "Autoresizing" << (!getName().isEmpty() ? getName() : getModelURL())
|
||||
<< "from mesh extents";
|
||||
QMetaObject::invokeMethod(DependencyManager::get<EntityScriptingInterface>().data(), "editEntity",
|
||||
Qt::QueuedConnection,
|
||||
|
@ -594,8 +594,8 @@ bool RenderableModelEntityItem::supportsDetailedRayIntersection() const {
|
|||
return _model && _model->isLoaded();
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
bool& keepSearching, OctreeElementPointer& element, float& distance, BoxFace& face,
|
||||
bool RenderableModelEntityItem::findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||
bool& keepSearching, OctreeElementPointer& element, float& distance, BoxFace& face,
|
||||
glm::vec3& surfaceNormal, void** intersectedObject, bool precisionPicking) const {
|
||||
if (!_model) {
|
||||
return true;
|
||||
|
@ -1239,11 +1239,10 @@ void RenderableModelEntityItem::locationChanged(bool tellPhysics) {
|
|||
return;
|
||||
}
|
||||
|
||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
render::Transaction transaction;
|
||||
|
||||
transaction.updateItem(myMetaItem);
|
||||
scene->enqueueTransaction(transaction);
|
||||
AbstractViewStateInterface::instance()->getMain3DScene()->enqueueTransaction(transaction);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ public:
|
|||
|
||||
void doInitialModelSimulation();
|
||||
|
||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
||||
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
|
||||
|
||||
void updateModelBounds();
|
||||
|
|
|
@ -161,7 +161,7 @@ RenderableParticleEffectEntityItem::RenderableParticleEffectEntityItem(const Ent
|
|||
}
|
||||
|
||||
bool RenderableParticleEffectEntityItem::addToScene(EntityItemPointer self,
|
||||
render::ScenePointer scene,
|
||||
const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) {
|
||||
_scene = scene;
|
||||
_renderItemId = _scene->allocateID();
|
||||
|
@ -176,7 +176,7 @@ bool RenderableParticleEffectEntityItem::addToScene(EntityItemPointer self,
|
|||
}
|
||||
|
||||
void RenderableParticleEffectEntityItem::removeFromScene(EntityItemPointer self,
|
||||
render::ScenePointer scene,
|
||||
const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) {
|
||||
transaction.removeItem(_renderItemId);
|
||||
_scene = nullptr;
|
||||
|
@ -323,4 +323,4 @@ void RenderableParticleEffectEntityItem::notifyBoundChanged() {
|
|||
});
|
||||
|
||||
_scene->enqueueTransaction(transaction);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ public:
|
|||
|
||||
void updateRenderItem();
|
||||
|
||||
virtual bool addToScene(EntityItemPointer self, render::ScenePointer scene, render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(EntityItemPointer self, render::ScenePointer scene, render::Transaction& transaction) override;
|
||||
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
|
||||
protected:
|
||||
virtual void locationChanged(bool tellPhysics = true) override { EntityItem::locationChanged(tellPhysics); notifyBoundChanged(); }
|
||||
|
|
|
@ -816,7 +816,7 @@ void RenderablePolyVoxEntityItem::render(RenderArgs* args) {
|
|||
}
|
||||
|
||||
bool RenderablePolyVoxEntityItem::addToScene(EntityItemPointer self,
|
||||
std::shared_ptr<render::Scene> scene,
|
||||
const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) {
|
||||
_myItem = scene->allocateID();
|
||||
|
||||
|
@ -834,7 +834,7 @@ bool RenderablePolyVoxEntityItem::addToScene(EntityItemPointer self,
|
|||
}
|
||||
|
||||
void RenderablePolyVoxEntityItem::removeFromScene(EntityItemPointer self,
|
||||
std::shared_ptr<render::Scene> scene,
|
||||
const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) {
|
||||
transaction.removeItem(_myItem);
|
||||
render::Item::clearID(_myItem);
|
||||
|
|
|
@ -106,10 +106,10 @@ public:
|
|||
virtual void setZTextureURL(const QString& zTextureURL) override;
|
||||
|
||||
virtual bool addToScene(EntityItemPointer self,
|
||||
std::shared_ptr<render::Scene> scene,
|
||||
const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(EntityItemPointer self,
|
||||
std::shared_ptr<render::Scene> scene,
|
||||
const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) override;
|
||||
|
||||
virtual void setXNNeighborID(const EntityItemID& xNNeighborID) override;
|
||||
|
|
|
@ -217,7 +217,7 @@ namespace render {
|
|||
}
|
||||
}
|
||||
|
||||
bool RenderableZoneEntityItem::addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
||||
bool RenderableZoneEntityItem::addToScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) {
|
||||
_myMetaItem = scene->allocateID();
|
||||
|
||||
|
@ -232,7 +232,7 @@ bool RenderableZoneEntityItem::addToScene(EntityItemPointer self, std::shared_pt
|
|||
return true;
|
||||
}
|
||||
|
||||
void RenderableZoneEntityItem::removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
||||
void RenderableZoneEntityItem::removeFromScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) {
|
||||
transaction.removeItem(_myMetaItem);
|
||||
render::Item::clearID(_myMetaItem);
|
||||
|
|
|
@ -38,8 +38,8 @@ public:
|
|||
virtual void render(RenderArgs* args) override;
|
||||
virtual bool contains(const glm::vec3& point) const override;
|
||||
|
||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene, render::Transaction& transaction) override;
|
||||
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene, render::Transaction& transaction) override;
|
||||
|
||||
render::ItemID getRenderItemID() const { return _myMetaItem; }
|
||||
|
||||
|
|
|
@ -151,9 +151,9 @@ public:
|
|||
bool& somethingChanged)
|
||||
{ somethingChanged = false; return 0; }
|
||||
|
||||
virtual bool addToScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
||||
virtual bool addToScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) { return false; } // by default entity items don't add to scene
|
||||
virtual void removeFromScene(EntityItemPointer self, std::shared_ptr<render::Scene> scene,
|
||||
virtual void removeFromScene(EntityItemPointer self, const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) { } // by default entity items don't add to scene
|
||||
virtual void render(RenderArgs* args) { } // by default entity items don't know how to render
|
||||
|
||||
|
|
|
@ -429,7 +429,7 @@ void ModelEntityItem::setJointTranslations(const QVector<glm::vec3>& translation
|
|||
for (int index = 0; index < translations.size(); index++) {
|
||||
if (_localJointTranslationsSet[index]) {
|
||||
_localJointTranslations[index] = translations[index];
|
||||
_localJointTranslationsSet[index] = true;
|
||||
_localJointTranslationsDirty[index] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -744,6 +744,10 @@ void GLBackend::recycle() const {
|
|||
glDeleteQueries((GLsizei)ids.size(), ids.data());
|
||||
}
|
||||
}
|
||||
|
||||
GLVariableAllocationSupport::manageMemory();
|
||||
GLVariableAllocationSupport::_frameTexturesCreated = 0;
|
||||
|
||||
}
|
||||
|
||||
void GLBackend::setCameraCorrection(const Mat4& correction) {
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
#include "GLTexture.h"
|
||||
|
||||
#include <QtCore/QThread>
|
||||
#include <NumericalConstants.h>
|
||||
|
||||
#include "GLBackend.h"
|
||||
|
||||
using namespace gpu;
|
||||
|
@ -111,6 +114,20 @@ GLTexture::~GLTexture() {
|
|||
}
|
||||
}
|
||||
|
||||
void GLTexture::copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const {
|
||||
if (!_gpuObject.isStoredMipFaceAvailable(sourceMip)) {
|
||||
return;
|
||||
}
|
||||
auto size = _gpuObject.evalMipDimensions(sourceMip);
|
||||
auto mipData = _gpuObject.accessStoredMipFace(sourceMip, face);
|
||||
if (mipData) {
|
||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
||||
copyMipFaceLinesFromTexture(targetMip, face, size, 0, texelFormat.format, texelFormat.type, mipData->readData());
|
||||
} else {
|
||||
qCDebug(gpugllogging) << "Missing mipData level=" << sourceMip << " face=" << (int)face << " for texture " << _gpuObject.source().c_str();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GLExternalTexture::GLExternalTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, GLuint id)
|
||||
: Parent(backend, texture, id) { }
|
||||
|
@ -127,3 +144,420 @@ GLExternalTexture::~GLExternalTexture() {
|
|||
const_cast<GLuint&>(_id) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Variable sized textures
|
||||
using MemoryPressureState = GLVariableAllocationSupport::MemoryPressureState;
|
||||
using WorkQueue = GLVariableAllocationSupport::WorkQueue;
|
||||
|
||||
std::list<TextureWeakPointer> GLVariableAllocationSupport::_memoryManagedTextures;
|
||||
MemoryPressureState GLVariableAllocationSupport::_memoryPressureState { MemoryPressureState::Idle };
|
||||
std::atomic<bool> GLVariableAllocationSupport::_memoryPressureStateStale { false };
|
||||
const uvec3 GLVariableAllocationSupport::INITIAL_MIP_TRANSFER_DIMENSIONS { 64, 64, 1 };
|
||||
WorkQueue GLVariableAllocationSupport::_transferQueue;
|
||||
WorkQueue GLVariableAllocationSupport::_promoteQueue;
|
||||
WorkQueue GLVariableAllocationSupport::_demoteQueue;
|
||||
TexturePointer GLVariableAllocationSupport::_currentTransferTexture;
|
||||
size_t GLVariableAllocationSupport::_frameTexturesCreated { 0 };
|
||||
|
||||
#define OVERSUBSCRIBED_PRESSURE_VALUE 0.95f
|
||||
#define UNDERSUBSCRIBED_PRESSURE_VALUE 0.85f
|
||||
#define DEFAULT_ALLOWED_TEXTURE_MEMORY_MB ((size_t)1024)
|
||||
|
||||
static const size_t DEFAULT_ALLOWED_TEXTURE_MEMORY = MB_TO_BYTES(DEFAULT_ALLOWED_TEXTURE_MEMORY_MB);
|
||||
|
||||
using TransferJob = GLVariableAllocationSupport::TransferJob;
|
||||
|
||||
const uvec3 GLVariableAllocationSupport::MAX_TRANSFER_DIMENSIONS { 1024, 1024, 1 };
|
||||
const size_t GLVariableAllocationSupport::MAX_TRANSFER_SIZE = GLVariableAllocationSupport::MAX_TRANSFER_DIMENSIONS.x * GLVariableAllocationSupport::MAX_TRANSFER_DIMENSIONS.y * 4;
|
||||
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
std::shared_ptr<std::thread> TransferJob::_bufferThread { nullptr };
|
||||
std::atomic<bool> TransferJob::_shutdownBufferingThread { false };
|
||||
Mutex TransferJob::_mutex;
|
||||
TransferJob::VoidLambdaQueue TransferJob::_bufferLambdaQueue;
|
||||
|
||||
void TransferJob::startTransferLoop() {
|
||||
if (_bufferThread) {
|
||||
return;
|
||||
}
|
||||
_shutdownBufferingThread = false;
|
||||
_bufferThread = std::make_shared<std::thread>([] {
|
||||
TransferJob::bufferLoop();
|
||||
});
|
||||
}
|
||||
|
||||
void TransferJob::stopTransferLoop() {
|
||||
if (!_bufferThread) {
|
||||
return;
|
||||
}
|
||||
_shutdownBufferingThread = true;
|
||||
_bufferThread->join();
|
||||
_bufferThread.reset();
|
||||
_shutdownBufferingThread = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
TransferJob::TransferJob(const GLTexture& parent, uint16_t sourceMip, uint16_t targetMip, uint8_t face, uint32_t lines, uint32_t lineOffset)
|
||||
: _parent(parent) {
|
||||
|
||||
auto transferDimensions = _parent._gpuObject.evalMipDimensions(sourceMip);
|
||||
GLenum format;
|
||||
GLenum type;
|
||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_parent._gpuObject.getTexelFormat(), _parent._gpuObject.getStoredMipFormat());
|
||||
format = texelFormat.format;
|
||||
type = texelFormat.type;
|
||||
auto mipSize = _parent._gpuObject.getStoredMipFaceSize(sourceMip, face);
|
||||
|
||||
|
||||
if (0 == lines) {
|
||||
_transferSize = mipSize;
|
||||
_bufferingLambda = [=] {
|
||||
auto mipData = _parent._gpuObject.accessStoredMipFace(sourceMip, face);
|
||||
_buffer.resize(_transferSize);
|
||||
memcpy(&_buffer[0], mipData->readData(), _transferSize);
|
||||
_bufferingCompleted = true;
|
||||
};
|
||||
|
||||
} else {
|
||||
transferDimensions.y = lines;
|
||||
auto dimensions = _parent._gpuObject.evalMipDimensions(sourceMip);
|
||||
auto bytesPerLine = (uint32_t)mipSize / dimensions.y;
|
||||
auto sourceOffset = bytesPerLine * lineOffset;
|
||||
_transferSize = bytesPerLine * lines;
|
||||
_bufferingLambda = [=] {
|
||||
auto mipData = _parent._gpuObject.accessStoredMipFace(sourceMip, face);
|
||||
_buffer.resize(_transferSize);
|
||||
memcpy(&_buffer[0], mipData->readData() + sourceOffset, _transferSize);
|
||||
_bufferingCompleted = true;
|
||||
};
|
||||
}
|
||||
|
||||
Backend::updateTextureTransferPendingSize(0, _transferSize);
|
||||
|
||||
_transferLambda = [=] {
|
||||
_parent.copyMipFaceLinesFromTexture(targetMip, face, transferDimensions, lineOffset, format, type, _buffer.data());
|
||||
std::vector<uint8_t> emptyVector;
|
||||
_buffer.swap(emptyVector);
|
||||
};
|
||||
}
|
||||
|
||||
TransferJob::TransferJob(const GLTexture& parent, std::function<void()> transferLambda)
|
||||
: _parent(parent), _bufferingCompleted(true), _transferLambda(transferLambda) {
|
||||
}
|
||||
|
||||
TransferJob::~TransferJob() {
|
||||
Backend::updateTextureTransferPendingSize(_transferSize, 0);
|
||||
}
|
||||
|
||||
|
||||
bool TransferJob::tryTransfer() {
|
||||
// Disable threaded texture transfer for now
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
// Are we ready to transfer
|
||||
if (_bufferingCompleted) {
|
||||
_transferLambda();
|
||||
return true;
|
||||
}
|
||||
|
||||
startBuffering();
|
||||
return false;
|
||||
#else
|
||||
if (!_bufferingCompleted) {
|
||||
_bufferingLambda();
|
||||
_bufferingCompleted = true;
|
||||
}
|
||||
_transferLambda();
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
|
||||
void TransferJob::startBuffering() {
|
||||
if (_bufferingStarted) {
|
||||
return;
|
||||
}
|
||||
_bufferingStarted = true;
|
||||
{
|
||||
Lock lock(_mutex);
|
||||
_bufferLambdaQueue.push(_bufferingLambda);
|
||||
}
|
||||
}
|
||||
|
||||
void TransferJob::bufferLoop() {
|
||||
while (!_shutdownBufferingThread) {
|
||||
VoidLambdaQueue workingQueue;
|
||||
{
|
||||
Lock lock(_mutex);
|
||||
_bufferLambdaQueue.swap(workingQueue);
|
||||
}
|
||||
|
||||
if (workingQueue.empty()) {
|
||||
QThread::msleep(5);
|
||||
continue;
|
||||
}
|
||||
|
||||
while (!workingQueue.empty()) {
|
||||
workingQueue.front()();
|
||||
workingQueue.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GLVariableAllocationSupport::GLVariableAllocationSupport() {
|
||||
_memoryPressureStateStale = true;
|
||||
}
|
||||
|
||||
GLVariableAllocationSupport::~GLVariableAllocationSupport() {
|
||||
_memoryPressureStateStale = true;
|
||||
}
|
||||
|
||||
void GLVariableAllocationSupport::addMemoryManagedTexture(const TexturePointer& texturePointer) {
|
||||
_memoryManagedTextures.push_back(texturePointer);
|
||||
addToWorkQueue(texturePointer);
|
||||
}
|
||||
|
||||
void GLVariableAllocationSupport::addToWorkQueue(const TexturePointer& texturePointer) {
|
||||
GLTexture* gltexture = Backend::getGPUObject<GLTexture>(*texturePointer);
|
||||
GLVariableAllocationSupport* vargltexture = dynamic_cast<GLVariableAllocationSupport*>(gltexture);
|
||||
switch (_memoryPressureState) {
|
||||
case MemoryPressureState::Oversubscribed:
|
||||
if (vargltexture->canDemote()) {
|
||||
// Demote largest first
|
||||
_demoteQueue.push({ texturePointer, (float)gltexture->size() });
|
||||
}
|
||||
break;
|
||||
|
||||
case MemoryPressureState::Undersubscribed:
|
||||
if (vargltexture->canPromote()) {
|
||||
// Promote smallest first
|
||||
_promoteQueue.push({ texturePointer, 1.0f / (float)gltexture->size() });
|
||||
}
|
||||
break;
|
||||
|
||||
case MemoryPressureState::Transfer:
|
||||
if (vargltexture->hasPendingTransfers()) {
|
||||
// Transfer priority given to smaller mips first
|
||||
_transferQueue.push({ texturePointer, 1.0f / (float)gltexture->_gpuObject.evalMipSize(vargltexture->_populatedMip) });
|
||||
}
|
||||
break;
|
||||
|
||||
case MemoryPressureState::Idle:
|
||||
break;
|
||||
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
WorkQueue& GLVariableAllocationSupport::getActiveWorkQueue() {
|
||||
static WorkQueue empty;
|
||||
switch (_memoryPressureState) {
|
||||
case MemoryPressureState::Oversubscribed:
|
||||
return _demoteQueue;
|
||||
|
||||
case MemoryPressureState::Undersubscribed:
|
||||
return _promoteQueue;
|
||||
|
||||
case MemoryPressureState::Transfer:
|
||||
return _transferQueue;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_UNREACHABLE();
|
||||
return empty;
|
||||
}
|
||||
|
||||
// FIXME hack for stats display
|
||||
QString getTextureMemoryPressureModeString() {
|
||||
switch (GLVariableAllocationSupport::_memoryPressureState) {
|
||||
case MemoryPressureState::Oversubscribed:
|
||||
return "Oversubscribed";
|
||||
|
||||
case MemoryPressureState::Undersubscribed:
|
||||
return "Undersubscribed";
|
||||
|
||||
case MemoryPressureState::Transfer:
|
||||
return "Transfer";
|
||||
|
||||
case MemoryPressureState::Idle:
|
||||
return "Idle";
|
||||
}
|
||||
Q_UNREACHABLE();
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
void GLVariableAllocationSupport::updateMemoryPressure() {
|
||||
static size_t lastAllowedMemoryAllocation = gpu::Texture::getAllowedGPUMemoryUsage();
|
||||
|
||||
size_t allowedMemoryAllocation = gpu::Texture::getAllowedGPUMemoryUsage();
|
||||
if (0 == allowedMemoryAllocation) {
|
||||
allowedMemoryAllocation = DEFAULT_ALLOWED_TEXTURE_MEMORY;
|
||||
}
|
||||
|
||||
// If the user explicitly changed the allowed memory usage, we need to mark ourselves stale
|
||||
// so that we react
|
||||
if (allowedMemoryAllocation != lastAllowedMemoryAllocation) {
|
||||
_memoryPressureStateStale = true;
|
||||
lastAllowedMemoryAllocation = allowedMemoryAllocation;
|
||||
}
|
||||
|
||||
if (!_memoryPressureStateStale.exchange(false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
|
||||
// Clear any defunct textures (weak pointers that no longer have a valid texture)
|
||||
_memoryManagedTextures.remove_if([&](const TextureWeakPointer& weakPointer) {
|
||||
return weakPointer.expired();
|
||||
});
|
||||
|
||||
// Convert weak pointers to strong. This new list may still contain nulls if a texture was
|
||||
// deleted on another thread between the previous line and this one
|
||||
std::vector<TexturePointer> strongTextures; {
|
||||
strongTextures.reserve(_memoryManagedTextures.size());
|
||||
std::transform(
|
||||
_memoryManagedTextures.begin(), _memoryManagedTextures.end(),
|
||||
std::back_inserter(strongTextures),
|
||||
[](const TextureWeakPointer& p) { return p.lock(); });
|
||||
}
|
||||
|
||||
size_t totalVariableMemoryAllocation = 0;
|
||||
size_t idealMemoryAllocation = 0;
|
||||
bool canDemote = false;
|
||||
bool canPromote = false;
|
||||
bool hasTransfers = false;
|
||||
for (const auto& texture : strongTextures) {
|
||||
// Race conditions can still leave nulls in the list, so we need to check
|
||||
if (!texture) {
|
||||
continue;
|
||||
}
|
||||
GLTexture* gltexture = Backend::getGPUObject<GLTexture>(*texture);
|
||||
GLVariableAllocationSupport* vartexture = dynamic_cast<GLVariableAllocationSupport*>(gltexture);
|
||||
// Track how much the texture thinks it should be using
|
||||
idealMemoryAllocation += texture->evalTotalSize();
|
||||
// Track how much we're actually using
|
||||
totalVariableMemoryAllocation += gltexture->size();
|
||||
canDemote |= vartexture->canDemote();
|
||||
canPromote |= vartexture->canPromote();
|
||||
hasTransfers |= vartexture->hasPendingTransfers();
|
||||
}
|
||||
|
||||
size_t unallocated = idealMemoryAllocation - totalVariableMemoryAllocation;
|
||||
float pressure = (float)totalVariableMemoryAllocation / (float)allowedMemoryAllocation;
|
||||
|
||||
auto newState = MemoryPressureState::Idle;
|
||||
if (pressure > OVERSUBSCRIBED_PRESSURE_VALUE && canDemote) {
|
||||
newState = MemoryPressureState::Oversubscribed;
|
||||
} else if (pressure < UNDERSUBSCRIBED_PRESSURE_VALUE && unallocated != 0 && canPromote) {
|
||||
newState = MemoryPressureState::Undersubscribed;
|
||||
} else if (hasTransfers) {
|
||||
newState = MemoryPressureState::Transfer;
|
||||
}
|
||||
|
||||
if (newState != _memoryPressureState) {
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
if (MemoryPressureState::Transfer == _memoryPressureState) {
|
||||
TransferJob::stopTransferLoop();
|
||||
}
|
||||
_memoryPressureState = newState;
|
||||
if (MemoryPressureState::Transfer == _memoryPressureState) {
|
||||
TransferJob::startTransferLoop();
|
||||
}
|
||||
#else
|
||||
_memoryPressureState = newState;
|
||||
#endif
|
||||
// Clear the existing queue
|
||||
_transferQueue = WorkQueue();
|
||||
_promoteQueue = WorkQueue();
|
||||
_demoteQueue = WorkQueue();
|
||||
|
||||
// Populate the existing textures into the queue
|
||||
for (const auto& texture : strongTextures) {
|
||||
// Race conditions can still leave nulls in the list, so we need to check
|
||||
if (!texture) {
|
||||
continue;
|
||||
}
|
||||
addToWorkQueue(texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GLVariableAllocationSupport::processWorkQueues() {
|
||||
if (MemoryPressureState::Idle == _memoryPressureState) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& workQueue = getActiveWorkQueue();
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
while (!workQueue.empty()) {
|
||||
auto workTarget = workQueue.top();
|
||||
workQueue.pop();
|
||||
auto texture = workTarget.first.lock();
|
||||
if (!texture) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Grab the first item off the demote queue
|
||||
GLTexture* gltexture = Backend::getGPUObject<GLTexture>(*texture);
|
||||
GLVariableAllocationSupport* vartexture = dynamic_cast<GLVariableAllocationSupport*>(gltexture);
|
||||
if (MemoryPressureState::Oversubscribed == _memoryPressureState) {
|
||||
if (!vartexture->canDemote()) {
|
||||
continue;
|
||||
}
|
||||
vartexture->demote();
|
||||
_memoryPressureStateStale = true;
|
||||
} else if (MemoryPressureState::Undersubscribed == _memoryPressureState) {
|
||||
if (!vartexture->canPromote()) {
|
||||
continue;
|
||||
}
|
||||
vartexture->promote();
|
||||
_memoryPressureStateStale = true;
|
||||
} else if (MemoryPressureState::Transfer == _memoryPressureState) {
|
||||
if (!vartexture->hasPendingTransfers()) {
|
||||
continue;
|
||||
}
|
||||
vartexture->executeNextTransfer(texture);
|
||||
} else {
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
// Reinject into the queue if more work to be done
|
||||
addToWorkQueue(texture);
|
||||
break;
|
||||
}
|
||||
|
||||
if (workQueue.empty()) {
|
||||
_memoryPressureStateStale = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GLVariableAllocationSupport::manageMemory() {
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
updateMemoryPressure();
|
||||
processWorkQueues();
|
||||
}
|
||||
|
||||
|
||||
void GLVariableAllocationSupport::executeNextTransfer(const TexturePointer& currentTexture) {
|
||||
if (_populatedMip <= _allocatedMip) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pendingTransfers.empty()) {
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
||||
if (!_pendingTransfers.empty()) {
|
||||
// Keeping hold of a strong pointer during the transfer ensures that the transfer thread cannot try to access a destroyed texture
|
||||
_currentTransferTexture = currentTexture;
|
||||
if (_pendingTransfers.front()->tryTransfer()) {
|
||||
_pendingTransfers.pop();
|
||||
_currentTransferTexture.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
#include "GLShared.h"
|
||||
#include "GLBackend.h"
|
||||
#include "GLTexelFormat.h"
|
||||
#include <thread>
|
||||
|
||||
#define THREADED_TEXTURE_BUFFERING 1
|
||||
|
||||
namespace gpu { namespace gl {
|
||||
|
||||
|
@ -19,9 +22,124 @@ struct GLFilterMode {
|
|||
GLint magFilter;
|
||||
};
|
||||
|
||||
class GLVariableAllocationSupport {
|
||||
friend class GLBackend;
|
||||
|
||||
public:
|
||||
GLVariableAllocationSupport();
|
||||
virtual ~GLVariableAllocationSupport();
|
||||
|
||||
enum class MemoryPressureState {
|
||||
Idle,
|
||||
Transfer,
|
||||
Oversubscribed,
|
||||
Undersubscribed,
|
||||
};
|
||||
|
||||
using QueuePair = std::pair<TextureWeakPointer, float>;
|
||||
struct QueuePairLess {
|
||||
bool operator()(const QueuePair& a, const QueuePair& b) {
|
||||
return a.second < b.second;
|
||||
}
|
||||
};
|
||||
using WorkQueue = std::priority_queue<QueuePair, std::vector<QueuePair>, QueuePairLess>;
|
||||
|
||||
class TransferJob {
|
||||
using VoidLambda = std::function<void()>;
|
||||
using VoidLambdaQueue = std::queue<VoidLambda>;
|
||||
using ThreadPointer = std::shared_ptr<std::thread>;
|
||||
const GLTexture& _parent;
|
||||
// Holds the contents to transfer to the GPU in CPU memory
|
||||
std::vector<uint8_t> _buffer;
|
||||
// Indicates if a transfer from backing storage to interal storage has started
|
||||
bool _bufferingStarted { false };
|
||||
bool _bufferingCompleted { false };
|
||||
VoidLambda _transferLambda;
|
||||
VoidLambda _bufferingLambda;
|
||||
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
static Mutex _mutex;
|
||||
static VoidLambdaQueue _bufferLambdaQueue;
|
||||
static ThreadPointer _bufferThread;
|
||||
static std::atomic<bool> _shutdownBufferingThread;
|
||||
static void bufferLoop();
|
||||
#endif
|
||||
|
||||
public:
|
||||
TransferJob(const TransferJob& other) = delete;
|
||||
TransferJob(const GLTexture& parent, std::function<void()> transferLambda);
|
||||
TransferJob(const GLTexture& parent, uint16_t sourceMip, uint16_t targetMip, uint8_t face, uint32_t lines = 0, uint32_t lineOffset = 0);
|
||||
~TransferJob();
|
||||
bool tryTransfer();
|
||||
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
static void startTransferLoop();
|
||||
static void stopTransferLoop();
|
||||
#endif
|
||||
|
||||
private:
|
||||
size_t _transferSize { 0 };
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
void startBuffering();
|
||||
#endif
|
||||
void transfer();
|
||||
};
|
||||
|
||||
using TransferQueue = std::queue<std::unique_ptr<TransferJob>>;
|
||||
static MemoryPressureState _memoryPressureState;
|
||||
|
||||
public:
|
||||
static void addMemoryManagedTexture(const TexturePointer& texturePointer);
|
||||
|
||||
protected:
|
||||
static size_t _frameTexturesCreated;
|
||||
static std::atomic<bool> _memoryPressureStateStale;
|
||||
static std::list<TextureWeakPointer> _memoryManagedTextures;
|
||||
static WorkQueue _transferQueue;
|
||||
static WorkQueue _promoteQueue;
|
||||
static WorkQueue _demoteQueue;
|
||||
static TexturePointer _currentTransferTexture;
|
||||
static const uvec3 INITIAL_MIP_TRANSFER_DIMENSIONS;
|
||||
static const uvec3 MAX_TRANSFER_DIMENSIONS;
|
||||
static const size_t MAX_TRANSFER_SIZE;
|
||||
|
||||
|
||||
static void updateMemoryPressure();
|
||||
static void processWorkQueues();
|
||||
static void addToWorkQueue(const TexturePointer& texture);
|
||||
static WorkQueue& getActiveWorkQueue();
|
||||
|
||||
static void manageMemory();
|
||||
|
||||
//bool canPromoteNoAllocate() const { return _allocatedMip < _populatedMip; }
|
||||
bool canPromote() const { return _allocatedMip > 0; }
|
||||
bool canDemote() const { return _allocatedMip < _maxAllocatedMip; }
|
||||
bool hasPendingTransfers() const { return _populatedMip > _allocatedMip; }
|
||||
void executeNextTransfer(const TexturePointer& currentTexture);
|
||||
virtual void populateTransferQueue() = 0;
|
||||
virtual void promote() = 0;
|
||||
virtual void demote() = 0;
|
||||
|
||||
// The allocated mip level, relative to the number of mips in the gpu::Texture object
|
||||
// The relationship between a given glMip to the original gpu::Texture mip is always
|
||||
// glMip + _allocatedMip
|
||||
uint16 _allocatedMip { 0 };
|
||||
// The populated mip level, relative to the number of mips in the gpu::Texture object
|
||||
// This must always be >= the allocated mip
|
||||
uint16 _populatedMip { 0 };
|
||||
// The highest (lowest resolution) mip that we will support, relative to the number
|
||||
// of mips in the gpu::Texture object
|
||||
uint16 _maxAllocatedMip { 0 };
|
||||
// Contains a series of lambdas that when executed will transfer data to the GPU, modify
|
||||
// the _populatedMip and update the sampler in order to fully populate the allocated texture
|
||||
// until _populatedMip == _allocatedMip
|
||||
TransferQueue _pendingTransfers;
|
||||
};
|
||||
|
||||
class GLTexture : public GLObject<Texture> {
|
||||
using Parent = GLObject<Texture>;
|
||||
friend class GLBackend;
|
||||
friend class GLVariableAllocationSupport;
|
||||
public:
|
||||
static const uint16_t INVALID_MIP { (uint16_t)-1 };
|
||||
static const uint8_t INVALID_FACE { (uint8_t)-1 };
|
||||
|
@ -45,6 +163,8 @@ public:
|
|||
protected:
|
||||
virtual Size size() const = 0;
|
||||
virtual void generateMips() const = 0;
|
||||
virtual void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum format, GLenum type, const void* sourcePointer) const = 0;
|
||||
virtual void copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const final;
|
||||
|
||||
GLTexture(const std::weak_ptr<gl::GLBackend>& backend, const Texture& texture, GLuint id);
|
||||
};
|
||||
|
@ -57,6 +177,8 @@ public:
|
|||
protected:
|
||||
GLExternalTexture(const std::weak_ptr<gl::GLBackend>& backend, const Texture& texture, GLuint id);
|
||||
void generateMips() const override {}
|
||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum format, GLenum type, const void* sourcePointer) const override {}
|
||||
|
||||
Size size() const override { return 0; }
|
||||
};
|
||||
|
||||
|
|
|
@ -45,8 +45,7 @@ public:
|
|||
protected:
|
||||
GL41Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
void generateMips() const override;
|
||||
void copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const;
|
||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum format, GLenum type, const void* sourcePointer) const;
|
||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum format, GLenum type, const void* sourcePointer) const override;
|
||||
virtual void syncSampler() const;
|
||||
|
||||
void withPreservedTexture(std::function<void()> f) const;
|
||||
|
@ -86,8 +85,29 @@ public:
|
|||
GL41StrictResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
};
|
||||
|
||||
class GL41ResourceTexture : public GL41FixedAllocationTexture {
|
||||
using Parent = GL41FixedAllocationTexture;
|
||||
class GL41VariableAllocationTexture : public GL41Texture, public GLVariableAllocationSupport {
|
||||
using Parent = GL41Texture;
|
||||
friend class GL41Backend;
|
||||
using PromoteLambda = std::function<void()>;
|
||||
|
||||
|
||||
protected:
|
||||
GL41VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
~GL41VariableAllocationTexture();
|
||||
|
||||
void allocateStorage(uint16 allocatedMip);
|
||||
void syncSampler() const override;
|
||||
void promote() override;
|
||||
void demote() override;
|
||||
void populateTransferQueue() override;
|
||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum format, GLenum type, const void* sourcePointer) const override;
|
||||
|
||||
Size size() const override { return _size; }
|
||||
Size _size { 0 };
|
||||
};
|
||||
|
||||
class GL41ResourceTexture : public GL41VariableAllocationTexture {
|
||||
using Parent = GL41VariableAllocationTexture;
|
||||
friend class GL41Backend;
|
||||
protected:
|
||||
GL41ResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
|
|
|
@ -46,11 +46,11 @@ GLTexture* GL41Backend::syncGPUObject(const TexturePointer& texturePointer) {
|
|||
object = new GL41StrictResourceTexture(shared_from_this(), texture);
|
||||
break;
|
||||
|
||||
case TextureUsageType::RESOURCE: {
|
||||
case TextureUsageType::RESOURCE:
|
||||
qCDebug(gpugllogging) << "variable / Strict texture " << texture.source().c_str();
|
||||
object = new GL41ResourceTexture(shared_from_this(), texture);
|
||||
GLVariableAllocationSupport::addMemoryManagedTexture(texturePointer);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
|
@ -69,7 +69,9 @@ GL41Texture::GL41Texture(const std::weak_ptr<GLBackend>& backend, const Texture&
|
|||
|
||||
GLuint GL41Texture::allocate(const Texture& texture) {
|
||||
GLuint result;
|
||||
glGenTextures(1, &result);
|
||||
// FIXME technically GL 4.2, but OSX includes the ARB_texture_storage extension
|
||||
glCreateTextures(getGLTextureType(texture), 1, &result);
|
||||
//glGenTextures(1, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -105,20 +107,6 @@ void GL41Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const
|
|||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void GL41Texture::copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const {
|
||||
if (!_gpuObject.isStoredMipFaceAvailable(sourceMip)) {
|
||||
return;
|
||||
}
|
||||
auto size = _gpuObject.evalMipDimensions(sourceMip);
|
||||
auto mipData = _gpuObject.accessStoredMipFace(sourceMip, face);
|
||||
if (mipData) {
|
||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
||||
copyMipFaceLinesFromTexture(targetMip, face, size, 0, texelFormat.format, texelFormat.type, mipData->readData());
|
||||
} else {
|
||||
qCDebug(gpugllogging) << "Missing mipData level=" << sourceMip << " face=" << (int)face << " for texture " << _gpuObject.source().c_str();
|
||||
}
|
||||
}
|
||||
|
||||
void GL41Texture::syncSampler() const {
|
||||
const Sampler& sampler = _gpuObject.getSampler();
|
||||
|
||||
|
@ -216,29 +204,217 @@ GL41StrictResourceTexture::GL41StrictResourceTexture(const std::weak_ptr<GLBacke
|
|||
}
|
||||
}
|
||||
|
||||
using GL41VariableAllocationTexture = GL41Backend::GL41VariableAllocationTexture;
|
||||
|
||||
GL41VariableAllocationTexture::GL41VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL41Texture(backend, texture) {
|
||||
auto mipLevels = texture.getNumMips();
|
||||
_allocatedMip = mipLevels;
|
||||
uvec3 mipDimensions;
|
||||
for (uint16_t mip = 0; mip < mipLevels; ++mip) {
|
||||
if (glm::all(glm::lessThanEqual(texture.evalMipDimensions(mip), INITIAL_MIP_TRANSFER_DIMENSIONS))) {
|
||||
_maxAllocatedMip = _populatedMip = mip;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t allocatedMip = _populatedMip - std::min<uint16_t>(_populatedMip, 2);
|
||||
allocateStorage(allocatedMip);
|
||||
_memoryPressureStateStale = true;
|
||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||
for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) {
|
||||
uint16_t targetMip = sourceMip - _allocatedMip;
|
||||
for (uint8_t face = 0; face < maxFace; ++face) {
|
||||
copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||
}
|
||||
}
|
||||
syncSampler();
|
||||
}
|
||||
|
||||
GL41VariableAllocationTexture::~GL41VariableAllocationTexture() {
|
||||
Backend::updateTextureGPUMemoryUsage(_size, 0);
|
||||
}
|
||||
|
||||
void GL41VariableAllocationTexture::allocateStorage(uint16 allocatedMip) {
|
||||
_allocatedMip = allocatedMip;
|
||||
|
||||
const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat());
|
||||
const auto dimensions = _gpuObject.evalMipDimensions(_allocatedMip);
|
||||
const auto totalMips = _gpuObject.getNumMips();
|
||||
const auto mips = totalMips - _allocatedMip;
|
||||
withPreservedTexture([&] {
|
||||
// FIXME technically GL 4.2, but OSX includes the ARB_texture_storage extension
|
||||
glTexStorage2D(_target, mips, texelFormat.internalFormat, dimensions.x, dimensions.y);
|
||||
});
|
||||
auto mipLevels = _gpuObject.getNumMips();
|
||||
_size = 0;
|
||||
for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) {
|
||||
_size += _gpuObject.evalMipSize(mip);
|
||||
}
|
||||
Backend::updateTextureGPUMemoryUsage(0, _size);
|
||||
}
|
||||
|
||||
|
||||
void GL41VariableAllocationTexture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum format, GLenum type, const void* sourcePointer) const {
|
||||
withPreservedTexture([&] {
|
||||
Parent::copyMipFaceLinesFromTexture(mip, face, size, yOffset, format, type, sourcePointer);
|
||||
});
|
||||
}
|
||||
|
||||
void GL41VariableAllocationTexture::syncSampler() const {
|
||||
withPreservedTexture([&] {
|
||||
Parent::syncSampler();
|
||||
glTexParameteri(_target, GL_TEXTURE_BASE_LEVEL, _populatedMip - _allocatedMip);
|
||||
});
|
||||
}
|
||||
|
||||
void GL41VariableAllocationTexture::promote() {
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
Q_ASSERT(_allocatedMip > 0);
|
||||
GLuint oldId = _id;
|
||||
auto oldSize = _size;
|
||||
// create new texture
|
||||
const_cast<GLuint&>(_id) = allocate(_gpuObject);
|
||||
uint16_t oldAllocatedMip = _allocatedMip;
|
||||
|
||||
// allocate storage for new level
|
||||
allocateStorage(_allocatedMip - std::min<uint16_t>(_allocatedMip, 2));
|
||||
|
||||
withPreservedTexture([&] {
|
||||
GLuint fbo { 0 };
|
||||
glCreateFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
|
||||
|
||||
uint16_t mips = _gpuObject.getNumMips();
|
||||
// copy pre-existing mips
|
||||
for (uint16_t mip = _populatedMip; mip < mips; ++mip) {
|
||||
auto mipDimensions = _gpuObject.evalMipDimensions(mip);
|
||||
uint16_t targetMip = mip - _allocatedMip;
|
||||
uint16_t sourceMip = mip - oldAllocatedMip;
|
||||
for (GLenum target : getFaceTargets(_target)) {
|
||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, oldId, sourceMip);
|
||||
(void)CHECK_GL_ERROR();
|
||||
glCopyTexSubImage2D(target, targetMip, 0, 0, 0, 0, mipDimensions.x, mipDimensions.y);
|
||||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
}
|
||||
|
||||
// destroy the transfer framebuffer
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glDeleteFramebuffers(1, &fbo);
|
||||
|
||||
syncSampler();
|
||||
});
|
||||
|
||||
// destroy the old texture
|
||||
glDeleteTextures(1, &oldId);
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
||||
void GL41VariableAllocationTexture::demote() {
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
Q_ASSERT(_allocatedMip < _maxAllocatedMip);
|
||||
auto oldId = _id;
|
||||
auto oldSize = _size;
|
||||
const_cast<GLuint&>(_id) = allocate(_gpuObject);
|
||||
uint16_t oldAllocatedMip = _allocatedMip;
|
||||
allocateStorage(_allocatedMip + 1);
|
||||
_populatedMip = std::max(_populatedMip, _allocatedMip);
|
||||
|
||||
withPreservedTexture([&] {
|
||||
GLuint fbo { 0 };
|
||||
glCreateFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
|
||||
|
||||
uint16_t mips = _gpuObject.getNumMips();
|
||||
// copy pre-existing mips
|
||||
for (uint16_t mip = _populatedMip; mip < mips; ++mip) {
|
||||
auto mipDimensions = _gpuObject.evalMipDimensions(mip);
|
||||
uint16_t targetMip = mip - _allocatedMip;
|
||||
uint16_t sourceMip = mip - oldAllocatedMip;
|
||||
for (GLenum target : getFaceTargets(_target)) {
|
||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, oldId, sourceMip);
|
||||
(void)CHECK_GL_ERROR();
|
||||
glCopyTexSubImage2D(target, targetMip, 0, 0, 0, 0, mipDimensions.x, mipDimensions.y);
|
||||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
}
|
||||
|
||||
// destroy the transfer framebuffer
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
|
||||
glDeleteFramebuffers(1, &fbo);
|
||||
|
||||
syncSampler();
|
||||
});
|
||||
|
||||
|
||||
// destroy the old texture
|
||||
glDeleteTextures(1, &oldId);
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
||||
|
||||
void GL41VariableAllocationTexture::populateTransferQueue() {
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
if (_populatedMip <= _allocatedMip) {
|
||||
return;
|
||||
}
|
||||
_pendingTransfers = TransferQueue();
|
||||
|
||||
const uint8_t maxFace = GLTexture::getFaceCount(_target);
|
||||
uint16_t sourceMip = _populatedMip;
|
||||
do {
|
||||
--sourceMip;
|
||||
auto targetMip = sourceMip - _allocatedMip;
|
||||
auto mipDimensions = _gpuObject.evalMipDimensions(sourceMip);
|
||||
for (uint8_t face = 0; face < maxFace; ++face) {
|
||||
if (!_gpuObject.isStoredMipFaceAvailable(sourceMip, face)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the mip is less than the max transfer size, then just do it in one transfer
|
||||
if (glm::all(glm::lessThanEqual(mipDimensions, MAX_TRANSFER_DIMENSIONS))) {
|
||||
// Can the mip be transferred in one go
|
||||
_pendingTransfers.emplace(new TransferJob(*this, sourceMip, targetMip, face));
|
||||
continue;
|
||||
}
|
||||
|
||||
// break down the transfers into chunks so that no single transfer is
|
||||
// consuming more than X bandwidth
|
||||
auto mipSize = _gpuObject.getStoredMipFaceSize(sourceMip, face);
|
||||
const auto lines = mipDimensions.y;
|
||||
auto bytesPerLine = mipSize / lines;
|
||||
Q_ASSERT(0 == (mipSize % lines));
|
||||
uint32_t linesPerTransfer = (uint32_t)(MAX_TRANSFER_SIZE / bytesPerLine);
|
||||
uint32_t lineOffset = 0;
|
||||
while (lineOffset < lines) {
|
||||
uint32_t linesToCopy = std::min<uint32_t>(lines - lineOffset, linesPerTransfer);
|
||||
_pendingTransfers.emplace(new TransferJob(*this, sourceMip, targetMip, face, linesToCopy, lineOffset));
|
||||
lineOffset += linesToCopy;
|
||||
}
|
||||
}
|
||||
|
||||
// queue up the sampler and populated mip change for after the transfer has completed
|
||||
_pendingTransfers.emplace(new TransferJob(*this, [=] {
|
||||
_populatedMip = sourceMip;
|
||||
syncSampler();
|
||||
}));
|
||||
} while (sourceMip != _allocatedMip);
|
||||
}
|
||||
|
||||
// resource textures
|
||||
using GL41ResourceTexture = GL41Backend::GL41ResourceTexture;
|
||||
|
||||
GL41ResourceTexture::GL41ResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL41FixedAllocationTexture(backend, texture) {
|
||||
Backend::updateTextureGPUMemoryUsage(0, size());
|
||||
|
||||
withPreservedTexture([&] {
|
||||
|
||||
auto mipLevels = _gpuObject.getNumMips();
|
||||
for (uint16_t sourceMip = 0; sourceMip < mipLevels; sourceMip++) {
|
||||
uint16_t targetMip = sourceMip;
|
||||
size_t maxFace = GLTexture::getFaceCount(_target);
|
||||
for (uint8_t face = 0; face < maxFace; face++) {
|
||||
copyMipFaceFromTexture(sourceMip, targetMip, face);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
GL41ResourceTexture::GL41ResourceTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL41VariableAllocationTexture(backend, texture) {
|
||||
if (texture.isAutogenerateMips()) {
|
||||
generateMips();
|
||||
}
|
||||
}
|
||||
|
||||
GL41ResourceTexture::~GL41ResourceTexture() {
|
||||
Backend::updateTextureGPUMemoryUsage(size(), 0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ using namespace gpu::gl45;
|
|||
|
||||
void GL45Backend::recycle() const {
|
||||
Parent::recycle();
|
||||
GL45VariableAllocationTexture::manageMemory();
|
||||
GL45VariableAllocationTexture::_frameTexturesCreated = 0;
|
||||
}
|
||||
|
||||
void GL45Backend::do_draw(const Batch& batch, size_t paramOffset) {
|
||||
|
|
|
@ -40,8 +40,7 @@ public:
|
|||
protected:
|
||||
GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
void generateMips() const override;
|
||||
void copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const;
|
||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum format, GLenum type, const void* sourcePointer) const;
|
||||
void copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum format, GLenum type, const void* sourcePointer) const override;
|
||||
virtual void syncSampler() const;
|
||||
};
|
||||
|
||||
|
@ -83,116 +82,17 @@ public:
|
|||
// Textures that can be managed at runtime to increase or decrease their memory load
|
||||
//
|
||||
|
||||
class GL45VariableAllocationTexture : public GL45Texture {
|
||||
class GL45VariableAllocationTexture : public GL45Texture, public GLVariableAllocationSupport {
|
||||
using Parent = GL45Texture;
|
||||
friend class GL45Backend;
|
||||
using PromoteLambda = std::function<void()>;
|
||||
|
||||
public:
|
||||
enum class MemoryPressureState {
|
||||
Idle,
|
||||
Transfer,
|
||||
Oversubscribed,
|
||||
Undersubscribed,
|
||||
};
|
||||
|
||||
using QueuePair = std::pair<TextureWeakPointer, float>;
|
||||
struct QueuePairLess {
|
||||
bool operator()(const QueuePair& a, const QueuePair& b) {
|
||||
return a.second < b.second;
|
||||
}
|
||||
};
|
||||
using WorkQueue = std::priority_queue<QueuePair, std::vector<QueuePair>, QueuePairLess>;
|
||||
|
||||
class TransferJob {
|
||||
using VoidLambda = std::function<void()>;
|
||||
using VoidLambdaQueue = std::queue<VoidLambda>;
|
||||
using ThreadPointer = std::shared_ptr<std::thread>;
|
||||
const GL45VariableAllocationTexture& _parent;
|
||||
// Holds the contents to transfer to the GPU in CPU memory
|
||||
std::vector<uint8_t> _buffer;
|
||||
// Indicates if a transfer from backing storage to interal storage has started
|
||||
bool _bufferingStarted { false };
|
||||
bool _bufferingCompleted { false };
|
||||
VoidLambda _transferLambda;
|
||||
VoidLambda _bufferingLambda;
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
static Mutex _mutex;
|
||||
static VoidLambdaQueue _bufferLambdaQueue;
|
||||
static ThreadPointer _bufferThread;
|
||||
static std::atomic<bool> _shutdownBufferingThread;
|
||||
static void bufferLoop();
|
||||
#endif
|
||||
|
||||
public:
|
||||
TransferJob(const TransferJob& other) = delete;
|
||||
TransferJob(const GL45VariableAllocationTexture& parent, std::function<void()> transferLambda);
|
||||
TransferJob(const GL45VariableAllocationTexture& parent, uint16_t sourceMip, uint16_t targetMip, uint8_t face, uint32_t lines = 0, uint32_t lineOffset = 0);
|
||||
~TransferJob();
|
||||
bool tryTransfer();
|
||||
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
static void startTransferLoop();
|
||||
static void stopTransferLoop();
|
||||
#endif
|
||||
|
||||
private:
|
||||
size_t _transferSize { 0 };
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
void startBuffering();
|
||||
#endif
|
||||
void transfer();
|
||||
};
|
||||
|
||||
using TransferQueue = std::queue<std::unique_ptr<TransferJob>>;
|
||||
static MemoryPressureState _memoryPressureState;
|
||||
protected:
|
||||
static size_t _frameTexturesCreated;
|
||||
static std::atomic<bool> _memoryPressureStateStale;
|
||||
static std::list<TextureWeakPointer> _memoryManagedTextures;
|
||||
static WorkQueue _transferQueue;
|
||||
static WorkQueue _promoteQueue;
|
||||
static WorkQueue _demoteQueue;
|
||||
static TexturePointer _currentTransferTexture;
|
||||
static const uvec3 INITIAL_MIP_TRANSFER_DIMENSIONS;
|
||||
|
||||
|
||||
static void updateMemoryPressure();
|
||||
static void processWorkQueues();
|
||||
static void addMemoryManagedTexture(const TexturePointer& texturePointer);
|
||||
static void addToWorkQueue(const TexturePointer& texture);
|
||||
static WorkQueue& getActiveWorkQueue();
|
||||
|
||||
static void manageMemory();
|
||||
|
||||
protected:
|
||||
GL45VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture);
|
||||
~GL45VariableAllocationTexture();
|
||||
//bool canPromoteNoAllocate() const { return _allocatedMip < _populatedMip; }
|
||||
bool canPromote() const { return _allocatedMip > 0; }
|
||||
bool canDemote() const { return _allocatedMip < _maxAllocatedMip; }
|
||||
bool hasPendingTransfers() const { return _populatedMip > _allocatedMip; }
|
||||
void executeNextTransfer(const TexturePointer& currentTexture);
|
||||
Size size() const override { return _size; }
|
||||
virtual void populateTransferQueue() = 0;
|
||||
virtual void promote() = 0;
|
||||
virtual void demote() = 0;
|
||||
|
||||
// The allocated mip level, relative to the number of mips in the gpu::Texture object
|
||||
// The relationship between a given glMip to the original gpu::Texture mip is always
|
||||
// glMip + _allocatedMip
|
||||
uint16 _allocatedMip { 0 };
|
||||
// The populated mip level, relative to the number of mips in the gpu::Texture object
|
||||
// This must always be >= the allocated mip
|
||||
uint16 _populatedMip { 0 };
|
||||
// The highest (lowest resolution) mip that we will support, relative to the number
|
||||
// of mips in the gpu::Texture object
|
||||
uint16 _maxAllocatedMip { 0 };
|
||||
Size _size { 0 };
|
||||
// Contains a series of lambdas that when executed will transfer data to the GPU, modify
|
||||
// the _populatedMip and update the sampler in order to fully populate the allocated texture
|
||||
// until _populatedMip == _allocatedMip
|
||||
TransferQueue _pendingTransfers;
|
||||
};
|
||||
|
||||
class GL45ResourceTexture : public GL45VariableAllocationTexture {
|
||||
|
|
|
@ -67,7 +67,7 @@ GLTexture* GL45Backend::syncGPUObject(const TexturePointer& texturePointer) {
|
|||
#else
|
||||
object = new GL45ResourceTexture(shared_from_this(), texture);
|
||||
#endif
|
||||
GL45VariableAllocationTexture::addMemoryManagedTexture(texturePointer);
|
||||
GLVariableAllocationSupport::addMemoryManagedTexture(texturePointer);
|
||||
} else {
|
||||
auto fallback = texturePointer->getFallbackTexture();
|
||||
if (fallback) {
|
||||
|
@ -135,20 +135,6 @@ void GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const
|
|||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
void GL45Texture::copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, uint8_t face) const {
|
||||
if (!_gpuObject.isStoredMipFaceAvailable(sourceMip)) {
|
||||
return;
|
||||
}
|
||||
auto size = _gpuObject.evalMipDimensions(sourceMip);
|
||||
auto mipData = _gpuObject.accessStoredMipFace(sourceMip, face);
|
||||
if (mipData) {
|
||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat());
|
||||
copyMipFaceLinesFromTexture(targetMip, face, size, 0, texelFormat.format, texelFormat.type, mipData->readData());
|
||||
} else {
|
||||
qCDebug(gpugllogging) << "Missing mipData level=" << sourceMip << " face=" << (int)face << " for texture " << _gpuObject.source().c_str();
|
||||
}
|
||||
}
|
||||
|
||||
void GL45Texture::syncSampler() const {
|
||||
const Sampler& sampler = _gpuObject.getSampler();
|
||||
|
||||
|
|
|
@ -27,416 +27,16 @@ using namespace gpu;
|
|||
using namespace gpu::gl;
|
||||
using namespace gpu::gl45;
|
||||
|
||||
// Variable sized textures
|
||||
using GL45VariableAllocationTexture = GL45Backend::GL45VariableAllocationTexture;
|
||||
using MemoryPressureState = GL45VariableAllocationTexture::MemoryPressureState;
|
||||
using WorkQueue = GL45VariableAllocationTexture::WorkQueue;
|
||||
|
||||
std::list<TextureWeakPointer> GL45VariableAllocationTexture::_memoryManagedTextures;
|
||||
MemoryPressureState GL45VariableAllocationTexture::_memoryPressureState = MemoryPressureState::Idle;
|
||||
std::atomic<bool> GL45VariableAllocationTexture::_memoryPressureStateStale { false };
|
||||
const uvec3 GL45VariableAllocationTexture::INITIAL_MIP_TRANSFER_DIMENSIONS { 64, 64, 1 };
|
||||
WorkQueue GL45VariableAllocationTexture::_transferQueue;
|
||||
WorkQueue GL45VariableAllocationTexture::_promoteQueue;
|
||||
WorkQueue GL45VariableAllocationTexture::_demoteQueue;
|
||||
TexturePointer GL45VariableAllocationTexture::_currentTransferTexture;
|
||||
|
||||
#define OVERSUBSCRIBED_PRESSURE_VALUE 0.95f
|
||||
#define UNDERSUBSCRIBED_PRESSURE_VALUE 0.85f
|
||||
#define DEFAULT_ALLOWED_TEXTURE_MEMORY_MB ((size_t)1024)
|
||||
|
||||
static const size_t DEFAULT_ALLOWED_TEXTURE_MEMORY = MB_TO_BYTES(DEFAULT_ALLOWED_TEXTURE_MEMORY_MB);
|
||||
|
||||
using TransferJob = GL45VariableAllocationTexture::TransferJob;
|
||||
|
||||
static const uvec3 MAX_TRANSFER_DIMENSIONS { 1024, 1024, 1 };
|
||||
static const size_t MAX_TRANSFER_SIZE = MAX_TRANSFER_DIMENSIONS.x * MAX_TRANSFER_DIMENSIONS.y * 4;
|
||||
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
std::shared_ptr<std::thread> TransferJob::_bufferThread { nullptr };
|
||||
std::atomic<bool> TransferJob::_shutdownBufferingThread { false };
|
||||
Mutex TransferJob::_mutex;
|
||||
TransferJob::VoidLambdaQueue TransferJob::_bufferLambdaQueue;
|
||||
|
||||
void TransferJob::startTransferLoop() {
|
||||
if (_bufferThread) {
|
||||
return;
|
||||
}
|
||||
_shutdownBufferingThread = false;
|
||||
_bufferThread = std::make_shared<std::thread>([] {
|
||||
TransferJob::bufferLoop();
|
||||
});
|
||||
}
|
||||
|
||||
void TransferJob::stopTransferLoop() {
|
||||
if (!_bufferThread) {
|
||||
return;
|
||||
}
|
||||
_shutdownBufferingThread = true;
|
||||
_bufferThread->join();
|
||||
_bufferThread.reset();
|
||||
_shutdownBufferingThread = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
TransferJob::TransferJob(const GL45VariableAllocationTexture& parent, uint16_t sourceMip, uint16_t targetMip, uint8_t face, uint32_t lines, uint32_t lineOffset)
|
||||
: _parent(parent) {
|
||||
|
||||
auto transferDimensions = _parent._gpuObject.evalMipDimensions(sourceMip);
|
||||
GLenum format;
|
||||
GLenum type;
|
||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_parent._gpuObject.getTexelFormat(), _parent._gpuObject.getStoredMipFormat());
|
||||
format = texelFormat.format;
|
||||
type = texelFormat.type;
|
||||
auto mipSize = _parent._gpuObject.getStoredMipFaceSize(sourceMip, face);
|
||||
|
||||
|
||||
if (0 == lines) {
|
||||
_transferSize = mipSize;
|
||||
_bufferingLambda = [=] {
|
||||
auto mipData = _parent._gpuObject.accessStoredMipFace(sourceMip, face);
|
||||
_buffer.resize(_transferSize);
|
||||
memcpy(&_buffer[0], mipData->readData(), _transferSize);
|
||||
_bufferingCompleted = true;
|
||||
};
|
||||
|
||||
} else {
|
||||
transferDimensions.y = lines;
|
||||
auto dimensions = _parent._gpuObject.evalMipDimensions(sourceMip);
|
||||
auto bytesPerLine = (uint32_t)mipSize / dimensions.y;
|
||||
auto sourceOffset = bytesPerLine * lineOffset;
|
||||
_transferSize = bytesPerLine * lines;
|
||||
_bufferingLambda = [=] {
|
||||
auto mipData = _parent._gpuObject.accessStoredMipFace(sourceMip, face);
|
||||
_buffer.resize(_transferSize);
|
||||
memcpy(&_buffer[0], mipData->readData() + sourceOffset, _transferSize);
|
||||
_bufferingCompleted = true;
|
||||
};
|
||||
}
|
||||
|
||||
Backend::updateTextureTransferPendingSize(0, _transferSize);
|
||||
|
||||
_transferLambda = [=] {
|
||||
_parent.copyMipFaceLinesFromTexture(targetMip, face, transferDimensions, lineOffset, format, type, _buffer.data());
|
||||
std::vector<uint8_t> emptyVector;
|
||||
_buffer.swap(emptyVector);
|
||||
};
|
||||
}
|
||||
|
||||
TransferJob::TransferJob(const GL45VariableAllocationTexture& parent, std::function<void()> transferLambda)
|
||||
: _parent(parent), _bufferingCompleted(true), _transferLambda(transferLambda) {
|
||||
}
|
||||
|
||||
TransferJob::~TransferJob() {
|
||||
Backend::updateTextureTransferPendingSize(_transferSize, 0);
|
||||
}
|
||||
|
||||
|
||||
bool TransferJob::tryTransfer() {
|
||||
// Disable threaded texture transfer for now
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
// Are we ready to transfer
|
||||
if (_bufferingCompleted) {
|
||||
_transferLambda();
|
||||
return true;
|
||||
}
|
||||
|
||||
startBuffering();
|
||||
return false;
|
||||
#else
|
||||
if (!_bufferingCompleted) {
|
||||
_bufferingLambda();
|
||||
_bufferingCompleted = true;
|
||||
}
|
||||
_transferLambda();
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
|
||||
void TransferJob::startBuffering() {
|
||||
if (_bufferingStarted) {
|
||||
return;
|
||||
}
|
||||
_bufferingStarted = true;
|
||||
{
|
||||
Lock lock(_mutex);
|
||||
_bufferLambdaQueue.push(_bufferingLambda);
|
||||
}
|
||||
}
|
||||
|
||||
void TransferJob::bufferLoop() {
|
||||
while (!_shutdownBufferingThread) {
|
||||
VoidLambdaQueue workingQueue;
|
||||
{
|
||||
Lock lock(_mutex);
|
||||
_bufferLambdaQueue.swap(workingQueue);
|
||||
}
|
||||
|
||||
if (workingQueue.empty()) {
|
||||
QThread::msleep(5);
|
||||
continue;
|
||||
}
|
||||
|
||||
while (!workingQueue.empty()) {
|
||||
workingQueue.front()();
|
||||
workingQueue.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void GL45VariableAllocationTexture::addMemoryManagedTexture(const TexturePointer& texturePointer) {
|
||||
_memoryManagedTextures.push_back(texturePointer);
|
||||
addToWorkQueue(texturePointer);
|
||||
}
|
||||
|
||||
void GL45VariableAllocationTexture::addToWorkQueue(const TexturePointer& texturePointer) {
|
||||
GL45VariableAllocationTexture* object = Backend::getGPUObject<GL45VariableAllocationTexture>(*texturePointer);
|
||||
switch (_memoryPressureState) {
|
||||
case MemoryPressureState::Oversubscribed:
|
||||
if (object->canDemote()) {
|
||||
// Demote largest first
|
||||
_demoteQueue.push({ texturePointer, (float)object->size() });
|
||||
}
|
||||
break;
|
||||
|
||||
case MemoryPressureState::Undersubscribed:
|
||||
if (object->canPromote()) {
|
||||
// Promote smallest first
|
||||
_promoteQueue.push({ texturePointer, 1.0f / (float)object->size() });
|
||||
}
|
||||
break;
|
||||
|
||||
case MemoryPressureState::Transfer:
|
||||
if (object->hasPendingTransfers()) {
|
||||
// Transfer priority given to smaller mips first
|
||||
_transferQueue.push({ texturePointer, 1.0f / (float)object->_gpuObject.evalMipSize(object->_populatedMip) });
|
||||
}
|
||||
break;
|
||||
|
||||
case MemoryPressureState::Idle:
|
||||
break;
|
||||
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
WorkQueue& GL45VariableAllocationTexture::getActiveWorkQueue() {
|
||||
static WorkQueue empty;
|
||||
switch (_memoryPressureState) {
|
||||
case MemoryPressureState::Oversubscribed:
|
||||
return _demoteQueue;
|
||||
|
||||
case MemoryPressureState::Undersubscribed:
|
||||
return _promoteQueue;
|
||||
|
||||
case MemoryPressureState::Transfer:
|
||||
return _transferQueue;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_UNREACHABLE();
|
||||
return empty;
|
||||
}
|
||||
|
||||
// FIXME hack for stats display
|
||||
QString getTextureMemoryPressureModeString() {
|
||||
switch (GL45VariableAllocationTexture::_memoryPressureState) {
|
||||
case MemoryPressureState::Oversubscribed:
|
||||
return "Oversubscribed";
|
||||
|
||||
case MemoryPressureState::Undersubscribed:
|
||||
return "Undersubscribed";
|
||||
|
||||
case MemoryPressureState::Transfer:
|
||||
return "Transfer";
|
||||
|
||||
case MemoryPressureState::Idle:
|
||||
return "Idle";
|
||||
}
|
||||
Q_UNREACHABLE();
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
void GL45VariableAllocationTexture::updateMemoryPressure() {
|
||||
static size_t lastAllowedMemoryAllocation = gpu::Texture::getAllowedGPUMemoryUsage();
|
||||
|
||||
size_t allowedMemoryAllocation = gpu::Texture::getAllowedGPUMemoryUsage();
|
||||
if (0 == allowedMemoryAllocation) {
|
||||
allowedMemoryAllocation = DEFAULT_ALLOWED_TEXTURE_MEMORY;
|
||||
}
|
||||
|
||||
// If the user explicitly changed the allowed memory usage, we need to mark ourselves stale
|
||||
// so that we react
|
||||
if (allowedMemoryAllocation != lastAllowedMemoryAllocation) {
|
||||
_memoryPressureStateStale = true;
|
||||
lastAllowedMemoryAllocation = allowedMemoryAllocation;
|
||||
}
|
||||
|
||||
if (!_memoryPressureStateStale.exchange(false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
|
||||
// Clear any defunct textures (weak pointers that no longer have a valid texture)
|
||||
_memoryManagedTextures.remove_if([&](const TextureWeakPointer& weakPointer) {
|
||||
return weakPointer.expired();
|
||||
});
|
||||
|
||||
// Convert weak pointers to strong. This new list may still contain nulls if a texture was
|
||||
// deleted on another thread between the previous line and this one
|
||||
std::vector<TexturePointer> strongTextures; {
|
||||
strongTextures.reserve(_memoryManagedTextures.size());
|
||||
std::transform(
|
||||
_memoryManagedTextures.begin(), _memoryManagedTextures.end(),
|
||||
std::back_inserter(strongTextures),
|
||||
[](const TextureWeakPointer& p) { return p.lock(); });
|
||||
}
|
||||
|
||||
size_t totalVariableMemoryAllocation = 0;
|
||||
size_t idealMemoryAllocation = 0;
|
||||
bool canDemote = false;
|
||||
bool canPromote = false;
|
||||
bool hasTransfers = false;
|
||||
for (const auto& texture : strongTextures) {
|
||||
// Race conditions can still leave nulls in the list, so we need to check
|
||||
if (!texture) {
|
||||
continue;
|
||||
}
|
||||
GL45VariableAllocationTexture* object = Backend::getGPUObject<GL45VariableAllocationTexture>(*texture);
|
||||
// Track how much the texture thinks it should be using
|
||||
idealMemoryAllocation += texture->evalTotalSize();
|
||||
// Track how much we're actually using
|
||||
totalVariableMemoryAllocation += object->size();
|
||||
canDemote |= object->canDemote();
|
||||
canPromote |= object->canPromote();
|
||||
hasTransfers |= object->hasPendingTransfers();
|
||||
}
|
||||
|
||||
size_t unallocated = idealMemoryAllocation - totalVariableMemoryAllocation;
|
||||
float pressure = (float)totalVariableMemoryAllocation / (float)allowedMemoryAllocation;
|
||||
|
||||
auto newState = MemoryPressureState::Idle;
|
||||
if (pressure > OVERSUBSCRIBED_PRESSURE_VALUE && canDemote) {
|
||||
newState = MemoryPressureState::Oversubscribed;
|
||||
} else if (pressure < UNDERSUBSCRIBED_PRESSURE_VALUE && unallocated != 0 && canPromote) {
|
||||
newState = MemoryPressureState::Undersubscribed;
|
||||
} else if (hasTransfers) {
|
||||
newState = MemoryPressureState::Transfer;
|
||||
}
|
||||
|
||||
if (newState != _memoryPressureState) {
|
||||
#if THREADED_TEXTURE_BUFFERING
|
||||
if (MemoryPressureState::Transfer == _memoryPressureState) {
|
||||
TransferJob::stopTransferLoop();
|
||||
}
|
||||
_memoryPressureState = newState;
|
||||
if (MemoryPressureState::Transfer == _memoryPressureState) {
|
||||
TransferJob::startTransferLoop();
|
||||
}
|
||||
#else
|
||||
_memoryPressureState = newState;
|
||||
#endif
|
||||
// Clear the existing queue
|
||||
_transferQueue = WorkQueue();
|
||||
_promoteQueue = WorkQueue();
|
||||
_demoteQueue = WorkQueue();
|
||||
|
||||
// Populate the existing textures into the queue
|
||||
for (const auto& texture : strongTextures) {
|
||||
addToWorkQueue(texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GL45VariableAllocationTexture::processWorkQueues() {
|
||||
if (MemoryPressureState::Idle == _memoryPressureState) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& workQueue = getActiveWorkQueue();
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
while (!workQueue.empty()) {
|
||||
auto workTarget = workQueue.top();
|
||||
workQueue.pop();
|
||||
auto texture = workTarget.first.lock();
|
||||
if (!texture) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Grab the first item off the demote queue
|
||||
GL45VariableAllocationTexture* object = Backend::getGPUObject<GL45VariableAllocationTexture>(*texture);
|
||||
if (MemoryPressureState::Oversubscribed == _memoryPressureState) {
|
||||
if (!object->canDemote()) {
|
||||
continue;
|
||||
}
|
||||
object->demote();
|
||||
} else if (MemoryPressureState::Undersubscribed == _memoryPressureState) {
|
||||
if (!object->canPromote()) {
|
||||
continue;
|
||||
}
|
||||
object->promote();
|
||||
} else if (MemoryPressureState::Transfer == _memoryPressureState) {
|
||||
if (!object->hasPendingTransfers()) {
|
||||
continue;
|
||||
}
|
||||
object->executeNextTransfer(texture);
|
||||
} else {
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
// Reinject into the queue if more work to be done
|
||||
addToWorkQueue(texture);
|
||||
break;
|
||||
}
|
||||
|
||||
if (workQueue.empty()) {
|
||||
_memoryPressureStateStale = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GL45VariableAllocationTexture::manageMemory() {
|
||||
PROFILE_RANGE(render_gpu_gl, __FUNCTION__);
|
||||
updateMemoryPressure();
|
||||
processWorkQueues();
|
||||
}
|
||||
|
||||
size_t GL45VariableAllocationTexture::_frameTexturesCreated { 0 };
|
||||
|
||||
GL45VariableAllocationTexture::GL45VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL45Texture(backend, texture) {
|
||||
++_frameTexturesCreated;
|
||||
}
|
||||
|
||||
GL45VariableAllocationTexture::~GL45VariableAllocationTexture() {
|
||||
_memoryPressureStateStale = true;
|
||||
Backend::updateTextureGPUMemoryUsage(_size, 0);
|
||||
}
|
||||
|
||||
void GL45VariableAllocationTexture::executeNextTransfer(const TexturePointer& currentTexture) {
|
||||
if (_populatedMip <= _allocatedMip) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pendingTransfers.empty()) {
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
||||
if (!_pendingTransfers.empty()) {
|
||||
// Keeping hold of a strong pointer during the transfer ensures that the transfer thread cannot try to access a destroyed texture
|
||||
_currentTransferTexture = currentTexture;
|
||||
if (_pendingTransfers.front()->tryTransfer()) {
|
||||
_pendingTransfers.pop();
|
||||
_currentTransferTexture.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Managed size resource textures
|
||||
using GL45ResourceTexture = GL45Backend::GL45ResourceTexture;
|
||||
|
||||
|
@ -453,7 +53,6 @@ GL45ResourceTexture::GL45ResourceTexture(const std::weak_ptr<GLBackend>& backend
|
|||
|
||||
uint16_t allocatedMip = _populatedMip - std::min<uint16_t>(_populatedMip, 2);
|
||||
allocateStorage(allocatedMip);
|
||||
_memoryPressureStateStale = true;
|
||||
copyMipsFromTexture();
|
||||
syncSampler();
|
||||
|
||||
|
@ -521,7 +120,6 @@ void GL45ResourceTexture::promote() {
|
|||
glDeleteTextures(1, &oldId);
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
_memoryPressureStateStale = true;
|
||||
syncSampler();
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
@ -554,7 +152,6 @@ void GL45ResourceTexture::demote() {
|
|||
glDeleteTextures(1, &oldId);
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
_memoryPressureStateStale = true;
|
||||
syncSampler();
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ namespace gpu {
|
|||
class Sampler;
|
||||
class Texture;
|
||||
using TexturePointer = std::shared_ptr<Texture>;
|
||||
using TextureWeakPointer = std::weak_ptr<Texture>;
|
||||
using Textures = std::vector<TexturePointer>;
|
||||
class TextureView;
|
||||
using TextureViews = std::vector<TextureView>;
|
||||
|
|
|
@ -231,8 +231,6 @@ void Model::updateRenderItems() {
|
|||
// We need to update them here so we can correctly update the bounding box.
|
||||
self->updateClusterMatrices();
|
||||
|
||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
|
||||
uint32_t deleteGeometryCounter = self->_deleteGeometryCounter;
|
||||
|
||||
render::Transaction transaction;
|
||||
|
@ -266,7 +264,7 @@ void Model::updateRenderItems() {
|
|||
});
|
||||
}
|
||||
|
||||
scene->enqueueTransaction(transaction);
|
||||
AbstractViewStateInterface::instance()->getMain3DScene()->enqueueTransaction(transaction);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -534,7 +532,7 @@ void Model::calculateTriangleSets() {
|
|||
}
|
||||
}
|
||||
|
||||
void Model::setVisibleInScene(bool newValue, std::shared_ptr<render::Scene> scene) {
|
||||
void Model::setVisibleInScene(bool newValue, const render::ScenePointer& scene) {
|
||||
if (_isVisible != newValue) {
|
||||
_isVisible = newValue;
|
||||
|
||||
|
@ -550,7 +548,7 @@ void Model::setVisibleInScene(bool newValue, std::shared_ptr<render::Scene> scen
|
|||
}
|
||||
|
||||
|
||||
void Model::setLayeredInFront(bool layered, std::shared_ptr<render::Scene> scene) {
|
||||
void Model::setLayeredInFront(bool layered, const render::ScenePointer& scene) {
|
||||
if (_isLayeredInFront != layered) {
|
||||
_isLayeredInFront = layered;
|
||||
|
||||
|
@ -565,7 +563,7 @@ void Model::setLayeredInFront(bool layered, std::shared_ptr<render::Scene> scene
|
|||
}
|
||||
}
|
||||
|
||||
bool Model::addToScene(std::shared_ptr<render::Scene> scene,
|
||||
bool Model::addToScene(const render::ScenePointer& scene,
|
||||
render::Transaction& transaction,
|
||||
render::Item::Status::Getters& statusGetters) {
|
||||
bool readyToRender = _collisionGeometry || isLoaded();
|
||||
|
@ -622,7 +620,7 @@ bool Model::addToScene(std::shared_ptr<render::Scene> scene,
|
|||
return somethingAdded;
|
||||
}
|
||||
|
||||
void Model::removeFromScene(std::shared_ptr<render::Scene> scene, render::Transaction& transaction) {
|
||||
void Model::removeFromScene(const render::ScenePointer& scene, render::Transaction& transaction) {
|
||||
foreach (auto item, _modelMeshRenderItemsMap.keys()) {
|
||||
transaction.removeItem(item);
|
||||
}
|
||||
|
@ -795,7 +793,7 @@ void Model::setURL(const QUrl& url) {
|
|||
|
||||
{
|
||||
render::Transaction transaction;
|
||||
render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||
if (scene) {
|
||||
removeFromScene(scene, transaction);
|
||||
scene->enqueueTransaction(transaction);
|
||||
|
@ -1271,7 +1269,7 @@ bool Model::isRenderable() const {
|
|||
return !_meshStates.isEmpty() || (isLoaded() && _renderGeometry->getMeshes().empty());
|
||||
}
|
||||
|
||||
bool Model::initWhenReady(render::ScenePointer scene) {
|
||||
bool Model::initWhenReady(const render::ScenePointer& scene) {
|
||||
// NOTE: this only called by SkeletonModel
|
||||
if (_addedToScene || !isRenderable()) {
|
||||
return false;
|
||||
|
|
|
@ -81,21 +81,21 @@ public:
|
|||
const QUrl& getURL() const { return _url; }
|
||||
|
||||
// new Scene/Engine rendering support
|
||||
void setVisibleInScene(bool newValue, std::shared_ptr<render::Scene> scene);
|
||||
void setLayeredInFront(bool layered, std::shared_ptr<render::Scene> scene);
|
||||
void setVisibleInScene(bool newValue, const render::ScenePointer& scene);
|
||||
void setLayeredInFront(bool layered, const render::ScenePointer& scene);
|
||||
bool needsFixupInScene() const;
|
||||
|
||||
bool needsReload() const { return _needsReload; }
|
||||
bool initWhenReady(render::ScenePointer scene);
|
||||
bool addToScene(std::shared_ptr<render::Scene> scene,
|
||||
bool initWhenReady(const render::ScenePointer& scene);
|
||||
bool addToScene(const render::ScenePointer& scene,
|
||||
render::Transaction& transaction) {
|
||||
auto getters = render::Item::Status::Getters(0);
|
||||
return addToScene(scene, transaction, getters);
|
||||
}
|
||||
bool addToScene(std::shared_ptr<render::Scene> scene,
|
||||
bool addToScene(const render::ScenePointer& scene,
|
||||
render::Transaction& transaction,
|
||||
render::Item::Status::Getters& statusGetters);
|
||||
void removeFromScene(std::shared_ptr<render::Scene> scene, render::Transaction& transaction);
|
||||
void removeFromScene(const render::ScenePointer& scene, render::Transaction& transaction);
|
||||
bool isRenderable() const;
|
||||
|
||||
bool isVisible() const { return _isVisible; }
|
||||
|
|
|
@ -410,40 +410,36 @@ void TabletProxy::loadQMLSource(const QVariant& path) {
|
|||
}
|
||||
|
||||
void TabletProxy::pushOntoStack(const QVariant& path) {
|
||||
if (_qmlTabletRoot) {
|
||||
auto stack = _qmlTabletRoot->findChild<QQuickItem*>("stack");
|
||||
QObject* root = nullptr;
|
||||
if (!_toolbarMode && _qmlTabletRoot) {
|
||||
root = _qmlTabletRoot;
|
||||
} else if (_toolbarMode && _desktopWindow) {
|
||||
root = _desktopWindow->asQuickItem();
|
||||
}
|
||||
|
||||
if (root) {
|
||||
auto stack = root->findChild<QQuickItem*>("stack");
|
||||
if (stack) {
|
||||
QMetaObject::invokeMethod(stack, "pushSource", Q_ARG(const QVariant&, path));
|
||||
} else {
|
||||
loadQMLSource(path);
|
||||
}
|
||||
} else if (_desktopWindow) {
|
||||
auto stack = _desktopWindow->asQuickItem()->findChild<QQuickItem*>("stack");
|
||||
if (stack) {
|
||||
QMetaObject::invokeMethod(stack, "pushSource", Q_ARG(const QVariant&, path));
|
||||
} else {
|
||||
qCDebug(scriptengine) << "tablet cannot push QML because _desktopWindow doesn't have child stack";
|
||||
}
|
||||
} else {
|
||||
qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot or _desktopWindow is null";
|
||||
}
|
||||
}
|
||||
|
||||
void TabletProxy::popFromStack() {
|
||||
if (_qmlTabletRoot) {
|
||||
auto stack = _qmlTabletRoot->findChild<QQuickItem*>("stack");
|
||||
if (stack) {
|
||||
QMetaObject::invokeMethod(stack, "popSource");
|
||||
} else {
|
||||
qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot doesn't have child stack";
|
||||
}
|
||||
} else if (_desktopWindow) {
|
||||
auto stack = _desktopWindow->asQuickItem()->findChild<QQuickItem*>("stack");
|
||||
if (stack) {
|
||||
QMetaObject::invokeMethod(stack, "popSource");
|
||||
} else {
|
||||
qCDebug(scriptengine) << "tablet cannot pop QML because _desktopWindow doesn't have child stack";
|
||||
}
|
||||
QObject* root = nullptr;
|
||||
if (!_toolbarMode && _qmlTabletRoot) {
|
||||
root = _qmlTabletRoot;
|
||||
} else if (_toolbarMode && _desktopWindow) {
|
||||
root = _desktopWindow->asQuickItem();
|
||||
}
|
||||
|
||||
if (root) {
|
||||
auto stack = root->findChild<QQuickItem*>("stack");
|
||||
QMetaObject::invokeMethod(stack, "popSource");
|
||||
} else {
|
||||
qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot or _desktopWindow is null";
|
||||
}
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
|
||||
class AABox;
|
||||
class OctreeRenderer;
|
||||
namespace render {
|
||||
class Scene;
|
||||
using ScenePointer = std::shared_ptr<Scene>;
|
||||
}
|
||||
|
||||
namespace gpu {
|
||||
class Batch;
|
||||
|
@ -126,6 +130,8 @@ public:
|
|||
bool _enableTexturing { true };
|
||||
|
||||
RenderDetails _details;
|
||||
render::ScenePointer _scene; // HACK
|
||||
int8_t _cameraMode { -1 }; // HACK
|
||||
};
|
||||
|
||||
#endif // hifi_RenderArgs_h
|
||||
|
|
|
@ -27,8 +27,8 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
// add lines where the hand ray picking is happening
|
||||
//
|
||||
|
||||
var WANT_DEBUG = true;
|
||||
var WANT_DEBUG_STATE = true;
|
||||
var WANT_DEBUG = false;
|
||||
var WANT_DEBUG_STATE = false;
|
||||
var WANT_DEBUG_SEARCH_NAME = null;
|
||||
|
||||
var FORCE_IGNORE_IK = false;
|
||||
|
@ -1051,8 +1051,6 @@ function MyController(hand) {
|
|||
this.homeButtonTouched = false;
|
||||
this.editTriggered = false;
|
||||
|
||||
this.controllerJointIndex = getControllerJointIndex(this.hand);
|
||||
|
||||
// Until there is some reliable way to keep track of a "stack" of parentIDs, we'll have problems
|
||||
// when more than one avatar does parenting grabs on things. This script tries to work
|
||||
// around this with two associative arrays: previousParentID and previousParentJointIndex. If
|
||||
|
@ -1736,6 +1734,7 @@ function MyController(hand) {
|
|||
|
||||
this.off = function(deltaTime, timestamp) {
|
||||
|
||||
this.controllerJointIndex = getControllerJointIndex(this.hand);
|
||||
this.checkForUnexpectedChildren();
|
||||
|
||||
if (this.editTriggered) {
|
||||
|
|
|
@ -84,12 +84,14 @@ window.onload = function () {
|
|||
if (messageOptions.containsGif) {
|
||||
if (messageOptions.processingGif) {
|
||||
imageCount = message.action.length + 1; // "+1" for the GIF that'll finish processing soon
|
||||
message.action.unshift({ localPath: '../../../resources/icons/loadingDark.gif' });
|
||||
message.action.unshift({ localPath: messageOptions.loadingGifPath });
|
||||
message.action.forEach(addImage);
|
||||
document.getElementById('p0').disabled = true;
|
||||
} else {
|
||||
var gifPath = message.action[0].localPath;
|
||||
document.getElementById('p0').disabled = false;
|
||||
document.getElementById('p0img').src = message.action[0].localPath;
|
||||
document.getElementById('p0img').src = gifPath;
|
||||
paths[0].localPath = gifPath;
|
||||
}
|
||||
} else {
|
||||
imageCount = message.action.length;
|
||||
|
|
|
@ -400,6 +400,7 @@ function getProfilePicture(username, callback) { // callback(url) if successfull
|
|||
var matched = !error && html.match(/img class="users-img" src="([^"]*)"/);
|
||||
if (!matched) {
|
||||
print('Error: Unable to get profile picture for', username, error);
|
||||
callback('');
|
||||
return;
|
||||
}
|
||||
callback(matched[1]);
|
||||
|
|
|
@ -90,12 +90,12 @@ function onMessage(message) {
|
|||
needsLogin = true;
|
||||
submessage.share = false;
|
||||
shareAfterLogin = true;
|
||||
snapshotToShareAfterLogin = {path: submessage.localPath, href: submessage.href};
|
||||
snapshotToShareAfterLogin = {path: submessage.localPath, href: submessage.href || href};
|
||||
}
|
||||
if (submessage.share) {
|
||||
print('sharing', submessage.localPath);
|
||||
outstanding = true;
|
||||
Window.shareSnapshot(submessage.localPath, submessage.href);
|
||||
Window.shareSnapshot(submessage.localPath, submessage.href || href);
|
||||
} else {
|
||||
print('not sharing', submessage.localPath);
|
||||
}
|
||||
|
@ -239,6 +239,7 @@ function processingGifStarted(pathStillSnapshot) {
|
|||
{
|
||||
containsGif: true,
|
||||
processingGif: true,
|
||||
loadingGifPath: Script.resolvePath(Script.resourcesPath() + 'icons/loadingDark.gif'),
|
||||
canShare: !!isDomainOpen(domainId),
|
||||
openFeedAfterShare: shouldOpenFeedAfterShare()
|
||||
}];
|
||||
|
|
Loading…
Reference in a new issue