diff --git a/interface/resources/controllers/xbox.json b/interface/resources/controllers/xbox.json index 1234372a7e..c4b9da9ae2 100644 --- a/interface/resources/controllers/xbox.json +++ b/interface/resources/controllers/xbox.json @@ -1,28 +1,49 @@ { "name": "XBox to Standard", "channels": [ - { "from": "GamePad.LY", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.LY" }, - { "from": "GamePad.LX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.LX" }, + { "from": "GamePad.LY", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.TranslateZ" }, + { "from": "GamePad.LX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.TranslateX" }, { "from": "GamePad.LT", "to": "Standard.LT" }, { "from": "GamePad.LB", "to": "Standard.LB" }, { "from": "GamePad.LS", "to": "Standard.LS" }, - { "from": "GamePad.RY", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.RY" }, - { "from": "GamePad.RX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Standard.RX" }, + + { "from": "GamePad.RX", + "when": [ "Application.InHMD", "Application.SnapTurn" ], + "to": "Actions.StepYaw", + "filters": + [ + { "type": "deadZone", "min": 0.15 }, + "constrainToInteger", + { "type": "pulse", "interval": 0.25 }, + { "type": "scale", "scale": 22.5 } + ] + }, + + { "from": "GamePad.RX", "to": "Actions.Yaw" }, + + { "from": "GamePad.RY", + "to": "Actions.VERTICAL_UP", + "filters": + [ + { "type": "deadZone", "min": 0.95 }, + "invert" + ] + }, + { "from": "GamePad.RT", "to": "Standard.RT" }, { "from": "GamePad.RB", "to": "Standard.RB" }, { "from": "GamePad.RS", "to": "Standard.RS" }, - { "from": "GamePad.Back", "to": "Standard.Back" }, - { "from": "GamePad.Start", "to": "Standard.Start" }, + { "from": "GamePad.Start", "to": "Actions.CycleCamera" }, + { "from": "GamePad.Back", "to": "Actions.ContextMenu" }, - { "from": [ "GamePad.DU", "GamePad.DL", "GamePad.DR", "GamePad.DD" ], "to": "Standard.LeftPrimaryThumb", "peek": true }, { "from": "GamePad.DU", "to": "Standard.DU" }, { "from": "GamePad.DD", "to": "Standard.DD" }, { "from": "GamePad.DL", "to": "Standard.DL" }, { "from": "GamePad.DR", "to": "Standard.DR" }, - { "from": [ "GamePad.A", "GamePad.B", "GamePad.X", "GamePad.Y" ], "to": "Standard.RightPrimaryThumb", "peek": true }, + { "from": [ "GamePad.Y" ], "to": "Standard.RightPrimaryThumb", "peek": true }, { "from": "GamePad.A", "to": "Standard.A" }, { "from": "GamePad.B", "to": "Standard.B" }, { "from": "GamePad.X", "to": "Standard.X" }, diff --git a/interface/resources/qml/AssetServer.qml b/interface/resources/qml/AssetServer.qml index 050bc8e99e..ec866a6f0e 100644 --- a/interface/resources/qml/AssetServer.qml +++ b/interface/resources/qml/AssetServer.qml @@ -184,7 +184,7 @@ ScrollingWindow { prompt.selected.connect(function (jsonResult) { if (jsonResult) { var result = JSON.parse(jsonResult); - var url = result.textInput; + var url = result.textInput.trim(); var shapeType; switch (result.comboBox) { case SHAPE_TYPE_SIMPLE_HULL: diff --git a/interface/resources/qml/controls-uit/ComboBox.qml b/interface/resources/qml/controls-uit/ComboBox.qml index fa100a965f..573fed4ef9 100644 --- a/interface/resources/qml/controls-uit/ComboBox.qml +++ b/interface/resources/qml/controls-uit/ComboBox.qml @@ -32,6 +32,8 @@ FocusScope { readonly property ComboBox control: comboBox + signal accepted(); + implicitHeight: comboBox.height; focus: true @@ -134,6 +136,7 @@ FocusScope { function hideList() { popup.visible = false; scrollView.hoverEnabled = false; + root.accepted(); } FocusScope { diff --git a/interface/resources/qml/dialogs/CustomQueryDialog.qml b/interface/resources/qml/dialogs/CustomQueryDialog.qml index 0cc2a8e002..97f55d087b 100644 --- a/interface/resources/qml/dialogs/CustomQueryDialog.qml +++ b/interface/resources/qml/dialogs/CustomQueryDialog.qml @@ -189,6 +189,7 @@ ModalWindow { left: parent.left; bottom: parent.bottom; leftMargin: 6; // Magic number to align with warning icon + bottomMargin: 6; } } @@ -202,7 +203,10 @@ ModalWindow { bottom: parent.bottom; } model: root.comboBox ? root.comboBox.items : []; - onCurrentTextChanged: updateCheckbox(); + onAccepted: { + updateCheckbox(); + focus = true; + } } } @@ -315,6 +319,7 @@ ModalWindow { Component.onCompleted: { keyboardEnabled = HMD.active; updateIcon(); + updateCheckbox(); d.resize(); textField.forceActiveFocus(); } diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 6fbd93e386..5fced85d2d 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -867,6 +867,10 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) { void AudioClient::handleAudioInput() { + if (!_inputDevice) { + return; + } + // input samples required to produce exactly NETWORK_FRAME_SAMPLES of output const int inputSamplesRequired = (_inputToNetworkResampler ? _inputToNetworkResampler->getMinInput(AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL) : diff --git a/libraries/controllers/src/controllers/ScriptingInterface.cpp b/libraries/controllers/src/controllers/ScriptingInterface.cpp index 78e9378c18..d32acb3d82 100644 --- a/libraries/controllers/src/controllers/ScriptingInterface.cpp +++ b/libraries/controllers/src/controllers/ScriptingInterface.cpp @@ -95,6 +95,11 @@ namespace controller { 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()); } diff --git a/libraries/controllers/src/controllers/ScriptingInterface.h b/libraries/controllers/src/controllers/ScriptingInterface.h index 713e864561..b47a6fea31 100644 --- a/libraries/controllers/src/controllers/ScriptingInterface.h +++ b/libraries/controllers/src/controllers/ScriptingInterface.h @@ -81,6 +81,7 @@ namespace controller { Q_INVOKABLE float getValue(const int& source) const; Q_INVOKABLE float getButtonValue(StandardButtonChannel source, uint16_t device = 0) const; Q_INVOKABLE float getAxisValue(StandardAxisChannel source, uint16_t device = 0) const; + Q_INVOKABLE float getAxisValue(int source) const; Q_INVOKABLE Pose getPoseValue(const int& source) const; Q_INVOKABLE Pose getPoseValue(StandardPoseChannel source, uint16_t device = 0) const; diff --git a/libraries/controllers/src/controllers/impl/endpoints/AnyEndpoint.cpp b/libraries/controllers/src/controllers/impl/endpoints/AnyEndpoint.cpp index a3b719b2c1..598dfb6ee8 100644 --- a/libraries/controllers/src/controllers/impl/endpoints/AnyEndpoint.cpp +++ b/libraries/controllers/src/controllers/impl/endpoints/AnyEndpoint.cpp @@ -27,19 +27,27 @@ AnyEndpoint::AnyEndpoint(Endpoint::List children) : Endpoint(Input::INVALID_INPU } } +// The value of an any-point is considered to be the maxiumum absolute value, +// this handles any's of multiple axis values as well as single values as well float AnyEndpoint::peek() const { - float result = 0; + float result = 0.0f; for (auto& child : _children) { - result = std::max(result, child->peek()); + auto childValue = child->peek(); + if (std::abs(childValue) > std::abs(result)) { + result = childValue; + } } return result; } // Fetching the value must trigger any necessary side effects of value() on ALL the children. float AnyEndpoint::value() { - float result = 0; + float result = 0.0f; for (auto& child : _children) { - result = std::max(result, child->value()); + auto childValue = child->value(); + if (std::abs(childValue) > std::abs(result)) { + result = childValue; + } } return result; } diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp index 70535e7a0a..ad165beba1 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp @@ -374,7 +374,8 @@ void HmdDisplayPlugin::updateFrameData() { } // this offset needs to match GRAB_POINT_SPHERE_OFFSET in scripts/system/libraries/controllers.js - static const vec3 GRAB_POINT_SPHERE_OFFSET = vec3(0.1f, 0.04f, -0.32f); + //static const vec3 GRAB_POINT_SPHERE_OFFSET = vec3(0.1f, 0.04f, -0.32f); + static const vec3 GRAB_POINT_SPHERE_OFFSET = vec3(0.0f, 0.0f, -0.175f); vec3 grabPointOffset = GRAB_POINT_SPHERE_OFFSET; if (i == 0) { grabPointOffset.x *= -1.0f; // this changes between left and right hands diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp index c082c00609..3c34765011 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackend.cpp @@ -666,7 +666,6 @@ void GLBackend::recycle() const { for (auto pair : externalTexturesTrash) { auto fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); pair.second(pair.first, fence); - decrementTextureGPUCount(); } } diff --git a/libraries/gpu-gl/src/gpu/gl/GLBackendPipeline.cpp b/libraries/gpu-gl/src/gpu/gl/GLBackendPipeline.cpp index f18962976c..ed0b9607e6 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLBackendPipeline.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLBackendPipeline.cpp @@ -192,6 +192,11 @@ void GLBackend::resetResourceStage() { void GLBackend::do_setResourceTexture(const Batch& batch, size_t paramOffset) { GLuint slot = batch._params[paramOffset + 1]._uint; + if (slot >= (GLuint) MAX_NUM_RESOURCE_TEXTURES) { + // "GLBackend::do_setResourceTexture: Trying to set a resource Texture at slot #" + slot + " which doesn't exist. MaxNumResourceTextures = " + getMaxNumResourceTextures()); + return; + } + TexturePointer resourceTexture = batch._textures.get(batch._params[paramOffset + 0]._uint); if (!resourceTexture) { diff --git a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp index 649065ab84..1caecb0b72 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp @@ -20,9 +20,20 @@ std::shared_ptr GLTexture::_textureTransferHelper; // FIXME placeholder for texture memory over-use #define DEFAULT_MAX_MEMORY_MB 256 -#define MIN_FREE_GPU_MEMORY_PERCENTAGE 0.25f #define OVER_MEMORY_PRESSURE 2.0f +// FIXME other apps show things like Oculus home consuming large amounts of GPU memory +// which causes us to blur textures needlessly (since other app GPU memory usage will likely +// be swapped out and not cause any actual impact +//#define CHECK_MIN_FREE_GPU_MEMORY +#ifdef CHECK_MIN_FREE_GPU_MEMORY +#define MIN_FREE_GPU_MEMORY_PERCENTAGE 0.25f +#endif + +// Allow 65% of all available GPU memory to be consumed by textures +// FIXME overly conservative? +#define MAX_CONSUMED_TEXTURE_MEMORY_PERCENTAGE 0.65f + const GLenum GLTexture::CUBE_FACE_LAYOUT[6] = { GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, @@ -107,6 +118,7 @@ float GLTexture::getMemoryPressure() { // If we can't query the dedicated memory just use a fallback fixed value of 256 MB totalGpuMemory = MB_TO_BYTES(DEFAULT_MAX_MEMORY_MB); } else { +#ifdef CHECK_MIN_FREE_GPU_MEMORY // Check the global free GPU memory auto freeGpuMemory = getFreeDedicatedMemory(); if (freeGpuMemory) { @@ -115,21 +127,26 @@ float GLTexture::getMemoryPressure() { if (freeGpuMemory != lastFreeGpuMemory) { lastFreeGpuMemory = freeGpuMemory; if (freePercentage < MIN_FREE_GPU_MEMORY_PERCENTAGE) { - qDebug() << "Exceeded max GPU memory"; + qCDebug(gpugllogging) << "Exceeded min free GPU memory " << freePercentage; return OVER_MEMORY_PRESSURE; } } } +#endif } - // Allow 50% of all available GPU memory to be consumed by textures - // FIXME overly conservative? - availableTextureMemory = (totalGpuMemory >> 1); + availableTextureMemory = static_cast(totalGpuMemory * MAX_CONSUMED_TEXTURE_MEMORY_PERCENTAGE); } // Return the consumed texture memory divided by the available texture memory. auto consumedGpuMemory = Context::getTextureGPUMemoryUsage(); - return (float)consumedGpuMemory / (float)availableTextureMemory; + float memoryPressure = (float)consumedGpuMemory / (float)availableTextureMemory; + static Context::Size lastConsumedGpuMemory = 0; + if (memoryPressure > 1.0f && lastConsumedGpuMemory != consumedGpuMemory) { + lastConsumedGpuMemory = consumedGpuMemory; + qCDebug(gpugllogging) << "Exceeded max allowed texture memory: " << consumedGpuMemory << " / " << availableTextureMemory; + } + return memoryPressure; } diff --git a/libraries/gpu/src/gpu/PackedNormal.slh b/libraries/gpu/src/gpu/PackedNormal.slh index ecb383fc30..1d834b620e 100644 --- a/libraries/gpu/src/gpu/PackedNormal.slh +++ b/libraries/gpu/src/gpu/PackedNormal.slh @@ -23,7 +23,7 @@ vec2 float32x3_to_oct(in vec3 v) { vec3 oct_to_float32x3(in vec2 e) { vec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y)); - if (v.z < 0) { + if (v.z < 0.0) { v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy); } return normalize(v); diff --git a/libraries/model/src/model/Light.slh b/libraries/model/src/model/Light.slh index 5e9d3d30c0..c9cfa1ad80 100644 --- a/libraries/model/src/model/Light.slh +++ b/libraries/model/src/model/Light.slh @@ -108,7 +108,7 @@ float evalLightAttenuation(Light l, float d) { // "Fade" the edges of light sources to make things look a bit more attractive. // Note: this tends to look a bit odd at lower exponents. - attenuation *= min(1, max(0, -(d - cutoff))); + attenuation *= min(1.0, max(0.0, -(d - cutoff))); return attenuation; } @@ -118,7 +118,7 @@ SphericalHarmonics getLightAmbientSphere(Light l) { } bool getLightHasAmbientMap(Light l) { - return l._control.x > 0; + return l._control.x > 0.0; } float getLightAmbientMapNumMips(Light l) { diff --git a/libraries/networking/src/AssetClient.cpp b/libraries/networking/src/AssetClient.cpp index f5e2caa60d..6a2cbf20cf 100644 --- a/libraries/networking/src/AssetClient.cpp +++ b/libraries/networking/src/AssetClient.cpp @@ -141,7 +141,11 @@ bool haveAssetServer() { } GetMappingRequest* AssetClient::createGetMappingRequest(const AssetPath& path) { - return new GetMappingRequest(path); + auto request = new GetMappingRequest(path); + + request->moveToThread(thread()); + + return request; } GetAllMappingsRequest* AssetClient::createGetAllMappingsRequest() { @@ -305,7 +309,7 @@ void AssetClient::handleAssetGetInfoReply(QSharedPointer messag void AssetClient::handleAssetGetReply(QSharedPointer message, SharedNodePointer senderNode) { Q_ASSERT(QThread::currentThread() == thread()); - auto assetHash = message->read(SHA256_HASH_LENGTH); + auto assetHash = message->readHead(SHA256_HASH_LENGTH); qCDebug(asset_client) << "Got reply for asset: " << assetHash.toHex(); MessageID messageID; @@ -349,8 +353,8 @@ void AssetClient::handleAssetGetReply(QSharedPointer message, S } else { auto weakNode = senderNode.toWeakRef(); - connect(message.data(), &ReceivedMessage::progress, this, [this, weakNode, messageID, length]() { - handleProgressCallback(weakNode, messageID, length); + connect(message.data(), &ReceivedMessage::progress, this, [this, weakNode, messageID, length](qint64 size) { + handleProgressCallback(weakNode, messageID, size, length); }); connect(message.data(), &ReceivedMessage::completed, this, [this, weakNode, messageID]() { handleCompleteCallback(weakNode, messageID); @@ -358,7 +362,8 @@ void AssetClient::handleAssetGetReply(QSharedPointer message, S } } -void AssetClient::handleProgressCallback(const QWeakPointer& node, MessageID messageID, DataOffset length) { +void AssetClient::handleProgressCallback(const QWeakPointer& node, MessageID messageID, + qint64 size, DataOffset length) { auto senderNode = node.toStrongRef(); if (!senderNode) { @@ -381,13 +386,7 @@ void AssetClient::handleProgressCallback(const QWeakPointer& node, Message } auto& callbacks = requestIt->second; - auto& message = callbacks.message; - - if (!message) { - return; - } - - callbacks.progressCallback(message->getSize(), length); + callbacks.progressCallback(size, length); } void AssetClient::handleCompleteCallback(const QWeakPointer& node, MessageID messageID) { diff --git a/libraries/networking/src/AssetClient.h b/libraries/networking/src/AssetClient.h index f951be762d..536a2e3603 100644 --- a/libraries/networking/src/AssetClient.h +++ b/libraries/networking/src/AssetClient.h @@ -93,7 +93,7 @@ private: bool cancelGetAssetRequest(MessageID id); bool cancelUploadAssetRequest(MessageID id); - void handleProgressCallback(const QWeakPointer& node, MessageID messageID, DataOffset length); + void handleProgressCallback(const QWeakPointer& node, MessageID messageID, qint64 size, DataOffset length); void handleCompleteCallback(const QWeakPointer& node, MessageID messageID); struct GetAssetRequestData { diff --git a/libraries/networking/src/AssetResourceRequest.cpp b/libraries/networking/src/AssetResourceRequest.cpp index f320f00dbb..11ced60ec4 100644 --- a/libraries/networking/src/AssetResourceRequest.cpp +++ b/libraries/networking/src/AssetResourceRequest.cpp @@ -11,10 +11,20 @@ #include "AssetResourceRequest.h" +#include + #include "AssetClient.h" #include "AssetUtils.h" #include "MappingRequest.h" -#include +#include "NetworkLogging.h" + +static const int DOWNLOAD_PROGRESS_LOG_INTERVAL_SECONDS = 5; + +AssetResourceRequest::AssetResourceRequest(const QUrl& url) : + ResourceRequest(url) +{ + _lastProgressDebug = p_high_resolution_clock::now() - std::chrono::seconds(DOWNLOAD_PROGRESS_LOG_INTERVAL_SECONDS); +} AssetResourceRequest::~AssetResourceRequest() { if (_assetMappingRequest) { @@ -24,10 +34,6 @@ AssetResourceRequest::~AssetResourceRequest() { if (_assetRequest) { _assetRequest->deleteLater(); } - - if (_sendTimer) { - cleanupTimer(); - } } bool AssetResourceRequest::urlIsAssetHash() const { @@ -37,24 +43,6 @@ bool AssetResourceRequest::urlIsAssetHash() const { return hashRegex.exactMatch(_url.toString()); } -void AssetResourceRequest::setupTimer() { - Q_ASSERT(!_sendTimer); - static const int TIMEOUT_MS = 2000; - - _sendTimer = new QTimer(this); - connect(_sendTimer, &QTimer::timeout, this, &AssetResourceRequest::onTimeout); - - _sendTimer->setSingleShot(true); - _sendTimer->start(TIMEOUT_MS); -} - -void AssetResourceRequest::cleanupTimer() { - Q_ASSERT(_sendTimer); - disconnect(_sendTimer, 0, this, 0); - _sendTimer->deleteLater(); - _sendTimer = nullptr; -} - void AssetResourceRequest::doSend() { // We'll either have a hash or an ATP path to a file (that maps to a hash) if (urlIsAssetHash()) { @@ -81,8 +69,6 @@ void AssetResourceRequest::requestMappingForPath(const AssetPath& path) { Q_ASSERT(_state == InProgress); Q_ASSERT(request == _assetMappingRequest); - cleanupTimer(); - switch (request->getError()) { case MappingRequest::NoError: // we have no error, we should have a resulting hash - use that to send of a request for that asset @@ -118,7 +104,6 @@ void AssetResourceRequest::requestMappingForPath(const AssetPath& path) { _assetMappingRequest = nullptr; }); - setupTimer(); _assetMappingRequest->start(); } @@ -133,8 +118,6 @@ void AssetResourceRequest::requestHash(const AssetHash& hash) { Q_ASSERT(_state == InProgress); Q_ASSERT(req == _assetRequest); Q_ASSERT(req->getState() == AssetRequest::Finished); - - cleanupTimer(); switch (req->getError()) { case AssetRequest::Error::NoError: @@ -162,35 +145,29 @@ void AssetResourceRequest::requestHash(const AssetHash& hash) { _assetRequest = nullptr; }); - setupTimer(); _assetRequest->start(); } void AssetResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) { Q_ASSERT(_state == InProgress); - // We've received data, so reset the timer - _sendTimer->start(); - emit progress(bytesReceived, bytesTotal); + + auto now = p_high_resolution_clock::now(); + + // if we haven't received the full asset check if it is time to output progress to log + // we do so every X seconds to assist with ATP download tracking + + if (bytesReceived != bytesTotal + && now - _lastProgressDebug > std::chrono::seconds(DOWNLOAD_PROGRESS_LOG_INTERVAL_SECONDS)) { + + int percentage = roundf((float) bytesReceived / (float) bytesTotal * 100.0f); + + qCDebug(networking).nospace() << "Progress for " << _url.path() << " - " + << bytesReceived << " of " << bytesTotal << " bytes - " << percentage << "%"; + + _lastProgressDebug = now; + } + } -void AssetResourceRequest::onTimeout() { - if (_state == InProgress) { - qWarning() << "Asset request timed out: " << _url; - if (_assetRequest) { - disconnect(_assetRequest, 0, this, 0); - _assetRequest->deleteLater(); - _assetRequest = nullptr; - } - if (_assetMappingRequest) { - disconnect(_assetMappingRequest, 0, this, 0); - _assetMappingRequest->deleteLater(); - _assetMappingRequest = nullptr; - } - _result = Timeout; - _state = Finished; - emit finished(); - } - cleanupTimer(); -} diff --git a/libraries/networking/src/AssetResourceRequest.h b/libraries/networking/src/AssetResourceRequest.h index c462fbc3f8..3f110fae17 100644 --- a/libraries/networking/src/AssetResourceRequest.h +++ b/libraries/networking/src/AssetResourceRequest.h @@ -14,13 +14,15 @@ #include +#include + #include "AssetRequest.h" #include "ResourceRequest.h" class AssetResourceRequest : public ResourceRequest { Q_OBJECT public: - AssetResourceRequest(const QUrl& url) : ResourceRequest(url) { } + AssetResourceRequest(const QUrl& url); virtual ~AssetResourceRequest() override; protected: @@ -28,21 +30,17 @@ protected: private slots: void onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal); - void onTimeout(); private: - void setupTimer(); - void cleanupTimer(); - bool urlIsAssetHash() const; void requestMappingForPath(const AssetPath& path); void requestHash(const AssetHash& hash); - QTimer* _sendTimer { nullptr }; - GetMappingRequest* _assetMappingRequest { nullptr }; AssetRequest* _assetRequest { nullptr }; + + p_high_resolution_clock::time_point _lastProgressDebug; }; #endif diff --git a/libraries/networking/src/ReceivedMessage.cpp b/libraries/networking/src/ReceivedMessage.cpp index cd3eb03473..02cb58fb2d 100644 --- a/libraries/networking/src/ReceivedMessage.cpp +++ b/libraries/networking/src/ReceivedMessage.cpp @@ -54,14 +54,14 @@ void ReceivedMessage::appendPacket(NLPacket& packet) { "We should not be appending to a complete message"); // Limit progress signal to every X packets - const int EMIT_PROGRESS_EVERY_X_PACKETS = 100; + const int EMIT_PROGRESS_EVERY_X_PACKETS = 50; ++_numPackets; _data.append(packet.getPayload(), packet.getPayloadSize()); if (_numPackets % EMIT_PROGRESS_EVERY_X_PACKETS == 0) { - emit progress(); + emit progress(getSize()); } if (packet.getPacketPosition() == NLPacket::PacketPosition::LAST) { diff --git a/libraries/networking/src/ReceivedMessage.h b/libraries/networking/src/ReceivedMessage.h index e9131c074f..3acb7163e7 100644 --- a/libraries/networking/src/ReceivedMessage.h +++ b/libraries/networking/src/ReceivedMessage.h @@ -78,7 +78,7 @@ public: template qint64 readHeadPrimitive(T* data); signals: - void progress(); + void progress(qint64 size); void completed(); private slots: diff --git a/libraries/render-utils/src/DeferredBufferRead.slh b/libraries/render-utils/src/DeferredBufferRead.slh index 6b5060cc5f..7cba2007cc 100644 --- a/libraries/render-utils/src/DeferredBufferRead.slh +++ b/libraries/render-utils/src/DeferredBufferRead.slh @@ -51,7 +51,7 @@ DeferredFragment unpackDeferredFragmentNoPosition(vec2 texcoord) { vec4 specularVal; DeferredFragment frag; - frag.depthVal = -1; + frag.depthVal = -1.0; normalVal = texture(normalMap, texcoord); diffuseVal = texture(albedoMap, texcoord); specularVal = texture(specularMap, texcoord); @@ -138,8 +138,8 @@ void unpackMidLowNormalCurvature(vec2 texcoord, out vec4 midNormalCurvature, out lowNormalCurvature = fetchDiffusedCurvature(texcoord); midNormalCurvature.xyz = normalize((midNormalCurvature.xyz - 0.5f) * 2.0f); lowNormalCurvature.xyz = normalize((lowNormalCurvature.xyz - 0.5f) * 2.0f); - midNormalCurvature.w = (midNormalCurvature.w * 2 - 1); - lowNormalCurvature.w = (lowNormalCurvature.w * 2 - 1); + midNormalCurvature.w = (midNormalCurvature.w * 2.0 - 1.0); + lowNormalCurvature.w = (lowNormalCurvature.w * 2.0 - 1.0); } <@endfunc@> diff --git a/libraries/render-utils/src/DeferredBufferWrite.slh b/libraries/render-utils/src/DeferredBufferWrite.slh index aa79781c25..2f6bfaeb61 100755 --- a/libraries/render-utils/src/DeferredBufferWrite.slh +++ b/libraries/render-utils/src/DeferredBufferWrite.slh @@ -27,8 +27,8 @@ float evalOpaqueFinalAlpha(float alpha, float mapAlpha) { } const float DEFAULT_ROUGHNESS = 0.9; -const float DEFAULT_SHININESS = 10; -const float DEFAULT_METALLIC = 0; +const float DEFAULT_SHININESS = 10.0; +const float DEFAULT_METALLIC = 0.0; const vec3 DEFAULT_SPECULAR = vec3(0.1); const vec3 DEFAULT_EMISSIVE = vec3(0.0); const float DEFAULT_OCCLUSION = 1.0; diff --git a/libraries/render-utils/src/DeferredGlobalLight.slh b/libraries/render-utils/src/DeferredGlobalLight.slh index 16cdab535c..799ad53b58 100755 --- a/libraries/render-utils/src/DeferredGlobalLight.slh +++ b/libraries/render-utils/src/DeferredGlobalLight.slh @@ -23,7 +23,7 @@ // prepareGlobalLight // Transform directions to worldspace vec3 fragNormal = vec3((normal)); - vec3 fragEyeVector = vec3(invViewMat * vec4(-position, 0.0)); + vec3 fragEyeVector = vec3(invViewMat * vec4(-1.0*position, 0.0)); vec3 fragEyeDir = normalize(fragEyeVector); // Get light @@ -143,13 +143,13 @@ vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscur float facingLight = step(PERPENDICULAR_THRESHOLD, diffuseDot); // Reevaluate the shadow attenuation for light facing fragments - float lightAttenuation = (1 - facingLight) + facingLight * shadowAttenuation; + float lightAttenuation = (1.0 - facingLight) + facingLight * shadowAttenuation; // Diffuse light is the lightmap dimmed by shadow vec3 diffuseLight = lightAttenuation * lightmap; // Ambient light is the lightmap when in shadow - vec3 ambientLight = (1 - lightAttenuation) * lightmap * getLightAmbientIntensity(light); + vec3 ambientLight = (1.0 - lightAttenuation) * lightmap * getLightAmbientIntensity(light); return isLightmapEnabled() * obscurance * albedo * (diffuseLight + ambientLight); } diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 808d765dd7..2e169e5cc3 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -478,6 +478,8 @@ void RenderDeferredSetup::run(const render::SceneContextPointer& sceneContext, c // Setup the global directional pass pipeline { if (deferredLightingEffect->_shadowMapEnabled) { + // If the keylight has an ambient Map then use the Skybox version of the pass + // otherwise use the ambient sphere version if (keyLight->getAmbientMap()) { program = deferredLightingEffect->_directionalSkyboxLightShadow; locations = deferredLightingEffect->_directionalSkyboxLightShadowLocations; @@ -486,11 +488,11 @@ void RenderDeferredSetup::run(const render::SceneContextPointer& sceneContext, c locations = deferredLightingEffect->_directionalAmbientSphereLightShadowLocations; } } else { + // If the keylight has an ambient Map then use the Skybox version of the pass + // otherwise use the ambient sphere version if (keyLight->getAmbientMap()) { - program = deferredLightingEffect->_directionalAmbientSphereLight; - locations = deferredLightingEffect->_directionalAmbientSphereLightLocations; - //program = deferredLightingEffect->_directionalSkyboxLight; - //locations = deferredLightingEffect->_directionalSkyboxLightLocations; + program = deferredLightingEffect->_directionalSkyboxLight; + locations = deferredLightingEffect->_directionalSkyboxLightLocations; } else { program = deferredLightingEffect->_directionalAmbientSphereLight; locations = deferredLightingEffect->_directionalAmbientSphereLightLocations; diff --git a/libraries/render-utils/src/LightAmbient.slh b/libraries/render-utils/src/LightAmbient.slh index ec665e6deb..b1b36ad2d4 100644 --- a/libraries/render-utils/src/LightAmbient.slh +++ b/libraries/render-utils/src/LightAmbient.slh @@ -23,7 +23,7 @@ vec4 evalSkyboxLight(vec3 direction, float lod) { <@func declareEvalAmbientSpecularIrradiance(supportAmbientSphere, supportAmbientMap, supportIfAmbientMapElseAmbientSphere)@> vec3 fresnelSchlickAmbient(vec3 fresnelColor, vec3 lightDir, vec3 halfDir, float gloss) { - return fresnelColor + (max(vec3(gloss), fresnelColor) - fresnelColor) * pow(1.0 - clamp(dot(lightDir, halfDir), 0.0, 1.0), 5); + return fresnelColor + (max(vec3(gloss), fresnelColor) - fresnelColor) * pow(1.0 - clamp(dot(lightDir, halfDir), 0.0, 1.0), 5.0); } <@if supportAmbientMap@> @@ -32,7 +32,7 @@ vec3 fresnelSchlickAmbient(vec3 fresnelColor, vec3 lightDir, vec3 halfDir, float vec3 evalAmbientSpecularIrradiance(Light light, vec3 fragEyeDir, vec3 fragNormal, float roughness, vec3 fresnel) { vec3 direction = -reflect(fragEyeDir, fragNormal); - vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, fragEyeDir, fragNormal, 1 - roughness); + vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, fragEyeDir, fragNormal, 1.0 - roughness); vec3 specularLight; <@if supportIfAmbientMapElseAmbientSphere@> if (getLightHasAmbientMap(light)) @@ -76,7 +76,7 @@ void evalLightingAmbient(out vec3 diffuse, out vec3 specular, Light light, vec3 // Diffuse from ambient - diffuse = (1 - metallic) * evalSphericalLight(getLightAmbientSphere(light), normal).xyz; + diffuse = (1.0 - metallic) * evalSphericalLight(getLightAmbientSphere(light), normal).xyz; // Specular highlight from ambient specular = evalAmbientSpecularIrradiance(light, eyeDir, normal, roughness, fresnel) * obscurance * getLightAmbientIntensity(light); diff --git a/libraries/render-utils/src/LightPoint.slh b/libraries/render-utils/src/LightPoint.slh index 5c9e66dd24..f4d20aa58e 100644 --- a/libraries/render-utils/src/LightPoint.slh +++ b/libraries/render-utils/src/LightPoint.slh @@ -40,7 +40,7 @@ void evalLightingPoint(out vec3 diffuse, out vec3 specular, Light light, if (isShowLightContour() > 0.0) { // Show edge float edge = abs(2.0 * ((getLightRadius(light) - fragLightDistance) / (0.1)) - 1.0); - if (edge < 1) { + if (edge < 1.0) { float edgeCoord = exp2(-8.0*edge*edge); diffuse = vec3(edgeCoord * edgeCoord * getLightShowContour(light) * getLightColor(light)); } diff --git a/libraries/render-utils/src/LightSpot.slh b/libraries/render-utils/src/LightSpot.slh index 8a17a5ef4d..7f39a1e5f9 100644 --- a/libraries/render-utils/src/LightSpot.slh +++ b/libraries/render-utils/src/LightSpot.slh @@ -44,7 +44,7 @@ void evalLightingSpot(out vec3 diffuse, out vec3 specular, Light light, float edgeDistS = dot(fragLightDistance * vec2(cosSpotAngle, sqrt(1.0 - cosSpotAngle * cosSpotAngle)), -getLightSpotOutsideNormal2(light)); float edgeDist = min(edgeDistR, edgeDistS); float edge = abs(2.0 * (edgeDist / (0.1)) - 1.0); - if (edge < 1) { + if (edge < 1.0) { float edgeCoord = exp2(-8.0*edge*edge); diffuse = vec3(edgeCoord * edgeCoord * getLightColor(light)); } diff --git a/libraries/render-utils/src/LightingModel.slh b/libraries/render-utils/src/LightingModel.slh index f36b2d8131..3bc05fc54f 100644 --- a/libraries/render-utils/src/LightingModel.slh +++ b/libraries/render-utils/src/LightingModel.slh @@ -118,8 +118,8 @@ vec3 fresnelSchlickColor(vec3 fresnelColor, vec3 lightDir, vec3 halfDir) { float specularDistribution(float roughness, vec3 normal, vec3 halfDir) { float ndoth = clamp(dot(halfDir, normal), 0.0, 1.0); - float gloss2 = pow(0.001 + roughness, 4); - float denom = (ndoth * ndoth*(gloss2 - 1) + 1); + float gloss2 = pow(0.001 + roughness, 4.0); + float denom = (ndoth * ndoth*(gloss2 - 1.0) + 1.0); float power = gloss2 / (3.14159 * denom * denom); return power; } @@ -142,7 +142,7 @@ vec4 evalPBRShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, float m float power = specularDistribution(roughness, fragNormal, halfDir); vec3 specular = power * fresnelColor * diffuse; - return vec4(specular, (1.0 - metallic) * diffuse * (1 - fresnelColor.x)); + return vec4(specular, (1.0 - metallic) * diffuse * (1.0 - fresnelColor.x)); } <@endfunc@> diff --git a/libraries/render-utils/src/SubsurfaceScattering.slh b/libraries/render-utils/src/SubsurfaceScattering.slh index 6d5dd01d8f..42ffafd9ff 100644 --- a/libraries/render-utils/src/SubsurfaceScattering.slh +++ b/libraries/render-utils/src/SubsurfaceScattering.slh @@ -137,7 +137,7 @@ vec3 integrate(float cosTheta, float skinRadius) { uniform sampler2D scatteringLUT; vec3 fetchBRDF(float LdotN, float curvature) { - return texture(scatteringLUT, vec2( clamp(LdotN * 0.5 + 0.5, 0.0, 1.0), clamp(2 * curvature, 0.0, 1.0))).xyz; + return texture(scatteringLUT, vec2( clamp(LdotN * 0.5 + 0.5, 0.0, 1.0), clamp(2.0 * curvature, 0.0, 1.0))).xyz; } vec3 fetchBRDFSpectrum(vec3 LdotNSpectrum, float curvature) { @@ -183,7 +183,7 @@ float tuneCurvatureUnsigned(float curvature) { } float unpackCurvature(float packedCurvature) { - return (packedCurvature * 2 - 1); + return (packedCurvature * 2.0 - 1.0); } vec3 evalScatteringBentNdotL(vec3 normal, vec3 midNormal, vec3 lowNormal, vec3 lightDir) { @@ -210,7 +210,7 @@ vec3 evalSkinBRDF(vec3 lightDir, vec3 normal, vec3 midNormal, vec3 lowNormal, fl return lowNormal * 0.5 + vec3(0.5); } if (showCurvature()) { - return (curvature > 0 ? vec3(curvature, 0.0, 0.0) : vec3(0.0, 0.0, -curvature)); + return (curvature > 0.0 ? vec3(curvature, 0.0, 0.0) : vec3(0.0, 0.0, -curvature)); } vec3 bentNdotL = evalScatteringBentNdotL(normal, midNormal, lowNormal, lightDir); diff --git a/libraries/render-utils/src/deferred_light.slv b/libraries/render-utils/src/deferred_light.slv index 27845bf6a2..74b3749181 100644 --- a/libraries/render-utils/src/deferred_light.slv +++ b/libraries/render-utils/src/deferred_light.slv @@ -26,7 +26,7 @@ void main(void) { ); vec4 pos = UNIT_QUAD[gl_VertexID]; - _texCoord0 = (pos.xy + 1) * 0.5; + _texCoord0 = (pos.xy + 1.0) * 0.5; _texCoord0 *= texcoordFrameTransform.zw; _texCoord0 += texcoordFrameTransform.xy; diff --git a/libraries/render-utils/src/deferred_light_limited.slv b/libraries/render-utils/src/deferred_light_limited.slv index 81ec882bdf..0525509f0b 100644 --- a/libraries/render-utils/src/deferred_light_limited.slv +++ b/libraries/render-utils/src/deferred_light_limited.slv @@ -47,7 +47,7 @@ void main(void) { ); vec4 pos = UNIT_QUAD[gl_VertexID]; - _texCoord0 = vec4((pos.xy + 1) * 0.5, 0.0, 1.0); + _texCoord0 = vec4((pos.xy + 1.0) * 0.5, 0.0, 1.0); if (cam_isStereo()) { _texCoord0.x = 0.5 * (_texCoord0.x + cam_getStereoSide()); diff --git a/libraries/render-utils/src/deferred_light_spot.slv b/libraries/render-utils/src/deferred_light_spot.slv index 6ae133b7a5..4a1a0472aa 100755 --- a/libraries/render-utils/src/deferred_light_spot.slv +++ b/libraries/render-utils/src/deferred_light_spot.slv @@ -60,7 +60,7 @@ void main(void) { ); vec4 pos = UNIT_QUAD[gl_VertexID]; - _texCoord0 = vec4((pos.xy + 1) * 0.5, 0.0, 1.0); + _texCoord0 = vec4((pos.xy + 1.0) * 0.5, 0.0, 1.0); if (cam_isStereo()) { _texCoord0.x = 0.5 * (_texCoord0.x + cam_getStereoSide()); } diff --git a/libraries/render-utils/src/directional_ambient_light.slf b/libraries/render-utils/src/directional_ambient_light.slf index 5b591cb01f..6c99d44c5f 100755 --- a/libraries/render-utils/src/directional_ambient_light.slf +++ b/libraries/render-utils/src/directional_ambient_light.slf @@ -2,7 +2,7 @@ <$VERSION_HEADER$> // Generated on <$_SCRIBE_DATE$> // -// directional_light.frag +// directional_ambient_light.frag // fragment shader // // Created by Andrzej Kapolka on 9/3/14. diff --git a/libraries/render-utils/src/directional_skybox_light.slf b/libraries/render-utils/src/directional_skybox_light.slf index 6130c8ac8e..d8a2f44042 100755 --- a/libraries/render-utils/src/directional_skybox_light.slf +++ b/libraries/render-utils/src/directional_skybox_light.slf @@ -2,7 +2,7 @@ <$VERSION_HEADER$> // Generated on <$_SCRIBE_DATE$> // -// directional_light.frag +// directional_skybox_light.frag // fragment shader // // Created by Sam Gateau on 5/8/2015. diff --git a/plugins/oculus/src/OculusBaseDisplayPlugin.cpp b/plugins/oculus/src/OculusBaseDisplayPlugin.cpp index 83da154b1f..377050064a 100644 --- a/plugins/oculus/src/OculusBaseDisplayPlugin.cpp +++ b/plugins/oculus/src/OculusBaseDisplayPlugin.cpp @@ -63,7 +63,6 @@ void OculusBaseDisplayPlugin::customizeContext() { void OculusBaseDisplayPlugin::uncustomizeContext() { Parent::uncustomizeContext(); - internalPresent(); } bool OculusBaseDisplayPlugin::internalActivate() { diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.cpp b/plugins/openvr/src/OpenVrDisplayPlugin.cpp index 68bb23a84d..c0fa0db214 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.cpp +++ b/plugins/openvr/src/OpenVrDisplayPlugin.cpp @@ -635,7 +635,11 @@ void OpenVrDisplayPlugin::postPreview() { _nextSimPoseData = nextSim; }); _nextRenderPoseData = nextRender; + + // FIXME - this looks wrong! _hmdActivityLevel = vr::k_EDeviceActivityLevel_UserInteraction; // _system->GetTrackedDeviceActivityLevel(vr::k_unTrackedDeviceIndex_Hmd); +#else + _hmdActivityLevel = _system->GetTrackedDeviceActivityLevel(vr::k_unTrackedDeviceIndex_Hmd); #endif } diff --git a/scripts/system/away.js b/scripts/system/away.js index c704da83f4..f4a1a22bf6 100644 --- a/scripts/system/away.js +++ b/scripts/system/away.js @@ -16,6 +16,7 @@ (function() { // BEGIN LOCAL_SCOPE +var BASIC_TIMER_INTERVAL = 50; // 50ms = 20hz var OVERLAY_WIDTH = 1920; var OVERLAY_HEIGHT = 1080; var OVERLAY_DATA = { @@ -49,6 +50,21 @@ var AWAY_INTRO = { endFrame: 83.0 }; +// MAIN CONTROL +var isEnabled = true; +var wasMuted; // unknonwn? +var isAway = false; // we start in the un-away state +var wasOverlaysVisible = Menu.isOptionChecked("Overlays"); +var eventMappingName = "io.highfidelity.away"; // goActive on hand controller button events, too. +var eventMapping = Controller.newMapping(eventMappingName); +var avatarPosition = MyAvatar.position; +var wasHmdMounted = HMD.mounted; + + +// some intervals we may create/delete +var avatarMovedInterval; + + // prefetch the kneel animation and hold a ref so it's always resident in memory when we need it. var _animation = AnimationCache.prefetch(AWAY_INTRO.url); @@ -125,41 +141,28 @@ function maybeMoveOverlay() { var halfWayBetweenOldAndLookAt = Vec3.multiply(lookAtChange, EASE_BY_RATIO); var newOverlayPosition = Vec3.sum(lastOverlayPosition, halfWayBetweenOldAndLookAt); lastOverlayPosition = newOverlayPosition; - var actualOverlayPositon = moveCloserToCamera(lastOverlayPosition); Overlays.editOverlay(overlayHMD, { visible: true, position: actualOverlayPositon }); // make sure desktop version is hidden Overlays.editOverlay(overlay, { visible: false }); + + // also remember avatar position + avatarPosition = MyAvatar.position; + } } } function ifAvatarMovedGoActive() { - if (Vec3.distance(MyAvatar.position, avatarPosition) > AVATAR_MOVE_FOR_ACTIVE_DISTANCE) { + var newAvatarPosition = MyAvatar.position; + if (Vec3.distance(newAvatarPosition, avatarPosition) > AVATAR_MOVE_FOR_ACTIVE_DISTANCE) { goActive(); } + avatarPosition = newAvatarPosition; } -// MAIN CONTROL -var isEnabled = true; -var wasMuted, isAway; -var wasOverlaysVisible = Menu.isOptionChecked("Overlays"); -var eventMappingName = "io.highfidelity.away"; // goActive on hand controller button events, too. -var eventMapping = Controller.newMapping(eventMappingName); -var avatarPosition = MyAvatar.position; - -// backward compatible version of getting HMD.mounted, so it works in old clients -function safeGetHMDMounted() { - if (HMD.mounted === undefined) { - return true; - } - return HMD.mounted; -} - -var wasHmdMounted = safeGetHMDMounted(); - -function goAway() { +function goAway(fromStartup) { if (!isEnabled || isAway) { return; } @@ -167,7 +170,6 @@ function goAway() { UserActivityLogger.toggledAway(true); isAway = true; - print('going "away"'); wasMuted = AudioDevice.getMuted(); if (!wasMuted) { AudioDevice.toggleMute(); @@ -189,10 +191,21 @@ function goAway() { // For HMD, the hmd preview will show the system mouse because of allowMouseCapture, // but we want to turn off our Reticle so that we don't get two in preview and a stuck one in headset. Reticle.visible = !HMD.active; - wasHmdMounted = safeGetHMDMounted(); // always remember the correct state + wasHmdMounted = HMD.mounted; // always remember the correct state avatarPosition = MyAvatar.position; - Script.update.connect(ifAvatarMovedGoActive); + + // If we're entering away mode from some other state than startup, then we create our move timer immediately. + // However if we're just stating up, we need to delay this process so that we don't think the initial teleport + // is actually a move. + if (fromStartup === undefined || fromStartup === false) { + avatarMovedInterval = Script.setInterval(ifAvatarMovedGoActive, BASIC_TIMER_INTERVAL); + } else { + var WAIT_FOR_MOVE_ON_STARTUP = 3000; // 3 seconds + Script.setTimeout(function() { + avatarMovedInterval = Script.setInterval(ifAvatarMovedGoActive, BASIC_TIMER_INTERVAL); + }, WAIT_FOR_MOVE_ON_STARTUP); + } } function goActive() { @@ -203,7 +216,6 @@ function goActive() { UserActivityLogger.toggledAway(false); isAway = false; - print('going "active"'); if (!wasMuted) { AudioDevice.toggleMute(); } @@ -230,9 +242,9 @@ function goActive() { if (HMD.active) { Reticle.position = HMD.getHUDLookAtPosition2D(); } - wasHmdMounted = safeGetHMDMounted(); // always remember the correct state + wasHmdMounted = HMD.mounted; // always remember the correct state - Script.update.disconnect(ifAvatarMovedGoActive); + Script.clearInterval(avatarMovedInterval); } function maybeGoActive(event) { @@ -250,10 +262,12 @@ var wasHmdActive = HMD.active; var wasMouseCaptured = Reticle.mouseCaptured; function maybeGoAway() { + // If our active state change (went to or from HMD mode), and we are now in the HMD, go into away if (HMD.active !== wasHmdActive) { wasHmdActive = !wasHmdActive; if (wasHmdActive) { goAway(); + return; } } @@ -264,19 +278,30 @@ function maybeGoAway() { wasMouseCaptured = !wasMouseCaptured; if (!wasMouseCaptured) { goAway(); + return; } } // If you've removed your HMD from your head, and we can detect it, we will also go away... - var hmdMounted = safeGetHMDMounted(); - if (HMD.active && !hmdMounted && wasHmdMounted) { - wasHmdMounted = hmdMounted; - goAway(); + if (HMD.mounted != wasHmdMounted) { + wasHmdMounted = HMD.mounted; + print("HMD mounted changed..."); + + // We're putting the HMD on... switch to those devices + if (HMD.mounted) { + print("NOW mounted..."); + } else { + print("HMD NOW un-mounted..."); + + if (HMD.active) { + goAway(); + return; + } + } } } function setEnabled(value) { - print("setting away enabled: ", value); if (!value) { goActive(); } @@ -293,9 +318,12 @@ var handleMessage = function(channel, message, sender) { Messages.subscribe(CHANNEL_AWAY_ENABLE); Messages.messageReceived.connect(handleMessage); -Script.update.connect(maybeMoveOverlay); +var maybeIntervalTimer = Script.setInterval(function(){ + maybeMoveOverlay(); + maybeGoAway(); +}, BASIC_TIMER_INTERVAL); + -Script.update.connect(maybeGoAway); Controller.mousePressEvent.connect(goActive); Controller.keyPressEvent.connect(maybeGoActive); // Note peek() so as to not interfere with other mappings. @@ -316,11 +344,17 @@ eventMapping.from(Controller.Standard.Start).peek().to(goActive); Controller.enableMapping(eventMappingName); Script.scriptEnding.connect(function () { - Script.update.disconnect(maybeGoAway); + Script.clearInterval(maybeIntervalTimer); goActive(); Controller.disableMapping(eventMappingName); Controller.mousePressEvent.disconnect(goActive); Controller.keyPressEvent.disconnect(maybeGoActive); }); +if (HMD.active && !HMD.mounted) { + print("Starting script, while HMD is active and not mounted..."); + goAway(true); +} + + }()); // END LOCAL_SCOPE diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 2ebf7a828d..8f54e3b62e 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -26,7 +26,7 @@ var WANT_DEBUG = false; var WANT_DEBUG_STATE = false; var WANT_DEBUG_SEARCH_NAME = null; -var FORCE_IGNORE_IK = true; +var FORCE_IGNORE_IK = false; var SHOW_GRAB_POINT_SPHERE = true; // @@ -112,7 +112,7 @@ var CHECK_TOO_FAR_UNEQUIP_TIME = 0.3; // seconds, duration between checks var GRAB_POINT_SPHERE_RADIUS = NEAR_GRAB_RADIUS; -var GRAB_POINT_SPHERE_COLOR = { red: 20, green: 90, blue: 238 }; +var GRAB_POINT_SPHERE_COLOR = { red: 240, green: 240, blue: 240 }; var GRAB_POINT_SPHERE_ALPHA = 0.85; @@ -1075,12 +1075,6 @@ function MyController(hand) { var controllerLocation = getControllerWorldLocation(this.handToController(), true); var worldHandPosition = controllerLocation.position; - if (controllerLocation.valid) { - this.grabPointSphereOn(); - } else { - this.grabPointSphereOff(); - } - var candidateEntities = Entities.findEntities(worldHandPosition, MAX_EQUIP_HOTSPOT_RADIUS); entityPropertiesCache.addEntities(candidateEntities); var potentialEquipHotspot = this.chooseBestEquipHotspot(candidateEntities); @@ -1103,9 +1097,11 @@ function MyController(hand) { if (!this.grabPointIntersectsEntity) { Controller.triggerHapticPulse(1, 20, this.hand); this.grabPointIntersectsEntity = true; + this.grabPointSphereOn(); } } else { this.grabPointIntersectsEntity = false; + this.grabPointSphereOff(); } }; @@ -1386,10 +1382,11 @@ function MyController(hand) { this.chooseBestEquipHotspot = function(candidateEntities) { var DISTANCE = 0; var equippableHotspots = this.chooseNearEquipHotspots(candidateEntities, DISTANCE); + var _this = this; if (equippableHotspots.length > 0) { // sort by distance equippableHotspots.sort(function(a, b) { - var handControllerLocation = getControllerWorldLocation(this.handToController(), true); + var handControllerLocation = getControllerWorldLocation(_this.handToController(), true); var aDistance = Vec3.distance(a.worldPosition, handControllerLocation.position); var bDistance = Vec3.distance(b.worldPosition, handControllerLocation.position); return aDistance - bDistance; @@ -1427,12 +1424,6 @@ function MyController(hand) { var controllerLocation = getControllerWorldLocation(this.handToController(), true); var handPosition = controllerLocation.position; - if (controllerLocation.valid) { - this.grabPointSphereOn(); - } else { - this.grabPointSphereOff(); - } - var rayPickInfo = this.calcRayPickInfo(this.hand); if (rayPickInfo.entityID) { @@ -1906,7 +1897,7 @@ function MyController(hand) { if (FORCE_IGNORE_IK) { this.ignoreIK = true; } else { - this.ignoreIK = grabbableData.ignoreIK ? grabbableData.ignoreIK : false; + this.ignoreIK = (grabbableData.ignoreIK !== undefined) ? grabbableData.ignoreIK : true; } var handRotation; diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 67aa8bdb13..0bcae7f409 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -830,7 +830,7 @@ function loaded() { elGrabbable.checked = properties.dynamic; elWantsTrigger.checked = false; - elIgnoreIK.checked = false; + elIgnoreIK.checked = true; var parsedUserData = {} try { parsedUserData = JSON.parse(properties.userData); @@ -1143,7 +1143,7 @@ function loaded() { userDataChanger("grabbableKey", "wantsTrigger", elWantsTrigger, elUserData, false); }); elIgnoreIK.addEventListener('change', function() { - userDataChanger("grabbableKey", "ignoreIK", elIgnoreIK, elUserData, false); + userDataChanger("grabbableKey", "ignoreIK", elIgnoreIK, elUserData, true); }); elCollisionSoundURL.addEventListener('change', createEmitTextPropertyUpdateFunction('collisionSoundURL')); @@ -1596,4 +1596,4 @@ function loaded() { document.addEventListener("contextmenu", function(event) { event.preventDefault(); }, false); -} \ No newline at end of file +} diff --git a/scripts/system/libraries/controllers.js b/scripts/system/libraries/controllers.js index 9bae46380e..c77ce4578c 100644 --- a/scripts/system/libraries/controllers.js +++ b/scripts/system/libraries/controllers.js @@ -10,9 +10,10 @@ // var GRAB_POINT_SPHERE_OFFSET = { x: 0, y: 0.2, z: 0 }; // var GRAB_POINT_SPHERE_OFFSET = { x: 0.1, y: 0.175, z: 0.04 }; +// var GRAB_POINT_SPHERE_OFFSET = { x: 0.1, y: 0.32, z: 0.04 }; // this offset needs to match the one in libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp -var GRAB_POINT_SPHERE_OFFSET = { x: 0.1, y: 0.32, z: 0.04 }; +var GRAB_POINT_SPHERE_OFFSET = { x: 0.0, y: 0.175, z: 0.0 }; getGrabPointSphereOffset = function(handController) { if (handController === Controller.Standard.RightHand) { diff --git a/scripts/system/users.js b/scripts/system/users.js index 1e1a68fd9c..af88e73362 100644 --- a/scripts/system/users.js +++ b/scripts/system/users.js @@ -1133,6 +1133,7 @@ var usersWindow = (function () { if (VISIBILITY_VALUES.indexOf(myVisibility) === -1) { myVisibility = VISIBILITY_FRIENDS; } + GlobalServices.findableBy = myVisibility; visibilityControl = new PopUpMenu({ prompt: VISIBILITY_PROMPT,