diff --git a/interface/resources/qml/hifi/audio/PlaySampleSound.qml b/interface/resources/qml/hifi/audio/PlaySampleSound.qml index fdf579420d..dec2e9bfc9 100644 --- a/interface/resources/qml/hifi/audio/PlaySampleSound.qml +++ b/interface/resources/qml/hifi/audio/PlaySampleSound.qml @@ -22,8 +22,7 @@ RowLayout { property var sample: null; property bool isPlaying: false; function createSampleSound() { - var SOUND = Qt.resolvedUrl("../../../sounds/sample.wav"); - sound = SoundCache.getSound(SOUND); + sound = ApplicationInterface.getSampleSound(); sample = null; } function playSound() { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4f6e871d48..dbc1d4cfbd 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -760,7 +760,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _notifiedPacketVersionMismatchThisDomain(false), _maxOctreePPS(maxOctreePacketsPerSecond.get()), _lastFaceTrackerUpdate(0), - _snapshotSound(nullptr) + _snapshotSound(nullptr), + _sampleSound(nullptr) + { auto steamClient = PluginManager::getInstance()->getSteamClientPlugin(); setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning())); @@ -805,7 +807,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo installNativeEventFilter(&MyNativeEventFilter::getInstance()); #endif - _logger = new FileLogger(this); qInstallMessageHandler(messageHandler); @@ -982,6 +983,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(myAvatar.get(), &MyAvatar::positionGoneTo, DependencyManager::get().data(), &AddressManager::storeCurrentAddress); + // Inititalize sample before registering + QFileInfo infSample = QFileInfo(PathUtils::resourcesPath() + "sounds/sample.wav"); + _sampleSound = DependencyManager::get()->getSound(QUrl::fromLocalFile(infSample.absoluteFilePath())); + auto scriptEngines = DependencyManager::get().data(); scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine){ registerScriptEngineWithApplicationServices(engine); @@ -1788,9 +1793,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo return entityServerNode && !isPhysicsEnabled(); }); - QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); - _snapshotSound = DependencyManager::get()->getSound(QUrl::fromLocalFile(inf.absoluteFilePath())); - + QFileInfo infSnap = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav"); + _snapshotSound = DependencyManager::get()->getSound(QUrl::fromLocalFile(infSnap.absoluteFilePath())); + QVariant testProperty = property(hifi::properties::TEST); qDebug() << testProperty; if (testProperty.isValid()) { @@ -4228,6 +4233,7 @@ void Application::initDisplay() { } void Application::init() { + // Make sure Login state is up to date DependencyManager::get()->toggleLoginDialog(); @@ -6836,6 +6842,10 @@ void Application::loadScriptURLDialog() const { }); } +SharedSoundPointer Application::getSampleSound() const { + return _sampleSound; +} + void Application::loadLODToolsDialog() { auto tabletScriptingInterface = DependencyManager::get(); auto tablet = dynamic_cast(tabletScriptingInterface->getTablet(SYSTEM_TABLET)); diff --git a/interface/src/Application.h b/interface/src/Application.h index b6c09bbd87..9263a25953 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -326,6 +326,7 @@ public slots: void toggleEntityScriptServerLogDialog(); Q_INVOKABLE void showAssetServerWidget(QString filePath = ""); Q_INVOKABLE void loadAddAvatarBookmarkDialog() const; + Q_INVOKABLE SharedSoundPointer getSampleSound() const; void showDialog(const QUrl& widgetUrl, const QUrl& tabletUrl, const QString& name) const; @@ -702,6 +703,7 @@ private: FileScriptingInterface* _fileDownload; AudioInjectorPointer _snapshotSoundInjector; SharedSoundPointer _snapshotSound; + SharedSoundPointer _sampleSound; DisplayPluginPointer _autoSwitchDisplayModeSupportedHMDPlugin; QString _autoSwitchDisplayModeSupportedHMDPluginName; diff --git a/libraries/audio/src/SoundCache.h b/libraries/audio/src/SoundCache.h index 97d5f659d8..bc4ddf303f 100644 --- a/libraries/audio/src/SoundCache.h +++ b/libraries/audio/src/SoundCache.h @@ -23,7 +23,6 @@ class SoundCache : public ResourceCache, public Dependency { public: Q_INVOKABLE SharedSoundPointer getSound(const QUrl& url); - protected: virtual QSharedPointer createResource(const QUrl& url, const QSharedPointer& fallback, const void* extra) override; diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index bf46037fd5..77c820e093 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -138,7 +138,7 @@ void main(void) { } // Mix with background at far range - const float BLEND_DISTANCE = 30000.0; + const float BLEND_DISTANCE = 27000.0; if (distance > BLEND_DISTANCE) { outFragColor = mix(potentialFragColor, fragColor, hazeParams.backgroundBlendValue); } else { diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 98846c5213..6fbcd6a794 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -97,7 +97,6 @@ static const bool HIFI_AUTOREFRESH_FILE_SCRIPTS { true }; Q_DECLARE_METATYPE(QScriptEngine::FunctionSignature) int functionSignatureMetaID = qRegisterMetaType(); -Q_DECLARE_METATYPE(ScriptEnginePointer) int scriptEnginePointerMetaID = qRegisterMetaType(); Q_LOGGING_CATEGORY(scriptengineScript, "hifi.scriptengine.script") diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index db159e7265..17c0e0713a 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -55,6 +55,8 @@ static const int DEFAULT_ENTITY_PPS_PER_SCRIPT = 900; class ScriptEngines; +Q_DECLARE_METATYPE(ScriptEnginePointer) + class CallbackData { public: QScriptValue function; diff --git a/scripts/system/controllers/controllerModules/farActionGrabEntity.js b/scripts/system/controllers/controllerModules/farActionGrabEntity.js index ee2db6f6e0..e34855d521 100644 --- a/scripts/system/controllers/controllerModules/farActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/farActionGrabEntity.js @@ -119,6 +119,7 @@ Script.include("/~/system/libraries/controllers.js"); this.actionID = null; // action this script created... this.entityWithContextOverlay = false; this.contextOverlayTimer = false; + this.previousCollisionStatus = false; this.reticleMinX = MARGIN; this.reticleMaxX; this.reticleMinY = MARGIN; @@ -342,7 +343,9 @@ Script.include("/~/system/libraries/controllers.js"); if (this.madeDynamic) { var props = {}; props.dynamic = false; + props.collisionless = this.previousCollisionStatus; props.localVelocity = {x: 0, y: 0, z: 0}; + props.localRotation = {x: 0, y: 0, z: 0}; Entities.editEntity(this.grabbedThingID, props); this.madeDynamic = false; } @@ -507,10 +510,12 @@ Script.include("/~/system/libraries/controllers.js"); if (entityIsGrabbable(targetProps)) { if (!entityIsDistanceGrabbable(targetProps)) { targetProps.dynamic = true; + this.previousCollisionStatus = targetProps.collisionless; + targetProps.collisionless = true; Entities.editEntity(entityID, targetProps); this.madeDynamic = true; } - + if (!this.distanceRotating) { this.grabbedThingID = entityID; this.grabbedDistance = rayPickInfo.distance; diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index b1e5599dc6..a015eed714 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -1373,7 +1373,7 @@ function loaded() { elShape.addEventListener('change', createEmitTextPropertyUpdateFunction('shape')); elWebSourceURL.addEventListener('change', createEmitTextPropertyUpdateFunction('sourceUrl')); - elWebDPI.addEventListener('change', createEmitNumberPropertyUpdateFunction('dpi')); + elWebDPI.addEventListener('change', createEmitNumberPropertyUpdateFunction('dpi', 0)); elModelURL.addEventListener('change', createEmitTextPropertyUpdateFunction('modelURL')); elShapeType.addEventListener('change', createEmitTextPropertyUpdateFunction('shapeType')); diff --git a/unpublishedScripts/marketplace/stopwatch/models/Stopwatch-min-hand.fbx b/unpublishedScripts/marketplace/stopwatch/models/Stopwatch-min-hand.fbx deleted file mode 100644 index b504da13bd..0000000000 Binary files a/unpublishedScripts/marketplace/stopwatch/models/Stopwatch-min-hand.fbx and /dev/null differ diff --git a/unpublishedScripts/marketplace/stopwatch/models/Stopwatch-sec-hand.fbx b/unpublishedScripts/marketplace/stopwatch/models/Stopwatch-sec-hand.fbx deleted file mode 100644 index 12aa85f126..0000000000 Binary files a/unpublishedScripts/marketplace/stopwatch/models/Stopwatch-sec-hand.fbx and /dev/null differ diff --git a/unpublishedScripts/marketplace/stopwatch/models/Stopwatch.fbx b/unpublishedScripts/marketplace/stopwatch/models/Stopwatch.fbx deleted file mode 100644 index 073544875e..0000000000 Binary files a/unpublishedScripts/marketplace/stopwatch/models/Stopwatch.fbx and /dev/null differ diff --git a/unpublishedScripts/marketplace/stopwatch/models/transparent-box.fbx b/unpublishedScripts/marketplace/stopwatch/models/transparent-box.fbx deleted file mode 100644 index b1df7d962c..0000000000 Binary files a/unpublishedScripts/marketplace/stopwatch/models/transparent-box.fbx and /dev/null differ diff --git a/unpublishedScripts/marketplace/stopwatch/sounds/chime.wav b/unpublishedScripts/marketplace/stopwatch/sounds/chime.wav deleted file mode 100644 index cd7143eeeb..0000000000 Binary files a/unpublishedScripts/marketplace/stopwatch/sounds/chime.wav and /dev/null differ diff --git a/unpublishedScripts/marketplace/stopwatch/sounds/tick.wav b/unpublishedScripts/marketplace/stopwatch/sounds/tick.wav deleted file mode 100644 index 21781f8ce4..0000000000 Binary files a/unpublishedScripts/marketplace/stopwatch/sounds/tick.wav and /dev/null differ diff --git a/unpublishedScripts/marketplace/stopwatch/spawnStopwatch.js b/unpublishedScripts/marketplace/stopwatch/spawnStopwatch.js deleted file mode 100644 index 3a0a8a506b..0000000000 --- a/unpublishedScripts/marketplace/stopwatch/spawnStopwatch.js +++ /dev/null @@ -1,89 +0,0 @@ -// -// spawnStopwatch.js -// -// Created by Ryan Huffman on 1/20/17. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -var forward = Quat.getFront(MyAvatar.orientation); -Vec3.print("Forward: ", forward); -var positionToSpawn = Vec3.sum(MyAvatar.position, Vec3.multiply(3, forward)); -var scale = 0.5; -positionToSpawn.y += 0.5; - -var stopwatchID = Entities.addEntity({ - type: "Model", - name: "stopwatch/base", - position: positionToSpawn, - modelURL: Script.resolvePath("models/Stopwatch.fbx"), - dimensions: Vec3.multiply(scale, {"x":4.129462242126465,"y":1.058512806892395,"z":5.773681640625}), - rotation: Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollDegrees(90, 0, 0)) -}); - -var secondHandID = Entities.addEntity({ - type: "Model", - name: "stopwatch/seconds", - parentID: stopwatchID, - localPosition: Vec3.multiply(scale, {"x":-0.004985813982784748,"y":0.39391064643859863,"z":0.8312804698944092}), - dimensions: Vec3.multiply(scale, {"x":0.14095762372016907,"y":0.02546107769012451,"z":1.6077008247375488}), - registrationPoint: {"x":0.5,"y":0.5,"z":1}, - modelURL: Script.resolvePath("models/Stopwatch-sec-hand.fbx"), -}); - -var minuteHandID = Entities.addEntity({ - type: "Model", - name: "stopwatch/minutes", - parentID: stopwatchID, - localPosition: Vec3.multiply(scale, {"x":-0.0023056098725646734,"y":0.3308190703392029,"z":0.21810021996498108}), - dimensions: Vec3.multiply(scale, {"x":0.045471154153347015,"y":0.015412690117955208,"z":0.22930574417114258}), - registrationPoint: {"x":0.5,"y":0.5,"z":1}, - modelURL: Script.resolvePath("models/Stopwatch-min-hand.fbx"), -}); - -var startStopButtonID = Entities.addEntity({ - type: "Model", - name: "stopwatch/startStop", - parentID: stopwatchID, - dimensions: Vec3.multiply(scale, { x: 0.8, y: 0.8, z: 1.0 }), - localPosition: Vec3.multiply(scale, { x: 0, y: -0.1, z: -2.06 }), - modelURL: Script.resolvePath("models/transparent-box.fbx") -}); - -var resetButtonID = Entities.addEntity({ - type: "Model", - name: "stopwatch/startStop", - parentID: stopwatchID, - dimensions: Vec3.multiply(scale, { x: 0.6, y: 0.6, z: 0.8 }), - localPosition: Vec3.multiply(scale, { x: -1.5, y: -0.1, z: -1.2 }), - localRotation: Quat.fromVec3Degrees({ x: 0, y: 36, z: 0 }), - modelURL: Script.resolvePath("models/transparent-box.fbx") -}); - -Entities.editEntity(stopwatchID, { - userData: JSON.stringify({ - secondHandID: secondHandID, - minuteHandID: minuteHandID - }), - serverScripts: Script.resolvePath("stopwatchServer.js") -}); - -Entities.editEntity(startStopButtonID, { - userData: JSON.stringify({ - stopwatchID: stopwatchID, - grabbableKey: { wantsTrigger: true } - }), - script: Script.resolvePath("stopwatchStartStop.js") -}); - -Entities.editEntity(resetButtonID, { - userData: JSON.stringify({ - stopwatchID: stopwatchID, - grabbableKey: { wantsTrigger: true } - }), - script: Script.resolvePath("stopwatchReset.js") -}); - -Script.stop() diff --git a/unpublishedScripts/marketplace/stopwatch/stopwatchReset.js b/unpublishedScripts/marketplace/stopwatch/stopwatchReset.js deleted file mode 100644 index b65c1e7340..0000000000 --- a/unpublishedScripts/marketplace/stopwatch/stopwatchReset.js +++ /dev/null @@ -1,22 +0,0 @@ -// -// stopwatchReset.js -// -// Created by David Rowe on 26 May 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -(function () { - this.preload = function (entityID) { - var properties = Entities.getEntityProperties(entityID, "userData"); - this.messageChannel = "STOPWATCH-" + JSON.parse(properties.userData).stopwatchID; - }; - function click() { - Messages.sendMessage(this.messageChannel, "reset"); - } - this.startNearTrigger = click; - this.startFarTrigger = click; - this.clickDownOnEntity = click; -}); diff --git a/unpublishedScripts/marketplace/stopwatch/stopwatchServer.js b/unpublishedScripts/marketplace/stopwatch/stopwatchServer.js deleted file mode 100644 index 6ae1b69087..0000000000 --- a/unpublishedScripts/marketplace/stopwatch/stopwatchServer.js +++ /dev/null @@ -1,132 +0,0 @@ -// -// stopwatchServer.js -// -// Created by Ryan Huffman on 1/20/17. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -(function() { - var self = this; - - self.equipped = false; - self.isActive = false; - self.seconds = 0; - - self.secondHandID = null; - self.minuteHandID = null; - - self.tickSound = SoundCache.getSound(Script.resolvePath("sounds/tick.wav")); - self.tickInjector = null; - self.tickIntervalID = null; - - self.chimeSound = SoundCache.getSound(Script.resolvePath("sounds/chime.wav")); - - self.preload = function(entityID) { - print("Preloading stopwatch: ", entityID); - self.entityID = entityID; - self.messageChannel = "STOPWATCH-" + entityID; - - var userData = Entities.getEntityProperties(self.entityID, 'userData').userData; - var data = JSON.parse(userData); - self.secondHandID = data.secondHandID; - self.minuteHandID = data.minuteHandID; - - self.resetTimer(); - - Messages.subscribe(self.messageChannel); - Messages.messageReceived.connect(this, self.messageReceived); - }; - self.unload = function() { - print("Unloading stopwatch:", self.entityID); - self.resetTimer(); - Messages.unsubscribe(self.messageChannel); - Messages.messageReceived.disconnect(this, self.messageReceived); - }; - self.messageReceived = function(channel, message, sender) { - print("Message received", channel, sender, message); - if (channel === self.messageChannel) { - switch (message) { - case "startStop": - if (self.isActive) { - self.stopTimer(); - } else { - self.startTimer(); - } - break; - case "reset": - self.stopTimer(); - self.resetTimer(); - break; - } - } - }; - self.getStopwatchPosition = function() { - return Entities.getEntityProperties(self.entityID, "position").position; - }; - self.resetTimer = function() { - print("Resetting stopwatch"); - Entities.editEntity(self.secondHandID, { - localRotation: Quat.fromPitchYawRollDegrees(0, 0, 0), - angularVelocity: { x: 0, y: 0, z: 0 }, - }); - Entities.editEntity(self.minuteHandID, { - localRotation: Quat.fromPitchYawRollDegrees(0, 0, 0), - angularVelocity: { x: 0, y: 0, z: 0 }, - }); - self.seconds = 0; - }; - self.startTimer = function() { - print("Starting stopwatch"); - if (!self.tickInjector) { - self.tickInjector = Audio.playSound(self.tickSound, { - position: self.getStopwatchPosition(), - volume: 0.7, - loop: true - }); - } else { - self.tickInjector.restart(); - } - - self.tickIntervalID = Script.setInterval(function() { - if (self.tickInjector) { - self.tickInjector.setOptions({ - position: self.getStopwatchPosition(), - volume: 0.7, - loop: true - }); - } - self.seconds++; - const degreesPerTick = -360 / 60; - Entities.editEntity(self.secondHandID, { - localRotation: Quat.fromPitchYawRollDegrees(0, self.seconds * degreesPerTick, 0), - }); - - if (self.seconds % 60 == 0) { - Entities.editEntity(self.minuteHandID, { - localRotation: Quat.fromPitchYawRollDegrees(0, (self.seconds / 60) * degreesPerTick, 0), - }); - Audio.playSound(self.chimeSound, { - position: self.getStopwatchPosition(), - volume: 1.0, - loop: false - }); - } - }, 1000); - - self.isActive = true; - }; - self.stopTimer = function () { - print("Stopping stopwatch"); - if (self.tickInjector) { - self.tickInjector.stop(); - } - if (self.tickIntervalID !== null) { - Script.clearInterval(self.tickIntervalID); - self.tickIntervalID = null; - } - self.isActive = false; - }; -}); diff --git a/unpublishedScripts/marketplace/stopwatch/stopwatchStartStop.js b/unpublishedScripts/marketplace/stopwatch/stopwatchStartStop.js deleted file mode 100644 index 88c037ee36..0000000000 --- a/unpublishedScripts/marketplace/stopwatch/stopwatchStartStop.js +++ /dev/null @@ -1,23 +0,0 @@ -// -// stopwatchStartStop.js -// -// Created by David Rowe on 26 May 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -(function () { - var messageChannel; - this.preload = function (entityID) { - var properties = Entities.getEntityProperties(entityID, "userData"); - this.messageChannel = "STOPWATCH-" + JSON.parse(properties.userData).stopwatchID; - }; - function click() { - Messages.sendMessage(this.messageChannel, "startStop"); - } - this.startNearTrigger = click; - this.startFarTrigger = click; - this.clickDownOnEntity = click; -});