-class AboutUtil : public QObject {
+/**jsdoc
+ * @namespace HifiAbout
+ *
+ * @hifi-interface
+ * @hifi-client-entity
+ *
+ * @property {string} buildDate
+ * @property {string} buildVersion
+ * @property {string} qtVersion
+ */
+class AboutUtil : public QObject {
Q_OBJECT
- Q_PROPERTY(QString buildDate READ buildDate CONSTANT)
- Q_PROPERTY(QString buildVersion READ buildVersion CONSTANT)
- Q_PROPERTY(QString qtVersion READ qtVersion CONSTANT)
-
- AboutUtil(QObject* parent = nullptr);
+ Q_PROPERTY(QString buildDate READ getBuildDate CONSTANT)
+ Q_PROPERTY(QString buildVersion READ getBuildVersion CONSTANT)
+ Q_PROPERTY(QString qtVersion READ getQtVersion CONSTANT)
public:
static AboutUtil* getInstance();
~AboutUtil() {}
- QString buildDate() const;
- QString buildVersion() const;
- QString qtVersion() const;
+ QString getBuildDate() const;
+ QString getBuildVersion() const;
+ QString getQtVersion() const;
public slots:
+
+ /**jsdoc
+ * @function HifiAbout.openUrl
+ * @param {string} url
+ */
void openUrl(const QString &url) const;
private:
-
- QString m_DateConverted;
+ AboutUtil(QObject* parent = nullptr);
+ QString _dateConverted;
};
#endif // hifi_AboutUtil_h
diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp
index 6a102f418b..acdcdef2cf 100644
--- a/interface/src/Application.cpp
+++ b/interface/src/Application.cpp
@@ -334,7 +334,11 @@ static const QString RENDER_FORWARD{ "HIFI_RENDER_FORWARD" };
static bool DISABLE_DEFERRED = QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
#endif
+#if !defined(Q_OS_ANDROID)
static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16;
+#else
+static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 4;
+#endif
// For processing on QThreadPool, we target a number of threads after reserving some
// based on how many are being consumed by the application and the display plugin. However,
@@ -693,8 +697,8 @@ private:
};
/**jsdoc
- * The Controller.Hardware.Application
object has properties representing Interface's state. The property
- * values are integer IDs, uniquely identifying each output. Read-only. These can be mapped to actions or functions or
+ *
The Controller.Hardware.Application
object has properties representing Interface's state. The property
+ * values are integer IDs, uniquely identifying each output. Read-only. These can be mapped to actions or functions or
* Controller.Standard
items in a {@link RouteObject} mapping (e.g., using the {@link RouteObject#when} method).
* Each data value is either 1.0
for "true" or 0.0
for "false".
*
@@ -717,7 +721,7 @@ private:
* NavigationFocused | number | number | Not used. |
*
*
- * @typedef Controller.Hardware-Application
+ * @typedef {object} Controller.Hardware-Application
*/
static const QString STATE_IN_HMD = "InHMD";
@@ -776,7 +780,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";
bool suppressPrompt = cmdOptionExists(argc, const_cast(argv), SUPPRESS_SETTINGS_RESET);
- // Ignore any previous crashes if running from command line with a test script.
+ // Ignore any previous crashes if running from command line with a test script.
bool inTestMode { false };
for (int i = 0; i < argc; ++i) {
QString parameter(argv[i]);
@@ -798,15 +802,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, cacheDir);
}
- // FIXME fix the OSX installer to install the resources.rcc binary instead of resource files and remove
- // this conditional exclusion
-#if !defined(Q_OS_OSX)
{
-#if defined(Q_OS_ANDROID)
- const QString resourcesBinaryFile = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/resources.rcc";
-#else
- const QString resourcesBinaryFile = QCoreApplication::applicationDirPath() + "/resources.rcc";
-#endif
+ const QString resourcesBinaryFile = PathUtils::getRccPath();
if (!QFile::exists(resourcesBinaryFile)) {
throw std::runtime_error("Unable to find primary resources");
}
@@ -814,7 +811,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
throw std::runtime_error("Unable to load primary resources");
}
}
-#endif
// Tell the plugin manager about our statically linked plugins
auto pluginManager = PluginManager::getInstance();
@@ -1112,7 +1108,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
qCDebug(interfaceapp) << "[VERSION] Build sequence:" << qPrintable(applicationVersion());
qCDebug(interfaceapp) << "[VERSION] MODIFIED_ORGANIZATION:" << BuildInfo::MODIFIED_ORGANIZATION;
qCDebug(interfaceapp) << "[VERSION] VERSION:" << BuildInfo::VERSION;
- qCDebug(interfaceapp) << "[VERSION] BUILD_BRANCH:" << BuildInfo::BUILD_BRANCH;
+ qCDebug(interfaceapp) << "[VERSION] BUILD_TYPE_STRING:" << BuildInfo::BUILD_TYPE_STRING;
qCDebug(interfaceapp) << "[VERSION] BUILD_GLOBAL_SERVICES:" << BuildInfo::BUILD_GLOBAL_SERVICES;
#if USE_STABLE_GLOBAL_SERVICES
qCDebug(interfaceapp) << "[VERSION] We will use STABLE global services.";
@@ -1369,11 +1365,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
initializeGL();
qCDebug(interfaceapp, "Initialized GL");
- // Initialize the display plugin architecture
+ // Initialize the display plugin architecture
initializeDisplayPlugins();
qCDebug(interfaceapp, "Initialized Display");
- // Create the rendering engine. This can be slow on some machines due to lots of
+ // Create the rendering engine. This can be slow on some machines due to lots of
// GPU pipeline creation.
initializeRenderEngine();
qCDebug(interfaceapp, "Initialized Render Engine.");
@@ -1417,7 +1413,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// In practice we shouldn't run across installs that don't have a known installer type.
// Client or Client+Server installs should always have the installer.ini next to their
// respective interface.exe, and Steam installs will be detected as such. If a user were
- // to delete the installer.ini, though, and as an example, we won't know the context of the
+ // to delete the installer.ini, though, and as an example, we won't know the context of the
// original install.
constexpr auto INSTALLER_KEY_TYPE = "type";
constexpr auto INSTALLER_KEY_CAMPAIGN = "campaign";
@@ -1443,17 +1439,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// add firstRun flag from settings to launch event
Setting::Handle firstRun { Settings::firstRun, true };
- // once the settings have been loaded, check if we need to flip the default for UserActivityLogger
- auto& userActivityLogger = UserActivityLogger::getInstance();
- if (!userActivityLogger.isDisabledSettingSet()) {
- // the user activity logger is opt-out for Interface
- // but it's defaulted to disabled for other targets
- // so we need to enable it here if it has never been disabled by the user
- userActivityLogger.disable(false);
- }
-
QString machineFingerPrint = uuidStringWithoutCurlyBraces(FingerprintUtils::getMachineFingerprint());
+ auto& userActivityLogger = UserActivityLogger::getInstance();
if (userActivityLogger.isEnabled()) {
// sessionRunTime will be reset soon by loadSettings. Grab it now to get previous session value.
// The value will be 0 if the user blew away settings this session, which is both a feature and a bug.
@@ -1465,6 +1453,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
{ "tester", QProcessEnvironment::systemEnvironment().contains(TESTER) },
{ "installer_campaign", installerCampaign },
{ "installer_type", installerType },
+ { "build_type", BuildInfo::BUILD_TYPE_STRING },
{ "previousSessionCrashed", _previousSessionCrashed },
{ "previousSessionRuntime", sessionRunTime.get() },
{ "cpu_architecture", QSysInfo::currentCpuArchitecture() },
@@ -2182,7 +2171,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
if (testProperty.isValid()) {
auto scriptEngines = DependencyManager::get();
const auto testScript = property(hifi::properties::TEST).toUrl();
-
+
// Set last parameter to exit interface when the test script finishes, if so requested
scriptEngines->loadScript(testScript, false, false, false, false, quitWhenFinished);
@@ -2399,7 +2388,7 @@ void Application::onAboutToQuit() {
}
}
- // The active display plugin needs to be loaded before the menu system is active,
+ // The active display plugin needs to be loaded before the menu system is active,
// so its persisted explicitly here
Setting::Handle{ ACTIVE_DISPLAY_PLUGIN_SETTING_NAME }.set(getActiveDisplayPlugin()->getName());
@@ -2492,6 +2481,7 @@ void Application::cleanupBeforeQuit() {
}
_window->saveGeometry();
+ _gpuContext->shutdown();
// Destroy third party processes after scripts have finished using them.
#ifdef HAVE_DDE
@@ -2609,10 +2599,55 @@ void Application::initializeGL() {
_isGLInitialized = true;
}
- _glWidget->makeCurrent();
- glClearColor(0.2f, 0.2f, 0.2f, 1);
- glClear(GL_COLOR_BUFFER_BIT);
- _glWidget->swapBuffers();
+ if (!_glWidget->makeCurrent()) {
+ qCWarning(interfaceapp, "Unable to make window context current");
+ }
+
+#if !defined(DISABLE_QML)
+ // Build a shared canvas / context for the Chromium processes
+ {
+ // Disable signed distance field font rendering on ATI/AMD GPUs, due to
+ // https://highfidelity.manuscript.com/f/cases/13677/Text-showing-up-white-on-Marketplace-app
+ std::string vendor{ (const char*)glGetString(GL_VENDOR) };
+ if ((vendor.find("AMD") != std::string::npos) || (vendor.find("ATI") != std::string::npos)) {
+ qputenv("QTWEBENGINE_CHROMIUM_FLAGS", QByteArray("--disable-distance-field-text"));
+ }
+
+ // Chromium rendering uses some GL functions that prevent nSight from capturing
+ // frames, so we only create the shared context if nsight is NOT active.
+ if (!nsightActive()) {
+ _chromiumShareContext = new OffscreenGLCanvas();
+ _chromiumShareContext->setObjectName("ChromiumShareContext");
+ _chromiumShareContext->create(_glWidget->qglContext());
+ if (!_chromiumShareContext->makeCurrent()) {
+ qCWarning(interfaceapp, "Unable to make chromium shared context current");
+ }
+ qt_gl_set_global_share_context(_chromiumShareContext->getContext());
+ _chromiumShareContext->doneCurrent();
+ // Restore the GL widget context
+ if (!_glWidget->makeCurrent()) {
+ qCWarning(interfaceapp, "Unable to make window context current");
+ }
+ } else {
+ qCWarning(interfaceapp) << "nSight detected, disabling chrome rendering";
+ }
+ }
+#endif
+
+ // Build a shared canvas / context for the QML rendering
+ {
+ _qmlShareContext = new OffscreenGLCanvas();
+ _qmlShareContext->setObjectName("QmlShareContext");
+ _qmlShareContext->create(_glWidget->qglContext());
+ if (!_qmlShareContext->makeCurrent()) {
+ qCWarning(interfaceapp, "Unable to make QML shared context current");
+ }
+ OffscreenQmlSurface::setSharedContext(_qmlShareContext->getContext());
+ _qmlShareContext->doneCurrent();
+ if (!_glWidget->makeCurrent()) {
+ qCWarning(interfaceapp, "Unable to make window context current");
+ }
+ }
// Build an offscreen GL context for the main thread.
_offscreenContext = new OffscreenGLCanvas();
@@ -2624,6 +2659,11 @@ void Application::initializeGL() {
_offscreenContext->doneCurrent();
_offscreenContext->setThreadContext();
+ _glWidget->makeCurrent();
+ glClearColor(0.2f, 0.2f, 0.2f, 1);
+ glClear(GL_COLOR_BUFFER_BIT);
+ _glWidget->swapBuffers();
+
// Move the GL widget context to the render event handler thread
_renderEventHandler = new RenderEventHandler(_glWidget->qglContext());
if (!_offscreenContext->makeCurrent()) {
@@ -2633,7 +2673,7 @@ void Application::initializeGL() {
// Create the GPU backend
// Requires the window context, because that's what's used in the actual rendering
- // and the GPU backend will make things like the VAO which cannot be shared across
+ // and the GPU backend will make things like the VAO which cannot be shared across
// contexts
_glWidget->makeCurrent();
gpu::Context::init();
@@ -2656,7 +2696,7 @@ void Application::initializeDisplayPlugins() {
auto lastActiveDisplayPluginName = activeDisplayPluginSetting.get();
auto defaultDisplayPlugin = displayPlugins.at(0);
- // Once time initialization code
+ // Once time initialization code
DisplayPluginPointer targetDisplayPlugin;
foreach(auto displayPlugin, displayPlugins) {
displayPlugin->setContext(_gpuContext);
@@ -2669,7 +2709,7 @@ void Application::initializeDisplayPlugins() {
}
// The default display plugin needs to be activated first, otherwise the display plugin thread
- // may be launched by an external plugin, which is bad
+ // may be launched by an external plugin, which is bad
setDisplayPlugin(defaultDisplayPlugin);
// Now set the desired plugin if it's not the same as the default plugin
@@ -2746,40 +2786,6 @@ extern void setupPreferences();
static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, int index, bool active = false);
void Application::initializeUi() {
- // Build a shared canvas / context for the Chromium processes
-#if !defined(DISABLE_QML)
- // Chromium rendering uses some GL functions that prevent nSight from capturing
- // frames, so we only create the shared context if nsight is NOT active.
- if (!nsightActive()) {
- _chromiumShareContext = new OffscreenGLCanvas();
- _chromiumShareContext->setObjectName("ChromiumShareContext");
- _chromiumShareContext->create(_offscreenContext->getContext());
- if (!_chromiumShareContext->makeCurrent()) {
- qCWarning(interfaceapp, "Unable to make chromium shared context current");
- }
- qt_gl_set_global_share_context(_chromiumShareContext->getContext());
- _chromiumShareContext->doneCurrent();
- // Restore the GL widget context
- _offscreenContext->makeCurrent();
- } else {
- qCWarning(interfaceapp) << "nSIGHT detected, disabling chrome rendering";
- }
-#endif
-
- // Build a shared canvas / context for the QML rendering
- _qmlShareContext = new OffscreenGLCanvas();
- _qmlShareContext->setObjectName("QmlShareContext");
- _qmlShareContext->create(_offscreenContext->getContext());
- if (!_qmlShareContext->makeCurrent()) {
- qCWarning(interfaceapp, "Unable to make QML shared context current");
- }
- OffscreenQmlSurface::setSharedContext(_qmlShareContext->getContext());
- _qmlShareContext->doneCurrent();
- // Restore the GL widget context
- _offscreenContext->makeCurrent();
- // Make sure all QML surfaces share the main thread GL context
- OffscreenQmlSurface::setSharedContext(_offscreenContext->getContext());
-
AddressBarDialog::registerType();
ErrorDialog::registerType();
LoginDialog::registerType();
@@ -3011,9 +3017,11 @@ void Application::onDesktopRootItemCreated(QQuickItem* rootItem) {
auto surfaceContext = DependencyManager::get()->getSurfaceContext();
surfaceContext->setContextProperty("Stats", Stats::getInstance());
+#if !defined(Q_OS_ANDROID)
auto offscreenUi = DependencyManager::get();
auto qml = PathUtils::qmlUrl("AvatarInputsBar.qml");
offscreenUi->show(qml, "AvatarInputsBar");
+#endif
}
void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {
@@ -3642,7 +3650,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
_keysPressed.insert(event->key());
_controllerScriptingInterface->emitKeyPressEvent(event); // send events to any registered scripts
-
// if one of our scripts have asked to capture this event, then stop processing it
if (_controllerScriptingInterface->isKeyCaptured(event)) {
return;
@@ -3668,9 +3675,21 @@ void Application::keyPressEvent(QKeyEvent* event) {
}
break;
- case Qt::Key_1:
- case Qt::Key_2:
- case Qt::Key_3:
+ case Qt::Key_1: {
+ Menu* menu = Menu::getInstance();
+ menu->triggerOption(MenuOption::FirstPerson);
+ break;
+ }
+ case Qt::Key_2: {
+ Menu* menu = Menu::getInstance();
+ menu->triggerOption(MenuOption::FullscreenMirror);
+ break;
+ }
+ case Qt::Key_3: {
+ Menu* menu = Menu::getInstance();
+ menu->triggerOption(MenuOption::ThirdPerson);
+ break;
+ }
case Qt::Key_4:
case Qt::Key_5:
case Qt::Key_6:
@@ -3727,6 +3746,13 @@ void Application::keyPressEvent(QKeyEvent* event) {
}
break;
+ case Qt::Key_R:
+ if (isMeta && !event->isAutoRepeat()) {
+ DependencyManager::get()->reloadAllScripts();
+ DependencyManager::get()->clearCache();
+ }
+ break;
+
case Qt::Key_Asterisk:
Menu::getInstance()->triggerOption(MenuOption::DefaultSkybox);
break;
@@ -3792,68 +3818,6 @@ void Application::keyPressEvent(QKeyEvent* event) {
Menu::getInstance()->triggerOption(MenuOption::Chat);
break;
-#if 0
- case Qt::Key_I:
- if (isShifted) {
- _myCamera.setEyeOffsetOrientation(glm::normalize(
- glm::quat(glm::vec3(0.002f, 0, 0)) * _myCamera.getEyeOffsetOrientation()));
- } else {
- _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, 0.001, 0));
- }
- updateProjectionMatrix();
- break;
-
- case Qt::Key_K:
- if (isShifted) {
- _myCamera.setEyeOffsetOrientation(glm::normalize(
- glm::quat(glm::vec3(-0.002f, 0, 0)) * _myCamera.getEyeOffsetOrientation()));
- } else {
- _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, -0.001, 0));
- }
- updateProjectionMatrix();
- break;
-
- case Qt::Key_J:
- if (isShifted) {
- QMutexLocker viewLocker(&_viewMutex);
- _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() - 0.1f);
- } else {
- _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(-0.001, 0, 0));
- }
- updateProjectionMatrix();
- break;
-
- case Qt::Key_M:
- if (isShifted) {
- QMutexLocker viewLocker(&_viewMutex);
- _viewFrustum.setFocalLength(_viewFrustum.getFocalLength() + 0.1f);
- } else {
- _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0.001, 0, 0));
- }
- updateProjectionMatrix();
- break;
-
- case Qt::Key_U:
- if (isShifted) {
- _myCamera.setEyeOffsetOrientation(glm::normalize(
- glm::quat(glm::vec3(0, 0, -0.002f)) * _myCamera.getEyeOffsetOrientation()));
- } else {
- _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, 0, -0.001));
- }
- updateProjectionMatrix();
- break;
-
- case Qt::Key_Y:
- if (isShifted) {
- _myCamera.setEyeOffsetOrientation(glm::normalize(
- glm::quat(glm::vec3(0, 0, 0.002f)) * _myCamera.getEyeOffsetOrientation()));
- } else {
- _myCamera.setEyeOffsetPosition(_myCamera.getEyeOffsetPosition() + glm::vec3(0, 0, 0.001));
- }
- updateProjectionMatrix();
- break;
-#endif
-
case Qt::Key_Slash:
Menu::getInstance()->triggerOption(MenuOption::Stats);
break;
@@ -4236,7 +4200,7 @@ bool Application::acceptSnapshot(const QString& urlString) {
static uint32_t _renderedFrameIndex { INVALID_FRAME };
bool Application::shouldPaint() const {
- if (_aboutToQuit) {
+ if (_aboutToQuit || _window->isMinimized()) {
return false;
}
@@ -4632,12 +4596,6 @@ void Application::idle() {
_overlayConductor.update(secondsSinceLastUpdate);
- auto myAvatar = getMyAvatar();
- if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON || _myCamera.getMode() == CAMERA_MODE_THIRD_PERSON) {
- Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN);
- Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !(myAvatar->getBoomLength() <= MyAvatar::ZOOM_MIN));
- cameraMenuChanged();
- }
_gameLoopCounter.increment();
}
@@ -4802,12 +4760,15 @@ void Application::loadSettings() {
// DONT CHECK IN
//DependencyManager::get()->setAutomaticLODAdjust(false);
- Menu::getInstance()->loadSettings();
+ auto menu = Menu::getInstance();
+ menu->loadSettings();
+
+ // override the menu option show overlays to always be true on startup
+ menu->setIsOptionChecked(MenuOption::Overlays, true);
// If there is a preferred plugin, we probably messed it up with the menu settings, so fix it.
auto pluginManager = PluginManager::getInstance();
auto plugins = pluginManager->getPreferredDisplayPlugins();
- auto menu = Menu::getInstance();
if (plugins.size() > 0) {
for (auto plugin : plugins) {
if (auto action = menu->getActionForOption(plugin->getName())) {
@@ -5184,6 +5145,21 @@ void Application::cameraModeChanged() {
cameraMenuChanged();
}
+void Application::changeViewAsNeeded(float boomLength) {
+ // Switch between first and third person views as needed
+ // This is called when the boom length has changed
+ bool boomLengthGreaterThanMinimum = (boomLength > MyAvatar::ZOOM_MIN);
+
+ if (_myCamera.getMode() == CAMERA_MODE_FIRST_PERSON && boomLengthGreaterThanMinimum) {
+ Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, false);
+ Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, true);
+ cameraMenuChanged();
+ } else if (_myCamera.getMode() == CAMERA_MODE_THIRD_PERSON && !boomLengthGreaterThanMinimum) {
+ Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, true);
+ Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, false);
+ cameraMenuChanged();
+ }
+}
void Application::cameraMenuChanged() {
auto menu = Menu::getInstance();
@@ -5462,7 +5438,7 @@ void Application::update(float deltaTime) {
// process octree stats packets are sent in between full sends of a scene (this isn't currently true).
// We keep physics disabled until we've received a full scene and everything near the avatar in that
// scene is ready to compute its collision shape.
- if (nearbyEntitiesAreReadyForPhysics()) {
+ if (nearbyEntitiesAreReadyForPhysics() && getMyAvatar()->isReadyForPhysics()) {
_physicsEnabled = true;
getMyAvatar()->updateMotionBehaviorFromMenu();
}
@@ -5820,7 +5796,7 @@ void Application::update(float deltaTime) {
viewIsDifferentEnough = true;
}
-
+
// if it's been a while since our last query or the view has significantly changed then send a query, otherwise suppress it
static const std::chrono::seconds MIN_PERIOD_BETWEEN_QUERIES { 3 };
auto now = SteadyClock::now();
@@ -6188,7 +6164,9 @@ void Application::updateWindowTitle() const {
auto nodeList = DependencyManager::get();
auto accountManager = DependencyManager::get();
- QString buildVersion = " (build " + applicationVersion() + ")";
+ QString buildVersion = " - "
+ + (BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable ? QString("Version") : QString("Build"))
+ + " " + applicationVersion();
QString loginStatus = accountManager->isLoggedIn() ? "" : " (NOT LOGGED IN)";
@@ -7634,18 +7612,18 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa
});
}
-void Application::takeSecondaryCameraSnapshot(const QString& filename) {
- postLambdaEvent([filename, this] {
+void Application::takeSecondaryCameraSnapshot(const bool& notify, const QString& filename) {
+ postLambdaEvent([notify, filename, this] {
QString snapshotPath = DependencyManager::get()->saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename,
TestScriptingInterface::getInstance()->getTestResultsLocation());
- emit DependencyManager::get()->stillSnapshotTaken(snapshotPath, true);
+ emit DependencyManager::get()->stillSnapshotTaken(snapshotPath, notify);
});
}
-void Application::takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const QString& filename) {
- postLambdaEvent([filename, cubemapOutputFormat, cameraPosition] {
- DependencyManager::get()->save360Snapshot(cameraPosition, cubemapOutputFormat, filename);
+void Application::takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const bool& notify, const QString& filename) {
+ postLambdaEvent([notify, filename, cubemapOutputFormat, cameraPosition] {
+ DependencyManager::get()->save360Snapshot(cameraPosition, cubemapOutputFormat, notify, filename);
});
}
@@ -7749,7 +7727,7 @@ void Application::sendLambdaEvent(const std::function& f) {
} else {
LambdaEvent event(f);
QCoreApplication::sendEvent(this, &event);
- }
+ }
}
void Application::initPlugins(const QStringList& arguments) {
@@ -7972,7 +7950,7 @@ void Application::setDisplayPlugin(DisplayPluginPointer newDisplayPlugin) {
}
// FIXME don't have the application directly set the state of the UI,
- // instead emit a signal that the display plugin is changing and let
+ // instead emit a signal that the display plugin is changing and let
// the desktop lock itself. Reduces coupling between the UI and display
// plugins
auto offscreenUi = DependencyManager::get();
@@ -8081,7 +8059,6 @@ void Application::switchDisplayMode() {
setActiveDisplayPlugin(DESKTOP_DISPLAY_PLUGIN_NAME);
startHMDStandBySession();
}
- emit activeDisplayPluginChanged();
}
_previousHMDWornStatus = currentHMDWornStatus;
}
diff --git a/interface/src/Application.h b/interface/src/Application.h
index ee97077002..236edf8bb0 100644
--- a/interface/src/Application.h
+++ b/interface/src/Application.h
@@ -281,8 +281,11 @@ public:
float getGameLoopRate() const { return _gameLoopCounter.rate(); }
void takeSnapshot(bool notify, bool includeAnimated = false, float aspectRatio = 0.0f, const QString& filename = QString());
- void takeSecondaryCameraSnapshot(const QString& filename = QString());
- void takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const QString& filename = QString());
+ void takeSecondaryCameraSnapshot(const bool& notify, const QString& filename = QString());
+ void takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition,
+ const bool& cubemapOutputFormat,
+ const bool& notify,
+ const QString& filename = QString());
void shareSnapshot(const QString& filename, const QUrl& href = QUrl(""));
@@ -417,6 +420,8 @@ public slots:
void updateVerboseLogging();
+ void changeViewAsNeeded(float boomLength);
+
private slots:
void onDesktopRootItemCreated(QQuickItem* qmlContext);
void onDesktopRootContextCreated(QQmlContext* qmlContext);
@@ -649,7 +654,7 @@ private:
quint64 _lastFaceTrackerUpdate;
render::ScenePointer _main3DScene{ new render::Scene(glm::vec3(-0.5f * (float)TREE_SCALE), (float)TREE_SCALE) };
- render::EnginePointer _renderEngine{ new render::Engine() };
+ render::EnginePointer _renderEngine{ new render::RenderEngine() };
gpu::ContextPointer _gpuContext; // initialized during window creation
mutable QMutex _renderArgsMutex{ QMutex::Recursive };
diff --git a/interface/src/Application_render.cpp b/interface/src/Application_render.cpp
index 2a16e8c33c..2208b3187c 100644
--- a/interface/src/Application_render.cpp
+++ b/interface/src/Application_render.cpp
@@ -30,9 +30,6 @@ void Application::editRenderArgs(RenderArgsEditor editor) {
void Application::paintGL() {
// Some plugins process message events, allowing paintGL to be called reentrantly.
- if (_aboutToQuit || _window->isMinimized()) {
- return;
- }
_renderFrameCount++;
_lastTimeRendered.start();
diff --git a/interface/src/Crashpad.cpp b/interface/src/Crashpad.cpp
index 45f1d0778f..88651925d5 100644
--- a/interface/src/Crashpad.cpp
+++ b/interface/src/Crashpad.cpp
@@ -18,6 +18,7 @@
#if HAS_CRASHPAD
#include
+#include
#include
#include
@@ -69,6 +70,8 @@ bool startCrashHandler() {
annotations["token"] = BACKTRACE_TOKEN;
annotations["format"] = "minidump";
annotations["version"] = BuildInfo::VERSION.toStdString();
+ annotations["build_number"] = BuildInfo::BUILD_NUMBER.toStdString();
+ annotations["build_type"] = BuildInfo::BUILD_TYPE_STRING.toStdString();
arguments.push_back("--no-rate-limit");
diff --git a/interface/src/FancyCamera.h b/interface/src/FancyCamera.h
index bee21bad22..4ca073fb4f 100644
--- a/interface/src/FancyCamera.h
+++ b/interface/src/FancyCamera.h
@@ -25,7 +25,7 @@ class FancyCamera : public Camera {
// FIXME: JSDoc 3.5.5 doesn't augment @property definitions. The following definition is repeated in Camera.h.
/**jsdoc
- * @property cameraEntity {Uuid} The ID of the entity that the camera position and orientation follow when the camera is in
+ * @property {Uuid} cameraEntity The ID of the entity that the camera position and orientation follow when the camera is in
* entity mode.
*/
Q_PROPERTY(QUuid cameraEntity READ getCameraEntity WRITE setCameraEntity)
diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp
index f55c389a1f..d55490998d 100644
--- a/interface/src/Menu.cpp
+++ b/interface/src/Menu.cpp
@@ -103,16 +103,32 @@ Menu::Menu() {
editMenu->addSeparator();
// Edit > Cut
- addActionToQMenuAndActionHash(editMenu, "Cut", Qt::CTRL | Qt::Key_X);
+ auto cutAction = addActionToQMenuAndActionHash(editMenu, "Cut", QKeySequence::Cut);
+ connect(cutAction, &QAction::triggered, [] {
+ QKeyEvent* keyEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_X, Qt::ControlModifier);
+ QCoreApplication::postEvent(QCoreApplication::instance(), keyEvent);
+ });
// Edit > Copy
- addActionToQMenuAndActionHash(editMenu, "Copy", Qt::CTRL | Qt::Key_C);
+ auto copyAction = addActionToQMenuAndActionHash(editMenu, "Copy", QKeySequence::Copy);
+ connect(copyAction, &QAction::triggered, [] {
+ QKeyEvent* keyEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_C, Qt::ControlModifier);
+ QCoreApplication::postEvent(QCoreApplication::instance(), keyEvent);
+ });
// Edit > Paste
- addActionToQMenuAndActionHash(editMenu, "Paste", Qt::CTRL | Qt::Key_V);
+ auto pasteAction = addActionToQMenuAndActionHash(editMenu, "Paste", QKeySequence::Paste);
+ connect(pasteAction, &QAction::triggered, [] {
+ QKeyEvent* keyEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_V, Qt::ControlModifier);
+ QCoreApplication::postEvent(QCoreApplication::instance(), keyEvent);
+ });
// Edit > Delete
- addActionToQMenuAndActionHash(editMenu, "Delete", Qt::Key_Delete);
+ auto deleteAction = addActionToQMenuAndActionHash(editMenu, "Delete", QKeySequence::Delete);
+ connect(deleteAction, &QAction::triggered, [] {
+ QKeyEvent* keyEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_Delete, Qt::ControlModifier);
+ QCoreApplication::postEvent(QCoreApplication::instance(), keyEvent);
+ });
editMenu->addSeparator();
@@ -201,21 +217,21 @@ Menu::Menu() {
// View > First Person
auto firstPersonAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(
- viewMenu, MenuOption::FirstPerson, Qt::Key_1,
+ viewMenu, MenuOption::FirstPerson, 0,
true, qApp, SLOT(cameraMenuChanged())));
firstPersonAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
// View > Third Person
auto thirdPersonAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(
- viewMenu, MenuOption::ThirdPerson, Qt::Key_3,
+ viewMenu, MenuOption::ThirdPerson, 0,
false, qApp, SLOT(cameraMenuChanged())));
thirdPersonAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
// View > Mirror
auto viewMirrorAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(
- viewMenu, MenuOption::FullscreenMirror, Qt::Key_2,
+ viewMenu, MenuOption::FullscreenMirror, 0,
false, qApp, SLOT(cameraMenuChanged())));
viewMirrorAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup));
@@ -572,6 +588,10 @@ Menu::Menu() {
});
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::FixGaze, 0, false);
+ addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ToggleHipsFollowing, 0, false,
+ avatar.get(), SLOT(setToggleHips(bool)));
+ addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawBaseOfSupport, 0, false,
+ avatar.get(), SLOT(setEnableDebugDrawBaseOfSupport(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawDefaultPose, 0, false,
avatar.get(), SLOT(setEnableDebugDrawDefaultPose(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawAnimPose, 0, false,
diff --git a/interface/src/Menu.h b/interface/src/Menu.h
index 8569911cbd..6fb089acd8 100644
--- a/interface/src/Menu.h
+++ b/interface/src/Menu.h
@@ -30,6 +30,7 @@ namespace MenuOption {
const QString AddressBar = "Show Address Bar";
const QString Animations = "Animations...";
const QString AnimDebugDrawAnimPose = "Debug Draw Animation";
+ const QString AnimDebugDrawBaseOfSupport = "Debug Draw Base of Support";
const QString AnimDebugDrawDefaultPose = "Debug Draw Default Pose";
const QString AnimDebugDrawPosition= "Debug Draw Position";
const QString AskToResetSettings = "Ask To Reset Settings on Start";
@@ -202,6 +203,7 @@ namespace MenuOption {
const QString ThirdPerson = "Third Person";
const QString ThreePointCalibration = "3 Point Calibration";
const QString ThrottleFPSIfNotFocus = "Throttle FPS If Not Focus"; // FIXME - this value duplicated in Basic2DWindowOpenGLDisplayPlugin.cpp
+ const QString ToggleHipsFollowing = "Toggle Hips Following";
const QString ToolWindow = "Tool Window";
const QString TransmitterDrive = "Transmitter Drive";
const QString TurnWithHead = "Turn using Head";
diff --git a/interface/src/SecondaryCamera.cpp b/interface/src/SecondaryCamera.cpp
index db51cf99c8..b9a767f700 100644
--- a/interface/src/SecondaryCamera.cpp
+++ b/interface/src/SecondaryCamera.cpp
@@ -9,11 +9,13 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
-#include "Application.h"
#include "SecondaryCamera.h"
-#include
-#include
+
#include
+#include
+#include
+
+#include "Application.h"
using RenderArgsPointer = std::shared_ptr;
diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp
index 094b3bb67b..4d133706e6 100644
--- a/interface/src/avatar/AvatarManager.cpp
+++ b/interface/src/avatar/AvatarManager.cpp
@@ -104,6 +104,9 @@ void AvatarManager::updateMyAvatar(float deltaTime) {
PerformanceWarning warn(showWarnings, "AvatarManager::updateMyAvatar()");
_myAvatar->update(deltaTime);
+ render::Transaction transaction;
+ _myAvatar->updateRenderItem(transaction);
+ qApp->getMain3DScene()->enqueueTransaction(transaction);
quint64 now = usecTimestampNow();
quint64 dt = now - _lastSendAvatarDataTime;
@@ -465,13 +468,14 @@ void AvatarManager::updateAvatarRenderStatus(bool shouldRenderAvatars) {
_shouldRender = shouldRenderAvatars;
const render::ScenePointer& scene = qApp->getMain3DScene();
render::Transaction transaction;
+ auto avatarHashCopy = getHashCopy();
if (_shouldRender) {
- for (auto avatarData : _avatarHash) {
+ for (auto avatarData : avatarHashCopy) {
auto avatar = std::static_pointer_cast(avatarData);
avatar->addToScene(avatar, scene, transaction);
}
} else {
- for (auto avatarData : _avatarHash) {
+ for (auto avatarData : avatarHashCopy) {
auto avatar = std::static_pointer_cast(avatarData);
avatar->removeFromScene(avatar, scene, transaction);
}
@@ -511,7 +515,8 @@ RayToAvatarIntersectionResult AvatarManager::findRayIntersectionVector(const Pic
glm::vec3 normDirection = glm::normalize(ray.direction);
- for (auto avatarData : _avatarHash) {
+ auto avatarHashCopy = getHashCopy();
+ for (auto avatarData : avatarHashCopy) {
auto avatar = std::static_pointer_cast(avatarData);
if ((avatarsToInclude.size() > 0 && !avatarsToInclude.contains(avatar->getID())) ||
(avatarsToDiscard.size() > 0 && avatarsToDiscard.contains(avatar->getID()))) {
diff --git a/interface/src/avatar/AvatarMotionState.cpp b/interface/src/avatar/AvatarMotionState.cpp
index beb7e34439..4c5aaacb95 100644
--- a/interface/src/avatar/AvatarMotionState.cpp
+++ b/interface/src/avatar/AvatarMotionState.cpp
@@ -21,17 +21,6 @@ AvatarMotionState::AvatarMotionState(AvatarSharedPointer avatar, const btCollisi
_type = MOTIONSTATE_TYPE_AVATAR;
}
-void AvatarMotionState::handleEasyChanges(uint32_t& flags) {
- ObjectMotionState::handleEasyChanges(flags);
- if (flags & Simulation::DIRTY_PHYSICS_ACTIVATION && !_body->isActive()) {
- _body->activate();
- }
-}
-
-bool AvatarMotionState::handleHardAndEasyChanges(uint32_t& flags, PhysicsEngine* engine) {
- return ObjectMotionState::handleHardAndEasyChanges(flags, engine);
-}
-
AvatarMotionState::~AvatarMotionState() {
assert(_avatar);
_avatar = nullptr;
@@ -57,9 +46,6 @@ PhysicsMotionType AvatarMotionState::computePhysicsMotionType() const {
const btCollisionShape* AvatarMotionState::computeNewShape() {
ShapeInfo shapeInfo;
std::static_pointer_cast(_avatar)->computeShapeInfo(shapeInfo);
- glm::vec3 halfExtents = shapeInfo.getHalfExtents();
- halfExtents.y = 0.0f;
- _diameter = 2.0f * glm::length(halfExtents);
return getShapeManager()->getShape(shapeInfo);
}
@@ -74,31 +60,25 @@ void AvatarMotionState::getWorldTransform(btTransform& worldTrans) const {
worldTrans.setRotation(glmToBullet(getObjectRotation()));
if (_body) {
_body->setLinearVelocity(glmToBullet(getObjectLinearVelocity()));
- _body->setAngularVelocity(glmToBullet(getObjectAngularVelocity()));
+ _body->setAngularVelocity(glmToBullet(getObjectLinearVelocity()));
}
}
// virtual
void AvatarMotionState::setWorldTransform(const btTransform& worldTrans) {
+ // HACK: The PhysicsEngine does not actually move OTHER avatars -- instead it slaves their local RigidBody to the transform
+ // as specified by a remote simulation. However, to give the remote simulation time to respond to our own objects we tie
+ // the other avatar's body to its true position with a simple spring. This is a HACK that will have to be improved later.
const float SPRING_TIMESCALE = 0.5f;
float tau = PHYSICS_ENGINE_FIXED_SUBSTEP / SPRING_TIMESCALE;
btVector3 currentPosition = worldTrans.getOrigin();
- btVector3 offsetToTarget = glmToBullet(getObjectPosition()) - currentPosition;
- float distance = offsetToTarget.length();
- if ((1.0f - tau) * distance > _diameter) {
- // the avatar body is far from its target --> slam position
- btTransform newTransform;
- newTransform.setOrigin(currentPosition + offsetToTarget);
- newTransform.setRotation(glmToBullet(getObjectRotation()));
- _body->setWorldTransform(newTransform);
- _body->setLinearVelocity(glmToBullet(getObjectLinearVelocity()));
- _body->setAngularVelocity(glmToBullet(getObjectAngularVelocity()));
- } else {
- // the avatar body is near its target --> slam velocity
- btVector3 velocity = glmToBullet(getObjectLinearVelocity()) + (1.0f / SPRING_TIMESCALE) * offsetToTarget;
- _body->setLinearVelocity(velocity);
- _body->setAngularVelocity(glmToBullet(getObjectAngularVelocity()));
- }
+ btVector3 targetPosition = glmToBullet(getObjectPosition());
+ btTransform newTransform;
+ newTransform.setOrigin((1.0f - tau) * currentPosition + tau * targetPosition);
+ newTransform.setRotation(glmToBullet(getObjectRotation()));
+ _body->setWorldTransform(newTransform);
+ _body->setLinearVelocity(glmToBullet(getObjectLinearVelocity()));
+ _body->setAngularVelocity(glmToBullet(getObjectLinearVelocity()));
}
// These pure virtual methods must be implemented for each MotionState type
@@ -160,13 +140,8 @@ QUuid AvatarMotionState::getSimulatorID() const {
}
// virtual
-void AvatarMotionState::computeCollisionGroupAndMask(int16_t& group, int16_t& mask) const {
+void AvatarMotionState::computeCollisionGroupAndMask(int32_t& group, int32_t& mask) const {
group = BULLET_COLLISION_GROUP_OTHER_AVATAR;
mask = Physics::getDefaultCollisionMask(group);
}
-// virtual
-float AvatarMotionState::getMass() const {
- return std::static_pointer_cast(_avatar)->computeMass();
-}
-
diff --git a/interface/src/avatar/AvatarMotionState.h b/interface/src/avatar/AvatarMotionState.h
index 73fb853312..07e8102752 100644
--- a/interface/src/avatar/AvatarMotionState.h
+++ b/interface/src/avatar/AvatarMotionState.h
@@ -23,9 +23,6 @@ class AvatarMotionState : public ObjectMotionState {
public:
AvatarMotionState(AvatarSharedPointer avatar, const btCollisionShape* shape);
- virtual void handleEasyChanges(uint32_t& flags) override;
- virtual bool handleHardAndEasyChanges(uint32_t& flags, PhysicsEngine* engine) override;
-
virtual PhysicsMotionType getMotionType() const override { return _motionType; }
virtual uint32_t getIncomingDirtyFlags() override;
@@ -65,9 +62,7 @@ public:
void addDirtyFlags(uint32_t flags) { _dirtyFlags |= flags; }
- virtual void computeCollisionGroupAndMask(int16_t& group, int16_t& mask) const override;
-
- virtual float getMass() const override;
+ virtual void computeCollisionGroupAndMask(int32_t& group, int32_t& mask) const override;
friend class AvatarManager;
friend class Avatar;
@@ -81,7 +76,6 @@ protected:
virtual const btCollisionShape* computeNewShape() override;
AvatarSharedPointer _avatar;
- float _diameter { 0.0f };
uint32_t _dirtyFlags;
};
diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp
index 5fb4e80b80..d57905ee33 100755
--- a/interface/src/avatar/MyAvatar.cpp
+++ b/interface/src/avatar/MyAvatar.cpp
@@ -52,6 +52,7 @@
#include "MyHead.h"
#include "MySkeletonModel.h"
+#include "AnimUtil.h"
#include "Application.h"
#include "AvatarManager.h"
#include "AvatarActionHold.h"
@@ -422,12 +423,12 @@ void MyAvatar::update(float deltaTime) {
}
#ifdef DEBUG_DRAW_HMD_MOVING_AVERAGE
- glm::vec3 p = transformPoint(getSensorToWorldMatrix(), getControllerPoseInAvatarFrame(controller::Pose::HEAD) *
- glm::vec3(_headControllerFacingMovingAverage.x, 0.0f, _headControllerFacingMovingAverage.y));
- DebugDraw::getInstance().addMarker("facing-avg", getOrientation(), p, glm::vec4(1.0f));
- p = transformPoint(getSensorToWorldMatrix(), getHMDSensorPosition() +
- glm::vec3(_headControllerFacing.x, 0.0f, _headControllerFacing.y));
- DebugDraw::getInstance().addMarker("facing", getOrientation(), p, glm::vec4(1.0f));
+ auto sensorHeadPose = getControllerPoseInSensorFrame(controller::Action::HEAD);
+ glm::vec3 worldHeadPos = transformPoint(getSensorToWorldMatrix(), sensorHeadPose.getTranslation());
+ glm::vec3 worldFacingAverage = transformVectorFast(getSensorToWorldMatrix(), glm::vec3(_headControllerFacingMovingAverage.x, 0.0f, _headControllerFacingMovingAverage.y));
+ glm::vec3 worldFacing = transformVectorFast(getSensorToWorldMatrix(), glm::vec3(_headControllerFacing.x, 0.0f, _headControllerFacing.y));
+ DebugDraw::getInstance().drawRay(worldHeadPos, worldHeadPos + worldFacing, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f));
+ DebugDraw::getInstance().drawRay(worldHeadPos, worldHeadPos + worldFacingAverage, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f));
#endif
if (_goToPending) {
@@ -654,8 +655,8 @@ void MyAvatar::simulate(float deltaTime) {
if (success) {
moveOperator.addEntityToMoveList(entity, newCube);
}
- // send an edit packet to update the entity-server about the queryAABox. If it's an
- // avatar-entity, don't.
+ // send an edit packet to update the entity-server about the queryAABox
+ // unless it is client-only
if (packetSender && !entity->getClientOnly()) {
EntityItemProperties properties = entity->getProperties();
properties.setQueryAACubeDirty();
@@ -663,6 +664,17 @@ void MyAvatar::simulate(float deltaTime) {
packetSender->queueEditEntityMessage(PacketType::EntityEdit, entityTree, entity->getID(), properties);
entity->setLastBroadcast(usecTimestampNow());
+
+ entity->forEachDescendant([&](SpatiallyNestablePointer descendant) {
+ EntityItemPointer entityDescendant = std::static_pointer_cast(descendant);
+ if (!entityDescendant->getClientOnly() && descendant->updateQueryAACube()) {
+ EntityItemProperties descendantProperties;
+ descendantProperties.setQueryAACube(descendant->getQueryAACube());
+ descendantProperties.setLastEdited(now);
+ packetSender->queueEditEntityMessage(PacketType::EntityEdit, entityTree, entityDescendant->getID(), descendantProperties);
+ entityDescendant->setLastBroadcast(now); // for debug/physics status icons
+ }
+ });
}
}
});
@@ -701,7 +713,8 @@ void MyAvatar::updateFromHMDSensorMatrix(const glm::mat4& hmdSensorMatrix) {
_hmdSensorOrientation = glmExtractRotation(hmdSensorMatrix);
auto headPose = getControllerPoseInSensorFrame(controller::Action::HEAD);
if (headPose.isValid()) {
- _headControllerFacing = getFacingDir2D(headPose.rotation);
+ glm::quat bodyOrientation = computeBodyFacingFromHead(headPose.rotation, Vectors::UNIT_Y);
+ _headControllerFacing = getFacingDir2D(bodyOrientation);
} else {
_headControllerFacing = glm::vec2(1.0f, 0.0f);
}
@@ -1068,6 +1081,22 @@ float loadSetting(Settings& settings, const QString& name, float defaultValue) {
return value;
}
+void MyAvatar::setToggleHips(bool followHead) {
+ _follow.setToggleHipsFollowing(followHead);
+}
+
+void MyAvatar::FollowHelper::setToggleHipsFollowing(bool followHead) {
+ _toggleHipsFollowing = followHead;
+}
+
+bool MyAvatar::FollowHelper::getToggleHipsFollowing() const {
+ return _toggleHipsFollowing;
+}
+
+void MyAvatar::setEnableDebugDrawBaseOfSupport(bool isEnabled) {
+ _enableDebugDrawBaseOfSupport = isEnabled;
+}
+
void MyAvatar::setEnableDebugDrawDefaultPose(bool isEnabled) {
_enableDebugDrawDefaultPose = isEnabled;
@@ -1127,7 +1156,11 @@ void MyAvatar::setEnableDebugDrawIKChains(bool isEnabled) {
}
void MyAvatar::setEnableMeshVisible(bool isEnabled) {
- _skeletonModel->setVisibleInScene(isEnabled, qApp->getMain3DScene(), render::ItemKey::TAG_BITS_NONE, true);
+ return Avatar::setEnableMeshVisible(isEnabled);
+}
+
+bool MyAvatar::getEnableMeshVisible() const {
+ return Avatar::getEnableMeshVisible();
}
void MyAvatar::setEnableInverseKinematics(bool isEnabled) {
@@ -1195,6 +1228,8 @@ void MyAvatar::loadData() {
settings.endGroup();
setEnableMeshVisible(Menu::getInstance()->isOptionChecked(MenuOption::MeshVisible));
+ _follow.setToggleHipsFollowing (Menu::getInstance()->isOptionChecked(MenuOption::ToggleHipsFollowing));
+ setEnableDebugDrawBaseOfSupport(Menu::getInstance()->isOptionChecked(MenuOption::AnimDebugDrawBaseOfSupport));
setEnableDebugDrawDefaultPose(Menu::getInstance()->isOptionChecked(MenuOption::AnimDebugDrawDefaultPose));
setEnableDebugDrawAnimPose(Menu::getInstance()->isOptionChecked(MenuOption::AnimDebugDrawAnimPose));
setEnableDebugDrawPosition(Menu::getInstance()->isOptionChecked(MenuOption::AnimDebugDrawPosition));
@@ -1479,7 +1514,10 @@ void MyAvatar::setSkeletonModelURL(const QUrl& skeletonModelURL) {
_skeletonModelChangeCount++;
int skeletonModelChangeCount = _skeletonModelChangeCount;
Avatar::setSkeletonModelURL(skeletonModelURL);
- _skeletonModel->setVisibleInScene(true, qApp->getMain3DScene(), render::ItemKey::TAG_BITS_NONE, true);
+ _skeletonModel->setTagMask(render::hifi::TAG_NONE);
+ _skeletonModel->setGroupCulled(true);
+ _skeletonModel->setVisibleInScene(true, qApp->getMain3DScene());
+
_headBoneSet.clear();
_cauterizationNeedsUpdate = true;
@@ -2054,14 +2092,12 @@ void MyAvatar::preDisplaySide(const RenderArgs* renderArgs) {
_attachmentData[i].jointName.compare("RightEye", Qt::CaseInsensitive) == 0 ||
_attachmentData[i].jointName.compare("HeadTop_End", Qt::CaseInsensitive) == 0 ||
_attachmentData[i].jointName.compare("Face", Qt::CaseInsensitive) == 0) {
- uint8_t modelRenderTagBits = shouldDrawHead ? render::ItemKey::TAG_BITS_0 : render::ItemKey::TAG_BITS_NONE;
- modelRenderTagBits |= render::ItemKey::TAG_BITS_1;
- _attachmentModels[i]->setVisibleInScene(true, qApp->getMain3DScene(),
- modelRenderTagBits, false);
+ uint8_t modelRenderTagBits = shouldDrawHead ? render::hifi::TAG_ALL_VIEWS : render::hifi::TAG_SECONDARY_VIEW;
- uint8_t castShadowRenderTagBits = render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1;
- _attachmentModels[i]->setCanCastShadow(true, qApp->getMain3DScene(),
- castShadowRenderTagBits, false);
+ _attachmentModels[i]->setTagMask(modelRenderTagBits);
+ _attachmentModels[i]->setGroupCulled(false);
+ _attachmentModels[i]->setCanCastShadow(true);
+ _attachmentModels[i]->setVisibleInScene(true, qApp->getMain3DScene());
}
}
}
@@ -2081,6 +2117,31 @@ bool MyAvatar::shouldRenderHead(const RenderArgs* renderArgs) const {
return !defaultMode || !firstPerson || !insideHead;
}
+void MyAvatar::setHasScriptedBlendshapes(bool hasScriptedBlendshapes) {
+ if (hasScriptedBlendshapes == _hasScriptedBlendShapes) {
+ return;
+ }
+ if (!hasScriptedBlendshapes) {
+ // send a forced avatarData update to make sure the script can send neutal blendshapes on unload
+ // without having to wait for the update loop, make sure _hasScriptedBlendShapes is still true
+ // before sending the update, or else it won't send the neutal blendshapes to the receiving clients
+ sendAvatarDataPacket(true);
+ }
+ _hasScriptedBlendShapes = hasScriptedBlendshapes;
+}
+
+void MyAvatar::setHasProceduralBlinkFaceMovement(bool hasProceduralBlinkFaceMovement) {
+ _headData->setHasProceduralBlinkFaceMovement(hasProceduralBlinkFaceMovement);
+}
+
+void MyAvatar::setHasProceduralEyeFaceMovement(bool hasProceduralEyeFaceMovement) {
+ _headData->setHasProceduralEyeFaceMovement(hasProceduralEyeFaceMovement);
+}
+
+void MyAvatar::setHasAudioEnabledFaceMovement(bool hasAudioEnabledFaceMovement) {
+ _headData->setHasAudioEnabledFaceMovement(hasAudioEnabledFaceMovement);
+}
+
void MyAvatar::updateOrientation(float deltaTime) {
// Smoothly rotate body with arrow keys
@@ -2245,9 +2306,15 @@ void MyAvatar::updateActionMotor(float deltaTime) {
_actionMotorVelocity = getSensorToWorldScale() * (_walkSpeed.get() * _walkSpeedScalar) * direction;
}
+ float previousBoomLength = _boomLength;
float boomChange = getDriveKey(ZOOM);
_boomLength += 2.0f * _boomLength * boomChange + boomChange * boomChange;
_boomLength = glm::clamp(_boomLength, ZOOM_MIN, ZOOM_MAX);
+
+ // May need to change view if boom length has changed
+ if (previousBoomLength != _boomLength) {
+ qApp->changeViewAsNeeded(_boomLength);
+ }
}
void MyAvatar::updatePosition(float deltaTime) {
@@ -2388,11 +2455,16 @@ void MyAvatar::restrictScaleFromDomainSettings(const QJsonObject& domainSettings
if (_domainMinimumHeight > _domainMaximumHeight) {
std::swap(_domainMinimumHeight, _domainMaximumHeight);
}
+
// Set avatar current scale
Settings settings;
settings.beginGroup("Avatar");
_targetScale = loadSetting(settings, "scale", 1.0f);
+ // clamp the desired _targetScale by the domain limits NOW, don't try to gracefully animate. Because
+ // this might cause our avatar to become embedded in the terrain.
+ _targetScale = getDomainLimitedScale();
+
qCDebug(interfaceapp) << "This domain requires a minimum avatar scale of " << _domainMinimumHeight
<< " and a maximum avatar scale of " << _domainMaximumHeight;
@@ -2401,6 +2473,8 @@ void MyAvatar::restrictScaleFromDomainSettings(const QJsonObject& domainSettings
setModelScale(_targetScale);
rebuildCollisionShape();
settings.endGroup();
+
+ _haveReceivedHeightLimitsFromDomain = true;
}
void MyAvatar::leaveDomain() {
@@ -2418,6 +2492,7 @@ void MyAvatar::saveAvatarScale() {
void MyAvatar::clearScaleRestriction() {
_domainMinimumHeight = MIN_AVATAR_HEIGHT;
_domainMaximumHeight = MAX_AVATAR_HEIGHT;
+ _haveReceivedHeightLimitsFromDomain = false;
}
void MyAvatar::goToLocation(const QVariant& propertiesVar) {
@@ -2535,8 +2610,12 @@ bool MyAvatar::safeLanding(const glm::vec3& position) {
// If position is not reliably safe from being stuck by physics, answer true and place a candidate better position in betterPositionOut.
bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& betterPositionOut) {
+
// We begin with utilities and tests. The Algorithm in four parts is below.
- auto halfHeight = _characterController.getCapsuleHalfHeight() + _characterController.getCapsuleRadius();
+ // NOTE: we use estimated avatar height here instead of the bullet capsule halfHeight, because
+ // the domain avatar height limiting might not have taken effect yet on the actual bullet shape.
+ auto halfHeight = 0.5f * getHeight();
+
if (halfHeight == 0) {
return false; // zero height avatar
}
@@ -2545,14 +2624,13 @@ bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& bette
return false; // no entity tree
}
// More utilities.
- const auto offset = getWorldOrientation() *_characterController.getCapsuleLocalOffset();
- const auto capsuleCenter = positionIn + offset;
+ const auto capsuleCenter = positionIn;
const auto up = _worldUpDirection, down = -up;
glm::vec3 upperIntersection, upperNormal, lowerIntersection, lowerNormal;
EntityItemID upperId, lowerId;
QVector include{}, ignore{};
auto mustMove = [&] { // Place bottom of capsule at the upperIntersection, and check again based on the capsule center.
- betterPositionOut = upperIntersection + (up * halfHeight) - offset;
+ betterPositionOut = upperIntersection + (up * halfHeight);
return true;
};
auto findIntersection = [&](const glm::vec3& startPointIn, const glm::vec3& directionIn, glm::vec3& intersectionOut, EntityItemID& entityIdOut, glm::vec3& normalOut) {
@@ -2572,7 +2650,7 @@ bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& bette
EntityItemID entityID = entityTree->findRayIntersection(startPointIn, directionIn, include, ignore, visibleOnly, collidableOnly, precisionPicking,
element, distance, face, normalOut, extraInfo, lockType, accurateResult);
if (entityID.isNull()) {
- return false;
+ return false;
}
intersectionOut = startPointIn + (directionIn * distance);
entityIdOut = entityID;
@@ -2598,7 +2676,7 @@ bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& bette
// I.e., we are in a clearing between two objects.
if (isDown(upperNormal) && isUp(lowerNormal)) {
auto spaceBetween = glm::distance(upperIntersection, lowerIntersection);
- const float halfHeightFactor = 2.5f; // Until case 5003 is fixed (and maybe after?), we need a fudge factor. Also account for content modelers not being precise.
+ const float halfHeightFactor = 2.25f; // Until case 5003 is fixed (and maybe after?), we need a fudge factor. Also account for content modelers not being precise.
if (spaceBetween > (halfHeightFactor * halfHeight)) {
// There is room for us to fit in that clearing. If there wasn't, physics would oscilate us between the objects above and below.
// We're now going to iterate upwards through successive upperIntersections, testing to see if we're contained within the top surface of some entity.
@@ -2797,6 +2875,7 @@ glm::mat4 MyAvatar::deriveBodyFromHMDSensor() const {
auto headPose = getControllerPoseInSensorFrame(controller::Action::HEAD);
if (headPose.isValid()) {
headPosition = headPose.translation;
+ // AJT: TODO: can remove this Y_180
headOrientation = headPose.rotation * Quaternions::Y_180;
}
const glm::quat headOrientationYawOnly = cancelOutRollAndPitch(headOrientation);
@@ -2819,6 +2898,8 @@ glm::mat4 MyAvatar::deriveBodyFromHMDSensor() const {
// eyeToNeck offset is relative full HMD orientation.
// while neckToRoot offset is only relative to HMDs yaw.
// Y_180 is necessary because rig is z forward and hmdOrientation is -z forward
+
+ // AJT: TODO: can remove this Y_180, if we remove the higher level one.
glm::vec3 headToNeck = headOrientation * Quaternions::Y_180 * (localNeck - localHead);
glm::vec3 neckToRoot = headOrientationYawOnly * Quaternions::Y_180 * -localNeck;
@@ -2828,6 +2909,202 @@ glm::mat4 MyAvatar::deriveBodyFromHMDSensor() const {
return createMatFromQuatAndPos(headOrientationYawOnly, bodyPos);
}
+// ease in function for dampening cg movement
+static float slope(float num) {
+ const float CURVE_CONSTANT = 1.0f;
+ float ret = 1.0f;
+ if (num > 0.0f) {
+ ret = 1.0f - (1.0f / (1.0f + CURVE_CONSTANT * num));
+ }
+ return ret;
+}
+
+// This function gives a soft clamp at the edge of the base of support
+// dampenCgMovement returns the damped cg value in Avatar space.
+// cgUnderHeadHandsAvatarSpace is also in Avatar space
+// baseOfSupportScale is based on the height of the user
+static glm::vec3 dampenCgMovement(glm::vec3 cgUnderHeadHandsAvatarSpace, float baseOfSupportScale) {
+ float distanceFromCenterZ = cgUnderHeadHandsAvatarSpace.z;
+ float distanceFromCenterX = cgUnderHeadHandsAvatarSpace.x;
+
+ // In the forward direction we need a different scale because forward is in
+ // the direction of the hip extensor joint, which means bending usually happens
+ // well before reaching the edge of the base of support.
+ const float clampFront = DEFAULT_AVATAR_SUPPORT_BASE_FRONT * DEFAULT_AVATAR_FORWARD_DAMPENING_FACTOR * baseOfSupportScale;
+ float clampBack = DEFAULT_AVATAR_SUPPORT_BASE_BACK * DEFAULT_AVATAR_LATERAL_DAMPENING_FACTOR * baseOfSupportScale;
+ float clampLeft = DEFAULT_AVATAR_SUPPORT_BASE_LEFT * DEFAULT_AVATAR_LATERAL_DAMPENING_FACTOR * baseOfSupportScale;
+ float clampRight = DEFAULT_AVATAR_SUPPORT_BASE_RIGHT * DEFAULT_AVATAR_LATERAL_DAMPENING_FACTOR * baseOfSupportScale;
+ glm::vec3 dampedCg(0.0f, 0.0f, 0.0f);
+
+ // find the damped z coord of the cg
+ if (cgUnderHeadHandsAvatarSpace.z < 0.0f) {
+ // forward displacement
+ dampedCg.z = slope(fabs(distanceFromCenterZ / clampFront)) * clampFront;
+ } else {
+ // backwards displacement
+ dampedCg.z = slope(fabs(distanceFromCenterZ / clampBack)) * clampBack;
+ }
+
+ // find the damped x coord of the cg
+ if (cgUnderHeadHandsAvatarSpace.x > 0.0f) {
+ // right of center
+ dampedCg.x = slope(fabs(distanceFromCenterX / clampRight)) * clampRight;
+ } else {
+ // left of center
+ dampedCg.x = slope(fabs(distanceFromCenterX / clampLeft)) * clampLeft;
+ }
+ return dampedCg;
+}
+
+// computeCounterBalance returns the center of gravity in Avatar space
+glm::vec3 MyAvatar::computeCounterBalance() const {
+ struct JointMass {
+ QString name;
+ float weight;
+ glm::vec3 position;
+ JointMass() {};
+ JointMass(QString n, float w, glm::vec3 p) {
+ name = n;
+ weight = w;
+ position = p;
+ }
+ };
+
+ // init the body part weights
+ JointMass cgHeadMass(QString("Head"), DEFAULT_AVATAR_HEAD_MASS, glm::vec3(0.0f, 0.0f, 0.0f));
+ JointMass cgLeftHandMass(QString("LeftHand"), DEFAULT_AVATAR_LEFTHAND_MASS, glm::vec3(0.0f, 0.0f, 0.0f));
+ JointMass cgRightHandMass(QString("RightHand"), DEFAULT_AVATAR_RIGHTHAND_MASS, glm::vec3(0.0f, 0.0f, 0.0f));
+ glm::vec3 tposeHead = DEFAULT_AVATAR_HEAD_POS;
+ glm::vec3 tposeHips = glm::vec3(0.0f, 0.0f, 0.0f);
+
+ if (_skeletonModel->getRig().indexOfJoint(cgHeadMass.name) != -1) {
+ cgHeadMass.position = getAbsoluteJointTranslationInObjectFrame(_skeletonModel->getRig().indexOfJoint(cgHeadMass.name));
+ tposeHead = getAbsoluteDefaultJointTranslationInObjectFrame(_skeletonModel->getRig().indexOfJoint(cgHeadMass.name));
+ }
+ if (_skeletonModel->getRig().indexOfJoint(cgLeftHandMass.name) != -1) {
+ cgLeftHandMass.position = getAbsoluteJointTranslationInObjectFrame(_skeletonModel->getRig().indexOfJoint(cgLeftHandMass.name));
+ } else {
+ cgLeftHandMass.position = DEFAULT_AVATAR_LEFTHAND_POS;
+ }
+ if (_skeletonModel->getRig().indexOfJoint(cgRightHandMass.name) != -1) {
+ cgRightHandMass.position = getAbsoluteJointTranslationInObjectFrame(_skeletonModel->getRig().indexOfJoint(cgRightHandMass.name));
+ } else {
+ cgRightHandMass.position = DEFAULT_AVATAR_RIGHTHAND_POS;
+ }
+ if (_skeletonModel->getRig().indexOfJoint("Hips") != -1) {
+ tposeHips = getAbsoluteDefaultJointTranslationInObjectFrame(_skeletonModel->getRig().indexOfJoint("Hips"));
+ }
+
+ // find the current center of gravity position based on head and hand moments
+ glm::vec3 sumOfMoments = (cgHeadMass.weight * cgHeadMass.position) + (cgLeftHandMass.weight * cgLeftHandMass.position) + (cgRightHandMass.weight * cgRightHandMass.position);
+ float totalMass = cgHeadMass.weight + cgLeftHandMass.weight + cgRightHandMass.weight;
+
+ glm::vec3 currentCg = (1.0f / totalMass) * sumOfMoments;
+ currentCg.y = 0.0f;
+ // dampening the center of gravity, in effect, limits the value to the perimeter of the base of support
+ float baseScale = 1.0f;
+ if (getUserEyeHeight() > 0.0f) {
+ baseScale = getUserEyeHeight() / DEFAULT_AVATAR_EYE_HEIGHT;
+ }
+ glm::vec3 desiredCg = dampenCgMovement(currentCg, baseScale);
+
+ // compute hips position to maintain desiredCg
+ glm::vec3 counterBalancedForHead = (totalMass + DEFAULT_AVATAR_HIPS_MASS) * desiredCg;
+ counterBalancedForHead -= sumOfMoments;
+ glm::vec3 counterBalancedCg = (1.0f / DEFAULT_AVATAR_HIPS_MASS) * counterBalancedForHead;
+
+ // find the height of the hips
+ glm::vec3 xzDiff((cgHeadMass.position.x - counterBalancedCg.x), 0.0f, (cgHeadMass.position.z - counterBalancedCg.z));
+ float headMinusHipXz = glm::length(xzDiff);
+ float headHipDefault = glm::length(tposeHead - tposeHips);
+ float hipHeight = 0.0f;
+ if (headHipDefault > headMinusHipXz) {
+ hipHeight = sqrtf((headHipDefault * headHipDefault) - (headMinusHipXz * headMinusHipXz));
+ }
+ counterBalancedCg.y = (cgHeadMass.position.y - hipHeight);
+
+ // this is to be sure that the feet don't lift off the floor.
+ // add 5 centimeters to allow for going up on the toes.
+ if (counterBalancedCg.y > (tposeHips.y + 0.05f)) {
+ // if the height is higher than default hips, clamp to default hips
+ counterBalancedCg.y = tposeHips.y + 0.05f;
+ }
+ return counterBalancedCg;
+}
+
+// this function matches the hips rotation to the new cghips-head axis
+// headOrientation, headPosition and hipsPosition are in avatar space
+// returns the matrix of the hips in Avatar space
+static glm::mat4 computeNewHipsMatrix(glm::quat headOrientation, glm::vec3 headPosition, glm::vec3 hipsPosition) {
+
+ glm::quat bodyOrientation = computeBodyFacingFromHead(headOrientation, Vectors::UNIT_Y);
+
+ const float MIX_RATIO = 0.3f;
+ glm::quat hipsRot = safeLerp(Quaternions::IDENTITY, bodyOrientation, MIX_RATIO);
+ glm::vec3 hipsFacing = hipsRot * Vectors::UNIT_Z;
+
+ glm::vec3 spineVec = headPosition - hipsPosition;
+ glm::vec3 u, v, w;
+ generateBasisVectors(glm::normalize(spineVec), hipsFacing, u, v, w);
+ return glm::mat4(glm::vec4(w, 0.0f),
+ glm::vec4(u, 0.0f),
+ glm::vec4(v, 0.0f),
+ glm::vec4(hipsPosition, 1.0f));
+}
+
+static void drawBaseOfSupport(float baseOfSupportScale, float footLocal, glm::mat4 avatarToWorld) {
+ // scale the base of support based on user height
+ float clampFront = DEFAULT_AVATAR_SUPPORT_BASE_FRONT * baseOfSupportScale;
+ float clampBack = DEFAULT_AVATAR_SUPPORT_BASE_BACK * baseOfSupportScale;
+ float clampLeft = DEFAULT_AVATAR_SUPPORT_BASE_LEFT * baseOfSupportScale;
+ float clampRight = DEFAULT_AVATAR_SUPPORT_BASE_RIGHT * baseOfSupportScale;
+ float floor = footLocal + 0.05f;
+
+ // transform the base of support corners to world space
+ glm::vec3 frontRight = transformPoint(avatarToWorld, { clampRight, floor, clampFront });
+ glm::vec3 frontLeft = transformPoint(avatarToWorld, { clampLeft, floor, clampFront });
+ glm::vec3 backRight = transformPoint(avatarToWorld, { clampRight, floor, clampBack });
+ glm::vec3 backLeft = transformPoint(avatarToWorld, { clampLeft, floor, clampBack });
+
+ // draw the borders
+ const glm::vec4 rayColor = { 1.0f, 0.0f, 0.0f, 1.0f };
+ DebugDraw::getInstance().drawRay(backLeft, frontLeft, rayColor);
+ DebugDraw::getInstance().drawRay(backLeft, backRight, rayColor);
+ DebugDraw::getInstance().drawRay(backRight, frontRight, rayColor);
+ DebugDraw::getInstance().drawRay(frontLeft, frontRight, rayColor);
+}
+
+// this function finds the hips position using a center of gravity model that
+// balances the head and hands with the hips over the base of support
+// returns the rotation (-z forward) and position of the Avatar in Sensor space
+glm::mat4 MyAvatar::deriveBodyUsingCgModel() const {
+ glm::mat4 sensorToWorldMat = getSensorToWorldMatrix();
+ glm::mat4 worldToSensorMat = glm::inverse(sensorToWorldMat);
+ auto headPose = getControllerPoseInSensorFrame(controller::Action::HEAD);
+
+ glm::mat4 sensorHeadMat = createMatFromQuatAndPos(headPose.rotation * Quaternions::Y_180, headPose.translation);
+
+ // convert into avatar space
+ glm::mat4 avatarToWorldMat = getTransform().getMatrix();
+ glm::mat4 avatarHeadMat = glm::inverse(avatarToWorldMat) * sensorToWorldMat * sensorHeadMat;
+
+ if (_enableDebugDrawBaseOfSupport) {
+ float scaleBaseOfSupport = getUserEyeHeight() / DEFAULT_AVATAR_EYE_HEIGHT;
+ glm::vec3 rightFootPositionLocal = getAbsoluteJointTranslationInObjectFrame(_skeletonModel->getRig().indexOfJoint("RightFoot"));
+ drawBaseOfSupport(scaleBaseOfSupport, rightFootPositionLocal.y, avatarToWorldMat);
+ }
+
+ // get the new center of gravity
+ const glm::vec3 cgHipsPosition = computeCounterBalance();
+
+ // find the new hips rotation using the new head-hips axis as the up axis
+ glm::mat4 avatarHipsMat = computeNewHipsMatrix(glmExtractRotation(avatarHeadMat), extractTranslation(avatarHeadMat), cgHipsPosition);
+
+ // convert hips from avatar to sensor space
+ // The Y_180 is to convert from z forward to -z forward.
+ return worldToSensorMat * avatarToWorldMat * avatarHipsMat;
+}
+
float MyAvatar::getUserHeight() const {
return _userHeight.get();
}
@@ -2849,6 +3126,10 @@ float MyAvatar::getWalkSpeed() const {
return _walkSpeed.get() * _walkSpeedScalar;
}
+bool MyAvatar::isReadyForPhysics() const {
+ return qApp->isServerlessMode() || _haveReceivedHeightLimitsFromDomain;
+}
+
void MyAvatar::setSprintMode(bool sprint) {
_walkSpeedScalar = sprint ? AVATAR_SPRINT_SPEED_SCALAR : AVATAR_WALK_SPEED_SCALAR;
}
@@ -2992,9 +3273,7 @@ void MyAvatar::FollowHelper::decrementTimeRemaining(float dt) {
bool MyAvatar::FollowHelper::shouldActivateRotation(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const {
const float FOLLOW_ROTATION_THRESHOLD = cosf(PI / 6.0f); // 30 degrees
glm::vec2 bodyFacing = getFacingDir2D(currentBodyMatrix);
-
return glm::dot(-myAvatar.getHeadControllerFacingMovingAverage(), bodyFacing) < FOLLOW_ROTATION_THRESHOLD;
-
}
bool MyAvatar::FollowHelper::shouldActivateHorizontal(const MyAvatar& myAvatar, const glm::mat4& desiredBodyMatrix, const glm::mat4& currentBodyMatrix) const {
@@ -3065,11 +3344,19 @@ void MyAvatar::FollowHelper::prePhysicsUpdate(MyAvatar& myAvatar, const glm::mat
AnimPose followWorldPose(currentWorldMatrix);
+ glm::quat currentHipsLocal = myAvatar.getAbsoluteJointRotationInObjectFrame(myAvatar.getJointIndex("Hips"));
+ const glm::quat hipsinWorldSpace = followWorldPose.rot() * (Quaternions::Y_180 * (currentHipsLocal));
+ const glm::vec3 avatarUpWorld = glm::normalize(followWorldPose.rot()*(Vectors::UP));
+ glm::quat resultingSwingInWorld;
+ glm::quat resultingTwistInWorld;
+ swingTwistDecomposition(hipsinWorldSpace, avatarUpWorld, resultingSwingInWorld, resultingTwistInWorld);
+
// remove scale present from sensorToWorldMatrix
followWorldPose.scale() = glm::vec3(1.0f);
if (isActive(Rotation)) {
- followWorldPose.rot() = glmExtractRotation(desiredWorldMatrix);
+ //use the hmd reading for the hips follow
+ followWorldPose.rot() = glmExtractRotation(desiredWorldMatrix);
}
if (isActive(Horizontal)) {
glm::vec3 desiredTranslation = extractTranslation(desiredWorldMatrix);
@@ -3465,6 +3752,10 @@ void MyAvatar::updateHoldActions(const AnimPose& prePhysicsPose, const AnimPose&
}
}
+bool MyAvatar::isRecenteringHorizontally() const {
+ return _follow.isActive(FollowHelper::Horizontal);
+}
+
const MyHead* MyAvatar::getMyHead() const {
return static_cast(getHead());
}
diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h
index fa6a675d99..1a6feb142a 100644
--- a/interface/src/avatar/MyAvatar.h
+++ b/interface/src/avatar/MyAvatar.h
@@ -86,6 +86,10 @@ class MyAvatar : public Avatar {
* @property {number} audioListenerModeCamera=1 - The audio listening position is at the camera. Read-only.
* @property {number} audioListenerModeCustom=2 - The audio listening position is at a the position specified by set by the
* customListenPosition
and customListenOrientation
property values. Read-only.
+ * @property {boolean} hasScriptedBlendshapes=false - Blendshapes will be transmitted over the network if set to true.
+ * @property {boolean} hasProceduralBlinkFaceMovement=true - procedural blinking will be turned on if set to true.
+ * @property {boolean} hasProceduralEyeFaceMovement=true - procedural eye movement will be turned on if set to true.
+ * @property {boolean} hasAudioEnabledFaceMovement=true - If set to true, voice audio will move the mouth Blendshapes while MyAvatar.hasScriptedBlendshapes is enabled.
* @property {Vec3} customListenPosition=Vec3.ZERO - The listening position used when the audioListenerMode
* property value is audioListenerModeCustom
.
* @property {Quat} customListenOrientation=Quat.IDENTITY - The listening orientation used when the
@@ -105,6 +109,9 @@ class MyAvatar : public Avatar {
* by 30cm. Read-only.
* @property {Pose} rightHandTipPose - The pose of the right hand as determined by the hand controllers, with the position
* by 30cm. Read-only.
+ * @property {boolean} centerOfGravityModelEnabled=true - If true
then the avatar hips are placed according to the center of
+ * gravity model that balance the center of gravity over the base of support of the feet. Setting the value false
+ * will result in the default behaviour where the hips are placed under the head.
* @property {boolean} hmdLeanRecenterEnabled=true - If true
then the avatar is re-centered to be under the
* head's position. In room-scale VR, this behavior is what causes your avatar to follow your HMD as you walk around
* the room. Setting the value false
is useful if you want to pin the avatar to a fixed position.
@@ -121,7 +128,7 @@ class MyAvatar : public Avatar {
* while flying.
* @property {number} hmdRollControlDeadZone=8 - The amount of HMD roll, in degrees, required before your avatar turns if
* hmdRollControlEnabled
is enabled.
- * @property hmdRollControlRate {number} If hmdRollControlEnabled is true, this value determines the maximum turn rate of
+ * @property {number} hmdRollControlRate If hmdRollControlEnabled is true, this value determines the maximum turn rate of
* your avatar when rolling your HMD in degrees per second.
* @property {number} userHeight=1.75 - The height of the user in sensor space.
* @property {number} userEyeHeight=1.65 - The estimated height of the user's eyes in sensor space. Read-only.
@@ -184,6 +191,10 @@ class MyAvatar : public Avatar {
Q_PROPERTY(AudioListenerMode audioListenerModeHead READ getAudioListenerModeHead)
Q_PROPERTY(AudioListenerMode audioListenerModeCamera READ getAudioListenerModeCamera)
Q_PROPERTY(AudioListenerMode audioListenerModeCustom READ getAudioListenerModeCustom)
+ Q_PROPERTY(bool hasScriptedBlendshapes READ getHasScriptedBlendshapes WRITE setHasScriptedBlendshapes)
+ Q_PROPERTY(bool hasProceduralBlinkFaceMovement READ getHasProceduralBlinkFaceMovement WRITE setHasProceduralBlinkFaceMovement)
+ Q_PROPERTY(bool hasProceduralEyeFaceMovement READ getHasProceduralEyeFaceMovement WRITE setHasProceduralEyeFaceMovement)
+ Q_PROPERTY(bool hasAudioEnabledFaceMovement READ getHasAudioEnabledFaceMovement WRITE setHasAudioEnabledFaceMovement)
//TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity)
Q_PROPERTY(glm::vec3 leftHandPosition READ getLeftHandPosition)
@@ -199,6 +210,7 @@ class MyAvatar : public Avatar {
Q_PROPERTY(float energy READ getEnergy WRITE setEnergy)
Q_PROPERTY(bool isAway READ getIsAway WRITE setAway)
+ Q_PROPERTY(bool centerOfGravityModelEnabled READ getCenterOfGravityModelEnabled WRITE setCenterOfGravityModelEnabled)
Q_PROPERTY(bool hmdLeanRecenterEnabled READ getHMDLeanRecenterEnabled WRITE setHMDLeanRecenterEnabled)
Q_PROPERTY(bool collisionsEnabled READ getCollisionsEnabled WRITE setCollisionsEnabled)
Q_PROPERTY(bool characterControllerEnabled READ getCharacterControllerEnabled WRITE setCharacterControllerEnabled)
@@ -464,7 +476,7 @@ public:
Q_INVOKABLE bool getClearOverlayWhenMoving() const { return _clearOverlayWhenMoving; }
/**jsdoc
* @function MyAvatar.setClearOverlayWhenMoving
- * @returns {boolean}
+ * @param {boolean} on
*/
Q_INVOKABLE void setClearOverlayWhenMoving(bool on) { _clearOverlayWhenMoving = on; }
@@ -480,7 +492,16 @@ public:
*/
Q_INVOKABLE QString getDominantHand() const { return _dominantHand; }
-
+ /**jsdoc
+ * @function MyAvatar.setCenterOfGravityModelEnabled
+ * @param {boolean} enabled
+ */
+ Q_INVOKABLE void setCenterOfGravityModelEnabled(bool value) { _centerOfGravityModelEnabled = value; }
+ /**jsdoc
+ * @function MyAvatar.getCenterOfGravityModelEnabled
+ * @returns {boolean}
+ */
+ Q_INVOKABLE bool getCenterOfGravityModelEnabled() const { return _centerOfGravityModelEnabled; }
/**jsdoc
* @function MyAvatar.setHMDLeanRecenterEnabled
* @param {boolean} enabled
@@ -564,6 +585,13 @@ public:
*/
Q_INVOKABLE void triggerRotationRecenter();
+ /**jsdoc
+ *The isRecenteringHorizontally function returns true if MyAvatar
+ *is translating the root of the Avatar to keep the center of gravity under the head.
+ *isActive(Horizontal) is returned.
+ *@function MyAvatar.isRecenteringHorizontally
+ */
+ Q_INVOKABLE bool isRecenteringHorizontally() const;
eyeContactTarget getEyeContactTarget();
@@ -956,10 +984,18 @@ public:
void removeHoldAction(AvatarActionHold* holdAction); // thread-safe
void updateHoldActions(const AnimPose& prePhysicsPose, const AnimPose& postUpdatePose);
+
// derive avatar body position and orientation from the current HMD Sensor location.
- // results are in HMD frame
+ // results are in sensor frame (-z forward)
glm::mat4 deriveBodyFromHMDSensor() const;
+ glm::vec3 computeCounterBalance() const;
+
+ // derive avatar body position and orientation from using the current HMD Sensor location in relation to the previous
+ // location of the base of support of the avatar.
+ // results are in sensor frame (-z foward)
+ glm::mat4 deriveBodyUsingCgModel() const;
+
/**jsdoc
* @function MyAvatar.isUp
* @param {Vec3} direction
@@ -987,6 +1023,8 @@ public:
QVector getScriptUrls();
+ bool isReadyForPhysics() const;
+
public slots:
/**jsdoc
@@ -1107,7 +1145,16 @@ public slots:
*/
Q_INVOKABLE void updateMotionBehaviorFromMenu();
-
+ /**jsdoc
+ * @function MyAvatar.setToggleHips
+ * @param {boolean} enabled
+ */
+ void setToggleHips(bool followHead);
+ /**jsdoc
+ * @function MyAvatar.setEnableDebugDrawBaseOfSupport
+ * @param {boolean} enabled
+ */
+ void setEnableDebugDrawBaseOfSupport(bool isEnabled);
/**jsdoc
* @function MyAvatar.setEnableDebugDrawDefaultPose
* @param {boolean} enabled
@@ -1159,7 +1206,7 @@ public slots:
* @function MyAvatar.getEnableMeshVisible
* @returns {boolean} true
if your avatar's mesh is visible, otherwise false
.
*/
- bool getEnableMeshVisible() const { return _skeletonModel->isVisible(); }
+ bool getEnableMeshVisible() const override;
/**jsdoc
* Set whether or not your avatar mesh is visible.
@@ -1171,7 +1218,7 @@ public slots:
* MyAvatar.setEnableMeshVisible(true);
* }, 10000);
*/
- void setEnableMeshVisible(bool isEnabled);
+ virtual void setEnableMeshVisible(bool isEnabled) override;
/**jsdoc
* @function MyAvatar.setEnableInverseKinematics
@@ -1341,6 +1388,14 @@ private:
virtual bool shouldRenderHead(const RenderArgs* renderArgs) const override;
void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; setEnableMeshVisible(shouldRender); }
bool getShouldRenderLocally() const { return _shouldRender; }
+ void setHasScriptedBlendshapes(bool hasScriptedBlendshapes);
+ bool getHasScriptedBlendshapes() const override { return _hasScriptedBlendShapes; }
+ void setHasProceduralBlinkFaceMovement(bool hasProceduralBlinkFaceMovement);
+ bool getHasProceduralBlinkFaceMovement() const override { return _headData->getHasProceduralBlinkFaceMovement(); }
+ void setHasProceduralEyeFaceMovement(bool hasProceduralEyeFaceMovement);
+ bool getHasProceduralEyeFaceMovement() const override { return _headData->getHasProceduralEyeFaceMovement(); }
+ void setHasAudioEnabledFaceMovement(bool hasAudioEnabledFaceMovement);
+ bool getHasAudioEnabledFaceMovement() const override { return _headData->getHasAudioEnabledFaceMovement(); }
bool isMyAvatar() const override { return true; }
virtual int parseDataFromBuffer(const QByteArray& buffer) override;
virtual glm::vec3 getSkeletonPosition() const override;
@@ -1402,7 +1457,7 @@ private:
SharedSoundPointer _collisionSound;
MyCharacterController _characterController;
- int16_t _previousCollisionGroup { BULLET_COLLISION_GROUP_MY_AVATAR };
+ int32_t _previousCollisionGroup { BULLET_COLLISION_GROUP_MY_AVATAR };
AvatarWeakPointer _lookAtTargetAvatar;
glm::vec3 _targetAvatarPosition;
@@ -1449,6 +1504,7 @@ private:
bool _hmdRollControlEnabled { true };
float _hmdRollControlDeadZone { ROLL_CONTROL_DEAD_ZONE_DEFAULT };
float _hmdRollControlRate { ROLL_CONTROL_RATE_DEFAULT };
+ std::atomic _hasScriptedBlendShapes { false };
// working copy -- see AvatarData for thread-safe _sensorToWorldMatrixCache, used for outward facing access
glm::mat4 _sensorToWorldMatrix { glm::mat4() };
@@ -1458,8 +1514,8 @@ private:
glm::quat _hmdSensorOrientation;
glm::vec3 _hmdSensorPosition;
// cache head controller pose in sensor space
- glm::vec2 _headControllerFacing; // facing vector in xz plane
- glm::vec2 _headControllerFacingMovingAverage { 0, 0 }; // facing vector in xz plane
+ glm::vec2 _headControllerFacing; // facing vector in xz plane (sensor space)
+ glm::vec2 _headControllerFacingMovingAverage { 0.0f, 0.0f }; // facing vector in xz plane (sensor space)
// cache of the current body position and orientation of the avatar's body,
// in sensor space.
@@ -1495,9 +1551,12 @@ private:
void setForceActivateVertical(bool val);
bool getForceActivateHorizontal() const;
void setForceActivateHorizontal(bool val);
- std::atomic _forceActivateRotation{ false };
- std::atomic _forceActivateVertical{ false };
- std::atomic _forceActivateHorizontal{ false };
+ bool getToggleHipsFollowing() const;
+ void setToggleHipsFollowing(bool followHead);
+ std::atomic _forceActivateRotation { false };
+ std::atomic _forceActivateVertical { false };
+ std::atomic _forceActivateHorizontal { false };
+ std::atomic _toggleHipsFollowing { true };
};
FollowHelper _follow;
@@ -1510,6 +1569,7 @@ private:
bool _prevShouldDrawHead;
bool _rigEnabled { true };
+ bool _enableDebugDrawBaseOfSupport { false };
bool _enableDebugDrawDefaultPose { false };
bool _enableDebugDrawAnimPose { false };
bool _enableDebugDrawHandControllers { false };
@@ -1532,6 +1592,7 @@ private:
std::map _controllerPoseMap;
mutable std::mutex _controllerPoseMapMutex;
+ bool _centerOfGravityModelEnabled { true };
bool _hmdLeanRecenterEnabled { true };
bool _sprint { false };
@@ -1568,6 +1629,8 @@ private:
// load avatar scripts once when rig is ready
bool _shouldLoadScripts { false };
+
+ bool _haveReceivedHeightLimitsFromDomain = { false };
};
QScriptValue audioListenModeToScriptValue(QScriptEngine* engine, const AudioListenerMode& audioListenerMode);
diff --git a/interface/src/avatar/MyHead.cpp b/interface/src/avatar/MyHead.cpp
index cad2f9e5d0..9b05a26c76 100644
--- a/interface/src/avatar/MyHead.cpp
+++ b/interface/src/avatar/MyHead.cpp
@@ -46,32 +46,18 @@ void MyHead::simulate(float deltaTime) {
auto player = DependencyManager::get();
// Only use face trackers when not playing back a recording.
if (!player->isPlaying()) {
- FaceTracker* faceTracker = qApp->getActiveFaceTracker();
- _isFaceTrackerConnected = faceTracker != nullptr && !faceTracker->isMuted();
+ auto faceTracker = qApp->getActiveFaceTracker();
+ const bool hasActualFaceTrackerConnected = faceTracker && !faceTracker->isMuted();
+ _isFaceTrackerConnected = hasActualFaceTrackerConnected || _owningAvatar->getHasScriptedBlendshapes();
if (_isFaceTrackerConnected) {
- _transientBlendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
-
- if (typeid(*faceTracker) == typeid(DdeFaceTracker)) {
-
- if (Menu::getInstance()->isOptionChecked(MenuOption::UseAudioForMouth)) {
- calculateMouthShapes(deltaTime);
-
- const int JAW_OPEN_BLENDSHAPE = 21;
- const int MMMM_BLENDSHAPE = 34;
- const int FUNNEL_BLENDSHAPE = 40;
- const int SMILE_LEFT_BLENDSHAPE = 28;
- const int SMILE_RIGHT_BLENDSHAPE = 29;
- _transientBlendshapeCoefficients[JAW_OPEN_BLENDSHAPE] += _audioJawOpen;
- _transientBlendshapeCoefficients[SMILE_LEFT_BLENDSHAPE] += _mouth4;
- _transientBlendshapeCoefficients[SMILE_RIGHT_BLENDSHAPE] += _mouth4;
- _transientBlendshapeCoefficients[MMMM_BLENDSHAPE] += _mouth2;
- _transientBlendshapeCoefficients[FUNNEL_BLENDSHAPE] += _mouth3;
- }
- applyEyelidOffset(getFinalOrientationInWorldFrame());
+ if (hasActualFaceTrackerConnected) {
+ _blendshapeCoefficients = faceTracker->getBlendshapeCoefficients();
}
}
+
auto eyeTracker = DependencyManager::get();
_isEyeTrackerConnected = eyeTracker->isTracking();
+ // if eye tracker is connected we should get the data here.
}
Parent::simulate(deltaTime);
}
diff --git a/interface/src/avatar/MySkeletonModel.cpp b/interface/src/avatar/MySkeletonModel.cpp
index f317f6b2c1..c15b00ca19 100644
--- a/interface/src/avatar/MySkeletonModel.cpp
+++ b/interface/src/avatar/MySkeletonModel.cpp
@@ -45,7 +45,14 @@ static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) {
return result;
}
- glm::mat4 hipsMat = myAvatar->deriveBodyFromHMDSensor();
+ glm::mat4 hipsMat;
+ if (myAvatar->getCenterOfGravityModelEnabled()) {
+ // then we use center of gravity model
+ hipsMat = myAvatar->deriveBodyUsingCgModel();
+ } else {
+ // otherwise use the default of putting the hips under the head
+ hipsMat = myAvatar->deriveBodyFromHMDSensor();
+ }
glm::vec3 hipsPos = extractTranslation(hipsMat);
glm::quat hipsRot = glmExtractRotation(hipsMat);
@@ -53,8 +60,11 @@ static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) {
glm::mat4 avatarToSensorMat = worldToSensorMat * avatarToWorldMat;
// dampen hips rotation, by mixing it with the avatar orientation in sensor space
- const float MIX_RATIO = 0.5f;
- hipsRot = safeLerp(glmExtractRotation(avatarToSensorMat), hipsRot, MIX_RATIO);
+ // turning this off for center of gravity model because it is already mixed in there
+ if (!(myAvatar->getCenterOfGravityModelEnabled())) {
+ const float MIX_RATIO = 0.5f;
+ hipsRot = safeLerp(glmExtractRotation(avatarToSensorMat), hipsRot, MIX_RATIO);
+ }
if (isFlying) {
// rotate the hips back to match the flying animation.
@@ -73,6 +83,7 @@ static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) {
hipsPos = headPos + tiltRot * (hipsPos - headPos);
}
+ // AJT: TODO can we remove this?
return AnimPose(hipsRot * Quaternions::Y_180, hipsPos);
}
@@ -170,6 +181,15 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
}
}
+ bool isFlying = (myAvatar->getCharacterController()->getState() == CharacterController::State::Hover || myAvatar->getCharacterController()->computeCollisionGroup() == BULLET_COLLISION_GROUP_COLLISIONLESS);
+ if (isFlying != _prevIsFlying) {
+ const float FLY_TO_IDLE_HIPS_TRANSITION_TIME = 0.5f;
+ _flyIdleTimer = FLY_TO_IDLE_HIPS_TRANSITION_TIME;
+ } else {
+ _flyIdleTimer -= deltaTime;
+ }
+ _prevIsFlying = isFlying;
+
// if hips are not under direct control, estimate the hips position.
if (avatarHeadPose.isValid() && !(params.primaryControllerFlags[Rig::PrimaryControllerType_Hips] & (uint8_t)Rig::ControllerFlags::Enabled)) {
bool isFlying = (myAvatar->getCharacterController()->getState() == CharacterController::State::Hover || myAvatar->getCharacterController()->computeCollisionGroup() == BULLET_COLLISION_GROUP_COLLISIONLESS);
@@ -181,14 +201,28 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
AnimPose hips = computeHipsInSensorFrame(myAvatar, isFlying);
+ // timescale in seconds
+ const float TRANS_HORIZ_TIMESCALE = 0.15f;
+ const float TRANS_VERT_TIMESCALE = 0.01f; // We want the vertical component of the hips to follow quickly to prevent spine squash/stretch.
+ const float ROT_TIMESCALE = 0.15f;
+ const float FLY_IDLE_TRANSITION_TIMESCALE = 0.25f;
+
+ float transHorizAlpha, transVertAlpha, rotAlpha;
+ if (_flyIdleTimer < 0.0f) {
+ transHorizAlpha = glm::min(deltaTime / TRANS_HORIZ_TIMESCALE, 1.0f);
+ transVertAlpha = glm::min(deltaTime / TRANS_VERT_TIMESCALE, 1.0f);
+ rotAlpha = glm::min(deltaTime / ROT_TIMESCALE, 1.0f);
+ } else {
+ transHorizAlpha = glm::min(deltaTime / FLY_IDLE_TRANSITION_TIMESCALE, 1.0f);
+ transVertAlpha = glm::min(deltaTime / FLY_IDLE_TRANSITION_TIMESCALE, 1.0f);
+ rotAlpha = glm::min(deltaTime / FLY_IDLE_TRANSITION_TIMESCALE, 1.0f);
+ }
+
// smootly lerp hips, in sensorframe, with different coeff for horiz and vertical translation.
- const float ROT_ALPHA = 0.9f;
- const float TRANS_HORIZ_ALPHA = 0.9f;
- const float TRANS_VERT_ALPHA = 0.1f;
float hipsY = hips.trans().y;
- hips.trans() = lerp(hips.trans(), _prevHips.trans(), TRANS_HORIZ_ALPHA);
- hips.trans().y = lerp(hipsY, _prevHips.trans().y, TRANS_VERT_ALPHA);
- hips.rot() = safeLerp(hips.rot(), _prevHips.rot(), ROT_ALPHA);
+ hips.trans() = lerp(_prevHips.trans(), hips.trans(), transHorizAlpha);
+ hips.trans().y = lerp(_prevHips.trans().y, hipsY, transVertAlpha);
+ hips.rot() = safeLerp(_prevHips.rot(), hips.rot(), rotAlpha);
_prevHips = hips;
_prevHipsValid = true;
diff --git a/interface/src/avatar/MySkeletonModel.h b/interface/src/avatar/MySkeletonModel.h
index 252b6c293b..ebef9796a4 100644
--- a/interface/src/avatar/MySkeletonModel.h
+++ b/interface/src/avatar/MySkeletonModel.h
@@ -28,6 +28,8 @@ private:
AnimPose _prevHips; // sensor frame
bool _prevHipsValid { false };
+ bool _prevIsFlying { false };
+ float _flyIdleTimer { 0.0f };
std::map _jointRotationFrameOffsetMap;
};
diff --git a/interface/src/commerce/Ledger.cpp b/interface/src/commerce/Ledger.cpp
index f791ea25bc..69698e82a6 100644
--- a/interface/src/commerce/Ledger.cpp
+++ b/interface/src/commerce/Ledger.cpp
@@ -134,8 +134,14 @@ void Ledger::balance(const QStringList& keys) {
keysQuery("balance", "balanceSuccess", "balanceFailure");
}
-void Ledger::inventory(const QStringList& keys) {
- keysQuery("inventory", "inventorySuccess", "inventoryFailure");
+void Ledger::inventory(const QString& editionFilter, const QString& typeFilter, const QString& titleFilter, const int& page, const int& perPage) {
+ QJsonObject params;
+ params["edition_filter"] = editionFilter;
+ params["type_filter"] = typeFilter;
+ params["title_filter"] = titleFilter;
+ params["page"] = page;
+ params["per_page"] = perPage;
+ keysQuery("inventory", "inventorySuccess", "inventoryFailure", params);
}
QString hfcString(const QJsonValue& sentValue, const QJsonValue& receivedValue) {
@@ -260,9 +266,9 @@ void Ledger::historyFailure(QNetworkReply& reply) {
failResponse("history", reply);
}
-void Ledger::history(const QStringList& keys, const int& pageNumber) {
+void Ledger::history(const QStringList& keys, const int& pageNumber, const int& itemsPerPage) {
QJsonObject params;
- params["per_page"] = 100;
+ params["per_page"] = itemsPerPage;
params["page"] = pageNumber;
keysQuery("history", "historySuccess", "historyFailure", params);
}
diff --git a/interface/src/commerce/Ledger.h b/interface/src/commerce/Ledger.h
index abc97bfe72..8a8fd2630a 100644
--- a/interface/src/commerce/Ledger.h
+++ b/interface/src/commerce/Ledger.h
@@ -28,8 +28,8 @@ public:
void buy(const QString& hfc_key, int cost, const QString& asset_id, const QString& inventory_key, const bool controlled_failure = false);
bool receiveAt(const QString& hfc_key, const QString& signing_key);
void balance(const QStringList& keys);
- void inventory(const QStringList& keys);
- void history(const QStringList& keys, const int& pageNumber);
+ void inventory(const QString& editionFilter, const QString& typeFilter, const QString& titleFilter, const int& page, const int& perPage);
+ void history(const QStringList& keys, const int& pageNumber, const int& itemsPerPage);
void account();
void updateLocation(const QString& asset_id, const QString& location, const bool& alsoUpdateSiblings = false, const bool controlledFailure = false);
void certificateInfo(const QString& certificateId);
diff --git a/interface/src/commerce/QmlCommerce.cpp b/interface/src/commerce/QmlCommerce.cpp
index 722f29ba2f..b960c0b703 100644
--- a/interface/src/commerce/QmlCommerce.cpp
+++ b/interface/src/commerce/QmlCommerce.cpp
@@ -105,21 +105,21 @@ void QmlCommerce::balance() {
}
}
-void QmlCommerce::inventory() {
+void QmlCommerce::inventory(const QString& editionFilter, const QString& typeFilter, const QString& titleFilter, const int& page, const int& perPage) {
auto ledger = DependencyManager::get();
auto wallet = DependencyManager::get();
QStringList cachedPublicKeys = wallet->listPublicKeys();
if (!cachedPublicKeys.isEmpty()) {
- ledger->inventory(cachedPublicKeys);
+ ledger->inventory(editionFilter, typeFilter, titleFilter, page, perPage);
}
}
-void QmlCommerce::history(const int& pageNumber) {
+void QmlCommerce::history(const int& pageNumber, const int& itemsPerPage) {
auto ledger = DependencyManager::get();
auto wallet = DependencyManager::get();
QStringList cachedPublicKeys = wallet->listPublicKeys();
if (!cachedPublicKeys.isEmpty()) {
- ledger->history(cachedPublicKeys, pageNumber);
+ ledger->history(cachedPublicKeys, pageNumber, itemsPerPage);
}
}
@@ -227,10 +227,13 @@ QString QmlCommerce::getInstalledApps() {
QString scriptURL = appFileJsonObject["scriptURL"].toString();
// If the script .app.json is on the user's local disk but the associated script isn't running
- // for some reason, start that script again.
+ // for some reason (i.e. the user stopped it from Running Scripts),
+ // delete the .app.json from the user's local disk.
if (!runningScripts.contains(scriptURL)) {
- if ((DependencyManager::get()->loadScript(scriptURL.trimmed())).isNull()) {
- qCDebug(commerce) << "Couldn't start script while checking installed apps.";
+ if (!appFile.remove()) {
+ qCWarning(commerce)
+ << "Couldn't delete local .app.json file (app's script isn't running). App filename is:"
+ << appFileName;
}
}
} else {
diff --git a/interface/src/commerce/QmlCommerce.h b/interface/src/commerce/QmlCommerce.h
index 27e97fe7db..a0c6916799 100644
--- a/interface/src/commerce/QmlCommerce.h
+++ b/interface/src/commerce/QmlCommerce.h
@@ -73,8 +73,8 @@ protected:
Q_INVOKABLE void buy(const QString& assetId, int cost, const bool controlledFailure = false);
Q_INVOKABLE void balance();
- Q_INVOKABLE void inventory();
- Q_INVOKABLE void history(const int& pageNumber);
+ Q_INVOKABLE void inventory(const QString& editionFilter = QString(), const QString& typeFilter = QString(), const QString& titleFilter = QString(), const int& page = 1, const int& perPage = 20);
+ Q_INVOKABLE void history(const int& pageNumber, const int& itemsPerPage = 100);
Q_INVOKABLE void generateKeyPair();
Q_INVOKABLE void account();
diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp
index 982adb4b5e..e003ae88a0 100644
--- a/interface/src/commerce/Wallet.cpp
+++ b/interface/src/commerce/Wallet.cpp
@@ -314,6 +314,7 @@ Wallet::Wallet() {
auto nodeList = DependencyManager::get();
auto ledger = DependencyManager::get();
auto& packetReceiver = nodeList->getPacketReceiver();
+ _passphrase = new QString("");
packetReceiver.registerListener(PacketType::ChallengeOwnership, this, "handleChallengeOwnershipPacket");
packetReceiver.registerListener(PacketType::ChallengeOwnershipRequest, this, "handleChallengeOwnershipPacket");
@@ -365,6 +366,10 @@ Wallet::~Wallet() {
if (_securityImage) {
delete _securityImage;
}
+
+ if (_passphrase) {
+ delete _passphrase;
+ }
}
bool Wallet::setPassphrase(const QString& passphrase) {
@@ -531,7 +536,6 @@ bool Wallet::walletIsAuthenticatedWithPassphrase() {
// be sure to add the public key so we don't do this over and over
_publicKeys.push_back(publicKey.toBase64());
- DependencyManager::get()->setWalletStatus((uint)WalletStatus::WALLET_STATUS_READY);
return true;
}
}
@@ -610,7 +614,11 @@ void Wallet::updateImageProvider() {
SecurityImageProvider* securityImageProvider;
// inform offscreenUI security image provider
- QQmlEngine* engine = DependencyManager::get()->getSurfaceContext()->engine();
+ auto offscreenUI = DependencyManager::get();
+ if (!offscreenUI) {
+ return;
+ }
+ QQmlEngine* engine = offscreenUI->getSurfaceContext()->engine();
securityImageProvider = reinterpret_cast(engine->imageProvider(SecurityImageProvider::PROVIDER_NAME));
securityImageProvider->setSecurityImage(_securityImage);
diff --git a/interface/src/commerce/Wallet.h b/interface/src/commerce/Wallet.h
index 8a7d6b8c07..665afd9a23 100644
--- a/interface/src/commerce/Wallet.h
+++ b/interface/src/commerce/Wallet.h
@@ -78,7 +78,7 @@ private:
QByteArray _salt;
QByteArray _iv;
QByteArray _ckey;
- QString* _passphrase { new QString("") };
+ QString* _passphrase { nullptr };
bool _isOverridingServer { false };
bool writeWallet(const QString& newPassphrase = QString(""));
diff --git a/interface/src/main.cpp b/interface/src/main.cpp
index 22db128f7e..cd8c052d63 100644
--- a/interface/src/main.cpp
+++ b/interface/src/main.cpp
@@ -81,6 +81,13 @@ int main(int argc, const char* argv[]) {
// Instance UserActivityLogger now that the settings are loaded
auto& ual = UserActivityLogger::getInstance();
+ // once the settings have been loaded, check if we need to flip the default for UserActivityLogger
+ if (!ual.isDisabledSettingSet()) {
+ // the user activity logger is opt-out for Interface
+ // but it's defaulted to disabled for other targets
+ // so we need to enable it here if it has never been disabled by the user
+ ual.disable(false);
+ }
qDebug() << "UserActivityLogger is enabled:" << ual.isEnabled();
if (ual.isEnabled()) {
diff --git a/interface/src/raypick/PickScriptingInterface.cpp b/interface/src/raypick/PickScriptingInterface.cpp
index 8da6e7c615..74459ca624 100644
--- a/interface/src/raypick/PickScriptingInterface.cpp
+++ b/interface/src/raypick/PickScriptingInterface.cpp
@@ -36,7 +36,7 @@ unsigned int PickScriptingInterface::createPick(const PickQuery::PickType type,
* @typedef {object} Picks.RayPickProperties
* @property {boolean} [enabled=false] If this Pick should start enabled or not. Disabled Picks do not updated their pick results.
* @property {number} [filter=Picks.PICK_NOTHING] The filter for this Pick to use, constructed using filter flags combined using bitwise OR.
- * @property {float} [maxDistance=0.0] The max distance at which this Pick will intersect. 0.0 = no max. < 0.0 is invalid.
+ * @property {number} [maxDistance=0.0] The max distance at which this Pick will intersect. 0.0 = no max. < 0.0 is invalid.
* @property {string} [joint] Only for Joint or Mouse Ray Picks. If "Mouse", it will create a Ray Pick that follows the system mouse, in desktop or HMD.
* If "Avatar", it will create a Joint Ray Pick that follows your avatar's head. Otherwise, it will create a Joint Ray Pick that follows the given joint, if it
* exists on your current avatar.
@@ -103,7 +103,7 @@ unsigned int PickScriptingInterface::createRayPick(const QVariant& properties) {
* @property {number} [hand=-1] An integer. 0 == left, 1 == right. Invalid otherwise.
* @property {boolean} [enabled=false] If this Pick should start enabled or not. Disabled Picks do not updated their pick results.
* @property {number} [filter=Picks.PICK_NOTHING] The filter for this Pick to use, constructed using filter flags combined using bitwise OR.
- * @property {float} [maxDistance=0.0] The max distance at which this Pick will intersect. 0.0 = no max. < 0.0 is invalid.
+ * @property {number} [maxDistance=0.0] The max distance at which this Pick will intersect. 0.0 = no max. < 0.0 is invalid.
*/
unsigned int PickScriptingInterface::createStylusPick(const QVariant& properties) {
QVariantMap propMap = properties.toMap();
diff --git a/interface/src/raypick/PickScriptingInterface.h b/interface/src/raypick/PickScriptingInterface.h
index a39aa3a4a1..0ee091716d 100644
--- a/interface/src/raypick/PickScriptingInterface.h
+++ b/interface/src/raypick/PickScriptingInterface.h
@@ -22,21 +22,22 @@
* @hifi-interface
* @hifi-client-entity
*
- * @property PICK_NOTHING {number} A filter flag. Don't intersect with anything. Read-only.
- * @property PICK_ENTITIES {number} A filter flag. Include entities when intersecting. Read-only.
- * @property PICK_OVERLAYS {number} A filter flag. Include overlays when intersecting. Read-only.
- * @property PICK_AVATARS {number} A filter flag. Include avatars when intersecting. Read-only.
- * @property PICK_HUD {number} A filter flag. Include the HUD sphere when intersecting in HMD mode. Read-only.
- * @property PICK_COARSE {number} A filter flag. Pick against coarse meshes, instead of exact meshes. Read-only.
- * @property PICK_INCLUDE_INVISIBLE {number} A filter flag. Include invisible objects when intersecting. Read-only.
- * @property PICK_INCLUDE_NONCOLLIDABLE {number} A filter flag. Include non-collidable objects when intersecting.
+ * @property {number} PICK_NOTHING A filter flag. Don't intersect with anything. Read-only.
+ * @property {number} PICK_ENTITIES A filter flag. Include entities when intersecting. Read-only.
+ * @property {number} PICK_OVERLAYS A filter flag. Include overlays when intersecting. Read-only.
+ * @property {number} PICK_AVATARS A filter flag. Include avatars when intersecting. Read-only.
+ * @property {number} PICK_HUD A filter flag. Include the HUD sphere when intersecting in HMD mode. Read-only.
+ * @property {number} PICK_COARSE A filter flag. Pick against coarse meshes, instead of exact meshes. Read-only.
+ * @property {number} PICK_INCLUDE_INVISIBLE A filter flag. Include invisible objects when intersecting. Read-only.
+ * @property {number} PICK_INCLUDE_NONCOLLIDABLE A filter flag. Include non-collidable objects when intersecting.
* Read-only.
- * @property PICK_ALL_INTERSECTIONS {number} Read-only.
- * @property INTERSECTED_NONE {number} An intersection type. Intersected nothing with the given filter flags. Read-only.
- * @property INTERSECTED_ENTITY {number} An intersection type. Intersected an entity. Read-only.
- * @property INTERSECTED_OVERLAY {number} An intersection type. Intersected an overlay. Read-only.
- * @property INTERSECTED_AVATAR {number} An intersection type. Intersected an avatar. Read-only.
- * @property INTERSECTED_HUD {number} An intersection type. Intersected the HUD sphere. Read-only.
+ * @property {number} PICK_ALL_INTERSECTIONS Read-only.
+ * @property {number} INTERSECTED_NONE An intersection type. Intersected nothing with the given filter flags.
+ * Read-only.
+ * @property {number} INTERSECTED_ENTITY An intersection type. Intersected an entity. Read-only.
+ * @property {number} INTERSECTED_OVERLAY An intersection type. Intersected an overlay. Read-only.
+ * @property {number} INTERSECTED_AVATAR An intersection type. Intersected an avatar. Read-only.
+ * @property {number} INTERSECTED_HUD An intersection type. Intersected the HUD sphere. Read-only.
* @property {number} perFrameTimeBudget - The max number of usec to spend per frame updating Pick results. Read-only.
*/
@@ -99,11 +100,11 @@ public:
/**jsdoc
* An intersection result for a Ray Pick.
*
- * @typedef {Object} RayPickResult
+ * @typedef {object} RayPickResult
* @property {number} type The intersection type.
* @property {boolean} intersects If there was a valid intersection (type != INTERSECTED_NONE)
* @property {Uuid} objectID The ID of the intersected object. Uuid.NULL for the HUD or invalid intersections.
- * @property {float} distance The distance to the intersection point from the origin of the ray.
+ * @property {number} distance The distance to the intersection point from the origin of the ray.
* @property {Vec3} intersection The intersection point in world-space.
* @property {Vec3} surfaceNormal The surface normal at the intersected point. All NANs if type == INTERSECTED_HUD.
* @property {Variant} extraInfo Additional intersection details when available for Model objects.
@@ -113,11 +114,11 @@ public:
/**jsdoc
* An intersection result for a Stylus Pick.
*
- * @typedef {Object} StylusPickResult
+ * @typedef {object} StylusPickResult
* @property {number} type The intersection type.
* @property {boolean} intersects If there was a valid intersection (type != INTERSECTED_NONE)
* @property {Uuid} objectID The ID of the intersected object. Uuid.NULL for the HUD or invalid intersections.
- * @property {float} distance The distance to the intersection point from the origin of the ray.
+ * @property {number} distance The distance to the intersection point from the origin of the ray.
* @property {Vec3} intersection The intersection point in world-space.
* @property {Vec3} surfaceNormal The surface normal at the intersected point. All NANs if type == INTERSECTED_HUD.
* @property {Variant} extraInfo Additional intersection details when available for Model objects.
diff --git a/interface/src/raypick/PointerScriptingInterface.cpp b/interface/src/raypick/PointerScriptingInterface.cpp
index b7ac899c8d..4e953a5cb8 100644
--- a/interface/src/raypick/PointerScriptingInterface.cpp
+++ b/interface/src/raypick/PointerScriptingInterface.cpp
@@ -68,14 +68,14 @@ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties)
* A set of properties used to define the visual aspect of a Ray Pointer in the case that the Pointer is not intersecting something. Same as a {@link Pointers.RayPointerRenderState},
* but with an additional distance field.
*
- * @typedef {Object} Pointers.DefaultRayPointerRenderState
+ * @typedef {object} Pointers.DefaultRayPointerRenderState
* @augments Pointers.RayPointerRenderState
* @property {number} distance The distance at which to render the end of this Ray Pointer, if one is defined.
*/
/**jsdoc
* A set of properties used to define the visual aspect of a Ray Pointer in the case that the Pointer is intersecting something.
*
- * @typedef {Object} Pointers.RayPointerRenderState
+ * @typedef {object} Pointers.RayPointerRenderState
* @property {string} name The name of this render state, used by {@link Pointers.setRenderState} and {@link Pointers.editRenderState}
* @property {Overlays.OverlayProperties} [start] All of the properties you would normally pass to {@link Overlays.addOverlay}, plus the type (as a type
field).
* An overlay to represent the beginning of the Ray Pointer, if desired.
@@ -87,7 +87,7 @@ unsigned int PointerScriptingInterface::createStylus(const QVariant& properties)
/**jsdoc
* A trigger mechanism for Ray Pointers.
*
- * @typedef {Object} Pointers.Trigger
+ * @typedef {object} Pointers.Trigger
* @property {Controller.Standard|Controller.Actions|function} action This can be a built-in Controller action, like Controller.Standard.LTClick, or a function that evaluates to >= 1.0 when you want to trigger button
.
* @property {string} button Which button to trigger. "Primary", "Secondary", "Tertiary", and "Focus" are currently supported. Only "Primary" will trigger clicks on web surfaces. If "Focus" is triggered,
* it will try to set the entity or overlay focus to the object at which the Pointer is aimed. Buttons besides the first three will still trigger events, but event.button will be "None".
diff --git a/interface/src/raypick/PointerScriptingInterface.h b/interface/src/raypick/PointerScriptingInterface.h
index 49eb40504d..628af84790 100644
--- a/interface/src/raypick/PointerScriptingInterface.h
+++ b/interface/src/raypick/PointerScriptingInterface.h
@@ -136,7 +136,7 @@ public:
* Sets the length of this Pointer. No effect on Stylus Pointers.
* @function Pointers.setLength
* @param {number} uid The ID of the Pointer, as returned by {@link Pointers.createPointer}.
- * @param {float} length The desired length of the Pointer.
+ * @param {number} length The desired length of the Pointer.
*/
Q_INVOKABLE void setLength(unsigned int uid, float length) const { DependencyManager::get()->setLength(uid, length); }
diff --git a/interface/src/scripting/ControllerScriptingInterface.h b/interface/src/scripting/ControllerScriptingInterface.h
index e16383e234..051a372aad 100644
--- a/interface/src/scripting/ControllerScriptingInterface.h
+++ b/interface/src/scripting/ControllerScriptingInterface.h
@@ -105,9 +105,6 @@ class ScriptEngine;
* {@link Controller.getValue|getValue}
* {@link Controller.getAxisValue|getAxisValue}
* {@link Controller.getPoseValue|getgetPoseValue}
- * {@link Controller.getButtonValue|getButtonValue} for a particular device
- * {@link Controller.getAxisValue(0)|getAxisValue} for a particular device
- * {@link Controller.getPoseValue(0)|getPoseValue} for a particular device
* {@link Controller.getActionValue|getActionValue}
*
*
diff --git a/interface/src/scripting/TestScriptingInterface.cpp b/interface/src/scripting/TestScriptingInterface.cpp
index 700994c517..430441226f 100644
--- a/interface/src/scripting/TestScriptingInterface.cpp
+++ b/interface/src/scripting/TestScriptingInterface.cpp
@@ -14,6 +14,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -186,3 +187,7 @@ void TestScriptingInterface::saveObject(QVariant variant, const QString& filenam
file.write(jsonData);
file.close();
}
+
+void TestScriptingInterface::showMaximized() {
+ qApp->getWindow()->showMaximized();
+}
\ No newline at end of file
diff --git a/interface/src/scripting/TestScriptingInterface.h b/interface/src/scripting/TestScriptingInterface.h
index 5666417727..c47e39d1f3 100644
--- a/interface/src/scripting/TestScriptingInterface.h
+++ b/interface/src/scripting/TestScriptingInterface.h
@@ -27,70 +27,128 @@ public slots:
/**jsdoc
* Exits the application
+ * @function Test.quit
*/
void quit();
/**jsdoc
* Waits for all texture transfers to be complete
+ * @function Test.waitForTextureIdle
*/
void waitForTextureIdle();
/**jsdoc
* Waits for all pending downloads to be complete
+ * @function Test.waitForDownloadIdle
*/
void waitForDownloadIdle();
/**jsdoc
* Waits for all file parsing operations to be complete
+ * @function Test.waitForProcessingIdle
*/
void waitForProcessingIdle();
/**jsdoc
* Waits for all pending downloads, parsing and texture transfers to be complete
+ * @function Test.waitIdle
*/
void waitIdle();
+ /**jsdoc
+ * Waits for establishment of connection to server
+ * @function Test.waitForConnection
+ * @param {int} maxWaitMs [default=10000] - Number of milliseconds to wait
+ */
bool waitForConnection(qint64 maxWaitMs = 10000);
+ /**jsdoc
+ * Waits a specific number of milliseconds
+ * @function Test.wait
+ * @param {int} milliseconds - Number of milliseconds to wait
+ */
void wait(int milliseconds);
+ /**jsdoc
+ * Waits for all pending downloads, parsing and texture transfers to be complete
+ * @function Test.loadTestScene
+ * @param {string} sceneFile - URL of scene to load
+ */
bool loadTestScene(QString sceneFile);
+ /**jsdoc
+ * Clears all caches
+ * @function Test.clear
+ */
void clear();
/**jsdoc
* Start recording Chrome compatible tracing events
* logRules can be used to specify a set of logging category rules to limit what gets captured
+ * @function Test.startTracing
+ * @param {string} logrules [defaultValue=""] - See implementation for explanation
*/
bool startTracing(QString logrules = "");
/**jsdoc
* Stop recording Chrome compatible tracing events and serialize recorded events to a file
* Using a filename with a .gz extension will automatically compress the output file
+ * @function Test.stopTracing
+ * @param {string} filename - Name of file to save to
+ * @returns {bool} True if successful.
*/
bool stopTracing(QString filename);
+ /**jsdoc
+ * Starts a specific trace event
+ * @function Test.startTraceEvent
+ * @param {string} name - Name of event
+ */
void startTraceEvent(QString name);
+ /**jsdoc
+ * Stop a specific name event
+ * Using a filename with a .gz extension will automatically compress the output file
+ * @function Test.endTraceEvent
+ * @param {string} filename - Name of event
+ */
void endTraceEvent(QString name);
/**jsdoc
* Write detailed timing stats of next physics stepSimulation() to filename
+ * @function Test.savePhysicsSimulationStats
+ * @param {string} filename - Name of file to save to
*/
void savePhysicsSimulationStats(QString filename);
+ /**jsdoc
+ * Profiles a specific function
+ * @function Test.savePhysicsSimulationStats
+ * @param {string} name - Name used to reference the function
+ * @param {function} function - Function to profile
+ */
Q_INVOKABLE void profileRange(const QString& name, QScriptValue function);
/**jsdoc
* Clear all caches (menu command Reload Content)
+ * @function Test.clearCaches
*/
void clearCaches();
/**jsdoc
* Save a JSON object to a file in the test results location
+ * @function Test.saveObject
+ * @param {string} name - Name of the object
+ * @param {string} filename - Name of file to save to
*/
void saveObject(QVariant v, const QString& filename);
+ /**jsdoc
+ * Maximizes the window
+ * @function Test.showMaximized
+ */
+ void showMaximized();
+
private:
bool waitForCondition(qint64 maxWaitMs, std::function condition);
QString _testResultsLocation;
diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp
index 6f6e83842c..0aea7a02c5 100644
--- a/interface/src/scripting/WindowScriptingInterface.cpp
+++ b/interface/src/scripting/WindowScriptingInterface.cpp
@@ -446,12 +446,12 @@ void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, f
qApp->takeSnapshot(notify, includeAnimated, aspectRatio, filename);
}
-void WindowScriptingInterface::takeSecondaryCameraSnapshot(const QString& filename) {
- qApp->takeSecondaryCameraSnapshot(filename);
+void WindowScriptingInterface::takeSecondaryCameraSnapshot(const bool& notify, const QString& filename) {
+ qApp->takeSecondaryCameraSnapshot(notify, filename);
}
-void WindowScriptingInterface::takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const QString& filename) {
- qApp->takeSecondaryCamera360Snapshot(cameraPosition, cubemapOutputFormat, filename);
+void WindowScriptingInterface::takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const bool& notify, const QString& filename) {
+ qApp->takeSecondaryCamera360Snapshot(cameraPosition, cubemapOutputFormat, notify, filename);
}
void WindowScriptingInterface::shareSnapshot(const QString& path, const QUrl& href) {
@@ -522,7 +522,7 @@ int WindowScriptingInterface::openMessageBox(QString title, QString text, int bu
* RestoreDefaults | 0x8000000 | "Restore Defaults" |
*
*
- * @typedef Window.MessageBoxButton
+ * @typedef {number} Window.MessageBoxButton
*/
int WindowScriptingInterface::createMessageBox(QString title, QString text, int buttons, int defaultButton) {
auto messageBox = DependencyManager::get()->createMessageBox(OffscreenUi::ICON_INFORMATION, title, text,
diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h
index 1d06f33ec0..29eb6421e1 100644
--- a/interface/src/scripting/WindowScriptingInterface.h
+++ b/interface/src/scripting/WindowScriptingInterface.h
@@ -318,7 +318,6 @@ public slots:
* {@link Window.stillSnapshotTaken|stillSnapshotTaken} is emitted; when a still image plus moving images are captured,
* {@link Window.processingGifStarted|processingGifStarted} and {@link Window.processingGifCompleted|processingGifCompleted}
* are emitted. The path to store the snapshots and the length of the animated GIF to capture are specified in Settings >
- * NOTE: to provide a non-default value - all previous parameters must be provided.
* General > Snapshots.
* @function Window.takeSnapshot
* @param {boolean} [notify=true] - This value is passed on through the {@link Window.stillSnapshotTaken|stillSnapshotTaken}
@@ -328,7 +327,7 @@ public slots:
* @param {number} [aspectRatio=0] - The width/height ratio of the snapshot required. If the value is 0
the
* full resolution is used (window dimensions in desktop mode; HMD display dimensions in HMD mode), otherwise one of the
* dimensions is adjusted in order to match the aspect ratio.
- * @param {string} [filename=""] - If this parameter is not given, the image will be saved as 'hifi-snap-by--YYYY-MM-DD_HH-MM-SS'.
+ * @param {string} [filename=""] - If this parameter is not given, the image will be saved as "hifi-snap-by-<user name>-YYYY-MM-DD_HH-MM-SS".
* If this parameter is ""
then the image will be saved as ".jpg".
* Otherwise, the image will be saved to this filename, with an appended ".jpg".
*
@@ -360,29 +359,29 @@ public slots:
/**jsdoc
* Takes a still snapshot of the current view from the secondary camera that can be set up through the {@link Render} API.
- * NOTE: to provide a non-default value - all previous parameters must be provided.
* @function Window.takeSecondaryCameraSnapshot
- * @param {string} [filename=""] - If this parameter is not given, the image will be saved as 'hifi-snap-by--YYYY-MM-DD_HH-MM-SS'.
+ * @param {boolean} [notify=true] - This value is passed on through the {@link Window.stillSnapshotTaken|stillSnapshotTaken}
+ * signal.
+ * @param {string} [filename=""] - If this parameter is not given, the image will be saved as "hifi-snap-by-<user name>-YYYY-MM-DD_HH-MM-SS".
* If this parameter is ""
then the image will be saved as ".jpg".
* Otherwise, the image will be saved to this filename, with an appended ".jpg".
- *
- * var filename = QString();
*/
- void takeSecondaryCameraSnapshot(const QString& filename = QString());
+ void takeSecondaryCameraSnapshot(const bool& notify = true, const QString& filename = QString());
/**jsdoc
- * Takes a 360 snapshot given a position of the secondary camera (which does not need to have been previously set up).
- * @function Window.takeSecondaryCameraSnapshot
- * @param {vec3} [cameraPosition] - The (x, y, z) position of the camera for the 360 snapshot
- * @param {boolean} [cubemapOutputFormat=false] - If true
then the snapshot is saved as a cube map image,
- * otherwise is saved as an equirectangular image.
- * @param {string} [filename=""] - If this parameter is not given, the image will be saved as 'hifi-snap-by--YYYY-MM-DD_HH-MM-SS'.
- * If this parameter is ""
then the image will be saved as ".jpg".
- * Otherwise, the image will be saved to this filename, with an appended ".jpg".
- *
- * var filename = QString();
- */
- void takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat = false, const QString& filename = QString());
+ * Takes a 360° snapshot at a given position for the secondary camera. The secondary camera does not need to have been
+ * set up.
+ * @function Window.takeSecondaryCamera360Snapshot
+ * @param {Vec3} cameraPosition - The position of the camera for the snapshot.
+ * @param {boolean} [cubemapOutputFormat=false] - If true
then the snapshot is saved as a cube map image,
+ * otherwise is saved as an equirectangular image.
+ * @param {boolean} [notify=true] - This value is passed on through the {@link Window.stillSnapshotTaken|stillSnapshotTaken}
+ * signal.
+ * @param {string} [filename=""] - If this parameter is not supplied, the image will be saved as "hifi-snap-by-<user name>-YYYY-MM-DD_HH-MM-SS".
+ * If this parameter is ""
then the image will be saved as ".jpg".
+ * Otherwise, the image will be saved to this filename, with an appended ".jpg".
+ */
+ void takeSecondaryCamera360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat = false, const bool& notify = true, const QString& filename = QString());
/**jsdoc
* Emit a {@link Window.connectionAdded|connectionAdded} or a {@link Window.connectionError|connectionError} signal that
@@ -470,7 +469,7 @@ public slots:
*
*
*
- * @typedef Window.DisplayTexture
+ * @typedef {string} Window.DisplayTexture
*/
bool setDisplayTexture(const QString& name);
@@ -523,16 +522,21 @@ public slots:
int openMessageBox(QString title, QString text, int buttons, int defaultButton);
/**jsdoc
- * Open the given resource in the Interface window or in a web browser depending on the url scheme
+ * Open a URL in the Interface window or other application, depending on the URL's scheme. If the URL starts with
+ * hifi://
then that URL is navigated to in Interface, otherwise the URL is opened in the application the OS
+ * associates with the URL's scheme (e.g., a Web browser for http://
).
* @function Window.openUrl
- * @param {string} url - The resource to open
+ * @param {string} url - The URL to open.
*/
void openUrl(const QUrl& url);
/**jsdoc
- * (Android only) Open the requested Activity and optionally back to the scene when the activity is done
+ * Open an Android activity and optionally return back to the scene when the activity is completed. Android only.
* @function Window.openAndroidActivity
- * @param {string} activityName - The name of the activity to open. One of "Home", "Login" or "Privacy Policy"
+ * @param {string} activityName - The name of the activity to open: one of "Home"
, "Login"
, or
+ * "Privacy Policy"
.
+ * @param {boolean} backToScene - If true
, the user is automatically returned back to the scene when the
+ * activity is completed.
*/
void openAndroidActivity(const QString& activityName, const bool backToScene);
@@ -607,7 +611,8 @@ signals:
void stillSnapshotTaken(const QString& pathStillSnapshot, bool notify);
/**jsdoc
- * Triggered when a still equirectangular snapshot has been taken by calling {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot}
+ * Triggered when a still 360° snapshot has been taken by calling
+ * {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot}.
* @function Window.snapshot360Taken
* @param {string} pathStillSnapshot - The path and name of the snapshot image file.
* @param {boolean} notify - The value of the notify
parameter that {@link Window.takeSecondaryCamera360Snapshot|takeSecondaryCamera360Snapshot}
diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp
index d01e7d6671..83601a2797 100644
--- a/interface/src/ui/DialogsManager.cpp
+++ b/interface/src/ui/DialogsManager.cpp
@@ -93,10 +93,18 @@ void DialogsManager::setDomainConnectionFailureVisibility(bool visible) {
static const QUrl url("dialogs/TabletConnectionFailureDialog.qml");
auto hmd = DependencyManager::get();
if (visible) {
+ _dialogCreatedWhileShown = tablet->property("tabletShown").toBool();
tablet->initialScreen(url);
if (!hmd->getShouldShowTablet()) {
hmd->openTablet();
}
+ } else if (tablet->isPathLoaded(url)) {
+ tablet->closeDialog();
+ tablet->gotoHomeScreen();
+ if (!_dialogCreatedWhileShown) {
+ hmd->closeTablet();
+ }
+ _dialogCreatedWhileShown = false;
}
}
}
diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h
index f17ac39a7e..0633dec573 100644
--- a/interface/src/ui/DialogsManager.h
+++ b/interface/src/ui/DialogsManager.h
@@ -80,6 +80,7 @@ private:
QPointer _octreeStatsDialog;
QPointer _testingDialog;
QPointer _domainConnectionDialog;
+ bool _dialogCreatedWhileShown { false };
bool _addressBarVisible { false };
};
diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp
index e7e3c91d13..d131bb3467 100644
--- a/interface/src/ui/OverlayConductor.cpp
+++ b/interface/src/ui/OverlayConductor.cpp
@@ -18,7 +18,6 @@
#include "InterfaceLogging.h"
OverlayConductor::OverlayConductor() {
-
}
OverlayConductor::~OverlayConductor() {
@@ -33,8 +32,8 @@ bool OverlayConductor::headOutsideOverlay() const {
glm::vec3 uiPos = uiTransform.getTranslation();
glm::vec3 uiForward = uiTransform.getRotation() * glm::vec3(0.0f, 0.0f, -1.0f);
- const float MAX_COMPOSITOR_DISTANCE = 0.99f; // If you're 1m from center of ui sphere, you're at the surface.
- const float MAX_COMPOSITOR_ANGLE = 180.0f; // rotation check is effectively disabled
+ const float MAX_COMPOSITOR_DISTANCE = 0.99f; // If you're 1m from center of ui sphere, you're at the surface.
+ const float MAX_COMPOSITOR_ANGLE = 180.0f; // rotation check is effectively disabled
if (glm::distance(uiPos, hmdPos) > MAX_COMPOSITOR_DISTANCE ||
glm::dot(uiForward, hmdForward) < cosf(glm::radians(MAX_COMPOSITOR_ANGLE))) {
return true;
@@ -43,10 +42,9 @@ bool OverlayConductor::headOutsideOverlay() const {
}
bool OverlayConductor::updateAvatarIsAtRest() {
-
auto myAvatar = DependencyManager::get()->getMyAvatar();
- const quint64 REST_ENABLE_TIME_USECS = 1000 * 1000; // 1 s
+ const quint64 REST_ENABLE_TIME_USECS = 1000 * 1000; // 1 s
const quint64 REST_DISABLE_TIME_USECS = 200 * 1000; // 200 ms
const float AT_REST_THRESHOLD = 0.01f;
@@ -69,31 +67,6 @@ bool OverlayConductor::updateAvatarIsAtRest() {
return _currentAtRest;
}
-bool OverlayConductor::updateAvatarHasDriveInput() {
- auto myAvatar = DependencyManager::get()->getMyAvatar();
-
- const quint64 DRIVE_ENABLE_TIME_USECS = 200 * 1000; // 200 ms
- const quint64 DRIVE_DISABLE_TIME_USECS = 1000 * 1000; // 1 s
-
- bool desiredDriving = myAvatar->hasDriveInput();
- if (desiredDriving != _desiredDriving) {
- // start timer
- _desiredDrivingTimer = usecTimestampNow() + (desiredDriving ? DRIVE_ENABLE_TIME_USECS : DRIVE_DISABLE_TIME_USECS);
- }
-
- _desiredDriving = desiredDriving;
-
- if (_desiredDrivingTimer != 0 && usecTimestampNow() > _desiredDrivingTimer) {
- // timer expired
- // change state!
- _currentDriving = _desiredDriving;
- // disable timer
- _desiredDrivingTimer = 0;
- }
-
- return _currentDriving;
-}
-
void OverlayConductor::centerUI() {
// place the overlay at the current hmd position in sensor space
auto camMat = cancelOutRollAndPitch(qApp->getHMDSensorPose());
@@ -115,20 +88,19 @@ void OverlayConductor::update(float dt) {
_hmdMode = false;
}
- bool prevDriving = _currentDriving;
- bool isDriving = updateAvatarHasDriveInput();
- bool drivingChanged = prevDriving != isDriving;
bool isAtRest = updateAvatarIsAtRest();
+ bool isMoving = !isAtRest;
+
bool shouldRecenter = false;
- if (_flags & SuppressedByDrive) {
- if (!isDriving) {
- _flags &= ~SuppressedByDrive;
- shouldRecenter = true;
+ if (_flags & SuppressedByMove) {
+ if (!isMoving) {
+ _flags &= ~SuppressedByMove;
+ shouldRecenter = true;
}
} else {
- if (myAvatar->getClearOverlayWhenMoving() && drivingChanged && isDriving) {
- _flags |= SuppressedByDrive;
+ if (myAvatar->getClearOverlayWhenMoving() && isMoving) {
+ _flags |= SuppressedByMove;
}
}
@@ -143,7 +115,6 @@ void OverlayConductor::update(float dt) {
}
}
-
bool targetVisible = Menu::getInstance()->isOptionChecked(MenuOption::Overlays) && (0 == (_flags & SuppressMask));
if (targetVisible != currentVisible) {
offscreenUi->setPinned(!targetVisible);
diff --git a/interface/src/ui/OverlayConductor.h b/interface/src/ui/OverlayConductor.h
index cdd596a7bc..cf69c32fc5 100644
--- a/interface/src/ui/OverlayConductor.h
+++ b/interface/src/ui/OverlayConductor.h
@@ -23,23 +23,17 @@ public:
private:
bool headOutsideOverlay() const;
- bool updateAvatarHasDriveInput();
bool updateAvatarIsAtRest();
enum SupressionFlags {
- SuppressedByDrive = 0x01,
+ SuppressedByMove = 0x01,
SuppressedByHead = 0x02,
SuppressMask = 0x03,
};
- uint8_t _flags { SuppressedByDrive };
+ uint8_t _flags { SuppressedByMove };
bool _hmdMode { false };
- // used by updateAvatarHasDriveInput
- uint64_t _desiredDrivingTimer { 0 };
- bool _desiredDriving { false };
- bool _currentDriving { false };
-
// used by updateAvatarIsAtRest
uint64_t _desiredAtRestTimer { 0 };
bool _desiredAtRest { true };
diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp
index b2c0ee7ce7..2b306ace91 100644
--- a/interface/src/ui/Snapshot.cpp
+++ b/interface/src/ui/Snapshot.cpp
@@ -122,8 +122,9 @@ static const glm::quat CAMERA_ORIENTATION_LEFT(glm::quat(glm::radians(glm::vec3(
static const glm::quat CAMERA_ORIENTATION_BACK(glm::quat(glm::radians(glm::vec3(0.0f, 180.0f, 0.0f))));
static const glm::quat CAMERA_ORIENTATION_RIGHT(glm::quat(glm::radians(glm::vec3(0.0f, 270.0f, 0.0f))));
static const glm::quat CAMERA_ORIENTATION_UP(glm::quat(glm::radians(glm::vec3(90.0f, 0.0f, 0.0f))));
-void Snapshot::save360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const QString& filename) {
+void Snapshot::save360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const bool& notify, const QString& filename) {
_snapshotFilename = filename;
+ _notify360 = notify;
_cubemapOutputFormat = cubemapOutputFormat;
SecondaryCameraJobConfig* secondaryCameraRenderConfig = static_cast(qApp->getRenderEngine()->getConfiguration()->getConfig("SecondaryCamera"));
@@ -247,7 +248,8 @@ void Snapshot::convertToCubemap() {
painter.end();
- emit DependencyManager::get()->snapshot360Taken(saveSnapshot(outputImage, _snapshotFilename), true);
+ emit DependencyManager::get()->snapshot360Taken(saveSnapshot(outputImage, _snapshotFilename),
+ _notify360);
}
void Snapshot::convertToEquirectangular() {
@@ -327,7 +329,8 @@ void Snapshot::convertToEquirectangular() {
}
}
- emit DependencyManager::get()->snapshot360Taken(saveSnapshot(outputImage, _snapshotFilename), true);
+ emit DependencyManager::get()->snapshot360Taken(saveSnapshot(outputImage, _snapshotFilename),
+ _notify360);
}
QTemporaryFile* Snapshot::saveTempSnapshot(QImage image) {
diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h
index 2bac857a97..8fc05775bd 100644
--- a/interface/src/ui/Snapshot.h
+++ b/interface/src/ui/Snapshot.h
@@ -50,7 +50,10 @@ class Snapshot : public QObject, public Dependency {
public:
Snapshot();
QString saveSnapshot(QImage image, const QString& filename, const QString& pathname = QString());
- void save360Snapshot(const glm::vec3& cameraPosition, const bool& cubemapOutputFormat, const QString& filename);
+ void save360Snapshot(const glm::vec3& cameraPosition,
+ const bool& cubemapOutputFormat,
+ const bool& notify,
+ const QString& filename);
QTemporaryFile* saveTempSnapshot(QImage image);
SnapshotMetaData* parseSnapshotData(QString snapshotPath);
@@ -89,6 +92,7 @@ private:
const QString& userSelectedFilename = QString(),
const QString& userSelectedPathname = QString());
QString _snapshotFilename;
+ bool _notify360;
bool _cubemapOutputFormat;
QTimer _snapshotTimer;
qint16 _snapshotIndex;
diff --git a/interface/src/ui/SnapshotUploader.cpp b/interface/src/ui/SnapshotUploader.cpp
index 67902c1a35..4613871d25 100644
--- a/interface/src/ui/SnapshotUploader.cpp
+++ b/interface/src/ui/SnapshotUploader.cpp
@@ -35,6 +35,7 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) {
QString thumbnailUrl = dataObject.value("thumbnail_url").toString();
QString imageUrl = dataObject.value("image_url").toString();
QString snapshotID = dataObject.value("id").toString();
+ QString originalImageFileName = dataObject.value("original_image_file_name").toString();
auto addressManager = DependencyManager::get();
QString placeName = _inWorldLocation.authority(); // We currently only upload shareable places, in which case this is just host.
QString currentPath = _inWorldLocation.path();
@@ -48,6 +49,7 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) {
detailsObject.insert("shareable_url", dataObject.value("shareable_url").toString());
}
detailsObject.insert("snapshot_id", snapshotID);
+ detailsObject.insert("original_image_file_name", originalImageFileName);
QString pickledDetails = QJsonDocument(detailsObject).toJson();
userStoryObject.insert("details", pickledDetails);
userStoryObject.insert("thumbnail_url", thumbnailUrl);
diff --git a/interface/src/ui/overlays/Base3DOverlay.cpp b/interface/src/ui/overlays/Base3DOverlay.cpp
index f4efd1301d..f59b513bd5 100644
--- a/interface/src/ui/overlays/Base3DOverlay.cpp
+++ b/interface/src/ui/overlays/Base3DOverlay.cpp
@@ -349,3 +349,23 @@ void Base3DOverlay::setVisible(bool visible) {
Parent::setVisible(visible);
notifyRenderVariableChange();
}
+
+render::ItemKey Base3DOverlay::getKey() {
+ auto builder = render::ItemKey::Builder(Overlay::getKey());
+
+ if (getDrawInFront()) {
+ builder.withLayer(render::hifi::LAYER_3D_FRONT);
+ } else if (getDrawHUDLayer()) {
+ builder.withLayer(render::hifi::LAYER_3D_HUD);
+ } else {
+ builder.withoutLayer();
+ }
+
+ builder.withoutViewSpace();
+
+ if (isTransparent()) {
+ builder.withTransparent();
+ }
+
+ return builder.build();
+}
\ No newline at end of file
diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h
index ab83a64273..2a63a6cb67 100644
--- a/interface/src/ui/overlays/Base3DOverlay.h
+++ b/interface/src/ui/overlays/Base3DOverlay.h
@@ -35,6 +35,7 @@ public:
// getters
virtual bool is3D() const override { return true; }
+ virtual render::ItemKey getKey() override;
virtual uint32_t fetchMetaSubItems(render::ItemIDs& subItems) const override { subItems.push_back(getRenderItemID()); return (uint32_t) subItems.size(); }
virtual scriptable::ScriptableModelBase getScriptableModel() override { return scriptable::ScriptableModelBase(); }
diff --git a/interface/src/ui/overlays/Billboard3DOverlay.cpp b/interface/src/ui/overlays/Billboard3DOverlay.cpp
index 960f0de095..ecade70ef8 100644
--- a/interface/src/ui/overlays/Billboard3DOverlay.cpp
+++ b/interface/src/ui/overlays/Billboard3DOverlay.cpp
@@ -46,6 +46,13 @@ bool Billboard3DOverlay::applyTransformTo(Transform& transform, bool force) {
return transformChanged;
}
+void Billboard3DOverlay::update(float duration) {
+ if (isFacingAvatar()) {
+ _renderVariableDirty = true;
+ }
+ Parent::update(duration);
+}
+
Transform Billboard3DOverlay::evalRenderTransform() {
Transform transform = getTransform();
bool transformChanged = applyTransformTo(transform, true);
diff --git a/interface/src/ui/overlays/Billboard3DOverlay.h b/interface/src/ui/overlays/Billboard3DOverlay.h
index 6b3aa40451..174bc23bc8 100644
--- a/interface/src/ui/overlays/Billboard3DOverlay.h
+++ b/interface/src/ui/overlays/Billboard3DOverlay.h
@@ -18,6 +18,7 @@
class Billboard3DOverlay : public Planar3DOverlay, public PanelAttachable, public Billboardable {
Q_OBJECT
+ using Parent = Planar3DOverlay;
public:
Billboard3DOverlay() {}
@@ -26,6 +27,8 @@ public:
void setProperties(const QVariantMap& properties) override;
QVariant getProperty(const QString& property) override;
+ void update(float duration) override;
+
protected:
virtual bool applyTransformTo(Transform& transform, bool force = false) override;
diff --git a/interface/src/ui/overlays/Image3DOverlay.cpp b/interface/src/ui/overlays/Image3DOverlay.cpp
index df93245922..6e9946e935 100644
--- a/interface/src/ui/overlays/Image3DOverlay.cpp
+++ b/interface/src/ui/overlays/Image3DOverlay.cpp
@@ -51,11 +51,6 @@ void Image3DOverlay::update(float deltatime) {
_texture = DependencyManager::get()->getTexture(_url);
_textureIsLoaded = false;
}
- if (usecTimestampNow() > _transformExpiry) {
- Transform transform = getTransform();
- applyTransformTo(transform);
- setTransform(transform);
- }
Parent::update(deltatime);
}
diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp
index 27e3bd0e2d..875352ebb4 100644
--- a/interface/src/ui/overlays/ModelOverlay.cpp
+++ b/interface/src/ui/overlays/ModelOverlay.cpp
@@ -100,26 +100,40 @@ void ModelOverlay::update(float deltatime) {
processMaterials();
emit DependencyManager::get()->modelAddedToScene(getID(), NestableType::Overlay, _model);
}
+ bool metaDirty = false;
if (_visibleDirty) {
_visibleDirty = false;
// don't show overlays in mirrors or spectator-cam unless _isVisibleInSecondaryCamera is true
- _model->setVisibleInScene(getVisible(), scene,
- render::ItemKey::TAG_BITS_0 |
- (_isVisibleInSecondaryCamera ? render::ItemKey::TAG_BITS_1 : render::ItemKey::TAG_BITS_NONE),
- false);
+ uint8_t modelRenderTagMask = (_isVisibleInSecondaryCamera ? render::hifi::TAG_ALL_VIEWS : render::hifi::TAG_MAIN_VIEW);
+ _model->setTagMask(modelRenderTagMask, scene);
+ _model->setVisibleInScene(getVisible(), scene);
+ metaDirty = true;
}
if (_drawInFrontDirty) {
_drawInFrontDirty = false;
_model->setLayeredInFront(getDrawInFront(), scene);
+ metaDirty = true;
}
if (_drawInHUDDirty) {
_drawInHUDDirty = false;
_model->setLayeredInHUD(getDrawHUDLayer(), scene);
+ metaDirty = true;
+ }
+ if (_groupCulledDirty) {
+ _groupCulledDirty = false;
+ _model->setGroupCulled(_isGroupCulled, scene);
+ metaDirty = true;
+ }
+ if (metaDirty) {
+ transaction.updateItem(getRenderItemID(), [](Overlay& data) {});
}
scene->enqueueTransaction(transaction);
if (!_texturesLoaded && _model->getGeometry() && _model->getGeometry()->areTexturesLoaded()) {
_texturesLoaded = true;
+ if (!_modelTextures.isEmpty()) {
+ _model->setTextures(_modelTextures);
+ }
_model->updateRenderItems();
}
}
@@ -150,13 +164,24 @@ void ModelOverlay::setVisible(bool visible) {
}
void ModelOverlay::setDrawInFront(bool drawInFront) {
- Base3DOverlay::setDrawInFront(drawInFront);
- _drawInFrontDirty = true;
+ if (drawInFront != getDrawInFront()) {
+ Base3DOverlay::setDrawInFront(drawInFront);
+ _drawInFrontDirty = true;
+ }
}
void ModelOverlay::setDrawHUDLayer(bool drawHUDLayer) {
- Base3DOverlay::setDrawHUDLayer(drawHUDLayer);
- _drawInHUDDirty = true;
+ if (drawHUDLayer != getDrawHUDLayer()) {
+ Base3DOverlay::setDrawHUDLayer(drawHUDLayer);
+ _drawInHUDDirty = true;
+ }
+}
+
+void ModelOverlay::setGroupCulled(bool groupCulled) {
+ if (groupCulled != _isGroupCulled) {
+ _isGroupCulled = groupCulled;
+ _groupCulledDirty = true;
+ }
}
void ModelOverlay::setProperties(const QVariantMap& properties) {
@@ -207,8 +232,12 @@ void ModelOverlay::setProperties(const QVariantMap& properties) {
if (texturesValue.isValid() && texturesValue.canConvert(QVariant::Map)) {
_texturesLoaded = false;
QVariantMap textureMap = texturesValue.toMap();
- QMetaObject::invokeMethod(_model.get(), "setTextures", Qt::AutoConnection,
- Q_ARG(const QVariantMap&, textureMap));
+ _modelTextures = textureMap;
+ }
+
+ auto groupCulledValue = properties["isGroupCulled"];
+ if (groupCulledValue.isValid() && groupCulledValue.canConvert(QVariant::Bool)) {
+ setGroupCulled(groupCulledValue.toBool());
}
// jointNames is read-only.
@@ -348,6 +377,8 @@ vectorType ModelOverlay::mapJoints(mapFunction function) const {
* {@link Overlays.findRayIntersection|findRayIntersection} ignores the overlay.
* @property {boolean} drawInFront=false - If true
, the overlay is rendered in front of other overlays that don't
* have drawInFront
set to true
, and in front of entities.
+ * @property {boolean} isGroupCulled=false - If true
, the mesh parts of the model are LOD culled as a group.
+ * If false
, separate mesh parts will be LOD culled individually.
* @property {boolean} grabbable=false - Signal to grabbing scripts whether or not this overlay can be grabbed.
* @property {Uuid} parentID=null - The avatar, entity, or overlay that the overlay is parented to.
* @property {number} parentJointIndex=65535 - Integer value specifying the skeleton joint that the overlay is attached to if
@@ -712,3 +743,11 @@ scriptable::ScriptableModelBase ModelOverlay::getScriptableModel() {
}
return result;
}
+
+render::ItemKey ModelOverlay::getKey() {
+ auto builder = render::ItemKey::Builder(Base3DOverlay::getKey());
+ if (_isGroupCulled) {
+ builder.withMetaCullGroup();
+ }
+ return builder.build();
+}
\ No newline at end of file
diff --git a/interface/src/ui/overlays/ModelOverlay.h b/interface/src/ui/overlays/ModelOverlay.h
index 3ef3f23fec..334c9c06f1 100644
--- a/interface/src/ui/overlays/ModelOverlay.h
+++ b/interface/src/ui/overlays/ModelOverlay.h
@@ -33,6 +33,7 @@ public:
virtual uint32_t fetchMetaSubItems(render::ItemIDs& subItems) const override;
+ render::ItemKey getKey() override;
void clearSubRenderItemIDs();
void setSubRenderItemIDs(const render::ItemIDs& ids);
@@ -63,6 +64,7 @@ public:
void setVisible(bool visible) override;
void setDrawInFront(bool drawInFront) override;
void setDrawHUDLayer(bool drawHUDLayer) override;
+ void setGroupCulled(bool groupCulled);
void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName) override;
void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) override;
@@ -121,6 +123,8 @@ private:
bool _visibleDirty { true };
bool _drawInFrontDirty { false };
bool _drawInHUDDirty { false };
+ bool _isGroupCulled { false };
+ bool _groupCulledDirty { false };
void processMaterials();
diff --git a/interface/src/ui/overlays/Overlay.cpp b/interface/src/ui/overlays/Overlay.cpp
index 2c0c7c71b6..faa15ee2b4 100644
--- a/interface/src/ui/overlays/Overlay.cpp
+++ b/interface/src/ui/overlays/Overlay.cpp
@@ -244,4 +244,21 @@ void Overlay::addMaterial(graphics::MaterialLayer material, const std::string& p
void Overlay::removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) {
std::lock_guard lock(_materialsLock);
_materials[parentMaterialName].remove(material);
+}
+
+render::ItemKey Overlay::getKey() {
+ auto builder = render::ItemKey::Builder().withTypeShape();
+
+ builder.withViewSpace();
+ builder.withLayer(render::hifi::LAYER_2D);
+
+ if (!getVisible()) {
+ builder.withInvisible();
+ }
+
+ // always visible in primary view. if isVisibleInSecondaryCamera, also draw in secondary view
+ render::hifi::Tag viewTagBits = getIsVisibleInSecondaryCamera() ? render::hifi::TAG_ALL_VIEWS : render::hifi::TAG_MAIN_VIEW;
+ builder.withTagBits(viewTagBits);
+
+ return builder.build();
}
\ No newline at end of file
diff --git a/interface/src/ui/overlays/Overlay.h b/interface/src/ui/overlays/Overlay.h
index 2f27d50f7e..45fc77a452 100644
--- a/interface/src/ui/overlays/Overlay.h
+++ b/interface/src/ui/overlays/Overlay.h
@@ -40,6 +40,7 @@ public:
virtual void update(float deltatime) {}
virtual void render(RenderArgs* args) = 0;
+ virtual render::ItemKey getKey();
virtual AABox getBounds() const = 0;
virtual bool supportsGetProperty() const { return true; }
@@ -132,7 +133,6 @@ private:
namespace render {
template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay);
template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay);
- template <> int payloadGetLayer(const Overlay::Pointer& overlay);
template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args);
template <> const ShapeKey shapeGetShapeKey(const Overlay::Pointer& overlay);
template <> uint32_t metaFetchMetaSubItems(const Overlay::Pointer& overlay, ItemIDs& subItems);
diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h
index 3ff782da99..3debf74f26 100644
--- a/interface/src/ui/overlays/Overlays.h
+++ b/interface/src/ui/overlays/Overlays.h
@@ -53,7 +53,7 @@ const OverlayID UNKNOWN_OVERLAY_ID = OverlayID();
* @property {number} distance - The distance from the {@link PickRay} origin to the intersection point.
* @property {Vec3} surfaceNormal - The normal of the overlay surface at the intersection point.
* @property {Vec3} intersection - The position of the intersection point.
- * @property {Object} extraInfo Additional intersection details, if available.
+ * @property {object} extraInfo Additional intersection details, if available.
*/
class RayToOverlayIntersectionResult {
public:
@@ -482,7 +482,7 @@ public slots:
/**jsdoc
* Check if there is an overlay of a given ID.
- * @function Overlays.isAddedOverly
+ * @function Overlays.isAddedOverlay
* @param {Uuid} overlayID - The ID to check.
* @returns {boolean} true
if an overlay with the given ID exists, false
otherwise.
*/
diff --git a/interface/src/ui/overlays/OverlaysPayload.cpp b/interface/src/ui/overlays/OverlaysPayload.cpp
index 185547a333..37fadef0b4 100644
--- a/interface/src/ui/overlays/OverlaysPayload.cpp
+++ b/interface/src/ui/overlays/OverlaysPayload.cpp
@@ -32,48 +32,11 @@
namespace render {
template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay) {
- auto builder = ItemKey::Builder().withTypeShape();
- if (overlay->is3D()) {
- auto overlay3D = std::static_pointer_cast(overlay);
- if (overlay3D->getDrawInFront() || overlay3D->getDrawHUDLayer()) {
- builder.withLayered();
- }
- if (overlay->isTransparent()) {
- builder.withTransparent();
- }
- } else {
- builder.withViewSpace();
- }
-
- if (!overlay->getVisible()) {
- builder.withInvisible();
- }
-
- // always visible in primary view. if isVisibleInSecondaryCamera, also draw in secondary view
- uint32_t viewTaskBits = render::ItemKey::TAG_BITS_0 |
- (overlay->getIsVisibleInSecondaryCamera() ? render::ItemKey::TAG_BITS_1 : render::ItemKey::TAG_BITS_NONE);
-
- builder.withTagBits(viewTaskBits);
-
- return builder.build();
+ return overlay->getKey();
}
template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay) {
return overlay->getBounds();
}
- template <> int payloadGetLayer(const Overlay::Pointer& overlay) {
- if (overlay->is3D()) {
- auto overlay3D = std::dynamic_pointer_cast(overlay);
- if (overlay3D->getDrawInFront()) {
- return Item::LAYER_3D_FRONT;
- } else if (overlay3D->getDrawHUDLayer()) {
- return Item::LAYER_3D_HUD;
- } else {
- return Item::LAYER_3D;
- }
- } else {
- return Item::LAYER_2D;
- }
- }
template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args) {
if (args) {
overlay->render(args);
@@ -83,7 +46,6 @@ namespace render {
return overlay->getShapeKey();
}
-
template <> uint32_t metaFetchMetaSubItems(const Overlay::Pointer& overlay, ItemIDs& subItems) {
return overlay->fetchMetaSubItems(subItems);
}
diff --git a/interface/src/ui/overlays/Text3DOverlay.cpp b/interface/src/ui/overlays/Text3DOverlay.cpp
index 9c920efb93..b128ce7df7 100644
--- a/interface/src/ui/overlays/Text3DOverlay.cpp
+++ b/interface/src/ui/overlays/Text3DOverlay.cpp
@@ -83,15 +83,6 @@ xColor Text3DOverlay::getBackgroundColor() {
return result;
}
-void Text3DOverlay::update(float deltatime) {
- if (usecTimestampNow() > _transformExpiry) {
- Transform transform = getTransform();
- applyTransformTo(transform);
- setTransform(transform);
- }
- Parent::update(deltatime);
-}
-
void Text3DOverlay::render(RenderArgs* args) {
if (!_renderVisible || !getParentVisible()) {
return; // do nothing if we're not visible
@@ -306,13 +297,4 @@ QSizeF Text3DOverlay::textSize(const QString& text) const {
float pointToWorldScale = (maxHeight / FIXED_FONT_SCALING_RATIO) * _lineHeight;
return QSizeF(extents.x, extents.y) * pointToWorldScale;
-}
-
-bool Text3DOverlay::findRayIntersection(const glm::vec3 &origin, const glm::vec3 &direction, float &distance,
- BoxFace &face, glm::vec3& surfaceNormal) {
- Transform transform = getTransform();
- applyTransformTo(transform, true);
- setTransform(transform);
- return Billboard3DOverlay::findRayIntersection(origin, direction, distance, face, surfaceNormal);
-}
-
+}
\ No newline at end of file
diff --git a/interface/src/ui/overlays/Text3DOverlay.h b/interface/src/ui/overlays/Text3DOverlay.h
index daa5fdc804..21163101d0 100644
--- a/interface/src/ui/overlays/Text3DOverlay.h
+++ b/interface/src/ui/overlays/Text3DOverlay.h
@@ -30,8 +30,6 @@ public:
~Text3DOverlay();
virtual void render(RenderArgs* args) override;
- virtual void update(float deltatime) override;
-
virtual const render::ShapeKey getShapeKey() override;
// getters
@@ -60,9 +58,6 @@ public:
QSizeF textSize(const QString& test) const; // Meters
- virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance,
- BoxFace& face, glm::vec3& surfaceNormal) override;
-
virtual Text3DOverlay* createClone() const override;
private:
diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp
index c678e3d2a2..8af818edc6 100644
--- a/interface/src/ui/overlays/Web3DOverlay.cpp
+++ b/interface/src/ui/overlays/Web3DOverlay.cpp
@@ -259,7 +259,6 @@ void Web3DOverlay::setupQmlSurface() {
_webSurface->getSurfaceContext()->setContextProperty("Web3DOverlay", this);
_webSurface->getSurfaceContext()->setContextProperty("Window", DependencyManager::get().data());
_webSurface->getSurfaceContext()->setContextProperty("Reticle", qApp->getApplicationCompositor().getReticleInterface());
- _webSurface->getSurfaceContext()->setContextProperty("desktop", DependencyManager::get()->getDesktop());
_webSurface->getSurfaceContext()->setContextProperty("HiFiAbout", AboutUtil::getInstance());
// Override min fps for tablet UI, for silky smooth scrolling
diff --git a/libraries/animation/src/AnimUtil.cpp b/libraries/animation/src/AnimUtil.cpp
index 65c605b5ba..acb90126fc 100644
--- a/libraries/animation/src/AnimUtil.cpp
+++ b/libraries/animation/src/AnimUtil.cpp
@@ -9,7 +9,9 @@
//
#include "AnimUtil.h"
-#include "GLMHelpers.h"
+#include
+#include
+#include
// TODO: use restrict keyword
// TODO: excellent candidate for simd vectorization.
@@ -107,3 +109,44 @@ AnimPose boneLookAt(const glm::vec3& target, const AnimPose& bone) {
glm::vec4(bone.trans(), 1.0f));
return AnimPose(lookAt);
}
+
+// This will attempt to determine the proper body facing of a characters body
+// assumes headRot is z-forward and y-up.
+// and returns a bodyRot that is also z-forward and y-up
+glm::quat computeBodyFacingFromHead(const glm::quat& headRot, const glm::vec3& up) {
+
+ glm::vec3 bodyUp = glm::normalize(up);
+
+ // initially take the body facing from the head.
+ glm::vec3 headUp = headRot * Vectors::UNIT_Y;
+ glm::vec3 headForward = headRot * Vectors::UNIT_Z;
+ glm::vec3 headLeft = headRot * Vectors::UNIT_X;
+ const float NOD_THRESHOLD = cosf(glm::radians(45.0f));
+ const float TILT_THRESHOLD = cosf(glm::radians(30.0f));
+
+ glm::vec3 bodyForward = headForward;
+
+ float nodDot = glm::dot(headForward, bodyUp);
+ float tiltDot = glm::dot(headLeft, bodyUp);
+
+ if (fabsf(tiltDot) < TILT_THRESHOLD) { // if we are not tilting too much
+ if (nodDot < -NOD_THRESHOLD) { // head is looking downward
+ // the body should face in the same direction as the top the head.
+ bodyForward = headUp;
+ } else if (nodDot > NOD_THRESHOLD) { // head is looking upward
+ // the body should face away from the top of the head.
+ bodyForward = -headUp;
+ }
+ }
+
+ // cancel out upward component
+ bodyForward = glm::normalize(bodyForward - nodDot * bodyUp);
+
+ glm::vec3 u, v, w;
+ generateBasisVectors(bodyForward, bodyUp, u, v, w);
+
+ // create matrix from orthogonal basis vectors
+ glm::mat4 bodyMat(glm::vec4(w, 0.0f), glm::vec4(v, 0.0f), glm::vec4(u, 0.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
+
+ return glmExtractRotation(bodyMat);
+}
diff --git a/libraries/animation/src/AnimUtil.h b/libraries/animation/src/AnimUtil.h
index f2cceb361b..3cd7f4b6fb 100644
--- a/libraries/animation/src/AnimUtil.h
+++ b/libraries/animation/src/AnimUtil.h
@@ -33,4 +33,9 @@ inline glm::quat safeLerp(const glm::quat& a, const glm::quat& b, float alpha) {
AnimPose boneLookAt(const glm::vec3& target, const AnimPose& bone);
+// This will attempt to determine the proper body facing of a characters body
+// assumes headRot is z-forward and y-up.
+// and returns a bodyRot that is also z-forward and y-up
+glm::quat computeBodyFacingFromHead(const glm::quat& headRot, const glm::vec3& up);
+
#endif
diff --git a/libraries/animation/src/AnimationCache.h b/libraries/animation/src/AnimationCache.h
index d8f8a13cde..4b0a8901f5 100644
--- a/libraries/animation/src/AnimationCache.h
+++ b/libraries/animation/src/AnimationCache.h
@@ -70,7 +70,7 @@ public:
* @function AnimationCache.prefetch
* @param {string} url - URL of the resource to prefetch.
* @param {object} [extra=null]
- * @returns {Resource}
+ * @returns {ResourceObject}
*/
/**jsdoc
@@ -79,7 +79,7 @@ public:
* @param {string} url - URL of the resource to load.
* @param {string} [fallback=""] - Fallback URL if load of the desired URL fails.
* @param {} [extra=null]
- * @returns {Resource}
+ * @returns {object}
*/
@@ -87,7 +87,7 @@ public:
* Returns animation resource for particular animation.
* @function AnimationCache.getAnimation
* @param {string} url - URL to load.
- * @returns {Resource} animation
+ * @returns {AnimationObject} animation
*/
Q_INVOKABLE AnimationPointer getAnimation(const QString& url) { return getAnimation(QUrl(url)); }
Q_INVOKABLE AnimationPointer getAnimation(const QUrl& url);
@@ -104,6 +104,17 @@ private:
Q_DECLARE_METATYPE(AnimationPointer)
+/**jsdoc
+ * @class AnimationObject
+ *
+ * @hifi-interface
+ * @hifi-client-entity
+ * @hifi-server-entity
+ * @hifi-assignment-client
+ *
+ * @property {string[]} jointNames
+ * @property {FBXAnimationFrame[]} frames
+ */
/// An animation loaded from the network.
class Animation : public Resource {
Q_OBJECT
@@ -118,9 +129,16 @@ public:
virtual bool isLoaded() const override;
-
+ /**jsdoc
+ * @function AnimationObject.getJointNames
+ * @returns {string[]}
+ */
Q_INVOKABLE QStringList getJointNames() const;
+ /**jsdoc
+ * @function AnimationObject.getFrames
+ * @returns {FBXAnimationFrame[]}
+ */
Q_INVOKABLE QVector getFrames() const;
const QVector& getFramesReference() const;
diff --git a/libraries/audio/src/Sound.h b/libraries/audio/src/Sound.h
index 69dbf5a913..4cfdac7792 100644
--- a/libraries/audio/src/Sound.h
+++ b/libraries/audio/src/Sound.h
@@ -77,6 +77,17 @@ private:
typedef QSharedPointer SharedSoundPointer;
+/**jsdoc
+ * @class SoundObject
+ *
+ * @hifi-interface
+ * @hifi-client-entity
+ * @hifi-server-entity
+ * @hifi-assignment-client
+ *
+ * @property {boolean} downloaded
+ * @property {number} duration
+ */
class SoundScriptingInterface : public QObject {
Q_OBJECT
@@ -90,6 +101,10 @@ public:
bool isReady() const { return _sound->isReady(); }
float getDuration() { return _sound->getDuration(); }
+/**jsdoc
+ * @function SoundObject.ready
+ * @returns {Signal}
+ */
signals:
void ready();
diff --git a/libraries/audio/src/SoundCache.h b/libraries/audio/src/SoundCache.h
index 347f324353..4352b1d459 100644
--- a/libraries/audio/src/SoundCache.h
+++ b/libraries/audio/src/SoundCache.h
@@ -64,7 +64,7 @@ public:
* @function SoundCache.prefetch
* @param {string} url - URL of the resource to prefetch.
* @param {object} [extra=null]
- * @returns {Resource}
+ * @returns {ResourceObject}
*/
/**jsdoc
@@ -73,14 +73,14 @@ public:
* @param {string} url - URL of the resource to load.
* @param {string} [fallback=""] - Fallback URL if load of the desired URL fails.
* @param {} [extra=null]
- * @returns {Resource}
+ * @returns {object}
*/
/**jsdoc
* @function SoundCache.getSound
* @param {string} url
- * @returns {object}
+ * @returns {SoundObject}
*/
Q_INVOKABLE SharedSoundPointer getSound(const QUrl& url);
protected:
diff --git a/libraries/auto-updater/src/AutoUpdater.cpp b/libraries/auto-updater/src/AutoUpdater.cpp
index e58ac067a6..6749cd9e10 100644
--- a/libraries/auto-updater/src/AutoUpdater.cpp
+++ b/libraries/auto-updater/src/AutoUpdater.cpp
@@ -11,6 +11,8 @@
#include "AutoUpdater.h"
+#include
+
#include
#include
#include
@@ -157,10 +159,8 @@ void AutoUpdater::parseLatestVersionData() {
}
void AutoUpdater::checkVersionAndNotify() {
- if (QCoreApplication::applicationVersion() == "dev" ||
- QCoreApplication::applicationVersion().contains("PR") ||
- _builds.empty()) {
- // No version checking is required in dev builds or when no build
+ if (BuildInfo::BUILD_TYPE != BuildInfo::BuildType::Stable || _builds.empty()) {
+ // No version checking is required in nightly/PR/dev builds or when no build
// data was found for the platform
return;
}
@@ -196,4 +196,4 @@ void AutoUpdater::appendBuildData(int versionNumber,
thisBuildDetails.insert("pullRequestNumber", pullRequestNumber);
_builds.insert(versionNumber, thisBuildDetails);
-}
\ No newline at end of file
+}
diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp
index da829b23e4..9682c81697 100644
--- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp
+++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.cpp
@@ -52,10 +52,15 @@ const glm::vec3 HAND_TO_PALM_OFFSET(0.0f, 0.12f, 0.08f);
namespace render {
template <> const ItemKey payloadGetKey(const AvatarSharedPointer& avatar) {
- return ItemKey::Builder::opaqueShape().withTypeMeta().withTagBits(ItemKey::TAG_BITS_0 | ItemKey::TAG_BITS_1).withMetaCullGroup();
+ ItemKey::Builder keyBuilder = ItemKey::Builder::opaqueShape().withTypeMeta().withTagBits(render::hifi::TAG_ALL_VIEWS).withMetaCullGroup();
+ auto avatarPtr = static_pointer_cast(avatar);
+ if (!avatarPtr->getEnableMeshVisible()) {
+ keyBuilder.withInvisible();
+ }
+ return keyBuilder.build();
}
template <> const Item::Bound payloadGetBound(const AvatarSharedPointer& avatar) {
- return static_pointer_cast(avatar)->getBounds();
+ return static_pointer_cast(avatar)->getRenderBounds();
}
template <> void payloadRender(const AvatarSharedPointer& avatar, RenderArgs* args) {
auto avatarPtr = static_pointer_cast(avatar);
@@ -164,6 +169,11 @@ AABox Avatar::getBounds() const {
return _skeletonModel->getRenderableMeshBound();
}
+
+AABox Avatar::getRenderBounds() const {
+ return _renderBound;
+}
+
void Avatar::animateScaleChanges(float deltaTime) {
if (_isAnimatingScale) {
@@ -569,16 +579,26 @@ static TextRenderer3D* textRenderer(TextRendererType type) {
void Avatar::addToScene(AvatarSharedPointer self, const render::ScenePointer& scene, render::Transaction& transaction) {
auto avatarPayload = new render::Payload(self);
- auto avatarPayloadPointer = Avatar::PayloadPointer(avatarPayload);
-
+ auto avatarPayloadPointer = std::shared_ptr>(avatarPayload);
if (_renderItemID == render::Item::INVALID_ITEM_ID) {
_renderItemID = scene->allocateID();
}
+ // INitialize the _render bound as we are creating the avatar render item
+ _renderBound = getBounds();
transaction.resetItem(_renderItemID, avatarPayloadPointer);
_skeletonModel->addToScene(scene, transaction);
+ _skeletonModel->setTagMask(render::hifi::TAG_ALL_VIEWS);
+ _skeletonModel->setGroupCulled(true);
+ _skeletonModel->setCanCastShadow(true);
+ _skeletonModel->setVisibleInScene(_isMeshVisible, scene);
+
processMaterials();
for (auto& attachmentModel : _attachmentModels) {
attachmentModel->addToScene(scene, transaction);
+ attachmentModel->setTagMask(render::hifi::TAG_ALL_VIEWS);
+ attachmentModel->setGroupCulled(false);
+ attachmentModel->setCanCastShadow(true);
+ attachmentModel->setVisibleInScene(_isMeshVisible, scene);
}
_mustFadeIn = true;
@@ -637,7 +657,15 @@ void Avatar::removeFromScene(AvatarSharedPointer self, const render::ScenePointe
void Avatar::updateRenderItem(render::Transaction& transaction) {
if (render::Item::isValidID(_renderItemID)) {
- transaction.updateItem>(_renderItemID, [](render::Payload& p) {});
+ auto renderBound = getBounds();
+ transaction.updateItem(_renderItemID,
+ [renderBound](AvatarData& avatar) {
+ auto avatarPtr = dynamic_cast(&avatar);
+ if (avatarPtr) {
+ avatarPtr->_renderBound = renderBound;
+ }
+ }
+ );
}
}
@@ -759,6 +787,18 @@ void Avatar::render(RenderArgs* renderArgs) {
}
}
+
+void Avatar::setEnableMeshVisible(bool isEnabled) {
+ if (_isMeshVisible != isEnabled) {
+ _isMeshVisible = isEnabled;
+ _needMeshVisibleSwitch = true;
+ }
+}
+
+bool Avatar::getEnableMeshVisible() const {
+ return _isMeshVisible;
+}
+
void Avatar::fixupModelsInScene(const render::ScenePointer& scene) {
bool canTryFade{ false };
@@ -770,6 +810,12 @@ void Avatar::fixupModelsInScene(const render::ScenePointer& scene) {
if (_skeletonModel->isRenderable() && _skeletonModel->needsFixupInScene()) {
_skeletonModel->removeFromScene(scene, transaction);
_skeletonModel->addToScene(scene, transaction);
+
+ _skeletonModel->setTagMask(render::hifi::TAG_ALL_VIEWS);
+ _skeletonModel->setGroupCulled(true);
+ _skeletonModel->setCanCastShadow(true);
+ _skeletonModel->setVisibleInScene(_isMeshVisible, scene);
+
processMaterials();
canTryFade = true;
_isAnimatingScale = true;
@@ -778,9 +824,25 @@ void Avatar::fixupModelsInScene(const render::ScenePointer& scene) {
if (attachmentModel->isRenderable() && attachmentModel->needsFixupInScene()) {
attachmentModel->removeFromScene(scene, transaction);
attachmentModel->addToScene(scene, transaction);
+
+ attachmentModel->setTagMask(render::hifi::TAG_ALL_VIEWS);
+ attachmentModel->setGroupCulled(false);
+ attachmentModel->setCanCastShadow(true);
+ attachmentModel->setVisibleInScene(_isMeshVisible, scene);
}
}
+ if (_needMeshVisibleSwitch) {
+ _skeletonModel->setVisibleInScene(_isMeshVisible, scene);
+ for (auto attachmentModel : _attachmentModels) {
+ if (attachmentModel->isRenderable()) {
+ attachmentModel->setVisibleInScene(_isMeshVisible, scene);
+ }
+ }
+ updateRenderItem(transaction);
+ _needMeshVisibleSwitch = false;
+ }
+
if (_mustFadeIn && canTryFade) {
// Do it now to be sure all the sub items are ready and the fade is sent to them too
fade(transaction, render::Transition::USER_ENTER_DOMAIN);
@@ -799,6 +861,7 @@ bool Avatar::shouldRenderHead(const RenderArgs* renderArgs) const {
return true;
}
+// virtual
void Avatar::simulateAttachments(float deltaTime) {
assert(_attachmentModels.size() == _attachmentModelsTexturesLoaded.size());
PerformanceTimer perfTimer("attachments");
@@ -1481,14 +1544,12 @@ void Avatar::updateDisplayNameAlpha(bool showDisplayName) {
}
}
+// virtual
void Avatar::computeShapeInfo(ShapeInfo& shapeInfo) {
float uniformScale = getModelScale();
- float radius = uniformScale * _skeletonModel->getBoundingCapsuleRadius();
- float height = uniformScale * _skeletonModel->getBoundingCapsuleHeight();
- shapeInfo.setCapsuleY(radius, 0.5f * height);
-
- glm::vec3 offset = uniformScale * _skeletonModel->getBoundingCapsuleOffset();
- shapeInfo.setOffset(offset);
+ shapeInfo.setCapsuleY(uniformScale * _skeletonModel->getBoundingCapsuleRadius(),
+ 0.5f * uniformScale * _skeletonModel->getBoundingCapsuleHeight());
+ shapeInfo.setOffset(uniformScale * _skeletonModel->getBoundingCapsuleOffset());
}
void Avatar::getCapsule(glm::vec3& start, glm::vec3& end, float& radius) {
@@ -1511,8 +1572,9 @@ float Avatar::computeMass() {
return _density * TWO_PI * radius * radius * (glm::length(end - start) + 2.0f * radius / 3.0f);
}
+// virtual
void Avatar::rebuildCollisionShape() {
- addPhysicsFlags(Simulation::DIRTY_SHAPE | Simulation::DIRTY_MASS);
+ addPhysicsFlags(Simulation::DIRTY_SHAPE);
}
void Avatar::setPhysicsCallback(AvatarPhysicsCallback cb) {
diff --git a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h
index 01114b5f6d..10c1d9ead2 100644
--- a/libraries/avatars-renderer/src/avatars-renderer/Avatar.h
+++ b/libraries/avatars-renderer/src/avatars-renderer/Avatar.h
@@ -74,7 +74,6 @@ public:
virtual void instantiableAvatar() = 0;
typedef render::Payload Payload;
- typedef std::shared_ptr PayloadPointer;
void init();
void updateAvatarEntities();
@@ -292,7 +291,7 @@ public:
*/
/**jsdoc
* Information about a single joint in an Avatar's skeleton hierarchy.
- * @typedef MyAvatar.SkeletonJoint
+ * @typedef {object} MyAvatar.SkeletonJoint
* @property {string} name - Joint name.
* @property {number} index - Joint index.
* @property {number} parentIndex - Index of this joint's parent (-1 if no parent).
@@ -322,6 +321,7 @@ public:
bool hasNewJointData() const { return _hasNewJointData; }
float getBoundingRadius() const;
+ AABox getRenderBounds() const; // THis call is accessible from rendering thread only to report the bounding box of the avatar during the frame.
void addToScene(AvatarSharedPointer self, const render::ScenePointer& scene);
void ensureInScene(AvatarSharedPointer self, const render::ScenePointer& scene);
@@ -356,6 +356,10 @@ public:
virtual void setAvatarEntityDataChanged(bool value) override;
+ // Show hide the model representation of the avatar
+ virtual void setEnableMeshVisible(bool isEnabled);
+ virtual bool getEnableMeshVisible() const;
+
void addMaterial(graphics::MaterialLayer material, const std::string& parentMaterialName) override;
void removeMaterial(graphics::MaterialPointer material, const std::string& parentMaterialName) override;
@@ -532,6 +536,10 @@ protected:
std::mutex _materialsLock;
void processMaterials();
+
+ AABox _renderBound;
+ bool _isMeshVisible{ true };
+ bool _needMeshVisibleSwitch{ true };
};
#endif // hifi_Avatar_h
diff --git a/libraries/avatars-renderer/src/avatars-renderer/Head.cpp b/libraries/avatars-renderer/src/avatars-renderer/Head.cpp
index 256b3bf8a6..5800c1404b 100644
--- a/libraries/avatars-renderer/src/avatars-renderer/Head.cpp
+++ b/libraries/avatars-renderer/src/avatars-renderer/Head.cpp
@@ -20,6 +20,7 @@
#include
#include
#include
+#include "Logging.h"
#include "Avatar.h"
@@ -58,25 +59,30 @@ void Head::simulate(float deltaTime) {
_longTermAverageLoudness = glm::mix(_longTermAverageLoudness, _averageLoudness, glm::min(deltaTime / AUDIO_LONG_TERM_AVERAGING_SECS, 1.0f));
}
- if (!_isFaceTrackerConnected) {
- if (!_isEyeTrackerConnected) {
- // Update eye saccades
- const float AVERAGE_MICROSACCADE_INTERVAL = 1.0f;
- const float AVERAGE_SACCADE_INTERVAL = 6.0f;
- const float MICROSACCADE_MAGNITUDE = 0.002f;
- const float SACCADE_MAGNITUDE = 0.04f;
- const float NOMINAL_FRAME_RATE = 60.0f;
+ if (!_isEyeTrackerConnected) {
+ // Update eye saccades
+ const float AVERAGE_MICROSACCADE_INTERVAL = 1.0f;
+ const float AVERAGE_SACCADE_INTERVAL = 6.0f;
+ const float MICROSACCADE_MAGNITUDE = 0.002f;
+ const float SACCADE_MAGNITUDE = 0.04f;
+ const float NOMINAL_FRAME_RATE = 60.0f;
- if (randFloat() < deltaTime / AVERAGE_MICROSACCADE_INTERVAL) {
- _saccadeTarget = MICROSACCADE_MAGNITUDE * randVector();
- } else if (randFloat() < deltaTime / AVERAGE_SACCADE_INTERVAL) {
- _saccadeTarget = SACCADE_MAGNITUDE * randVector();
- }
- _saccade += (_saccadeTarget - _saccade) * pow(0.5f, NOMINAL_FRAME_RATE * deltaTime);
- } else {
- _saccade = glm::vec3();
+ if (randFloat() < deltaTime / AVERAGE_MICROSACCADE_INTERVAL) {
+ _saccadeTarget = MICROSACCADE_MAGNITUDE * randVector();
+ } else if (randFloat() < deltaTime / AVERAGE_SACCADE_INTERVAL) {
+ _saccadeTarget = SACCADE_MAGNITUDE * randVector();
}
+ _saccade += (_saccadeTarget - _saccade) * pow(0.5f, NOMINAL_FRAME_RATE * deltaTime);
+ } else {
+ _saccade = glm::vec3();
+ }
+ const float BLINK_SPEED = 10.0f;
+ const float BLINK_SPEED_VARIABILITY = 1.0f;
+ const float BLINK_START_VARIABILITY = 0.25f;
+ const float FULLY_OPEN = 0.0f;
+ const float FULLY_CLOSED = 1.0f;
+ if (getHasProceduralBlinkFaceMovement()) {
// Detect transition from talking to not; force blink after that and a delay
bool forceBlink = false;
const float TALKING_LOUDNESS = 100.0f;
@@ -88,29 +94,12 @@ void Head::simulate(float deltaTime) {
forceBlink = true;
}
- // Update audio attack data for facial animation (eyebrows and mouth)
- float audioAttackAveragingRate = (10.0f - deltaTime * NORMAL_HZ) / 10.0f; // --> 0.9 at 60 Hz
- _audioAttack = audioAttackAveragingRate * _audioAttack +
- (1.0f - audioAttackAveragingRate) * fabs((audioLoudness - _longTermAverageLoudness) - _lastLoudness);
- _lastLoudness = (audioLoudness - _longTermAverageLoudness);
-
- const float BROW_LIFT_THRESHOLD = 100.0f;
- if (_audioAttack > BROW_LIFT_THRESHOLD) {
- _browAudioLift += sqrtf(_audioAttack) * 0.01f;
- }
- _browAudioLift = glm::clamp(_browAudioLift *= 0.7f, 0.0f, 1.0f);
-
- const float BLINK_SPEED = 10.0f;
- const float BLINK_SPEED_VARIABILITY = 1.0f;
- const float BLINK_START_VARIABILITY = 0.25f;
- const float FULLY_OPEN = 0.0f;
- const float FULLY_CLOSED = 1.0f;
if (_leftEyeBlinkVelocity == 0.0f && _rightEyeBlinkVelocity == 0.0f) {
// no blinking when brows are raised; blink less with increasing loudness
const float BASE_BLINK_RATE = 15.0f / 60.0f;
const float ROOT_LOUDNESS_TO_BLINK_INTERVAL = 0.25f;
if (forceBlink || (_browAudioLift < EPSILON && shouldDo(glm::max(1.0f, sqrt(fabs(_averageLoudness - _longTermAverageLoudness)) *
- ROOT_LOUDNESS_TO_BLINK_INTERVAL) / BASE_BLINK_RATE, deltaTime))) {
+ ROOT_LOUDNESS_TO_BLINK_INTERVAL) / BASE_BLINK_RATE, deltaTime))) {
_leftEyeBlinkVelocity = BLINK_SPEED + randFloat() * BLINK_SPEED_VARIABILITY;
_rightEyeBlinkVelocity = BLINK_SPEED + randFloat() * BLINK_SPEED_VARIABILITY;
if (randFloat() < 0.5f) {
@@ -136,22 +125,45 @@ void Head::simulate(float deltaTime) {
_rightEyeBlinkVelocity = 0.0f;
}
}
+ } else {
+ _rightEyeBlink = FULLY_OPEN;
+ _leftEyeBlink = FULLY_OPEN;
+ }
// use data to update fake Faceshift blendshape coefficients
+ if (getHasAudioEnabledFaceMovement()) {
+ // Update audio attack data for facial animation (eyebrows and mouth)
+ float audioAttackAveragingRate = (10.0f - deltaTime * NORMAL_HZ) / 10.0f; // --> 0.9 at 60 Hz
+ _audioAttack = audioAttackAveragingRate * _audioAttack +
+ (1.0f - audioAttackAveragingRate) * fabs((audioLoudness - _longTermAverageLoudness) - _lastLoudness);
+ _lastLoudness = (audioLoudness - _longTermAverageLoudness);
+ const float BROW_LIFT_THRESHOLD = 100.0f;
+ if (_audioAttack > BROW_LIFT_THRESHOLD) {
+ _browAudioLift += sqrtf(_audioAttack) * 0.01f;
+ }
+ _browAudioLift = glm::clamp(_browAudioLift *= 0.7f, 0.0f, 1.0f);
calculateMouthShapes(deltaTime);
- FaceTracker::updateFakeCoefficients(_leftEyeBlink,
- _rightEyeBlink,
- _browAudioLift,
- _audioJawOpen,
- _mouth2,
- _mouth3,
- _mouth4,
- _transientBlendshapeCoefficients);
-
- applyEyelidOffset(getOrientation());
} else {
- _saccade = glm::vec3();
+ _audioJawOpen = 0.0f;
+ _browAudioLift = 0.0f;
+ _mouth2 = 0.0f;
+ _mouth3 = 0.0f;
+ _mouth4 = 0.0f;
+ _mouthTime = 0.0f;
+ }
+
+ FaceTracker::updateFakeCoefficients(_leftEyeBlink,
+ _rightEyeBlink,
+ _browAudioLift,
+ _audioJawOpen,
+ _mouth2,
+ _mouth3,
+ _mouth4,
+ _transientBlendshapeCoefficients);
+
+ if (getHasProceduralEyeFaceMovement()) {
+ applyEyelidOffset(getOrientation());
}
_leftEyePosition = _rightEyePosition = getPosition();
diff --git a/libraries/avatars-renderer/src/avatars-renderer/SkeletonModel.cpp b/libraries/avatars-renderer/src/avatars-renderer/SkeletonModel.cpp
index 428f86f0ab..de8c02f10e 100644
--- a/libraries/avatars-renderer/src/avatars-renderer/SkeletonModel.cpp
+++ b/libraries/avatars-renderer/src/avatars-renderer/SkeletonModel.cpp
@@ -35,7 +35,7 @@ SkeletonModel::SkeletonModel(Avatar* owningAvatar, QObject* parent) :
_useDualQuaternionSkinning = true;
// Avatars all cast shadow
- _canCastShadow = true;
+ setCanCastShadow(true);
assert(_owningAvatar);
}
diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp
index 7a28686f8c..b5186ba8f4 100644
--- a/libraries/avatars/src/AvatarData.cpp
+++ b/libraries/avatars/src/AvatarData.cpp
@@ -300,14 +300,15 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
tranlationChangedSince(lastSentTime) ||
parentInfoChangedSince(lastSentTime));
- hasFaceTrackerInfo = !dropFaceTracking && hasFaceTracker() && (sendAll || faceTrackerInfoChangedSince(lastSentTime));
+ hasFaceTrackerInfo = !dropFaceTracking && (hasFaceTracker() || getHasScriptedBlendshapes()) &&
+ (sendAll || faceTrackerInfoChangedSince(lastSentTime));
hasJointData = sendAll || !sendMinimum;
hasJointDefaultPoseFlags = hasJointData;
}
const size_t byteArraySize = AvatarDataPacket::MAX_CONSTANT_HEADER_SIZE +
- (hasFaceTrackerInfo ? AvatarDataPacket::maxFaceTrackerInfoSize(_headData->getNumSummedBlendshapeCoefficients()) : 0) +
+ (hasFaceTrackerInfo ? AvatarDataPacket::maxFaceTrackerInfoSize(_headData->getBlendshapeCoefficients().size()) : 0) +
(hasJointData ? AvatarDataPacket::maxJointDataSize(_jointData.size()) : 0) +
(hasJointDefaultPoseFlags ? AvatarDataPacket::maxJointDefaultPoseFlagsSize(_jointData.size()) : 0);
@@ -442,7 +443,7 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
auto startSection = destinationBuffer;
auto data = reinterpret_cast(destinationBuffer);
- uint8_t flags { 0 };
+ uint16_t flags { 0 };
setSemiNibbleAt(flags, KEY_STATE_START_BIT, _keyState);
@@ -450,20 +451,33 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
bool isFingerPointing = _handState & IS_FINGER_POINTING_FLAG;
setSemiNibbleAt(flags, HAND_STATE_START_BIT, _handState & ~IS_FINGER_POINTING_FLAG);
if (isFingerPointing) {
- setAtBit(flags, HAND_STATE_FINGER_POINTING_BIT);
+ setAtBit16(flags, HAND_STATE_FINGER_POINTING_BIT);
}
// face tracker state
if (_headData->_isFaceTrackerConnected) {
- setAtBit(flags, IS_FACE_TRACKER_CONNECTED);
+ setAtBit16(flags, IS_FACE_TRACKER_CONNECTED);
}
// eye tracker state
if (_headData->_isEyeTrackerConnected) {
- setAtBit(flags, IS_EYE_TRACKER_CONNECTED);
+ setAtBit16(flags, IS_EYE_TRACKER_CONNECTED);
}
// referential state
if (!parentID.isNull()) {
- setAtBit(flags, HAS_REFERENTIAL);
+ setAtBit16(flags, HAS_REFERENTIAL);
}
+ // audio face movement
+ if (_headData->getHasAudioEnabledFaceMovement()) {
+ setAtBit16(flags, AUDIO_ENABLED_FACE_MOVEMENT);
+ }
+ // procedural eye face movement
+ if (_headData->getHasProceduralEyeFaceMovement()) {
+ setAtBit16(flags, PROCEDURAL_EYE_FACE_MOVEMENT);
+ }
+ // procedural blink face movement
+ if (_headData->getHasProceduralBlinkFaceMovement()) {
+ setAtBit16(flags, PROCEDURAL_BLINK_FACE_MOVEMENT);
+ }
+
data->flags = flags;
destinationBuffer += sizeof(AvatarDataPacket::AdditionalFlags);
@@ -506,8 +520,9 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
if (hasFaceTrackerInfo) {
auto startSection = destinationBuffer;
auto faceTrackerInfo = reinterpret_cast(destinationBuffer);
- const auto& blendshapeCoefficients = _headData->getSummedBlendshapeCoefficients();
-
+ const auto& blendshapeCoefficients = _headData->getBlendshapeCoefficients();
+ // note: we don't use the blink and average loudness, we just use the numBlendShapes and
+ // compute the procedural info on the client side.
faceTrackerInfo->leftEyeBlink = _headData->_leftEyeBlink;
faceTrackerInfo->rightEyeBlink = _headData->_rightEyeBlink;
faceTrackerInfo->averageLoudness = _headData->_averageLoudness;
@@ -972,7 +987,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
PACKET_READ_CHECK(AdditionalFlags, sizeof(AvatarDataPacket::AdditionalFlags));
auto data = reinterpret_cast(sourceBuffer);
- uint8_t bitItems = data->flags;
+ uint16_t bitItems = data->flags;
// key state, stored as a semi-nibble in the bitItems
auto newKeyState = (KeyState)getSemiNibbleAt(bitItems, KEY_STATE_START_BIT);
@@ -980,26 +995,38 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
// hand state, stored as a semi-nibble plus a bit in the bitItems
// we store the hand state as well as other items in a shared bitset. The hand state is an octal, but is split
// into two sections to maintain backward compatibility. The bits are ordered as such (0-7 left to right).
- // +---+-----+-----+--+
- // |x,x|H0,H1|x,x,x|H2|
- // +---+-----+-----+--+
+ // AA 6/1/18 added three more flags bits 8,9, and 10 for procedural audio, blink, and eye saccade enabled
+ // +---+-----+-----+--+--+--+--+-----+
+ // |x,x|H0,H1|x,x,x|H2|Au|Bl|Ey|xxxxx|
+ // +---+-----+-----+--+--+--+--+-----+
// Hand state - H0,H1,H2 is found in the 3rd, 4th, and 8th bits
auto newHandState = getSemiNibbleAt(bitItems, HAND_STATE_START_BIT)
- + (oneAtBit(bitItems, HAND_STATE_FINGER_POINTING_BIT) ? IS_FINGER_POINTING_FLAG : 0);
+ + (oneAtBit16(bitItems, HAND_STATE_FINGER_POINTING_BIT) ? IS_FINGER_POINTING_FLAG : 0);
- auto newFaceTrackerConnected = oneAtBit(bitItems, IS_FACE_TRACKER_CONNECTED);
- auto newEyeTrackerConnected = oneAtBit(bitItems, IS_EYE_TRACKER_CONNECTED);
+ auto newFaceTrackerConnected = oneAtBit16(bitItems, IS_FACE_TRACKER_CONNECTED);
+ auto newEyeTrackerConnected = oneAtBit16(bitItems, IS_EYE_TRACKER_CONNECTED);
+ auto newHasAudioEnabledFaceMovement = oneAtBit16(bitItems, AUDIO_ENABLED_FACE_MOVEMENT);
+ auto newHasProceduralEyeFaceMovement = oneAtBit16(bitItems, PROCEDURAL_EYE_FACE_MOVEMENT);
+ auto newHasProceduralBlinkFaceMovement = oneAtBit16(bitItems, PROCEDURAL_BLINK_FACE_MOVEMENT);
+
+
bool keyStateChanged = (_keyState != newKeyState);
bool handStateChanged = (_handState != newHandState);
bool faceStateChanged = (_headData->_isFaceTrackerConnected != newFaceTrackerConnected);
bool eyeStateChanged = (_headData->_isEyeTrackerConnected != newEyeTrackerConnected);
- bool somethingChanged = keyStateChanged || handStateChanged || faceStateChanged || eyeStateChanged;
+ bool audioEnableFaceMovementChanged = (_headData->getHasAudioEnabledFaceMovement() != newHasAudioEnabledFaceMovement);
+ bool proceduralEyeFaceMovementChanged = (_headData->getHasProceduralEyeFaceMovement() != newHasProceduralEyeFaceMovement);
+ bool proceduralBlinkFaceMovementChanged = (_headData->getHasProceduralBlinkFaceMovement() != newHasProceduralBlinkFaceMovement);
+ bool somethingChanged = keyStateChanged || handStateChanged || faceStateChanged || eyeStateChanged || audioEnableFaceMovementChanged || proceduralEyeFaceMovementChanged || proceduralBlinkFaceMovementChanged;
_keyState = newKeyState;
_handState = newHandState;
_headData->_isFaceTrackerConnected = newFaceTrackerConnected;
_headData->_isEyeTrackerConnected = newEyeTrackerConnected;
+ _headData->setHasAudioEnabledFaceMovement(newHasAudioEnabledFaceMovement);
+ _headData->setHasProceduralEyeFaceMovement(newHasProceduralEyeFaceMovement);
+ _headData->setHasProceduralBlinkFaceMovement(newHasProceduralBlinkFaceMovement);
sourceBuffer += sizeof(AvatarDataPacket::AdditionalFlags);
@@ -1060,23 +1087,21 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
PACKET_READ_CHECK(FaceTrackerInfo, sizeof(AvatarDataPacket::FaceTrackerInfo));
auto faceTrackerInfo = reinterpret_cast(sourceBuffer);
- sourceBuffer += sizeof(AvatarDataPacket::FaceTrackerInfo);
-
- _headData->_leftEyeBlink = faceTrackerInfo->leftEyeBlink;
- _headData->_rightEyeBlink = faceTrackerInfo->rightEyeBlink;
- _headData->_averageLoudness = faceTrackerInfo->averageLoudness;
- _headData->_browAudioLift = faceTrackerInfo->browAudioLift;
-
int numCoefficients = faceTrackerInfo->numBlendshapeCoefficients;
const int coefficientsSize = sizeof(float) * numCoefficients;
+ sourceBuffer += sizeof(AvatarDataPacket::FaceTrackerInfo);
+
PACKET_READ_CHECK(FaceTrackerCoefficients, coefficientsSize);
_headData->_blendshapeCoefficients.resize(numCoefficients); // make sure there's room for the copy!
- _headData->_transientBlendshapeCoefficients.resize(numCoefficients);
+ //only copy the blendshapes to headData, not the procedural face info
memcpy(_headData->_blendshapeCoefficients.data(), sourceBuffer, coefficientsSize);
sourceBuffer += coefficientsSize;
+
int numBytesRead = sourceBuffer - startSection;
_faceTrackerRate.increment(numBytesRead);
_faceTrackerUpdateRate.increment();
+ } else {
+ _headData->_blendshapeCoefficients.fill(0, _headData->_blendshapeCoefficients.size());
}
if (hasJointData) {
@@ -2363,7 +2388,7 @@ glm::vec3 AvatarData::getAbsoluteJointTranslationInObjectFrame(int index) const
}
/**jsdoc
- * @typedef AttachmentData
+ * @typedef {object} AttachmentData
* @property {string} modelUrl
* @property {string} jointName
* @property {Vec3} translation
diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h
index 62a14ec51e..51b3257ba2 100644
--- a/libraries/avatars/src/AvatarData.h
+++ b/libraries/avatars/src/AvatarData.h
@@ -79,20 +79,30 @@ const quint32 AVATAR_MOTION_SCRIPTABLE_BITS =
// Bitset of state flags - we store the key state, hand state, Faceshift, eye tracking, and existence of
// referential data in this bit set. The hand state is an octal, but is split into two sections to maintain
// backward compatibility. The bits are ordered as such (0-7 left to right).
-// +-----+-----+-+-+-+--+
-// |K0,K1|H0,H1|F|E|R|H2|
-// +-----+-----+-+-+-+--+
+// AA 6/1/18 added three more flags bits 8,9, and 10 for procedural audio, blink, and eye saccade enabled
+//
+// +-----+-----+-+-+-+--+--+--+--+-----+
+// |K0,K1|H0,H1|F|E|R|H2|Au|Bl|Ey|xxxxx|
+// +-----+-----+-+-+-+--+--+--+--+-----+
+//
// Key state - K0,K1 is found in the 1st and 2nd bits
// Hand state - H0,H1,H2 is found in the 3rd, 4th, and 8th bits
// Face tracker - F is found in the 5th bit
// Eye tracker - E is found in the 6th bit
// Referential Data - R is found in the 7th bit
+// Procedural audio to mouth movement is enabled 8th bit
+// Procedural Blink is enabled 9th bit
+// Procedural Eyelid is enabled 10th bit
+
const int KEY_STATE_START_BIT = 0; // 1st and 2nd bits
const int HAND_STATE_START_BIT = 2; // 3rd and 4th bits
const int IS_FACE_TRACKER_CONNECTED = 4; // 5th bit
const int IS_EYE_TRACKER_CONNECTED = 5; // 6th bit (was CHAT_CIRCLING)
const int HAS_REFERENTIAL = 6; // 7th bit
const int HAND_STATE_FINGER_POINTING_BIT = 7; // 8th bit
+const int AUDIO_ENABLED_FACE_MOVEMENT = 8; // 9th bit
+const int PROCEDURAL_EYE_FACE_MOVEMENT = 9; // 10th bit
+const int PROCEDURAL_BLINK_FACE_MOVEMENT = 10; // 11th bit
const char HAND_STATE_NULL = 0;
@@ -200,9 +210,9 @@ namespace AvatarDataPacket {
static_assert(sizeof(SensorToWorldMatrix) == SENSOR_TO_WORLD_SIZE, "AvatarDataPacket::SensorToWorldMatrix size doesn't match.");
PACKED_BEGIN struct AdditionalFlags {
- uint8_t flags; // additional flags: hand state, key state, eye tracking
+ uint16_t flags; // additional flags: hand state, key state, eye tracking
} PACKED_END;
- const size_t ADDITIONAL_FLAGS_SIZE = 1;
+ const size_t ADDITIONAL_FLAGS_SIZE = 2;
static_assert(sizeof(AdditionalFlags) == ADDITIONAL_FLAGS_SIZE, "AvatarDataPacket::AdditionalFlags size doesn't match.");
// only present if HAS_REFERENTIAL flag is set in AvatarInfo.flags
@@ -501,6 +511,11 @@ public:
float getDomainLimitedScale() const;
+ virtual bool getHasScriptedBlendshapes() const { return false; }
+ virtual bool getHasProceduralBlinkFaceMovement() const { return true; }
+ virtual bool getHasProceduralEyeFaceMovement() const { return true; }
+ virtual bool getHasAudioEnabledFaceMovement() const { return false; }
+
/**jsdoc
* Returns the minimum scale allowed for this avatar in the current domain.
* This value can change as the user changes avatars or when changing domains.
@@ -578,8 +593,7 @@ public:
* @param {Quat} rotation - The rotation of the joint relative to its parent.
* @param {Vec3} translation - The translation of the joint relative to its parent.
* @example Set your avatar to it's default T-pose for a while.
- *
- *
+ *
* // Set all joint translations and rotations to defaults.
* var i, length, rotation, translation;
* for (i = 0, length = MyAvatar.getJointNames().length; i < length; i++) {
@@ -680,8 +694,7 @@ public:
* @param {string} name - The name of the joint.
* @param {Quat} rotation - The rotation of the joint relative to its parent.
* @example Set your avatar to its default T-pose then rotate its right arm.
- *
+ *
* // Set all joint translations and rotations to defaults.
* var i, length, rotation, translation;
* for (i = 0, length = MyAvatar.getJointNames().length; i < length; i++) {
@@ -713,8 +726,7 @@ public:
* @param {Vec3} translation - The translation of the joint relative to its parent.
* @example Stretch your avatar's neck. Depending on the avatar you are using, you will either see a gap between
* the head and body or you will see the neck stretched.
- *
+ *
* // Stretch your avatar's neck.
* MyAvatar.setJointTranslation("Neck", { x: 0, y: 25, z: 0 });
*
@@ -798,8 +810,7 @@ public:
* @param {Quat[]} jointRotations - The rotations for all joints in the avatar. The values are in the same order as the
* array returned by {@link MyAvatar.getJointNames} or {@link Avatar.getJointNames}.
* @example Set your avatar to its default T-pose then rotate its right arm.
- *
- *
+ *
* // Set all joint translations and rotations to defaults.
* var i, length, rotation, translation;
* for (i = 0, length = MyAvatar.getJointNames().length; i < length; i++) {
diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp
index 829c98a418..974ae92432 100644
--- a/libraries/avatars/src/AvatarHashMap.cpp
+++ b/libraries/avatars/src/AvatarHashMap.cpp
@@ -82,6 +82,7 @@ AvatarSharedPointer AvatarHashMap::addAvatar(const QUuid& sessionUUID, const QWe
avatar->setSessionUUID(sessionUUID);
avatar->setOwningAvatarMixer(mixerWeakPointer);
+ // addAvatar is only called from newOrExistingAvatar, which already locks _hashLock
_avatarHash.insert(sessionUUID, avatar);
emit avatarAddedEvent(sessionUUID);
diff --git a/libraries/avatars/src/AvatarHashMap.h b/libraries/avatars/src/AvatarHashMap.h
index 6747025de0..ef6f7845eb 100644
--- a/libraries/avatars/src/AvatarHashMap.h
+++ b/libraries/avatars/src/AvatarHashMap.h
@@ -46,7 +46,7 @@ class AvatarHashMap : public QObject, public Dependency {
public:
AvatarHash getHashCopy() { QReadLocker lock(&_hashLock); return _avatarHash; }
const AvatarHash getHashCopy() const { QReadLocker lock(&_hashLock); return _avatarHash; }
- int size() { return _avatarHash.size(); }
+ int size() { QReadLocker lock(&_hashLock); return _avatarHash.size(); }
// Currently, your own avatar will be included as the null avatar id.
@@ -152,8 +152,6 @@ protected:
virtual void handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason = KillAvatarReason::NoReason);
AvatarHash _avatarHash;
- // "Case-based safety": Most access to the _avatarHash is on the same thread. Write access is protected by a write-lock.
- // If you read from a different thread, you must read-lock the _hashLock. (Scripted write access is not supported).
mutable QReadWriteLock _hashLock;
private:
diff --git a/libraries/avatars/src/HeadData.h b/libraries/avatars/src/HeadData.h
index bcc2cacde5..f9c4b52139 100644
--- a/libraries/avatars/src/HeadData.h
+++ b/libraries/avatars/src/HeadData.h
@@ -69,6 +69,24 @@ public:
}
bool lookAtPositionChangedSince(quint64 time) { return _lookAtPositionChanged >= time; }
+ bool getHasProceduralEyeFaceMovement() const { return _hasProceduralEyeFaceMovement; }
+
+ void setHasProceduralEyeFaceMovement(const bool hasProceduralEyeFaceMovement) {
+ _hasProceduralEyeFaceMovement = hasProceduralEyeFaceMovement;
+ }
+
+ bool getHasProceduralBlinkFaceMovement() const { return _hasProceduralBlinkFaceMovement; }
+
+ void setHasProceduralBlinkFaceMovement(const bool hasProceduralBlinkFaceMovement) {
+ _hasProceduralBlinkFaceMovement = hasProceduralBlinkFaceMovement;
+ }
+
+ bool getHasAudioEnabledFaceMovement() const { return _hasAudioEnabledFaceMovement; }
+
+ void setHasAudioEnabledFaceMovement(const bool hasAudioEnabledFaceMovement) {
+ _hasAudioEnabledFaceMovement = hasAudioEnabledFaceMovement;
+ }
+
friend class AvatarData;
QJsonObject toJson() const;
@@ -83,6 +101,9 @@ protected:
glm::vec3 _lookAtPosition;
quint64 _lookAtPositionChanged { 0 };
+ bool _hasAudioEnabledFaceMovement { true };
+ bool _hasProceduralBlinkFaceMovement { true };
+ bool _hasProceduralEyeFaceMovement { true };
bool _isFaceTrackerConnected { false };
bool _isEyeTrackerConnected { false };
float _leftEyeBlink { 0.0f };
diff --git a/libraries/baking/src/TextureBaker.cpp b/libraries/baking/src/TextureBaker.cpp
index b6957a2712..2b50f6be97 100644
--- a/libraries/baking/src/TextureBaker.cpp
+++ b/libraries/baking/src/TextureBaker.cpp
@@ -157,18 +157,19 @@ void TextureBaker::processTexture() {
return;
}
- const char* name = khronos::gl::texture::toString(memKTX->_header.getGLInternaFormat());
- if (name == nullptr) {
- handleError("Could not determine internal format for compressed KTX: " + _textureURL.toString());
- return;
- }
// attempt to write the baked texture to the destination file path
- {
+ if (memKTX->_header.isCompressed()) {
+ const char* name = khronos::gl::texture::toString(memKTX->_header.getGLInternaFormat());
+ if (name == nullptr) {
+ handleError("Could not determine internal format for compressed KTX: " + _textureURL.toString());
+ return;
+ }
+
const char* data = reinterpret_cast(memKTX->_storage->data());
const size_t length = memKTX->_storage->size();
- auto fileName = _baseFilename + BAKED_TEXTURE_BCN_SUFFIX;
+ auto fileName = _baseFilename + "_" + name + ".ktx";
auto filePath = _outputDirectory.absoluteFilePath(fileName);
QFile bakedTextureFile { filePath };
if (!bakedTextureFile.open(QIODevice::WriteOnly) || bakedTextureFile.write(data, length) == -1) {
@@ -177,6 +178,18 @@ void TextureBaker::processTexture() {
}
_outputFiles.push_back(filePath);
meta.availableTextureTypes[memKTX->_header.getGLInternaFormat()] = _metaTexturePathPrefix + fileName;
+ } else {
+ const char* data = reinterpret_cast(memKTX->_storage->data());
+ const size_t length = memKTX->_storage->size();
+
+ auto fileName = _baseFilename + ".ktx";
+ auto filePath = _outputDirectory.absoluteFilePath(fileName);
+ QFile ktxTextureFile { filePath };
+ if (!ktxTextureFile.open(QIODevice::WriteOnly) || ktxTextureFile.write(data, length) == -1) {
+ handleError("Could not write ktx texture for " + _textureURL.toString());
+ return;
+ }
+ _outputFiles.push_back(filePath);
}
diff --git a/libraries/controllers/src/controllers/Actions.cpp b/libraries/controllers/src/controllers/Actions.cpp
index 978b0888ba..6923ef4b98 100644
--- a/libraries/controllers/src/controllers/Actions.cpp
+++ b/libraries/controllers/src/controllers/Actions.cpp
@@ -307,7 +307,7 @@ namespace controller {
* action.
*
*
- * @typedef Controller.Actions
+ * @typedef {object} Controller.Actions
*/
// Device functions
Input::NamedVector ActionsDevice::getAvailableInputs() const {
diff --git a/libraries/controllers/src/controllers/InputDevice.h b/libraries/controllers/src/controllers/InputDevice.h
index 30a58eb2f0..1e626e6a3c 100644
--- a/libraries/controllers/src/controllers/InputDevice.h
+++ b/libraries/controllers/src/controllers/InputDevice.h
@@ -79,7 +79,7 @@ enum Hand {
* {@link Controller.Hardware-Vive}.
*
*
- * @typedef Controller.Hardware
+ * @typedef {object} Controller.Hardware
* @example List all the currently available Controller.Hardware
properties.
* function printProperties(string, item) {
* print(string);
diff --git a/libraries/controllers/src/controllers/ScriptingInterface.cpp b/libraries/controllers/src/controllers/ScriptingInterface.cpp
index 16db22401f..f49b41cbe6 100644
--- a/libraries/controllers/src/controllers/ScriptingInterface.cpp
+++ b/libraries/controllers/src/controllers/ScriptingInterface.cpp
@@ -92,28 +92,16 @@ namespace controller {
return userInputMapper->getValue(Input((uint32_t)source));
}
- float ScriptingInterface::getButtonValue(StandardButtonChannel source, uint16_t device) const {
- return getValue(Input(device, source, ChannelType::BUTTON).getID());
- }
-
float ScriptingInterface::getAxisValue(int source) const {
auto userInputMapper = DependencyManager::get();
return userInputMapper->getValue(Input((uint32_t)source));
}
- float ScriptingInterface::getAxisValue(StandardAxisChannel source, uint16_t device) const {
- return getValue(Input(device, source, ChannelType::AXIS).getID());
- }
-
Pose ScriptingInterface::getPoseValue(const int& source) const {
auto userInputMapper = DependencyManager::get();
return userInputMapper->getPose(Input((uint32_t)source));
}
- Pose ScriptingInterface::getPoseValue(StandardPoseChannel source, uint16_t device) const {
- return getPoseValue(Input(device, source, ChannelType::POSE).getID());
- }
-
QVector ScriptingInterface::getAllActions() {
return DependencyManager::get()->getAllActions();
}
diff --git a/libraries/controllers/src/controllers/ScriptingInterface.h b/libraries/controllers/src/controllers/ScriptingInterface.h
index dacb0c8568..b0004bc12d 100644
--- a/libraries/controllers/src/controllers/ScriptingInterface.h
+++ b/libraries/controllers/src/controllers/ScriptingInterface.h
@@ -206,43 +206,6 @@ namespace controller {
*/
Q_INVOKABLE Pose getPoseValue(const int& source) const;
- /**jsdoc
- * Get the value of a button on a particular device.
- * @function Controller.getButtonValue
- * @param {StandardButtonChannel} source - The button to get the value of.
- * @param {number} [device=0] - The ID of the hardware device to get the value from. The default value of
- * 0
corresponds to Standard
.
- * @returns {number} The current value of the button if the parameters are valid, otherwise 0
.
- * @deprecated This function no longer works.
- */
- // FIXME: This function causes a JavaScript crash: https://highfidelity.manuscript.com/f/cases/edit/14139
- Q_INVOKABLE float getButtonValue(StandardButtonChannel source, uint16_t device = 0) const;
-
- /**jsdoc
- * Get the value of an axis control on a particular device.
- * @function Controller.getAxisValue
- * @variation 0
- * @param {StandardAxisChannel} source - The axis to get the value of.
- * @param {number} [device=0] - The ID of the hardware device to get the value from. The default value of
- * 0
corresponds to Standard
.
- * @returns {number} The current value of the axis if the parameters are valid, otherwise 0
.
- * @deprecated This function no longer works.
- */
- Q_INVOKABLE float getAxisValue(StandardAxisChannel source, uint16_t device = 0) const;
-
- /**jsdoc
- * Get the value of an pose control on a particular device.
- * @function Controller.getPoseValue
- * @variation 0
- * @param {StandardPoseChannel} source - The pose to get the value of.
- * @param {number} [device=0] - The ID of the hardware device to get the value from. The default value of
- * 0
corresponds to Standard
.
- * @returns {Pose} The current value of the controller pose output if the parameters are valid, otherwise an invalid
- * pose with Pose.valid == false
.
- * @deprecated This function no longer works.
- */
- Q_INVOKABLE Pose getPoseValue(StandardPoseChannel source, uint16_t device = 0) const;
-
/**jsdoc
* Triggers a haptic pulse on connected and enabled devices that have the capability.
* @function Controller.triggerHapticPulse
diff --git a/libraries/controllers/src/controllers/StandardController.cpp b/libraries/controllers/src/controllers/StandardController.cpp
index 471943400d..e1733d2524 100644
--- a/libraries/controllers/src/controllers/StandardController.cpp
+++ b/libraries/controllers/src/controllers/StandardController.cpp
@@ -231,7 +231,7 @@ void StandardController::focusOutEvent() {
*
*
*
- * @typedef Controller.Standard
+ * @typedef {object} Controller.Standard
*/
Input::NamedVector StandardController::getAvailableInputs() const {
static Input::NamedVector availableInputs {
diff --git a/libraries/display-plugins/src/display-plugins/Basic2DWindowOpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/Basic2DWindowOpenGLDisplayPlugin.cpp
index 09b9b7f8f9..d8b8cbd54a 100644
--- a/libraries/display-plugins/src/display-plugins/Basic2DWindowOpenGLDisplayPlugin.cpp
+++ b/libraries/display-plugins/src/display-plugins/Basic2DWindowOpenGLDisplayPlugin.cpp
@@ -151,11 +151,9 @@ void Basic2DWindowOpenGLDisplayPlugin::compositeExtra() {
batch.setModelTransform(stickTransform);
batch.draw(gpu::TRIANGLE_STRIP, 4);
- if (!virtualPadManager.getLeftVirtualPad()->isBeingTouched()) {
- batch.setResourceTexture(0, _virtualPadJumpBtnTexture);
- batch.setModelTransform(jumpTransform);
- batch.draw(gpu::TRIANGLE_STRIP, 4);
- }
+ batch.setResourceTexture(0, _virtualPadJumpBtnTexture);
+ batch.setModelTransform(jumpTransform);
+ batch.draw(gpu::TRIANGLE_STRIP, 4);
});
}
#endif
diff --git a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp
index 354d3242a9..513f955e9e 100644
--- a/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp
+++ b/libraries/display-plugins/src/display-plugins/OpenGLDisplayPlugin.cpp
@@ -46,6 +46,8 @@
const char* SRGB_TO_LINEAR_FRAG = R"SCRIBE(
+// OpenGLDisplayPlugin_present.frag
+
uniform sampler2D colorMap;
in vec2 varTexCoord0;
diff --git a/libraries/embedded-webserver/src/HTTPConnection.cpp b/libraries/embedded-webserver/src/HTTPConnection.cpp
index 12da599575..f65cd87f6e 100644
--- a/libraries/embedded-webserver/src/HTTPConnection.cpp
+++ b/libraries/embedded-webserver/src/HTTPConnection.cpp
@@ -11,6 +11,8 @@
#include "HTTPConnection.h"
+#include
+
#include
#include
#include
@@ -29,11 +31,92 @@ const char* HTTPConnection::StatusCode404 = "404 Not Found";
const char* HTTPConnection::StatusCode500 = "500 Internal server error";
const char* HTTPConnection::DefaultContentType = "text/plain; charset=ISO-8859-1";
-HTTPConnection::HTTPConnection (QTcpSocket* socket, HTTPManager* parentManager) :
+
+class MemoryStorage : public HTTPConnection::Storage {
+public:
+ static std::unique_ptr make(qint64 size);
+ virtual ~MemoryStorage() = default;
+
+ const QByteArray& content() const override { return _array; }
+ qint64 bytesLeftToWrite() const override { return _array.size() - _bytesWritten; }
+ void write(const QByteArray& data) override;
+
+private:
+ MemoryStorage(qint64 size) { _array.resize(size); }
+
+ QByteArray _array;
+ qint64 _bytesWritten { 0 };
+};
+
+std::unique_ptr MemoryStorage::make(qint64 size) {
+ return std::unique_ptr(new MemoryStorage(size));
+}
+
+void MemoryStorage::write(const QByteArray& data) {
+ assert(data.size() <= bytesLeftToWrite());
+ memcpy(_array.data() + _bytesWritten, data.data(), data.size());
+ _bytesWritten += data.size();
+}
+
+
+class FileStorage : public HTTPConnection::Storage {
+public:
+ static std::unique_ptr make(qint64 size);
+ virtual ~FileStorage();
+
+ const QByteArray& content() const override { return _wrapperArray; };
+ qint64 bytesLeftToWrite() const override { return _mappedMemorySize - _bytesWritten; }
+ void write(const QByteArray& data) override;
+
+private:
+ FileStorage(std::unique_ptr file, uchar* mapped, qint64 size);
+
+ // Byte array is const because any edit will trigger a deep copy
+ // and pull all the data we want to keep on disk in memory.
+ const QByteArray _wrapperArray;
+ std::unique_ptr _file;
+
+ uchar* const _mappedMemoryAddress { nullptr };
+ const qint64 _mappedMemorySize { 0 };
+ qint64 _bytesWritten { 0 };
+};
+
+std::unique_ptr FileStorage::make(qint64 size) {
+ auto file = std::unique_ptr(new QTemporaryFile());
+ file->open(); // Open for resize
+ file->resize(size);
+ auto mapped = file->map(0, size); // map the entire file
+
+ return std::unique_ptr(new FileStorage(std::move(file), mapped, size));
+}
+
+// Use QByteArray::fromRawData to avoid a new allocation and access the already existing
+// memory directly as long as all operations on the array are const.
+FileStorage::FileStorage(std::unique_ptr file, uchar* mapped, qint64 size) :
+ _wrapperArray(QByteArray::fromRawData(reinterpret_cast(mapped), size)),
+ _file(std::move(file)),
+ _mappedMemoryAddress(mapped),
+ _mappedMemorySize(size)
+{
+}
+
+FileStorage::~FileStorage() {
+ _file->unmap(_mappedMemoryAddress);
+ _file->close();
+}
+
+void FileStorage::write(const QByteArray& data) {
+ assert(data.size() <= bytesLeftToWrite());
+ // We write directly to the mapped memory
+ memcpy(_mappedMemoryAddress + _bytesWritten, data.data(), data.size());
+ _bytesWritten += data.size();
+}
+
+
+HTTPConnection::HTTPConnection(QTcpSocket* socket, HTTPManager* parentManager) :
QObject(parentManager),
_parentManager(parentManager),
_socket(socket),
- _stream(socket),
_address(socket->peerAddress())
{
// take over ownership of the socket
@@ -62,7 +145,7 @@ QHash HTTPConnection::parseUrlEncodedForm() {
return QHash();
}
- QUrlQuery form { _requestContent };
+ QUrlQuery form { _requestContent->content() };
QHash pairs;
for (auto pair : form.queryItems()) {
auto key = QUrl::fromPercentEncoding(pair.first.toLatin1().replace('+', ' '));
@@ -97,7 +180,7 @@ QList HTTPConnection::parseFormData() const {
QByteArray end = "\r\n--" + boundary + "--\r\n";
QList data;
- QBuffer buffer(const_cast(&_requestContent));
+ QBuffer buffer(const_cast(&_requestContent->content()));
buffer.open(QIODevice::ReadOnly);
while (buffer.canReadLine()) {
QByteArray line = buffer.readLine().trimmed();
@@ -107,12 +190,13 @@ QList HTTPConnection::parseFormData() const {
QByteArray line = buffer.readLine().trimmed();
if (line.isEmpty()) {
// content starts after this line
- int idx = _requestContent.indexOf(end, buffer.pos());
+ int idx = _requestContent->content().indexOf(end, buffer.pos());
if (idx == -1) {
qWarning() << "Missing end boundary." << _address;
return data;
}
- datum.second = _requestContent.mid(buffer.pos(), idx - buffer.pos());
+ datum.second = QByteArray::fromRawData(_requestContent->content().data() + buffer.pos(),
+ idx - buffer.pos());
data.append(datum);
buffer.seek(idx + end.length());
@@ -256,7 +340,24 @@ void HTTPConnection::readHeaders() {
_parentManager->handleHTTPRequest(this, _requestUrl);
} else {
- _requestContent.resize(clength.toInt());
+ bool success = false;
+ auto length = clength.toInt(&success);
+ if (!success) {
+ qWarning() << "Invalid header." << _address << trimmed;
+ respond("400 Bad Request", "The header was malformed.");
+ return;
+ }
+
+ // Storing big requests in memory gets expensive, especially on servers
+ // with limited memory. So we store big requests in a temporary file on disk
+ // and map it to faster read/write access.
+ static const int MAX_CONTENT_SIZE_IN_MEMORY = 10 * 1000 * 1000;
+ if (length < MAX_CONTENT_SIZE_IN_MEMORY) {
+ _requestContent = MemoryStorage::make(length);
+ } else {
+ _requestContent = FileStorage::make(length);
+ }
+
connect(_socket, SIGNAL(readyRead()), SLOT(readContent()));
// read any content immediately available
@@ -285,12 +386,13 @@ void HTTPConnection::readHeaders() {
}
void HTTPConnection::readContent() {
- int size = _requestContent.size();
- if (_socket->bytesAvailable() < size) {
- return;
- }
- _socket->read(_requestContent.data(), size);
- _socket->disconnect(this, SLOT(readContent()));
+ auto size = std::min(_socket->bytesAvailable(), _requestContent->bytesLeftToWrite());
- _parentManager->handleHTTPRequest(this, _requestUrl.path());
+ _requestContent->write(_socket->read(size));
+
+ if (_requestContent->bytesLeftToWrite() == 0) {
+ _socket->disconnect(this, SLOT(readContent()));
+
+ _parentManager->handleHTTPRequest(this, _requestUrl.path());
+ }
}
diff --git a/libraries/embedded-webserver/src/HTTPConnection.h b/libraries/embedded-webserver/src/HTTPConnection.h
index e4d23e3c90..4b42acf296 100644
--- a/libraries/embedded-webserver/src/HTTPConnection.h
+++ b/libraries/embedded-webserver/src/HTTPConnection.h
@@ -16,14 +16,14 @@
#ifndef hifi_HTTPConnection_h
#define hifi_HTTPConnection_h
-#include
#include
-#include
#include
#include
+#include
#include
#include
#include
+#include
#include
#include
@@ -57,52 +57,63 @@ public:
/// WebSocket close status codes.
enum ReasonCode { NoReason = 0, NormalClosure = 1000, GoingAway = 1001 };
+ class Storage {
+ public:
+ Storage() = default;
+ virtual ~Storage() = default;
+
+ virtual const QByteArray& content() const = 0;
+
+ virtual qint64 bytesLeftToWrite() const = 0;
+ virtual void write(const QByteArray& data) = 0;
+ };
+
/// Initializes the connection.
- HTTPConnection (QTcpSocket* socket, HTTPManager* parentManager);
+ HTTPConnection(QTcpSocket* socket, HTTPManager* parentManager);
/// Destroys the connection.
- virtual ~HTTPConnection ();
+ virtual ~HTTPConnection();
/// Returns a pointer to the underlying socket, to which WebSocket message bodies should be written.
- QTcpSocket* socket () const { return _socket; }
+ QTcpSocket* socket() const { return _socket; }
/// Returns the request operation.
- QNetworkAccessManager::Operation requestOperation () const { return _requestOperation; }
+ QNetworkAccessManager::Operation requestOperation() const { return _requestOperation; }
/// Returns a reference to the request URL.
- const QUrl& requestUrl () const { return _requestUrl; }
+ const QUrl& requestUrl() const { return _requestUrl; }
/// Returns a copy of the request header value. If it does not exist, it will return a default constructed QByteArray.
QByteArray requestHeader(const QString& key) const { return _requestHeaders.value(key.toLower().toLocal8Bit()); }
/// Returns a reference to the request content.
- const QByteArray& requestContent () const { return _requestContent; }
+ const QByteArray& requestContent() const { return _requestContent->content(); }
/// Parses the request content as form data, returning a list of header/content pairs.
- QList parseFormData () const;
+ QList parseFormData() const;
/// Parses the request content as a url encoded form, returning a hash of key/value pairs.
/// Duplicate keys are not supported.
QHash parseUrlEncodedForm();
/// Sends a response and closes the connection.
- void respond (const char* code, const QByteArray& content = QByteArray(),
+ void respond(const char* code, const QByteArray& content = QByteArray(),
const char* contentType = DefaultContentType,
const Headers& headers = Headers());
- void respond (const char* code, std::unique_ptr device,
+ void respond(const char* code, std::unique_ptr device,
const char* contentType = DefaultContentType,
const Headers& headers = Headers());
protected slots:
/// Reads the request line.
- void readRequest ();
+ void readRequest();
/// Reads the headers.
- void readHeaders ();
+ void readHeaders();
/// Reads the content.
- void readContent ();
+ void readContent();
protected:
void respondWithStatusAndHeaders(const char* code, const char* contentType, const Headers& headers, qint64 size);
@@ -112,9 +123,6 @@ protected:
/// The underlying socket.
QTcpSocket* _socket;
-
- /// The data stream for writing to the socket.
- QDataStream _stream;
/// The stored address.
QHostAddress _address;
@@ -132,7 +140,7 @@ protected:
QByteArray _lastRequestHeader;
/// The content of the request.
- QByteArray _requestContent;
+ std::unique_ptr _requestContent;
/// Response content
std::unique_ptr _responseDevice;
diff --git a/libraries/embedded-webserver/src/HTTPManager.cpp b/libraries/embedded-webserver/src/HTTPManager.cpp
index db6fc8e084..4a75994e12 100644
--- a/libraries/embedded-webserver/src/HTTPManager.cpp
+++ b/libraries/embedded-webserver/src/HTTPManager.cpp
@@ -24,8 +24,7 @@
const int SOCKET_ERROR_EXIT_CODE = 2;
const int SOCKET_CHECK_INTERVAL_IN_MS = 30000;
-HTTPManager::HTTPManager(const QHostAddress& listenAddress, quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler, QObject* parent) :
- QTcpServer(parent),
+HTTPManager::HTTPManager(const QHostAddress& listenAddress, quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler) :
_listenAddress(listenAddress),
_documentRoot(documentRoot),
_requestHandler(requestHandler),
diff --git a/libraries/embedded-webserver/src/HTTPManager.h b/libraries/embedded-webserver/src/HTTPManager.h
index cb76eed9f2..597f6921cc 100644
--- a/libraries/embedded-webserver/src/HTTPManager.h
+++ b/libraries/embedded-webserver/src/HTTPManager.h
@@ -33,7 +33,7 @@ class HTTPManager : public QTcpServer, public HTTPRequestHandler {
Q_OBJECT
public:
/// Initializes the manager.
- HTTPManager(const QHostAddress& listenAddress, quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler = NULL, QObject* parent = 0);
+ HTTPManager(const QHostAddress& listenAddress, quint16 port, const QString& documentRoot, HTTPRequestHandler* requestHandler = nullptr);
bool handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler = false) override;
diff --git a/libraries/embedded-webserver/src/HTTPSConnection.h b/libraries/embedded-webserver/src/HTTPSConnection.h
index 7b53dc0063..3e6c752a08 100644
--- a/libraries/embedded-webserver/src/HTTPSConnection.h
+++ b/libraries/embedded-webserver/src/HTTPSConnection.h
@@ -23,4 +23,4 @@ protected slots:
void handleSSLErrors(const QList& errors);
};
-#endif // hifi_HTTPSConnection_h
\ No newline at end of file
+#endif // hifi_HTTPSConnection_h
diff --git a/libraries/embedded-webserver/src/HTTPSManager.cpp b/libraries/embedded-webserver/src/HTTPSManager.cpp
index 8ba44f98ac..95339a0dd6 100644
--- a/libraries/embedded-webserver/src/HTTPSManager.cpp
+++ b/libraries/embedded-webserver/src/HTTPSManager.cpp
@@ -16,8 +16,8 @@
#include "HTTPSConnection.h"
HTTPSManager::HTTPSManager(QHostAddress listenAddress, quint16 port, const QSslCertificate& certificate, const QSslKey& privateKey,
- const QString& documentRoot, HTTPSRequestHandler* requestHandler, QObject* parent) :
- HTTPManager(listenAddress, port, documentRoot, requestHandler, parent),
+ const QString& documentRoot, HTTPSRequestHandler* requestHandler) :
+ HTTPManager(listenAddress, port, documentRoot, requestHandler),
_certificate(certificate),
_privateKey(privateKey),
_sslRequestHandler(requestHandler)
diff --git a/libraries/embedded-webserver/src/HTTPSManager.h b/libraries/embedded-webserver/src/HTTPSManager.h
index 2d3cc9ed62..9cea32862c 100644
--- a/libraries/embedded-webserver/src/HTTPSManager.h
+++ b/libraries/embedded-webserver/src/HTTPSManager.h
@@ -31,7 +31,7 @@ public:
const QSslCertificate& certificate,
const QSslKey& privateKey,
const QString& documentRoot,
- HTTPSRequestHandler* requestHandler = NULL, QObject* parent = 0);
+ HTTPSRequestHandler* requestHandler = nullptr);
void setCertificate(const QSslCertificate& certificate) { _certificate = certificate; }
void setPrivateKey(const QSslKey& privateKey) { _privateKey = privateKey; }
@@ -48,4 +48,4 @@ private:
HTTPSRequestHandler* _sslRequestHandler;
};
-#endif // hifi_HTTPSManager_h
\ No newline at end of file
+#endif // hifi_HTTPSManager_h
diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp
index b61f24972a..ae4c13d96f 100644
--- a/libraries/entities-renderer/src/RenderableEntityItem.cpp
+++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp
@@ -157,16 +157,20 @@ Item::Bound EntityRenderer::getBound() {
return _bound;
}
+render::hifi::Tag EntityRenderer::getTagMask() const {
+ return _isVisibleInSecondaryCamera ? render::hifi::TAG_ALL_VIEWS : render::hifi::TAG_MAIN_VIEW;
+}
+
ItemKey EntityRenderer::getKey() {
if (isTransparent()) {
- return ItemKey::Builder::transparentShape().withTypeMeta().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1);
+ return ItemKey::Builder::transparentShape().withTypeMeta().withTagBits(getTagMask());
}
// This allows shapes to cast shadows
if (_canCastShadow) {
- return ItemKey::Builder::opaqueShape().withTypeMeta().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1).withShadowCaster();
+ return ItemKey::Builder::opaqueShape().withTypeMeta().withTagBits(getTagMask()).withShadowCaster();
} else {
- return ItemKey::Builder::opaqueShape().withTypeMeta().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1);
+ return ItemKey::Builder::opaqueShape().withTypeMeta().withTagBits(getTagMask());
}
}
@@ -380,6 +384,7 @@ void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transa
_moving = entity->isMovingRelativeToParent();
_visible = entity->getVisible();
+ setIsVisibleInSecondaryCamera(entity->isVisibleInSecondaryCamera());
_canCastShadow = entity->getCanCastShadow();
_cauterized = entity->getCauterized();
_needsRenderUpdate = false;
diff --git a/libraries/entities-renderer/src/RenderableEntityItem.h b/libraries/entities-renderer/src/RenderableEntityItem.h
index ada57c8ab0..e1ce2ed39e 100644
--- a/libraries/entities-renderer/src/RenderableEntityItem.h
+++ b/libraries/entities-renderer/src/RenderableEntityItem.h
@@ -18,6 +18,7 @@
#include "AbstractViewStateInterface.h"
#include "EntitiesRendererLogging.h"
#include
+#include
class EntityTreeRenderer;
@@ -74,6 +75,7 @@ protected:
virtual Item::Bound getBound() override;
virtual void render(RenderArgs* args) override final;
virtual uint32_t metaFetchMetaSubItems(ItemIDs& subItems) override;
+ virtual render::hifi::Tag getTagMask() const;
// Returns true if the item in question needs to have updateInScene called because of internal rendering state changes
virtual bool needsRenderUpdate() const;
@@ -97,6 +99,8 @@ protected:
bool isFading() const { return _isFading; }
virtual bool isTransparent() const { return _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f : false; }
inline bool isValidRenderItem() const { return _renderItemID != Item::INVALID_ITEM_ID; }
+
+ virtual void setIsVisibleInSecondaryCamera(bool value) { _isVisibleInSecondaryCamera = value; }
template
T withReadLockResult(const std::function& f) {
@@ -129,6 +133,7 @@ protected:
bool _isFading{ _entitiesShouldFadeFunction() };
bool _prevIsTransparent { false };
bool _visible { false };
+ bool _isVisibleInSecondaryCamera { false };
bool _canCastShadow { false };
bool _cauterized { false };
bool _moving { false };
diff --git a/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp b/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp
index 7cea841bf0..eabcb68e4f 100644
--- a/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp
+++ b/libraries/entities-renderer/src/RenderableMaterialEntityItem.cpp
@@ -43,7 +43,7 @@ void MaterialEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer&
ItemKey MaterialEntityRenderer::getKey() {
ItemKey::Builder builder;
- builder.withTypeShape().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1);
+ builder.withTypeShape().withTagBits(getTagMask());
if (!_visible) {
builder.withInvisible();
diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp
index c4fa71a488..a91534668c 100644
--- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp
+++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp
@@ -1060,9 +1060,9 @@ ModelEntityRenderer::ModelEntityRenderer(const EntityItemPointer& entity) : Pare
void ModelEntityRenderer::setKey(bool didVisualGeometryRequestSucceed) {
if (didVisualGeometryRequestSucceed) {
- _itemKey = ItemKey::Builder().withTypeMeta().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1);
+ _itemKey = ItemKey::Builder().withTypeMeta().withTagBits(getTagMask());
} else {
- _itemKey = ItemKey::Builder().withTypeMeta().withTypeShape().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1);
+ _itemKey = ItemKey::Builder().withTypeMeta().withTypeShape().withTagBits(getTagMask());
}
}
@@ -1070,6 +1070,13 @@ ItemKey ModelEntityRenderer::getKey() {
return _itemKey;
}
+render::hifi::Tag ModelEntityRenderer::getTagMask() const {
+ // Default behavior for model is to not be visible in main view if cauterized (aka parented to the avatar's neck joint)
+ return _cauterized ?
+ (_isVisibleInSecondaryCamera ? render::hifi::TAG_SECONDARY_VIEW : render::hifi::TAG_NONE) :
+ Parent::getTagMask(); // calculate which views to be shown in
+}
+
uint32_t ModelEntityRenderer::metaFetchMetaSubItems(ItemIDs& subItems) {
if (_model) {
auto metaSubItems = _subRenderItemIDs;
@@ -1329,6 +1336,7 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
emit DependencyManager::get()->
modelAddedToScene(entity->getEntityItemID(), NestableType::Entity, _model);
}
+ _didLastVisualGeometryRequestSucceed = didVisualGeometryRequestSucceed;
});
connect(model.get(), &Model::requestRenderUpdate, this, &ModelEntityRenderer::requestRenderUpdate);
connect(entity.get(), &RenderableModelEntityItem::requestCollisionGeometryUpdate, this, &ModelEntityRenderer::flagForCollisionGeometryUpdate);
@@ -1386,21 +1394,22 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
entity->updateModelBounds();
entity->stopModelOverrideIfNoParent();
- // Default behavior for model is to not be visible in main view if cauterized (aka parented to the avatar's neck joint)
- uint32_t viewTaskBits = _cauterized ?
- render::ItemKey::TAG_BITS_1 : // draw in every view except the main one (view zero)
- render::ItemKey::TAG_BITS_ALL; // draw in all views
-
- if (model->isVisible() != _visible || model->getViewTagBits() != viewTaskBits) {
+ render::hifi::Tag tagMask = getTagMask();
+ if (model->isVisible() != _visible) {
// FIXME: this seems like it could be optimized if we tracked our last known visible state in
// the renderable item. As it stands now the model checks it's visible/invisible state
// so most of the time we don't do anything in this function.
- model->setVisibleInScene(_visible, scene, viewTaskBits, false);
+ model->setVisibleInScene(_visible, scene);
}
+
+ if (model->getTagMask() != tagMask) {
+ model->setTagMask(tagMask, scene);
+ }
+
// TODO? early exit here when not visible?
if (model->canCastShadow() != _canCastShadow) {
- model->setCanCastShadow(_canCastShadow, scene, viewTaskBits, false);
+ model->setCanCastShadow(_canCastShadow, scene);
}
if (_needsCollisionGeometryUpdate) {
@@ -1473,6 +1482,11 @@ void ModelEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
}
}
+void ModelEntityRenderer::setIsVisibleInSecondaryCamera(bool value) {
+ Parent::setIsVisibleInSecondaryCamera(value);
+ setKey(_didLastVisualGeometryRequestSucceed);
+}
+
void ModelEntityRenderer::flagForCollisionGeometryUpdate() {
_needsCollisionGeometryUpdate = true;
emit requestRenderUpdate();
diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.h b/libraries/entities-renderer/src/RenderableModelEntityItem.h
index 68bc70c8a9..f1748ca069 100644
--- a/libraries/entities-renderer/src/RenderableModelEntityItem.h
+++ b/libraries/entities-renderer/src/RenderableModelEntityItem.h
@@ -164,6 +164,10 @@ protected:
void flagForCollisionGeometryUpdate();
void setCollisionMeshKey(const void* key);
+ render::hifi::Tag getTagMask() const override;
+
+ void setIsVisibleInSecondaryCamera(bool value) override;
+
private:
void animate(const TypedEntityPointer& entity);
void mapJoints(const TypedEntityPointer& entity, const QStringList& modelJointNames);
@@ -202,6 +206,8 @@ private:
render::ItemKey _itemKey { render::ItemKey::Builder().withTypeMeta() };
+ bool _didLastVisualGeometryRequestSucceed { true };
+
void processMaterials();
};
diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp
index ee77646920..881c39c0bd 100644
--- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp
+++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp
@@ -147,9 +147,9 @@ void ParticleEffectEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEn
ItemKey ParticleEffectEntityRenderer::getKey() {
if (_visible) {
- return ItemKey::Builder::transparentShape().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1);
+ return ItemKey::Builder::transparentShape().withTagBits(getTagMask());
} else {
- return ItemKey::Builder().withInvisible().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1).build();
+ return ItemKey::Builder().withInvisible().withTagBits(getTagMask()).build();
}
}
diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp
index d571eac35c..7cab57123d 100644
--- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp
+++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp
@@ -112,7 +112,7 @@ PolyLineEntityRenderer::PolyLineEntityRenderer(const EntityItemPointer& entity)
}
ItemKey PolyLineEntityRenderer::getKey() {
- return ItemKey::Builder::transparentShape().withTypeMeta().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1);
+ return ItemKey::Builder::transparentShape().withTypeMeta().withTagBits(getTagMask());
}
ShapeKey PolyLineEntityRenderer::getShapeKey() {
diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h
index 70c87dca6f..7077ae799b 100644
--- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h
+++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h
@@ -169,7 +169,7 @@ public:
}
protected:
- virtual ItemKey getKey() override { return ItemKey::Builder::opaqueShape().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1); }
+ virtual ItemKey getKey() override { return ItemKey::Builder::opaqueShape().withTagBits(getTagMask()); }
virtual ShapeKey getShapeKey() override;
virtual bool needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const override;
virtual void doRenderUpdateSynchronousTyped(const ScenePointer& scene, Transaction& transaction, const TypedEntityPointer& entity) override;
diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp
index 1d34837a58..69068b81d2 100644
--- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp
+++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp
@@ -139,7 +139,7 @@ bool ShapeEntityRenderer::isTransparent() const {
ItemKey ShapeEntityRenderer::getKey() {
ItemKey::Builder builder;
- builder.withTypeShape().withTypeMeta().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1);
+ builder.withTypeShape().withTypeMeta().withTagBits(getTagMask());
withReadLock([&] {
if (isTransparent()) {
diff --git a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp
index 5062162b6e..c5035431f6 100644
--- a/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp
+++ b/libraries/entities-renderer/src/RenderableZoneEntityItem.cpp
@@ -269,7 +269,7 @@ void ZoneEntityRenderer::doRenderUpdateAsynchronousTyped(const TypedEntityPointe
ItemKey ZoneEntityRenderer::getKey() {
- return ItemKey::Builder().withTypeMeta().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1).build();
+ return ItemKey::Builder().withTypeMeta().withTagBits(getTagMask()).build();
}
bool ZoneEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
diff --git a/libraries/entities-renderer/src/textured_particle.slv b/libraries/entities-renderer/src/textured_particle.slv
index cab76227c4..1d4261b1cc 100644
--- a/libraries/entities-renderer/src/textured_particle.slv
+++ b/libraries/entities-renderer/src/textured_particle.slv
@@ -37,8 +37,8 @@ layout(std140) uniform particleBuffer {
ParticleUniforms particle;
};
-in vec3 inPosition;
-in vec2 inColor; // This is actual Lifetime + Seed
+layout(location=0) in vec3 inPosition;
+layout(location=2) in vec2 inColor; // This is actual Lifetime + Seed
out vec4 varColor;
out vec2 varTexcoord;
diff --git a/libraries/entities/src/AnimationPropertyGroup.cpp b/libraries/entities/src/AnimationPropertyGroup.cpp
index 43c6b7a6a5..2db85eb7ac 100644
--- a/libraries/entities/src/AnimationPropertyGroup.cpp
+++ b/libraries/entities/src/AnimationPropertyGroup.cpp
@@ -46,7 +46,7 @@ bool operator!=(const AnimationPropertyGroup& a, const AnimationPropertyGroup& b
/**jsdoc
* The AnimationProperties are used to configure an animation.
- * @typedef Entities.AnimationProperties
+ * @typedef {object} Entities.AnimationProperties
* @property {string} url="" - The URL of the FBX file that has the animation.
* @property {number} fps=30 - The speed in frames/s that the animation is played at.
* @property {number} firstFrame=0 - The first frame to play in the animation.
diff --git a/libraries/entities/src/EntityEditPacketSender.cpp b/libraries/entities/src/EntityEditPacketSender.cpp
index 6c6c4b37d0..9ca102d016 100644
--- a/libraries/entities/src/EntityEditPacketSender.cpp
+++ b/libraries/entities/src/EntityEditPacketSender.cpp
@@ -154,3 +154,11 @@ void EntityEditPacketSender::queueEraseEntityMessage(const EntityItemID& entityI
queueOctreeEditMessage(PacketType::EntityErase, bufferOut);
}
}
+
+void EntityEditPacketSender::queueCloneEntityMessage(const EntityItemID& entityIDToClone, const EntityItemID& newEntityID) {
+ QByteArray bufferOut(NLPacket::maxPayloadSize(PacketType::EntityClone), 0);
+
+ if (EntityItemProperties::encodeCloneEntityMessage(entityIDToClone, newEntityID, bufferOut)) {
+ queueOctreeEditMessage(PacketType::EntityClone, bufferOut);
+ }
+}
diff --git a/libraries/entities/src/EntityEditPacketSender.h b/libraries/entities/src/EntityEditPacketSender.h
index bf79bb9203..31f91707b8 100644
--- a/libraries/entities/src/EntityEditPacketSender.h
+++ b/libraries/entities/src/EntityEditPacketSender.h
@@ -38,6 +38,7 @@ public:
void queueEraseEntityMessage(const EntityItemID& entityItemID);
+ void queueCloneEntityMessage(const EntityItemID& entityIDToClone, const EntityItemID& newEntityID);
// My server type is the model server
virtual char getMyNodeType() const override { return NodeType::EntityServer; }
diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp
index d35c01a51b..70881fbc40 100644
--- a/libraries/entities/src/EntityItem.cpp
+++ b/libraries/entities/src/EntityItem.cpp
@@ -124,6 +124,13 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param
requestedProperties += PROP_LAST_EDITED_BY;
+ requestedProperties += PROP_CLONEABLE;
+ requestedProperties += PROP_CLONE_LIFETIME;
+ requestedProperties += PROP_CLONE_LIMIT;
+ requestedProperties += PROP_CLONE_DYNAMIC;
+ requestedProperties += PROP_CLONE_AVATAR_ENTITY;
+ requestedProperties += PROP_CLONE_ORIGIN_ID;
+
return requestedProperties;
}
@@ -288,6 +295,13 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
APPEND_ENTITY_PROPERTY(PROP_QUERY_AA_CUBE, getQueryAACube());
APPEND_ENTITY_PROPERTY(PROP_LAST_EDITED_BY, getLastEditedBy());
+ APPEND_ENTITY_PROPERTY(PROP_CLONEABLE, getCloneable());
+ APPEND_ENTITY_PROPERTY(PROP_CLONE_LIFETIME, getCloneLifetime());
+ APPEND_ENTITY_PROPERTY(PROP_CLONE_LIMIT, getCloneLimit());
+ APPEND_ENTITY_PROPERTY(PROP_CLONE_DYNAMIC, getCloneDynamic());
+ APPEND_ENTITY_PROPERTY(PROP_CLONE_AVATAR_ENTITY, getCloneAvatarEntity());
+ APPEND_ENTITY_PROPERTY(PROP_CLONE_ORIGIN_ID, getCloneOriginID());
+
appendSubclassData(packetData, params, entityTreeElementExtraEncodeData,
requestedProperties,
propertyFlags,
@@ -803,7 +817,7 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
READ_ENTITY_PROPERTY(PROP_VISIBLE, bool, setVisible);
READ_ENTITY_PROPERTY(PROP_CAN_CAST_SHADOW, bool, setCanCastShadow);
READ_ENTITY_PROPERTY(PROP_COLLISIONLESS, bool, setCollisionless);
- READ_ENTITY_PROPERTY(PROP_COLLISION_MASK, uint8_t, setCollisionMask);
+ READ_ENTITY_PROPERTY(PROP_COLLISION_MASK, uint16_t, setCollisionMask);
READ_ENTITY_PROPERTY(PROP_DYNAMIC, bool, setDynamic);
READ_ENTITY_PROPERTY(PROP_LOCKED, bool, setLocked);
READ_ENTITY_PROPERTY(PROP_USER_DATA, QString, setUserData);
@@ -848,6 +862,13 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef
READ_ENTITY_PROPERTY(PROP_LAST_EDITED_BY, QUuid, setLastEditedBy);
+ READ_ENTITY_PROPERTY(PROP_CLONEABLE, bool, setCloneable);
+ READ_ENTITY_PROPERTY(PROP_CLONE_LIFETIME, float, setCloneLifetime);
+ READ_ENTITY_PROPERTY(PROP_CLONE_LIMIT, float, setCloneLimit);
+ READ_ENTITY_PROPERTY(PROP_CLONE_DYNAMIC, bool, setCloneDynamic);
+ READ_ENTITY_PROPERTY(PROP_CLONE_AVATAR_ENTITY, bool, setCloneAvatarEntity);
+ READ_ENTITY_PROPERTY(PROP_CLONE_ORIGIN_ID, QUuid, setCloneOriginID);
+
bytesRead += readEntitySubclassDataFromBuffer(dataAt, (bytesLeftToRead - bytesRead), args,
propertyFlags, overwriteLocalData, somethingChanged);
@@ -1275,6 +1296,13 @@ EntityItemProperties EntityItem::getProperties(EntityPropertyFlags desiredProper
COPY_ENTITY_PROPERTY_TO_PROPERTIES(lastEditedBy, getLastEditedBy);
+ COPY_ENTITY_PROPERTY_TO_PROPERTIES(cloneable, getCloneable);
+ COPY_ENTITY_PROPERTY_TO_PROPERTIES(cloneLifetime, getCloneLifetime);
+ COPY_ENTITY_PROPERTY_TO_PROPERTIES(cloneLimit, getCloneLimit);
+ COPY_ENTITY_PROPERTY_TO_PROPERTIES(cloneDynamic, getCloneDynamic);
+ COPY_ENTITY_PROPERTY_TO_PROPERTIES(cloneAvatarEntity, getCloneAvatarEntity);
+ COPY_ENTITY_PROPERTY_TO_PROPERTIES(cloneOriginID, getCloneOriginID);
+
properties._defaultSettings = false;
return properties;
@@ -1355,6 +1383,7 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(visible, setVisible);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(canCastShadow, setCanCastShadow);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(userData, setUserData);
+ SET_ENTITY_PROPERTY_FROM_PROPERTIES(isVisibleInSecondaryCamera, setIsVisibleInSecondaryCamera);
// Certifiable Properties
SET_ENTITY_PROPERTY_FROM_PROPERTIES(itemName, setItemName);
@@ -1382,6 +1411,13 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
SET_ENTITY_PROPERTY_FROM_PROPERTIES(lastEditedBy, setLastEditedBy);
+ SET_ENTITY_PROPERTY_FROM_PROPERTIES(cloneable, setCloneable);
+ SET_ENTITY_PROPERTY_FROM_PROPERTIES(cloneLifetime, setCloneLifetime);
+ SET_ENTITY_PROPERTY_FROM_PROPERTIES(cloneLimit, setCloneLimit);
+ SET_ENTITY_PROPERTY_FROM_PROPERTIES(cloneDynamic, setCloneDynamic);
+ SET_ENTITY_PROPERTY_FROM_PROPERTIES(cloneAvatarEntity, setCloneAvatarEntity);
+ SET_ENTITY_PROPERTY_FROM_PROPERTIES(cloneOriginID, setCloneOriginID);
+
if (updateQueryAACube()) {
somethingChanged = true;
}
@@ -1814,7 +1850,7 @@ void EntityItem::setCollisionless(bool value) {
});
}
-void EntityItem::setCollisionMask(uint8_t value) {
+void EntityItem::setCollisionMask(uint16_t value) {
withWriteLock([&] {
if ((_collisionMask & ENTITY_COLLISION_MASK_DEFAULT) != (value & ENTITY_COLLISION_MASK_DEFAULT)) {
_collisionMask = (value & ENTITY_COLLISION_MASK_DEFAULT);
@@ -1879,7 +1915,7 @@ void EntityItem::setCreated(quint64 value) {
});
}
-void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask) const {
+void EntityItem::computeCollisionGroupAndFinalMask(int32_t& group, int32_t& mask) const {
if (_collisionless) {
group = BULLET_COLLISION_GROUP_COLLISIONLESS;
mask = 0;
@@ -1892,7 +1928,7 @@ void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask
group = BULLET_COLLISION_GROUP_STATIC;
}
- uint8_t userMask = getCollisionMask();
+ uint16_t userMask = getCollisionMask();
if ((bool)(userMask & USER_COLLISION_GROUP_MY_AVATAR) !=
(bool)(userMask & USER_COLLISION_GROUP_OTHER_AVATAR)) {
@@ -1906,7 +1942,7 @@ void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask
if ((bool)(_flags & Simulation::SPECIAL_FLAGS_NO_BOOTSTRAPPING)) {
userMask &= ~USER_COLLISION_GROUP_MY_AVATAR;
}
- mask = Physics::getDefaultCollisionMask(group) & (int16_t)(userMask);
+ mask = Physics::getDefaultCollisionMask(group) & (int32_t)(userMask);
}
}
@@ -2725,6 +2761,28 @@ void EntityItem::setVisible(bool value) {
}
}
+bool EntityItem::isVisibleInSecondaryCamera() const {
+ bool result;
+ withReadLock([&] {
+ result = _isVisibleInSecondaryCamera;
+ });
+ return result;
+}
+
+void EntityItem::setIsVisibleInSecondaryCamera(bool value) {
+ bool changed = false;
+ withWriteLock([&] {
+ if (_isVisibleInSecondaryCamera != value) {
+ changed = true;
+ _isVisibleInSecondaryCamera = value;
+ }
+ });
+
+ if (changed) {
+ emit requestRenderUpdate();
+ }
+}
+
bool EntityItem::getCanCastShadow() const {
bool result;
withReadLock([&] {
@@ -2760,8 +2818,8 @@ bool EntityItem::getCollisionless() const {
return result;
}
-uint8_t EntityItem::getCollisionMask() const {
- uint8_t result;
+uint16_t EntityItem::getCollisionMask() const {
+ uint16_t result;
withReadLock([&] {
result = _collisionMask;
});
@@ -2975,3 +3033,118 @@ std::unordered_map EntityItem::getMaterial
}
return toReturn;
}
+
+bool EntityItem::getCloneable() const {
+ bool result;
+ withReadLock([&] {
+ result = _cloneable;
+ });
+ return result;
+}
+
+void EntityItem::setCloneable(bool value) {
+ withWriteLock([&] {
+ _cloneable = value;
+ });
+}
+
+float EntityItem::getCloneLifetime() const {
+ float result;
+ withReadLock([&] {
+ result = _cloneLifetime;
+ });
+ return result;
+}
+
+void EntityItem::setCloneLifetime(float value) {
+ withWriteLock([&] {
+ _cloneLifetime = value;
+ });
+}
+
+float EntityItem::getCloneLimit() const {
+ float result;
+ withReadLock([&] {
+ result = _cloneLimit;
+ });
+ return result;
+}
+
+void EntityItem::setCloneLimit(float value) {
+ withWriteLock([&] {
+ _cloneLimit = value;
+ });
+}
+
+bool EntityItem::getCloneDynamic() const {
+ bool result;
+ withReadLock([&] {
+ result = _cloneDynamic;
+ });
+ return result;
+}
+
+void EntityItem::setCloneDynamic(bool value) {
+ withWriteLock([&] {
+ _cloneDynamic = value;
+ });
+}
+
+bool EntityItem::getCloneAvatarEntity() const {
+ bool result;
+ withReadLock([&] {
+ result = _cloneAvatarEntity;
+ });
+ return result;
+}
+
+void EntityItem::setCloneAvatarEntity(bool value) {
+ withWriteLock([&] {
+ _cloneAvatarEntity = value;
+ });
+}
+
+const QUuid EntityItem::getCloneOriginID() const {
+ QUuid result;
+ withReadLock([&] {
+ result = _cloneOriginID;
+ });
+ return result;
+}
+
+void EntityItem::setCloneOriginID(const QUuid& value) {
+ withWriteLock([&] {
+ _cloneOriginID = value;
+ });
+}
+
+void EntityItem::addCloneID(const QUuid& cloneID) {
+ withWriteLock([&] {
+ if (!_cloneIDs.contains(cloneID)) {
+ _cloneIDs.append(cloneID);
+ }
+ });
+}
+
+void EntityItem::removeCloneID(const QUuid& cloneID) {
+ withWriteLock([&] {
+ int index = _cloneIDs.indexOf(cloneID);
+ if (index >= 0) {
+ _cloneIDs.removeAt(index);
+ }
+ });
+}
+
+const QVector EntityItem::getCloneIDs() const {
+ QVector result;
+ withReadLock([&] {
+ result = _cloneIDs;
+ });
+ return result;
+}
+
+void EntityItem::setCloneIDs(const QVector& cloneIDs) {
+ withWriteLock([&] {
+ _cloneIDs = cloneIDs;
+ });
+}
diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h
index a88250a133..0acf8dbbc1 100644
--- a/libraries/entities/src/EntityItem.h
+++ b/libraries/entities/src/EntityItem.h
@@ -277,6 +277,9 @@ public:
bool getVisible() const;
void setVisible(bool value);
+ bool isVisibleInSecondaryCamera() const;
+ void setIsVisibleInSecondaryCamera(bool value);
+
bool getCanCastShadow() const;
void setCanCastShadow(bool value);
@@ -288,10 +291,10 @@ public:
bool getCollisionless() const;
void setCollisionless(bool value);
- uint8_t getCollisionMask() const;
- void setCollisionMask(uint8_t value);
+ uint16_t getCollisionMask() const;
+ void setCollisionMask(uint16_t value);
- void computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask) const;
+ void computeCollisionGroupAndFinalMask(int32_t& group, int32_t& mask) const;
bool getDynamic() const;
void setDynamic(bool value);
@@ -341,6 +344,19 @@ public:
quint32 getStaticCertificateVersion() const;
void setStaticCertificateVersion(const quint32&);
+ bool getCloneable() const;
+ void setCloneable(bool value);
+ float getCloneLifetime() const;
+ void setCloneLifetime(float value);
+ float getCloneLimit() const;
+ void setCloneLimit(float value);
+ bool getCloneDynamic() const;
+ void setCloneDynamic(bool value);
+ bool getCloneAvatarEntity() const;
+ void setCloneAvatarEntity(bool value);
+ const QUuid getCloneOriginID() const;
+ void setCloneOriginID(const QUuid& value);
+
// TODO: get rid of users of getRadius()...
float getRadius() const;
@@ -494,6 +510,11 @@ public:
void setSimulationOwnershipExpiry(uint64_t expiry) { _simulationOwnershipExpiry = expiry; }
uint64_t getSimulationOwnershipExpiry() const { return _simulationOwnershipExpiry; }
+ void addCloneID(const QUuid& cloneID);
+ void removeCloneID(const QUuid& cloneID);
+ const QVector getCloneIDs() const;
+ void setCloneIDs(const QVector& cloneIDs);
+
signals:
void requestRenderUpdate();
@@ -560,9 +581,10 @@ protected:
glm::vec3 _registrationPoint { ENTITY_ITEM_DEFAULT_REGISTRATION_POINT };
float _angularDamping { ENTITY_ITEM_DEFAULT_ANGULAR_DAMPING };
bool _visible { ENTITY_ITEM_DEFAULT_VISIBLE };
+ bool _isVisibleInSecondaryCamera { ENTITY_ITEM_DEFAULT_VISIBLE_IN_SECONDARY_CAMERA };
bool _canCastShadow{ ENTITY_ITEM_DEFAULT_CAN_CAST_SHADOW };
bool _collisionless { ENTITY_ITEM_DEFAULT_COLLISIONLESS };
- uint8_t _collisionMask { ENTITY_COLLISION_MASK_DEFAULT };
+ uint16_t _collisionMask { ENTITY_COLLISION_MASK_DEFAULT };
bool _dynamic { ENTITY_ITEM_DEFAULT_DYNAMIC };
bool _locked { ENTITY_ITEM_DEFAULT_LOCKED };
QString _userData { ENTITY_ITEM_DEFAULT_USER_DATA };
@@ -648,6 +670,14 @@ protected:
bool _cauterized { false }; // if true, don't draw because it would obscure 1st-person camera
+ bool _cloneable { ENTITY_ITEM_DEFAULT_CLONEABLE };
+ float _cloneLifetime { ENTITY_ITEM_DEFAULT_CLONE_LIFETIME };
+ float _cloneLimit { ENTITY_ITEM_DEFAULT_CLONE_LIMIT };
+ bool _cloneDynamic { ENTITY_ITEM_DEFAULT_CLONE_DYNAMIC };
+ bool _cloneAvatarEntity { ENTITY_ITEM_DEFAULT_CLONE_AVATAR_ENTITY };
+ QUuid _cloneOriginID;
+ QVector _cloneIDs;
+
private:
std::unordered_map _materials;
std::mutex _materialsLock;
diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp
index 4d7c114176..84e248b74d 100644
--- a/libraries/entities/src/EntityItemProperties.cpp
+++ b/libraries/entities/src/EntityItemProperties.cpp
@@ -130,7 +130,7 @@ void buildStringToMaterialMappingModeLookup() {
addMaterialMappingMode(PROJECTED);
}
-QString getCollisionGroupAsString(uint8_t group) {
+QString getCollisionGroupAsString(uint16_t group) {
switch (group) {
case USER_COLLISION_GROUP_DYNAMIC:
return "dynamic";
@@ -146,7 +146,7 @@ QString getCollisionGroupAsString(uint8_t group) {
return "";
}
-uint8_t getCollisionGroupAsBitMask(const QStringRef& name) {
+uint16_t getCollisionGroupAsBitMask(const QStringRef& name) {
if (0 == name.compare(QString("dynamic"))) {
return USER_COLLISION_GROUP_DYNAMIC;
} else if (0 == name.compare(QString("static"))) {
@@ -164,7 +164,7 @@ uint8_t getCollisionGroupAsBitMask(const QStringRef& name) {
QString EntityItemProperties::getCollisionMaskAsString() const {
QString maskString("");
for (int i = 0; i < NUM_USER_COLLISION_GROUPS; ++i) {
- uint8_t group = 0x01 << i;
+ uint16_t group = 0x0001 << i;
if (group & _collisionMask) {
maskString.append(getCollisionGroupAsString(group));
maskString.append(',');
@@ -175,7 +175,7 @@ QString EntityItemProperties::getCollisionMaskAsString() const {
void EntityItemProperties::setCollisionMaskFromString(const QString& maskString) {
QVector groups = maskString.splitRef(',');
- uint8_t mask = 0x00;
+ uint16_t mask = 0x0000;
for (auto groupName : groups) {
mask |= getCollisionGroupAsBitMask(groupName);
}
@@ -368,6 +368,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_MATERIAL_MAPPING_SCALE, materialMappingScale);
CHECK_PROPERTY_CHANGE(PROP_MATERIAL_MAPPING_ROT, materialMappingRot);
CHECK_PROPERTY_CHANGE(PROP_MATERIAL_DATA, materialData);
+ CHECK_PROPERTY_CHANGE(PROP_VISIBLE_IN_SECONDARY_CAMERA, isVisibleInSecondaryCamera);
// Certifiable Properties
CHECK_PROPERTY_CHANGE(PROP_ITEM_NAME, itemName);
@@ -436,6 +437,13 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_DPI, dpi);
CHECK_PROPERTY_CHANGE(PROP_RELAY_PARENT_JOINTS, relayParentJoints);
+ CHECK_PROPERTY_CHANGE(PROP_CLONEABLE, cloneable);
+ CHECK_PROPERTY_CHANGE(PROP_CLONE_LIFETIME, cloneLifetime);
+ CHECK_PROPERTY_CHANGE(PROP_CLONE_LIMIT, cloneLimit);
+ CHECK_PROPERTY_CHANGE(PROP_CLONE_DYNAMIC, cloneDynamic);
+ CHECK_PROPERTY_CHANGE(PROP_CLONE_AVATAR_ENTITY, cloneAvatarEntity);
+ CHECK_PROPERTY_CHANGE(PROP_CLONE_ORIGIN_ID, cloneOriginID);
+
changedProperties += _animation.getChangedProperties();
changedProperties += _keyLight.getChangedProperties();
changedProperties += _ambientLight.getChangedProperties();
@@ -479,10 +487,11 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
* @property {boolean} locked=false - Whether or not the entity can be edited or deleted. If