mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 10:39:54 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into sysTray
This commit is contained in:
commit
af6db93b70
58 changed files with 1193 additions and 617 deletions
57
interface/resources/icons/tablet-icons/goto-a-msg.svg
Normal file
57
interface/resources/icons/tablet-icons/goto-a-msg.svg
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
version="1.1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
viewBox="0 0 50 50"
|
||||||
|
style="enable-background:new 0 0 50 50;"
|
||||||
|
xml:space="preserve"
|
||||||
|
id="svg2"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="goto-a.svg"><metadata
|
||||||
|
id="metadata14"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||||
|
id="defs12" /><sodipodi:namedview
|
||||||
|
pagecolor="#ff0000"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="852"
|
||||||
|
inkscape:window-height="480"
|
||||||
|
id="namedview10"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="4.72"
|
||||||
|
inkscape:cx="25"
|
||||||
|
inkscape:cy="25"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="svg2" /><style
|
||||||
|
type="text/css"
|
||||||
|
id="style4">
|
||||||
|
.st0{fill:#FFFFFF;}
|
||||||
|
.st1{fill:#EF3B4E;}
|
||||||
|
</style>
|
||||||
|
<circle class="st1" cx="44.1" cy="6" r="5.6"/>
|
||||||
|
<g
|
||||||
|
id="Layer_2" /><g
|
||||||
|
id="Layer_1"
|
||||||
|
style="fill:#000000;fill-opacity:1"><path
|
||||||
|
class="st0"
|
||||||
|
d="M47.2,41.3l-9.1-9.1c-0.8-0.8-1.9-1.1-3-1l-2.4-2.4c1.8-2.6,2.8-5.7,2.8-9c0-8.9-7.2-16.1-16.1-16.1 S3.3,11,3.3,19.8c0,8.9,7.2,16.1,16.1,16.1c4.1,0,7.8-1.5,10.6-4l2.2,2.2c-0.2,1.1,0.1,2.2,1,3l9.1,9.1c1.4,1.4,3.6,1.4,4.9,0 C48.5,44.9,48.5,42.7,47.2,41.3z M19.4,32.2c-6.8,0-12.3-5.5-12.3-12.3c0-6.8,5.5-12.3,12.3-12.3s12.3,5.5,12.3,12.3 C31.8,26.6,26.2,32.2,19.4,32.2z"
|
||||||
|
id="path8"
|
||||||
|
style="fill:#000000;fill-opacity:1" /></g></svg>
|
After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 911 B After Width: | Height: | Size: 911 B |
6
interface/resources/icons/tablet-icons/wallet-a-msg.svg
Normal file
6
interface/resources/icons/tablet-icons/wallet-a-msg.svg
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 96 96" style="enable-background:new 0 0 96 96;" xml:space="preserve">
|
||||||
|
<style type="text/css">
|
||||||
|
.st1{fill:#EF3B4E;}
|
||||||
|
</style>
|
||||||
|
<circle class="st1" cx="84.6" cy="11.5" r="10.75"/>
|
||||||
|
<g><path d="M2.4,70.5c0,6.1,4.9,11,11,11H76c6.1,0,11-4.9,11-11V59.6c3.7-0.7,6.6-3.9,6.6-7.9v-7.5c0-3.9-2.8-7.2-6.6-7.9V25.5 c0-6.1-4.9-11-11-11H13.4c-6.1,0-11,4.9-11,11V70.5z M87.6,51.8c0,1.1-0.9,2-2,2H72.2c-2.8,0-5-2.2-5-5v-1.5c0-2.8,2.2-5,5-5h13.3 c1.1,0,2,0.9,2,2V51.8z M8.4,25.5c0-2.8,2.2-5,5-5H76c2.8,0,5,2.2,5,5v10.7h-8.7c-6.1,0-11,4.9-11,11v1.5c0,6.1,4.9,11,11,11H81 v10.7c0,2.8-2.2,5-5,5H13.4c-2.8,0-5-2.2-5-5V25.5z"></path></g></svg>
|
After Width: | Height: | Size: 755 B |
16
interface/resources/icons/tablet-icons/wallet-i-msg.svg
Normal file
16
interface/resources/icons/tablet-icons/wallet-i-msg.svg
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<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 96 96" style="enable-background:new 0 0 96 96;" xml:space="preserve">
|
||||||
|
<style type="text/css">
|
||||||
|
.st0{fill:#FFFFFF;}
|
||||||
|
.st1{fill:#EF3B4E;}
|
||||||
|
</style>
|
||||||
|
<circle class="st1" cx="84.6" cy="11.5" r="10.75"/>
|
||||||
|
<g>
|
||||||
|
<path class="st0" d="M2.4,70.5c0,6.1,4.9,11,11,11H76c6.1,0,11-4.9,11-11V59.6c3.7-0.7,6.6-3.9,6.6-7.9v-7.5c0-3.9-2.8-7.2-6.6-7.9
|
||||||
|
V25.5c0-6.1-4.9-11-11-11H13.4c-6.1,0-11,4.9-11,11C2.4,25.5,2.4,70.5,2.4,70.5z M87.6,51.8c0,1.1-0.9,2-2,2H72.2c-2.8,0-5-2.2-5-5
|
||||||
|
v-1.5c0-2.8,2.2-5,5-5h13.3c1.1,0,2,0.9,2,2L87.6,51.8L87.6,51.8z M8.4,25.5c0-2.8,2.2-5,5-5H76c2.8,0,5,2.2,5,5v10.7h-8.7
|
||||||
|
c-6.1,0-11,4.9-11,11v1.5c0,6.1,4.9,11,11,11H81v10.7c0,2.8-2.2,5-5,5H13.4c-2.8,0-5-2.2-5-5V25.5z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 984 B |
|
@ -0,0 +1,290 @@
|
||||||
|
//
|
||||||
|
// marketplaceItemTester
|
||||||
|
// qml/hifi/commerce/marketplaceItemTester
|
||||||
|
//
|
||||||
|
// Load items not in the marketplace for testing purposes
|
||||||
|
//
|
||||||
|
// Created by Zach Fox on 2018-09-05
|
||||||
|
// Copyright 2018 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
|
||||||
|
import QtQuick.Controls.Styles 1.4
|
||||||
|
import QtQuick.Dialogs 1.0
|
||||||
|
import QtQuick.Layouts 1.1
|
||||||
|
import Hifi 1.0 as Hifi
|
||||||
|
import "../../../styles-uit" as HifiStylesUit
|
||||||
|
import "../../../controls-uit" as HifiControlsUit
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property string installedApps
|
||||||
|
property var nextResourceObjectId: 0
|
||||||
|
signal sendToScript(var message)
|
||||||
|
|
||||||
|
HifiStylesUit.HifiConstants { id: hifi }
|
||||||
|
ListModel { id: resourceListModel }
|
||||||
|
|
||||||
|
color: hifi.colors.white
|
||||||
|
|
||||||
|
AnimatedImage {
|
||||||
|
id: spinner;
|
||||||
|
source: "spinner.gif"
|
||||||
|
width: 74;
|
||||||
|
height: width;
|
||||||
|
anchors.verticalCenter: parent.verticalCenter;
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fromScript(message) {
|
||||||
|
switch (message.method) {
|
||||||
|
case "newResourceObjectInTest":
|
||||||
|
var resourceObject = message.resourceObject;
|
||||||
|
resourceListModel.append(resourceObject);
|
||||||
|
spinner.visible = false;
|
||||||
|
break;
|
||||||
|
case "nextObjectIdInTest":
|
||||||
|
nextResourceObjectId = message.id;
|
||||||
|
spinner.visible = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildResourceObj(resource) {
|
||||||
|
resource = resource.trim();
|
||||||
|
var assetType = (resource.match(/\.app\.json$/) ? "application" :
|
||||||
|
resource.match(/\.fst$/) ? "avatar" :
|
||||||
|
resource.match(/\.json\.gz$/) ? "content set" :
|
||||||
|
resource.match(/\.json$/) ? "entity or wearable" :
|
||||||
|
"unknown");
|
||||||
|
return { "id": nextResourceObjectId++,
|
||||||
|
"resource": resource,
|
||||||
|
"assetType": assetType };
|
||||||
|
}
|
||||||
|
|
||||||
|
function installResourceObj(resourceObj) {
|
||||||
|
if ("application" === resourceObj.assetType) {
|
||||||
|
Commerce.installApp(resourceObj.resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addAllInstalledAppsToList() {
|
||||||
|
var i, apps = Commerce.getInstalledApps().split(","), len = apps.length;
|
||||||
|
for(i = 0; i < len - 1; ++i) {
|
||||||
|
if (i in apps) {
|
||||||
|
resourceListModel.append(buildResourceObj(apps[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toUrl(resource) {
|
||||||
|
var httpPattern = /^http/i;
|
||||||
|
return httpPattern.test(resource) ? resource : "file:///" + resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rezEntity(resource, entityType) {
|
||||||
|
sendToScript({
|
||||||
|
method: 'tester_rezClicked',
|
||||||
|
itemHref: toUrl(resource),
|
||||||
|
itemType: entityType});
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: 12
|
||||||
|
anchors.bottomMargin: 40
|
||||||
|
anchors.rightMargin: 12
|
||||||
|
model: resourceListModel
|
||||||
|
spacing: 5
|
||||||
|
interactive: false
|
||||||
|
|
||||||
|
delegate: RowLayout {
|
||||||
|
anchors.left: parent.left
|
||||||
|
width: parent.width
|
||||||
|
spacing: 5
|
||||||
|
|
||||||
|
property var actions: {
|
||||||
|
"forward": function(resource, assetType){
|
||||||
|
switch(assetType) {
|
||||||
|
case "application":
|
||||||
|
Commerce.openApp(resource);
|
||||||
|
break;
|
||||||
|
case "avatar":
|
||||||
|
MyAvatar.useFullAvatarURL(resource);
|
||||||
|
break;
|
||||||
|
case "content set":
|
||||||
|
urlHandler.handleUrl("hifi://localhost/0,0,0");
|
||||||
|
Commerce.replaceContentSet(toUrl(resource), "");
|
||||||
|
break;
|
||||||
|
case "entity":
|
||||||
|
case "wearable":
|
||||||
|
rezEntity(resource, assetType);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print("Marketplace item tester unsupported assetType " + assetType);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"trash": function(){
|
||||||
|
if ("application" === assetType) {
|
||||||
|
Commerce.uninstallApp(resource);
|
||||||
|
}
|
||||||
|
sendToScript({
|
||||||
|
method: "tester_deleteResourceObject",
|
||||||
|
objectId: resourceListModel.get(index).id});
|
||||||
|
resourceListModel.remove(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Layout.preferredWidth: root.width * .6
|
||||||
|
spacing: 5
|
||||||
|
Text {
|
||||||
|
text: {
|
||||||
|
var match = resource.match(/\/([^/]*)$/);
|
||||||
|
return match ? match[1] : resource;
|
||||||
|
}
|
||||||
|
font.pointSize: 12
|
||||||
|
horizontalAlignment: Text.AlignBottom
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
text: resource
|
||||||
|
font.pointSize: 8
|
||||||
|
width: root.width * .6
|
||||||
|
horizontalAlignment: Text.AlignBottom
|
||||||
|
wrapMode: Text.WrapAnywhere
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
id: comboBox
|
||||||
|
|
||||||
|
Layout.preferredWidth: root.width * .2
|
||||||
|
|
||||||
|
model: [
|
||||||
|
"application",
|
||||||
|
"avatar",
|
||||||
|
"content set",
|
||||||
|
"entity",
|
||||||
|
"wearable",
|
||||||
|
"unknown"
|
||||||
|
]
|
||||||
|
|
||||||
|
currentIndex: (("entity or wearable" === assetType) ?
|
||||||
|
model.indexOf("unknown") : model.indexOf(assetType))
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
onCurrentIndexChanged.connect(function() {
|
||||||
|
assetType = model[currentIndex];
|
||||||
|
sendToScript({
|
||||||
|
method: "tester_updateResourceObjectAssetType",
|
||||||
|
objectId: resourceListModel.get(index)["id"],
|
||||||
|
assetType: assetType });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: [ "forward", "trash" ]
|
||||||
|
|
||||||
|
HifiStylesUit.HiFiGlyphs {
|
||||||
|
property var glyphs: {
|
||||||
|
"application": hifi.glyphs.install,
|
||||||
|
"avatar": hifi.glyphs.avatar,
|
||||||
|
"content set": hifi.glyphs.globe,
|
||||||
|
"entity": hifi.glyphs.wand,
|
||||||
|
"trash": hifi.glyphs.trash,
|
||||||
|
"unknown": hifi.glyphs.circleSlash,
|
||||||
|
"wearable": hifi.glyphs.hat,
|
||||||
|
}
|
||||||
|
text: (("trash" === modelData) ?
|
||||||
|
glyphs.trash :
|
||||||
|
glyphs[comboBox.model[comboBox.currentIndex]])
|
||||||
|
size: ("trash" === modelData) ? 22 : 30
|
||||||
|
color: hifi.colors.black
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
actions[modelData](resource, comboBox.currentText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
headerPositioning: ListView.OverlayHeader
|
||||||
|
header: HifiStylesUit.RalewayRegular {
|
||||||
|
id: rootHeader
|
||||||
|
text: "Marketplace Item Tester"
|
||||||
|
height: 80
|
||||||
|
width: paintedWidth
|
||||||
|
size: 22
|
||||||
|
color: hifi.colors.black
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.leftMargin: 12
|
||||||
|
}
|
||||||
|
|
||||||
|
footerPositioning: ListView.OverlayFooter
|
||||||
|
footer: Row {
|
||||||
|
id: rootActions
|
||||||
|
spacing: 20
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
|
property string currentAction
|
||||||
|
property var actions: {
|
||||||
|
"Load File": function(){
|
||||||
|
rootActions.currentAction = "load file";
|
||||||
|
Window.browseChanged.connect(onResourceSelected);
|
||||||
|
Window.browseAsync("Please select a file (*.app.json *.json *.fst *.json.gz)", "", "Assets (*.app.json *.json *.fst *.json.gz)");
|
||||||
|
},
|
||||||
|
"Load URL": function(){
|
||||||
|
rootActions.currentAction = "load url";
|
||||||
|
Window.promptTextChanged.connect(onResourceSelected);
|
||||||
|
Window.promptAsync("Please enter a URL", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onResourceSelected(resource) {
|
||||||
|
// It is possible that we received the present signal
|
||||||
|
// from something other than our browserAsync window.
|
||||||
|
// Alas, there is nothing we can do about that so charge
|
||||||
|
// ahead as though we are sure the present signal is one
|
||||||
|
// we expect.
|
||||||
|
switch(currentAction) {
|
||||||
|
case "load file":
|
||||||
|
Window.browseChanged.disconnect(onResourceSelected);
|
||||||
|
break
|
||||||
|
case "load url":
|
||||||
|
Window.promptTextChanged.disconnect(onResourceSelected);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (resource) {
|
||||||
|
var resourceObj = buildResourceObj(resource);
|
||||||
|
installResourceObj(resourceObj);
|
||||||
|
sendToScript({
|
||||||
|
method: 'tester_newResourceObject',
|
||||||
|
resourceObject: resourceObj });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: [ "Load File", "Load URL" ]
|
||||||
|
HifiControlsUit.Button {
|
||||||
|
color: hifi.buttons.blue
|
||||||
|
fontSize: 20
|
||||||
|
text: modelData
|
||||||
|
width: root.width / 3
|
||||||
|
height: 40
|
||||||
|
onClicked: actions[text]()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
|
@ -59,7 +59,7 @@ Item {
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: Commerce;
|
target: Commerce;
|
||||||
|
|
||||||
onContentSetChanged: {
|
onContentSetChanged: {
|
||||||
if (contentSetHref === root.itemHref) {
|
if (contentSetHref === root.itemHref) {
|
||||||
showConfirmation = true;
|
showConfirmation = true;
|
||||||
|
@ -135,7 +135,7 @@ Item {
|
||||||
anchors.topMargin: 8;
|
anchors.topMargin: 8;
|
||||||
width: 30;
|
width: 30;
|
||||||
height: width;
|
height: width;
|
||||||
|
|
||||||
HiFiGlyphs {
|
HiFiGlyphs {
|
||||||
id: closeContextMenuGlyph;
|
id: closeContextMenuGlyph;
|
||||||
text: hifi.glyphs.close;
|
text: hifi.glyphs.close;
|
||||||
|
@ -376,7 +376,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
transform: Rotation {
|
transform: Rotation {
|
||||||
id: rotation;
|
id: rotation;
|
||||||
origin.x: flipable.width/2;
|
origin.x: flipable.width/2;
|
||||||
|
@ -509,7 +509,7 @@ Item {
|
||||||
}
|
}
|
||||||
verticalAlignment: Text.AlignTop;
|
verticalAlignment: Text.AlignTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
HiFiGlyphs {
|
HiFiGlyphs {
|
||||||
id: statusIcon;
|
id: statusIcon;
|
||||||
text: {
|
text: {
|
||||||
|
@ -588,7 +588,7 @@ Item {
|
||||||
border.width: 1;
|
border.width: 1;
|
||||||
border.color: "#E2334D";
|
border.color: "#E2334D";
|
||||||
}
|
}
|
||||||
|
|
||||||
HiFiGlyphs {
|
HiFiGlyphs {
|
||||||
id: contextMenuGlyph;
|
id: contextMenuGlyph;
|
||||||
text: hifi.glyphs.verticalEllipsis;
|
text: hifi.glyphs.verticalEllipsis;
|
||||||
|
@ -615,7 +615,7 @@ Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: rezzedNotifContainer;
|
id: rezzedNotifContainer;
|
||||||
z: 998;
|
z: 998;
|
||||||
|
@ -663,13 +663,13 @@ Item {
|
||||||
Tablet.playSound(TabletEnums.ButtonHover);
|
Tablet.playSound(TabletEnums.ButtonHover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onFocusChanged: {
|
onFocusChanged: {
|
||||||
if (focus) {
|
if (focus) {
|
||||||
Tablet.playSound(TabletEnums.ButtonHover);
|
Tablet.playSound(TabletEnums.ButtonHover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Tablet.playSound(TabletEnums.ButtonClick);
|
Tablet.playSound(TabletEnums.ButtonClick);
|
||||||
if (root.itemType === "contentSet") {
|
if (root.itemType === "contentSet") {
|
||||||
|
@ -775,7 +775,7 @@ Item {
|
||||||
// Style
|
// Style
|
||||||
color: hifi.colors.redAccent;
|
color: hifi.colors.redAccent;
|
||||||
horizontalAlignment: Text.AlignRight;
|
horizontalAlignment: Text.AlignRight;
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
hoverEnabled: true;
|
hoverEnabled: true;
|
||||||
|
|
|
@ -93,7 +93,7 @@ Rectangle {
|
||||||
console.log("Failed to get Available Updates", result.data.message);
|
console.log("Failed to get Available Updates", result.data.message);
|
||||||
} else {
|
} else {
|
||||||
sendToScript({method: 'purchases_availableUpdatesReceived', numUpdates: result.data.updates.length });
|
sendToScript({method: 'purchases_availableUpdatesReceived', numUpdates: result.data.updates.length });
|
||||||
root.numUpdatesAvailable = result.data.updates.length;
|
root.numUpdatesAvailable = result.total_entries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,14 +45,6 @@ Item {
|
||||||
onHistoryResult : {
|
onHistoryResult : {
|
||||||
transactionHistoryModel.handlePage(null, result);
|
transactionHistoryModel.handlePage(null, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
onAvailableUpdatesResult: {
|
|
||||||
if (result.status !== 'success') {
|
|
||||||
console.log("Failed to get Available Updates", result.data.message);
|
|
||||||
} else {
|
|
||||||
sendToScript({method: 'wallet_availableUpdatesReceived', numUpdates: result.data.updates.length });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|
|
@ -1691,21 +1691,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
return DependencyManager::get<OffscreenUi>()->navigationFocused() ? 1 : 0;
|
return DependencyManager::get<OffscreenUi>()->navigationFocused() ? 1 : 0;
|
||||||
});
|
});
|
||||||
_applicationStateDevice->setInputVariant(STATE_PLATFORM_WINDOWS, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_PLATFORM_WINDOWS, []() -> float {
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
_applicationStateDevice->setInputVariant(STATE_PLATFORM_MAC, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_PLATFORM_MAC, []() -> float {
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
_applicationStateDevice->setInputVariant(STATE_PLATFORM_ANDROID, []() -> float {
|
_applicationStateDevice->setInputVariant(STATE_PLATFORM_ANDROID, []() -> float {
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1759,10 +1759,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
|
|
||||||
// Make sure we don't time out during slow operations at startup
|
// Make sure we don't time out during slow operations at startup
|
||||||
updateHeartbeat();
|
updateHeartbeat();
|
||||||
|
|
||||||
QTimer* settingsTimer = new QTimer();
|
QTimer* settingsTimer = new QTimer();
|
||||||
moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
|
moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
|
||||||
connect(qApp, &Application::beforeAboutToQuit, [this, settingsTimer]{
|
// This needs to run on the settings thread, so we need to pass the `settingsTimer` as the
|
||||||
|
// receiver object, otherwise it will run on the application thread and trigger a warning
|
||||||
|
// about trying to kill the timer on the main thread.
|
||||||
|
connect(qApp, &Application::beforeAboutToQuit, settingsTimer, [this, settingsTimer]{
|
||||||
// Disconnect the signal from the save settings
|
// Disconnect the signal from the save settings
|
||||||
QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
|
QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
|
||||||
// Stop the settings timer
|
// Stop the settings timer
|
||||||
|
@ -2881,9 +2883,10 @@ void Application::initializeUi() {
|
||||||
QUrl{ "hifi/commerce/common/CommerceLightbox.qml" },
|
QUrl{ "hifi/commerce/common/CommerceLightbox.qml" },
|
||||||
QUrl{ "hifi/commerce/common/EmulatedMarketplaceHeader.qml" },
|
QUrl{ "hifi/commerce/common/EmulatedMarketplaceHeader.qml" },
|
||||||
QUrl{ "hifi/commerce/common/FirstUseTutorial.qml" },
|
QUrl{ "hifi/commerce/common/FirstUseTutorial.qml" },
|
||||||
QUrl{ "hifi/commerce/common/SortableListModel.qml" },
|
|
||||||
QUrl{ "hifi/commerce/common/sendAsset/SendAsset.qml" },
|
QUrl{ "hifi/commerce/common/sendAsset/SendAsset.qml" },
|
||||||
|
QUrl{ "hifi/commerce/common/SortableListModel.qml" },
|
||||||
QUrl{ "hifi/commerce/inspectionCertificate/InspectionCertificate.qml" },
|
QUrl{ "hifi/commerce/inspectionCertificate/InspectionCertificate.qml" },
|
||||||
|
QUrl{ "hifi/commerce/marketplaceItemTester/MarketplaceItemTester.qml"},
|
||||||
QUrl{ "hifi/commerce/purchases/PurchasedItem.qml" },
|
QUrl{ "hifi/commerce/purchases/PurchasedItem.qml" },
|
||||||
QUrl{ "hifi/commerce/purchases/Purchases.qml" },
|
QUrl{ "hifi/commerce/purchases/Purchases.qml" },
|
||||||
QUrl{ "hifi/commerce/wallet/Help.qml" },
|
QUrl{ "hifi/commerce/wallet/Help.qml" },
|
||||||
|
@ -3503,13 +3506,14 @@ bool Application::isServerlessMode() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setIsInterstitialMode(bool interstitialMode) {
|
void Application::setIsInterstitialMode(bool interstitialMode) {
|
||||||
Settings settings;
|
bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
|
||||||
bool enableInterstitial = settings.value("enableIntersitialMode", false).toBool();
|
if (enableInterstitial) {
|
||||||
if (_interstitialMode != interstitialMode && enableInterstitial) {
|
if (_interstitialMode != interstitialMode) {
|
||||||
_interstitialMode = interstitialMode;
|
_interstitialMode = interstitialMode;
|
||||||
|
|
||||||
DependencyManager::get<AudioClient>()->setAudioPaused(_interstitialMode);
|
DependencyManager::get<AudioClient>()->setAudioPaused(_interstitialMode);
|
||||||
DependencyManager::get<AvatarManager>()->setMyAvatarDataPacketsPaused(_interstitialMode);
|
DependencyManager::get<AvatarManager>()->setMyAvatarDataPacketsPaused(_interstitialMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -432,7 +432,7 @@ public slots:
|
||||||
|
|
||||||
void setIsServerlessMode(bool serverlessDomain);
|
void setIsServerlessMode(bool serverlessDomain);
|
||||||
void loadServerlessDomain(QUrl domainURL, bool errorDomain = false);
|
void loadServerlessDomain(QUrl domainURL, bool errorDomain = false);
|
||||||
void setIsInterstitialMode(bool interstialMode);
|
void setIsInterstitialMode(bool interstitialMode);
|
||||||
|
|
||||||
void updateVerboseLogging();
|
void updateVerboseLogging();
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,15 @@ void ConnectionMonitor::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(&_timer, &QTimer::timeout, this, [this]() {
|
connect(&_timer, &QTimer::timeout, this, [this]() {
|
||||||
qDebug() << "ConnectionMonitor: Redirecting to 404 error domain";
|
|
||||||
// set in a timeout error
|
// set in a timeout error
|
||||||
emit setRedirectErrorState(REDIRECT_HIFI_ADDRESS, 5);
|
bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
|
||||||
|
if (enableInterstitial) {
|
||||||
|
qDebug() << "ConnectionMonitor: Redirecting to 404 error domain";
|
||||||
|
emit setRedirectErrorState(REDIRECT_HIFI_ADDRESS, "", 5);
|
||||||
|
} else {
|
||||||
|
qDebug() << "ConnectionMonitor: Showing connection failure window";
|
||||||
|
DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,4 +59,8 @@ void ConnectionMonitor::startTimer() {
|
||||||
|
|
||||||
void ConnectionMonitor::stopTimer() {
|
void ConnectionMonitor::stopTimer() {
|
||||||
_timer.stop();
|
_timer.stop();
|
||||||
|
bool enableInterstitial = DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
|
||||||
|
if (!enableInterstitial) {
|
||||||
|
DependencyManager::get<DialogsManager>()->setDomainConnectionFailureVisibility(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void setRedirectErrorState(QUrl errorURL, int reasonCode);
|
void setRedirectErrorState(QUrl errorURL, QString reasonMessage = "", int reasonCode = -1, const QString& extraInfo = "");
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void startTimer();
|
void startTimer();
|
||||||
|
@ -34,4 +34,4 @@ private:
|
||||||
QTimer _timer;
|
QTimer _timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_ConnectionMonitor_h
|
#endif // hifi_ConnectionMonitor_h
|
||||||
|
|
|
@ -234,11 +234,13 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
||||||
const SortableAvatar& sortData = *it;
|
const SortableAvatar& sortData = *it;
|
||||||
const auto avatar = std::static_pointer_cast<OtherAvatar>(sortData.getAvatar());
|
const auto avatar = std::static_pointer_cast<OtherAvatar>(sortData.getAvatar());
|
||||||
|
|
||||||
// TODO: to help us scale to more avatars it would be nice to not have to poll orb state here
|
// TODO: to help us scale to more avatars it would be nice to not have to poll this stuff every update
|
||||||
// if the geometry is loaded then turn off the orb
|
|
||||||
if (avatar->getSkeletonModel()->isLoaded()) {
|
if (avatar->getSkeletonModel()->isLoaded()) {
|
||||||
// remove the orb if it is there
|
// remove the orb if it is there
|
||||||
avatar->removeOrb();
|
avatar->removeOrb();
|
||||||
|
if (avatar->needsPhysicsUpdate()) {
|
||||||
|
_avatarsToChangeInPhysics.insert(avatar);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
avatar->updateOrbPosition();
|
avatar->updateOrbPosition();
|
||||||
}
|
}
|
||||||
|
@ -456,31 +458,37 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarManager::clearOtherAvatars() {
|
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.
|
|
||||||
const render::ScenePointer& scene = qApp->getMain3DScene();
|
|
||||||
render::Transaction transaction;
|
|
||||||
|
|
||||||
QReadLocker locker(&_hashLock);
|
|
||||||
AvatarHash::iterator avatarIterator = _avatarHash.begin();
|
|
||||||
while (avatarIterator != _avatarHash.end()) {
|
|
||||||
auto avatar = std::static_pointer_cast<Avatar>(avatarIterator.value());
|
|
||||||
if (avatar != _myAvatar) {
|
|
||||||
handleRemovedAvatar(avatar);
|
|
||||||
avatarIterator = _avatarHash.erase(avatarIterator);
|
|
||||||
} else {
|
|
||||||
++avatarIterator;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assert(scene);
|
|
||||||
scene->enqueueTransaction(transaction);
|
|
||||||
_myAvatar->clearLookAtTargetAvatar();
|
_myAvatar->clearLookAtTargetAvatar();
|
||||||
|
|
||||||
|
// setup a vector of removed avatars outside the scope of the hash lock
|
||||||
|
std::vector<AvatarSharedPointer> removedAvatars;
|
||||||
|
|
||||||
|
{
|
||||||
|
QWriteLocker locker(&_hashLock);
|
||||||
|
|
||||||
|
removedAvatars.reserve(_avatarHash.size());
|
||||||
|
|
||||||
|
auto avatarIterator = _avatarHash.begin();
|
||||||
|
while (avatarIterator != _avatarHash.end()) {
|
||||||
|
auto avatar = std::static_pointer_cast<Avatar>(avatarIterator.value());
|
||||||
|
if (avatar != _myAvatar) {
|
||||||
|
removedAvatars.push_back(avatar);
|
||||||
|
avatarIterator = _avatarHash.erase(avatarIterator);
|
||||||
|
} else {
|
||||||
|
++avatarIterator;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& av : removedAvatars) {
|
||||||
|
handleRemovedAvatar(av);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarManager::deleteAllAvatars() {
|
void AvatarManager::deleteAllAvatars() {
|
||||||
assert(_avatarsToChangeInPhysics.empty());
|
assert(_avatarsToChangeInPhysics.empty());
|
||||||
|
|
||||||
QReadLocker locker(&_hashLock);
|
QWriteLocker locker(&_hashLock);
|
||||||
AvatarHash::iterator avatarIterator = _avatarHash.begin();
|
AvatarHash::iterator avatarIterator = _avatarHash.begin();
|
||||||
while (avatarIterator != _avatarHash.end()) {
|
while (avatarIterator != _avatarHash.end()) {
|
||||||
auto avatar = std::static_pointer_cast<OtherAvatar>(avatarIterator.value());
|
auto avatar = std::static_pointer_cast<OtherAvatar>(avatarIterator.value());
|
||||||
|
|
|
@ -204,7 +204,12 @@ private:
|
||||||
void simulateAvatarFades(float deltaTime);
|
void simulateAvatarFades(float deltaTime);
|
||||||
|
|
||||||
AvatarSharedPointer newSharedAvatar() override;
|
AvatarSharedPointer newSharedAvatar() override;
|
||||||
void handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason = KillAvatarReason::NoReason) override;
|
|
||||||
|
// called only from the AvatarHashMap thread - cannot be called while this thread holds the
|
||||||
|
// hash lock, since handleRemovedAvatar needs a write lock on the entity tree and the entity tree
|
||||||
|
// frequently grabs a read lock on the hash to get a given avatar by ID
|
||||||
|
void handleRemovedAvatar(const AvatarSharedPointer& removedAvatar,
|
||||||
|
KillAvatarReason removalReason = KillAvatarReason::NoReason) override;
|
||||||
|
|
||||||
QVector<AvatarSharedPointer> _avatarsToFade;
|
QVector<AvatarSharedPointer> _avatarsToFade;
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,7 @@ MyAvatar::MyAvatar(QThread* thread) :
|
||||||
_bodySensorMatrix(),
|
_bodySensorMatrix(),
|
||||||
_goToPending(false),
|
_goToPending(false),
|
||||||
_goToSafe(true),
|
_goToSafe(true),
|
||||||
|
_goToFeetAjustment(false),
|
||||||
_goToPosition(),
|
_goToPosition(),
|
||||||
_goToOrientation(),
|
_goToOrientation(),
|
||||||
_prevShouldDrawHead(true),
|
_prevShouldDrawHead(true),
|
||||||
|
@ -498,7 +499,7 @@ void MyAvatar::update(float deltaTime) {
|
||||||
setCurrentStandingHeight(computeStandingHeightMode(getControllerPoseInAvatarFrame(controller::Action::HEAD)));
|
setCurrentStandingHeight(computeStandingHeightMode(getControllerPoseInAvatarFrame(controller::Action::HEAD)));
|
||||||
setAverageHeadRotation(computeAverageHeadRotation(getControllerPoseInAvatarFrame(controller::Action::HEAD)));
|
setAverageHeadRotation(computeAverageHeadRotation(getControllerPoseInAvatarFrame(controller::Action::HEAD)));
|
||||||
|
|
||||||
if (_drawAverageFacingEnabled) {
|
if (_drawAverageFacingEnabled) {
|
||||||
auto sensorHeadPose = getControllerPoseInSensorFrame(controller::Action::HEAD);
|
auto sensorHeadPose = getControllerPoseInSensorFrame(controller::Action::HEAD);
|
||||||
glm::vec3 worldHeadPos = transformPoint(getSensorToWorldMatrix(), sensorHeadPose.getTranslation());
|
glm::vec3 worldHeadPos = transformPoint(getSensorToWorldMatrix(), sensorHeadPose.getTranslation());
|
||||||
glm::vec3 worldFacingAverage = transformVectorFast(getSensorToWorldMatrix(), glm::vec3(_headControllerFacingMovingAverage.x, 0.0f, _headControllerFacingMovingAverage.y));
|
glm::vec3 worldFacingAverage = transformVectorFast(getSensorToWorldMatrix(), glm::vec3(_headControllerFacingMovingAverage.x, 0.0f, _headControllerFacingMovingAverage.y));
|
||||||
|
@ -526,6 +527,11 @@ void MyAvatar::update(float deltaTime) {
|
||||||
_physicsSafetyPending = getCollisionsEnabled();
|
_physicsSafetyPending = getCollisionsEnabled();
|
||||||
_characterController.recomputeFlying(); // In case we've gone to into the sky.
|
_characterController.recomputeFlying(); // In case we've gone to into the sky.
|
||||||
}
|
}
|
||||||
|
if (_goToFeetAjustment && _skeletonModelLoaded) {
|
||||||
|
auto feetAjustment = getWorldPosition() - getWorldFeetPosition();
|
||||||
|
goToLocation(getWorldPosition() + feetAjustment);
|
||||||
|
_goToFeetAjustment = false;
|
||||||
|
}
|
||||||
if (_physicsSafetyPending && qApp->isPhysicsEnabled() && _characterController.isEnabledAndReady()) {
|
if (_physicsSafetyPending && qApp->isPhysicsEnabled() && _characterController.isEnabledAndReady()) {
|
||||||
// When needed and ready, arrange to check and fix.
|
// When needed and ready, arrange to check and fix.
|
||||||
_physicsSafetyPending = false;
|
_physicsSafetyPending = false;
|
||||||
|
@ -1728,6 +1734,7 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
|
||||||
|
|
||||||
_headBoneSet.clear();
|
_headBoneSet.clear();
|
||||||
_cauterizationNeedsUpdate = true;
|
_cauterizationNeedsUpdate = true;
|
||||||
|
_skeletonModelLoaded = false;
|
||||||
|
|
||||||
std::shared_ptr<QMetaObject::Connection> skeletonConnection = std::make_shared<QMetaObject::Connection>();
|
std::shared_ptr<QMetaObject::Connection> skeletonConnection = std::make_shared<QMetaObject::Connection>();
|
||||||
*skeletonConnection = QObject::connect(_skeletonModel.get(), &SkeletonModel::skeletonLoaded, [this, skeletonModelChangeCount, skeletonConnection]() {
|
*skeletonConnection = QObject::connect(_skeletonModel.get(), &SkeletonModel::skeletonLoaded, [this, skeletonModelChangeCount, skeletonConnection]() {
|
||||||
|
@ -1745,6 +1752,7 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
|
||||||
_skeletonModel->setCauterizeBoneSet(_headBoneSet);
|
_skeletonModel->setCauterizeBoneSet(_headBoneSet);
|
||||||
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
_fstAnimGraphOverrideUrl = _skeletonModel->getGeometry()->getAnimGraphOverrideUrl();
|
||||||
initAnimGraph();
|
initAnimGraph();
|
||||||
|
_skeletonModelLoaded = true;
|
||||||
}
|
}
|
||||||
QObject::disconnect(*skeletonConnection);
|
QObject::disconnect(*skeletonConnection);
|
||||||
});
|
});
|
||||||
|
@ -2945,46 +2953,10 @@ void MyAvatar::goToLocation(const QVariant& propertiesVar) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::goToFeetLocation(const glm::vec3& newPosition,
|
void MyAvatar::goToFeetLocation(const glm::vec3& newPosition,
|
||||||
bool hasOrientation, const glm::quat& newOrientation,
|
bool hasOrientation, const glm::quat& newOrientation,
|
||||||
bool shouldFaceLocation) {
|
bool shouldFaceLocation) {
|
||||||
|
_goToFeetAjustment = true;
|
||||||
qCDebug(interfaceapp).nospace() << "MyAvatar goToFeetLocation - moving to " << newPosition.x << ", "
|
goToLocation(newPosition, hasOrientation, newOrientation, shouldFaceLocation);
|
||||||
<< newPosition.y << ", " << newPosition.z;
|
|
||||||
|
|
||||||
ShapeInfo shapeInfo;
|
|
||||||
computeShapeInfo(shapeInfo);
|
|
||||||
glm::vec3 halfExtents = shapeInfo.getHalfExtents();
|
|
||||||
glm::vec3 localFeetPos = shapeInfo.getOffset() - glm::vec3(0.0f, halfExtents.y + halfExtents.x, 0.0f);
|
|
||||||
glm::mat4 localFeet = createMatFromQuatAndPos(Quaternions::IDENTITY, localFeetPos);
|
|
||||||
|
|
||||||
glm::mat4 worldFeet = createMatFromQuatAndPos(Quaternions::IDENTITY, newPosition);
|
|
||||||
|
|
||||||
glm::mat4 avatarMat = worldFeet * glm::inverse(localFeet);
|
|
||||||
|
|
||||||
glm::vec3 adjustedPosition = extractTranslation(avatarMat);
|
|
||||||
|
|
||||||
_goToPending = true;
|
|
||||||
_goToPosition = adjustedPosition;
|
|
||||||
_goToOrientation = getWorldOrientation();
|
|
||||||
if (hasOrientation) {
|
|
||||||
qCDebug(interfaceapp).nospace() << "MyAvatar goToFeetLocation - new orientation is "
|
|
||||||
<< newOrientation.x << ", " << newOrientation.y << ", " << newOrientation.z << ", " << newOrientation.w;
|
|
||||||
|
|
||||||
// orient the user to face the target
|
|
||||||
glm::quat quatOrientation = cancelOutRollAndPitch(newOrientation);
|
|
||||||
|
|
||||||
if (shouldFaceLocation) {
|
|
||||||
quatOrientation = newOrientation * glm::angleAxis(PI, Vectors::UP);
|
|
||||||
|
|
||||||
// move the user a couple units away
|
|
||||||
const float DISTANCE_TO_USER = 2.0f;
|
|
||||||
_goToPosition = adjustedPosition - quatOrientation * IDENTITY_FORWARD * DISTANCE_TO_USER;
|
|
||||||
}
|
|
||||||
|
|
||||||
_goToOrientation = quatOrientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit transformChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::goToLocation(const glm::vec3& newPosition,
|
void MyAvatar::goToLocation(const glm::vec3& newPosition,
|
||||||
|
|
|
@ -1732,6 +1732,7 @@ private:
|
||||||
bool _goToPending { false };
|
bool _goToPending { false };
|
||||||
bool _physicsSafetyPending { false };
|
bool _physicsSafetyPending { false };
|
||||||
bool _goToSafe { true };
|
bool _goToSafe { true };
|
||||||
|
bool _goToFeetAjustment { false };
|
||||||
glm::vec3 _goToPosition;
|
glm::vec3 _goToPosition;
|
||||||
glm::quat _goToOrientation;
|
glm::quat _goToOrientation;
|
||||||
|
|
||||||
|
@ -1807,6 +1808,7 @@ private:
|
||||||
|
|
||||||
bool _haveReceivedHeightLimitsFromDomain { false };
|
bool _haveReceivedHeightLimitsFromDomain { false };
|
||||||
int _disableHandTouchCount { 0 };
|
int _disableHandTouchCount { 0 };
|
||||||
|
bool _skeletonModelLoaded { false };
|
||||||
|
|
||||||
Setting::Handle<QString> _dominantHandSetting;
|
Setting::Handle<QString> _dominantHandSetting;
|
||||||
Setting::Handle<float> _headPitchSetting;
|
Setting::Handle<float> _headPitchSetting;
|
||||||
|
|
|
@ -119,6 +119,11 @@ bool OtherAvatar::shouldBeInPhysicsSimulation() const {
|
||||||
return (_workloadRegion < workload::Region::R3 && !isDead());
|
return (_workloadRegion < workload::Region::R3 && !isDead());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OtherAvatar::needsPhysicsUpdate() const {
|
||||||
|
constexpr uint32_t FLAGS_OF_INTEREST = Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS | Simulation::DIRTY_POSITION;
|
||||||
|
return (_motionState && (bool)(_motionState->getIncomingDirtyFlags() & FLAGS_OF_INTEREST));
|
||||||
|
}
|
||||||
|
|
||||||
void OtherAvatar::rebuildCollisionShape() {
|
void OtherAvatar::rebuildCollisionShape() {
|
||||||
if (_motionState) {
|
if (_motionState) {
|
||||||
_motionState->addDirtyFlags(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS);
|
_motionState->addDirtyFlags(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS);
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
|
|
||||||
void setWorkloadRegion(uint8_t region);
|
void setWorkloadRegion(uint8_t region);
|
||||||
bool shouldBeInPhysicsSimulation() const;
|
bool shouldBeInPhysicsSimulation() const;
|
||||||
|
bool needsPhysicsUpdate() const;
|
||||||
|
|
||||||
friend AvatarManager;
|
friend AvatarManager;
|
||||||
|
|
||||||
|
|
|
@ -247,12 +247,18 @@ void QmlCommerce::transferAssetToUsername(const QString& username,
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlCommerce::replaceContentSet(const QString& itemHref, const QString& certificateID) {
|
void QmlCommerce::replaceContentSet(const QString& itemHref, const QString& certificateID) {
|
||||||
auto ledger = DependencyManager::get<Ledger>();
|
if (!certificateID.isEmpty()) {
|
||||||
ledger->updateLocation(certificateID, DependencyManager::get<AddressManager>()->getPlaceName(), true);
|
auto ledger = DependencyManager::get<Ledger>();
|
||||||
|
ledger->updateLocation(
|
||||||
|
certificateID,
|
||||||
|
DependencyManager::get<AddressManager>()->getPlaceName(),
|
||||||
|
true);
|
||||||
|
}
|
||||||
qApp->replaceDomainContent(itemHref);
|
qApp->replaceDomainContent(itemHref);
|
||||||
QJsonObject messageProperties = { { "status", "SuccessfulRequestToReplaceContent" }, { "content_set_url", itemHref } };
|
QJsonObject messageProperties = {
|
||||||
|
{ "status", "SuccessfulRequestToReplaceContent" },
|
||||||
|
{ "content_set_url", itemHref } };
|
||||||
UserActivityLogger::getInstance().logAction("replace_domain_content", messageProperties);
|
UserActivityLogger::getInstance().logAction("replace_domain_content", messageProperties);
|
||||||
|
|
||||||
emit contentSetChanged(itemHref);
|
emit contentSetChanged(itemHref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,6 +282,7 @@ QString QmlCommerce::getInstalledApps(const QString& justInstalledAppID) {
|
||||||
// Thus, we protect against deleting the .app.json from the user's disk (below)
|
// Thus, we protect against deleting the .app.json from the user's disk (below)
|
||||||
// by skipping that check for the app we just installed.
|
// by skipping that check for the app we just installed.
|
||||||
if ((justInstalledAppID != "") && ((justInstalledAppID + ".app.json") == appFileName)) {
|
if ((justInstalledAppID != "") && ((justInstalledAppID + ".app.json") == appFileName)) {
|
||||||
|
installedAppsFromMarketplace += appFileName + ",";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,14 @@ void LaserPointer::editRenderStatePath(const std::string& state, const QVariant&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PickResultPointer LaserPointer::getPickResultCopy(const PickResultPointer& pickResult) const {
|
||||||
|
auto rayPickResult = std::dynamic_pointer_cast<RayPickResult>(pickResult);
|
||||||
|
if (!rayPickResult) {
|
||||||
|
return std::make_shared<RayPickResult>();
|
||||||
|
}
|
||||||
|
return std::make_shared<RayPickResult>(*rayPickResult.get());
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap LaserPointer::toVariantMap() const {
|
QVariantMap LaserPointer::toVariantMap() const {
|
||||||
QVariantMap qVariantMap;
|
QVariantMap qVariantMap;
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@ public:
|
||||||
static std::shared_ptr<StartEndRenderState> buildRenderState(const QVariantMap& propMap);
|
static std::shared_ptr<StartEndRenderState> buildRenderState(const QVariantMap& propMap);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
PickResultPointer getPickResultCopy(const PickResultPointer& pickResult) const override;
|
||||||
|
|
||||||
void editRenderStatePath(const std::string& state, const QVariant& pathProps) override;
|
void editRenderStatePath(const std::string& state, const QVariant& pathProps) override;
|
||||||
|
|
||||||
glm::vec3 getPickOrigin(const PickResultPointer& pickResult) const override;
|
glm::vec3 getPickOrigin(const PickResultPointer& pickResult) const override;
|
||||||
|
|
|
@ -30,6 +30,14 @@ ParabolaPointer::ParabolaPointer(const QVariant& rayProps, const RenderStateMap&
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PickResultPointer ParabolaPointer::getPickResultCopy(const PickResultPointer& pickResult) const {
|
||||||
|
auto parabolaPickResult = std::dynamic_pointer_cast<ParabolaPickResult>(pickResult);
|
||||||
|
if (!parabolaPickResult) {
|
||||||
|
return std::make_shared<ParabolaPickResult>();
|
||||||
|
}
|
||||||
|
return std::make_shared<ParabolaPickResult>(*parabolaPickResult.get());
|
||||||
|
}
|
||||||
|
|
||||||
void ParabolaPointer::editRenderStatePath(const std::string& state, const QVariant& pathProps) {
|
void ParabolaPointer::editRenderStatePath(const std::string& state, const QVariant& pathProps) {
|
||||||
auto renderState = std::static_pointer_cast<RenderState>(_renderStates[state]);
|
auto renderState = std::static_pointer_cast<RenderState>(_renderStates[state]);
|
||||||
if (renderState) {
|
if (renderState) {
|
||||||
|
|
|
@ -102,6 +102,8 @@ public:
|
||||||
static std::shared_ptr<StartEndRenderState> buildRenderState(const QVariantMap& propMap);
|
static std::shared_ptr<StartEndRenderState> buildRenderState(const QVariantMap& propMap);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual PickResultPointer getPickResultCopy(const PickResultPointer& pickResult) const override;
|
||||||
|
|
||||||
void editRenderStatePath(const std::string& state, const QVariant& pathProps) override;
|
void editRenderStatePath(const std::string& state, const QVariant& pathProps) override;
|
||||||
|
|
||||||
glm::vec3 getPickOrigin(const PickResultPointer& pickResult) const override;
|
glm::vec3 getPickOrigin(const PickResultPointer& pickResult) const override;
|
||||||
|
|
|
@ -147,6 +147,14 @@ bool StylusPointer::shouldTrigger(const PickResultPointer& pickResult) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PickResultPointer StylusPointer::getPickResultCopy(const PickResultPointer& pickResult) const {
|
||||||
|
auto stylusPickResult = std::dynamic_pointer_cast<StylusPickResult>(pickResult);
|
||||||
|
if (!stylusPickResult) {
|
||||||
|
return std::make_shared<StylusPickResult>();
|
||||||
|
}
|
||||||
|
return std::make_shared<StylusPickResult>(*stylusPickResult.get());
|
||||||
|
}
|
||||||
|
|
||||||
Pointer::PickedObject StylusPointer::getHoveredObject(const PickResultPointer& pickResult) {
|
Pointer::PickedObject StylusPointer::getHoveredObject(const PickResultPointer& pickResult) {
|
||||||
auto stylusPickResult = std::static_pointer_cast<const StylusPickResult>(pickResult);
|
auto stylusPickResult = std::static_pointer_cast<const StylusPickResult>(pickResult);
|
||||||
if (!stylusPickResult) {
|
if (!stylusPickResult) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ protected:
|
||||||
Buttons getPressedButtons(const PickResultPointer& pickResult) override;
|
Buttons getPressedButtons(const PickResultPointer& pickResult) override;
|
||||||
bool shouldHover(const PickResultPointer& pickResult) override;
|
bool shouldHover(const PickResultPointer& pickResult) override;
|
||||||
bool shouldTrigger(const PickResultPointer& pickResult) override;
|
bool shouldTrigger(const PickResultPointer& pickResult) override;
|
||||||
|
virtual PickResultPointer getPickResultCopy(const PickResultPointer& pickResult) const override;
|
||||||
|
|
||||||
PointerEvent buildPointerEvent(const PickedObject& target, const PickResultPointer& pickResult, const std::string& button = "", bool hover = true) override;
|
PointerEvent buildPointerEvent(const PickedObject& target, const PickResultPointer& pickResult, const std::string& button = "", bool hover = true) override;
|
||||||
|
|
||||||
|
|
|
@ -180,6 +180,14 @@ void WindowScriptingInterface::setPreviousBrowseAssetLocation(const QString& loc
|
||||||
Setting::Handle<QVariant>(LAST_BROWSE_ASSETS_LOCATION_SETTING).set(location);
|
Setting::Handle<QVariant>(LAST_BROWSE_ASSETS_LOCATION_SETTING).set(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WindowScriptingInterface::getInterstitialModeEnabled() const {
|
||||||
|
return DependencyManager::get<NodeList>()->getDomainHandler().getInterstitialModeEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowScriptingInterface::setInterstitialModeEnabled(bool enableInterstitialMode) {
|
||||||
|
DependencyManager::get<NodeList>()->getDomainHandler().setInterstitialModeEnabled(enableInterstitialMode);
|
||||||
|
}
|
||||||
|
|
||||||
bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) {
|
bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
return offscreenUi->isPointOnDesktopWindow(point);
|
return offscreenUi->isPointOnDesktopWindow(point);
|
||||||
|
|
|
@ -49,6 +49,7 @@ class WindowScriptingInterface : public QObject, public Dependency {
|
||||||
Q_PROPERTY(int innerHeight READ getInnerHeight)
|
Q_PROPERTY(int innerHeight READ getInnerHeight)
|
||||||
Q_PROPERTY(int x READ getX)
|
Q_PROPERTY(int x READ getX)
|
||||||
Q_PROPERTY(int y READ getY)
|
Q_PROPERTY(int y READ getY)
|
||||||
|
Q_PROPERTY(bool interstitialModeEnabled READ getInterstitialModeEnabled WRITE setInterstitialModeEnabled)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WindowScriptingInterface();
|
WindowScriptingInterface();
|
||||||
|
@ -758,6 +759,9 @@ private:
|
||||||
QString getPreviousBrowseAssetLocation() const;
|
QString getPreviousBrowseAssetLocation() const;
|
||||||
void setPreviousBrowseAssetLocation(const QString& location);
|
void setPreviousBrowseAssetLocation(const QString& location);
|
||||||
|
|
||||||
|
bool getInterstitialModeEnabled() const;
|
||||||
|
void setInterstitialModeEnabled(bool enableInterstitialMode);
|
||||||
|
|
||||||
void ensureReticleVisible() const;
|
void ensureReticleVisible() const;
|
||||||
|
|
||||||
int createMessageBox(QString title, QString text, int buttons, int defaultButton);
|
int createMessageBox(QString title, QString text, int buttons, int defaultButton);
|
||||||
|
|
|
@ -100,6 +100,13 @@ QList<QAudioDeviceInfo> getAvailableDevices(QAudio::Mode mode) {
|
||||||
|
|
||||||
// now called from a background thread, to keep blocking operations off the audio thread
|
// now called from a background thread, to keep blocking operations off the audio thread
|
||||||
void AudioClient::checkDevices() {
|
void AudioClient::checkDevices() {
|
||||||
|
// Make sure we're not shutting down
|
||||||
|
Lock timerMutex(_checkDevicesMutex);
|
||||||
|
// If we HAVE shut down after we were queued, but prior to execution, early exit
|
||||||
|
if (nullptr == _checkDevicesTimer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto inputDevices = getAvailableDevices(QAudio::AudioInput);
|
auto inputDevices = getAvailableDevices(QAudio::AudioInput);
|
||||||
auto outputDevices = getAvailableDevices(QAudio::AudioOutput);
|
auto outputDevices = getAvailableDevices(QAudio::AudioOutput);
|
||||||
|
|
||||||
|
@ -278,9 +285,6 @@ void AudioClient::customDeleter() {
|
||||||
_shouldRestartInputSetup = false;
|
_shouldRestartInputSetup = false;
|
||||||
#endif
|
#endif
|
||||||
stop();
|
stop();
|
||||||
_checkDevicesTimer->stop();
|
|
||||||
_checkPeakValuesTimer->stop();
|
|
||||||
|
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,12 +657,26 @@ void AudioClient::start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioClient::stop() {
|
void AudioClient::stop() {
|
||||||
|
|
||||||
qCDebug(audioclient) << "AudioClient::stop(), requesting switchInputToAudioDevice() to shut down";
|
qCDebug(audioclient) << "AudioClient::stop(), requesting switchInputToAudioDevice() to shut down";
|
||||||
switchInputToAudioDevice(QAudioDeviceInfo(), true);
|
switchInputToAudioDevice(QAudioDeviceInfo(), true);
|
||||||
|
|
||||||
qCDebug(audioclient) << "AudioClient::stop(), requesting switchOutputToAudioDevice() to shut down";
|
qCDebug(audioclient) << "AudioClient::stop(), requesting switchOutputToAudioDevice() to shut down";
|
||||||
switchOutputToAudioDevice(QAudioDeviceInfo(), true);
|
switchOutputToAudioDevice(QAudioDeviceInfo(), true);
|
||||||
|
|
||||||
|
// Stop triggering the checks
|
||||||
|
QObject::disconnect(_checkPeakValuesTimer, &QTimer::timeout, nullptr, nullptr);
|
||||||
|
QObject::disconnect(_checkDevicesTimer, &QTimer::timeout, nullptr, nullptr);
|
||||||
|
|
||||||
|
// Destruction of the pointers will occur when the parent object (this) is destroyed)
|
||||||
|
{
|
||||||
|
Lock lock(_checkDevicesMutex);
|
||||||
|
_checkDevicesTimer = nullptr;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Lock lock(_checkPeakValuesMutex);
|
||||||
|
_checkPeakValuesTimer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
_checkInputTimer.stop();
|
_checkInputTimer.stop();
|
||||||
disconnect(&_checkInputTimer, &QTimer::timeout, 0, 0);
|
disconnect(&_checkInputTimer, &QTimer::timeout, 0, 0);
|
||||||
|
|
|
@ -447,7 +447,9 @@ private:
|
||||||
bool _shouldRestartInputSetup { true }; // Should we restart the input device because of an unintended stop?
|
bool _shouldRestartInputSetup { true }; // Should we restart the input device because of an unintended stop?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Mutex _checkDevicesMutex;
|
||||||
QTimer* _checkDevicesTimer { nullptr };
|
QTimer* _checkDevicesTimer { nullptr };
|
||||||
|
Mutex _checkPeakValuesMutex;
|
||||||
QTimer* _checkPeakValuesTimer { nullptr };
|
QTimer* _checkPeakValuesTimer { nullptr };
|
||||||
|
|
||||||
bool _isRecording { false };
|
bool _isRecording { false };
|
||||||
|
|
|
@ -40,6 +40,12 @@ void release(IAudioClient* audioClient) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioClient::checkPeakValues() {
|
void AudioClient::checkPeakValues() {
|
||||||
|
// Guard against running during shutdown
|
||||||
|
Lock timerMutex(_checkPeakValuesMutex);
|
||||||
|
if (nullptr == _checkPeakValuesTimer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// prepare the windows environment
|
// prepare the windows environment
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,11 @@ void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundScriptingInterface::SoundScriptingInterface(SharedSoundPointer sound) : _sound(sound) {
|
SoundScriptingInterface::SoundScriptingInterface(const SharedSoundPointer& sound) : _sound(sound) {
|
||||||
QObject::connect(sound.data(), &Sound::ready, this, &SoundScriptingInterface::ready);
|
// During shutdown we can sometimes get an empty sound pointer back
|
||||||
|
if (_sound) {
|
||||||
|
QObject::connect(_sound.data(), &Sound::ready, this, &SoundScriptingInterface::ready);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound::Sound(const QUrl& url, bool isStereo, bool isAmbisonic) :
|
Sound::Sound(const QUrl& url, bool isStereo, bool isAmbisonic) :
|
||||||
|
|
|
@ -105,11 +105,11 @@ class SoundScriptingInterface : public QObject {
|
||||||
Q_PROPERTY(float duration READ getDuration)
|
Q_PROPERTY(float duration READ getDuration)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoundScriptingInterface(SharedSoundPointer sound);
|
SoundScriptingInterface(const SharedSoundPointer& sound);
|
||||||
SharedSoundPointer getSound() { return _sound; }
|
const SharedSoundPointer& getSound() { return _sound; }
|
||||||
|
|
||||||
bool isReady() const { return _sound->isReady(); }
|
bool isReady() const { return _sound ? _sound->isReady() : false; }
|
||||||
float getDuration() { return _sound->getDuration(); }
|
float getDuration() { return _sound ? _sound->getDuration() : 0.0f; }
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when the sound has been downloaded and is ready to be played.
|
* Triggered when the sound has been downloaded and is ready to be played.
|
||||||
|
|
|
@ -66,6 +66,22 @@ void AvatarReplicas::removeReplicas(const QUuid& parentID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<AvatarSharedPointer> AvatarReplicas::takeReplicas(const QUuid& parentID) {
|
||||||
|
std::vector<AvatarSharedPointer> replicas;
|
||||||
|
|
||||||
|
auto it = _replicasMap.find(parentID);
|
||||||
|
|
||||||
|
if (it != _replicasMap.end()) {
|
||||||
|
// take a copy of the replica shared pointers for this parent
|
||||||
|
replicas.swap(it->second);
|
||||||
|
|
||||||
|
// erase the replicas for this parent from our map
|
||||||
|
_replicasMap.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
return replicas;
|
||||||
|
}
|
||||||
|
|
||||||
void AvatarReplicas::processAvatarIdentity(const QUuid& parentID, const QByteArray& identityData, bool& identityChanged, bool& displayNameChanged) {
|
void AvatarReplicas::processAvatarIdentity(const QUuid& parentID, const QByteArray& identityData, bool& identityChanged, bool& displayNameChanged) {
|
||||||
if (_replicasMap.find(parentID) != _replicasMap.end()) {
|
if (_replicasMap.find(parentID) != _replicasMap.end()) {
|
||||||
auto &replicas = _replicasMap[parentID];
|
auto &replicas = _replicasMap[parentID];
|
||||||
|
@ -386,24 +402,31 @@ void AvatarHashMap::processKillAvatar(QSharedPointer<ReceivedMessage> message, S
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarHashMap::removeAvatar(const QUuid& sessionUUID, KillAvatarReason removalReason) {
|
void AvatarHashMap::removeAvatar(const QUuid& sessionUUID, KillAvatarReason removalReason) {
|
||||||
QWriteLocker locker(&_hashLock);
|
std::vector<AvatarSharedPointer> removedAvatars;
|
||||||
|
|
||||||
auto replicaIDs = _replicas.getReplicaIDs(sessionUUID);
|
{
|
||||||
_replicas.removeReplicas(sessionUUID);
|
QWriteLocker locker(&_hashLock);
|
||||||
for (auto id : replicaIDs) {
|
|
||||||
auto removedReplica = _avatarHash.take(id);
|
auto replicas = _replicas.takeReplicas(sessionUUID);
|
||||||
if (removedReplica) {
|
|
||||||
handleRemovedAvatar(removedReplica, removalReason);
|
for (auto& replica : replicas) {
|
||||||
|
auto removedReplica = _avatarHash.take(replica->getID());
|
||||||
|
if (removedReplica) {
|
||||||
|
removedAvatars.push_back(removedReplica);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_pendingAvatars.remove(sessionUUID);
|
||||||
|
auto removedAvatar = _avatarHash.take(sessionUUID);
|
||||||
|
|
||||||
|
if (removedAvatar) {
|
||||||
|
removedAvatars.push_back(removedAvatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_pendingAvatars.remove(sessionUUID);
|
for (auto& removedAvatar: removedAvatars) {
|
||||||
auto removedAvatar = _avatarHash.take(sessionUUID);
|
|
||||||
|
|
||||||
if (removedAvatar) {
|
|
||||||
handleRemovedAvatar(removedAvatar, removalReason);
|
handleRemovedAvatar(removedAvatar, removalReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarHashMap::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason) {
|
void AvatarHashMap::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason) {
|
||||||
|
@ -421,11 +444,18 @@ void AvatarHashMap::sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& ol
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarHashMap::clearOtherAvatars() {
|
void AvatarHashMap::clearOtherAvatars() {
|
||||||
QWriteLocker locker(&_hashLock);
|
QList<AvatarSharedPointer> removedAvatars;
|
||||||
|
|
||||||
for (auto& av : _avatarHash) {
|
{
|
||||||
handleRemovedAvatar(av);
|
QWriteLocker locker(&_hashLock);
|
||||||
|
|
||||||
|
// grab a copy of the current avatars so we can call handleRemoveAvatar for them
|
||||||
|
removedAvatars = _avatarHash.values();
|
||||||
|
|
||||||
|
_avatarHash.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
_avatarHash.clear();
|
for (auto& av : removedAvatars) {
|
||||||
|
handleRemovedAvatar(av);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
void parseDataFromBuffer(const QUuid& parentID, const QByteArray& buffer);
|
void parseDataFromBuffer(const QUuid& parentID, const QByteArray& buffer);
|
||||||
void processAvatarIdentity(const QUuid& parentID, const QByteArray& identityData, bool& identityChanged, bool& displayNameChanged);
|
void processAvatarIdentity(const QUuid& parentID, const QByteArray& identityData, bool& identityChanged, bool& displayNameChanged);
|
||||||
void removeReplicas(const QUuid& parentID);
|
void removeReplicas(const QUuid& parentID);
|
||||||
|
std::vector<AvatarSharedPointer> takeReplicas(const QUuid& parentID);
|
||||||
void processTrait(const QUuid& parentID, AvatarTraits::TraitType traitType, QByteArray traitBinaryData);
|
void processTrait(const QUuid& parentID, AvatarTraits::TraitType traitType, QByteArray traitBinaryData);
|
||||||
void processDeletedTraitInstance(const QUuid& parentID, AvatarTraits::TraitType traitType, AvatarTraits::TraitInstanceID instanceID);
|
void processDeletedTraitInstance(const QUuid& parentID, AvatarTraits::TraitType traitType, AvatarTraits::TraitInstanceID instanceID);
|
||||||
void processTraitInstance(const QUuid& parentID, AvatarTraits::TraitType traitType,
|
void processTraitInstance(const QUuid& parentID, AvatarTraits::TraitType traitType,
|
||||||
|
@ -179,7 +180,7 @@ protected:
|
||||||
bool& isNew);
|
bool& isNew);
|
||||||
virtual AvatarSharedPointer findAvatar(const QUuid& sessionUUID) const; // uses a QReadLocker on the hashLock
|
virtual AvatarSharedPointer findAvatar(const QUuid& sessionUUID) const; // uses a QReadLocker on the hashLock
|
||||||
virtual void removeAvatar(const QUuid& sessionUUID, KillAvatarReason removalReason = KillAvatarReason::NoReason);
|
virtual void removeAvatar(const QUuid& sessionUUID, KillAvatarReason removalReason = KillAvatarReason::NoReason);
|
||||||
|
|
||||||
virtual void handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason = KillAvatarReason::NoReason);
|
virtual void handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason = KillAvatarReason::NoReason);
|
||||||
|
|
||||||
AvatarHash _avatarHash;
|
AvatarHash _avatarHash;
|
||||||
|
|
|
@ -140,8 +140,7 @@ public:
|
||||||
* </table>
|
* </table>
|
||||||
* @typedef {number} location.LookupTrigger
|
* @typedef {number} location.LookupTrigger
|
||||||
*/
|
*/
|
||||||
enum LookupTrigger
|
enum LookupTrigger {
|
||||||
{
|
|
||||||
UserInput,
|
UserInput,
|
||||||
Back,
|
Back,
|
||||||
Forward,
|
Forward,
|
||||||
|
@ -207,9 +206,8 @@ public slots:
|
||||||
// functions and signals that should be exposed are moved to a scripting interface class.
|
// functions and signals that should be exposed are moved to a scripting interface class.
|
||||||
//
|
//
|
||||||
// we currently expect this to be called from NodeList once handleLookupString has been called with a path
|
// we currently expect this to be called from NodeList once handleLookupString has been called with a path
|
||||||
bool goToViewpointForPath(const QString& viewpointString, const QString& pathString) {
|
bool goToViewpointForPath(const QString& viewpointString, const QString& pathString)
|
||||||
return handleViewpoint(viewpointString, false, DomainPathResponse, false, pathString);
|
{ return handleViewpoint(viewpointString, false, DomainPathResponse, false, pathString); }
|
||||||
}
|
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Go back to the previous location in your navigation history, if there is one.
|
* Go back to the previous location in your navigation history, if there is one.
|
||||||
|
@ -231,8 +229,7 @@ public slots:
|
||||||
* location history is correctly maintained.
|
* location history is correctly maintained.
|
||||||
*/
|
*/
|
||||||
void goToLocalSandbox(QString path = "", LookupTrigger trigger = LookupTrigger::StartupFromSettings) {
|
void goToLocalSandbox(QString path = "", LookupTrigger trigger = LookupTrigger::StartupFromSettings) {
|
||||||
handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger);
|
handleUrl(SANDBOX_HIFI_ADDRESS + path, trigger); }
|
||||||
}
|
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Go to the default "welcome" metaverse address.
|
* Go to the default "welcome" metaverse address.
|
||||||
|
@ -364,8 +361,7 @@ signals:
|
||||||
* location.locationChangeRequired.connect(onLocationChangeRequired);
|
* location.locationChangeRequired.connect(onLocationChangeRequired);
|
||||||
*/
|
*/
|
||||||
void locationChangeRequired(const glm::vec3& newPosition,
|
void locationChangeRequired(const glm::vec3& newPosition,
|
||||||
bool hasOrientationChange,
|
bool hasOrientationChange, const glm::quat& newOrientation,
|
||||||
const glm::quat& newOrientation,
|
|
||||||
bool shouldFaceLocation);
|
bool shouldFaceLocation);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
@ -448,11 +444,8 @@ private:
|
||||||
|
|
||||||
bool handleNetworkAddress(const QString& lookupString, LookupTrigger trigger, bool& hostChanged);
|
bool handleNetworkAddress(const QString& lookupString, LookupTrigger trigger, bool& hostChanged);
|
||||||
void handlePath(const QString& path, LookupTrigger trigger, bool wasPathOnly = false);
|
void handlePath(const QString& path, LookupTrigger trigger, bool wasPathOnly = false);
|
||||||
bool handleViewpoint(const QString& viewpointString,
|
bool handleViewpoint(const QString& viewpointString, bool shouldFace, LookupTrigger trigger,
|
||||||
bool shouldFace,
|
bool definitelyPathOnly = false, const QString& pathString = QString());
|
||||||
LookupTrigger trigger,
|
|
||||||
bool definitelyPathOnly = false,
|
|
||||||
const QString& pathString = QString());
|
|
||||||
bool handleUsername(const QString& lookupString);
|
bool handleUsername(const QString& lookupString);
|
||||||
bool handleDomainID(const QString& host);
|
bool handleDomainID(const QString& host);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
|
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
|
||||||
|
#include <shared/QtHelpers.h>
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include <QtCore/QJsonDocument>
|
#include <QtCore/QJsonDocument>
|
||||||
#include <QtCore/QDataStream>
|
#include <QtCore/QDataStream>
|
||||||
|
|
||||||
|
@ -134,6 +138,18 @@ void DomainHandler::hardReset() {
|
||||||
_pendingPath.clear();
|
_pendingPath.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DomainHandler::getInterstitialModeEnabled() const {
|
||||||
|
return _interstitialModeSettingLock.resultWithReadLock<bool>([&] {
|
||||||
|
return _enableInterstitialMode.get();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void DomainHandler::setInterstitialModeEnabled(bool enableInterstitialMode) {
|
||||||
|
_interstitialModeSettingLock.withWriteLock([&] {
|
||||||
|
_enableInterstitialMode.set(enableInterstitialMode);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void DomainHandler::setErrorDomainURL(const QUrl& url) {
|
void DomainHandler::setErrorDomainURL(const QUrl& url) {
|
||||||
_errorDomainURL = url;
|
_errorDomainURL = url;
|
||||||
return;
|
return;
|
||||||
|
@ -340,11 +356,15 @@ void DomainHandler::loadedErrorDomain(std::map<QString, QString> namedPaths) {
|
||||||
DependencyManager::get<AddressManager>()->goToViewpointForPath(viewpoint, QString());
|
DependencyManager::get<AddressManager>()->goToViewpointForPath(viewpoint, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::setRedirectErrorState(QUrl errorUrl, int reasonCode) {
|
void DomainHandler::setRedirectErrorState(QUrl errorUrl, QString reasonMessage, int reasonCode, const QString& extraInfo) {
|
||||||
_errorDomainURL = errorUrl;
|
|
||||||
_lastDomainConnectionError = reasonCode;
|
_lastDomainConnectionError = reasonCode;
|
||||||
_isInErrorState = true;
|
if (getInterstitialModeEnabled()) {
|
||||||
emit redirectToErrorDomainURL(_errorDomainURL);
|
_errorDomainURL = errorUrl;
|
||||||
|
_isInErrorState = true;
|
||||||
|
emit redirectToErrorDomainURL(_errorDomainURL);
|
||||||
|
} else {
|
||||||
|
emit domainConnectionRefused(reasonMessage, reasonCode, extraInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::requestDomainSettings() {
|
void DomainHandler::requestDomainSettings() {
|
||||||
|
@ -485,13 +505,9 @@ void DomainHandler::processDomainServerConnectionDeniedPacket(QSharedPointer<Rec
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo);
|
emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo);
|
||||||
#else
|
#else
|
||||||
if (reasonCode == ConnectionRefusedReason::ProtocolMismatch || reasonCode == ConnectionRefusedReason::NotAuthorized) {
|
|
||||||
// ingest the error - this is a "hard" connection refusal.
|
// ingest the error - this is a "hard" connection refusal.
|
||||||
setRedirectErrorState(_errorDomainURL, (int)reasonCode);
|
setRedirectErrorState(_errorDomainURL, reasonMessage, (int)reasonCode, extraInfo);
|
||||||
} else {
|
|
||||||
emit domainConnectionRefused(reasonMessage, (int)reasonCode, extraInfo);
|
|
||||||
}
|
|
||||||
_lastDomainConnectionError = (int)reasonCode;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
#include <QtNetwork/QHostInfo>
|
#include <QtNetwork/QHostInfo>
|
||||||
|
|
||||||
|
#include <shared/ReadWriteLockable.h>
|
||||||
|
#include <SettingHandle.h>
|
||||||
|
|
||||||
#include "HifiSockAddr.h"
|
#include "HifiSockAddr.h"
|
||||||
#include "NetworkPeer.h"
|
#include "NetworkPeer.h"
|
||||||
#include "NLPacket.h"
|
#include "NLPacket.h"
|
||||||
|
@ -83,6 +86,8 @@ public:
|
||||||
bool isConnected() const { return _isConnected; }
|
bool isConnected() const { return _isConnected; }
|
||||||
void setIsConnected(bool isConnected);
|
void setIsConnected(bool isConnected);
|
||||||
bool isServerless() const { return _domainURL.scheme() != URL_SCHEME_HIFI; }
|
bool isServerless() const { return _domainURL.scheme() != URL_SCHEME_HIFI; }
|
||||||
|
bool getInterstitialModeEnabled() const;
|
||||||
|
void setInterstitialModeEnabled(bool enableInterstitialMode);
|
||||||
|
|
||||||
void connectedToServerless(std::map<QString, QString> namedPaths);
|
void connectedToServerless(std::map<QString, QString> namedPaths);
|
||||||
|
|
||||||
|
@ -171,7 +176,7 @@ public slots:
|
||||||
void processDomainServerConnectionDeniedPacket(QSharedPointer<ReceivedMessage> message);
|
void processDomainServerConnectionDeniedPacket(QSharedPointer<ReceivedMessage> message);
|
||||||
|
|
||||||
// sets domain handler in error state.
|
// sets domain handler in error state.
|
||||||
void setRedirectErrorState(QUrl errorUrl, int reasonCode);
|
void setRedirectErrorState(QUrl errorUrl, QString reasonMessage = "", int reason = -1, const QString& extraInfo = "");
|
||||||
|
|
||||||
bool isInErrorState() { return _isInErrorState; }
|
bool isInErrorState() { return _isInErrorState; }
|
||||||
|
|
||||||
|
@ -224,6 +229,8 @@ private:
|
||||||
QJsonObject _settingsObject;
|
QJsonObject _settingsObject;
|
||||||
QString _pendingPath;
|
QString _pendingPath;
|
||||||
QTimer _settingsTimer;
|
QTimer _settingsTimer;
|
||||||
|
mutable ReadWriteLockable _interstitialModeSettingLock;
|
||||||
|
Setting::Handle<bool> _enableInterstitialMode{ "enableInterstitialMode", false };
|
||||||
|
|
||||||
QSet<QString> _domainConnectionRefusals;
|
QSet<QString> _domainConnectionRefusals;
|
||||||
bool _hasCheckedForAccessToken { false };
|
bool _hasCheckedForAccessToken { false };
|
||||||
|
|
|
@ -68,7 +68,8 @@ void Pointer::update(unsigned int pointerID) {
|
||||||
// This only needs to be a read lock because update won't change any of the properties that can be modified from scripts
|
// This only needs to be a read lock because update won't change any of the properties that can be modified from scripts
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
auto pickResult = getPrevPickResult();
|
auto pickResult = getPrevPickResult();
|
||||||
auto visualPickResult = getVisualPickResult(pickResult);
|
// Pointer needs its own PickResult object so it doesn't modify the cached pick result
|
||||||
|
auto visualPickResult = getVisualPickResult(getPickResultCopy(pickResult));
|
||||||
updateVisuals(visualPickResult);
|
updateVisuals(visualPickResult);
|
||||||
generatePointerEvents(pointerID, visualPickResult);
|
generatePointerEvents(pointerID, visualPickResult);
|
||||||
});
|
});
|
||||||
|
|
|
@ -91,6 +91,7 @@ protected:
|
||||||
|
|
||||||
virtual bool shouldHover(const PickResultPointer& pickResult) { return true; }
|
virtual bool shouldHover(const PickResultPointer& pickResult) { return true; }
|
||||||
virtual bool shouldTrigger(const PickResultPointer& pickResult) { return true; }
|
virtual bool shouldTrigger(const PickResultPointer& pickResult) { return true; }
|
||||||
|
virtual PickResultPointer getPickResultCopy(const PickResultPointer& pickResult) const = 0;
|
||||||
virtual PickResultPointer getVisualPickResult(const PickResultPointer& pickResult) { return pickResult; };
|
virtual PickResultPointer getVisualPickResult(const PickResultPointer& pickResult) { return pickResult; };
|
||||||
|
|
||||||
static const float POINTER_MOVE_DELAY;
|
static const float POINTER_MOVE_DELAY;
|
||||||
|
|
|
@ -37,6 +37,8 @@ namespace gr {
|
||||||
|
|
||||||
#define OUTLINE_STENCIL_MASK 1
|
#define OUTLINE_STENCIL_MASK 1
|
||||||
|
|
||||||
|
extern void initZPassPipelines(ShapePlumber& plumber, gpu::StatePointer state);
|
||||||
|
|
||||||
HighlightRessources::HighlightRessources() {
|
HighlightRessources::HighlightRessources() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +182,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
|
||||||
|
|
||||||
auto maskPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder);
|
auto maskPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder);
|
||||||
auto maskSkinnedPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withSkinned());
|
auto maskSkinnedPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withSkinned());
|
||||||
|
auto maskSkinnedDQPipeline = _shapePlumber->pickPipeline(args, defaultKeyBuilder.withSkinned().withDualQuatSkinned());
|
||||||
|
|
||||||
// Setup camera, projection and viewport for all items
|
// Setup camera, projection and viewport for all items
|
||||||
batch.setViewportTransform(args->_viewport);
|
batch.setViewportTransform(args->_viewport);
|
||||||
|
@ -187,14 +190,17 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
|
||||||
batch.setProjectionJitter(jitter.x, jitter.y);
|
batch.setProjectionJitter(jitter.x, jitter.y);
|
||||||
batch.setViewTransform(viewMat);
|
batch.setViewTransform(viewMat);
|
||||||
|
|
||||||
std::vector<ShapeKey> skinnedShapeKeys{};
|
std::vector<ShapeKey> skinnedShapeKeys;
|
||||||
|
std::vector<ShapeKey> skinnedDQShapeKeys;
|
||||||
|
|
||||||
// Iterate through all inShapes and render the unskinned
|
// Iterate through all inShapes and render the unskinned
|
||||||
args->_shapePipeline = maskPipeline;
|
args->_shapePipeline = maskPipeline;
|
||||||
batch.setPipeline(maskPipeline->pipeline);
|
batch.setPipeline(maskPipeline->pipeline);
|
||||||
for (const auto& items : inShapes) {
|
for (const auto& items : inShapes) {
|
||||||
itemBounds.insert(itemBounds.end(), items.second.begin(), items.second.end());
|
itemBounds.insert(itemBounds.end(), items.second.begin(), items.second.end());
|
||||||
if (items.first.isSkinned()) {
|
if (items.first.isSkinned() && items.first.isDualQuatSkinned()) {
|
||||||
|
skinnedDQShapeKeys.push_back(items.first);
|
||||||
|
} else if (items.first.isSkinned()) {
|
||||||
skinnedShapeKeys.push_back(items.first);
|
skinnedShapeKeys.push_back(items.first);
|
||||||
} else {
|
} else {
|
||||||
renderItems(renderContext, items.second);
|
renderItems(renderContext, items.second);
|
||||||
|
@ -202,10 +208,21 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reiterate to render the skinned
|
// Reiterate to render the skinned
|
||||||
args->_shapePipeline = maskSkinnedPipeline;
|
if (skinnedShapeKeys.size() > 0) {
|
||||||
batch.setPipeline(maskSkinnedPipeline->pipeline);
|
args->_shapePipeline = maskSkinnedPipeline;
|
||||||
for (const auto& key : skinnedShapeKeys) {
|
batch.setPipeline(maskSkinnedPipeline->pipeline);
|
||||||
renderItems(renderContext, inShapes.at(key));
|
for (const auto& key : skinnedShapeKeys) {
|
||||||
|
renderItems(renderContext, inShapes.at(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reiterate to render the DQ skinned
|
||||||
|
if (skinnedDQShapeKeys.size() > 0) {
|
||||||
|
args->_shapePipeline = maskSkinnedDQPipeline;
|
||||||
|
batch.setPipeline(maskSkinnedDQPipeline->pipeline);
|
||||||
|
for (const auto& key : skinnedDQShapeKeys) {
|
||||||
|
renderItems(renderContext, inShapes.at(key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
args->_shapePipeline = nullptr;
|
args->_shapePipeline = nullptr;
|
||||||
|
@ -488,7 +505,7 @@ void DrawHighlightTask::build(JobModel& task, const render::Varying& inputs, ren
|
||||||
state->setDepthTest(true, true, gpu::LESS_EQUAL);
|
state->setDepthTest(true, true, gpu::LESS_EQUAL);
|
||||||
state->setColorWriteMask(false, false, false, false);
|
state->setColorWriteMask(false, false, false, false);
|
||||||
|
|
||||||
initMaskPipelines(*shapePlumber, state);
|
initZPassPipelines(*shapePlumber, state);
|
||||||
}
|
}
|
||||||
auto sharedParameters = std::make_shared<HighlightSharedParameters>();
|
auto sharedParameters = std::make_shared<HighlightSharedParameters>();
|
||||||
|
|
||||||
|
@ -548,16 +565,4 @@ const render::Varying DrawHighlightTask::addSelectItemJobs(JobModel& task, const
|
||||||
const auto selectedMetasAndOpaques = task.addJob<SelectItems>("OpaqueSelection", selectMetaAndOpaqueInput);
|
const auto selectedMetasAndOpaques = task.addJob<SelectItems>("OpaqueSelection", selectMetaAndOpaqueInput);
|
||||||
const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques, selectionName).asVarying();
|
const auto selectItemInput = SelectItems::Inputs(transparents, selectedMetasAndOpaques, selectionName).asVarying();
|
||||||
return task.addJob<SelectItems>("TransparentSelection", selectItemInput);
|
return task.addJob<SelectItems>("TransparentSelection", selectItemInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawHighlightTask::initMaskPipelines(render::ShapePlumber& shapePlumber, gpu::StatePointer state) {
|
|
||||||
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(shader::render_utils::program::model_shadow);
|
|
||||||
shapePlumber.addPipeline(
|
|
||||||
ShapeKey::Filter::Builder().withoutSkinned(),
|
|
||||||
modelProgram, state);
|
|
||||||
|
|
||||||
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(shader::render_utils::program::skin_model_shadow);
|
|
||||||
shapePlumber.addPipeline(
|
|
||||||
ShapeKey::Filter::Builder().withSkinned(),
|
|
||||||
skinProgram, state);
|
|
||||||
}
|
|
|
@ -208,8 +208,6 @@ public:
|
||||||
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs);
|
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static void initMaskPipelines(render::ShapePlumber& plumber, gpu::StatePointer state);
|
|
||||||
static const render::Varying addSelectItemJobs(JobModel& task, const render::Varying& selectionName, const RenderFetchCullSortTask::BucketList& items);
|
static const render::Varying addSelectItemJobs(JobModel& task, const render::Varying& selectionName, const RenderFetchCullSortTask::BucketList& items);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1281,92 +1281,6 @@ QStringList Model::getJointNames() const {
|
||||||
return isActive() ? getFBXGeometry().getJointNames() : QStringList();
|
return isActive() ? getFBXGeometry().getJointNames() : QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
class Blender : public QRunnable {
|
|
||||||
public:
|
|
||||||
|
|
||||||
Blender(ModelPointer model, int blendNumber, const Geometry::WeakPointer& geometry, const QVector<float>& blendshapeCoefficients);
|
|
||||||
|
|
||||||
virtual void run() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
ModelPointer _model;
|
|
||||||
int _blendNumber;
|
|
||||||
Geometry::WeakPointer _geometry;
|
|
||||||
QVector<float> _blendshapeCoefficients;
|
|
||||||
};
|
|
||||||
|
|
||||||
Blender::Blender(ModelPointer model, int blendNumber, const Geometry::WeakPointer& geometry, const QVector<float>& blendshapeCoefficients) :
|
|
||||||
_model(model),
|
|
||||||
_blendNumber(blendNumber),
|
|
||||||
_geometry(geometry),
|
|
||||||
_blendshapeCoefficients(blendshapeCoefficients) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void Blender::run() {
|
|
||||||
QVector<glm::vec3> vertices;
|
|
||||||
QVector<NormalType> normalsAndTangents;
|
|
||||||
if (_model && _model->isLoaded()) {
|
|
||||||
DETAILED_PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } });
|
|
||||||
int offset = 0;
|
|
||||||
int normalsAndTangentsOffset = 0;
|
|
||||||
auto meshes = _model->getFBXGeometry().meshes;
|
|
||||||
int meshIndex = 0;
|
|
||||||
foreach (const FBXMesh& mesh, meshes) {
|
|
||||||
auto modelMeshNormalsAndTangents = _model->_normalsAndTangents.find(meshIndex++);
|
|
||||||
if (mesh.blendshapes.isEmpty() || modelMeshNormalsAndTangents == _model->_normalsAndTangents.end()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
vertices += mesh.vertices;
|
|
||||||
normalsAndTangents += modelMeshNormalsAndTangents->second;
|
|
||||||
glm::vec3* meshVertices = vertices.data() + offset;
|
|
||||||
NormalType* meshNormalsAndTangents = normalsAndTangents.data() + normalsAndTangentsOffset;
|
|
||||||
offset += mesh.vertices.size();
|
|
||||||
normalsAndTangentsOffset += modelMeshNormalsAndTangents->second.size();
|
|
||||||
const float NORMAL_COEFFICIENT_SCALE = 0.01f;
|
|
||||||
for (int i = 0, n = qMin(_blendshapeCoefficients.size(), mesh.blendshapes.size()); i < n; i++) {
|
|
||||||
float vertexCoefficient = _blendshapeCoefficients.at(i);
|
|
||||||
const float EPSILON = 0.0001f;
|
|
||||||
if (vertexCoefficient < EPSILON) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
float normalCoefficient = vertexCoefficient * NORMAL_COEFFICIENT_SCALE;
|
|
||||||
const FBXBlendshape& blendshape = mesh.blendshapes.at(i);
|
|
||||||
tbb::parallel_for(tbb::blocked_range<int>(0, blendshape.indices.size()), [&](const tbb::blocked_range<int>& range) {
|
|
||||||
for (auto j = range.begin(); j < range.end(); j++) {
|
|
||||||
int index = blendshape.indices.at(j);
|
|
||||||
meshVertices[index] += blendshape.vertices.at(j) * vertexCoefficient;
|
|
||||||
|
|
||||||
glm::vec3 normal = mesh.normals.at(index) + blendshape.normals.at(j) * normalCoefficient;
|
|
||||||
glm::vec3 tangent;
|
|
||||||
if (index < mesh.tangents.size()) {
|
|
||||||
tangent = mesh.tangents.at(index);
|
|
||||||
if ((int)j < blendshape.tangents.size()) {
|
|
||||||
tangent += blendshape.tangents.at(j) * normalCoefficient;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if FBX_PACK_NORMALS
|
|
||||||
glm::uint32 finalNormal;
|
|
||||||
glm::uint32 finalTangent;
|
|
||||||
buffer_helpers::packNormalAndTangent(normal, tangent, finalNormal, finalTangent);
|
|
||||||
#else
|
|
||||||
const auto& finalNormal = normal;
|
|
||||||
const auto& finalTangent = tangent;
|
|
||||||
#endif
|
|
||||||
meshNormalsAndTangents[2 * index] = finalNormal;
|
|
||||||
meshNormalsAndTangents[2 * index + 1] = finalTangent;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// post the result to the ModelBlender, which will dispatch to the model if still alive
|
|
||||||
QMetaObject::invokeMethod(DependencyManager::get<ModelBlender>().data(), "setBlendedVertices",
|
|
||||||
Q_ARG(ModelPointer, _model), Q_ARG(int, _blendNumber), Q_ARG(QVector<glm::vec3>, vertices),
|
|
||||||
Q_ARG(QVector<NormalType>, normalsAndTangents));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Model::setScaleToFit(bool scaleToFit, const glm::vec3& dimensions, bool forceRescale) {
|
void Model::setScaleToFit(bool scaleToFit, const glm::vec3& dimensions, bool forceRescale) {
|
||||||
if (forceRescale || _scaleToFit != scaleToFit || _scaleToFitDimensions != dimensions) {
|
if (forceRescale || _scaleToFit != scaleToFit || _scaleToFitDimensions != dimensions) {
|
||||||
_scaleToFit = scaleToFit;
|
_scaleToFit = scaleToFit;
|
||||||
|
@ -1531,44 +1445,6 @@ void Model::updateClusterMatrices() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Model::maybeStartBlender() {
|
|
||||||
if (isLoaded()) {
|
|
||||||
const FBXGeometry& fbxGeometry = getFBXGeometry();
|
|
||||||
if (fbxGeometry.hasBlendedMeshes()) {
|
|
||||||
QThreadPool::globalInstance()->start(new Blender(getThisPointer(), ++_blendNumber, _renderGeometry, _blendshapeCoefficients));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Model::setBlendedVertices(int blendNumber, const QVector<glm::vec3>& vertices, const QVector<NormalType>& normalsAndTangents) {
|
|
||||||
if (!isLoaded() || blendNumber < _appliedBlendNumber || !_blendedVertexBuffersInitialized) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_appliedBlendNumber = blendNumber;
|
|
||||||
const FBXGeometry& fbxGeometry = getFBXGeometry();
|
|
||||||
int index = 0;
|
|
||||||
int normalAndTangentIndex = 0;
|
|
||||||
for (int i = 0; i < fbxGeometry.meshes.size(); i++) {
|
|
||||||
const FBXMesh& mesh = fbxGeometry.meshes.at(i);
|
|
||||||
auto meshNormalsAndTangents = _normalsAndTangents.find(i);
|
|
||||||
const auto& buffer = _blendedVertexBuffers.find(i);
|
|
||||||
if (mesh.blendshapes.isEmpty() || meshNormalsAndTangents == _normalsAndTangents.end() || buffer == _blendedVertexBuffers.end()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto vertexCount = mesh.vertices.size();
|
|
||||||
const auto verticesSize = vertexCount * sizeof(glm::vec3);
|
|
||||||
buffer->second->resize(mesh.vertices.size() * sizeof(glm::vec3) + meshNormalsAndTangents->second.size() * sizeof(NormalType));
|
|
||||||
buffer->second->setSubData(0, verticesSize, (gpu::Byte*) vertices.constData() + index * sizeof(glm::vec3));
|
|
||||||
buffer->second->setSubData(verticesSize, meshNormalsAndTangents->second.size() * sizeof(NormalType), (const gpu::Byte*) normalsAndTangents.data() + normalAndTangentIndex * sizeof(NormalType));
|
|
||||||
|
|
||||||
index += vertexCount;
|
|
||||||
normalAndTangentIndex += meshNormalsAndTangents->second.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Model::deleteGeometry() {
|
void Model::deleteGeometry() {
|
||||||
_deleteGeometryCounter++;
|
_deleteGeometryCounter++;
|
||||||
_blendedVertexBuffers.clear();
|
_blendedVertexBuffers.clear();
|
||||||
|
@ -1605,42 +1481,6 @@ const render::ItemIDs& Model::fetchRenderItemIDs() const {
|
||||||
return _modelMeshRenderItemIDs;
|
return _modelMeshRenderItemIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::initializeBlendshapes(const FBXMesh& mesh, int index) {
|
|
||||||
_blendedVertexBuffers[index] = std::make_shared<gpu::Buffer>();
|
|
||||||
QVector<NormalType> normalsAndTangents;
|
|
||||||
normalsAndTangents.resize(2 * mesh.normals.size());
|
|
||||||
|
|
||||||
// Interleave normals and tangents
|
|
||||||
// Parallel version for performance
|
|
||||||
tbb::parallel_for(tbb::blocked_range<int>(0, mesh.normals.size()), [&](const tbb::blocked_range<int>& range) {
|
|
||||||
auto normalsRange = std::make_pair(mesh.normals.begin() + range.begin(), mesh.normals.begin() + range.end());
|
|
||||||
auto tangentsRange = std::make_pair(mesh.tangents.begin() + range.begin(), mesh.tangents.begin() + range.end());
|
|
||||||
auto normalsAndTangentsIt = normalsAndTangents.begin() + 2 * range.begin();
|
|
||||||
|
|
||||||
for (auto normalIt = normalsRange.first, tangentIt = tangentsRange.first;
|
|
||||||
normalIt != normalsRange.second;
|
|
||||||
++normalIt, ++tangentIt) {
|
|
||||||
#if FBX_PACK_NORMALS
|
|
||||||
glm::uint32 finalNormal;
|
|
||||||
glm::uint32 finalTangent;
|
|
||||||
buffer_helpers::packNormalAndTangent(*normalIt, *tangentIt, finalNormal, finalTangent);
|
|
||||||
#else
|
|
||||||
const auto& finalNormal = *normalIt;
|
|
||||||
const auto& finalTangent = *tangentIt;
|
|
||||||
#endif
|
|
||||||
*normalsAndTangentsIt = finalNormal;
|
|
||||||
++normalsAndTangentsIt;
|
|
||||||
*normalsAndTangentsIt = finalTangent;
|
|
||||||
++normalsAndTangentsIt;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const auto verticesSize = mesh.vertices.size() * sizeof(glm::vec3);
|
|
||||||
_blendedVertexBuffers[index]->resize(mesh.vertices.size() * sizeof(glm::vec3) + normalsAndTangents.size() * sizeof(NormalType));
|
|
||||||
_blendedVertexBuffers[index]->setSubData(0, verticesSize, (const gpu::Byte*) mesh.vertices.constData());
|
|
||||||
_blendedVertexBuffers[index]->setSubData(verticesSize, normalsAndTangents.size() * sizeof(NormalType), (const gpu::Byte*) normalsAndTangents.data());
|
|
||||||
_normalsAndTangents[index] = normalsAndTangents;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Model::createRenderItemSet() {
|
void Model::createRenderItemSet() {
|
||||||
assert(isLoaded());
|
assert(isLoaded());
|
||||||
const auto& meshes = _renderGeometry->getMeshes();
|
const auto& meshes = _renderGeometry->getMeshes();
|
||||||
|
@ -1774,6 +1614,164 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Blender : public QRunnable {
|
||||||
|
public:
|
||||||
|
|
||||||
|
Blender(ModelPointer model, int blendNumber, const Geometry::WeakPointer& geometry, const QVector<float>& blendshapeCoefficients);
|
||||||
|
|
||||||
|
virtual void run() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
ModelPointer _model;
|
||||||
|
int _blendNumber;
|
||||||
|
Geometry::WeakPointer _geometry;
|
||||||
|
QVector<float> _blendshapeCoefficients;
|
||||||
|
};
|
||||||
|
|
||||||
|
Blender::Blender(ModelPointer model, int blendNumber, const Geometry::WeakPointer& geometry, const QVector<float>& blendshapeCoefficients) :
|
||||||
|
_model(model),
|
||||||
|
_blendNumber(blendNumber),
|
||||||
|
_geometry(geometry),
|
||||||
|
_blendshapeCoefficients(blendshapeCoefficients) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void Blender::run() {
|
||||||
|
QVector<glm::vec3> vertices;
|
||||||
|
QVector<NormalType> normalsAndTangents;
|
||||||
|
if (_model && _model->isLoaded()) {
|
||||||
|
DETAILED_PROFILE_RANGE_EX(simulation_animation, __FUNCTION__, 0xFFFF0000, 0, { { "url", _model->getURL().toString() } });
|
||||||
|
int offset = 0;
|
||||||
|
int normalsAndTangentsOffset = 0;
|
||||||
|
auto meshes = _model->getFBXGeometry().meshes;
|
||||||
|
int meshIndex = 0;
|
||||||
|
foreach(const FBXMesh& mesh, meshes) {
|
||||||
|
auto modelMeshNormalsAndTangents = _model->_normalsAndTangents.find(meshIndex++);
|
||||||
|
if (mesh.blendshapes.isEmpty() || modelMeshNormalsAndTangents == _model->_normalsAndTangents.end()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
vertices += mesh.vertices;
|
||||||
|
normalsAndTangents += modelMeshNormalsAndTangents->second;
|
||||||
|
glm::vec3* meshVertices = vertices.data() + offset;
|
||||||
|
NormalType* meshNormalsAndTangents = normalsAndTangents.data() + normalsAndTangentsOffset;
|
||||||
|
offset += mesh.vertices.size();
|
||||||
|
normalsAndTangentsOffset += modelMeshNormalsAndTangents->second.size();
|
||||||
|
const float NORMAL_COEFFICIENT_SCALE = 0.01f;
|
||||||
|
for (int i = 0, n = qMin(_blendshapeCoefficients.size(), mesh.blendshapes.size()); i < n; i++) {
|
||||||
|
float vertexCoefficient = _blendshapeCoefficients.at(i);
|
||||||
|
const float EPSILON = 0.0001f;
|
||||||
|
if (vertexCoefficient < EPSILON) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
float normalCoefficient = vertexCoefficient * NORMAL_COEFFICIENT_SCALE;
|
||||||
|
const FBXBlendshape& blendshape = mesh.blendshapes.at(i);
|
||||||
|
tbb::parallel_for(tbb::blocked_range<int>(0, blendshape.indices.size()), [&](const tbb::blocked_range<int>& range) {
|
||||||
|
for (auto j = range.begin(); j < range.end(); j++) {
|
||||||
|
int index = blendshape.indices.at(j);
|
||||||
|
meshVertices[index] += blendshape.vertices.at(j) * vertexCoefficient;
|
||||||
|
|
||||||
|
glm::vec3 normal = mesh.normals.at(index) + blendshape.normals.at(j) * normalCoefficient;
|
||||||
|
glm::vec3 tangent;
|
||||||
|
if (index < mesh.tangents.size()) {
|
||||||
|
tangent = mesh.tangents.at(index);
|
||||||
|
if ((int)j < blendshape.tangents.size()) {
|
||||||
|
tangent += blendshape.tangents.at(j) * normalCoefficient;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if FBX_PACK_NORMALS
|
||||||
|
glm::uint32 finalNormal;
|
||||||
|
glm::uint32 finalTangent;
|
||||||
|
buffer_helpers::packNormalAndTangent(normal, tangent, finalNormal, finalTangent);
|
||||||
|
#else
|
||||||
|
const auto& finalNormal = normal;
|
||||||
|
const auto& finalTangent = tangent;
|
||||||
|
#endif
|
||||||
|
meshNormalsAndTangents[2 * index] = finalNormal;
|
||||||
|
meshNormalsAndTangents[2 * index + 1] = finalTangent;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// post the result to the ModelBlender, which will dispatch to the model if still alive
|
||||||
|
QMetaObject::invokeMethod(DependencyManager::get<ModelBlender>().data(), "setBlendedVertices",
|
||||||
|
Q_ARG(ModelPointer, _model), Q_ARG(int, _blendNumber), Q_ARG(QVector<glm::vec3>, vertices),
|
||||||
|
Q_ARG(QVector<NormalType>, normalsAndTangents));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Model::maybeStartBlender() {
|
||||||
|
if (isLoaded()) {
|
||||||
|
QThreadPool::globalInstance()->start(new Blender(getThisPointer(), ++_blendNumber, _renderGeometry, _blendshapeCoefficients));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Model::setBlendedVertices(int blendNumber, const QVector<glm::vec3>& vertices, const QVector<NormalType>& normalsAndTangents) {
|
||||||
|
if (!isLoaded() || blendNumber < _appliedBlendNumber || !_blendedVertexBuffersInitialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_appliedBlendNumber = blendNumber;
|
||||||
|
const FBXGeometry& fbxGeometry = getFBXGeometry();
|
||||||
|
int index = 0;
|
||||||
|
int normalAndTangentIndex = 0;
|
||||||
|
for (int i = 0; i < fbxGeometry.meshes.size(); i++) {
|
||||||
|
const FBXMesh& mesh = fbxGeometry.meshes.at(i);
|
||||||
|
auto meshNormalsAndTangents = _normalsAndTangents.find(i);
|
||||||
|
const auto& buffer = _blendedVertexBuffers.find(i);
|
||||||
|
if (mesh.blendshapes.isEmpty() || meshNormalsAndTangents == _normalsAndTangents.end() || buffer == _blendedVertexBuffers.end()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto vertexCount = mesh.vertices.size();
|
||||||
|
const auto verticesSize = vertexCount * sizeof(glm::vec3);
|
||||||
|
buffer->second->resize(mesh.vertices.size() * sizeof(glm::vec3) + meshNormalsAndTangents->second.size() * sizeof(NormalType));
|
||||||
|
buffer->second->setSubData(0, verticesSize, (gpu::Byte*) vertices.constData() + index * sizeof(glm::vec3));
|
||||||
|
buffer->second->setSubData(verticesSize, meshNormalsAndTangents->second.size() * sizeof(NormalType), (const gpu::Byte*) normalsAndTangents.data() + normalAndTangentIndex * sizeof(NormalType));
|
||||||
|
|
||||||
|
index += vertexCount;
|
||||||
|
normalAndTangentIndex += meshNormalsAndTangents->second.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Model::initializeBlendshapes(const FBXMesh& mesh, int index) {
|
||||||
|
_blendedVertexBuffers[index] = std::make_shared<gpu::Buffer>();
|
||||||
|
QVector<NormalType> normalsAndTangents;
|
||||||
|
normalsAndTangents.resize(2 * mesh.normals.size());
|
||||||
|
|
||||||
|
// Interleave normals and tangents
|
||||||
|
// Parallel version for performance
|
||||||
|
tbb::parallel_for(tbb::blocked_range<int>(0, mesh.normals.size()), [&](const tbb::blocked_range<int>& range) {
|
||||||
|
auto normalsRange = std::make_pair(mesh.normals.begin() + range.begin(), mesh.normals.begin() + range.end());
|
||||||
|
auto tangentsRange = std::make_pair(mesh.tangents.begin() + range.begin(), mesh.tangents.begin() + range.end());
|
||||||
|
auto normalsAndTangentsIt = normalsAndTangents.begin() + 2 * range.begin();
|
||||||
|
|
||||||
|
for (auto normalIt = normalsRange.first, tangentIt = tangentsRange.first;
|
||||||
|
normalIt != normalsRange.second;
|
||||||
|
++normalIt, ++tangentIt) {
|
||||||
|
#if FBX_PACK_NORMALS
|
||||||
|
glm::uint32 finalNormal;
|
||||||
|
glm::uint32 finalTangent;
|
||||||
|
buffer_helpers::packNormalAndTangent(*normalIt, *tangentIt, finalNormal, finalTangent);
|
||||||
|
#else
|
||||||
|
const auto& finalNormal = *normalIt;
|
||||||
|
const auto& finalTangent = *tangentIt;
|
||||||
|
#endif
|
||||||
|
*normalsAndTangentsIt = finalNormal;
|
||||||
|
++normalsAndTangentsIt;
|
||||||
|
*normalsAndTangentsIt = finalTangent;
|
||||||
|
++normalsAndTangentsIt;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const auto verticesSize = mesh.vertices.size() * sizeof(glm::vec3);
|
||||||
|
_blendedVertexBuffers[index]->resize(mesh.vertices.size() * sizeof(glm::vec3) + normalsAndTangents.size() * sizeof(NormalType));
|
||||||
|
_blendedVertexBuffers[index]->setSubData(0, verticesSize, (const gpu::Byte*) mesh.vertices.constData());
|
||||||
|
_blendedVertexBuffers[index]->setSubData(verticesSize, normalsAndTangents.size() * sizeof(NormalType), (const gpu::Byte*) normalsAndTangents.data());
|
||||||
|
_normalsAndTangents[index] = normalsAndTangents;
|
||||||
|
}
|
||||||
|
|
||||||
ModelBlender::ModelBlender() :
|
ModelBlender::ModelBlender() :
|
||||||
_pendingBlenders(0) {
|
_pendingBlenders(0) {
|
||||||
}
|
}
|
||||||
|
@ -1783,14 +1781,23 @@ ModelBlender::~ModelBlender() {
|
||||||
|
|
||||||
void ModelBlender::noteRequiresBlend(ModelPointer model) {
|
void ModelBlender::noteRequiresBlend(ModelPointer model) {
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
if (_pendingBlenders < QThread::idealThreadCount()) {
|
if (_modelsRequiringBlendsSet.find(model) == _modelsRequiringBlendsSet.end()) {
|
||||||
if (model->maybeStartBlender()) {
|
_modelsRequiringBlendsQueue.push(model);
|
||||||
_pendingBlenders++;
|
_modelsRequiringBlendsSet.insert(model);
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_modelsRequiringBlends.insert(model);
|
if (_pendingBlenders < QThread::idealThreadCount()) {
|
||||||
|
while (!_modelsRequiringBlendsQueue.empty()) {
|
||||||
|
auto weakPtr = _modelsRequiringBlendsQueue.front();
|
||||||
|
_modelsRequiringBlendsQueue.pop();
|
||||||
|
_modelsRequiringBlendsSet.erase(weakPtr);
|
||||||
|
ModelPointer nextModel = weakPtr.lock();
|
||||||
|
if (nextModel && nextModel->maybeStartBlender()) {
|
||||||
|
_pendingBlenders++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelBlender::setBlendedVertices(ModelPointer model, int blendNumber, QVector<glm::vec3> vertices, QVector<NormalType> normalsAndTangents) {
|
void ModelBlender::setBlendedVertices(ModelPointer model, int blendNumber, QVector<glm::vec3> vertices, QVector<NormalType> normalsAndTangents) {
|
||||||
|
@ -1800,20 +1807,15 @@ void ModelBlender::setBlendedVertices(ModelPointer model, int blendNumber, QVect
|
||||||
{
|
{
|
||||||
Lock lock(_mutex);
|
Lock lock(_mutex);
|
||||||
_pendingBlenders--;
|
_pendingBlenders--;
|
||||||
_modelsRequiringBlends.erase(model);
|
while (!_modelsRequiringBlendsQueue.empty()) {
|
||||||
std::set<ModelWeakPointer, std::owner_less<ModelWeakPointer>> modelsToErase;
|
auto weakPtr = _modelsRequiringBlendsQueue.front();
|
||||||
for (auto i = _modelsRequiringBlends.begin(); i != _modelsRequiringBlends.end(); i++) {
|
_modelsRequiringBlendsQueue.pop();
|
||||||
auto weakPtr = *i;
|
_modelsRequiringBlendsSet.erase(weakPtr);
|
||||||
ModelPointer nextModel = weakPtr.lock();
|
ModelPointer nextModel = weakPtr.lock();
|
||||||
if (nextModel && nextModel->maybeStartBlender()) {
|
if (nextModel && nextModel->maybeStartBlender()) {
|
||||||
_pendingBlenders++;
|
_pendingBlenders++;
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
modelsToErase.insert(weakPtr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto& weakPtr : modelsToErase) {
|
|
||||||
_modelsRequiringBlends.erase(weakPtr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -530,7 +530,8 @@ private:
|
||||||
ModelBlender();
|
ModelBlender();
|
||||||
virtual ~ModelBlender();
|
virtual ~ModelBlender();
|
||||||
|
|
||||||
std::set<ModelWeakPointer, std::owner_less<ModelWeakPointer>> _modelsRequiringBlends;
|
std::queue<ModelWeakPointer> _modelsRequiringBlendsQueue;
|
||||||
|
std::set<ModelWeakPointer, std::owner_less<ModelWeakPointer>> _modelsRequiringBlendsSet;
|
||||||
int _pendingBlenders;
|
int _pendingBlenders;
|
||||||
Mutex _mutex;
|
Mutex _mutex;
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <set>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
|
@ -127,82 +127,10 @@ void usecTimestampNowForceClockSkew(qint64 clockSkew) {
|
||||||
::usecTimestampNowAdjust = clockSkew;
|
::usecTimestampNowAdjust = clockSkew;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::atomic<qint64> TIME_REFERENCE { 0 }; // in usec
|
|
||||||
static std::once_flag usecTimestampNowIsInitialized;
|
|
||||||
static QElapsedTimer timestampTimer;
|
|
||||||
|
|
||||||
quint64 usecTimestampNow(bool wantDebug) {
|
quint64 usecTimestampNow(bool wantDebug) {
|
||||||
std::call_once(usecTimestampNowIsInitialized, [&] {
|
using namespace std::chrono;
|
||||||
TIME_REFERENCE = QDateTime::currentMSecsSinceEpoch() * USECS_PER_MSEC; // ms to usec
|
static const auto unixEpoch = system_clock::from_time_t(0);
|
||||||
timestampTimer.start();
|
return duration_cast<microseconds>(system_clock::now() - unixEpoch).count() + usecTimestampNowAdjust;
|
||||||
});
|
|
||||||
|
|
||||||
quint64 now;
|
|
||||||
quint64 nsecsElapsed = timestampTimer.nsecsElapsed();
|
|
||||||
quint64 usecsElapsed = nsecsElapsed / NSECS_PER_USEC; // nsec to usec
|
|
||||||
|
|
||||||
// QElapsedTimer may not advance if the CPU has gone to sleep. In which case it
|
|
||||||
// will begin to deviate from real time. We detect that here, and reset if necessary
|
|
||||||
quint64 msecsCurrentTime = QDateTime::currentMSecsSinceEpoch();
|
|
||||||
quint64 msecsEstimate = (TIME_REFERENCE + usecsElapsed) / USECS_PER_MSEC; // usecs to msecs
|
|
||||||
int possibleSkew = msecsEstimate - msecsCurrentTime;
|
|
||||||
const int TOLERANCE = 10 * MSECS_PER_SECOND; // up to 10 seconds of skew is tolerated
|
|
||||||
if (abs(possibleSkew) > TOLERANCE) {
|
|
||||||
// reset our TIME_REFERENCE and timer
|
|
||||||
TIME_REFERENCE = QDateTime::currentMSecsSinceEpoch() * USECS_PER_MSEC; // ms to usec
|
|
||||||
timestampTimer.restart();
|
|
||||||
now = TIME_REFERENCE + ::usecTimestampNowAdjust;
|
|
||||||
|
|
||||||
if (wantDebug) {
|
|
||||||
qCDebug(shared) << "usecTimestampNow() - resetting QElapsedTimer. ";
|
|
||||||
qCDebug(shared) << " msecsCurrentTime:" << msecsCurrentTime;
|
|
||||||
qCDebug(shared) << " msecsEstimate:" << msecsEstimate;
|
|
||||||
qCDebug(shared) << " possibleSkew:" << possibleSkew;
|
|
||||||
qCDebug(shared) << " TOLERANCE:" << TOLERANCE;
|
|
||||||
|
|
||||||
qCDebug(shared) << " nsecsElapsed:" << nsecsElapsed;
|
|
||||||
qCDebug(shared) << " usecsElapsed:" << usecsElapsed;
|
|
||||||
|
|
||||||
QDateTime currentLocalTime = QDateTime::currentDateTime();
|
|
||||||
|
|
||||||
quint64 msecsNow = now / 1000; // usecs to msecs
|
|
||||||
QDateTime nowAsString;
|
|
||||||
nowAsString.setMSecsSinceEpoch(msecsNow);
|
|
||||||
|
|
||||||
qCDebug(shared) << " now:" << now;
|
|
||||||
qCDebug(shared) << " msecsNow:" << msecsNow;
|
|
||||||
|
|
||||||
qCDebug(shared) << " nowAsString:" << nowAsString.toString("yyyy-MM-dd hh:mm:ss.zzz");
|
|
||||||
qCDebug(shared) << " currentLocalTime:" << currentLocalTime.toString("yyyy-MM-dd hh:mm:ss.zzz");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
now = TIME_REFERENCE + usecsElapsed + ::usecTimestampNowAdjust;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wantDebug) {
|
|
||||||
QDateTime currentLocalTime = QDateTime::currentDateTime();
|
|
||||||
|
|
||||||
quint64 msecsNow = now / 1000; // usecs to msecs
|
|
||||||
QDateTime nowAsString;
|
|
||||||
nowAsString.setMSecsSinceEpoch(msecsNow);
|
|
||||||
|
|
||||||
quint64 msecsTimeReference = TIME_REFERENCE / 1000; // usecs to msecs
|
|
||||||
QDateTime timeReferenceAsString;
|
|
||||||
timeReferenceAsString.setMSecsSinceEpoch(msecsTimeReference);
|
|
||||||
|
|
||||||
qCDebug(shared) << "usecTimestampNow() - details... ";
|
|
||||||
qCDebug(shared) << " TIME_REFERENCE:" << TIME_REFERENCE;
|
|
||||||
qCDebug(shared) << " timeReferenceAsString:" << timeReferenceAsString.toString("yyyy-MM-dd hh:mm:ss.zzz");
|
|
||||||
qCDebug(shared) << " usecTimestampNowAdjust:" << usecTimestampNowAdjust;
|
|
||||||
qCDebug(shared) << " nsecsElapsed:" << nsecsElapsed;
|
|
||||||
qCDebug(shared) << " usecsElapsed:" << usecsElapsed;
|
|
||||||
qCDebug(shared) << " now:" << now;
|
|
||||||
qCDebug(shared) << " msecsNow:" << msecsNow;
|
|
||||||
qCDebug(shared) << " nowAsString:" << nowAsString.toString("yyyy-MM-dd hh:mm:ss.zzz");
|
|
||||||
qCDebug(shared) << " currentLocalTime:" << currentLocalTime.toString("yyyy-MM-dd hh:mm:ss.zzz");
|
|
||||||
}
|
|
||||||
|
|
||||||
return now;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float secTimestampNow() {
|
float secTimestampNow() {
|
||||||
|
|
|
@ -19,7 +19,7 @@ module.exports = {
|
||||||
|
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
request: function (options, callback) { // cb(error, responseOfCorrectContentType) of url. A subset of npm request.
|
request: function (options, callback) { // cb(error, responseOfCorrectContentType) of url. A subset of npm request.
|
||||||
var httpRequest = new XMLHttpRequest(), key;
|
var httpRequest = new XMLHttpRequest(), key;
|
||||||
// QT bug: apparently doesn't handle onload. Workaround using readyState.
|
// QT bug: apparently doesn't handle onload. Workaround using readyState.
|
||||||
httpRequest.onreadystatechange = function () {
|
httpRequest.onreadystatechange = function () {
|
||||||
var READY_STATE_DONE = 4;
|
var READY_STATE_DONE = 4;
|
||||||
|
@ -72,7 +72,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
httpRequest.open(options.method, options.uri, true);
|
httpRequest.open(options.method, options.uri, true);
|
||||||
httpRequest.send(options.body || null);
|
httpRequest.send(options.body || null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ===========================================================================================
|
// ===========================================================================================
|
||||||
|
|
|
@ -474,9 +474,6 @@ function fromQml(message) {
|
||||||
Window.location = "hifi://BankOfHighFidelity";
|
Window.location = "hifi://BankOfHighFidelity";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'wallet_availableUpdatesReceived':
|
|
||||||
// NOP
|
|
||||||
break;
|
|
||||||
case 'http.request':
|
case 'http.request':
|
||||||
// Handled elsewhere, don't log.
|
// Handled elsewhere, don't log.
|
||||||
break;
|
break;
|
||||||
|
@ -491,15 +488,77 @@ function walletOpened() {
|
||||||
Controller.mouseMoveEvent.connect(handleMouseMoveEvent);
|
Controller.mouseMoveEvent.connect(handleMouseMoveEvent);
|
||||||
triggerMapping.enable();
|
triggerMapping.enable();
|
||||||
triggerPressMapping.enable();
|
triggerPressMapping.enable();
|
||||||
|
shouldShowDot = false;
|
||||||
|
ui.messagesWaiting(shouldShowDot);
|
||||||
}
|
}
|
||||||
|
|
||||||
function walletClosed() {
|
function walletClosed() {
|
||||||
off();
|
off();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
function notificationDataProcessPage(data) {
|
||||||
// Manage the connection between the button and the window.
|
return data.data.history;
|
||||||
//
|
}
|
||||||
|
|
||||||
|
var shouldShowDot = false;
|
||||||
|
function notificationPollCallback(historyArray) {
|
||||||
|
if (!ui.isOpen) {
|
||||||
|
var notificationCount = historyArray.length;
|
||||||
|
shouldShowDot = shouldShowDot || notificationCount > 0;
|
||||||
|
ui.messagesWaiting(shouldShowDot);
|
||||||
|
|
||||||
|
if (notificationCount > 0) {
|
||||||
|
var message;
|
||||||
|
if (!ui.notificationInitialCallbackMade) {
|
||||||
|
message = "You have " + notificationCount + " unread wallet " +
|
||||||
|
"transaction" + (notificationCount === 1 ? "" : "s") + ". Open WALLET to see all activity.";
|
||||||
|
ui.notificationDisplayBanner(message);
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < notificationCount; i++) {
|
||||||
|
message = '"' + (historyArray[i].message) + '" ' +
|
||||||
|
"Open WALLET to see all activity.";
|
||||||
|
ui.notificationDisplayBanner(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isReturnedDataEmpty(data) {
|
||||||
|
var historyArray = data.data.history;
|
||||||
|
return historyArray.length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var DEVELOPER_MENU = "Developer";
|
||||||
|
var MARKETPLACE_ITEM_TESTER_LABEL = "Marketplace Item Tester";
|
||||||
|
var MARKETPLACE_ITEM_TESTER_QML_SOURCE = "hifi/commerce/marketplaceItemTester/MarketplaceItemTester.qml";
|
||||||
|
function installMarketplaceItemTester() {
|
||||||
|
if (!Menu.menuExists(DEVELOPER_MENU)) {
|
||||||
|
Menu.addMenu(DEVELOPER_MENU);
|
||||||
|
}
|
||||||
|
if (!Menu.menuItemExists(DEVELOPER_MENU, MARKETPLACE_ITEM_TESTER_LABEL)) {
|
||||||
|
Menu.addMenuItem({
|
||||||
|
menuName: DEVELOPER_MENU,
|
||||||
|
menuItemName: MARKETPLACE_ITEM_TESTER_LABEL,
|
||||||
|
isCheckable: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Menu.menuItemEvent.connect(function (menuItem) {
|
||||||
|
if (menuItem === MARKETPLACE_ITEM_TESTER_LABEL) {
|
||||||
|
ui.open(MARKETPLACE_ITEM_TESTER_QML_SOURCE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function uninstallMarketplaceItemTester() {
|
||||||
|
if (Menu.menuExists(DEVELOPER_MENU) &&
|
||||||
|
Menu.menuItemExists(DEVELOPER_MENU, MARKETPLACE_ITEM_TESTER_LABEL)
|
||||||
|
) {
|
||||||
|
Menu.removeMenuItem(DEVELOPER_MENU, MARKETPLACE_ITEM_TESTER_LABEL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var BUTTON_NAME = "WALLET";
|
var BUTTON_NAME = "WALLET";
|
||||||
var WALLET_QML_SOURCE = "hifi/commerce/wallet/Wallet.qml";
|
var WALLET_QML_SOURCE = "hifi/commerce/wallet/Wallet.qml";
|
||||||
var ui;
|
var ui;
|
||||||
|
@ -510,10 +569,18 @@ function startup() {
|
||||||
home: WALLET_QML_SOURCE,
|
home: WALLET_QML_SOURCE,
|
||||||
onOpened: walletOpened,
|
onOpened: walletOpened,
|
||||||
onClosed: walletClosed,
|
onClosed: walletClosed,
|
||||||
onMessage: fromQml
|
onMessage: fromQml,
|
||||||
|
notificationPollEndpoint: "/api/v1/commerce/history?per_page=10",
|
||||||
|
notificationPollTimeoutMs: 300000,
|
||||||
|
notificationDataProcessPage: notificationDataProcessPage,
|
||||||
|
notificationPollCallback: notificationPollCallback,
|
||||||
|
notificationPollStopPaginatingConditionMet: isReturnedDataEmpty,
|
||||||
|
notificationPollCaresAboutSince: true
|
||||||
});
|
});
|
||||||
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
||||||
|
installMarketplaceItemTester();
|
||||||
}
|
}
|
||||||
|
|
||||||
var isUpdateOverlaysWired = false;
|
var isUpdateOverlaysWired = false;
|
||||||
function off() {
|
function off() {
|
||||||
Users.usernameFromIDReply.disconnect(usernameFromIDReply);
|
Users.usernameFromIDReply.disconnect(usernameFromIDReply);
|
||||||
|
@ -528,9 +595,11 @@ function off() {
|
||||||
}
|
}
|
||||||
removeOverlays();
|
removeOverlays();
|
||||||
}
|
}
|
||||||
|
|
||||||
function shutdown() {
|
function shutdown() {
|
||||||
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
|
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
|
||||||
deleteSendMoneyParticleEffect();
|
deleteSendMoneyParticleEffect();
|
||||||
|
uninstallMarketplaceItemTester();
|
||||||
off();
|
off();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
this.highlightedEntities = [];
|
this.highlightedEntities = [];
|
||||||
|
|
||||||
this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
|
this.parameters = dispatcherUtils.makeDispatcherModuleParameters(
|
||||||
120,
|
480,
|
||||||
this.hand === dispatcherUtils.RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
this.hand === dispatcherUtils.RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
||||||
[],
|
[],
|
||||||
100);
|
100);
|
||||||
|
|
|
@ -29,7 +29,7 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
this.reticleMaxY;
|
this.reticleMaxY;
|
||||||
|
|
||||||
this.parameters = makeDispatcherModuleParameters(
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
200,
|
160,
|
||||||
this.hand === RIGHT_HAND ? ["rightHand", "rightHandEquip", "rightHandTrigger"] : ["leftHand", "leftHandEquip", "leftHandTrigger"],
|
this.hand === RIGHT_HAND ? ["rightHand", "rightHandEquip", "rightHandTrigger"] : ["leftHand", "leftHandEquip", "leftHandTrigger"],
|
||||||
[],
|
[],
|
||||||
100,
|
100,
|
||||||
|
|
|
@ -21,7 +21,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
this.disableModules = false;
|
this.disableModules = false;
|
||||||
var NO_HAND_LASER = -1; // Invalid hand parameter so that default laser is not displayed.
|
var NO_HAND_LASER = -1; // Invalid hand parameter so that default laser is not displayed.
|
||||||
this.parameters = makeDispatcherModuleParameters(
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
240, // Not too high otherwise the tablet laser doesn't work.
|
200, // Not too high otherwise the tablet laser doesn't work.
|
||||||
this.hand === RIGHT_HAND
|
this.hand === RIGHT_HAND
|
||||||
? ["rightHand", "rightHandEquip", "rightHandTrigger"]
|
? ["rightHand", "rightHandEquip", "rightHandTrigger"]
|
||||||
: ["leftHand", "leftHandEquip", "leftHandTrigger"],
|
: ["leftHand", "leftHandEquip", "leftHandTrigger"],
|
||||||
|
|
|
@ -26,7 +26,7 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
|
||||||
this.hapticTargetID = null;
|
this.hapticTargetID = null;
|
||||||
|
|
||||||
this.parameters = makeDispatcherModuleParameters(
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
140,
|
500,
|
||||||
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
||||||
[],
|
[],
|
||||||
100);
|
100);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
this.hyperlink = "";
|
this.hyperlink = "";
|
||||||
|
|
||||||
this.parameters = makeDispatcherModuleParameters(
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
125,
|
485,
|
||||||
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
||||||
[],
|
[],
|
||||||
100);
|
100);
|
||||||
|
|
|
@ -57,7 +57,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
this.cloneAllowed = true;
|
this.cloneAllowed = true;
|
||||||
|
|
||||||
this.parameters = makeDispatcherModuleParameters(
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
140,
|
500,
|
||||||
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"],
|
||||||
[],
|
[],
|
||||||
100);
|
100);
|
||||||
|
|
|
@ -29,7 +29,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
this.startSent = false;
|
this.startSent = false;
|
||||||
|
|
||||||
this.parameters = makeDispatcherModuleParameters(
|
this.parameters = makeDispatcherModuleParameters(
|
||||||
120,
|
480,
|
||||||
this.hand === RIGHT_HAND ? ["rightHandTrigger", "rightHand"] : ["leftHandTrigger", "leftHand"],
|
this.hand === RIGHT_HAND ? ["rightHandTrigger", "rightHand"] : ["leftHandTrigger", "leftHand"],
|
||||||
[],
|
[],
|
||||||
100);
|
100);
|
||||||
|
|
|
@ -121,7 +121,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE;
|
controllerData.triggerValues[this.otherHand] <= TRIGGER_OFF_VALUE;
|
||||||
var allowThisModule = !otherModuleRunning || isTriggerPressed;
|
var allowThisModule = !otherModuleRunning || isTriggerPressed;
|
||||||
|
|
||||||
if (allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed, false)) {
|
if ((allowThisModule && this.isPointingAtTriggerable(controllerData, isTriggerPressed, false)) && !this.grabModuleWantsNearbyOverlay(controllerData)) {
|
||||||
this.updateAllwaysOn();
|
this.updateAllwaysOn();
|
||||||
if (isTriggerPressed) {
|
if (isTriggerPressed) {
|
||||||
this.dominantHandOverride = true; // Override dominant hand.
|
this.dominantHandOverride = true; // Override dominant hand.
|
||||||
|
|
|
@ -20,13 +20,14 @@ var AppUi = Script.require('appUi');
|
||||||
Script.include("/~/system/libraries/gridTool.js");
|
Script.include("/~/system/libraries/gridTool.js");
|
||||||
Script.include("/~/system/libraries/connectionUtils.js");
|
Script.include("/~/system/libraries/connectionUtils.js");
|
||||||
|
|
||||||
var METAVERSE_SERVER_URL = Account.metaverseServerURL;
|
|
||||||
var MARKETPLACES_URL = Script.resolvePath("../html/marketplaces.html");
|
|
||||||
var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js");
|
|
||||||
var MARKETPLACE_CHECKOUT_QML_PATH = "hifi/commerce/checkout/Checkout.qml";
|
var MARKETPLACE_CHECKOUT_QML_PATH = "hifi/commerce/checkout/Checkout.qml";
|
||||||
|
var MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH = "hifi/commerce/inspectionCertificate/InspectionCertificate.qml";
|
||||||
|
var MARKETPLACE_ITEM_TESTER_QML_PATH = "hifi/commerce/marketplaceItemTester/MarketplaceItemTester.qml";
|
||||||
var MARKETPLACE_PURCHASES_QML_PATH = "hifi/commerce/purchases/Purchases.qml";
|
var MARKETPLACE_PURCHASES_QML_PATH = "hifi/commerce/purchases/Purchases.qml";
|
||||||
var MARKETPLACE_WALLET_QML_PATH = "hifi/commerce/wallet/Wallet.qml";
|
var MARKETPLACE_WALLET_QML_PATH = "hifi/commerce/wallet/Wallet.qml";
|
||||||
var MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH = "hifi/commerce/inspectionCertificate/InspectionCertificate.qml";
|
var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js");
|
||||||
|
var MARKETPLACES_URL = Script.resolvePath("../html/marketplaces.html");
|
||||||
|
var METAVERSE_SERVER_URL = Account.metaverseServerURL;
|
||||||
var REZZING_SOUND = SoundCache.getSound(Script.resolvePath("../assets/sounds/rezzing.wav"));
|
var REZZING_SOUND = SoundCache.getSound(Script.resolvePath("../assets/sounds/rezzing.wav"));
|
||||||
|
|
||||||
// Event bridge messages.
|
// Event bridge messages.
|
||||||
|
@ -137,7 +138,6 @@ function onUsernameChanged() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var userHasUpdates = false;
|
|
||||||
function sendCommerceSettings() {
|
function sendCommerceSettings() {
|
||||||
ui.sendToHtml({
|
ui.sendToHtml({
|
||||||
type: "marketplaces",
|
type: "marketplaces",
|
||||||
|
@ -147,7 +147,7 @@ function sendCommerceSettings() {
|
||||||
userIsLoggedIn: Account.loggedIn,
|
userIsLoggedIn: Account.loggedIn,
|
||||||
walletNeedsSetup: Wallet.walletStatus === 1,
|
walletNeedsSetup: Wallet.walletStatus === 1,
|
||||||
metaverseServerURL: Account.metaverseServerURL,
|
metaverseServerURL: Account.metaverseServerURL,
|
||||||
messagesWaiting: userHasUpdates
|
messagesWaiting: shouldShowDot
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -756,7 +756,7 @@ function deleteSendAssetParticleEffect() {
|
||||||
}
|
}
|
||||||
sendAssetRecipient = null;
|
sendAssetRecipient = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var savedDisablePreviewOption = Menu.isOptionChecked("Disable Preview");
|
var savedDisablePreviewOption = Menu.isOptionChecked("Disable Preview");
|
||||||
var UI_FADE_TIMEOUT_MS = 150;
|
var UI_FADE_TIMEOUT_MS = 150;
|
||||||
function maybeEnableHMDPreview() {
|
function maybeEnableHMDPreview() {
|
||||||
|
@ -768,6 +768,13 @@ function maybeEnableHMDPreview() {
|
||||||
}, UI_FADE_TIMEOUT_MS);
|
}, UI_FADE_TIMEOUT_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var resourceObjectsInTest = [];
|
||||||
|
function signalNewResourceObjectInTest(resourceObject) {
|
||||||
|
ui.tablet.sendToQml({
|
||||||
|
method: "newResourceObjectInTest",
|
||||||
|
resourceObject: resourceObject });
|
||||||
|
}
|
||||||
|
|
||||||
var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
if (message.messageSrc === "HTML") {
|
if (message.messageSrc === "HTML") {
|
||||||
return;
|
return;
|
||||||
|
@ -817,8 +824,20 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
break;
|
break;
|
||||||
case 'checkout_rezClicked':
|
case 'checkout_rezClicked':
|
||||||
case 'purchases_rezClicked':
|
case 'purchases_rezClicked':
|
||||||
|
case 'tester_rezClicked':
|
||||||
rezEntity(message.itemHref, message.itemType);
|
rezEntity(message.itemHref, message.itemType);
|
||||||
break;
|
break;
|
||||||
|
case 'tester_newResourceObject':
|
||||||
|
var resourceObject = message.resourceObject;
|
||||||
|
resourceObjectsInTest[resourceObject.id] = resourceObject;
|
||||||
|
signalNewResourceObjectInTest(resourceObject);
|
||||||
|
break;
|
||||||
|
case 'tester_updateResourceObjectAssetType':
|
||||||
|
resourceObjectsInTest[message.objectId].assetType = message.assetType;
|
||||||
|
break;
|
||||||
|
case 'tester_deleteResourceObject':
|
||||||
|
delete resourceObjectsInTest[message.objectId];
|
||||||
|
break;
|
||||||
case 'header_marketplaceImageClicked':
|
case 'header_marketplaceImageClicked':
|
||||||
case 'purchases_backClicked':
|
case 'purchases_backClicked':
|
||||||
ui.open(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
ui.open(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
|
@ -841,10 +860,6 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
openLoginWindow();
|
openLoginWindow();
|
||||||
break;
|
break;
|
||||||
case 'disableHmdPreview':
|
case 'disableHmdPreview':
|
||||||
if (!savedDisablePreviewOption) {
|
|
||||||
savedDisablePreviewOption = Menu.isOptionChecked("Disable Preview");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!savedDisablePreviewOption) {
|
if (!savedDisablePreviewOption) {
|
||||||
DesktopPreviewProvider.setPreviewDisabledReason("SECURE_SCREEN");
|
DesktopPreviewProvider.setPreviewDisabledReason("SECURE_SCREEN");
|
||||||
Menu.setIsOptionChecked("Disable Preview", true);
|
Menu.setIsOptionChecked("Disable Preview", true);
|
||||||
|
@ -908,10 +923,9 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
removeOverlays();
|
removeOverlays();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'wallet_availableUpdatesReceived':
|
|
||||||
case 'purchases_availableUpdatesReceived':
|
case 'purchases_availableUpdatesReceived':
|
||||||
userHasUpdates = message.numUpdates > 0;
|
shouldShowDot = message.numUpdates > 0;
|
||||||
ui.messagesWaiting(userHasUpdates);
|
ui.messagesWaiting(shouldShowDot && !ui.isOpen);
|
||||||
break;
|
break;
|
||||||
case 'purchases_updateWearables':
|
case 'purchases_updateWearables':
|
||||||
var currentlyWornWearables = [];
|
var currentlyWornWearables = [];
|
||||||
|
@ -962,34 +976,65 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function pushResourceObjectsInTest() {
|
||||||
|
var maxObjectId = -1;
|
||||||
|
for (var objectId in resourceObjectsInTest) {
|
||||||
|
signalNewResourceObjectInTest(resourceObjectsInTest[objectId]);
|
||||||
|
maxObjectId = (maxObjectId < objectId) ? parseInt(objectId) : maxObjectId;
|
||||||
|
}
|
||||||
|
// N.B. Thinking about removing the following sendToQml? Be sure
|
||||||
|
// that the marketplace item tester QML has heard from us, at least
|
||||||
|
// so that it can indicate to the user that all of the resoruce
|
||||||
|
// objects in test have been transmitted to it.
|
||||||
|
ui.tablet.sendToQml({ method: "nextObjectIdInTest", id: maxObjectId + 1 });
|
||||||
|
}
|
||||||
|
|
||||||
// Function Name: onTabletScreenChanged()
|
// Function Name: onTabletScreenChanged()
|
||||||
//
|
//
|
||||||
// Description:
|
// Description:
|
||||||
// -Called when the TabletScriptingInterface::screenChanged() signal is emitted. The "type" argument can be either the string
|
// -Called when the TabletScriptingInterface::screenChanged() signal is emitted. The "type" argument can be either the string
|
||||||
// value of "Home", "Web", "Menu", "QML", or "Closed". The "url" argument is only valid for Web and QML.
|
// value of "Home", "Web", "Menu", "QML", or "Closed". The "url" argument is only valid for Web and QML.
|
||||||
var onMarketplaceScreen = false;
|
|
||||||
var onWalletScreen = false;
|
|
||||||
var onCommerceScreen = false;
|
var onCommerceScreen = false;
|
||||||
var onInspectionCertificateScreen = false;
|
var onInspectionCertificateScreen = false;
|
||||||
|
var onMarketplaceItemTesterScreen = false;
|
||||||
|
var onMarketplaceScreen = false;
|
||||||
|
var onWalletScreen = false;
|
||||||
var onTabletScreenChanged = function onTabletScreenChanged(type, url) {
|
var onTabletScreenChanged = function onTabletScreenChanged(type, url) {
|
||||||
ui.setCurrentVisibleScreenMetadata(type, url);
|
ui.setCurrentVisibleScreenMetadata(type, url);
|
||||||
onMarketplaceScreen = type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1;
|
onMarketplaceScreen = type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1;
|
||||||
onInspectionCertificateScreen = type === "QML" && url.indexOf(MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH) !== -1;
|
onInspectionCertificateScreen = type === "QML" && url.indexOf(MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH) !== -1;
|
||||||
var onWalletScreenNow = url.indexOf(MARKETPLACE_WALLET_QML_PATH) !== -1;
|
var onWalletScreenNow = url.indexOf(MARKETPLACE_WALLET_QML_PATH) !== -1;
|
||||||
var onCommerceScreenNow = type === "QML" &&
|
var onCommerceScreenNow = type === "QML" && (
|
||||||
(url.indexOf(MARKETPLACE_CHECKOUT_QML_PATH) !== -1 || url === MARKETPLACE_PURCHASES_QML_PATH ||
|
url.indexOf(MARKETPLACE_CHECKOUT_QML_PATH) !== -1 ||
|
||||||
onInspectionCertificateScreen);
|
url === MARKETPLACE_PURCHASES_QML_PATH ||
|
||||||
|
url.indexOf(MARKETPLACE_INSPECTIONCERTIFICATE_QML_PATH) !== -1);
|
||||||
|
var onMarketplaceItemTesterScreenNow = (
|
||||||
|
url.indexOf(MARKETPLACE_ITEM_TESTER_QML_PATH) !== -1 ||
|
||||||
|
url === MARKETPLACE_ITEM_TESTER_QML_PATH);
|
||||||
|
|
||||||
// exiting wallet or commerce screen
|
if ((!onWalletScreenNow && onWalletScreen) ||
|
||||||
if ((!onWalletScreenNow && onWalletScreen) || (!onCommerceScreenNow && onCommerceScreen)) {
|
(!onCommerceScreenNow && onCommerceScreen) ||
|
||||||
|
(!onMarketplaceItemTesterScreenNow && onMarketplaceScreen)
|
||||||
|
) {
|
||||||
|
// exiting wallet, commerce, or marketplace item tester screen
|
||||||
maybeEnableHMDPreview();
|
maybeEnableHMDPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
onCommerceScreen = onCommerceScreenNow;
|
onCommerceScreen = onCommerceScreenNow;
|
||||||
onWalletScreen = onWalletScreenNow;
|
onWalletScreen = onWalletScreenNow;
|
||||||
wireQmlEventBridge(onMarketplaceScreen || onCommerceScreen || onWalletScreen);
|
onMarketplaceItemTesterScreen = onMarketplaceItemTesterScreenNow;
|
||||||
|
|
||||||
|
wireQmlEventBridge(
|
||||||
|
onMarketplaceScreen ||
|
||||||
|
onCommerceScreen ||
|
||||||
|
onWalletScreen ||
|
||||||
|
onMarketplaceItemTesterScreen);
|
||||||
|
|
||||||
if (url === MARKETPLACE_PURCHASES_QML_PATH) {
|
if (url === MARKETPLACE_PURCHASES_QML_PATH) {
|
||||||
|
// FIXME? Is there a race condition here in which the event
|
||||||
|
// bridge may not be up yet? If so, Script.setTimeout(..., 750)
|
||||||
|
// may help avoid the condition.
|
||||||
ui.tablet.sendToQml({
|
ui.tablet.sendToQml({
|
||||||
method: 'updatePurchases',
|
method: 'updatePurchases',
|
||||||
referrerURL: referrerURL,
|
referrerURL: referrerURL,
|
||||||
|
@ -1026,13 +1071,53 @@ var onTabletScreenChanged = function onTabletScreenChanged(type, url) {
|
||||||
});
|
});
|
||||||
off();
|
off();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (onMarketplaceItemTesterScreen) {
|
||||||
|
// Why setTimeout? The QML event bridge, wired above, requires a
|
||||||
|
// variable amount of time to come up, in practice less than
|
||||||
|
// 750ms.
|
||||||
|
Script.setTimeout(pushResourceObjectsInTest, 750);
|
||||||
|
}
|
||||||
|
|
||||||
console.debug(ui.buttonName + " app reports: Tablet screen changed.\nNew screen type: " + type +
|
console.debug(ui.buttonName + " app reports: Tablet screen changed.\nNew screen type: " + type +
|
||||||
"\nNew screen URL: " + url + "\nCurrent app open status: " + ui.isOpen + "\n");
|
"\nNew screen URL: " + url + "\nCurrent app open status: " + ui.isOpen + "\n");
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
function notificationDataProcessPage(data) {
|
||||||
// Manage the connection between the button and the window.
|
return data.data.updates;
|
||||||
//
|
}
|
||||||
|
|
||||||
|
var shouldShowDot = false;
|
||||||
|
function notificationPollCallback(updatesArray) {
|
||||||
|
shouldShowDot = shouldShowDot || updatesArray.length > 0;
|
||||||
|
ui.messagesWaiting(shouldShowDot && !ui.isOpen);
|
||||||
|
|
||||||
|
if (updatesArray.length > 0) {
|
||||||
|
var message;
|
||||||
|
if (!ui.notificationInitialCallbackMade) {
|
||||||
|
message = updatesArray.length + " of your purchased items " +
|
||||||
|
(updatesArray.length === 1 ? "has an update " : "have updates ") +
|
||||||
|
"available. Open MARKET to update.";
|
||||||
|
ui.notificationDisplayBanner(message);
|
||||||
|
|
||||||
|
ui.notificationPollCaresAboutSince = true;
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < updatesArray.length; i++) {
|
||||||
|
message = "Update available for \"" +
|
||||||
|
updatesArray[i].base_item_title + "\"." +
|
||||||
|
"Open MARKET to update.";
|
||||||
|
ui.notificationDisplayBanner(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isReturnedDataEmpty(data) {
|
||||||
|
var historyArray = data.data.updates;
|
||||||
|
return historyArray.length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var BUTTON_NAME = "MARKET";
|
var BUTTON_NAME = "MARKET";
|
||||||
var MARKETPLACE_URL = METAVERSE_SERVER_URL + "/marketplace";
|
var MARKETPLACE_URL = METAVERSE_SERVER_URL + "/marketplace";
|
||||||
var MARKETPLACE_URL_INITIAL = MARKETPLACE_URL + "?"; // Append "?" to signal injected script that it's the initial page.
|
var MARKETPLACE_URL_INITIAL = MARKETPLACE_URL + "?"; // Append "?" to signal injected script that it's the initial page.
|
||||||
|
@ -1044,7 +1129,13 @@ function startup() {
|
||||||
inject: MARKETPLACES_INJECT_SCRIPT_URL,
|
inject: MARKETPLACES_INJECT_SCRIPT_URL,
|
||||||
home: MARKETPLACE_URL_INITIAL,
|
home: MARKETPLACE_URL_INITIAL,
|
||||||
onScreenChanged: onTabletScreenChanged,
|
onScreenChanged: onTabletScreenChanged,
|
||||||
onMessage: onQmlMessageReceived
|
onMessage: onQmlMessageReceived,
|
||||||
|
notificationPollEndpoint: "/api/v1/commerce/available_updates?per_page=10",
|
||||||
|
notificationPollTimeoutMs: 300000,
|
||||||
|
notificationDataProcessPage: notificationDataProcessPage,
|
||||||
|
notificationPollCallback: notificationPollCallback,
|
||||||
|
notificationPollStopPaginatingConditionMet: isReturnedDataEmpty,
|
||||||
|
notificationPollCaresAboutSince: false // Changes to true after first poll
|
||||||
});
|
});
|
||||||
ContextOverlay.contextOverlayClicked.connect(openInspectionCertificateQML);
|
ContextOverlay.contextOverlayClicked.connect(openInspectionCertificateQML);
|
||||||
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
|
||||||
|
|
|
@ -823,46 +823,40 @@ function notificationDataProcessPage(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var shouldShowDot = false;
|
var shouldShowDot = false;
|
||||||
var storedOnlineUsersArray = [];
|
var pingPong = false;
|
||||||
|
var storedOnlineUsers = {};
|
||||||
function notificationPollCallback(connectionsArray) {
|
function notificationPollCallback(connectionsArray) {
|
||||||
//
|
//
|
||||||
// START logic for handling online/offline user changes
|
// START logic for handling online/offline user changes
|
||||||
//
|
//
|
||||||
var i, j;
|
pingPong = !pingPong;
|
||||||
var newlyOnlineConnectionsArray = [];
|
var newOnlineUsers = 0;
|
||||||
for (i = 0; i < connectionsArray.length; i++) {
|
var message;
|
||||||
var currentUser = connectionsArray[i];
|
|
||||||
|
|
||||||
if (connectionsArray[i].online) {
|
connectionsArray.forEach(function (user) {
|
||||||
var indexOfStoredOnlineUser = -1;
|
var stored = storedOnlineUsers[user.username];
|
||||||
for (j = 0; j < storedOnlineUsersArray.length; j++) {
|
var storedOrNew = stored || user;
|
||||||
if (currentUser.username === storedOnlineUsersArray[j].username) {
|
storedOrNew.pingPong = pingPong;
|
||||||
indexOfStoredOnlineUser = j;
|
if (stored) {
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// If the user record isn't already presesnt inside `storedOnlineUsersArray`...
|
newOnlineUsers++;
|
||||||
if (indexOfStoredOnlineUser < 0) {
|
storedOnlineUsers[user.username] = user;
|
||||||
storedOnlineUsersArray.push(currentUser);
|
|
||||||
newlyOnlineConnectionsArray.push(currentUser);
|
if (!ui.isOpen && ui.notificationInitialCallbackMade) {
|
||||||
}
|
message = user.username + " is available in " +
|
||||||
} else {
|
user.location.root.name + ". Open PEOPLE to join them.";
|
||||||
var indexOfOfflineUser = -1;
|
ui.notificationDisplayBanner(message);
|
||||||
for (j = 0; j < storedOnlineUsersArray.length; j++) {
|
}
|
||||||
if (currentUser.username === storedOnlineUsersArray[j].username) {
|
});
|
||||||
indexOfOfflineUser = j;
|
var key;
|
||||||
break;
|
for (key in storedOnlineUsers) {
|
||||||
}
|
if (storedOnlineUsers[key].pingPong !== pingPong) {
|
||||||
}
|
delete storedOnlineUsers[key];
|
||||||
if (indexOfOfflineUser >= 0) {
|
|
||||||
storedOnlineUsersArray.splice(indexOfOfflineUser);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If there's new data, the light should turn on.
|
shouldShowDot = newOnlineUsers > 0 || (Object.keys(storedOnlineUsers).length > 0 && shouldShowDot);
|
||||||
// If the light is already on and you have connections online, the light should stay on.
|
|
||||||
// In all other cases, the light should turn off or stay off.
|
|
||||||
shouldShowDot = newlyOnlineConnectionsArray.length > 0 || (storedOnlineUsersArray.length > 0 && shouldShowDot);
|
|
||||||
//
|
//
|
||||||
// END logic for handling online/offline user changes
|
// END logic for handling online/offline user changes
|
||||||
//
|
//
|
||||||
|
@ -874,19 +868,10 @@ function notificationPollCallback(connectionsArray) {
|
||||||
shouldShowDot: shouldShowDot
|
shouldShowDot: shouldShowDot
|
||||||
});
|
});
|
||||||
|
|
||||||
if (newlyOnlineConnectionsArray.length > 0) {
|
if (newOnlineUsers > 0 && !ui.notificationInitialCallbackMade) {
|
||||||
var message;
|
message = newOnlineUsers + " of your connections " +
|
||||||
if (!ui.notificationInitialCallbackMade) {
|
(newOnlineUsers === 1 ? "is" : "are") + " available online. Open PEOPLE to join them.";
|
||||||
message = newlyOnlineConnectionsArray.length + " of your connections " +
|
ui.notificationDisplayBanner(message);
|
||||||
(newlyOnlineConnectionsArray.length === 1 ? "is" : "are") + " online. Open PEOPLE to join them!";
|
|
||||||
ui.notificationDisplayBanner(message);
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < newlyOnlineConnectionsArray.length; i++) {
|
|
||||||
message = newlyOnlineConnectionsArray[i].username + " is available in " +
|
|
||||||
newlyOnlineConnectionsArray[i].location.root.name + ". Open PEOPLE to join them!";
|
|
||||||
ui.notificationDisplayBanner(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -904,7 +889,7 @@ function startup() {
|
||||||
onOpened: palOpened,
|
onOpened: palOpened,
|
||||||
onClosed: off,
|
onClosed: off,
|
||||||
onMessage: fromQml,
|
onMessage: fromQml,
|
||||||
notificationPollEndpoint: "/api/v1/users?filter=connections&per_page=10",
|
notificationPollEndpoint: "/api/v1/users?filter=connections&status=online&per_page=10",
|
||||||
notificationPollTimeoutMs: 60000,
|
notificationPollTimeoutMs: 60000,
|
||||||
notificationDataProcessPage: notificationDataProcessPage,
|
notificationDataProcessPage: notificationDataProcessPage,
|
||||||
notificationPollCallback: notificationPollCallback,
|
notificationPollCallback: notificationPollCallback,
|
||||||
|
|
|
@ -15,118 +15,121 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
(function () { // BEGIN LOCAL_SCOPE
|
(function () { // BEGIN LOCAL_SCOPE
|
||||||
var request = Script.require('request').request;
|
|
||||||
var AppUi = Script.require('appUi');
|
var AppUi = Script.require('appUi');
|
||||||
var DEBUG = false;
|
|
||||||
function debug() {
|
|
||||||
if (!DEBUG) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
print('tablet-goto.js:', [].map.call(arguments, JSON.stringify));
|
|
||||||
}
|
|
||||||
|
|
||||||
var stories = {}, pingPong = false;
|
|
||||||
function expire(id) {
|
|
||||||
var options = {
|
|
||||||
uri: Account.metaverseServerURL + '/api/v1/user_stories/' + id,
|
|
||||||
method: 'PUT',
|
|
||||||
json: true,
|
|
||||||
body: {expire: "true"}
|
|
||||||
};
|
|
||||||
request(options, function (error, response) {
|
|
||||||
debug('expired story', options, 'error:', error, 'response:', response);
|
|
||||||
if (error || (response.status !== 'success')) {
|
|
||||||
print("ERROR expiring story: ", error || response.status);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var PER_PAGE_DEBUG = 10;
|
|
||||||
var PER_PAGE_NORMAL = 100;
|
|
||||||
function pollForAnnouncements() {
|
|
||||||
// We could bail now if !Account.isLoggedIn(), but what if we someday have system-wide announcments?
|
|
||||||
var actions = 'announcement';
|
|
||||||
var count = DEBUG ? PER_PAGE_DEBUG : PER_PAGE_NORMAL;
|
|
||||||
var options = [
|
|
||||||
'now=' + new Date().toISOString(),
|
|
||||||
'include_actions=' + actions,
|
|
||||||
'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'),
|
|
||||||
'require_online=true',
|
|
||||||
'protocol=' + encodeURIComponent(Window.protocolSignature()),
|
|
||||||
'per_page=' + count
|
|
||||||
];
|
|
||||||
var url = Account.metaverseServerURL + '/api/v1/user_stories?' + options.join('&');
|
|
||||||
request({
|
|
||||||
uri: url
|
|
||||||
}, function (error, data) {
|
|
||||||
debug(url, error, data);
|
|
||||||
if (error || (data.status !== 'success')) {
|
|
||||||
print("Error: unable to get", url, error || data.status);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var didNotify = false, key;
|
|
||||||
pingPong = !pingPong;
|
|
||||||
data.user_stories.forEach(function (story) {
|
|
||||||
var stored = stories[story.id], storedOrNew = stored || story;
|
|
||||||
debug('story exists:', !!stored, storedOrNew);
|
|
||||||
if ((storedOrNew.username === Account.username) && (storedOrNew.place_name !== location.placename)) {
|
|
||||||
if (storedOrNew.audience === 'for_connections') { // Only expire if we haven't already done so.
|
|
||||||
expire(story.id);
|
|
||||||
}
|
|
||||||
return; // before marking
|
|
||||||
}
|
|
||||||
storedOrNew.pingPong = pingPong;
|
|
||||||
if (stored) { // already seen
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
stories[story.id] = story;
|
|
||||||
var message = story.username + " " + story.action_string + " in " +
|
|
||||||
story.place_name + ". Open GOTO to join them.";
|
|
||||||
Window.displayAnnouncement(message);
|
|
||||||
didNotify = true;
|
|
||||||
});
|
|
||||||
for (key in stories) { // Any story we were tracking that was not marked, has expired.
|
|
||||||
if (stories[key].pingPong !== pingPong) {
|
|
||||||
debug('removing story', key);
|
|
||||||
delete stories[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (didNotify) {
|
|
||||||
ui.messagesWaiting(true);
|
|
||||||
if (HMD.isHandControllerAvailable()) {
|
|
||||||
var STRENGTH = 1.0, DURATION_MS = 60, HAND = 2; // both hands
|
|
||||||
Controller.triggerHapticPulse(STRENGTH, DURATION_MS, HAND);
|
|
||||||
}
|
|
||||||
} else if (!Object.keys(stories).length) { // If there's nothing being tracked, then any messageWaiting has expired.
|
|
||||||
ui.messagesWaiting(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
var MS_PER_SEC = 1000;
|
|
||||||
var DEBUG_POLL_TIME_SEC = 10;
|
|
||||||
var NORMAL_POLL_TIME_SEC = 60;
|
|
||||||
var ANNOUNCEMENTS_POLL_TIME_MS = (DEBUG ? DEBUG_POLL_TIME_SEC : NORMAL_POLL_TIME_SEC) * MS_PER_SEC;
|
|
||||||
var pollTimer = Script.setInterval(pollForAnnouncements, ANNOUNCEMENTS_POLL_TIME_MS);
|
|
||||||
|
|
||||||
function gotoOpened() {
|
function gotoOpened() {
|
||||||
ui.messagesWaiting(false);
|
shouldShowDot = false;
|
||||||
|
ui.messagesWaiting(shouldShowDot);
|
||||||
|
}
|
||||||
|
|
||||||
|
function notificationDataProcessPage(data) {
|
||||||
|
return data.user_stories;
|
||||||
|
}
|
||||||
|
|
||||||
|
var shouldShowDot = false;
|
||||||
|
var pingPong = false;
|
||||||
|
var storedAnnouncements = {};
|
||||||
|
var storedFeaturedStories = {};
|
||||||
|
var message;
|
||||||
|
function notificationPollCallback(userStoriesArray) {
|
||||||
|
//
|
||||||
|
// START logic for keeping track of new info
|
||||||
|
//
|
||||||
|
pingPong = !pingPong;
|
||||||
|
var totalNewStories = 0;
|
||||||
|
var shouldNotifyIndividually = !ui.isOpen && ui.notificationInitialCallbackMade;
|
||||||
|
userStoriesArray.forEach(function (story) {
|
||||||
|
if (story.audience !== "for_connections" &&
|
||||||
|
story.audience !== "for_feed") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var stored = storedAnnouncements[story.id] || storedFeaturedStories[story.id];
|
||||||
|
var storedOrNew = stored || story;
|
||||||
|
storedOrNew.pingPong = pingPong;
|
||||||
|
if (stored) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
totalNewStories++;
|
||||||
|
|
||||||
|
if (story.audience === "for_connections") {
|
||||||
|
storedAnnouncements[story.id] = story;
|
||||||
|
|
||||||
|
if (shouldNotifyIndividually) {
|
||||||
|
message = story.username + " says something is happening in " +
|
||||||
|
story.place_name + ". Open GOTO to join them.";
|
||||||
|
ui.notificationDisplayBanner(message);
|
||||||
|
}
|
||||||
|
} else if (story.audience === "for_feed") {
|
||||||
|
storedFeaturedStories[story.id] = story;
|
||||||
|
|
||||||
|
if (shouldNotifyIndividually) {
|
||||||
|
message = story.username + " invites you to an event in " +
|
||||||
|
story.place_name + ". Open GOTO to join them.";
|
||||||
|
ui.notificationDisplayBanner(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var key;
|
||||||
|
for (key in storedAnnouncements) {
|
||||||
|
if (storedAnnouncements[key].pingPong !== pingPong) {
|
||||||
|
delete storedAnnouncements[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (key in storedFeaturedStories) {
|
||||||
|
if (storedFeaturedStories[key].pingPong !== pingPong) {
|
||||||
|
delete storedFeaturedStories[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// END logic for keeping track of new info
|
||||||
|
//
|
||||||
|
|
||||||
|
var totalStories = Object.keys(storedAnnouncements).length +
|
||||||
|
Object.keys(storedFeaturedStories).length;
|
||||||
|
shouldShowDot = totalNewStories > 0 || (totalStories > 0 && shouldShowDot);
|
||||||
|
ui.messagesWaiting(shouldShowDot && !ui.isOpen);
|
||||||
|
|
||||||
|
if (totalStories > 0 && !ui.isOpen && !ui.notificationInitialCallbackMade) {
|
||||||
|
message = "There " + (totalStories === 1 ? "is " : "are ") + totalStories + " event" +
|
||||||
|
(totalStories === 1 ? "" : "s") + " to know about. " +
|
||||||
|
"Open GOTO to see " + (totalStories === 1 ? "it" : "them") + ".";
|
||||||
|
ui.notificationDisplayBanner(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isReturnedDataEmpty(data) {
|
||||||
|
var storiesArray = data.user_stories;
|
||||||
|
return storiesArray.length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ui;
|
var ui;
|
||||||
var GOTO_QML_SOURCE = "hifi/tablet/TabletAddressDialog.qml";
|
var GOTO_QML_SOURCE = "hifi/tablet/TabletAddressDialog.qml";
|
||||||
var BUTTON_NAME = "GOTO";
|
var BUTTON_NAME = "GOTO";
|
||||||
function startup() {
|
function startup() {
|
||||||
|
var options = [
|
||||||
|
'include_actions=announcement',
|
||||||
|
'restriction=open,hifi',
|
||||||
|
'require_online=true',
|
||||||
|
'protocol=' + encodeURIComponent(Window.protocolSignature()),
|
||||||
|
'per_page=10'
|
||||||
|
];
|
||||||
|
var endpoint = '/api/v1/user_stories?' + options.join('&');
|
||||||
|
|
||||||
ui = new AppUi({
|
ui = new AppUi({
|
||||||
buttonName: BUTTON_NAME,
|
buttonName: BUTTON_NAME,
|
||||||
sortOrder: 8,
|
sortOrder: 8,
|
||||||
onOpened: gotoOpened,
|
onOpened: gotoOpened,
|
||||||
home: GOTO_QML_SOURCE
|
home: GOTO_QML_SOURCE,
|
||||||
|
notificationPollEndpoint: endpoint,
|
||||||
|
notificationPollTimeoutMs: 60000,
|
||||||
|
notificationDataProcessPage: notificationDataProcessPage,
|
||||||
|
notificationPollCallback: notificationPollCallback,
|
||||||
|
notificationPollStopPaginatingConditionMet: isReturnedDataEmpty,
|
||||||
|
notificationPollCaresAboutSince: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function shutdown() {
|
|
||||||
Script.clearInterval(pollTimer);
|
|
||||||
}
|
|
||||||
|
|
||||||
startup();
|
startup();
|
||||||
Script.scriptEnding.connect(shutdown);
|
|
||||||
}()); // END LOCAL_SCOPE
|
}()); // END LOCAL_SCOPE
|
||||||
|
|
Loading…
Reference in a new issue