From 74aedd73fd23de8f023c6fc9c7d6ef2a2ddd9b27 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 12 Jun 2018 15:47:55 -0700 Subject: [PATCH 01/36] Exit at end of non-interactive recursive script. Similarity index set to -100.0 to indicate size difference. Simplified repo. path in testRecursive scripts. Wait 10" before starting recursive script. --- tools/auto-tester/src/Test.cpp | 70 +++++++++++++++++++--------------- tools/auto-tester/src/Test.h | 4 ++ 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 1a25cc5c0e..e34a5f787c 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -63,7 +63,6 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar) // Loop over both lists and compare each pair of images // Quit loop if user has aborted due to a failed test. - const double THRESHOLD { 0.9995 }; bool success{ true }; bool keepOn{ true }; for (int i = 0; keepOn && i < expectedImagesFullFilenames.length(); ++i) { @@ -71,17 +70,19 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar) QImage resultImage(resultImagesFullFilenames[i]); QImage expectedImage(expectedImagesFullFilenames[i]); + double similarityIndex; // in [-1.0 .. 1.0], where 1.0 means images are identical + + // similarityIndex is set to -100.0 to indicate images are not the same size if (isInteractiveMode && (resultImage.width() != expectedImage.width() || resultImage.height() != expectedImage.height())) { QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Images are not the same size"); - exit(-1); - } - - double similarityIndex; // in [-1.0 .. 1.0], where 1.0 means images are identical - try { - similarityIndex = imageComparer.compareImages(resultImage, expectedImage); - } catch (...) { - QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Image not in expected format"); - exit(-1); + similarityIndex = -100.0; + } else { + try { + similarityIndex = imageComparer.compareImages(resultImage, expectedImage); + } catch (...) { + QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Image not in expected format"); + exit(-1); + } } if (similarityIndex < THRESHOLD) { @@ -177,19 +178,24 @@ void Test::appendTestResultsToFile(const QString& testResultsFolderPath, TestFai } void Test::startTestsEvaluation(const QString& testFolder) { - // Get list of JPEG images in folder, sorted by name - QString previousSelection = snapshotDirectory; - QString parent = previousSelection.left(previousSelection.lastIndexOf('/')); - if (!parent.isNull() && parent.right(1) != "/") { - parent += "/"; - } - snapshotDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", parent, - QFileDialog::ShowDirsOnly); + if (testFolder.isNull()) { + // Get list of JPEG images in folder, sorted by name + QString previousSelection = snapshotDirectory; + QString parent = previousSelection.left(previousSelection.lastIndexOf('/')); + if (!parent.isNull() && parent.right(1) != "/") { + parent += "/"; + } + snapshotDirectory = QFileDialog::getExistingDirectory(nullptr, "Please select folder containing the test images", parent, + QFileDialog::ShowDirsOnly); - // If user cancelled then restore previous selection and return - if (snapshotDirectory == "") { - snapshotDirectory = previousSelection; - return; + // If user cancelled then restore previous selection and return + if (snapshotDirectory == "") { + snapshotDirectory = previousSelection; + return; + } + } else { + snapshotDirectory = testFolder; + exitWhenComplete = true; } // Quit if test results folder could not be created @@ -259,6 +265,10 @@ void Test::finishTestsEvaluation(bool isRunningFromCommandline, bool interactive } zipAndDeleteTestResultsFolder(); + + if (exitWhenComplete) { + exit(0); + } } bool Test::isAValidDirectory(const QString& pathname) { @@ -299,10 +309,7 @@ QString Test::extractPathFromTestsDown(const QString& fullPath) { void Test::includeTest(QTextStream& textStream, const QString& testPathname) { QString partialPath = extractPathFromTestsDown(testPathname); - textStream << "Script.include(\"" - << "https://github.com/" << GIT_HUB_USER << "/hifi_tests/blob/" << GIT_HUB_BRANCH - << partialPath + "?raw=true\");" - << endl; + textStream << "Script.include(repositoryPath + \"" << partialPath + "?raw=true\");" << endl; } // Creates a single script in a user-selected folder. @@ -401,8 +408,11 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact textStream << "repository = \"" + GIT_HUB_REPOSITORY + "/\";" << endl; textStream << "branch = \"" + GIT_HUB_BRANCH + "/\";" << endl << endl; - textStream << "var autoTester = Script.require(\"https://github.com/" + GIT_HUB_USER + "/hifi_tests/blob/" - + GIT_HUB_BRANCH + "/tests/utils/autoTester.js?raw=true\");" << endl << endl; + // Wait 10 seconds before starting + textStream << "Test.wait(10000);" << endl << endl; + + textStream << "var repositoryPath = \"https://github.com/\" + user + repository + \"blob/\" + branch;" << endl; + textStream << "var autoTester = Script.require(repositoryPath + \"tests/utils/autoTester.js?raw=true\");" << endl << endl; textStream << "autoTester.enableRecursive();" << endl; textStream << "autoTester.enableAuto();" << endl << endl; @@ -560,9 +570,7 @@ ExtractedText Test::getTestScriptLines(QString testFileName) { const QString ws("\\h*"); //white-space character const QString functionPerformName(ws + "autoTester" + ws + "\\." + ws + "perform"); const QString quotedString("\\\".+\\\""); - const QString ownPath("Script" + ws + "\\." + ws + "resolvePath" + ws + "\\(" + ws + "\\\"\\.\\\"" + ws + "\\)"); - const QString functionParameter("function" + ws + "\\(testType" + ws + "\\)"); - QString regexTestTitle(ws + functionPerformName + "\\(" + quotedString + "\\," + ws + ownPath + "\\," + ws + functionParameter + ws + "{" + ".*"); + QString regexTestTitle(ws + functionPerformName + "\\(" + quotedString); QRegularExpression lineContainingTitle = QRegularExpression(regexTestTitle); diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index 32564035e7..5833b990c2 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -76,6 +76,8 @@ private: const QString TEST_RESULTS_FOLDER { "TestResults" }; const QString TEST_RESULTS_FILENAME { "TestResults.txt" }; + const double THRESHOLD{ 0.999 }; + QDir imageDirectory; MismatchWindow mismatchWindow; @@ -115,6 +117,8 @@ private: // var pathSeparator = "."; const QString ADVANCE_KEY{ "n" }; const QString PATH_SEPARATOR{ "." }; + + bool exitWhenComplete{ false }; }; #endif // hifi_test_h \ No newline at end of file From 9ca27468f6fe63da1c6bad4169ba1275b58a9982 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 13 Jun 2018 19:29:09 -0700 Subject: [PATCH 02/36] Added selection of branch from the command line. --- tools/auto-tester/src/Test.cpp | 14 +++++-- tools/auto-tester/src/Test.h | 6 ++- tools/auto-tester/src/main.cpp | 36 +++++++++++++--- tools/auto-tester/src/ui/AutoTester.cpp | 14 ++++++- tools/auto-tester/src/ui/AutoTester.h | 7 +++- tools/auto-tester/src/ui/AutoTester.ui | 56 ++++++++++++++++++------- 6 files changed, 106 insertions(+), 27 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index e34a5f787c..0f38a9c619 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -25,6 +25,10 @@ extern AutoTester* autoTester; Test::Test() { mismatchWindow.setModal(true); + + if (autoTester) { + autoTester->loadBranchCombo(GIT_HUB_BRANCHES); + } } bool Test::createTestResultsFolderPath(const QString& directory) { @@ -177,7 +181,7 @@ void Test::appendTestResultsToFile(const QString& testResultsFolderPath, TestFai comparisonImage.save(failureFolderPath + "/" + "Difference Image.png"); } -void Test::startTestsEvaluation(const QString& testFolder) { +void Test::startTestsEvaluation(const QString& testFolder, const QString& branchFromCommandLine) { if (testFolder.isNull()) { // Get list of JPEG images in folder, sorted by name QString previousSelection = snapshotDirectory; @@ -225,6 +229,8 @@ void Test::startTestsEvaluation(const QString& testFolder) { expectedImagesFilenames.clear(); expectedImagesFullFilenames.clear(); + QString branch = (branchFromCommandLine.isNull()) ? autoTester->getSelectedBranch() : branchFromCommandLine ; + foreach(QString currentFilename, sortedTestResultsFilenames) { QString fullCurrentFilename = snapshotDirectory + "/" + currentFilename; if (isInSnapshotFilenameFormat("png", currentFilename)) { @@ -237,7 +243,7 @@ void Test::startTestsEvaluation(const QString& testFolder) { QString expectedImageFilenameTail = currentFilename.left(currentFilename.length() - 4).right(NUM_DIGITS); QString expectedImageStoredFilename = EXPECTED_IMAGE_PREFIX + expectedImageFilenameTail + ".png"; - QString imageURLString("https://raw.githubusercontent.com/" + GIT_HUB_USER + "/hifi_tests/" + GIT_HUB_BRANCH + "/" + + QString imageURLString("https://raw.githubusercontent.com/" + GIT_HUB_USER + "/hifi_tests/" + branch + "/" + expectedImagePartialSourceDirectory + "/" + expectedImageStoredFilename); expectedImagesURLs << imageURLString; @@ -406,7 +412,9 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact textStream << "user = \"" + GIT_HUB_USER + "/\";" << endl; textStream << "repository = \"" + GIT_HUB_REPOSITORY + "/\";" << endl; - textStream << "branch = \"" + GIT_HUB_BRANCH + "/\";" << endl << endl; + + QString branch = autoTester->getSelectedBranch(); + textStream << "branch = \"" + branch + "/\";" << endl << endl; // Wait 10 seconds before starting textStream << "Test.wait(10000);" << endl << endl; diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index 5833b990c2..b91a49ed95 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -37,7 +37,7 @@ class Test { public: Test(); - void startTestsEvaluation(const QString& testFolder = QString()); + void startTestsEvaluation(const QString& testFolder = QString(), const QString& branchFromCommandLine = QString()); void finishTestsEvaluation(bool isRunningFromCommandline, bool interactiveMode, QProgressBar* progressBar); void createRecursiveScript(); @@ -106,7 +106,9 @@ private: // Used for accessing GitHub const QString GIT_HUB_USER{ "highfidelity" }; const QString GIT_HUB_REPOSITORY{ "hifi_tests" }; - const QString GIT_HUB_BRANCH{ "master" }; + + // The branch is user-selected + const QStringList GIT_HUB_BRANCHES{ "master", "RC69" }; const QString DATETIME_FORMAT{ "yyyy-MM-dd_hh-mm-ss" }; diff --git a/tools/auto-tester/src/main.cpp b/tools/auto-tester/src/main.cpp index ffa7a0b237..e01cd21f77 100644 --- a/tools/auto-tester/src/main.cpp +++ b/tools/auto-tester/src/main.cpp @@ -10,23 +10,49 @@ #include #include "ui/AutoTester.h" +#include + AutoTester* autoTester; int main(int argc, char *argv[]) { - // Only parameter is "--testFolder" + // If no parameters then run in interactive mode + // Parameter --testFolder + // Parameter --branch + // default is "master" + // QString testFolder; - if (argc == 3) { - if (QString(argv[1]) == "--testFolder") { - testFolder = QString(argv[2]); + QString branch; + if (argc > 2) { + for (int i = 1; i < argc - 1; ++i) + if (QString(argv[i]) == "--testFolder") { + ++i; + if (i < argc) { + testFolder = QString(argv[i]); + } else { + std::cout << "Missing parameter after --testFolder" << endl; + exit(-1); + } + } else if (QString(argv[i]) == "--branch") { + ++i; + if (i < argc) { + branch = QString(argv[i]); + } else { + std::cout << "Missing parameter after --branch" << endl; + exit(-1); + } + } else { + std::cout << "Unknown parameter" << endl; + exit(-1); } } QApplication application(argc, argv); autoTester = new AutoTester(); + autoTester->setup(); if (!testFolder.isNull()) { - autoTester->runFromCommandLine(testFolder); + autoTester->runFromCommandLine(testFolder, branch); } else { autoTester->show(); } diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index 14329e36c2..d94916ecbc 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -29,13 +29,15 @@ AutoTester::AutoTester(QWidget *parent) : QMainWindow(parent) { ui.hideTaskbarButton->setVisible(false); ui.showTaskbarButton->setVisible(false); #endif +} +void AutoTester::setup() { test = new Test(); } -void AutoTester::runFromCommandLine(const QString& testFolder) { +void AutoTester::runFromCommandLine(const QString& testFolder, const QString& branch) { isRunningFromCommandline = true; - test->startTestsEvaluation(testFolder); + test->startTestsEvaluation(testFolder, branch); } void AutoTester::on_evaluateTestsButton_clicked() { @@ -150,3 +152,11 @@ void AutoTester::saveImage(int index) { void AutoTester::about() { QMessageBox::information(0, "About", QString("Built ") + __DATE__ + " : " + __TIME__); } + +void AutoTester::loadBranchCombo(const QStringList& items) { + ui.branchComboBox->addItems(items); +} + +QString AutoTester::getSelectedBranch() { + return ui.branchComboBox->currentText(); +} \ No newline at end of file diff --git a/tools/auto-tester/src/ui/AutoTester.h b/tools/auto-tester/src/ui/AutoTester.h index 7b419a9af8..5eff89e957 100644 --- a/tools/auto-tester/src/ui/AutoTester.h +++ b/tools/auto-tester/src/ui/AutoTester.h @@ -23,11 +23,16 @@ class AutoTester : public QMainWindow { public: AutoTester(QWidget *parent = Q_NULLPTR); - void runFromCommandLine(const QString& testFolder); + void setup(); + + void runFromCommandLine(const QString& testFolder, const QString& branch); void downloadImage(const QUrl& url); void downloadImages(const QStringList& URLs, const QString& directoryName, const QStringList& filenames); + void loadBranchCombo(const QStringList& items); + QString getSelectedBranch(); + private slots: void on_evaluateTestsButton_clicked(); void on_createRecursiveScriptButton_clicked(); diff --git a/tools/auto-tester/src/ui/AutoTester.ui b/tools/auto-tester/src/ui/AutoTester.ui index 236138acf4..44c00509e6 100644 --- a/tools/auto-tester/src/ui/AutoTester.ui +++ b/tools/auto-tester/src/ui/AutoTester.ui @@ -43,8 +43,8 @@ - 20 - 285 + 340 + 275 220 40 @@ -56,8 +56,8 @@ - 360 - 35 + 340 + 95 220 40 @@ -69,8 +69,8 @@ - 23 - 250 + 343 + 240 131 20 @@ -85,8 +85,8 @@ - 20 - 340 + 340 + 330 255 23 @@ -98,8 +98,8 @@ - 360 - 100 + 340 + 160 220 40 @@ -150,8 +150,8 @@ - 490 - 280 + 10 + 410 91 40 @@ -163,8 +163,8 @@ - 490 - 230 + 10 + 360 91 40 @@ -173,6 +173,34 @@ Hide Taskbar + + + + 428 + 41 + 131 + 31 + + + + + + + 340 + 30 + 81 + 51 + + + + + 10 + + + + GitHub Branch + + From e8154b5df18fc881153120248c3d6a39902b8a80 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 17 Jun 2018 08:35:45 +1200 Subject: [PATCH 03/36] Fix Create app selection updating when entities are deleted --- scripts/system/edit.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 05f5e3cb19..02af474f55 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -475,18 +475,18 @@ var toolBar = (function () { var DELETE_ENTITY_TIMER_TIMEOUT = 100; function checkDeletedEntityAndUpdate(entityID) { - // Allow for multiple entity deletes before updating the entity list. - entitiesToDelete.push(entityID); - if (deletedEntityTimer !== null) { - Script.clearTimeout(deletedEntityTimer); + if (selectionManager.selections.indexOf(entityID) !== -1) { + // Allow for multiple entity deletes before updating the entities selected. + entitiesToDelete.push(entityID); + if (deletedEntityTimer !== null) { + Script.clearTimeout(deletedEntityTimer); + } + deletedEntityTimer = Script.setTimeout(function () { + selectionManager.removeEntities(entitiesToDelete); + entitiesToDelete = []; + deletedEntityTimer = null; + }, DELETE_ENTITY_TIMER_TIMEOUT); } - deletedEntityTimer = Script.setTimeout(function () { - selectionManager.removeEntities(entitiesToDelete); - entityListTool.clearEntityList(); - entityListTool.sendUpdate(); - entitiesToDelete = []; - deletedEntityTimer = null; - }, DELETE_ENTITY_TIMER_TIMEOUT); } function initialize() { From d59ddc47648e784c8ab3fabbf4700b660c399a97 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 18 Jun 2018 07:44:04 -0700 Subject: [PATCH 04/36] Added selection of branch from combo. --- tools/auto-tester/src/Test.cpp | 10 +++--- tools/auto-tester/src/ui/AutoTester.ui | 42 +++++++++++++------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 0f38a9c619..1cfc32e481 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -411,13 +411,15 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact textStream << "// This is an automatically generated file, created by auto-tester on " << QDateTime::currentDateTime().toString(DATE_TIME_FORMAT) << endl << endl; textStream << "user = \"" + GIT_HUB_USER + "/\";" << endl; - textStream << "repository = \"" + GIT_HUB_REPOSITORY + "/\";" << endl; + textStream << "repository = \"" + GIT_HUB_REPOSITORY + "/\";" << endl << endl; - QString branch = autoTester->getSelectedBranch(); - textStream << "branch = \"" + branch + "/\";" << endl << endl; + textStream << "Script.include(\"https://github.com/highfidelity/hifi_tests/blob/RC69/tests/utils/branchUtils.js?raw=true\");" << endl; + textStream << "branch = getBranch(Script.resolvePath(\".\"), repository) +\"/\";" << endl << endl; // Wait 10 seconds before starting - textStream << "Test.wait(10000);" << endl << endl; + textStream << "if (typeof Test !== 'undefined') {" << endl; + textStream << " Test.wait(10000);" << endl; + textStream << "};" << endl << endl; textStream << "var repositoryPath = \"https://github.com/\" + user + repository + \"blob/\" + branch;" << endl; textStream << "var autoTester = Script.require(repositoryPath + \"tests/utils/autoTester.js?raw=true\");" << endl << endl; diff --git a/tools/auto-tester/src/ui/AutoTester.ui b/tools/auto-tester/src/ui/AutoTester.ui index 44c00509e6..df21dad1eb 100644 --- a/tools/auto-tester/src/ui/AutoTester.ui +++ b/tools/auto-tester/src/ui/AutoTester.ui @@ -6,7 +6,7 @@ 0 0 - 607 + 583 514 @@ -17,9 +17,9 @@ - 360 - 400 - 220 + 460 + 410 + 101 40 @@ -43,7 +43,7 @@ - 340 + 330 275 220 40 @@ -56,8 +56,8 @@ - 340 - 95 + 330 + 30 220 40 @@ -69,8 +69,8 @@ - 343 - 240 + 330 + 250 131 20 @@ -85,7 +85,7 @@ - 340 + 330 330 255 23 @@ -98,8 +98,8 @@ - 340 - 160 + 330 + 80 220 40 @@ -112,7 +112,7 @@ 20 - 80 + 100 220 40 @@ -125,7 +125,7 @@ 20 - 130 + 150 220 40 @@ -138,7 +138,7 @@ 20 - 180 + 220 220 40 @@ -176,8 +176,8 @@ - 428 - 41 + 418 + 211 131 31 @@ -186,10 +186,10 @@ - 340 - 30 + 330 + 220 81 - 51 + 16 @@ -207,7 +207,7 @@ 0 0 - 607 + 583 21 From 4897e11a125cdd2f39aa62d2c260cad852dfe07d Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 18 Jun 2018 12:43:42 -0700 Subject: [PATCH 05/36] Save downloaded byte array (from GitHub) to file with PNG extension. --- tools/auto-tester/src/ImageComparer.cpp | 3 --- tools/auto-tester/src/Test.cpp | 7 +------ tools/auto-tester/src/ui/AutoTester.cpp | 14 ++++++-------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/tools/auto-tester/src/ImageComparer.cpp b/tools/auto-tester/src/ImageComparer.cpp index 3afdeaec0a..56da37f225 100644 --- a/tools/auto-tester/src/ImageComparer.cpp +++ b/tools/auto-tester/src/ImageComparer.cpp @@ -17,9 +17,6 @@ double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) const { // Make sure the image is 8 bits per colour QImage::Format format = expectedImage.format(); - if (format != QImage::Format::Format_ARGB32) { - throw -1; - } const int L = 255; // (2^number of bits per pixel) - 1 const double K1 { 0.01 }; diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 1cfc32e481..7a61782f9e 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -81,12 +81,7 @@ bool Test::compareImageLists(bool isInteractiveMode, QProgressBar* progressBar) QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Images are not the same size"); similarityIndex = -100.0; } else { - try { - similarityIndex = imageComparer.compareImages(resultImage, expectedImage); - } catch (...) { - QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), "Image not in expected format"); - exit(-1); - } + similarityIndex = imageComparer.compareImages(resultImage, expectedImage); } if (similarityIndex < THRESHOLD) { diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index d94916ecbc..a238e2e7e8 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -127,14 +127,12 @@ void AutoTester::downloadImages(const QStringList& URLs, const QString& director } void AutoTester::saveImage(int index) { - QPixmap pixmap; - pixmap.loadFromData(downloaders[index]->downloadedData()); - - QImage image = pixmap.toImage(); - image = image.convertToFormat(QImage::Format_ARGB32); - - QString fullPathname = _directoryName + "/" + _filenames[index]; - if (!image.save(fullPathname, 0, 100)) { + try { + QFile file(_directoryName + "/" + _filenames[index]); + file.open(QIODevice::WriteOnly); + file.write(downloaders[index]->downloadedData()); + file.close(); + } catch (...) { QMessageBox::information(0, "Test Aborted", "Failed to save image: " + _filenames[index]); ui.progressBar->setVisible(false); return; From dc5c5c20df84b87c64e74a8bb18684a678df7418 Mon Sep 17 00:00:00 2001 From: humbletim Date: Mon, 11 Jun 2018 15:44:19 -0400 Subject: [PATCH 06/36] raypick partIndex commit include shapeID for accessing proper material index add raypick shapeID test script --- libraries/entities/src/EntityItem.h | 3 +- libraries/entities/src/EntityTreeElement.cpp | 4 +- libraries/render-utils/src/Model.cpp | 170 ++++++++++--------- libraries/render-utils/src/Model.h | 3 +- libraries/shared/src/TriangleSet.h | 2 + scripts/developer/tests/raypickTester.js | 73 ++++++++ 6 files changed, 174 insertions(+), 81 deletions(-) create mode 100644 scripts/developer/tests/raypickTester.js diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 0acf8dbbc1..84391382fc 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -185,6 +185,7 @@ public: /// Dimensions in meters (0.0 - TREE_SCALE) glm::vec3 getScaledDimensions() const; virtual void setScaledDimensions(const glm::vec3& value); + virtual glm::vec3 getRaycastDimensions() const { return getScaledDimensions(); } inline const glm::vec3 getUnscaledDimensions() const { return _unscaledDimensions; } virtual void setUnscaledDimensions(const glm::vec3& value); @@ -239,7 +240,7 @@ public: // position, size, and bounds related helpers virtual AACube getMaximumAACube(bool& success) const override; AACube getMinimumAACube(bool& success) const; - AABox getAABox(bool& success) const; /// axis aligned bounding box in world-frame (meters) + virtual AABox getAABox(bool& success) const; /// axis aligned bounding box in world-frame (meters) using SpatiallyNestable::getQueryAACube; virtual AACube getQueryAACube(bool& success) const override; diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index cbcddfc57b..bc5bb1e81d 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -214,7 +214,7 @@ EntityItemID EntityTreeElement::findDetailedRayIntersection(const glm::vec3& ori glm::mat4 entityToWorldMatrix = translation * rotation; glm::mat4 worldToEntityMatrix = glm::inverse(entityToWorldMatrix); - glm::vec3 dimensions = entity->getScaledDimensions(); + glm::vec3 dimensions = entity->getRaycastDimensions(); glm::vec3 registrationPoint = entity->getRegistrationPoint(); glm::vec3 corner = -(dimensions * registrationPoint); @@ -312,7 +312,7 @@ void EntityTreeElement::getEntities(const glm::vec3& searchPosition, float searc glm::vec3 penetration; if (!success || entityBox.findSpherePenetration(searchPosition, searchRadius, penetration)) { - glm::vec3 dimensions = entity->getScaledDimensions(); + glm::vec3 dimensions = entity->getRaycastDimensions(); // FIXME - consider allowing the entity to determine penetration so that // entities could presumably dull actuall hull testing if they wanted to diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 178c00c4c7..dc65863c6e 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -401,26 +401,34 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g glm::vec3 meshFrameOrigin = glm::vec3(worldToMeshMatrix * glm::vec4(origin, 1.0f)); glm::vec3 meshFrameDirection = glm::vec3(worldToMeshMatrix * glm::vec4(direction, 0.0f)); - for (auto& triangleSet : _modelSpaceMeshTriangleSets) { - float triangleSetDistance = 0.0f; - BoxFace triangleSetFace; - Triangle triangleSetTriangle; - if (triangleSet.findRayIntersection(meshFrameOrigin, meshFrameDirection, triangleSetDistance, triangleSetFace, triangleSetTriangle, pickAgainstTriangles, allowBackface)) { + int shapeID = 0; + for (auto& meshTriangleSets : _modelSpaceMeshTriangleSets) { + int partIndex = 0; + for (auto &partTriangleSet : meshTriangleSets) { + float triangleSetDistance = 0.0f; + BoxFace triangleSetFace; + Triangle triangleSetTriangle; + if (partTriangleSet.findRayIntersection(meshFrameOrigin, meshFrameDirection, triangleSetDistance, triangleSetFace, triangleSetTriangle, pickAgainstTriangles, allowBackface)) { - glm::vec3 meshIntersectionPoint = meshFrameOrigin + (meshFrameDirection * triangleSetDistance); - glm::vec3 worldIntersectionPoint = glm::vec3(meshToWorldMatrix * glm::vec4(meshIntersectionPoint, 1.0f)); - float worldDistance = glm::distance(origin, worldIntersectionPoint); + glm::vec3 meshIntersectionPoint = meshFrameOrigin + (meshFrameDirection * triangleSetDistance); + glm::vec3 worldIntersectionPoint = glm::vec3(meshToWorldMatrix * glm::vec4(meshIntersectionPoint, 1.0f)); + float worldDistance = glm::distance(origin, worldIntersectionPoint); - if (worldDistance < bestDistance) { - bestDistance = worldDistance; - intersectedSomething = true; - face = triangleSetFace; - bestModelTriangle = triangleSetTriangle; - bestWorldTriangle = triangleSetTriangle * meshToWorldMatrix; - extraInfo["worldIntersectionPoint"] = vec3toVariant(worldIntersectionPoint); - extraInfo["meshIntersectionPoint"] = vec3toVariant(meshIntersectionPoint); - bestSubMeshIndex = subMeshIndex; + if (worldDistance < bestDistance) { + bestDistance = worldDistance; + intersectedSomething = true; + face = triangleSetFace; + bestModelTriangle = triangleSetTriangle; + bestWorldTriangle = triangleSetTriangle * meshToWorldMatrix; + extraInfo["worldIntersectionPoint"] = vec3toVariant(worldIntersectionPoint); + extraInfo["meshIntersectionPoint"] = vec3toVariant(meshIntersectionPoint); + extraInfo["partIndex"] = partIndex; + extraInfo["shapeID"] = shapeID; + bestSubMeshIndex = subMeshIndex; + } } + partIndex++; + shapeID++; } subMeshIndex++; } @@ -485,12 +493,14 @@ bool Model::convexHullContains(glm::vec3 point) { glm::mat4 worldToMeshMatrix = glm::inverse(meshToWorldMatrix); glm::vec3 meshFramePoint = glm::vec3(worldToMeshMatrix * glm::vec4(point, 1.0f)); - for (const auto& triangleSet : _modelSpaceMeshTriangleSets) { - const AABox& box = triangleSet.getBounds(); - if (box.contains(meshFramePoint)) { - if (triangleSet.convexHullContains(meshFramePoint)) { - // It's inside this mesh, return true. - return true; + for (auto& meshTriangleSets : _modelSpaceMeshTriangleSets) { + for (auto &partTriangleSet : meshTriangleSets) { + const AABox& box = partTriangleSet.getBounds(); + if (box.contains(meshFramePoint)) { + if (partTriangleSet.convexHullContains(meshFramePoint)) { + // It's inside this mesh, return true. + return true; + } } } } @@ -653,9 +663,15 @@ void Model::calculateTriangleSets(const FBXGeometry& geometry) { for (int i = 0; i < numberOfMeshes; i++) { const FBXMesh& mesh = geometry.meshes.at(i); - for (int j = 0; j < mesh.parts.size(); j++) { + const int numberOfParts = mesh.parts.size(); + auto& meshTriangleSets = _modelSpaceMeshTriangleSets[i]; + meshTriangleSets.resize(numberOfParts); + + for (int j = 0; j < numberOfParts; j++) { const FBXMeshPart& part = mesh.parts.at(j); + auto& partTriangleSet = meshTriangleSets[j]; + const int INDICES_PER_TRIANGLE = 3; const int INDICES_PER_QUAD = 4; const int TRIANGLES_PER_QUAD = 2; @@ -664,7 +680,7 @@ void Model::calculateTriangleSets(const FBXGeometry& geometry) { int numberOfQuads = part.quadIndices.size() / INDICES_PER_QUAD; int numberOfTris = part.triangleIndices.size() / INDICES_PER_TRIANGLE; int totalTriangles = (numberOfQuads * TRIANGLES_PER_QUAD) + numberOfTris; - _modelSpaceMeshTriangleSets[i].reserve(totalTriangles); + partTriangleSet.reserve(totalTriangles); auto meshTransform = geometry.offset * mesh.modelTransform; @@ -686,8 +702,8 @@ void Model::calculateTriangleSets(const FBXGeometry& geometry) { Triangle tri1 = { v0, v1, v3 }; Triangle tri2 = { v1, v2, v3 }; - _modelSpaceMeshTriangleSets[i].insert(tri1); - _modelSpaceMeshTriangleSets[i].insert(tri2); + partTriangleSet.insert(tri1); + partTriangleSet.insert(tri2); } } @@ -706,7 +722,7 @@ void Model::calculateTriangleSets(const FBXGeometry& geometry) { glm::vec3 v2 = glm::vec3(meshTransform * glm::vec4(mesh.vertices[i2], 1.0f)); Triangle tri = { v0, v1, v2 }; - _modelSpaceMeshTriangleSets[i].insert(tri); + partTriangleSet.insert(tri); } } } @@ -876,56 +892,58 @@ void Model::renderDebugMeshBoxes(gpu::Batch& batch) { DependencyManager::get()->bindSimpleProgram(batch, false, false, false, true, true); - for (const auto& triangleSet : _modelSpaceMeshTriangleSets) { - auto box = triangleSet.getBounds(); + for (auto& meshTriangleSets : _modelSpaceMeshTriangleSets) { + for (auto &partTriangleSet : meshTriangleSets) { + auto box = partTriangleSet.getBounds(); - if (_debugMeshBoxesID == GeometryCache::UNKNOWN_ID) { - _debugMeshBoxesID = DependencyManager::get()->allocateID(); + if (_debugMeshBoxesID == GeometryCache::UNKNOWN_ID) { + _debugMeshBoxesID = DependencyManager::get()->allocateID(); + } + QVector points; + + glm::vec3 brn = box.getCorner(); + glm::vec3 bln = brn + glm::vec3(box.getDimensions().x, 0, 0); + glm::vec3 brf = brn + glm::vec3(0, 0, box.getDimensions().z); + glm::vec3 blf = brn + glm::vec3(box.getDimensions().x, 0, box.getDimensions().z); + + glm::vec3 trn = brn + glm::vec3(0, box.getDimensions().y, 0); + glm::vec3 tln = bln + glm::vec3(0, box.getDimensions().y, 0); + glm::vec3 trf = brf + glm::vec3(0, box.getDimensions().y, 0); + glm::vec3 tlf = blf + glm::vec3(0, box.getDimensions().y, 0); + + points << brn << bln; + points << brf << blf; + points << brn << brf; + points << bln << blf; + + points << trn << tln; + points << trf << tlf; + points << trn << trf; + points << tln << tlf; + + points << brn << trn; + points << brf << trf; + points << bln << tln; + points << blf << tlf; + + glm::vec4 color[] = { + { 0.0f, 1.0f, 0.0f, 1.0f }, // green + { 1.0f, 0.0f, 0.0f, 1.0f }, // red + { 0.0f, 0.0f, 1.0f, 1.0f }, // blue + { 1.0f, 0.0f, 1.0f, 1.0f }, // purple + { 1.0f, 1.0f, 0.0f, 1.0f }, // yellow + { 0.0f, 1.0f, 1.0f, 1.0f }, // cyan + { 1.0f, 1.0f, 1.0f, 1.0f }, // white + { 0.0f, 0.5f, 0.0f, 1.0f }, + { 0.0f, 0.0f, 0.5f, 1.0f }, + { 0.5f, 0.0f, 0.5f, 1.0f }, + { 0.5f, 0.5f, 0.0f, 1.0f }, + { 0.0f, 0.5f, 0.5f, 1.0f } }; + + DependencyManager::get()->updateVertices(_debugMeshBoxesID, points, color[colorNdx]); + DependencyManager::get()->renderVertices(batch, gpu::LINES, _debugMeshBoxesID); + colorNdx++; } - QVector points; - - glm::vec3 brn = box.getCorner(); - glm::vec3 bln = brn + glm::vec3(box.getDimensions().x, 0, 0); - glm::vec3 brf = brn + glm::vec3(0, 0, box.getDimensions().z); - glm::vec3 blf = brn + glm::vec3(box.getDimensions().x, 0, box.getDimensions().z); - - glm::vec3 trn = brn + glm::vec3(0, box.getDimensions().y, 0); - glm::vec3 tln = bln + glm::vec3(0, box.getDimensions().y, 0); - glm::vec3 trf = brf + glm::vec3(0, box.getDimensions().y, 0); - glm::vec3 tlf = blf + glm::vec3(0, box.getDimensions().y, 0); - - points << brn << bln; - points << brf << blf; - points << brn << brf; - points << bln << blf; - - points << trn << tln; - points << trf << tlf; - points << trn << trf; - points << tln << tlf; - - points << brn << trn; - points << brf << trf; - points << bln << tln; - points << blf << tlf; - - glm::vec4 color[] = { - { 0.0f, 1.0f, 0.0f, 1.0f }, // green - { 1.0f, 0.0f, 0.0f, 1.0f }, // red - { 0.0f, 0.0f, 1.0f, 1.0f }, // blue - { 1.0f, 0.0f, 1.0f, 1.0f }, // purple - { 1.0f, 1.0f, 0.0f, 1.0f }, // yellow - { 0.0f, 1.0f, 1.0f, 1.0f }, // cyan - { 1.0f, 1.0f, 1.0f, 1.0f }, // white - { 0.0f, 0.5f, 0.0f, 1.0f }, - { 0.0f, 0.0f, 0.5f, 1.0f }, - { 0.5f, 0.0f, 0.5f, 1.0f }, - { 0.5f, 0.5f, 0.0f, 1.0f }, - { 0.0f, 0.5f, 0.5f, 1.0f } }; - - DependencyManager::get()->updateVertices(_debugMeshBoxesID, points, color[colorNdx]); - DependencyManager::get()->renderVertices(batch, gpu::LINES, _debugMeshBoxesID); - colorNdx++; } _mutex.unlock(); } diff --git a/libraries/render-utils/src/Model.h b/libraries/render-utils/src/Model.h index bc82a0d335..0bddae6a38 100644 --- a/libraries/render-utils/src/Model.h +++ b/libraries/render-utils/src/Model.h @@ -423,8 +423,7 @@ protected: bool _overrideModelTransform { false }; bool _triangleSetsValid { false }; void calculateTriangleSets(const FBXGeometry& geometry); - QVector _modelSpaceMeshTriangleSets; // model space triangles for all sub meshes - + std::vector> _modelSpaceMeshTriangleSets; // model space triangles for all sub meshes virtual void createRenderItemSet(); diff --git a/libraries/shared/src/TriangleSet.h b/libraries/shared/src/TriangleSet.h index 9f688f9def..2853d0f68e 100644 --- a/libraries/shared/src/TriangleSet.h +++ b/libraries/shared/src/TriangleSet.h @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#pragma once + #include #include "AABox.h" diff --git a/scripts/developer/tests/raypickTester.js b/scripts/developer/tests/raypickTester.js new file mode 100644 index 0000000000..a6704fc55c --- /dev/null +++ b/scripts/developer/tests/raypickTester.js @@ -0,0 +1,73 @@ +// raypickTester.js +// +// display intersection details (including material) when hovering over entities/avatars/overlays +// + +/* eslint-disable comma-dangle, no-empty, no-magic-numbers */ + +var PICK_FILTERS = Picks.PICK_ENTITIES | Picks.PICK_OVERLAYS | Picks.PICK_AVATARS | Picks.PICK_INCLUDE_NONCOLLIDABLE; +var HAND_JOINT = '_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND'.replace('RIGHT', MyAvatar.getDominantHand().toUpperCase()); +var JOINT_NAME = HMD.active ? HAND_JOINT : 'Mouse'; +var UPDATE_MS = 1000/30; + +// create tect3d overlay to display hover results +var overlayID = Overlays.addOverlay('text3d', { + text: 'hover', + visible: false, + backgroundAlpha: 0, + isFacingAvatar: true, + lineHeight: 0.05, + dimensions: Vec3.HALF, +}); +Script.scriptEnding.connect(function() { + Overlays.deleteOverlay(overlayID); +}); + +// create raycast picker +var pickID = Picks.createPick(PickType.Ray, { + joint: JOINT_NAME, + filter: PICK_FILTERS, + enabled: true, +}); +var blacklist = [ overlayID ]; // exclude hover text from ray pick results +Picks.setIgnoreItems(pickID, blacklist); +Script.scriptEnding.connect(function() { + RayPick.removeRayPick(pickID); +}); + +// query object materials (using the Graphics.* API) +function getSubmeshMaterial(objectID, shapeID) { + try { + var materialLayers = Graphics.getModel(objectID).materialLayers; + var shapeMaterialLayers = materialLayers[shapeID]; + return shapeMaterialLayers[0].material; + } catch (e) { + return { name: '' }; + } +} + +// refresh hover overlay text based on intersection results +function updateOverlay(overlayID, result) { + var material = this.getSubmeshMaterial(result.objectID, result.extraInfo.shapeID); + var position = Vec3.mix(result.searchRay.origin, result.intersection, 0.5); + var extraInfo = result.extraInfo; + var text = [ + 'mesh: ' + extraInfo.subMeshName, + 'materialName: ' + material.name, + 'type: ' + Entities.getNestableType(result.objectID), + 'distance: ' + result.distance.toFixed(2)+'m', + ['submesh: ' + extraInfo.subMeshIndex, 'part: '+extraInfo.partIndex, 'shape: '+extraInfo.shapeID].join(' | '), + ].filter(Boolean).join('\n'); + + Overlays.editOverlay(overlayID, { + text: text, + position: position, + visible: result.intersects, + }); +} + +// monitor for enw results at 30fps +Script.setInterval(function() { + var result = RayPick.getPrevRayPickResult(pickID); + updateOverlay(overlayID, result); +}, UPDATE_MS); From 5de451e8e0cec8716f9597766c12cb461953145e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 19 Jun 2018 14:52:49 +1200 Subject: [PATCH 07/36] Update entity list upon entity deletion --- scripts/system/edit.js | 22 +++++++++++++--------- scripts/system/html/js/entityList.js | 2 +- scripts/system/html/js/entityProperties.js | 4 ++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 02af474f55..01e4a071e1 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -475,18 +475,22 @@ var toolBar = (function () { var DELETE_ENTITY_TIMER_TIMEOUT = 100; function checkDeletedEntityAndUpdate(entityID) { + // Allow for multiple entity deletes before updating the entities selected. if (selectionManager.selections.indexOf(entityID) !== -1) { - // Allow for multiple entity deletes before updating the entities selected. entitiesToDelete.push(entityID); - if (deletedEntityTimer !== null) { - Script.clearTimeout(deletedEntityTimer); - } - deletedEntityTimer = Script.setTimeout(function () { - selectionManager.removeEntities(entitiesToDelete); - entitiesToDelete = []; - deletedEntityTimer = null; - }, DELETE_ENTITY_TIMER_TIMEOUT); } + if (deletedEntityTimer !== null) { + Script.clearTimeout(deletedEntityTimer); + } + deletedEntityTimer = Script.setTimeout(function () { + if (entitiesToDelete.length > 0) { + selectionManager.removeEntities(entitiesToDelete); + } + entityListTool.clearEntityList(); + entityListTool.sendUpdate(); + entitiesToDelete = []; + deletedEntityTimer = null; + }, DELETE_ENTITY_TIMER_TIMEOUT); } function initialize() { diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 88b3ccbf7c..0b02dd6d4f 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -346,7 +346,7 @@ function loaded() { if (notFound) { refreshEntities(); } - } else if (data.type == "update") { + } else if (data.type == "update" && data.selectedIDs !== undefined) { var newEntities = data.entities; if (newEntities && newEntities.length == 0) { elNoEntitiesMessage.style.display = "block"; diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 4271aa9b09..f5b24a5f8e 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -893,9 +893,9 @@ function loaded() { } else { elServerScriptStatus.innerText = "Not running"; } - } else if (data.type === "update") { + } else if (data.type === "update" && data.selections) { - if (!data.selections || data.selections.length === 0) { + if (data.selections.length === 0) { if (lastEntityID !== null) { if (editor !== null) { saveJSONUserData(true); From 064f4ca2045dcd1f04811834004990e4207c66a3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 19 Jun 2018 16:22:59 +1200 Subject: [PATCH 08/36] Remove deleted entities from list without scrolling to top --- scripts/system/edit.js | 7 ++----- scripts/system/html/js/entityList.js | 16 +++++++++++++++- scripts/system/libraries/entityList.js | 9 +++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 01e4a071e1..3eae6ebe7c 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -476,9 +476,7 @@ var toolBar = (function () { function checkDeletedEntityAndUpdate(entityID) { // Allow for multiple entity deletes before updating the entities selected. - if (selectionManager.selections.indexOf(entityID) !== -1) { - entitiesToDelete.push(entityID); - } + entitiesToDelete.push(entityID); if (deletedEntityTimer !== null) { Script.clearTimeout(deletedEntityTimer); } @@ -486,8 +484,7 @@ var toolBar = (function () { if (entitiesToDelete.length > 0) { selectionManager.removeEntities(entitiesToDelete); } - entityListTool.clearEntityList(); - entityListTool.sendUpdate(); + entityListTool.removeEntities(entitiesToDelete, selectionManager.selections); entitiesToDelete = []; deletedEntityTimer = null; }, DELETE_ENTITY_TIMER_TIMEOUT); diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 0b02dd6d4f..11a875dbb5 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -195,6 +195,18 @@ function loaded() { } } + function removeEntities(deletedIDs, selectedIDs) { + for (i = 0, length = deletedIDs.length; i < length; i++) { + delete entities[deletedIDs[i]]; + entityList.remove("id", deletedIDs[i]); + } + if (refreshEntityListTimer) { + clearTimeout(refreshEntityListTimer); + } + refreshEntityListTimer = setTimeout(refreshEntityListObject, 50); + updateSelectedEntities(selectedIDs); + } + function clearEntities() { entities = {}; entityList.clear(); @@ -346,7 +358,7 @@ function loaded() { if (notFound) { refreshEntities(); } - } else if (data.type == "update" && data.selectedIDs !== undefined) { + } else if (data.type === "update" && data.selectedIDs !== undefined) { var newEntities = data.entities; if (newEntities && newEntities.length == 0) { elNoEntitiesMessage.style.display = "block"; @@ -367,6 +379,8 @@ function loaded() { updateSelectedEntities(data.selectedIDs); resize(); } + } else if (data.type === "removeEntities" && data.deletedIDs !== undefined) { + removeEntities(data.deletedIDs, data.selectedIDs); } else if (data.type === "deleted") { for (i = 0, length = data.ids.length; i < length; i++) { delete entities[data.ids[i]]; diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index 611bd4d84c..3fda7588df 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -57,6 +57,15 @@ EntityListTool = function(opts) { webView.emitScriptEvent(JSON.stringify(data)); }; + that.removeEntities = function (deletedIDs, selectedIDs) { + var data = { + type: 'removeEntities', + deletedIDs: deletedIDs, + selectedIDs: selectedIDs + }; + webView.emitScriptEvent(JSON.stringify(data)); + }; + function valueIfDefined(value) { return value !== undefined ? value : ""; } From 79293310e56a58efd40d0978e99635514d9d1f78 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 19 Jun 2018 11:59:31 -0700 Subject: [PATCH 09/36] No more use of JPG files. --- tools/auto-tester/src/ImageComparer.cpp | 4 +-- tools/auto-tester/src/Test.cpp | 35 +++++-------------------- tools/auto-tester/src/Test.h | 4 +-- 3 files changed, 9 insertions(+), 34 deletions(-) diff --git a/tools/auto-tester/src/ImageComparer.cpp b/tools/auto-tester/src/ImageComparer.cpp index 56da37f225..fa73f97887 100644 --- a/tools/auto-tester/src/ImageComparer.cpp +++ b/tools/auto-tester/src/ImageComparer.cpp @@ -15,10 +15,8 @@ // Computes SSIM - see https://en.wikipedia.org/wiki/Structural_similarity // The value is computed for the luminance component and the average value is returned double ImageComparer::compareImages(QImage resultImage, QImage expectedImage) const { - // Make sure the image is 8 bits per colour - QImage::Format format = expectedImage.format(); - const int L = 255; // (2^number of bits per pixel) - 1 + const double K1 { 0.01 }; const double K2 { 0.03 }; const double c1 = pow((K1 * L), 2); diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 7a61782f9e..88f4e58782 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -202,17 +202,6 @@ void Test::startTestsEvaluation(const QString& testFolder, const QString& branch return; } - // Before any processing - all images are converted to PNGs, as this is the format stored on GitHub - QStringList sortedSnapshotFilenames = createListOfAll_imagesInDirectory("jpg", snapshotDirectory); - foreach(QString filename, sortedSnapshotFilenames) { - QString filenameWithoutExtension = filename.left(filename.length() - 4); - copyJPGtoPNG(snapshotDirectory + "/" + filenameWithoutExtension + ".jpg", - snapshotDirectory + "/" + filenameWithoutExtension + ".png" - ); - - QFile::remove(snapshotDirectory + "/" + filenameWithoutExtension + ".jpg"); - } - // Create two lists. The first is the test results, the second is the expected images // The expected images are represented as a URL to enable download from GitHub // Images that are in the wrong format are ignored. @@ -513,13 +502,13 @@ void Test::createTests() { return; } - QStringList sortedImageFilenames = createListOfAll_imagesInDirectory("jpg", snapshotDirectory); + QStringList sortedImageFilenames = createListOfAll_imagesInDirectory("png", snapshotDirectory); int i = 1; const int maxImages = pow(10, NUM_DIGITS); foreach (QString currentFilename, sortedImageFilenames) { QString fullCurrentFilename = snapshotDirectory + "/" + currentFilename; - if (isInSnapshotFilenameFormat("jpg", currentFilename)) { + if (isInSnapshotFilenameFormat("png", currentFilename)) { if (i >= maxImages) { QMessageBox::critical(0, "Error", "More than " + QString::number(maxImages) + " images not supported"); exit(-1); @@ -543,9 +532,12 @@ void Test::createTests() { fullNewFileName += "/" + newFilename; try { - copyJPGtoPNG(fullCurrentFilename, fullNewFileName); + if (QFile::exists(fullNewFileName)) { + QFile::remove(fullNewFileName); + } + QFile::copy(fullCurrentFilename, fullNewFileName); } catch (...) { - QMessageBox::critical(0, "Error", "Could not delete existing file: " + currentFilename + "\nTest creation aborted"); + QMessageBox::critical(0, "Error", "Could not copy file: " + fullCurrentFilename + " to " + fullNewFileName + "\n"); exit(-1); } ++i; @@ -824,19 +816,6 @@ void Test::createTestsOutline() { QMessageBox::information(0, "Success", "Test outline file " + testsOutlineFilename + " has been created"); } -void Test::copyJPGtoPNG(const QString& sourceJPGFullFilename, const QString& destinationPNGFullFilename) { - QFile::remove(destinationPNGFullFilename); - - QImageReader reader; - reader.setFileName(sourceJPGFullFilename); - - QImage image = reader.read(); - - QImageWriter writer; - writer.setFileName(destinationPNGFullFilename); - writer.write(image); -} - QStringList Test::createListOfAll_imagesInDirectory(const QString& imageFormat, const QString& pathToImageDirectory) { imageDirectory = QDir(pathToImageDirectory); QStringList nameFilters; diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index b91a49ed95..94d868338d 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -69,14 +69,12 @@ public: QString getExpectedImageDestinationDirectory(const QString& filename); QString getExpectedImagePartialSourceDirectory(const QString& filename); - void copyJPGtoPNG(const QString& sourceJPGFullFilename, const QString& destinationPNGFullFilename); - private: const QString TEST_FILENAME { "test.js" }; const QString TEST_RESULTS_FOLDER { "TestResults" }; const QString TEST_RESULTS_FILENAME { "TestResults.txt" }; - const double THRESHOLD{ 0.999 }; + const double THRESHOLD{ 0.96 }; QDir imageDirectory; From 568ba6f77762f6f9748fceed21ede22eba927f36 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 19 Jun 2018 14:14:16 -0700 Subject: [PATCH 10/36] fixing shape entity --- .../src/RenderableEntityItem.cpp | 10 +++++++- .../src/RenderableEntityItem.h | 1 + .../src/RenderableShapeEntityItem.cpp | 25 +++++++++++++------ .../src/RenderableTextEntityItem.cpp | 12 +++++++++ .../src/RenderableTextEntityItem.h | 2 ++ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp index ae4c13d96f..d44e66aa6b 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp @@ -363,6 +363,14 @@ bool EntityRenderer::needsRenderUpdateFromEntity(const EntityItemPointer& entity return false; } +void EntityRenderer::updateModelTransform() { + bool success = false; + auto newModelTransform = _entity->getTransformToCenter(success); + if (success) { + _modelTransform = newModelTransform; + } +} + void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) { DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__); withWriteLock([&] { @@ -419,4 +427,4 @@ void EntityRenderer::addMaterial(graphics::MaterialLayer material, const std::st void EntityRenderer::removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) { std::lock_guard lock(_materialsLock); _materials[parentMaterialName].remove(material); -} \ No newline at end of file +} diff --git a/libraries/entities-renderer/src/RenderableEntityItem.h b/libraries/entities-renderer/src/RenderableEntityItem.h index e1ce2ed39e..1083d74807 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.h +++ b/libraries/entities-renderer/src/RenderableEntityItem.h @@ -97,6 +97,7 @@ protected: virtual void doRender(RenderArgs* args) = 0; bool isFading() const { return _isFading; } + void updateModelTransform(); virtual bool isTransparent() const { return _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f : false; } inline bool isValidRenderItem() const { return _renderItemID != Item::INVALID_ITEM_ID; } diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp index 69068b81d2..2e0656ab81 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp @@ -97,16 +97,25 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce addMaterial(graphics::MaterialLayer(_material, 0), "0"); _shape = entity->getShape(); - _position = entity->getWorldPosition(); - _dimensions = entity->getScaledDimensions(); - _orientation = entity->getWorldOrientation(); - _renderTransform = getModelTransform(); + }); - if (_shape == entity::Sphere) { - _renderTransform.postScale(SPHERE_ENTITY_SCALE); - } + void* key = (void*)this; + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () { + withWriteLock([&] { + auto entity = getEntity(); + _position = entity->getWorldPosition(); + _dimensions = entity->getScaledDimensions(); + _orientation = entity->getWorldOrientation(); + bool success = false; + auto newModelTransform = entity->getTransformToCenter(success); + _renderTransform = success ? newModelTransform : getModelTransform(); - _renderTransform.postScale(_dimensions); + if (_shape == entity::Sphere) { + _renderTransform.postScale(SPHERE_ENTITY_SCALE); + } + + _renderTransform.postScale(_dimensions); + });; }); } diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index e58eb540e8..25e7b0750a 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -20,6 +20,7 @@ #include "GLMHelpers.h" +using namespace render; using namespace render::entities; static const int FIXED_FONT_POINT_SIZE = 40; @@ -64,6 +65,17 @@ bool TextEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint return false; } +void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { + void* key = (void*)this; + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () { + withWriteLock([&] { + auto entity = getEntity(); + _position = entity->getWorldPosition(); + updateModelTransform(); + }); + }); +} + void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { _textColor = toGlm(entity->getTextColorX()); _backgroundColor = toGlm(entity->getBackgroundColorX()); diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.h b/libraries/entities-renderer/src/RenderableTextEntityItem.h index b0a72cf253..4c64ec7c4d 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.h +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.h @@ -27,6 +27,7 @@ public: ~TextEntityRenderer(); private: virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override; + virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override; virtual void doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) override; virtual void doRender(RenderArgs* args) override; int _geometryID{ 0 }; @@ -34,6 +35,7 @@ private: bool _faceCamera; glm::vec3 _dimensions; glm::vec3 _textColor; + glm::vec3 _position; glm::vec3 _backgroundColor; QString _text; float _lineHeight; From 61cbe84ae5c95a6f20a2448d85b10c2671820a2c Mon Sep 17 00:00:00 2001 From: David Back Date: Tue, 19 Jun 2018 14:39:58 -0700 Subject: [PATCH 11/36] fix stretching below minimum still moving entity --- scripts/system/libraries/entitySelectionTool.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 1b41559160..4c0202b43f 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -2129,10 +2129,19 @@ SelectionDisplay = (function() { } var minimumDimension = directionEnum === STRETCH_DIRECTION.ALL ? STRETCH_ALL_MINIMUM_DIMENSION : - STRETCH_MINIMUM_DIMENSION; - newDimensions.x = Math.max(newDimensions.x, minimumDimension); - newDimensions.y = Math.max(newDimensions.y, minimumDimension); - newDimensions.z = Math.max(newDimensions.z, minimumDimension); + STRETCH_MINIMUM_DIMENSION; + if (newDimensions.x <= minimumDimension) { + newDimensions.x = minimumDimension; + changeInDimensions.x = minimumDimension - initialDimensions.x; + } + if (newDimensions.y <= minimumDimension) { + newDimensions.y = minimumDimension; + changeInDimensions.y = minimumDimension - initialDimensions.y; + } + if (newDimensions.z <= minimumDimension) { + newDimensions.z = minimumDimension; + changeInDimensions.z = minimumDimension - initialDimensions.z; + } var changeInPosition = Vec3.multiplyQbyV(rotation, vec3Mult(localDeltaPivot, changeInDimensions)); if (directionEnum === STRETCH_DIRECTION.ALL) { From 633be87473dc428e9f7ffc11d3b4b9758bfe7b76 Mon Sep 17 00:00:00 2001 From: David Back Date: Tue, 19 Jun 2018 14:57:46 -0700 Subject: [PATCH 12/36] fix stretch panel dimensions --- scripts/system/libraries/entitySelectionTool.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 4c0202b43f..6cb5bc5d00 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -1332,9 +1332,10 @@ SelectionDisplay = (function() { dimensions: stretchPanelXDimensions }); var stretchPanelYDimensions = Vec3.subtract(scaleLTNCubePositionRotated, scaleRTFCubePositionRotated); + var tempX = Math.abs(stretchPanelYDimensions.x); stretchPanelYDimensions.x = Math.abs(stretchPanelYDimensions.z); stretchPanelYDimensions.y = STRETCH_PANEL_WIDTH; - stretchPanelYDimensions.z = Math.abs(stretchPanelYDimensions.x); + stretchPanelYDimensions.z = tempX; var stretchPanelYPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x:0, y:dimensions.y / 2, z:0 })); Overlays.editOverlay(handleStretchYPanel, { position: stretchPanelYPosition, @@ -1342,8 +1343,9 @@ SelectionDisplay = (function() { dimensions: stretchPanelYDimensions }); var stretchPanelZDimensions = Vec3.subtract(scaleLTNCubePositionRotated, scaleRBFCubePositionRotated); + var tempX = Math.abs(stretchPanelZDimensions.x); stretchPanelZDimensions.x = Math.abs(stretchPanelZDimensions.y); - stretchPanelZDimensions.y = Math.abs(stretchPanelZDimensions.x); + stretchPanelZDimensions.y = tempX; stretchPanelZDimensions.z = STRETCH_PANEL_WIDTH; var stretchPanelZPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x:0, y:0, z:dimensions.z / 2 })); Overlays.editOverlay(handleStretchZPanel, { From 694c272424658d5f7cff1f73d6230c4da3707ad8 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 19 Jun 2018 16:27:10 -0700 Subject: [PATCH 13/36] fixed text entity --- .../src/RenderableTextEntityItem.cpp | 29 ++++++++++--------- .../src/RenderableTextEntityItem.h | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index 25e7b0750a..46f3709c91 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -67,35 +67,39 @@ bool TextEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPoint void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { void* key = (void*)this; - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () { + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] () { withWriteLock([&] { - auto entity = getEntity(); - _position = entity->getWorldPosition(); + _dimensions = entity->getScaledDimensions(); updateModelTransform(); + _renderTransform = getModelTransform(); }); }); } void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { - _textColor = toGlm(entity->getTextColorX()); - _backgroundColor = toGlm(entity->getBackgroundColorX()); - _dimensions = entity->getScaledDimensions(); - _faceCamera = entity->getFaceCamera(); - _lineHeight = entity->getLineHeight(); - _text = entity->getText(); + _textColor = toGlm(entity->getTextColorX()); + _backgroundColor = toGlm(entity->getBackgroundColorX()); + _faceCamera = entity->getFaceCamera(); + _lineHeight = entity->getLineHeight(); + _text = entity->getText(); } void TextEntityRenderer::doRender(RenderArgs* args) { PerformanceTimer perfTimer("RenderableTextEntityItem::render"); - + + Transform modelTransform; + glm::vec3 dimensions; + withReadLock([&] { + modelTransform = _renderTransform; + dimensions = _dimensions; + }); static const float SLIGHTLY_BEHIND = -0.005f; float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f; bool transparent = fadeRatio < 1.0f; glm::vec4 textColor = glm::vec4(_textColor, fadeRatio); glm::vec4 backgroundColor = glm::vec4(_backgroundColor, fadeRatio); - const glm::vec3& dimensions = _dimensions; - + // Render background glm::vec3 minCorner = glm::vec3(0.0f, -dimensions.y, SLIGHTLY_BEHIND); glm::vec3 maxCorner = glm::vec3(dimensions.x, 0.0f, SLIGHTLY_BEHIND); @@ -105,7 +109,6 @@ void TextEntityRenderer::doRender(RenderArgs* args) { Q_ASSERT(args->_batch); gpu::Batch& batch = *args->_batch; - const auto& modelTransform = getModelTransform(); auto transformToTopLeft = modelTransform; if (_faceCamera) { //rotate about vertical to face the camera diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.h b/libraries/entities-renderer/src/RenderableTextEntityItem.h index 4c64ec7c4d..93d6deb354 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.h +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.h @@ -35,7 +35,7 @@ private: bool _faceCamera; glm::vec3 _dimensions; glm::vec3 _textColor; - glm::vec3 _position; + Transform _renderTransform; glm::vec3 _backgroundColor; QString _text; float _lineHeight; From 3d4f164a9f1a1aeef877e13ed7d59983eb810b88 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 19 Jun 2018 16:53:36 -0700 Subject: [PATCH 14/36] fixing web entity and whitespace cleanup --- .../src/RenderableTextEntityItem.cpp | 10 +++--- .../src/RenderableWebEntityItem.cpp | 36 +++++++++++-------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index 46f3709c91..4f08fca1d7 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -103,8 +103,8 @@ void TextEntityRenderer::doRender(RenderArgs* args) { // Render background glm::vec3 minCorner = glm::vec3(0.0f, -dimensions.y, SLIGHTLY_BEHIND); glm::vec3 maxCorner = glm::vec3(dimensions.x, 0.0f, SLIGHTLY_BEHIND); - - + + // Batch render calls Q_ASSERT(args->_batch); gpu::Batch& batch = *args->_batch; @@ -120,7 +120,7 @@ void TextEntityRenderer::doRender(RenderArgs* args) { } transformToTopLeft.postTranslate(dimensions * glm::vec3(-0.5f, 0.5f, 0.0f)); // Go to the top left transformToTopLeft.setScale(1.0f); // Use a scale of one so that the text is not deformed - + batch.setModelTransform(transformToTopLeft); auto geometryCache = DependencyManager::get(); if (!_geometryID) { @@ -128,11 +128,11 @@ void TextEntityRenderer::doRender(RenderArgs* args) { } geometryCache->bindSimpleProgram(batch, false, transparent, false, false, false); geometryCache->renderQuad(batch, minCorner, maxCorner, backgroundColor, _geometryID); - + float scale = _lineHeight / _textRenderer->getFontSize(); transformToTopLeft.setScale(scale); // Scale to have the correct line height batch.setModelTransform(transformToTopLeft); - + float leftMargin = 0.1f * _lineHeight, topMargin = 0.1f * _lineHeight; glm::vec2 bounds = glm::vec2(dimensions.x - 2.0f * leftMargin, dimensions.y - 2.0f * topMargin); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 693e3d0cf4..17d6d58781 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -149,8 +149,8 @@ void WebEntityRenderer::onTimeout() { } void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) { - // If the content type has changed, or the old content type was QML, we need to - // destroy the existing surface (because surfaces don't support changing the root + // If the content type has changed, or the old content type was QML, we need to + // destroy the existing surface (because surfaces don't support changing the root // object, so subsequent loads of content just overlap the existing content bool urlChanged = false; { @@ -187,24 +187,30 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene if (!hasWebSurface() && !buildWebSurface(entity)) { return; } - + if (urlChanged && _contentType == ContentType::HtmlContent) { _webSurface->getRootItem()->setProperty(URL_PROPERTY, _lastSourceUrl); } - if (_contextPosition != entity->getWorldPosition()) { - // update globalPosition - _contextPosition = entity->getWorldPosition(); - _webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(_contextPosition)); - } + void* key = (void*)this; + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] () { + withWriteLock([&] { + if (_contextPosition != entity->getWorldPosition()) { + // update globalPosition + _contextPosition = entity->getWorldPosition(); + _webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(_contextPosition)); + } - _lastDPI = entity->getDPI(); - _lastLocked = entity->getLocked(); + _lastDPI = entity->getDPI(); + _lastLocked = entity->getLocked(); - glm::vec2 windowSize = getWindowSize(entity); - _webSurface->resize(QSize(windowSize.x, windowSize.y)); - _renderTransform = getModelTransform(); - _renderTransform.postScale(entity->getScaledDimensions()); + glm::vec2 windowSize = getWindowSize(entity); + _webSurface->resize(QSize(windowSize.x, windowSize.y)); + updateModelTransform(); + _renderTransform = getModelTransform(); + _renderTransform.postScale(entity->getScaledDimensions()); + }); + }); }); } @@ -297,7 +303,7 @@ bool WebEntityRenderer::buildWebSurface(const TypedEntityPointer& entity) { if (_contentType == ContentType::HtmlContent) { // We special case YouTube URLs since we know they are videos that we should play with at least 30 FPS. - // FIXME this doesn't handle redirects or shortened URLs, consider using a signaling method from the + // FIXME this doesn't handle redirects or shortened URLs, consider using a signaling method from the // web entity if (QUrl(_lastSourceUrl).host().endsWith("youtube.com", Qt::CaseInsensitive)) { _webSurface->setMaxFps(YOUTUBE_MAX_FPS); From f891c37ac88bc6acfca1dc2b159a941ce75729c8 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 20 Jun 2018 10:59:19 -0700 Subject: [PATCH 15/36] fix particle entity --- .../src/RenderableParticleEffectEntityItem.cpp | 13 ++++++++++++- .../src/RenderableParticleEffectEntityItem.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index 881c39c0bd..104af39c99 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -125,6 +125,14 @@ void ParticleEffectEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePoi }); } } + + void* key = (void*)this; + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () { + withWriteLock([&] { + updateModelTransform(); + _renderTransform = getModelTransform(); + }); + }); } void ParticleEffectEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { @@ -324,7 +332,10 @@ void ParticleEffectEntityRenderer::doRender(RenderArgs* args) { // In trail mode, the particles are created in world space. // so we only set a transform if they're not in trail mode if (!_particleProperties.emission.shouldTrail) { - transform = getModelTransform(); + + withReadLock([&] { + transform = _renderTransform; + }); transform.setScale(vec3(1)); } batch.setModelTransform(transform); diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h index be2641c0c9..0b121a6dda 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h @@ -103,6 +103,7 @@ private: BufferPointer _particleBuffer{ std::make_shared() }; BufferView _uniformBuffer; quint64 _lastSimulated { 0 }; + Transform _renderTransform; NetworkTexturePointer _networkTexture; ScenePointer _scene; From 7704e8c2a97b404ce1e0c61496039835b6e201aa Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 20 Jun 2018 14:47:41 -0700 Subject: [PATCH 16/36] fix stretching too far, improve stretch sphere vs camera dist sizing --- .../system/libraries/entitySelectionTool.js | 59 +++++++++++++------ 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 6cb5bc5d00..62eb845191 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -307,7 +307,7 @@ SelectionDisplay = (function() { var STRETCH_PANEL_WIDTH = 0.01; var SCALE_CUBE_OFFSET = 0.5; - var SCALE_CUBE_CAMERA_DISTANCE_MULTIPLE = 0.015; + var SCALE_CUBE_CAMERA_DISTANCE_MULTIPLE = 0.0125; var CLONER_OFFSET = { x:0.9, y:-0.9, z:0.9 }; @@ -1216,61 +1216,73 @@ SelectionDisplay = (function() { var scaleCubeOffsetX = SCALE_CUBE_OFFSET * dimensions.x; var scaleCubeOffsetY = SCALE_CUBE_OFFSET * dimensions.y; var scaleCubeOffsetZ = SCALE_CUBE_OFFSET * dimensions.z; - var scaleCubeDimension = rotateDimension * SCALE_CUBE_CAMERA_DISTANCE_MULTIPLE / - ROTATE_RING_CAMERA_DISTANCE_MULTIPLE; - var scaleCubeDimensions = { x:scaleCubeDimension, y:scaleCubeDimension, z:scaleCubeDimension }; var scaleCubeRotation = spaceMode === SPACE_LOCAL ? rotation : Quat.IDENTITY; var scaleLBNCubePosition = { x:-scaleCubeOffsetX, y:-scaleCubeOffsetY, z:-scaleCubeOffsetZ }; scaleLBNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLBNCubePosition)); + var scaleLBNCubeToCamera = getDistanceToCamera(scaleLBNCubePosition); + var scaleRBNCubePosition = { x:scaleCubeOffsetX, y:-scaleCubeOffsetY, z:-scaleCubeOffsetZ }; + scaleRBNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRBNCubePosition)); + var scaleRBNCubeToCamera = getDistanceToCamera(scaleRBNCubePosition); + var scaleLBFCubePosition = { x:-scaleCubeOffsetX, y:-scaleCubeOffsetY, z:scaleCubeOffsetZ }; + scaleLBFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLBFCubePosition)); + var scaleLBFCubeToCamera = getDistanceToCamera(scaleLBFCubePosition); + var scaleRBFCubePosition = { x:scaleCubeOffsetX, y:-scaleCubeOffsetY, z:scaleCubeOffsetZ }; + scaleRBFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRBFCubePosition)); + var scaleRBFCubeToCamera = getDistanceToCamera(scaleRBFCubePosition); + var scaleLTNCubePosition = { x:-scaleCubeOffsetX, y:scaleCubeOffsetY, z:-scaleCubeOffsetZ }; + scaleLTNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLTNCubePosition)); + var scaleLTNCubeToCamera = getDistanceToCamera(scaleLTNCubePosition); + var scaleRTNCubePosition = { x:scaleCubeOffsetX, y:scaleCubeOffsetY, z:-scaleCubeOffsetZ }; + scaleRTNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRTNCubePosition)); + var scaleRTNCubeToCamera = getDistanceToCamera(scaleRTNCubePosition); + var scaleLTFCubePosition = { x:-scaleCubeOffsetX, y:scaleCubeOffsetY, z:scaleCubeOffsetZ }; + scaleLTFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLTFCubePosition)); + var scaleLTFCubeToCamera = getDistanceToCamera(scaleLTFCubePosition); + var scaleRTFCubePosition = { x:scaleCubeOffsetX, y:scaleCubeOffsetY, z:scaleCubeOffsetZ }; + scaleRTFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRTFCubePosition)); + var scaleRTFCubeToCamera = getDistanceToCamera(scaleRTFCubePosition); + + var scaleCubeToCamera = Math.min(scaleLBNCubeToCamera, scaleRBNCubeToCamera, scaleLBFCubeToCamera, + scaleRBFCubeToCamera, scaleLTNCubeToCamera, scaleRTNCubeToCamera, + scaleLTFCubeToCamera, scaleRTFCubeToCamera); + var scaleCubeDimension = scaleCubeToCamera * SCALE_CUBE_CAMERA_DISTANCE_MULTIPLE; + var scaleCubeDimensions = { x:scaleCubeDimension, y:scaleCubeDimension, z:scaleCubeDimension }; + Overlays.editOverlay(handleScaleLBNCube, { position: scaleLBNCubePosition, rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleRBNCubePosition = { x:scaleCubeOffsetX, y:-scaleCubeOffsetY, z:-scaleCubeOffsetZ }; - scaleRBNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRBNCubePosition)); Overlays.editOverlay(handleScaleRBNCube, { position: scaleRBNCubePosition, rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleLBFCubePosition = { x:-scaleCubeOffsetX, y:-scaleCubeOffsetY, z:scaleCubeOffsetZ }; - scaleLBFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLBFCubePosition)); Overlays.editOverlay(handleScaleLBFCube, { position: scaleLBFCubePosition, rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleRBFCubePosition = { x:scaleCubeOffsetX, y:-scaleCubeOffsetY, z:scaleCubeOffsetZ }; - scaleRBFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRBFCubePosition)); Overlays.editOverlay(handleScaleRBFCube, { position: scaleRBFCubePosition, rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleLTNCubePosition = { x:-scaleCubeOffsetX, y:scaleCubeOffsetY, z:-scaleCubeOffsetZ }; - scaleLTNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLTNCubePosition)); Overlays.editOverlay(handleScaleLTNCube, { position: scaleLTNCubePosition, rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleRTNCubePosition = { x:scaleCubeOffsetX, y:scaleCubeOffsetY, z:-scaleCubeOffsetZ }; - scaleRTNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRTNCubePosition)); Overlays.editOverlay(handleScaleRTNCube, { position: scaleRTNCubePosition, rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleLTFCubePosition = { x:-scaleCubeOffsetX, y:scaleCubeOffsetY, z:scaleCubeOffsetZ }; - scaleLTFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLTFCubePosition)); Overlays.editOverlay(handleScaleLTFCube, { position: scaleLTFCubePosition, rotation: scaleCubeRotation, dimensions: scaleCubeDimensions }); - var scaleRTFCubePosition = { x:scaleCubeOffsetX, y:scaleCubeOffsetY, z:scaleCubeOffsetZ }; - scaleRTFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRTFCubePosition)); Overlays.editOverlay(handleScaleRTFCube, { position: scaleRTFCubePosition, rotation: scaleCubeRotation, @@ -1794,7 +1806,7 @@ SelectionDisplay = (function() { var dotVector = Vec3.dot(vector, projectionVector); vector = Vec3.multiply(dotVector, projectionVector); vector = grid.snapToGrid(vector); - + var wantDebug = false; if (wantDebug) { print("translateUpDown... "); @@ -1874,6 +1886,7 @@ SelectionDisplay = (function() { var pickRayPosition = null; var pickRayPosition3D = null; var rotation = null; + var previousPickRay = null; var onBegin = function(event, pickRay, pickResult) { var properties = Entities.getEntityProperties(SelectionManager.selections[0]); @@ -2047,6 +2060,8 @@ SelectionDisplay = (function() { Menu.setIsOptionChecked(AVATAR_COLLISIONS_OPTION, false); handleStretchCollisionOverride = true; } + + previousPickRay = pickRay; }; var onEnd = function(event, reason) { @@ -2077,6 +2092,10 @@ SelectionDisplay = (function() { var localDeltaPivot = deltaPivot; var localSigns = signs; var pickRay = generalComputePickRay(event.x, event.y); + if ((Vec3.dot(pickRay.direction, planeNormal) > 0 && Vec3.dot(previousPickRay.direction, planeNormal) < 0) || + (Vec3.dot(pickRay.direction, planeNormal) < 0 && Vec3.dot(previousPickRay.direction, planeNormal) > 0)) { + pickRay = previousPickRay; + } // Are we using handControllers or Mouse - only relevant for 3D tools var controllerPose = getControllerWorldLocation(activeHand, true); @@ -2167,6 +2186,8 @@ SelectionDisplay = (function() { Vec3.print(" changeInPosition:", changeInPosition); Vec3.print(" newPosition:", newPosition); } + + previousPickRay = pickRay; SelectionManager._update(); };// End of onMove def From 54145e03105dc061a4e9879e8493ec6a47cd1144 Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 20 Jun 2018 15:53:38 -0700 Subject: [PATCH 17/36] use previous pick ray when translate reaches end --- .../system/libraries/entitySelectionTool.js | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 62eb845191..1550f6eff2 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -982,6 +982,11 @@ SelectionDisplay = (function() { var toCameraDistance = Vec3.length(Vec3.subtract(cameraPosition, position)); return toCameraDistance; } + + function usePreviousPickRay(pickRayDirection, previousPickRayDirection, normal) { + return (Vec3.dot(pickRayDirection, normal) > 0 && Vec3.dot(previousPickRayDirection, normal) < 0) || + (Vec3.dot(pickRayDirection, normal) < 0 && Vec3.dot(previousPickRayDirection, normal) > 0); + } // @return string - The mode of the currently active tool; // otherwise, "UNKNOWN" if there's no active tool. @@ -1782,12 +1787,17 @@ SelectionDisplay = (function() { } else { duplicatedEntityIDs = null; } + + previousPickRay = pickRay; }, onEnd: function(event, reason) { pushCommandForSelections(duplicatedEntityIDs); }, onMove: function(event) { pickRay = generalComputePickRay(event.x, event.y); + if (usePreviousPickRay(pickRay.direction, previousPickRay.direction, pickNormal)) { + pickRay = previousPickRay; + } var newIntersection = rayPlaneIntersection(pickRay, SelectionManager.worldPosition, pickNormal); var vector = Vec3.subtract(newIntersection, lastPick); @@ -1806,7 +1816,7 @@ SelectionDisplay = (function() { var dotVector = Vec3.dot(vector, projectionVector); vector = Vec3.multiply(dotVector, projectionVector); vector = grid.snapToGrid(vector); - + var wantDebug = false; if (wantDebug) { print("translateUpDown... "); @@ -1831,6 +1841,8 @@ SelectionDisplay = (function() { var newPosition = Vec3.sum(properties.position, vector); Entities.editEntity(id, { position: newPosition }); } + + previousPickRay = pickRay; SelectionManager._update(); } @@ -2092,11 +2104,10 @@ SelectionDisplay = (function() { var localDeltaPivot = deltaPivot; var localSigns = signs; var pickRay = generalComputePickRay(event.x, event.y); - if ((Vec3.dot(pickRay.direction, planeNormal) > 0 && Vec3.dot(previousPickRay.direction, planeNormal) < 0) || - (Vec3.dot(pickRay.direction, planeNormal) < 0 && Vec3.dot(previousPickRay.direction, planeNormal) > 0)) { + if (usePreviousPickRay(pickRay.direction, previousPickRay.direction, planeNormal)) { pickRay = previousPickRay; } - + // Are we using handControllers or Mouse - only relevant for 3D tools var controllerPose = getControllerWorldLocation(activeHand, true); var vector = null; @@ -2176,7 +2187,7 @@ SelectionDisplay = (function() { dimensions: newDimensions }); } - + var wantDebug = false; if (wantDebug) { print(stretchMode); From d43be5ce1900d1c33fa8c45e105cda7f255cba11 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 21 Jun 2018 16:35:37 +1200 Subject: [PATCH 18/36] Code review --- scripts/system/html/js/entityList.js | 28 ++++++++++------------ scripts/system/html/js/entityProperties.js | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 11a875dbb5..a8c0e22ae6 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -184,27 +184,25 @@ function loaded() { currentElement.onclick = onRowClicked; currentElement.ondblclick = onRowDoubleClicked; }); - - if (refreshEntityListTimer) { - clearTimeout(refreshEntityListTimer); - } - refreshEntityListTimer = setTimeout(refreshEntityListObject, 50); } else { var item = entities[id].item; item.values({ name: name, url: filename, locked: locked, visible: visible }); } } - function removeEntities(deletedIDs, selectedIDs) { + function removeEntities(deletedIDs) { for (i = 0, length = deletedIDs.length; i < length; i++) { delete entities[deletedIDs[i]]; entityList.remove("id", deletedIDs[i]); } + } + + function scheduleRefreshEntityList() { + var REFRESH_DELAY = 50; if (refreshEntityListTimer) { clearTimeout(refreshEntityListTimer); } - refreshEntityListTimer = setTimeout(refreshEntityListObject, 50); - updateSelectedEntities(selectedIDs); + refreshEntityListTimer = setTimeout(refreshEntityListObject, REFRESH_DELAY); } function clearEntities() { @@ -377,15 +375,15 @@ function loaded() { newEntities[i].hasScript ? SCRIPT_GLYPH : null); } updateSelectedEntities(data.selectedIDs); + scheduleRefreshEntityList(); resize(); } - } else if (data.type === "removeEntities" && data.deletedIDs !== undefined) { - removeEntities(data.deletedIDs, data.selectedIDs); - } else if (data.type === "deleted") { - for (i = 0, length = data.ids.length; i < length; i++) { - delete entities[data.ids[i]]; - entityList.remove("id", data.ids[i]); - } + } else if (data.type === "removeEntities" && data.deletedIDs !== undefined && data.selectedIDs !== undefined) { + removeEntities(data.deletedIDs); + updateSelectedEntities(data.selectedIDs); + scheduleRefreshEntityList(); + } else if (data.type === "deleted" && data.ids) { + removeEntities(data.ids); refreshFooter(); } }); diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index f5b24a5f8e..a6a781b35f 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -911,7 +911,7 @@ function loaded() { elID.value = ""; elPropertiesList.className = ''; disableProperties(); - } else if (data.selections && data.selections.length > 1) { + } else if (data.selections.length > 1) { deleteJSONEditor(); deleteJSONMaterialEditor(); var selections = data.selections; From 37b35353d24a9cb1d5e070ca8c104041970e36ef Mon Sep 17 00:00:00 2001 From: David Back Date: Thu, 21 Jun 2018 14:48:37 -0700 Subject: [PATCH 19/36] space --- scripts/system/libraries/entitySelectionTool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 1550f6eff2..4cbdd4a3f7 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -2187,7 +2187,7 @@ SelectionDisplay = (function() { dimensions: newDimensions }); } - + var wantDebug = false; if (wantDebug) { print(stretchMode); From ed56f09fcfb62e546e884c0ce788d2c02ac86b26 Mon Sep 17 00:00:00 2001 From: David Back Date: Thu, 21 Jun 2018 15:00:10 -0700 Subject: [PATCH 20/36] comment --- scripts/system/libraries/entitySelectionTool.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 4cbdd4a3f7..0429543eb8 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -1795,6 +1795,8 @@ SelectionDisplay = (function() { }, onMove: function(event) { pickRay = generalComputePickRay(event.x, event.y); + + // Use previousPickRay if new pickRay will cause resulting rayPlaneIntersection values to wrap around if (usePreviousPickRay(pickRay.direction, previousPickRay.direction, pickNormal)) { pickRay = previousPickRay; } @@ -2104,6 +2106,8 @@ SelectionDisplay = (function() { var localDeltaPivot = deltaPivot; var localSigns = signs; var pickRay = generalComputePickRay(event.x, event.y); + + // Use previousPickRay if new pickRay will cause resulting rayPlaneIntersection values to wrap around if (usePreviousPickRay(pickRay.direction, previousPickRay.direction, planeNormal)) { pickRay = previousPickRay; } From c019a4816ff8bbdedfd1486059b1abafc4e7f956 Mon Sep 17 00:00:00 2001 From: David Back Date: Thu, 21 Jun 2018 16:45:09 -0700 Subject: [PATCH 21/36] CR changes + eslint fixes --- .../system/libraries/entitySelectionTool.js | 347 ++++++++---------- 1 file changed, 152 insertions(+), 195 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 0429543eb8..7d32f91a2c 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -13,11 +13,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -/* global SPACE_LOCAL, SelectionManager */ +/* global SelectionManager, grid, rayPlaneIntersection, rayPlaneIntersection2, pushCommandForSelections, + getMainTabletIDs, getControllerWorldLocation */ -SPACE_LOCAL = "local"; -SPACE_WORLD = "world"; -HIGHLIGHT_LIST_NAME = "editHandleHighlightList"; +var SPACE_LOCAL = "local"; +var SPACE_WORLD = "world"; +var HIGHLIGHT_LIST_NAME = "editHandleHighlightList"; Script.include([ "./controllers.js", @@ -76,7 +77,7 @@ SelectionManager = (function() { outlineWidth: 3, isOutlineSmooth: true }; - //disabling this for now as it is causing rendering issues with the other handle overlays + // disabling this for now as it is causing rendering issues with the other handle overlays //Selection.enableListHighlight(HIGHLIGHT_LIST_NAME, editHandleOutlineStyle); that.savedProperties = {}; @@ -179,7 +180,7 @@ SelectionManager = (function() { } }); return duplicatedEntityIDs; - } + }; that._update = function(selectionUpdated) { var properties = null; @@ -257,11 +258,12 @@ SelectionManager = (function() { // Normalize degrees to be in the range (-180, 180) function normalizeDegrees(degrees) { - degrees = ((degrees + 180) % 360) - 180; - if (degrees <= -180) { - degrees += 360; + var maxDegrees = 360; + var halfMaxDegrees = maxDegrees / 2; + degrees = ((degrees + halfMaxDegrees) % maxDegrees) - halfMaxDegrees; + if (degrees <= -halfMaxDegrees) { + degrees += maxDegrees; } - return degrees; } @@ -271,14 +273,14 @@ SelectionDisplay = (function() { var NEGATE_VECTOR = -1; - var COLOR_GREEN = { red:31, green:198, blue:166 }; - var COLOR_BLUE = { red:0, green:147, blue:197 }; - var COLOR_RED = { red:226, green:51, blue:77 }; - var COLOR_HOVER = { red:227, green:227, blue:227 }; + var COLOR_GREEN = { red: 31, green: 198, blue: 166 }; + var COLOR_BLUE = { red: 0, green: 147, blue: 197 }; + var COLOR_RED = { red: 226, green: 51, blue: 77 }; + var COLOR_HOVER = { red: 227, green: 227, blue: 227 }; var COLOR_ROTATE_CURRENT_RING = { red: 255, green: 99, blue: 9 }; - var COLOR_SCALE_EDGE = { red:87, green:87, blue:87 }; - var COLOR_SCALE_CUBE = { red:106, green:106, blue:106 }; - var COLOR_SCALE_CUBE_SELECTED = { red:18, green:18, blue:18 }; + var COLOR_SCALE_EDGE = { red: 87, green: 87, blue: 87 }; + var COLOR_SCALE_CUBE = { red: 106, green: 106, blue: 106 }; + var COLOR_SCALE_CUBE_SELECTED = { red: 18, green: 18, blue: 18 }; var TRANSLATE_ARROW_CYLINDER_OFFSET = 0.1; var TRANSLATE_ARROW_CYLINDER_CAMERA_DISTANCE_MULTIPLE = 0.005; @@ -309,41 +311,41 @@ SelectionDisplay = (function() { var SCALE_CUBE_OFFSET = 0.5; var SCALE_CUBE_CAMERA_DISTANCE_MULTIPLE = 0.0125; - var CLONER_OFFSET = { x:0.9, y:-0.9, z:0.9 }; + var CLONER_OFFSET = { x: 0.9, y: -0.9, z: 0.9 }; var CTRL_KEY_CODE = 16777249; var AVATAR_COLLISIONS_OPTION = "Enable Avatar Collisions"; var TRANSLATE_DIRECTION = { - X : 0, - Y : 1, - Z : 2 - } + X: 0, + Y: 1, + Z: 2 + }; var STRETCH_DIRECTION = { - X : 0, - Y : 1, - Z : 2, - ALL : 3 - } + X: 0, + Y: 1, + Z: 2, + ALL: 3 + }; var SCALE_DIRECTION = { - LBN : 0, - RBN : 1, - LBF : 2, - RBF : 3, - LTN : 4, - RTN : 5, - LTF : 6, - RTF : 7 - } + LBN: 0, + RBN: 1, + LBF: 2, + RBF: 3, + LTN: 4, + RTN: 5, + LTF: 6, + RTF: 7 + }; var ROTATE_DIRECTION = { - PITCH : 0, - YAW : 1, - ROLL : 2 - } + PITCH: 0, + YAW: 1, + ROLL: 2 + }; var spaceMode = SPACE_LOCAL; var overlayNames = []; @@ -386,16 +388,16 @@ SelectionDisplay = (function() { }; var handleTranslateXCone = Overlays.addOverlay("shape", handlePropertiesTranslateArrowCones); var handleTranslateXCylinder = Overlays.addOverlay("shape", handlePropertiesTranslateArrowCylinders); - Overlays.editOverlay(handleTranslateXCone, { color : COLOR_RED }); - Overlays.editOverlay(handleTranslateXCylinder, { color : COLOR_RED }); + Overlays.editOverlay(handleTranslateXCone, { color: COLOR_RED }); + Overlays.editOverlay(handleTranslateXCylinder, { color: COLOR_RED }); var handleTranslateYCone = Overlays.addOverlay("shape", handlePropertiesTranslateArrowCones); var handleTranslateYCylinder = Overlays.addOverlay("shape", handlePropertiesTranslateArrowCylinders); - Overlays.editOverlay(handleTranslateYCone, { color : COLOR_GREEN }); - Overlays.editOverlay(handleTranslateYCylinder, { color : COLOR_GREEN }); + Overlays.editOverlay(handleTranslateYCone, { color: COLOR_GREEN }); + Overlays.editOverlay(handleTranslateYCylinder, { color: COLOR_GREEN }); var handleTranslateZCone = Overlays.addOverlay("shape", handlePropertiesTranslateArrowCones); var handleTranslateZCylinder = Overlays.addOverlay("shape", handlePropertiesTranslateArrowCylinders); - Overlays.editOverlay(handleTranslateZCone, { color : COLOR_BLUE }); - Overlays.editOverlay(handleTranslateZCylinder, { color : COLOR_BLUE }); + Overlays.editOverlay(handleTranslateZCone, { color: COLOR_BLUE }); + Overlays.editOverlay(handleTranslateZCylinder, { color: COLOR_BLUE }); var handlePropertiesRotateRings = { alpha: 1, @@ -411,18 +413,18 @@ SelectionDisplay = (function() { }; var handleRotatePitchRing = Overlays.addOverlay("circle3d", handlePropertiesRotateRings); Overlays.editOverlay(handleRotatePitchRing, { - color : COLOR_RED, - majorTickMarksColor: COLOR_RED, + color: COLOR_RED, + majorTickMarksColor: COLOR_RED }); var handleRotateYawRing = Overlays.addOverlay("circle3d", handlePropertiesRotateRings); Overlays.editOverlay(handleRotateYawRing, { - color : COLOR_GREEN, - majorTickMarksColor: COLOR_GREEN, + color: COLOR_GREEN, + majorTickMarksColor: COLOR_GREEN }); var handleRotateRollRing = Overlays.addOverlay("circle3d", handlePropertiesRotateRings); Overlays.editOverlay(handleRotateRollRing, { - color : COLOR_BLUE, - majorTickMarksColor: COLOR_BLUE, + color: COLOR_BLUE, + majorTickMarksColor: COLOR_BLUE }); var handleRotateCurrentRing = Overlays.addOverlay("circle3d", { @@ -461,11 +463,11 @@ SelectionDisplay = (function() { drawInFront: true }; var handleStretchXSphere = Overlays.addOverlay("shape", handlePropertiesStretchSpheres); - Overlays.editOverlay(handleStretchXSphere, { color : COLOR_RED }); + Overlays.editOverlay(handleStretchXSphere, { color: COLOR_RED }); var handleStretchYSphere = Overlays.addOverlay("shape", handlePropertiesStretchSpheres); - Overlays.editOverlay(handleStretchYSphere, { color : COLOR_GREEN }); + Overlays.editOverlay(handleStretchYSphere, { color: COLOR_GREEN }); var handleStretchZSphere = Overlays.addOverlay("shape", handlePropertiesStretchSpheres); - Overlays.editOverlay(handleStretchZSphere, { color : COLOR_BLUE }); + Overlays.editOverlay(handleStretchZSphere, { color: COLOR_BLUE }); var handlePropertiesStretchPanel = { shape: "Quad", @@ -474,13 +476,13 @@ SelectionDisplay = (function() { visible: false, ignoreRayIntersection: true, drawInFront: true - } + }; var handleStretchXPanel = Overlays.addOverlay("shape", handlePropertiesStretchPanel); - Overlays.editOverlay(handleStretchXPanel, { color : COLOR_RED }); + Overlays.editOverlay(handleStretchXPanel, { color: COLOR_RED }); var handleStretchYPanel = Overlays.addOverlay("shape", handlePropertiesStretchPanel); - Overlays.editOverlay(handleStretchYPanel, { color : COLOR_GREEN }); + Overlays.editOverlay(handleStretchYPanel, { color: COLOR_GREEN }); var handleStretchZPanel = Overlays.addOverlay("shape", handlePropertiesStretchPanel); - Overlays.editOverlay(handleStretchZPanel, { color : COLOR_BLUE }); + Overlays.editOverlay(handleStretchZPanel, { color: COLOR_BLUE }); var handlePropertiesScaleCubes = { size: 0.025, @@ -506,7 +508,7 @@ SelectionDisplay = (function() { ignoreRayIntersection: true, drawInFront: true, lineWidth: 0.2 - } + }; var handleScaleTREdge = Overlays.addOverlay("line3d", handlePropertiesScaleEdge); var handleScaleTLEdge = Overlays.addOverlay("line3d", handlePropertiesScaleEdge); var handleScaleTFEdge = Overlays.addOverlay("line3d", handlePropertiesScaleEdge); @@ -646,7 +648,7 @@ SelectionDisplay = (function() { that.shutdown = function() { that.restoreAvatarCollisionsFromStretch(); - } + }; Script.scriptEnding.connect(that.shutdown); // We get mouseMoveEvents from the handControllers, via handControllerPointer. @@ -773,11 +775,11 @@ SelectionDisplay = (function() { }; that.resetPreviousHandleColor = function() { - if (previousHandle != null) { + if (previousHandle !== null) { Overlays.editOverlay(previousHandle, { color: previousHandleColor }); previousHandle = null; } - if (previousHandleHelper != null) { + if (previousHandleHelper !== null) { Overlays.editOverlay(previousHandleHelper, { color: previousHandleColor }); previousHandleHelper = null; } @@ -874,7 +876,7 @@ SelectionDisplay = (function() { Overlays.editOverlay(result.overlayID, { color: COLOR_HOVER }); previousHandle = result.overlayID; previousHandleHelper = that.getHandleHelper(result.overlayID); - if (previousHandleHelper != null) { + if (previousHandleHelper !== null) { Overlays.editOverlay(previousHandleHelper, { color: COLOR_HOVER }); } previousHandleColor = pickedColor; @@ -932,7 +934,7 @@ SelectionDisplay = (function() { ctrlPressed = false; that.updateActiveRotateRing(); } - } + }; // Triggers notification on specific key driven events that.keyPressEvent = function(key) { @@ -940,7 +942,7 @@ SelectionDisplay = (function() { ctrlPressed = true; that.updateActiveRotateRing(); } - } + }; // NOTE: mousePressEvent and mouseMoveEvent from the main script should call us., so we don't hook these: // Controller.mousePressEvent.connect(that.mousePressEvent); @@ -1007,8 +1009,6 @@ SelectionDisplay = (function() { lastCameraOrientation = Camera.getOrientation(); if (event !== false) { - pickRay = generalComputePickRay(event.x, event.y); - var wantDebug = false; if (wantDebug) { print("select() with EVENT...... "); @@ -1034,7 +1034,8 @@ SelectionDisplay = (function() { spaceMode = newSpaceMode; that.updateHandles(); } else if (wantDebug) { - print("WARNING: entitySelectionTool.setSpaceMode - Can't update SpaceMode. CurrentMode: " + spaceMode + " DesiredMode: " + newSpaceMode); + print("WARNING: entitySelectionTool.setSpaceMode - Can't update SpaceMode. CurrentMode: " + + spaceMode + " DesiredMode: " + newSpaceMode); } if (wantDebug) { print("====== SetSpaceMode called. <========"); @@ -1084,7 +1085,8 @@ SelectionDisplay = (function() { } if (!handleTools.hasOwnProperty(toolHandle)) { - print("WARNING: entitySelectionTool.isActiveTool - Encountered unknown grabberToolHandle: " + toolHandle + ". Tools should be registered via addHandleTool."); + print("WARNING: entitySelectionTool.isActiveTool - Encountered unknown grabberToolHandle: " + + toolHandle + ". Tools should be registered via addHandleTool."); // EARLY EXIT return false; } @@ -1114,13 +1116,14 @@ SelectionDisplay = (function() { var rotationInverse = Quat.inverse(rotation); var toCameraDistance = getDistanceToCamera(position); - var localRotationX = Quat.fromPitchYawRollDegrees(0, 0, -90); + var rotationDegrees = 90; + var localRotationX = Quat.fromPitchYawRollDegrees(0, 0, -rotationDegrees); var rotationX = Quat.multiply(rotation, localRotationX); worldRotationX = rotationX; - var localRotationY = Quat.fromPitchYawRollDegrees(0, 90, 0); + var localRotationY = Quat.fromPitchYawRollDegrees(0, rotationDegrees, 0); var rotationY = Quat.multiply(rotation, localRotationY); worldRotationY = rotationY; - var localRotationZ = Quat.fromPitchYawRollDegrees(90, 0, 0); + var localRotationZ = Quat.fromPitchYawRollDegrees(rotationDegrees, 0, 0); var rotationZ = Quat.multiply(rotation, localRotationZ); worldRotationZ = rotationZ; @@ -1133,7 +1136,7 @@ SelectionDisplay = (function() { // UPDATE ROTATION RINGS // rotateDimension is used as the base dimension for all overlays var rotateDimension = Math.max(maxHandleDimension, toCameraDistance * ROTATE_RING_CAMERA_DISTANCE_MULTIPLE); - var rotateDimensions = { x:rotateDimension, y:rotateDimension, z:rotateDimension }; + var rotateDimensions = { x: rotateDimension, y: rotateDimension, z: rotateDimension }; if (!isActiveTool(handleRotatePitchRing)) { Overlays.editOverlay(handleRotatePitchRing, { position: position, @@ -1165,16 +1168,16 @@ SelectionDisplay = (function() { var arrowCylinderDimension = rotateDimension * TRANSLATE_ARROW_CYLINDER_CAMERA_DISTANCE_MULTIPLE / ROTATE_RING_CAMERA_DISTANCE_MULTIPLE; var arrowCylinderDimensions = { - x:arrowCylinderDimension, - y:arrowCylinderDimension * TRANSLATE_ARROW_CYLINDER_Y_MULTIPLE, - z:arrowCylinderDimension + x: arrowCylinderDimension, + y: arrowCylinderDimension * TRANSLATE_ARROW_CYLINDER_Y_MULTIPLE, + z: arrowCylinderDimension }; var arrowConeDimension = rotateDimension * TRANSLATE_ARROW_CONE_CAMERA_DISTANCE_MULTIPLE / ROTATE_RING_CAMERA_DISTANCE_MULTIPLE; - var arrowConeDimensions = { x:arrowConeDimension, y:arrowConeDimension, z:arrowConeDimension }; + var arrowConeDimensions = { x: arrowConeDimension, y: arrowConeDimension, z: arrowConeDimension }; var arrowCylinderOffset = rotateDimension * TRANSLATE_ARROW_CYLINDER_OFFSET / ROTATE_RING_CAMERA_DISTANCE_MULTIPLE; var arrowConeOffset = arrowCylinderDimensions.y * TRANSLATE_ARROW_CONE_OFFSET_CYLINDER_DIMENSION_MULTIPLE; - var cylinderXPosition = { x:arrowCylinderOffset, y:0, z:0 }; + var cylinderXPosition = { x: arrowCylinderOffset, y: 0, z: 0 }; cylinderXPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, cylinderXPosition)); Overlays.editOverlay(handleTranslateXCylinder, { position: cylinderXPosition, @@ -1188,7 +1191,7 @@ SelectionDisplay = (function() { rotation: rotationX, dimensions: arrowConeDimensions }); - var cylinderYPosition = { x:0, y:arrowCylinderOffset, z:0 }; + var cylinderYPosition = { x: 0, y: arrowCylinderOffset, z: 0 }; cylinderYPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, cylinderYPosition)); Overlays.editOverlay(handleTranslateYCylinder, { position: cylinderYPosition, @@ -1202,7 +1205,7 @@ SelectionDisplay = (function() { rotation: rotationY, dimensions: arrowConeDimensions }); - var cylinderZPosition = { x:0, y:0, z:arrowCylinderOffset }; + var cylinderZPosition = { x: 0, y: 0, z: arrowCylinderOffset }; cylinderZPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, cylinderZPosition)); Overlays.editOverlay(handleTranslateZCylinder, { position: cylinderZPosition, @@ -1222,28 +1225,28 @@ SelectionDisplay = (function() { var scaleCubeOffsetY = SCALE_CUBE_OFFSET * dimensions.y; var scaleCubeOffsetZ = SCALE_CUBE_OFFSET * dimensions.z; var scaleCubeRotation = spaceMode === SPACE_LOCAL ? rotation : Quat.IDENTITY; - var scaleLBNCubePosition = { x:-scaleCubeOffsetX, y:-scaleCubeOffsetY, z:-scaleCubeOffsetZ }; + var scaleLBNCubePosition = { x: -scaleCubeOffsetX, y: -scaleCubeOffsetY, z: -scaleCubeOffsetZ }; scaleLBNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLBNCubePosition)); var scaleLBNCubeToCamera = getDistanceToCamera(scaleLBNCubePosition); - var scaleRBNCubePosition = { x:scaleCubeOffsetX, y:-scaleCubeOffsetY, z:-scaleCubeOffsetZ }; + var scaleRBNCubePosition = { x: scaleCubeOffsetX, y: -scaleCubeOffsetY, z: -scaleCubeOffsetZ }; scaleRBNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRBNCubePosition)); var scaleRBNCubeToCamera = getDistanceToCamera(scaleRBNCubePosition); - var scaleLBFCubePosition = { x:-scaleCubeOffsetX, y:-scaleCubeOffsetY, z:scaleCubeOffsetZ }; + var scaleLBFCubePosition = { x: -scaleCubeOffsetX, y: -scaleCubeOffsetY, z: scaleCubeOffsetZ }; scaleLBFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLBFCubePosition)); var scaleLBFCubeToCamera = getDistanceToCamera(scaleLBFCubePosition); - var scaleRBFCubePosition = { x:scaleCubeOffsetX, y:-scaleCubeOffsetY, z:scaleCubeOffsetZ }; + var scaleRBFCubePosition = { x: scaleCubeOffsetX, y: -scaleCubeOffsetY, z: scaleCubeOffsetZ }; scaleRBFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRBFCubePosition)); var scaleRBFCubeToCamera = getDistanceToCamera(scaleRBFCubePosition); - var scaleLTNCubePosition = { x:-scaleCubeOffsetX, y:scaleCubeOffsetY, z:-scaleCubeOffsetZ }; + var scaleLTNCubePosition = { x: -scaleCubeOffsetX, y: scaleCubeOffsetY, z: -scaleCubeOffsetZ }; scaleLTNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLTNCubePosition)); var scaleLTNCubeToCamera = getDistanceToCamera(scaleLTNCubePosition); - var scaleRTNCubePosition = { x:scaleCubeOffsetX, y:scaleCubeOffsetY, z:-scaleCubeOffsetZ }; + var scaleRTNCubePosition = { x: scaleCubeOffsetX, y: scaleCubeOffsetY, z: -scaleCubeOffsetZ }; scaleRTNCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRTNCubePosition)); var scaleRTNCubeToCamera = getDistanceToCamera(scaleRTNCubePosition); - var scaleLTFCubePosition = { x:-scaleCubeOffsetX, y:scaleCubeOffsetY, z:scaleCubeOffsetZ }; + var scaleLTFCubePosition = { x: -scaleCubeOffsetX, y: scaleCubeOffsetY, z: scaleCubeOffsetZ }; scaleLTFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleLTFCubePosition)); var scaleLTFCubeToCamera = getDistanceToCamera(scaleLTFCubePosition); - var scaleRTFCubePosition = { x:scaleCubeOffsetX, y:scaleCubeOffsetY, z:scaleCubeOffsetZ }; + var scaleRTFCubePosition = { x: scaleCubeOffsetX, y: scaleCubeOffsetY, z: scaleCubeOffsetZ }; scaleRTFCubePosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, scaleRTFCubePosition)); var scaleRTFCubeToCamera = getDistanceToCamera(scaleRTFCubePosition); @@ -1251,7 +1254,7 @@ SelectionDisplay = (function() { scaleRBFCubeToCamera, scaleLTNCubeToCamera, scaleRTNCubeToCamera, scaleLTFCubeToCamera, scaleRTFCubeToCamera); var scaleCubeDimension = scaleCubeToCamera * SCALE_CUBE_CAMERA_DISTANCE_MULTIPLE; - var scaleCubeDimensions = { x:scaleCubeDimension, y:scaleCubeDimension, z:scaleCubeDimension }; + var scaleCubeDimensions = { x: scaleCubeDimension, y: scaleCubeDimension, z: scaleCubeDimension }; Overlays.editOverlay(handleScaleLBNCube, { position: scaleLBNCubePosition, @@ -1311,21 +1314,21 @@ SelectionDisplay = (function() { // UPDATE STRETCH SPHERES var stretchSphereDimension = rotateDimension * STRETCH_SPHERE_CAMERA_DISTANCE_MULTIPLE / ROTATE_RING_CAMERA_DISTANCE_MULTIPLE; - var stretchSphereDimensions = { x:stretchSphereDimension, y:stretchSphereDimension, z:stretchSphereDimension }; + var stretchSphereDimensions = { x: stretchSphereDimension, y: stretchSphereDimension, z: stretchSphereDimension }; var stretchSphereOffset = rotateDimension * STRETCH_SPHERE_OFFSET / ROTATE_RING_CAMERA_DISTANCE_MULTIPLE; - var stretchXPosition = { x:stretchSphereOffset, y:0, z:0 }; + var stretchXPosition = { x: stretchSphereOffset, y: 0, z: 0 }; stretchXPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, stretchXPosition)); Overlays.editOverlay(handleStretchXSphere, { position: stretchXPosition, dimensions: stretchSphereDimensions }); - var stretchYPosition = { x:0, y:stretchSphereOffset, z:0 }; + var stretchYPosition = { x: 0, y: stretchSphereOffset, z: 0 }; stretchYPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, stretchYPosition)); Overlays.editOverlay(handleStretchYSphere, { position: stretchYPosition, dimensions: stretchSphereDimensions }); - var stretchZPosition = { x:0, y:0, z:stretchSphereOffset }; + var stretchZPosition = { x: 0, y: 0, z: stretchSphereOffset }; stretchZPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, stretchZPosition)); Overlays.editOverlay(handleStretchZSphere, { position: stretchZPosition, @@ -1342,7 +1345,7 @@ SelectionDisplay = (function() { stretchPanelXDimensions.x = STRETCH_PANEL_WIDTH; stretchPanelXDimensions.y = Math.abs(stretchPanelXDimensions.z); stretchPanelXDimensions.z = tempY; - var stretchPanelXPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x:dimensions.x / 2, y:0, z:0 })); + var stretchPanelXPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x: dimensions.x / 2, y: 0, z: 0 })); Overlays.editOverlay(handleStretchXPanel, { position: stretchPanelXPosition, rotation: rotationZ, @@ -1353,18 +1356,18 @@ SelectionDisplay = (function() { stretchPanelYDimensions.x = Math.abs(stretchPanelYDimensions.z); stretchPanelYDimensions.y = STRETCH_PANEL_WIDTH; stretchPanelYDimensions.z = tempX; - var stretchPanelYPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x:0, y:dimensions.y / 2, z:0 })); + var stretchPanelYPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x: 0, y: dimensions.y / 2, z: 0 })); Overlays.editOverlay(handleStretchYPanel, { position: stretchPanelYPosition, rotation: rotationY, dimensions: stretchPanelYDimensions }); var stretchPanelZDimensions = Vec3.subtract(scaleLTNCubePositionRotated, scaleRBFCubePositionRotated); - var tempX = Math.abs(stretchPanelZDimensions.x); + tempX = Math.abs(stretchPanelZDimensions.x); stretchPanelZDimensions.x = Math.abs(stretchPanelZDimensions.y); stretchPanelZDimensions.y = tempX; stretchPanelZDimensions.z = STRETCH_PANEL_WIDTH; - var stretchPanelZPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x:0, y:0, z:dimensions.z / 2 })); + var stretchPanelZPosition = Vec3.sum(position, Vec3.multiplyQbyV(rotation, { x: 0, y: 0, z: dimensions.z / 2 })); Overlays.editOverlay(handleStretchZPanel, { position: stretchPanelZPosition, rotation: rotationX, @@ -1397,10 +1400,10 @@ SelectionDisplay = (function() { } // UPDATE CLONER (CURRENTLY HIDDEN FOR NOW) - var handleClonerOffset = { - x:CLONER_OFFSET.x * dimensions.x, - y:CLONER_OFFSET.y * dimensions.y, - z:CLONER_OFFSET.z * dimensions.z + var handleClonerOffset = { + x: CLONER_OFFSET.x * dimensions.x, + y: CLONER_OFFSET.y * dimensions.y, + z: CLONER_OFFSET.z * dimensions.z }; var handleClonerPos = Vec3.sum(position, Vec3.multiplyQbyV(rotation, handleClonerOffset)); Overlays.editOverlay(handleCloner, { @@ -1438,9 +1441,9 @@ SelectionDisplay = (function() { !isActiveTool(handleRotateYawRing) && !isActiveTool(handleRotateRollRing))); - //keep cloner always hidden for now since you can hold Alt to clone while - //translating an entity - we may bring cloner back for HMD only later - //that.setHandleClonerVisible(!activeTool || isActiveTool(handleCloner)); + // keep cloner always hidden for now since you can hold Alt to clone while + // translating an entity - we may bring cloner back for HMD only later + // that.setHandleClonerVisible(!activeTool || isActiveTool(handleCloner)); if (wantDebug) { print("====== Update Handles <======="); @@ -1458,8 +1461,8 @@ SelectionDisplay = (function() { } else if (isActiveTool(handleRotateRollRing)) { activeRotateRing = handleRotateRollRing; } - if (activeRotateRing != null) { - var tickMarksAngle = ctrlPressed ? ROTATE_CTRL_SNAP_ANGLE : ROTATE_DEFAULT_TICK_MARKS_ANGLE; + if (activeRotateRing !== null) { + var tickMarksAngle = ctrlPressed ? ROTATE_CTRL_SNAP_ANGLE : ROTATE_DEFAULT_TICK_MARKS_ANGLE; Overlays.editOverlay(activeRotateRing, { majorTickMarksAngle: tickMarksAngle }); } }; @@ -1640,7 +1643,7 @@ SelectionDisplay = (function() { }, onMove: function(event) { var wantDebug = false; - pickRay = generalComputePickRay(event.x, event.y); + var pickRay = generalComputePickRay(event.x, event.y); var pick = rayPlaneIntersection2(pickRay, translateXZTool.pickPlanePosition, { x: 0, @@ -1706,7 +1709,8 @@ SelectionDisplay = (function() { } constrainMajorOnly = event.isControl; - var cornerPosition = Vec3.sum(startPosition, Vec3.multiply(-0.5, SelectionManager.worldDimensions)); + var negateAndHalve = -0.5; + var cornerPosition = Vec3.sum(startPosition, Vec3.multiply(negateAndHalve, SelectionManager.worldDimensions)); vector = Vec3.subtract( grid.snapToGrid(Vec3.sum(cornerPosition, vector), constrainMajorOnly), cornerPosition); @@ -1752,15 +1756,16 @@ SelectionDisplay = (function() { var pickNormal = null; var lastPick = null; var projectionVector = null; + var previousPickRay = null; addHandleTool(overlay, { mode: mode, onBegin: function(event, pickRay, pickResult) { if (direction === TRANSLATE_DIRECTION.X) { - pickNormal = { x:0, y:1, z:1 }; + pickNormal = { x: 0, y: 1, z: 1 }; } else if (direction === TRANSLATE_DIRECTION.Y) { - pickNormal = { x:1, y:0, z:1 }; + pickNormal = { x: 1, y: 0, z: 1 }; } else if (direction === TRANSLATE_DIRECTION.Z) { - pickNormal = { x:1, y:1, z:0 }; + pickNormal = { x: 1, y: 1, z: 0 }; } var rotation = spaceMode === SPACE_LOCAL ? SelectionManager.localRotation : SelectionManager.worldRotation; @@ -1794,7 +1799,7 @@ SelectionDisplay = (function() { pushCommandForSelections(duplicatedEntityIDs); }, onMove: function(event) { - pickRay = generalComputePickRay(event.x, event.y); + var pickRay = generalComputePickRay(event.x, event.y); // Use previousPickRay if new pickRay will cause resulting rayPlaneIntersection values to wrap around if (usePreviousPickRay(pickRay.direction, previousPickRay.direction, pickNormal)) { @@ -1805,11 +1810,11 @@ SelectionDisplay = (function() { var vector = Vec3.subtract(newIntersection, lastPick); if (direction === TRANSLATE_DIRECTION.X) { - projectionVector = { x:1, y:0, z:0 }; + projectionVector = { x: 1, y: 0, z: 0 }; } else if (direction === TRANSLATE_DIRECTION.Y) { - projectionVector = { x:0, y:1, z:0 }; + projectionVector = { x: 0, y: 1, z: 0 }; } else if (direction === TRANSLATE_DIRECTION.Z) { - projectionVector = { x:0, y:0, z:1 }; + projectionVector = { x: 0, y: 0, z: 1 }; } var rotation = spaceMode === SPACE_LOCAL ? SelectionManager.localRotation : SelectionManager.worldRotation; @@ -1865,7 +1870,7 @@ SelectionDisplay = (function() { Menu.setIsOptionChecked(AVATAR_COLLISIONS_OPTION, true); handleStretchCollisionOverride = false; } - } + }; // TOOL DEFINITION: HANDLE STRETCH TOOL function makeStretchTool(stretchMode, directionEnum, directionVec, pivot, offset, stretchPanel, scaleHandle) { @@ -1892,7 +1897,6 @@ SelectionDisplay = (function() { var lastPick3D = null; var initialPosition = null; var initialDimensions = null; - var initialIntersection = null; var initialProperties = null; var registrationPoint = null; var deltaPivot = null; @@ -1933,7 +1937,7 @@ SelectionDisplay = (function() { var scaledOffset = Vec3.multiply(0.5, offset); // Offset from the registration point - offsetRP = Vec3.subtract(scaledOffset, centeredRP); + var offsetRP = Vec3.subtract(scaledOffset, centeredRP); // Scaled offset in world coordinates var scaledOffsetWorld = vec3Mult(initialDimensions, offsetRP); @@ -1943,57 +1947,10 @@ SelectionDisplay = (function() { if (directionFor3DStretch) { // pivot, offset and pickPlanePosition for 3D manipulation var scaledPivot3D = Vec3.multiply(0.5, Vec3.multiply(1.0, directionFor3DStretch)); - deltaPivot3D = Vec3.subtract(centeredRP, scaledPivot3D); - - var scaledOffsetWorld3D = vec3Mult(initialDimensions, - Vec3.subtract(Vec3.multiply(0.5, Vec3.multiply(-1.0, directionFor3DStretch)), centeredRP)); - + deltaPivot3D = Vec3.subtract(centeredRP, scaledPivot3D); pickRayPosition3D = Vec3.sum(initialPosition, Vec3.multiplyQbyV(rotation, scaledOffsetWorld)); } - var start = null; - var end = null; - if ((numDimensions === 1) && mask.x) { - start = Vec3.multiplyQbyV(rotation, { - x: -10000, - y: 0, - z: 0 - }); - start = Vec3.sum(start, properties.position); - end = Vec3.multiplyQbyV(rotation, { - x: 10000, - y: 0, - z: 0 - }); - end = Vec3.sum(end, properties.position); - } - if ((numDimensions === 1) && mask.y) { - start = Vec3.multiplyQbyV(rotation, { - x: 0, - y: -10000, - z: 0 - }); - start = Vec3.sum(start, properties.position); - end = Vec3.multiplyQbyV(rotation, { - x: 0, - y: 10000, - z: 0 - }); - end = Vec3.sum(end, properties.position); - } - if ((numDimensions === 1) && mask.z) { - start = Vec3.multiplyQbyV(rotation, { - x: 0, - y: 0, - z: -10000 - }); - start = Vec3.sum(start, properties.position); - end = Vec3.multiplyQbyV(rotation, { - x: 0, - y: 0, - z: 10000 - }); - end = Vec3.sum(end, properties.position); - } + if (numDimensions === 1) { if (mask.x === 1) { planeNormal = { @@ -2064,10 +2021,10 @@ SelectionDisplay = (function() { SelectionManager.saveProperties(); that.resetPreviousHandleColor(); - if (stretchPanel != null) { + if (stretchPanel !== null) { Overlays.editOverlay(stretchPanel, { visible: true }); } - if (scaleHandle != null) { + if (scaleHandle !== null) { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE_SELECTED }); } if (Menu.isOptionChecked(AVATAR_COLLISIONS_OPTION)) { @@ -2079,10 +2036,10 @@ SelectionDisplay = (function() { }; var onEnd = function(event, reason) { - if (stretchPanel != null) { + if (stretchPanel !== null) { Overlays.editOverlay(stretchPanel, { visible: false }); } - if (scaleHandle != null) { + if (scaleHandle !== null) { Overlays.editOverlay(scaleHandle, { color: COLOR_SCALE_CUBE }); } that.restoreAvatarCollisionsFromStretch(); @@ -2092,14 +2049,12 @@ SelectionDisplay = (function() { var onMove = function(event) { var proportional = (spaceMode === SPACE_WORLD) || directionEnum === STRETCH_DIRECTION.ALL; - var position, dimensions, rotation; + var position, rotation; if (spaceMode === SPACE_LOCAL) { position = SelectionManager.localPosition; - dimensions = SelectionManager.localDimensions; rotation = SelectionManager.localRotation; } else { position = SelectionManager.worldPosition; - dimensions = SelectionManager.worldDimensions; rotation = SelectionManager.worldRotation; } @@ -2115,6 +2070,7 @@ SelectionDisplay = (function() { // Are we using handControllers or Mouse - only relevant for 3D tools var controllerPose = getControllerWorldLocation(activeHand, true); var vector = null; + var newPick = null; if (HMD.isHMDAvailable() && HMD.isHandControllerAvailable() && controllerPose.valid && that.triggered && directionFor3DStretch) { localDeltaPivot = deltaPivot3D; @@ -2166,22 +2122,22 @@ SelectionDisplay = (function() { var minimumDimension = directionEnum === STRETCH_DIRECTION.ALL ? STRETCH_ALL_MINIMUM_DIMENSION : STRETCH_MINIMUM_DIMENSION; - if (newDimensions.x <= minimumDimension) { + if (newDimensions.x < minimumDimension) { newDimensions.x = minimumDimension; changeInDimensions.x = minimumDimension - initialDimensions.x; } - if (newDimensions.y <= minimumDimension) { + if (newDimensions.y < minimumDimension) { newDimensions.y = minimumDimension; changeInDimensions.y = minimumDimension - initialDimensions.y; } - if (newDimensions.z <= minimumDimension) { + if (newDimensions.z < minimumDimension) { newDimensions.z = minimumDimension; changeInDimensions.z = minimumDimension - initialDimensions.z; } var changeInPosition = Vec3.multiplyQbyV(rotation, vec3Mult(localDeltaPivot, changeInDimensions)); if (directionEnum === STRETCH_DIRECTION.ALL) { - changeInPosition = { x:0, y:0, z:0 }; + changeInPosition = { x: 0, y: 0, z: 0 }; } var newPosition = Vec3.sum(initialPosition, changeInPosition); @@ -2219,13 +2175,13 @@ SelectionDisplay = (function() { var directionVector, offset, stretchPanel; if (directionEnum === STRETCH_DIRECTION.X) { stretchPanel = handleStretchXPanel; - directionVector = { x:-1, y:0, z:0 }; + directionVector = { x: -1, y: 0, z: 0 }; } else if (directionEnum === STRETCH_DIRECTION.Y) { stretchPanel = handleStretchYPanel; - directionVector = { x:0, y:-1, z:0 }; + directionVector = { x: 0, y: -1, z: 0 }; } else if (directionEnum === STRETCH_DIRECTION.Z) { - stretchPanel = handleStretchZPanel - directionVector = { x:0, y:0, z:-1 }; + stretchPanel = handleStretchZPanel; + directionVector = { x: 0, y: 0, z: -1 }; } offset = Vec3.multiply(directionVector, NEGATE_VECTOR); var tool = makeStretchTool(mode, directionEnum, directionVector, directionVector, offset, stretchPanel, null); @@ -2236,28 +2192,28 @@ SelectionDisplay = (function() { function addHandleScaleTool(overlay, mode, directionEnum) { var directionVector, offset, selectedHandle; if (directionEnum === SCALE_DIRECTION.LBN) { - directionVector = { x:1, y:1, z:1 }; + directionVector = { x: 1, y: 1, z: 1 }; selectedHandle = handleScaleLBNCube; } else if (directionEnum === SCALE_DIRECTION.RBN) { - directionVector = { x:-1, y:1, z:1 }; + directionVector = { x: -1, y: 1, z: 1 }; selectedHandle = handleScaleRBNCube; } else if (directionEnum === SCALE_DIRECTION.LBF) { - directionVector = { x:1, y:1, z:-1 }; + directionVector = { x: 1, y: 1, z: -1 }; selectedHandle = handleScaleLBFCube; } else if (directionEnum === SCALE_DIRECTION.RBF) { - directionVector = { x:-1, y:1, z:-1 }; + directionVector = { x: -1, y: 1, z: -1 }; selectedHandle = handleScaleRBFCube; } else if (directionEnum === SCALE_DIRECTION.LTN) { - directionVector = { x:1, y:-1, z:1 }; + directionVector = { x: 1, y: -1, z: 1 }; selectedHandle = handleScaleLTNCube; } else if (directionEnum === SCALE_DIRECTION.RTN) { - directionVector = { x:-1, y:-1, z:1 }; + directionVector = { x: -1, y: -1, z: 1 }; selectedHandle = handleScaleRTNCube; } else if (directionEnum === SCALE_DIRECTION.LTF) { - directionVector = { x:1, y:-1, z:-1 }; + directionVector = { x: 1, y: -1, z: -1 }; selectedHandle = handleScaleLTFCube; } else if (directionEnum === SCALE_DIRECTION.RTF) { - directionVector = { x:-1, y:-1, z:-1 }; + directionVector = { x: -1, y: -1, z: -1 }; selectedHandle = handleScaleRTFCube; } offset = Vec3.multiply(directionVector, NEGATE_VECTOR); @@ -2268,7 +2224,6 @@ SelectionDisplay = (function() { // FUNCTION: UPDATE ROTATION DEGREES OVERLAY function updateRotationDegreesOverlay(angleFromZero, position) { - var angle = angleFromZero * (Math.PI / 180); var toCameraDistance = getDistanceToCamera(position); var overlayProps = { position: position, @@ -2459,9 +2414,10 @@ SelectionDisplay = (function() { var startAtCurrent = 0; var endAtCurrent = angleFromZero; + var maxDegrees = 360; if (angleFromZero < 0) { - startAtCurrent = 360 + angleFromZero; - endAtCurrent = 360; + startAtCurrent = maxDegrees + angleFromZero; + endAtCurrent = maxDegrees; } Overlays.editOverlay(handleRotateCurrentRing, { startAt: startAtCurrent, @@ -2473,8 +2429,9 @@ SelectionDisplay = (function() { if (spaceMode === SPACE_LOCAL) { Overlays.editOverlay(handleRotateCurrentRing, { rotation: worldRotationZ }); } else { + var rotationDegrees = 90; Overlays.editOverlay(handleRotateCurrentRing, { - rotation: Quat.fromPitchYawRollDegrees(-90, 0, 0) + rotation: Quat.fromPitchYawRollDegrees(-rotationDegrees, 0, 0) }); } } From 8ad8713a139bd646ed9951ae5f4d968b48b83e44 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Thu, 21 Jun 2018 17:02:51 -0700 Subject: [PATCH 22/36] New API. --- tools/auto-tester/src/Test.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 88f4e58782..1e76c19303 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -299,7 +299,9 @@ QString Test::extractPathFromTestsDown(const QString& fullPath) { void Test::includeTest(QTextStream& textStream, const QString& testPathname) { QString partialPath = extractPathFromTestsDown(testPathname); - textStream << "Script.include(repositoryPath + \"" << partialPath + "?raw=true\");" << endl; + QString partialPathWithoutTests = partialPath.right(partialPath.length() - 7); + + textStream << "Script.include(repositoryPath + \"" << partialPathWithoutTests + "\");" << endl; } // Creates a single script in a user-selected folder. @@ -394,20 +396,17 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact const QString DATE_TIME_FORMAT("MMM d yyyy, h:mm"); textStream << "// This is an automatically generated file, created by auto-tester on " << QDateTime::currentDateTime().toString(DATE_TIME_FORMAT) << endl << endl; - textStream << "user = \"" + GIT_HUB_USER + "/\";" << endl; - textStream << "repository = \"" + GIT_HUB_REPOSITORY + "/\";" << endl << endl; + // Include 'autoTest.js' + textStream << "Script.include(\"https://raw.githubusercontent.com/highfidelity/hifi_tests/master/tests/utils/branchUtils.js\");" << endl; + textStream << "var autoTester = createAutoTester(Script.resolvePath(\".\"));" << endl << endl; - textStream << "Script.include(\"https://github.com/highfidelity/hifi_tests/blob/RC69/tests/utils/branchUtils.js?raw=true\");" << endl; - textStream << "branch = getBranch(Script.resolvePath(\".\"), repository) +\"/\";" << endl << endl; + textStream << "var repositoryPath = autoTester.getRepositoryPath();" << endl << endl; // Wait 10 seconds before starting textStream << "if (typeof Test !== 'undefined') {" << endl; textStream << " Test.wait(10000);" << endl; textStream << "};" << endl << endl; - textStream << "var repositoryPath = \"https://github.com/\" + user + repository + \"blob/\" + branch;" << endl; - textStream << "var autoTester = Script.require(repositoryPath + \"tests/utils/autoTester.js?raw=true\");" << endl << endl; - textStream << "autoTester.enableRecursive();" << endl; textStream << "autoTester.enableAuto();" << endl << endl; From 5b36449edd24d9c1ea5a462909dc32d463d8bc9e Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 22 Jun 2018 09:54:25 -0700 Subject: [PATCH 23/36] allowing grabbing of collisionless entities --- scripts/system/controllers/grab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index a835373e4d..88e19a419f 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -270,7 +270,7 @@ function Grabber() { var renderStates = [{name: "grabbed", end: beacon}]; this.mouseRayEntities = Pointers.createPointer(PickType.Ray, { joint: "Mouse", - filter: Picks.PICK_ENTITIES, + filter: Picks.PICK_ENTITIES | Picks.PICK_INCLUDE_NONCOLLIDABLE, faceAvatar: true, scaleWithAvatar: true, enabled: true, From 1239472f2d332154d708dcb4e402c7a521e50d96 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Fri, 22 Jun 2018 11:35:01 -0700 Subject: [PATCH 24/36] adding line for allowing grabbing of collisionless overlays --- scripts/system/controllers/grab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index 88e19a419f..ba973f0108 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -260,7 +260,7 @@ function Grabber() { this.mouseRayOverlays = Picks.createPick(PickType.Ray, { joint: "Mouse", - filter: Picks.PICK_OVERLAYS, + filter: Picks.PICK_OVERLAYS | Picks.PICK_INCLUDE_NONCOLLIDABLE, enabled: true }); var tabletItems = getMainTabletIDs(); From df3d6890984fec750f0dd52c1be67e2dad0c9301 Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 12 Jun 2018 10:50:45 -0700 Subject: [PATCH 25/36] Try mono threaded and profiled --- libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp index 07cb5fa15f..261ec78891 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp @@ -18,7 +18,7 @@ #define DEFAULT_ALLOWED_TEXTURE_MEMORY_MB ((size_t)1024) #define MAX_RESOURCE_TEXTURES_PER_FRAME 2 #define NO_BUFFER_WORK_SLEEP_TIME_MS 2 -#define THREADED_TEXTURE_BUFFERING 1 +//#define THREADED_TEXTURE_BUFFERING 1 static const size_t DEFAULT_ALLOWED_TEXTURE_MEMORY = MB_TO_BYTES(DEFAULT_ALLOWED_TEXTURE_MEMORY_MB); @@ -375,6 +375,7 @@ void GLTextureTransferEngineDefault::populateActiveBufferQueue() { } bool GLTextureTransferEngineDefault::processActiveBufferQueue() { + PROFILE_RANGE(render_gpu_gl, __FUNCTION__); ActiveTransferQueue activeBufferQueue; { Lock lock(_bufferMutex); From 7b4b6bc3b81270f361cd9e1cebfe6417574b586d Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 22 Jun 2018 13:28:09 -0700 Subject: [PATCH 26/36] Same fix as the point lighting flashing for rc69 in master --- libraries/gpu-gl-common/src/gpu/gl/GLBackend.h | 1 + libraries/gpu-gl-common/src/gpu/gl/GLBackendInput.cpp | 10 +++++++++- .../gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp | 3 +-- libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp | 10 +++++++++- libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp | 10 +++++++++- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h index 622c8f1081..6faccb1527 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.h @@ -278,6 +278,7 @@ protected: struct InputStageState { bool _invalidFormat { true }; + bool _lastUpdateStereoState{ false }; bool _hadColorAttribute{ true }; Stream::FormatPointer _format; std::string _formatKey; diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendInput.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendInput.cpp index 4145eb6061..77e1f90f66 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendInput.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendInput.cpp @@ -156,6 +156,14 @@ void GLBackend::do_setIndirectBuffer(const Batch& batch, size_t paramOffset) { } void GLBackend::updateInput() { + bool isStereoNow = isStereo(); + // track stereo state change potentially happening wihtout changing the input format + // this is a rare case requesting to invalid the format +#ifdef GPU_STEREO_DRAWCALL_INSTANCED + _input._invalidFormat |= (isStereoNow != _input._lastUpdateStereoState); +#endif + _input._lastUpdateStereoState = isStereoNow; + if (_input._invalidFormat) { InputStageState::ActivationCache newActivation; @@ -213,7 +221,7 @@ void GLBackend::updateInput() { (void)CHECK_GL_ERROR(); } #ifdef GPU_STEREO_DRAWCALL_INSTANCED - glVertexBindingDivisor(bufferChannelNum, frequency * (isStereo() ? 2 : 1)); + glVertexBindingDivisor(bufferChannelNum, frequency * (isStereoNow ? 2 : 1)); #else glVertexBindingDivisor(bufferChannelNum, frequency); #endif diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp index 261ec78891..07cb5fa15f 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLTextureTransfer.cpp @@ -18,7 +18,7 @@ #define DEFAULT_ALLOWED_TEXTURE_MEMORY_MB ((size_t)1024) #define MAX_RESOURCE_TEXTURES_PER_FRAME 2 #define NO_BUFFER_WORK_SLEEP_TIME_MS 2 -//#define THREADED_TEXTURE_BUFFERING 1 +#define THREADED_TEXTURE_BUFFERING 1 static const size_t DEFAULT_ALLOWED_TEXTURE_MEMORY = MB_TO_BYTES(DEFAULT_ALLOWED_TEXTURE_MEMORY_MB); @@ -375,7 +375,6 @@ void GLTextureTransferEngineDefault::populateActiveBufferQueue() { } bool GLTextureTransferEngineDefault::processActiveBufferQueue() { - PROFILE_RANGE(render_gpu_gl, __FUNCTION__); ActiveTransferQueue activeBufferQueue; { Lock lock(_bufferMutex); diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp index 42bd56e6e4..9dcb08f0b7 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp @@ -25,6 +25,14 @@ void GL41Backend::resetInputStage() { } void GL41Backend::updateInput() { + bool isStereoNow = isStereo(); + // track stereo state change potentially happening wihtout changing the input format + // this is a rare case requesting to invalid the format +#ifdef GPU_STEREO_DRAWCALL_INSTANCED + _input._invalidFormat |= (isStereoNow != _input._lastUpdateStereoState); +#endif + _input._lastUpdateStereoState = isStereoNow; + if (_input._invalidFormat || _input._invalidBuffers.any()) { if (_input._invalidFormat) { @@ -111,7 +119,7 @@ void GL41Backend::updateInput() { reinterpret_cast(pointer + perLocationStride * (GLuint)locNum)); } #ifdef GPU_STEREO_DRAWCALL_INSTANCED - glVertexAttribDivisor(slot + (GLuint)locNum, attrib._frequency * (isStereo() ? 2 : 1)); + glVertexAttribDivisor(slot + (GLuint)locNum, attrib._frequency * (isStereoNow ? 2 : 1)); #else glVertexAttribDivisor(slot + (GLuint)locNum, attrib._frequency); #endif diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp index 34bf6774f7..cc3e609bda 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp @@ -27,6 +27,14 @@ void GL45Backend::resetInputStage() { } void GL45Backend::updateInput() { + bool isStereoNow = isStereo(); + // track stereo state change potentially happening wihtout changing the input format + // this is a rare case requesting to invalid the format +#ifdef GPU_STEREO_DRAWCALL_INSTANCED + _input._invalidFormat |= (isStereoNow != _input._lastUpdateStereoState); +#endif + _input._lastUpdateStereoState = isStereoNow; + if (_input._invalidFormat) { InputStageState::ActivationCache newActivation; @@ -84,7 +92,7 @@ void GL45Backend::updateInput() { (void)CHECK_GL_ERROR(); } #ifdef GPU_STEREO_DRAWCALL_INSTANCED - glVertexBindingDivisor(bufferChannelNum, frequency * (isStereo() ? 2 : 1)); + glVertexBindingDivisor(bufferChannelNum, frequency * (isStereoNow ? 2 : 1)); #else glVertexBindingDivisor(bufferChannelNum, frequency); #endif From 09ccd3acf04a639fd0fe1701f64b5b66164e26c7 Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 22 Jun 2018 18:13:40 -0700 Subject: [PATCH 27/36] fix multi-selection color setting visible/locked to false --- scripts/system/edit.js | 6 +----- scripts/system/html/js/colpick.js | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 05f5e3cb19..c751adfc78 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -2027,12 +2027,8 @@ var PropertiesTool = function (opts) { } else if (data.type === "update") { selectionManager.saveProperties(); if (selectionManager.selections.length > 1) { - properties = { - locked: data.properties.locked, - visible: data.properties.visible - }; for (i = 0; i < selectionManager.selections.length; i++) { - Entities.editEntity(selectionManager.selections[i], properties); + Entities.editEntity(selectionManager.selections[i], data.properties); } } else if (data.properties) { if (data.properties.dynamic === false) { diff --git a/scripts/system/html/js/colpick.js b/scripts/system/html/js/colpick.js index 199c624bc5..a078849ae3 100644 --- a/scripts/system/html/js/colpick.js +++ b/scripts/system/html/js/colpick.js @@ -269,6 +269,9 @@ For usage and examples: colpick.com/plugin }, // Show/hide the color picker show = function (ev) { + if ($(this).attr('disabled')) { + return; + } // Prevent the trigger of any direct parent ev.stopPropagation(); var cal = $('#' + $(this).data('colpickId')); From 39b3e5a7119c7e44618a76b499bdb85ceee613bb Mon Sep 17 00:00:00 2001 From: David Back Date: Fri, 22 Jun 2018 18:15:16 -0700 Subject: [PATCH 28/36] tabs --- scripts/system/html/js/colpick.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/system/html/js/colpick.js b/scripts/system/html/js/colpick.js index a078849ae3..505dd294d6 100644 --- a/scripts/system/html/js/colpick.js +++ b/scripts/system/html/js/colpick.js @@ -269,9 +269,9 @@ For usage and examples: colpick.com/plugin }, // Show/hide the color picker show = function (ev) { - if ($(this).attr('disabled')) { - return; - } + if ($(this).attr('disabled')) { + return; + } // Prevent the trigger of any direct parent ev.stopPropagation(); var cal = $('#' + $(this).data('colpickId')); From 25834c38099374a92f5d171b62d50de71168cc3c Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 25 Jun 2018 09:13:58 -0700 Subject: [PATCH 29/36] Allow multiple evaluations. --- tools/auto-tester/src/Test.cpp | 20 ++++-- tools/auto-tester/src/Test.h | 6 +- tools/auto-tester/src/main.cpp | 24 +++++-- tools/auto-tester/src/ui/AutoTester.cpp | 23 ++++-- tools/auto-tester/src/ui/AutoTester.h | 8 ++- tools/auto-tester/src/ui/AutoTester.ui | 94 ++++++++++++++++--------- 6 files changed, 117 insertions(+), 58 deletions(-) diff --git a/tools/auto-tester/src/Test.cpp b/tools/auto-tester/src/Test.cpp index 1e76c19303..4f02544c12 100644 --- a/tools/auto-tester/src/Test.cpp +++ b/tools/auto-tester/src/Test.cpp @@ -27,7 +27,8 @@ Test::Test() { mismatchWindow.setModal(true); if (autoTester) { - autoTester->loadBranchCombo(GIT_HUB_BRANCHES); + autoTester->setUserText("highfidelity"); + autoTester->setBranchText("master"); } } @@ -176,7 +177,7 @@ void Test::appendTestResultsToFile(const QString& testResultsFolderPath, TestFai comparisonImage.save(failureFolderPath + "/" + "Difference Image.png"); } -void Test::startTestsEvaluation(const QString& testFolder, const QString& branchFromCommandLine) { +void Test::startTestsEvaluation(const QString& testFolder, const QString& branchFromCommandLine, const QString& userFromCommandLine) { if (testFolder.isNull()) { // Get list of JPEG images in folder, sorted by name QString previousSelection = snapshotDirectory; @@ -213,7 +214,8 @@ void Test::startTestsEvaluation(const QString& testFolder, const QString& branch expectedImagesFilenames.clear(); expectedImagesFullFilenames.clear(); - QString branch = (branchFromCommandLine.isNull()) ? autoTester->getSelectedBranch() : branchFromCommandLine ; + QString branch = (branchFromCommandLine.isNull()) ? autoTester->getSelectedBranch() : branchFromCommandLine; + QString user = (userFromCommandLine.isNull()) ? autoTester->getSelectedUser() : userFromCommandLine; foreach(QString currentFilename, sortedTestResultsFilenames) { QString fullCurrentFilename = snapshotDirectory + "/" + currentFilename; @@ -227,7 +229,7 @@ void Test::startTestsEvaluation(const QString& testFolder, const QString& branch QString expectedImageFilenameTail = currentFilename.left(currentFilename.length() - 4).right(NUM_DIGITS); QString expectedImageStoredFilename = EXPECTED_IMAGE_PREFIX + expectedImageFilenameTail + ".png"; - QString imageURLString("https://raw.githubusercontent.com/" + GIT_HUB_USER + "/hifi_tests/" + branch + "/" + + QString imageURLString("https://raw.githubusercontent.com/" + user + "/" + GIT_HUB_REPOSITORY + "/" + branch + "/" + expectedImagePartialSourceDirectory + "/" + expectedImageStoredFilename); expectedImagesURLs << imageURLString; @@ -301,7 +303,7 @@ void Test::includeTest(QTextStream& textStream, const QString& testPathname) { QString partialPath = extractPathFromTestsDown(testPathname); QString partialPathWithoutTests = partialPath.right(partialPath.length() - 7); - textStream << "Script.include(repositoryPath + \"" << partialPathWithoutTests + "\");" << endl; + textStream << "Script.include(testsRootPath + \"" << partialPathWithoutTests + "\");" << endl; } // Creates a single script in a user-selected folder. @@ -397,10 +399,14 @@ void Test::createRecursiveScript(const QString& topLevelDirectory, bool interact textStream << "// This is an automatically generated file, created by auto-tester on " << QDateTime::currentDateTime().toString(DATE_TIME_FORMAT) << endl << endl; // Include 'autoTest.js' - textStream << "Script.include(\"https://raw.githubusercontent.com/highfidelity/hifi_tests/master/tests/utils/branchUtils.js\");" << endl; + QString branch = autoTester->getSelectedBranch(); + QString user = autoTester->getSelectedUser(); + + textStream << "PATH_TO_THE_REPO_PATH_UTILS_FILE = \"https://raw.githubusercontent.com/" + user + "/hifi_tests/" + branch + "/tests/utils/branchUtils.js\";" << endl; + textStream << "Script.include(PATH_TO_THE_REPO_PATH_UTILS_FILE);" << endl; textStream << "var autoTester = createAutoTester(Script.resolvePath(\".\"));" << endl << endl; - textStream << "var repositoryPath = autoTester.getRepositoryPath();" << endl << endl; + textStream << "var testsRootPath = autoTester.getTestsRootPath();" << endl << endl; // Wait 10 seconds before starting textStream << "if (typeof Test !== 'undefined') {" << endl; diff --git a/tools/auto-tester/src/Test.h b/tools/auto-tester/src/Test.h index 94d868338d..5c6d3e5686 100644 --- a/tools/auto-tester/src/Test.h +++ b/tools/auto-tester/src/Test.h @@ -37,7 +37,7 @@ class Test { public: Test(); - void startTestsEvaluation(const QString& testFolder = QString(), const QString& branchFromCommandLine = QString()); + void startTestsEvaluation(const QString& testFolder = QString(), const QString& branchFromCommandLine = QString(), const QString& userFromCommandLine = QString()); void finishTestsEvaluation(bool isRunningFromCommandline, bool interactiveMode, QProgressBar* progressBar); void createRecursiveScript(); @@ -102,12 +102,8 @@ private: QStringList resultImagesFullFilenames; // Used for accessing GitHub - const QString GIT_HUB_USER{ "highfidelity" }; const QString GIT_HUB_REPOSITORY{ "hifi_tests" }; - // The branch is user-selected - const QStringList GIT_HUB_BRANCHES{ "master", "RC69" }; - const QString DATETIME_FORMAT{ "yyyy-MM-dd_hh-mm-ss" }; ExtractedText getTestScriptLines(QString testFileName); diff --git a/tools/auto-tester/src/main.cpp b/tools/auto-tester/src/main.cpp index e01cd21f77..ed7f4b4e74 100644 --- a/tools/auto-tester/src/main.cpp +++ b/tools/auto-tester/src/main.cpp @@ -19,11 +19,17 @@ int main(int argc, char *argv[]) { // Parameter --testFolder // Parameter --branch // default is "master" - // + // Parameter --user + // default is "highfidelity" + // Parameter --repository + // default is "highfidelity" + QString testFolder; - QString branch; - if (argc > 2) { - for (int i = 1; i < argc - 1; ++i) + + QString branch{ "master" }; + QString user{ "highfidelity" }; + + for (int i = 1; i < argc - 1; ++i) { if (QString(argv[i]) == "--testFolder") { ++i; if (i < argc) { @@ -40,6 +46,14 @@ int main(int argc, char *argv[]) { std::cout << "Missing parameter after --branch" << endl; exit(-1); } + } else if (QString(argv[i]) == "--user") { + ++i; + if (i < argc) { + user = QString(argv[i]); + } else { + std::cout << "Missing parameter after --user" << endl; + exit(-1); + } } else { std::cout << "Unknown parameter" << endl; exit(-1); @@ -52,7 +66,7 @@ int main(int argc, char *argv[]) { autoTester->setup(); if (!testFolder.isNull()) { - autoTester->runFromCommandLine(testFolder, branch); + autoTester->runFromCommandLine(testFolder, branch, user); } else { autoTester->show(); } diff --git a/tools/auto-tester/src/ui/AutoTester.cpp b/tools/auto-tester/src/ui/AutoTester.cpp index a238e2e7e8..079fa63a9d 100644 --- a/tools/auto-tester/src/ui/AutoTester.cpp +++ b/tools/auto-tester/src/ui/AutoTester.cpp @@ -35,9 +35,9 @@ void AutoTester::setup() { test = new Test(); } -void AutoTester::runFromCommandLine(const QString& testFolder, const QString& branch) { +void AutoTester::runFromCommandLine(const QString& testFolder, const QString& branch, const QString& user) { isRunningFromCommandline = true; - test->startTestsEvaluation(testFolder, branch); + test->startTestsEvaluation(testFolder, branch, user); } void AutoTester::on_evaluateTestsButton_clicked() { @@ -118,6 +118,7 @@ void AutoTester::downloadImages(const QStringList& URLs, const QString& director ui.progressBar->setValue(0); ui.progressBar->setVisible(true); + downloaders.clear(); for (int i = 0; i < _numberOfImagesToDownload; ++i) { QUrl imageURL(URLs[i]); downloadImage(imageURL); @@ -141,6 +142,7 @@ void AutoTester::saveImage(int index) { ++_numberOfImagesDownloaded; if (_numberOfImagesDownloaded == _numberOfImagesToDownload) { + disconnect(signalMapper, SIGNAL (mapped(int)), this, SLOT (saveImage(int))); test->finishTestsEvaluation(isRunningFromCommandline, ui.checkBoxInteractiveMode->isChecked(), ui.progressBar); } else { ui.progressBar->setValue(_numberOfImagesDownloaded); @@ -151,10 +153,19 @@ void AutoTester::about() { QMessageBox::information(0, "About", QString("Built ") + __DATE__ + " : " + __TIME__); } -void AutoTester::loadBranchCombo(const QStringList& items) { - ui.branchComboBox->addItems(items); +void AutoTester::setUserText(const QString& user) { + ui.userTextEdit->setText(user); +} + +QString AutoTester::getSelectedUser() +{ + return ui.userTextEdit->toPlainText(); +} + +void AutoTester::setBranchText(const QString& branch) { + ui.branchTextEdit->setText(branch); } QString AutoTester::getSelectedBranch() { - return ui.branchComboBox->currentText(); -} \ No newline at end of file + return ui.branchTextEdit->toPlainText(); +} diff --git a/tools/auto-tester/src/ui/AutoTester.h b/tools/auto-tester/src/ui/AutoTester.h index 5eff89e957..d47c4929c4 100644 --- a/tools/auto-tester/src/ui/AutoTester.h +++ b/tools/auto-tester/src/ui/AutoTester.h @@ -12,6 +12,7 @@ #include #include +#include #include "ui_AutoTester.h" #include "../Downloader.h" @@ -25,12 +26,15 @@ public: void setup(); - void runFromCommandLine(const QString& testFolder, const QString& branch); + void runFromCommandLine(const QString& testFolder, const QString& branch, const QString& user); void downloadImage(const QUrl& url); void downloadImages(const QStringList& URLs, const QString& directoryName, const QStringList& filenames); - void loadBranchCombo(const QStringList& items); + void setUserText(const QString& user); + QString getSelectedUser(); + + void setBranchText(const QString& branch); QString getSelectedBranch(); private slots: diff --git a/tools/auto-tester/src/ui/AutoTester.ui b/tools/auto-tester/src/ui/AutoTester.ui index df21dad1eb..e12fc70e3f 100644 --- a/tools/auto-tester/src/ui/AutoTester.ui +++ b/tools/auto-tester/src/ui/AutoTester.ui @@ -6,8 +6,8 @@ 0 0 - 583 - 514 + 612 + 537 @@ -17,8 +17,8 @@ - 460 - 410 + 380 + 430 101 40 @@ -43,9 +43,9 @@ - 330 - 275 - 220 + 430 + 270 + 101 40 @@ -57,7 +57,7 @@ 330 - 30 + 110 220 40 @@ -69,8 +69,8 @@ - 330 - 250 + 320 + 280 131 20 @@ -85,7 +85,7 @@ - 330 + 320 330 255 23 @@ -99,7 +99,7 @@ 330 - 80 + 170 220 40 @@ -112,7 +112,7 @@ 20 - 100 + 110 220 40 @@ -125,7 +125,7 @@ 20 - 150 + 160 220 40 @@ -138,7 +138,7 @@ 20 - 220 + 250 220 40 @@ -151,43 +151,33 @@ 10 - 410 - 91 + 440 + 211 40 - Show Taskbar + Show Windows Taskbar 10 - 360 - 91 + 390 + 211 40 - Hide Taskbar - - - - - - 418 - 211 - 131 - 31 - + Hide Windows Taskbar 330 - 220 + 55 81 16 @@ -201,13 +191,51 @@ GitHub Branch + + + + 330 + 15 + 81 + 16 + + + + + 10 + + + + GitHub User + + + + + + 420 + 12 + 140 + 24 + + + + + + + 420 + 50 + 140 + 24 + + + 0 0 - 583 + 612 21 From b73a957935ad67ddfde432297c309cd22b2bf8e2 Mon Sep 17 00:00:00 2001 From: humbletim Date: Mon, 25 Jun 2018 14:17:33 -0400 Subject: [PATCH 30/36] changes per PR --- scripts/developer/tests/raypickTester.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/developer/tests/raypickTester.js b/scripts/developer/tests/raypickTester.js index a6704fc55c..cebee4f29a 100644 --- a/scripts/developer/tests/raypickTester.js +++ b/scripts/developer/tests/raypickTester.js @@ -32,7 +32,7 @@ var pickID = Picks.createPick(PickType.Ray, { var blacklist = [ overlayID ]; // exclude hover text from ray pick results Picks.setIgnoreItems(pickID, blacklist); Script.scriptEnding.connect(function() { - RayPick.removeRayPick(pickID); + Picks.removePick(pickID); }); // query object materials (using the Graphics.* API) @@ -68,6 +68,6 @@ function updateOverlay(overlayID, result) { // monitor for enw results at 30fps Script.setInterval(function() { - var result = RayPick.getPrevRayPickResult(pickID); + var result = Picks.getPrevPickResult(pickID); updateOverlay(overlayID, result); }, UPDATE_MS); From 7a5d79450580ada0a9bcd6081c7e778ff8e8fbac Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 25 Jun 2018 14:40:54 -0700 Subject: [PATCH 31/36] Fix MS16113: Use alternate method for creating backup instructions --- interface/src/commerce/Wallet.cpp | 33 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index e003ae88a0..991f1ebf3f 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -127,31 +127,40 @@ EC_KEY* readKeys(const char* filename) { bool Wallet::writeBackupInstructions() { QString inputFilename(PathUtils::resourcesPath() + "html/commerce/backup_instructions.html"); QString outputFilename = PathUtils::getAppDataFilePath(INSTRUCTIONS_FILE); + QFile inputFile(inputFilename); QFile outputFile(outputFilename); bool retval = false; - if (QFile::exists(outputFilename) || getKeyFilePath() == "") + if (getKeyFilePath() == "") { return false; } - QFile::copy(inputFilename, outputFilename); - if (QFile::exists(outputFilename) && outputFile.open(QIODevice::ReadWrite)) { + if (QFile::exists(inputFilename) && inputFile.open(QIODevice::ReadOnly)) { + if (outputFile.open(QIODevice::ReadWrite)) { + // Read the data from the original file, then close it + QByteArray fileData = inputFile.readAll(); + inputFile.close(); - QByteArray fileData = outputFile.readAll(); - QString text(fileData); + // Translate the data from the original file into a QString + QString text(fileData); - text.replace(QString("HIFIKEY_PATH_REPLACEME"), keyFilePath()); + // Replace the necessary string + text.replace(QString("HIFIKEY_PATH_REPLACEME"), keyFilePath()); - outputFile.seek(0); // go to the beginning of the file - outputFile.write(text.toUtf8()); // write the new text back to the file + // Write the new text back to the file + outputFile.write(text.toUtf8()); - outputFile.close(); // close the file handle. + // Close the output file + outputFile.close(); - retval = true; - qCDebug(commerce) << "wrote html file successfully"; + retval = true; + qCDebug(commerce) << "wrote html file successfully"; + } else { + qCDebug(commerce) << "failed to open output html file" << outputFilename; + } } else { - qCDebug(commerce) << "failed to open output html file" << outputFilename; + qCDebug(commerce) << "failed to open input html file" << inputFilename; } return retval; } From 05438f3b850b50da73baf0d784060503961e5143 Mon Sep 17 00:00:00 2001 From: David Back Date: Mon, 25 Jun 2018 15:26:54 -0700 Subject: [PATCH 32/36] bad avatar collision merge --- scripts/system/libraries/entitySelectionTool.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 4b0c73e304..cd3c9fe418 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -657,11 +657,6 @@ SelectionDisplay = (function() { var activeTool = null; var handleTools = {}; - that.shutdown = function() { - that.restoreAvatarCollisionsFromStretch(); - }; - Script.scriptEnding.connect(that.shutdown); - // We get mouseMoveEvents from the handControllers, via handControllerPointer. // But we dont' get mousePressEvents. that.triggerMapping = Controller.newMapping(Script.resolvePath('') + '-click'); @@ -1882,13 +1877,6 @@ SelectionDisplay = (function() { }; }; - that.restoreAvatarCollisionsFromStretch = function() { - if (handleStretchCollisionOverride) { - Menu.setIsOptionChecked(AVATAR_COLLISIONS_OPTION, true); - handleStretchCollisionOverride = false; - } - }; - // TOOL DEFINITION: HANDLE STRETCH TOOL function makeStretchTool(stretchMode, directionEnum, directionVec, pivot, offset, stretchPanel, scaleHandle) { var directionFor3DStretch = directionVec; From bd8e8aab85cd3cdd630745b1f0255671bb4d316a Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Mon, 25 Jun 2018 16:40:43 -0700 Subject: [PATCH 33/36] Fixed gcc warnings. --- tools/auto-tester/src/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/auto-tester/src/main.cpp b/tools/auto-tester/src/main.cpp index ed7f4b4e74..03b8cf51ff 100644 --- a/tools/auto-tester/src/main.cpp +++ b/tools/auto-tester/src/main.cpp @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { if (i < argc) { testFolder = QString(argv[i]); } else { - std::cout << "Missing parameter after --testFolder" << endl; + std::cout << "Missing parameter after --testFolder" << std::endl; exit(-1); } } else if (QString(argv[i]) == "--branch") { @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) { if (i < argc) { branch = QString(argv[i]); } else { - std::cout << "Missing parameter after --branch" << endl; + std::cout << "Missing parameter after --branch" << std::endl; exit(-1); } } else if (QString(argv[i]) == "--user") { @@ -51,11 +51,11 @@ int main(int argc, char *argv[]) { if (i < argc) { user = QString(argv[i]); } else { - std::cout << "Missing parameter after --user" << endl; + std::cout << "Missing parameter after --user" << std::endl; exit(-1); } } else { - std::cout << "Unknown parameter" << endl; + std::cout << "Unknown parameter" << std::endl; exit(-1); } } From a906fbaf5634e16f307f2ab97587f09a11738a57 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 26 Jun 2018 10:20:22 -0700 Subject: [PATCH 34/36] fix login links --- .../qml/LoginDialog/LinkAccountBody.qml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/LoginDialog/LinkAccountBody.qml b/interface/resources/qml/LoginDialog/LinkAccountBody.qml index 4708bfdebe..6cbd1c4837 100644 --- a/interface/resources/qml/LoginDialog/LinkAccountBody.qml +++ b/interface/resources/qml/LoginDialog/LinkAccountBody.qml @@ -126,10 +126,12 @@ Item { activeFocusOnPress: true ShortcutText { + z: 10 anchors { - verticalCenter: usernameField.textFieldLabel.verticalCenter - left: usernameField.textFieldLabel.right - leftMargin: 10 + left: usernameField.left + top: usernameField.top + leftMargin: usernameField.textFieldLabel.contentWidth + 10 + topMargin: -19 } text: "Forgot Username?" @@ -154,10 +156,12 @@ Item { activeFocusOnPress: true ShortcutText { + z: 10 anchors { - verticalCenter: passwordField.textFieldLabel.verticalCenter - left: passwordField.textFieldLabel.right - leftMargin: 10 + left: passwordField.left + top: passwordField.top + leftMargin: passwordField.textFieldLabel.contentWidth + 10 + topMargin: -19 } text: "Forgot Password?" @@ -168,6 +172,7 @@ Item { onLinkActivated: loginDialog.openUrl(link) } + onFocusChanged: { root.text = ""; root.isPassword = true; From d8834af7499d83c8fcebe919695b56e5c749b3e7 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 26 Jun 2018 11:53:45 -0700 Subject: [PATCH 35/36] make requested changes --- libraries/entities-renderer/src/RenderableEntityItem.h | 1 + .../src/RenderableMaterialEntityItem.h | 1 - .../src/RenderableParticleEffectEntityItem.h | 1 - .../entities-renderer/src/RenderableShapeEntityItem.h | 1 - .../entities-renderer/src/RenderableTextEntityItem.cpp | 10 +++++----- .../entities-renderer/src/RenderableTextEntityItem.h | 3 +-- .../entities-renderer/src/RenderableWebEntityItem.h | 1 - .../entities-renderer/src/RenderableZoneEntityItem.h | 1 - 8 files changed, 7 insertions(+), 12 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableEntityItem.h b/libraries/entities-renderer/src/RenderableEntityItem.h index 1083d74807..40966c4f41 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.h +++ b/libraries/entities-renderer/src/RenderableEntityItem.h @@ -141,6 +141,7 @@ protected: bool _needsRenderUpdate { false }; // Only touched on the rendering thread bool _renderUpdateQueued{ false }; + Transform _renderTransform; std::unordered_map _materials; std::mutex _materialsLock; diff --git a/libraries/entities-renderer/src/RenderableMaterialEntityItem.h b/libraries/entities-renderer/src/RenderableMaterialEntityItem.h index 96c720f79f..168041a842 100644 --- a/libraries/entities-renderer/src/RenderableMaterialEntityItem.h +++ b/libraries/entities-renderer/src/RenderableMaterialEntityItem.h @@ -35,7 +35,6 @@ private: glm::vec2 _materialMappingPos; glm::vec2 _materialMappingScale; float _materialMappingRot; - Transform _renderTransform; std::shared_ptr _drawMaterial; }; diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h index b182be346e..8e9353894a 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.h @@ -89,7 +89,6 @@ private: BufferPointer _particleBuffer{ std::make_shared() }; BufferView _uniformBuffer; quint64 _lastSimulated { 0 }; - Transform _renderTransform; NetworkTexturePointer _networkTexture; ScenePointer _scene; diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.h b/libraries/entities-renderer/src/RenderableShapeEntityItem.h index 463ef187fc..7700aa6ef0 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.h +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.h @@ -40,7 +40,6 @@ private: Procedural _procedural; QString _lastUserData; - Transform _renderTransform; entity::Shape _shape { entity::Sphere }; std::shared_ptr _material; glm::vec3 _position; diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp index 4f08fca1d7..ce4b6d9175 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.cpp @@ -77,11 +77,11 @@ void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen } void TextEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointer& entity) { - _textColor = toGlm(entity->getTextColorX()); - _backgroundColor = toGlm(entity->getBackgroundColorX()); - _faceCamera = entity->getFaceCamera(); - _lineHeight = entity->getLineHeight(); - _text = entity->getText(); + _textColor = toGlm(entity->getTextColorX()); + _backgroundColor = toGlm(entity->getBackgroundColorX()); + _faceCamera = entity->getFaceCamera(); + _lineHeight = entity->getLineHeight(); + _text = entity->getText(); } diff --git a/libraries/entities-renderer/src/RenderableTextEntityItem.h b/libraries/entities-renderer/src/RenderableTextEntityItem.h index 93d6deb354..ac7f2b620f 100644 --- a/libraries/entities-renderer/src/RenderableTextEntityItem.h +++ b/libraries/entities-renderer/src/RenderableTextEntityItem.h @@ -35,12 +35,11 @@ private: bool _faceCamera; glm::vec3 _dimensions; glm::vec3 _textColor; - Transform _renderTransform; glm::vec3 _backgroundColor; QString _text; float _lineHeight; }; -} } +} } #endif // hifi_RenderableTextEntityItem_h diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.h b/libraries/entities-renderer/src/RenderableWebEntityItem.h index 3100014e9b..1ba8ed0ec7 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.h +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.h @@ -68,7 +68,6 @@ private: bool _lastLocked; QTimer _timer; uint64_t _lastRenderTime { 0 }; - Transform _renderTransform; }; } } // namespace diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.h b/libraries/entities-renderer/src/RenderableZoneEntityItem.h index 2f8fd47b79..c48679e5d4 100644 --- a/libraries/entities-renderer/src/RenderableZoneEntityItem.h +++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.h @@ -123,7 +123,6 @@ private: bool _pendingSkyboxTexture{ false }; QString _proceduralUserData; - Transform _renderTransform; }; } } // namespace From 97ee02811c3533d08193015d38e2df3c1a761544 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 26 Jun 2018 12:27:59 -0700 Subject: [PATCH 36/36] disable shadows in secondary camera --- interface/src/SecondaryCamera.cpp | 21 ++++++------------- interface/src/SecondaryCamera.h | 14 +------------ .../src/DeferredLightingEffect.cpp | 12 ++++------- .../render-utils/src/DeferredLightingEffect.h | 9 ++++++-- libraries/render-utils/src/RenderCommonTask.h | 3 +-- .../render-utils/src/RenderDeferredTask.cpp | 8 +++---- .../render-utils/src/RenderDeferredTask.h | 2 +- libraries/render-utils/src/RenderViewTask.cpp | 2 +- 8 files changed, 25 insertions(+), 46 deletions(-) diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp index b9a767f700..559cb140b5 100644 --- a/interface/src/SecondaryCamera.cpp +++ b/interface/src/SecondaryCamera.cpp @@ -11,25 +11,16 @@ #include "SecondaryCamera.h" +#include +#include + #include #include -#include #include "Application.h" using RenderArgsPointer = std::shared_ptr; -void MainRenderTask::build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred) { - task.addJob("RenderShadowTask", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1); - const auto items = task.addJob("FetchCullSort", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1); - assert(items.canCast()); - if (!isDeferred) { - task.addJob("Forward", items); - } else { - task.addJob("RenderDeferredTask", items); - } -} - class SecondaryCameraJob { // Changes renderContext for our framebuffer and view. public: using Config = SecondaryCameraJobConfig; @@ -213,10 +204,10 @@ void SecondaryCameraRenderTask::build(JobModel& task, const render::Varying& inp const auto cachedArg = task.addJob("SecondaryCamera"); const auto items = task.addJob("FetchCullSort", cullFunctor, render::ItemKey::TAG_BITS_1, render::ItemKey::TAG_BITS_1); assert(items.canCast()); - if (!isDeferred) { - task.addJob("Forward", items); + if (isDeferred) { + task.addJob("RenderDeferredTask", items, false); } else { - task.addJob("RenderDeferredTask", items); + task.addJob("Forward", items); } task.addJob("EndSecondaryCamera", cachedArg); } \ No newline at end of file diff --git a/interface/src/SecondaryCamera.h b/interface/src/SecondaryCamera.h index 3d9e52617c..3c8540c081 100644 --- a/interface/src/SecondaryCamera.h +++ b/interface/src/SecondaryCamera.h @@ -12,23 +12,11 @@ #pragma once #ifndef hifi_SecondaryCamera_h #define hifi_SecondaryCamera_h - -#include + #include -#include -#include #include #include -class MainRenderTask { -public: - using JobModel = render::Task::Model; - - MainRenderTask() {} - - void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, render::CullFunctor cullFunctor, bool isDeferred = true); -}; - class SecondaryCameraJobConfig : public render::Task::Config { // Exposes secondary camera parameters to JavaScript. Q_OBJECT Q_PROPERTY(QUuid attachedEntityId MEMBER attachedEntityId NOTIFY dirty) // entity whose properties define camera position and orientation diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index a98e0403fa..9223e0fa03 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -472,7 +472,8 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, const graphics::HazePointer& haze, const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer, const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer, - const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource) { + const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource, + bool renderShadows) { auto args = renderContext->args; auto& batch = (*args->_batch); @@ -554,7 +555,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, // Check if keylight casts shadows bool keyLightCastShadows { false }; - if (lightStage && lightStage->_currentFrame._sunLights.size()) { + if (renderShadows && lightStage && lightStage->_currentFrame._sunLights.size()) { graphics::LightPointer keyLight = lightStage->getLight(lightStage->_currentFrame._sunLights.front()); if (keyLight) { keyLightCastShadows = keyLight->getCastShadows(); @@ -711,11 +712,6 @@ void RenderDeferredCleanup::run(const render::RenderContextPointer& renderContex } } -RenderDeferred::RenderDeferred() { - -} - - void RenderDeferred::configure(const Config& config) { } @@ -742,7 +738,7 @@ void RenderDeferred::run(const RenderContextPointer& renderContext, const Inputs args->_batch = &batch; _gpuTimer->begin(batch); - setupJob.run(renderContext, deferredTransform, deferredFramebuffer, lightingModel, haze, surfaceGeometryFramebuffer, ssaoFramebuffer, subsurfaceScatteringResource); + setupJob.run(renderContext, deferredTransform, deferredFramebuffer, lightingModel, haze, surfaceGeometryFramebuffer, ssaoFramebuffer, subsurfaceScatteringResource, _renderShadows); lightsJob.run(renderContext, deferredTransform, deferredFramebuffer, lightingModel, surfaceGeometryFramebuffer, lightClusters); diff --git a/libraries/render-utils/src/DeferredLightingEffect.h b/libraries/render-utils/src/DeferredLightingEffect.h index 3b77b8137e..9b55083ad7 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.h +++ b/libraries/render-utils/src/DeferredLightingEffect.h @@ -127,7 +127,8 @@ public: const graphics::HazePointer& haze, const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer, const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer, - const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource); + const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource, + bool renderShadows); }; class RenderDeferredLocals { @@ -166,7 +167,8 @@ public: using Config = RenderDeferredConfig; using JobModel = render::Job::ModelI; - RenderDeferred(); + RenderDeferred() {} + RenderDeferred(bool renderShadows) : _renderShadows(renderShadows) {} void configure(const Config& config); @@ -178,6 +180,9 @@ public: protected: gpu::RangeTimerPointer _gpuTimer; + +private: + bool _renderShadows { false }; }; class DefaultLightingSetup { diff --git a/libraries/render-utils/src/RenderCommonTask.h b/libraries/render-utils/src/RenderCommonTask.h index 79599d3ab7..65f8cdfbfc 100644 --- a/libraries/render-utils/src/RenderCommonTask.h +++ b/libraries/render-utils/src/RenderCommonTask.h @@ -61,7 +61,6 @@ protected: class DrawOverlay3D { public: using Inputs = render::VaryingSet3; - using Config = DrawOverlay3DConfig; using JobModel = render::Job::ModelI; @@ -73,7 +72,7 @@ public: protected: render::ShapePlumberPointer _shapePlumber; int _maxDrawn; // initialized by Config - bool _opaquePass{ true }; + bool _opaquePass { true }; }; class CompositeHUD { diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index dc12c0f781..32bdad280c 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -64,8 +64,8 @@ void RenderDeferredTask::configure(const Config& config) } const render::Varying RenderDeferredTask::addSelectItemJobs(JobModel& task, const char* selectionName, - const render::Varying& metas, - const render::Varying& opaques, + const render::Varying& metas, + const render::Varying& opaques, const render::Varying& transparents) { const auto selectMetaInput = SelectItems::Inputs(metas, Varying(), std::string()).asVarying(); const auto selectedMetas = task.addJob("MetaSelection", selectMetaInput, selectionName); @@ -75,7 +75,7 @@ const render::Varying RenderDeferredTask::addSelectItemJobs(JobModel& task, cons return task.addJob("TransparentSelection", selectItemInput, selectionName); } -void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output) { +void RenderDeferredTask::build(JobModel& task, const render::Varying& input, render::Varying& output, bool renderShadows) { const auto& items = input.get(); auto fadeEffect = DependencyManager::get(); @@ -168,7 +168,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto deferredLightingInputs = RenderDeferred::Inputs(deferredFrameTransform, deferredFramebuffer, lightingModel, surfaceGeometryFramebuffer, ambientOcclusionFramebuffer, scatteringResource, lightClusters, hazeModel).asVarying(); - task.addJob("RenderDeferred", deferredLightingInputs); + task.addJob("RenderDeferred", deferredLightingInputs, renderShadows); // Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job diff --git a/libraries/render-utils/src/RenderDeferredTask.h b/libraries/render-utils/src/RenderDeferredTask.h index 9917058790..ab6ab177d2 100644 --- a/libraries/render-utils/src/RenderDeferredTask.h +++ b/libraries/render-utils/src/RenderDeferredTask.h @@ -126,7 +126,7 @@ public: RenderDeferredTask(); void configure(const Config& config); - void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs); + void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs, bool renderShadows); private: static const render::Varying addSelectItemJobs(JobModel& task, diff --git a/libraries/render-utils/src/RenderViewTask.cpp b/libraries/render-utils/src/RenderViewTask.cpp index 82426a3a1f..6f6a87c222 100644 --- a/libraries/render-utils/src/RenderViewTask.cpp +++ b/libraries/render-utils/src/RenderViewTask.cpp @@ -27,7 +27,7 @@ void RenderViewTask::build(JobModel& task, const render::Varying& input, render: assert(items.canCast()); if (isDeferred) { - task.addJob("RenderDeferredTask", items); + task.addJob("RenderDeferredTask", items, true); } else { task.addJob("Forward", items); }