From 3301ad64f4a6cb7fb67c8371bb53030f677669a0 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 11 Dec 2014 12:32:31 -0800 Subject: [PATCH 01/63] Split initGverb into create/configure --- interface/src/Audio.cpp | 31 ++++++++++++------------------- interface/src/Audio.h | 3 ++- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 101d16d3ba..7514e062ce 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -495,31 +495,24 @@ bool Audio::switchOutputToAudioDevice(const QString& outputDeviceName) { return switchOutputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioOutput, outputDeviceName)); } -void Audio::initGverb() { +ty_gverb* Audio::createGverbFilter() { // Initialize a new gverb instance - _gverbLocal = gverb_new(_outputFormat.sampleRate(), _reverbOptions->getMaxRoomSize(), _reverbOptions->getRoomSize(), - _reverbOptions->getReverbTime(), _reverbOptions->getDamping(), _reverbOptions->getSpread(), - _reverbOptions->getInputBandwidth(), _reverbOptions->getEarlyLevel(), - _reverbOptions->getTailLevel()); - _gverb = gverb_new(_outputFormat.sampleRate(), _reverbOptions->getMaxRoomSize(), _reverbOptions->getRoomSize(), + ty_gverb* filter = gverb_new(_outputFormat.sampleRate(), _reverbOptions->getMaxRoomSize(), _reverbOptions->getRoomSize(), _reverbOptions->getReverbTime(), _reverbOptions->getDamping(), _reverbOptions->getSpread(), _reverbOptions->getInputBandwidth(), _reverbOptions->getEarlyLevel(), _reverbOptions->getTailLevel()); + return filter; +} + +void Audio::configureGverbFilter(ty_gverb* filter) { // Configure the instance (these functions are not super well named - they actually set several internal variables) - gverb_set_roomsize(_gverbLocal, _reverbOptions->getRoomSize()); - gverb_set_revtime(_gverbLocal, _reverbOptions->getReverbTime()); - gverb_set_damping(_gverbLocal, _reverbOptions->getDamping()); - gverb_set_inputbandwidth(_gverbLocal, _reverbOptions->getInputBandwidth()); - gverb_set_earlylevel(_gverbLocal, DB_CO(_reverbOptions->getEarlyLevel())); - gverb_set_taillevel(_gverbLocal, DB_CO(_reverbOptions->getTailLevel())); - - gverb_set_roomsize(_gverb, _reverbOptions->getRoomSize()); - gverb_set_revtime(_gverb, _reverbOptions->getReverbTime()); - gverb_set_damping(_gverb, _reverbOptions->getDamping()); - gverb_set_inputbandwidth(_gverb, _reverbOptions->getInputBandwidth()); - gverb_set_earlylevel(_gverb, DB_CO(_reverbOptions->getEarlyLevel())); - gverb_set_taillevel(_gverb, DB_CO(_reverbOptions->getTailLevel())); + gverb_set_roomsize(filter, _reverbOptions->getRoomSize()); + gverb_set_revtime(filter, _reverbOptions->getReverbTime()); + gverb_set_damping(filter, _reverbOptions->getDamping()); + gverb_set_inputbandwidth(filter, _reverbOptions->getInputBandwidth()); + gverb_set_earlylevel(filter, DB_CO(_reverbOptions->getEarlyLevel())); + gverb_set_taillevel(filter, DB_CO(_reverbOptions->getTailLevel())); } void Audio::updateGverbOptions() { diff --git a/interface/src/Audio.h b/interface/src/Audio.h index 47fe00a84c..22a679370d 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -256,7 +256,8 @@ private: void processProceduralAudio(int16_t* monoInput, int numSamples); // Adds Reverb - void initGverb(); + ty_gverb* createGverbFilter(); + void configureGverbFilter(ty_gverb* filter); void updateGverbOptions(); void addReverb(ty_gverb* gverb, int16_t* samples, int numSamples, QAudioFormat& format, bool noEcho = false); From 1f35e130efec51565d4fae59d636ce0ac5fade6c Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 11 Dec 2014 12:33:40 -0800 Subject: [PATCH 02/63] Smooth reverb wet level on room edges --- assignment-client/src/audio/AudioMixer.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index c3ec321c77..92f46c29ec 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -475,10 +475,20 @@ void AudioMixer::sendAudioEnvironmentPacket(SharedNodePointer node) { for (int i = 0; i < _zoneReverbSettings.size(); ++i) { AudioMixerClientData* data = static_cast(node->getLinkedData()); glm::vec3 streamPosition = data->getAvatarAudioStream()->getPosition(); - if (_audioZones[_zoneReverbSettings[i].zone].contains(streamPosition)) { + AABox box = _audioZones[_zoneReverbSettings[i].zone]; + if (box.contains(streamPosition)) { hasReverb = true; reverbTime = _zoneReverbSettings[i].reverbTime; wetLevel = _zoneReverbSettings[i].wetLevel; + + // Modulate wet level with distance to wall + float MIN_ATTENUATION_DISTANCE = 2.0f; + float MAX_ATTENUATION = 0.75f; + glm::vec3 distanceToWalls = (box.getDimensions() / 2.0f) - glm::abs(streamPosition - box.calcCenter()); + float distanceToClosestWall = glm::min(distanceToWalls.x, distanceToWalls.z); + if (distanceToClosestWall < MIN_ATTENUATION_DISTANCE) { + wetLevel *= 1.0f - MAX_ATTENUATION * (1.0f - distanceToClosestWall / MIN_ATTENUATION_DISTANCE); + } break; } } From 3fbed61a675afde5f306197c4ba7fb2bb8a56810 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 11 Dec 2014 12:39:59 -0800 Subject: [PATCH 03/63] Correctly free filters --- interface/src/Audio.cpp | 5 +++++ interface/src/Audio.h | 1 + 2 files changed, 6 insertions(+) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 7514e062ce..9c450b8b64 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -139,6 +139,11 @@ Audio::Audio(QObject* parent) : initGverb(); } +Audio::~Audio() { + gverb_free(_gverb); + gverb_free(_gverbLocal); +} + void Audio::init(QGLWidget *parent) { _micTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic.svg")); _muteTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic-mute.svg")); diff --git a/interface/src/Audio.h b/interface/src/Audio.h index 22a679370d..cef49088fa 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -85,6 +85,7 @@ public: // setup for audio I/O Audio(QObject* parent = 0); + ~Audio(); float getLastInputLoudness() const { return glm::max(_lastInputLoudness - _noiseGateMeasuredFloor, 0.0f); } float getTimeSinceLastClip() const { return _timeSinceLastClip; } From 96262fac36d238480a88d0c0e04ed4814e21abf6 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 11 Dec 2014 12:41:18 -0800 Subject: [PATCH 04/63] flush filters on reset / do not update on wetLevel change --- interface/src/Audio.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 9c450b8b64..aebd9d1795 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -157,6 +157,9 @@ void Audio::reset() { _toneSource.reset(); _sourceGain.reset(); _inputGain.reset(); + + gverb_flush(_gverb); + gverb_flush(_gverbLocal); } void Audio::resetStats() { @@ -530,7 +533,7 @@ void Audio::updateGverbOptions() { } if (_zoneReverbOptions.getWetLevel() != _receivedAudioStream.getWetLevel()) { _zoneReverbOptions.setWetLevel(_receivedAudioStream.getWetLevel()); - reverbChanged = true; + // Not part of actual filter config, no need to set reverbChanged to true } if (_reverbOptions != &_zoneReverbOptions) { From 58275ac3dde67c498376b027119be4891835870f Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 11 Dec 2014 13:14:48 -0800 Subject: [PATCH 05/63] Flush gverb filters on turn off --- interface/src/Audio.cpp | 39 +++++++++++++++++++++++++++++++-------- interface/src/Audio.h | 2 +- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index aebd9d1795..aec586290e 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -135,8 +135,9 @@ Audio::Audio(QObject* parent) : connect(&_receivedAudioStream, &MixedProcessedAudioStream::addedStereoSamples, this, &Audio::addStereoSamplesToScope, Qt::DirectConnection); connect(&_receivedAudioStream, &MixedProcessedAudioStream::processSamples, this, &Audio::processReceivedSamples, Qt::DirectConnection); - // Initialize GVerb - initGverb(); + // create GVerb filters + _gverb = createGverbFilter(); + _gverbLocal = createGverbFilter(); } Audio::~Audio() { @@ -148,6 +149,10 @@ void Audio::init(QGLWidget *parent) { _micTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic.svg")); _muteTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/mic-mute.svg")); _boxTextureId = parent->bindTexture(QImage(Application::resourcesPath() + "images/audio-box.svg")); + + // configure filters + configureGverbFilter(_gverb); + configureGverbFilter(_gverbLocal); } void Audio::reset() { @@ -463,12 +468,11 @@ void Audio::start() { _sourceGain.initialize(); _noiseSource.initialize(); _toneSource.initialize(); - _sourceGain.setParameters(0.25f,0.0f); - _inputGain.setParameters(1.0f,0.0f); + _sourceGain.setParameters(0.25f, 0.0f); + _inputGain.setParameters(1.0f, 0.0f); } void Audio::stop() { - _inputFrameBuffer.finalize(); _inputGain.finalize(); _sourceGain.finalize(); @@ -546,7 +550,21 @@ void Audio::updateGverbOptions() { } if (reverbChanged) { - initGverb(); + gverb_free(_gverb); + _gverb = createGverbFilter(); + configureGverbFilter(_gverb); + gverb_free(_gverbLocal); + _gverbLocal = createGverbFilter(); + configureGverbFilter(_gverbLocal); + } +} + +void Audio::setReverb(bool reverb) { + _reverb = reverb; + + if (!_reverb) { + gverb_flush(_gverb); + gverb_flush(_gverbLocal); } } @@ -565,8 +583,13 @@ void Audio::setReverbOptions(const AudioEffectOptions* options) { _scriptReverbOptions.setWetLevel(options->getWetLevel()); if (_reverbOptions == &_scriptReverbOptions) { - // Apply them to the reverb instance(s) - initGverb(); + // Apply them to the reverb instances + gverb_free(_gverb); + _gverb = createGverbFilter(); + configureGverbFilter(_gverb); + gverb_free(_gverbLocal); + _gverbLocal = createGverbFilter(); + configureGverbFilter(_gverbLocal); } } diff --git a/interface/src/Audio.h b/interface/src/Audio.h index cef49088fa..8176e1bdf5 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -165,7 +165,7 @@ public slots: float getInputVolume() const { return (_audioInput) ? _audioInput->volume() : 0.0f; } void setInputVolume(float volume) { if (_audioInput) _audioInput->setVolume(volume); } - void setReverb(bool reverb) { _reverb = reverb; } + void setReverb(bool reverb); void setReverbOptions(const AudioEffectOptions* options); const AudioStreamStats& getAudioMixerAvatarStreamAudioStats() const { return _audioMixerAvatarStreamAudioStats; } From 59e7c1ecc092c6526320624c58e189b1bb3f9e16 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 29 Dec 2014 15:31:27 -0800 Subject: [PATCH 06/63] Avoid int overflow --- interface/src/ModelUploader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/ModelUploader.cpp b/interface/src/ModelUploader.cpp index e702d9db76..26eac328ae 100644 --- a/interface/src/ModelUploader.cpp +++ b/interface/src/ModelUploader.cpp @@ -55,7 +55,7 @@ static const QString MODEL_URL = "/api/v1/models"; static const QString SETTING_NAME = "LastModelUploadLocation"; -static const int BYTES_PER_MEGABYTES = 1024 * 1024; +static const unsigned long BYTES_PER_MEGABYTES = 1024 * 1024; static const unsigned long MAX_SIZE = 50 * 1024 * BYTES_PER_MEGABYTES; // 50 GB (Virtually remove limit) static const int MAX_TEXTURE_SIZE = 1024; static const int TIMEOUT = 1000; From 7b88deef16e07a83f7dd2c560cb7ed95aeb2b2c5 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Tue, 13 Jan 2015 22:08:35 +0100 Subject: [PATCH 07/63] Implement UI sounds for virtualKeyboard & notifications --- examples/controllers/oculus/goTo.js | 10 +- .../virtualKeyboardTextEntityExample.js | 10 +- examples/libraries/soundArray.js | 40 ++++++ examples/notifications.js | 135 +++++++++--------- 4 files changed, 128 insertions(+), 67 deletions(-) create mode 100644 examples/libraries/soundArray.js diff --git a/examples/controllers/oculus/goTo.js b/examples/controllers/oculus/goTo.js index ba1ee1eb81..f3db99493d 100644 --- a/examples/controllers/oculus/goTo.js +++ b/examples/controllers/oculus/goTo.js @@ -18,6 +18,7 @@ Script.include("../../libraries/globals.js"); Script.include("../../libraries/virtualKeyboard.js"); +Script.include("../../libraries/soundArray.js"); var windowDimensions = Controller.getViewportDimensions(); var cursor = null; @@ -26,6 +27,12 @@ var textFontSize = 9; var text = null; var locationURL = ""; +var randomSounds = new SoundArray({}, true); +var numberOfSounds = 7; +for (var i = 1; i <= numberOfSounds; i++) { + randomSounds.addSound(HIFI_PUBLIC_BUCKET + "sounds/UI/virtualKeyboard-press" + i + ".raw"); +} + function appendChar(char) { locationURL += char; updateTextOverlay(); @@ -51,6 +58,7 @@ function updateTextOverlay() { } keyboard.onKeyPress = function(event) { + randomSounds.playRandom(); if (event.event == 'keypress') { appendChar(event.char); } @@ -66,7 +74,7 @@ keyboard.onKeyRelease = function(event) { print("going to hifi://" + locationURL); location = "hifi://" + locationURL; locationURL = ""; - keyboard.hide(); + keyboard.hide(); updateTextOverlay(); } } diff --git a/examples/controllers/oculus/virtualKeyboardTextEntityExample.js b/examples/controllers/oculus/virtualKeyboardTextEntityExample.js index 794b659bcb..3c201cb307 100644 --- a/examples/controllers/oculus/virtualKeyboardTextEntityExample.js +++ b/examples/controllers/oculus/virtualKeyboardTextEntityExample.js @@ -17,6 +17,7 @@ Script.include("../../libraries/globals.js"); Script.include("../../libraries/virtualKeyboard.js"); +Script.include("../../libraries/soundArray.js"); const SPAWN_DISTANCE = 1; const DEFAULT_TEXT_DIMENSION_Z = 0.02; @@ -34,6 +35,12 @@ var text = null; var textText = ""; var textSizeMeasureOverlay = Overlays.addOverlay("text3d", {visible: false}); +var randomSounds = new SoundArray({}, true); +var numberOfSounds = 7; +for (var i = 1; i <= numberOfSounds; i++) { + randomSounds.addSound(HIFI_PUBLIC_BUCKET + "sounds/UI/virtualKeyboard-press" + i + ".raw"); +} + function appendChar(char) { textText += char; updateTextOverlay(); @@ -58,6 +65,7 @@ function updateTextOverlay() { } keyboard.onKeyPress = function(event) { + randomSounds.playRandom(); if (event.event == 'keypress') { appendChar(event.char); } else if (event.event == 'enter') { @@ -100,7 +108,7 @@ keyboard.onKeyRelease = function(event) { backgroundColor: { red: 0, green: 0, blue: 0 }, textColor: { red: 255, green: 255, blue: 255 }, text: textText + "\n" + usernameLine, - lineHeight: 0.1 + lineHeight: 0.1 }); } textText = ""; diff --git a/examples/libraries/soundArray.js b/examples/libraries/soundArray.js new file mode 100644 index 0000000000..0da2db07d3 --- /dev/null +++ b/examples/libraries/soundArray.js @@ -0,0 +1,40 @@ +/** + * An array for sounds, allows you to randomly play a sound + * taken from the removed editVoxels.js + */ +SoundArray = function(audioOptions, autoUpdateAudioPosition) { + this.audioOptions = audioOptions !== undefined ? audioOptions : {}; + this.autoUpdateAudioPosition = autoUpdateAudioPosition !== undefined ? autoUpdateAudioPosition : false; + if (this.audioOptions.position === undefined) { + this.audioOptions.position = Vec3.sum(MyAvatar.position, { x: 0, y: 1, z: 0}), + } + if (this.audioOptions.volume === undefined) { + this.audioOptions.volume = 1.0; + } + this.sounds = new Array(); + this.addSound = function (soundURL) { + this.sounds[this.sounds.length] = SoundCache.getSound(soundURL); + }; + this.play = function (index) { + if (0 <= index && index < this.sounds.length) { + if (this.autoUpdateAudioPosition) { + this.updateAudioPosition(); + } + Audio.playSound(this.sounds[index], this.audioOptions); + } else { + print("[ERROR] libraries/soundArray.js:play() : Index " + index + " out of range."); + } + }; + this.playRandom = function () { + if (this.sounds.length > 0) { + this.play(Math.floor(Math.random() * this.sounds.length)); + } else { + print("[ERROR] libraries/soundArray.js:playRandom() : Array is empty."); + } + }; + this.updateAudioPosition = function() { + var position = MyAvatar.position; + var forwardVector = Quat.getFront(MyAvatar.orientation); + this.audioOptions.position = Vec3.sum(position, forwardVector); + }; +}; diff --git a/examples/notifications.js b/examples/notifications.js index 5527fc35fc..2449873f27 100644 --- a/examples/notifications.js +++ b/examples/notifications.js @@ -1,13 +1,13 @@ -// -// notifications.js -// Version 0.801 -// Created by Adrian +// +// notifications.js +// Version 0.801 +// Created by Adrian // // Adrian McCarlie 8-10-14 // This script demonstrates on-screen overlay type notifications. // Copyright 2014 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 @@ -20,29 +20,29 @@ // CTRL/m for mic mute and unmute. // System generated notifications: -// Displays users online at startup. +// Displays users online at startup. // If Screen is resized. // Triggers notification if @MyUserName is mentioned in chat. // Announces existing user logging out. // Announces new user logging in. // If mic is muted for any reason. -// +// // To add a new System notification type: // -// 1. Set the Event Connector at the bottom of the script. -// example: +// 1. Set the Event Connector at the bottom of the script. +// example: // GlobalServices.incomingMessage.connect(onIncomingMessage); // -// 2. Create a new function to produce a text string, do not include new line returns. +// 2. Create a new function to produce a text string, do not include new line returns. // example: // function onIncomingMessage(user, message) { -// //do stuff here; +// //do stuff here; // var text = "This is a notification"; // wordWrap(text); // } // // This new function must call wordWrap(text) if the length of message is longer than 42 chars or unknown. -// wordWrap() will format the text to fit the notifications overlay and send it to createNotification(text). +// wordWrap() will format the text to fit the notifications overlay and send it to createNotification(text). // If the message is 42 chars or less you should bypass wordWrap() and call createNotification() directly. @@ -53,37 +53,44 @@ // 3. Call createNotifications(text) parsing the text. // example: // if (key.text == "q") { //queries number of users online -// var numUsers = GlobalServices.onlineUsers.length; -// var welcome = "There are " + numUsers + " users online now."; -// createNotification(welcome); +// var numUsers = GlobalServices.onlineUsers.length; +// var welcome = "There are " + numUsers + " users online now."; +// createNotification(welcome); // } - +Script.include("./libraries/globals.js"); +Script.include("./libraries/soundArray.js"); var width = 340.0; //width of notification overlay var height = 40.0; // height of a single line notification overlay var windowDimensions = Controller.getViewportDimensions(); // get the size of the interface window var overlayLocationX = (windowDimensions.x - (width + 20.0));// positions window 20px from the right of the interface window -var buttonLocationX = overlayLocationX + (width - 28.0); +var buttonLocationX = overlayLocationX + (width - 28.0); var locationY = 20.0; // position down from top of interface window var topMargin = 13.0; var leftMargin = 10.0; var textColor = { red: 228, green: 228, blue: 228}; // text color -var backColor = { red: 2, green: 2, blue: 2}; // background color was 38,38,38 +var backColor = { red: 2, green: 2, blue: 2}; // background color was 38,38,38 var backgroundAlpha = 0; var fontSize = 12.0; var persistTime = 10.0; // time in seconds before notification fades var clickedText = false; var frame = 0; -var ourWidth = Window.innerWidth; -var ourHeight = Window.innerHeight; +var ourWidth = Window.innerWidth; +var ourHeight = Window.innerHeight; var text = "placeholder"; var last_users = GlobalServices.onlineUsers; var users = []; var ctrlIsPressed = false; var ready = true; - + +var randomSounds = new SoundArray({}, true); +var numberOfSounds = 2; +for (var i = 1; i <= numberOfSounds; i++) { + randomSounds.addSound(HIFI_PUBLIC_BUCKET + "sounds/UI/notification-general" + i + ".raw"); +} + // When our script shuts down, we should clean up all of our overlays -function scriptEnding() { +function scriptEnding() { for (i = 0; i < notifications.length; i++) { Overlays.deleteOverlay(notifications[i]); Overlays.deleteOverlay(buttons[i]); @@ -92,7 +99,7 @@ function scriptEnding() { Script.scriptEnding.connect(scriptEnding); var notifications = []; -var buttons = []; +var buttons = []; var times = []; var heights = []; var myAlpha = []; @@ -117,7 +124,7 @@ function createNotification(text) { height = height + extraLine; var overlayProperties = { x: overlayLocationX, - y: level, + y: level, width: width, height: height, color: textColor, @@ -126,10 +133,10 @@ function createNotification(text) { topMargin: topMargin, leftMargin: leftMargin, font: {size: fontSize}, - text: text, + text: text, }; var bLevel = level + 12.0; - var buttonProperties = { + var buttonProperties = { x: buttonLocationX, y: bLevel, width: 10.0, @@ -139,17 +146,15 @@ function createNotification(text) { color: { red: 255, green: 255, blue: 255}, visible: true, alpha: backgroundAlpha, - }; - - Notify(overlayProperties, buttonProperties, height); - + }; + Notify(overlayProperties, buttonProperties, height); } -// Pushes data to each array and sets up data for 2nd dimension array +// Pushes data to each array and sets up data for 2nd dimension array // to handle auxiliary data not carried by the overlay class -// specifically notification "heights", "times" of creation, and . -function Notify(notice, button, height){ - +// specifically notification "heights", "times" of creation, and . +function Notify(notice, button, height){ + randomSounds.playRandom(); notifications.push((Overlays.addOverlay("text", notice))); buttons.push((Overlays.addOverlay("image",button))); times.push(new Date().getTime() / 1000); @@ -162,14 +167,14 @@ function Notify(notice, button, height){ } function fadeIn(noticeIn, buttonIn) { - var myLength = arrays.length; + var myLength = arrays.length; var q = 0; var pauseTimer = null; - pauseTimer = Script.setInterval(function() { + pauseTimer = Script.setInterval(function() { q++; qFade = q / 10.0; - Overlays.editOverlay(noticeIn, {alpha: qFade}); - Overlays.editOverlay(buttonIn, {alpha: qFade}); + Overlays.editOverlay(noticeIn, {alpha: qFade}); + Overlays.editOverlay(buttonIn, {alpha: qFade}); if (q >= 9.0) { Script.clearInterval(pauseTimer); } @@ -178,11 +183,11 @@ function fadeIn(noticeIn, buttonIn) { // push data from above to the 2 dimensional array -function createArrays(notice, button, createTime, height, myAlpha) { - arrays.push([notice, button, createTime, height, myAlpha]); +function createArrays(notice, button, createTime, height, myAlpha) { + arrays.push([notice, button, createTime, height, myAlpha]); } // handles mouse clicks on buttons -function mousePressEvent(event) { +function mousePressEvent(event) { var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y}); //identify which overlay was clicked for (i = 0; i < buttons.length; i++) { //if user clicked a button if(clickedOverlay == buttons[i]) { @@ -192,10 +197,10 @@ function mousePressEvent(event) { buttons.splice(i, 1); times.splice(i, 1); heights.splice(i, 1); - myAlpha.splice(i, 1); + myAlpha.splice(i, 1); arrays.splice(i, 1); } - } + } } // Control key remains active only while key is held down @@ -204,19 +209,19 @@ function keyReleaseEvent(key) { ctrlIsPressed = false; } } - + // Triggers notification on specific key driven events function keyPressEvent(key) { if (key.key == 16777249) { ctrlIsPressed = true; } if (key.text == "q") { //queries number of users online - var numUsers = GlobalServices.onlineUsers.length; - var welcome = "There are " + numUsers + " users online now."; - createNotification(welcome); - } + var numUsers = GlobalServices.onlineUsers.length; + var welcome = "There are " + numUsers + " users online now."; + createNotification(welcome); + } - if (key.text == "s") { + if (key.text == "s") { if (ctrlIsPressed == true){ var noteString = "Snapshot taken."; createNotification(noteString); @@ -241,7 +246,7 @@ function stringDivider(str, slotWidth, spaceReplacer) { return left + spaceReplacer + stringDivider(right, slotWidth, spaceReplacer); } } - return str; + return str; } // This fires a notification on window resize @@ -249,7 +254,7 @@ function checkSize(){ if((Window.innerWidth != ourWidth)||(Window.innerHeight != ourHeight)) { var windowResize = "Window has been resized"; ourWidth = Window.innerWidth; - ourHeight = Window.innerHeight; + ourHeight = Window.innerHeight; windowDimensions = Controller.getViewportDimensions(); overlayLocationX = (windowDimensions.x - (width + 60.0)); buttonLocationX = overlayLocationX + (width - 35.0); @@ -261,12 +266,12 @@ function checkSize(){ function onOnlineUsersChanged(users) { for (user in users) { if (last_users.indexOf(users[user]) == -1.0) { - createNotification(users[user] + " has joined"); + createNotification(users[user] + " has joined"); } } for (user in last_users) { if (users.indexOf(last_users[user]) == -1.0) { - createNotification(last_users[user] + " has left"); + createNotification(last_users[user] + " has left"); } } last_users = users; @@ -294,7 +299,7 @@ function update(){ checkSize(); // checks for size change to trigger windowResize notification locationY = 20.0; for (var i = 0; i < arrays.length; i++) { //repositions overlays as others fade - var nextOverlay = Overlays.getOverlayAtPoint({x: overlayLocationX, y: locationY}); + var nextOverlay = Overlays.getOverlayAtPoint({x: overlayLocationX, y: locationY}); Overlays.editOverlay(notifications[i], { x:overlayLocationX, y:locationY}); Overlays.editOverlay(buttons[i], { x:buttonLocationX, y:locationY + 12.0}); locationY = locationY + arrays[i][3]; @@ -302,12 +307,12 @@ function update(){ } // This checks the age of the notification and prepares to fade it after 9.0 seconds (var persistTime - 1) - for (var i = 0; i < arrays.length; i++) { - if (ready){ - var j = arrays[i][2]; - var k = j + persistTime; + for (var i = 0; i < arrays.length; i++) { + if (ready) { + var j = arrays[i][2]; + var k = j + persistTime; if (k < (new Date().getTime() / 1000)) { - ready = false; + ready = false; noticeOut = arrays[i][0]; buttonOut = arrays[i][1]; var arraysOut = i; @@ -322,11 +327,11 @@ function fadeOut(noticeOut, buttonOut, arraysOut) { var myLength = arrays.length; var r = 9.0; var pauseTimer = null; - pauseTimer = Script.setInterval(function() { + pauseTimer = Script.setInterval(function() { r--; - rFade = r / 10.0; - Overlays.editOverlay(noticeOut, {alpha: rFade}); - Overlays.editOverlay(buttonOut, {alpha: rFade}); + rFade = r / 10.0; + Overlays.editOverlay(noticeOut, {alpha: rFade}); + Overlays.editOverlay(buttonOut, {alpha: rFade}); if (r < 0) { dismiss(noticeOut, buttonOut, arraysOut); arrays.splice(arraysOut, 1); @@ -337,8 +342,8 @@ function fadeOut(noticeOut, buttonOut, arraysOut) { } // This handles the final dismissal of a notification after fading -function dismiss(firstNoteOut, firstButOut, firstOut) { - var working = firstOut +function dismiss(firstNoteOut, firstButOut, firstOut) { + var working = firstOut; Overlays.deleteOverlay(firstNoteOut); Overlays.deleteOverlay(firstButOut); notifications.splice(firstOut, 1); From bd9668b9fa259c751c0f59ab128cc84429c9320b Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 15 Jan 2015 18:23:43 -0800 Subject: [PATCH 08/63] Change WetLevel modulation --- assignment-client/src/audio/AudioMixer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index ee681b9942..1aa0c75086 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -487,11 +487,11 @@ void AudioMixer::sendAudioEnvironmentPacket(SharedNodePointer node) { // Modulate wet level with distance to wall float MIN_ATTENUATION_DISTANCE = 2.0f; - float MAX_ATTENUATION = 0.75f; + float MAX_ATTENUATION = -12; // dB glm::vec3 distanceToWalls = (box.getDimensions() / 2.0f) - glm::abs(streamPosition - box.calcCenter()); float distanceToClosestWall = glm::min(distanceToWalls.x, distanceToWalls.z); if (distanceToClosestWall < MIN_ATTENUATION_DISTANCE) { - wetLevel *= 1.0f - MAX_ATTENUATION * (1.0f - distanceToClosestWall / MIN_ATTENUATION_DISTANCE); + wetLevel += MAX_ATTENUATION * (1.0f - distanceToClosestWall / MIN_ATTENUATION_DISTANCE); } break; } From 4cd1d54f15ae22dbb1e09e82a178dcee0ac1fb30 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 6 Feb 2015 21:42:58 -0800 Subject: [PATCH 09/63] Fix progress bar's SVG dimensions --- examples/progress.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/progress.js b/examples/progress.js index 6ee53c55e6..7fb2a043e2 100644 --- a/examples/progress.js +++ b/examples/progress.js @@ -23,18 +23,19 @@ fadeWaitTimer = null, FADE_OUT_WAIT = 1000, // Wait before starting to fade out after progress 100%. visible = false, - BAR_WIDTH = 320, // Nominal dimension of SVG in pixels of visible portion (half) of the bar. - BAR_HEIGHT = 20, + BAR_WIDTH = 480, // Dimension of SVG in pixels of visible portion (half) of the bar. + BAR_HEIGHT = 30, BAR_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar.svg", - BACKGROUND_WIDTH = 360, - BACKGROUND_HEIGHT = 60, - BACKGROUND_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar-background.svg", + BACKGROUND_WIDTH = 540, + BACKGROUND_HEIGHT = 90, + BACKGROUND_URL = "http://ctrlaltstudio.com/hifi/progress-bar-background.svg", + //BACKGROUND_URL = "http://hifi-public.s3.amazonaws.com/images/progress-bar-background.svg", isOnHMD = false, windowWidth = 0, windowHeight = 0, background2D = {}, bar2D = {}, - SCALE_2D = 0.55, // Scale the SVGs for 2D display. + SCALE_2D = 0.35, // Scale the SVGs for 2D display. background3D = {}, bar3D = {}, ENABLE_VR_MODE_MENU_ITEM = "Enable VR Mode", @@ -43,7 +44,7 @@ PROGRESS_3D_ELEVATION = -0.8, // Height of top middle of top notification relative to avatar eyes. PROGRESS_3D_YAW = 0.0, // Degrees relative to notifications direction. PROGRESS_3D_PITCH = -60.0, // Degrees from vertical. - SCALE_3D = 0.0017, // Scale the bar SVG for 3D display. + SCALE_3D = 0.0011, // Scale the bar SVG for 3D display. BACKGROUND_3D_SIZE = { x: 0.76, y: 0.08 }, // Match up with the 3D background with those of notifications.js notices. BACKGROUND_3D_COLOR = { red: 2, green: 2, blue: 2 }, BACKGROUND_3D_ALPHA = 0.7; From 334f26c84fc7583e5d889d8241076d51933bcae3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 6 Feb 2015 21:43:21 -0800 Subject: [PATCH 10/63] Display some progress while waiting at 0% and limit speed of advance --- examples/progress.js | 110 ++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 48 deletions(-) diff --git a/examples/progress.js b/examples/progress.js index 7fb2a043e2..57a1fd1a07 100644 --- a/examples/progress.js +++ b/examples/progress.js @@ -13,9 +13,13 @@ (function () { - var progress = 100, // % + var rawProgress = 100, // % raw value. + displayProgress = 100, // % smoothed value to display. + DISPLAY_PROGRESS_MINOR_MAXIMUM = 8, // % displayed progress bar goes up to while 0% raw progress. + DISPLAY_PROGRESS_MINOR_INCREMENT = 0.1, // % amount to increment display value each update when 0% raw progress. + DISPLAY_PROGRESS_MAJOR_INCREMENT = 5, // % maximum amount to increment display value when >0% raw progress. alpha = 0.0, - alphaDelta = 0.0, // > 0 if fading in; < 0 if fading out/ + alphaDelta = 0.0, // > 0 if fading in; < 0 if fading out. ALPHA_DELTA_IN = 0.15, ALPHA_DELTA_OUT = -0.02, fadeTimer = null, @@ -90,56 +94,15 @@ function onDownloadInfoChanged(info) { var i; - // Calculate progress + // Update raw progress value if (info.downloading.length + info.pending === 0) { - progress = 100; + rawProgress = 100; } else { - progress = 0; + rawProgress = 0; for (i = 0; i < info.downloading.length; i += 1) { - progress += info.downloading[i]; + rawProgress += info.downloading[i]; } - progress = progress / (info.downloading.length + info.pending); - } - - // Update state - if (!visible) { // Not visible because no recent downloads - if (progress < 100) { // Have started downloading so fade in - visible = true; - alphaDelta = ALPHA_DELTA_IN; - fadeTimer = Script.setInterval(fade, FADE_INTERVAL); - } - } else if (alphaDelta !== 0.0) { // Fading in or out - if (alphaDelta > 0) { - if (progress === 100) { // Was donloading but now have finished so fade out - alphaDelta = ALPHA_DELTA_OUT; - } - } else { - if (progress < 100) { // Was finished downloading but have resumed so fade in - alphaDelta = ALPHA_DELTA_IN; - } - } - } else { // Fully visible because downloading or recently so - if (fadeWaitTimer === null) { - if (progress === 100) { // Was downloading but have finished so fade out soon - fadeWaitTimer = Script.setTimeout(function () { - alphaDelta = ALPHA_DELTA_OUT; - fadeTimer = Script.setInterval(fade, FADE_INTERVAL); - fadeWaitTimer = null; - }, FADE_OUT_WAIT); - } - } else { - if (progress < 100) { // Was finished and waiting to fade out but have resumed downloading so don't fade out - Script.clearInterval(fadeWaitTimer); - fadeWaitTimer = null; - } - } - } - - // Update progress bar - if (visible) { - Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, { - subImage: { x: BAR_WIDTH * (1 - progress / 100), y: 0, width: BAR_WIDTH, height: BAR_HEIGHT } - }); + rawProgress = rawProgress / (info.downloading.length + info.pending); } } @@ -201,7 +164,58 @@ createOverlays(); } + // Calculate progress value to display + if (rawProgress === 0 && displayProgress <= DISPLAY_PROGRESS_MINOR_MAXIMUM) { + displayProgress = Math.min(displayProgress + DISPLAY_PROGRESS_MINOR_INCREMENT, DISPLAY_PROGRESS_MINOR_MAXIMUM); + } else if (rawProgress < displayProgress) { + displayProgress = rawProgress; + } else if (rawProgress > displayProgress) { + displayProgress = Math.min(rawProgress, displayProgress + DISPLAY_PROGRESS_MAJOR_INCREMENT); + } // else (rawProgress === displayProgress); do nothing. + + // Update state + if (!visible) { // Not visible because no recent downloads + if (displayProgress < 100) { // Have started downloading so fade in + visible = true; + alphaDelta = ALPHA_DELTA_IN; + fadeTimer = Script.setInterval(fade, FADE_INTERVAL); + } + } else if (alphaDelta !== 0.0) { // Fading in or out + if (alphaDelta > 0) { + if (displayProgress === 100) { // Was downloading but now have finished so fade out + alphaDelta = ALPHA_DELTA_OUT; + } + } else { + if (displayProgress < 100) { // Was finished downloading but have resumed so fade in + alphaDelta = ALPHA_DELTA_IN; + } + } + } else { // Fully visible because downloading or recently so + if (fadeWaitTimer === null) { + if (displayProgress === 100) { // Was downloading but have finished so fade out soon + fadeWaitTimer = Script.setTimeout(function () { + alphaDelta = ALPHA_DELTA_OUT; + fadeTimer = Script.setInterval(fade, FADE_INTERVAL); + fadeWaitTimer = null; + }, FADE_OUT_WAIT); + } + } else { + if (displayProgress < 100) { // Was finished and waiting to fade out but have resumed so don't fade out + Script.clearInterval(fadeWaitTimer); + fadeWaitTimer = null; + } + } + } + if (visible) { + + // Update progress bar + Overlays.editOverlay(isOnHMD ? bar3D.overlay : bar2D.overlay, { + visible: visible, + subImage: { x: BAR_WIDTH * (1 - displayProgress / 100), y: 0, width: BAR_WIDTH, height: BAR_HEIGHT } + }); + + // Update position if (isOnHMD) { // Update 3D overlays to maintain positions relative to avatar eyePosition = MyAvatar.getDefaultEyePosition(); From 5a81b8a5906be87d6ae2cfec2388b17151976a2e Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Fri, 13 Feb 2015 10:17:08 +0100 Subject: [PATCH 11/63] Do all the reverb at the input level --- libraries/audio-client/src/AudioClient.cpp | 53 +++++++++++++--------- libraries/audio-client/src/AudioClient.h | 2 +- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index d72fa46fc3..6dcd1fa733 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -616,9 +616,10 @@ void AudioClient::setReverbOptions(const AudioEffectOptions* options) { } } -void AudioClient::addReverb(ty_gverb* gverb, int16_t* samplesData, int numSamples, QAudioFormat& audioFormat, bool noEcho) { +void AudioClient::addReverb(ty_gverb* gverb, int16_t* samplesData, int16_t* reverbAlone, int numSamples, + QAudioFormat& audioFormat, bool noEcho) { float wetFraction = DB_CO(_reverbOptions->getWetLevel()); - float dryFraction = (noEcho) ? 0.0f : (1.0f - wetFraction); + float dryFraction = 1.0f - wetFraction; float lValue,rValue; for (int sample = 0; sample < numSamples; sample += audioFormat.channelCount()) { @@ -633,11 +634,19 @@ void AudioClient::addReverb(ty_gverb* gverb, int16_t* samplesData, int numSample int lResult = glm::clamp((int)(samplesData[j] * dryFraction + lValue * wetFraction), AudioConstants::MIN_SAMPLE_VALUE, AudioConstants::MAX_SAMPLE_VALUE); samplesData[j] = (int16_t)lResult; + + if (noEcho) { + reverbAlone[j] = (int16_t)lValue * wetFraction; + } } else if (j == (sample + 1)) { // right channel int rResult = glm::clamp((int)(samplesData[j] * dryFraction + rValue * wetFraction), AudioConstants::MIN_SAMPLE_VALUE, AudioConstants::MAX_SAMPLE_VALUE); samplesData[j] = (int16_t)rResult; + + if (noEcho) { + reverbAlone[j] = (int16_t)rValue * wetFraction; + } } else { // ignore channels above 2 } @@ -647,9 +656,8 @@ void AudioClient::addReverb(ty_gverb* gverb, int16_t* samplesData, int numSample void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) { // If there is server echo, reverb will be applied to the recieved audio stream so no need to have it here. - bool hasLocalReverb = (_reverb || _receivedAudioStream.hasReverb()) && - !_shouldEchoToServer; - if (_muted || !_audioOutput || (!_shouldEchoLocally && !hasLocalReverb)) { + bool hasReverb = _reverb || _receivedAudioStream.hasReverb(); + if (_muted || !_audioOutput || (!_shouldEchoLocally && !hasReverb)) { return; } @@ -671,24 +679,30 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) { } } - static QByteArray loopBackByteArray; - loopBackByteArray.resize(numDestinationSamplesRequired(_inputFormat, _outputFormat, - inputByteArray.size() / sizeof(int16_t)) * sizeof(int16_t)); + int numInputSamples = inputByteArray.size() / sizeof(int16_t); + int16_t* inputSamples = reinterpret_cast(inputByteArray.data()); - possibleResampling(_loopbackResampler, - reinterpret_cast(inputByteArray.data()), - reinterpret_cast(loopBackByteArray.data()), - inputByteArray.size() / sizeof(int16_t), loopBackByteArray.size() / sizeof(int16_t), - _inputFormat, _outputFormat); + static QByteArray reverbAlone; + reverbAlone.resize(inputByteArray.size()); + int16_t* reverbAloneSamples = reinterpret_cast(reverbAlone.data()); - if (hasLocalReverb) { - int16_t* loopbackSamples = reinterpret_cast(loopBackByteArray.data()); - int numLoopbackSamples = loopBackByteArray.size() / sizeof(int16_t); + if (hasReverb) { updateGverbOptions(); - addReverb(_gverbLocal, loopbackSamples, numLoopbackSamples, _outputFormat, !_shouldEchoLocally); + addReverb(_gverbLocal, inputSamples, reverbAloneSamples, numInputSamples, + _outputFormat, !_shouldEchoLocally); } if (_loopbackOutputDevice) { + static QByteArray loopBackByteArray; + int numLoopbackSamples = numDestinationSamplesRequired(_inputFormat, _outputFormat, numInputSamples); + loopBackByteArray.resize(numLoopbackSamples * sizeof(int16_t)); + + possibleResampling(_loopbackResampler, + (_shouldEchoLocally) ? inputSamples : reverbAloneSamples, + reinterpret_cast(loopBackByteArray.data()), + numInputSamples, numLoopbackSamples, + _inputFormat, _outputFormat); + _loopbackOutputDevice->write(loopBackByteArray); } } @@ -884,11 +898,6 @@ void AudioClient::processReceivedSamples(const QByteArray& inputBuffer, QByteArr reinterpret_cast(outputBuffer.data()), numNetworkOutputSamples, numDeviceOutputSamples, _desiredOutputFormat, _outputFormat); - - if(_reverb || _receivedAudioStream.hasReverb()) { - updateGverbOptions(); - addReverb(_gverb, (int16_t*)outputBuffer.data(), numDeviceOutputSamples, _outputFormat); - } } void AudioClient::sendMuteEnvironmentPacket() { diff --git a/libraries/audio-client/src/AudioClient.h b/libraries/audio-client/src/AudioClient.h index 0adf60fea8..183d8bc63f 100644 --- a/libraries/audio-client/src/AudioClient.h +++ b/libraries/audio-client/src/AudioClient.h @@ -251,7 +251,7 @@ private: ty_gverb* createGverbFilter(); void configureGverbFilter(ty_gverb* filter); void updateGverbOptions(); - void addReverb(ty_gverb* gverb, int16_t* samples, int numSamples, QAudioFormat& format, bool noEcho = false); + void addReverb(ty_gverb* gverb, int16_t* samples, int16_t* reverbAlone, int numSamples, QAudioFormat& format, bool noEcho = false); void handleLocalEchoAndReverb(QByteArray& inputByteArray); From 2c7e225ef75866416026c79d28688d5420ea69ac Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:14:47 -0800 Subject: [PATCH 12/63] use cmake ExternalProject for glm in Interface --- CMakeLists.txt | 1 + cmake/externals/glm/CMakeLists.txt | 11 +++++++++++ cmake/macros/AddDependencyExternalProject.cmake | 15 +++++++++++++++ interface/CMakeLists.txt | 6 ++++-- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 cmake/externals/glm/CMakeLists.txt create mode 100644 cmake/macros/AddDependencyExternalProject.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 04a5f3ee9a..b6eb3b935e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,7 @@ set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros") +set(EXTERNAL_PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/externals") file(GLOB HIFI_CUSTOM_MACROS "cmake/macros/*.cmake") foreach(CUSTOM_MACRO ${HIFI_CUSTOM_MACROS}) diff --git a/cmake/externals/glm/CMakeLists.txt b/cmake/externals/glm/CMakeLists.txt new file mode 100644 index 0000000000..0692b9573d --- /dev/null +++ b/cmake/externals/glm/CMakeLists.txt @@ -0,0 +1,11 @@ +include(ExternalProject) +ExternalProject_Add( + glm + URL https://github.com/g-truc/glm/archive/0.9.5.4.zip + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD ON +) +ExternalProject_Get_Property(glm source_dir) +set(GLM_INCLUDE_DIRS ${source_dir}/glm) \ No newline at end of file diff --git a/cmake/macros/AddDependencyExternalProject.cmake b/cmake/macros/AddDependencyExternalProject.cmake new file mode 100644 index 0000000000..56cf6d71be --- /dev/null +++ b/cmake/macros/AddDependencyExternalProject.cmake @@ -0,0 +1,15 @@ +# +# SetupExternalProject.cmake +# cmake/macros +# +# Copyright 2015 High Fidelity, Inc. +# Created by Stephen Birarda on February 13, 2014 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +macro(ADD_DEPENDENCY_EXTERNAL_PROJECT _PROJ_NAME) + add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME}/build) + add_dependencies(${TARGET_NAME} ${_PROJ_NAME}) +endmacro() \ No newline at end of file diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 8b23b85e04..8de425d5b0 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -32,8 +32,6 @@ elseif (WIN32) set(GL_HEADERS "#include \n#include \n#include ") endif () -# set up the external glm library -include_glm() include_bullet() # create the InterfaceConfig.h file based on GL_HEADERS above @@ -109,6 +107,10 @@ endif() # create the executable, make it a bundle on OS X add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) +# set up the external glm library +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) + # link required hifi libraries link_hifi_libraries(shared octree environment gpu model fbx metavoxels networking entities avatars audio audio-client animation script-engine physics From df8e51f8353b099fe1eaf42c23bc01efc45fe0be Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:21:21 -0800 Subject: [PATCH 13/63] use external project glm in more targets --- assignment-client/CMakeLists.txt | 3 ++- cmake/macros/IncludeGLM.cmake | 13 ------------- gvr-interface/CMakeLists.txt | 3 ++- interface/CMakeLists.txt | 2 +- libraries/audio/CMakeLists.txt | 3 ++- 5 files changed, 7 insertions(+), 17 deletions(-) delete mode 100644 cmake/macros/IncludeGLM.cmake diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index b56eea5c90..c2203316f9 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -2,7 +2,8 @@ set(TARGET_NAME assignment-client) setup_hifi_project(Core Gui Network Script Widgets) -include_glm() +add_dependency_external_project(glm) +target_link_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) # link in the shared libraries link_hifi_libraries( diff --git a/cmake/macros/IncludeGLM.cmake b/cmake/macros/IncludeGLM.cmake deleted file mode 100644 index 3e4bf9174d..0000000000 --- a/cmake/macros/IncludeGLM.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# -# IncludeGLM.cmake -# -# Copyright 2013 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 -# - -macro(INCLUDE_GLM) - find_package(GLM REQUIRED) - include_directories(SYSTEM "${GLM_INCLUDE_DIRS}") -endmacro(INCLUDE_GLM) \ No newline at end of file diff --git a/gvr-interface/CMakeLists.txt b/gvr-interface/CMakeLists.txt index 37ac6ec050..68eeb86791 100644 --- a/gvr-interface/CMakeLists.txt +++ b/gvr-interface/CMakeLists.txt @@ -24,7 +24,8 @@ endif () include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) -include_glm() +add_dependency_external_project(glm) +target_link_libraries(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared networking audio-client avatars) include_dependency_includes() diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 8de425d5b0..2be9f7bee2 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -109,7 +109,7 @@ add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) # set up the external glm library add_dependency_external_project(glm) -target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) +target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) # link required hifi libraries link_hifi_libraries(shared octree environment gpu model fbx metavoxels networking entities avatars diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index b08d9e88f4..c44198ddef 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -3,7 +3,8 @@ set(TARGET_NAME audio) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Network) -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(networking shared) From a4752aaab07cefb31730d493348fe88fc4362d4e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:22:09 -0800 Subject: [PATCH 14/63] use external project glm in avatars --- libraries/avatars/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index ccb661376d..c227e057e3 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -3,7 +3,8 @@ set(TARGET_NAME avatars) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Network Script) -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(audio shared networking) From 866295b09e28bab615d5d11325d3f62729de1d17 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:24:46 -0800 Subject: [PATCH 15/63] use external project glm in entities library --- libraries/entities/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/entities/CMakeLists.txt b/libraries/entities/CMakeLists.txt index 7589599548..8846dbfb89 100644 --- a/libraries/entities/CMakeLists.txt +++ b/libraries/entities/CMakeLists.txt @@ -3,7 +3,9 @@ set(TARGET_NAME entities) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Network Script) -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) + include_bullet() link_hifi_libraries(avatars shared octree gpu model fbx networking animation) From 0e790daa5b373cf808d2c048c3867976b5600aa2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:26:23 -0800 Subject: [PATCH 16/63] remove glm dependency from entities-renderer --- libraries/entities-renderer/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/entities-renderer/CMakeLists.txt b/libraries/entities-renderer/CMakeLists.txt index 6d7f5ee960..5f3b2298a8 100644 --- a/libraries/entities-renderer/CMakeLists.txt +++ b/libraries/entities-renderer/CMakeLists.txt @@ -3,8 +3,6 @@ set(TARGET_NAME entities-renderer) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Widgets OpenGL Network Script) -include_glm() - link_hifi_libraries(shared gpu script-engine render-utils) # call macro to include our dependency includes and bubble them up via a property on our target From 4d5d647d846ba732c14d9720a4d8ec407fa2c6f4 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:27:24 -0800 Subject: [PATCH 17/63] use external project glm in environment library --- libraries/environment/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/environment/CMakeLists.txt b/libraries/environment/CMakeLists.txt index 962628cd85..7cd91823d3 100644 --- a/libraries/environment/CMakeLists.txt +++ b/libraries/environment/CMakeLists.txt @@ -3,7 +3,8 @@ set(TARGET_NAME environment) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared networking) From 26b93731f827417c963d79379a549791a2af4df8 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:28:06 -0800 Subject: [PATCH 18/63] use glm as external project in fbx library --- libraries/fbx/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 67fe920568..7e28f63fc9 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -3,7 +3,8 @@ set(TARGET_NAME fbx) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared gpu model networking octree) From 54ce79db5a42e4e35aceaa0beb74de052d534c9d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:29:19 -0800 Subject: [PATCH 19/63] remove glm dependency in gpu library --- libraries/gpu/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/gpu/CMakeLists.txt b/libraries/gpu/CMakeLists.txt index b6bbba1c0f..789ffdbfeb 100644 --- a/libraries/gpu/CMakeLists.txt +++ b/libraries/gpu/CMakeLists.txt @@ -3,8 +3,6 @@ set(TARGET_NAME gpu) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() -include_glm() - link_hifi_libraries(shared) if (APPLE) From 16615b9be021aed93f41ac7fd2e1a593279d18eb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:30:22 -0800 Subject: [PATCH 20/63] use glm external project in metavoxels library --- libraries/metavoxels/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 4ead36e51a..6143bce2dc 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -8,7 +8,8 @@ setup_hifi_library(Network Script Widgets) # link in the networking library link_hifi_libraries(shared networking) -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) # call macro to include our dependency includes and bubble them up via a property on our target include_dependency_includes() \ No newline at end of file From 1d90c1c827111d00d71aef52be1b799a9e5fea56 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:31:41 -0800 Subject: [PATCH 21/63] use glm external project in model library --- libraries/model/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/model/CMakeLists.txt b/libraries/model/CMakeLists.txt index 309f6c3e6d..6d729ea58c 100755 --- a/libraries/model/CMakeLists.txt +++ b/libraries/model/CMakeLists.txt @@ -3,7 +3,8 @@ set(TARGET_NAME model) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared gpu) From 8994cc026801570e44cf13cb0a71a5f81b1f364e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:32:27 -0800 Subject: [PATCH 22/63] use external project glm for octree library --- libraries/octree/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index f4ac2263c2..c55f3bae89 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -3,7 +3,8 @@ set(TARGET_NAME octree) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared networking) From d7ce10dedb0b4b493ae456066201a936adeb57d1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:33:35 -0800 Subject: [PATCH 23/63] use external project glm for physics library --- libraries/physics/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/physics/CMakeLists.txt b/libraries/physics/CMakeLists.txt index 416ffa49f1..8b48501458 100644 --- a/libraries/physics/CMakeLists.txt +++ b/libraries/physics/CMakeLists.txt @@ -3,7 +3,9 @@ set(TARGET_NAME physics) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) + include_bullet() if (BULLET_FOUND) target_link_libraries(${TARGET_NAME} ${BULLET_LIBRARIES}) From fa6f6a6b71d0cf7e3ed88cfb32ad1175e791ca7a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:34:19 -0800 Subject: [PATCH 24/63] use external project glm in render-utils --- libraries/render-utils/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/render-utils/CMakeLists.txt b/libraries/render-utils/CMakeLists.txt index ed2dcce858..0bf7e91951 100644 --- a/libraries/render-utils/CMakeLists.txt +++ b/libraries/render-utils/CMakeLists.txt @@ -8,7 +8,8 @@ qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Widgets OpenGL Network Script) -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(animation fbx shared gpu) From b7135510873ab205ea8d1e5447970a4cb8a35c8a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:35:06 -0800 Subject: [PATCH 25/63] use external project glm in script-engine --- libraries/script-engine/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 7ab73ceefb..2c325e4daf 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -3,7 +3,8 @@ set(TARGET_NAME script-engine) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Gui Network Script Widgets) -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared octree gpu model fbx entities animation audio physics metavoxels) From d3973a724c3fe3e9b013c5d638ea85e8b8b4435d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:35:52 -0800 Subject: [PATCH 26/63] remove glm requirement in audio tests --- tests/audio/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index fb6b9c2e11..62d0ce5be9 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -2,8 +2,6 @@ set(TARGET_NAME audio-tests) setup_hifi_project() -include_glm() - # link in the shared libraries link_hifi_libraries(shared audio networking) From 0e32ed280a059d621ad73eae52634b2f926523f5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:36:23 -0800 Subject: [PATCH 27/63] put back glm dependency via external proj in entities-renderer --- libraries/entities-renderer/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/entities-renderer/CMakeLists.txt b/libraries/entities-renderer/CMakeLists.txt index 5f3b2298a8..46d6b8a462 100644 --- a/libraries/entities-renderer/CMakeLists.txt +++ b/libraries/entities-renderer/CMakeLists.txt @@ -3,6 +3,9 @@ set(TARGET_NAME entities-renderer) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(Widgets OpenGL Network Script) +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) + link_hifi_libraries(shared gpu script-engine render-utils) # call macro to include our dependency includes and bubble them up via a property on our target From 263afdd22c22f7acb33f8fbeff8cc22745ce8232 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:37:17 -0800 Subject: [PATCH 28/63] use external project glm in physics tests --- tests/physics/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 14e6c56df3..89fba47bea 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -2,7 +2,9 @@ set(TARGET_NAME physics-tests) setup_hifi_project() -include_glm() +add_dependency_external_project(glm) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) + include_bullet() link_hifi_libraries(shared physics) From 9c13bec47686a019d0188c4c442716ed490c1603 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:38:01 -0800 Subject: [PATCH 29/63] remove glm include where no longer required --- tests/metavoxels/CMakeLists.txt | 2 -- tests/octree/CMakeLists.txt | 2 -- tests/render-utils/CMakeLists.txt | 2 -- tests/shared/CMakeLists.txt | 2 -- tools/bitstream2json/CMakeLists.txt | 2 -- tools/json2bitstream/CMakeLists.txt | 2 -- 6 files changed, 12 deletions(-) diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 7524c5c87c..76f8870b34 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -2,8 +2,6 @@ set(TARGET_NAME metavoxel-tests) auto_mtc() -include_glm() - setup_hifi_project(Network Script Widgets) # link in the shared libraries diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index 7fc6b56332..99e3516431 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -2,8 +2,6 @@ set(TARGET_NAME octree-tests) setup_hifi_project(Script Network) -include_glm() - # link in the shared libraries link_hifi_libraries(shared octree gpu model fbx metavoxels networking entities avatars audio animation script-engine physics) diff --git a/tests/render-utils/CMakeLists.txt b/tests/render-utils/CMakeLists.txt index 47d80268d8..12a9fe5701 100644 --- a/tests/render-utils/CMakeLists.txt +++ b/tests/render-utils/CMakeLists.txt @@ -2,8 +2,6 @@ set(TARGET_NAME render-utils-tests) setup_hifi_project(Quick Gui OpenGL) -include_glm() - #include_oglplus() # link in the shared libraries diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index f067fa52b5..0402d3c74b 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -2,8 +2,6 @@ set(TARGET_NAME shared-tests) setup_hifi_project() -include_glm() - # link in the shared libraries link_hifi_libraries(shared) diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index 2e8bb213be..64ffbae5bf 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,8 +1,6 @@ set(TARGET_NAME bitstream2json) setup_hifi_project(Widgets Script) -include_glm() - link_hifi_libraries(metavoxels) include_dependency_includes() \ No newline at end of file diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index 283d450e11..d69a8dbe17 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,8 +1,6 @@ set(TARGET_NAME json2bitstream) setup_hifi_project(Widgets Script) -include_glm() - link_hifi_libraries(metavoxels) include_dependency_includes() \ No newline at end of file From 2f875cc08e741a69555deab94d861f9280953c21 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:38:13 -0800 Subject: [PATCH 30/63] remove the glm find module --- cmake/modules/FindGLM.cmake | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 cmake/modules/FindGLM.cmake diff --git a/cmake/modules/FindGLM.cmake b/cmake/modules/FindGLM.cmake deleted file mode 100644 index a75730b238..0000000000 --- a/cmake/modules/FindGLM.cmake +++ /dev/null @@ -1,28 +0,0 @@ -# -# FindGLM.cmake -# -# Try to find GLM include path. -# Once done this will define -# -# GLM_INCLUDE_DIRS -# -# Created on 7/17/2014 by Stephen Birarda -# Copyright 2014 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 -# - -# setup hints for GLM search -include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") -hifi_library_search_hints("glm") - -# locate header -find_path(GLM_INCLUDE_DIR "glm/glm.hpp" HINTS ${GLM_SEARCH_DIRS}) - -set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIRS) - -mark_as_advanced(GLM_INCLUDE_DIRS GLM_SEARCH_DIRS) \ No newline at end of file From 9136154cd5adc3a566c10ee62b9ab20f21442f18 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 10:48:27 -0800 Subject: [PATCH 31/63] fix double subdir include, clear up build guide --- BUILD.md | 7 ++++++- assignment-client/CMakeLists.txt | 2 +- cmake/macros/AddDependencyExternalProject.cmake | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/BUILD.md b/BUILD.md index 82cbf6628c..3065254529 100644 --- a/BUILD.md +++ b/BUILD.md @@ -2,7 +2,6 @@ * [cmake](http://www.cmake.org/cmake/resources/software.html) ~> 2.8.12.2 * [Qt](http://qt-project.org/downloads) ~> 5.3.2 -* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4 * [OpenSSL](https://www.openssl.org/related/binaries.html) ~> 1.0.1g * IMPORTANT: OpenSSL 1.0.1g is critical to avoid a security vulnerability. * [Intel Threading Building Blocks](https://www.threadingbuildingblocks.org/) ~> 4.3 @@ -10,6 +9,12 @@ * [Bullet Physics Engine](https://code.google.com/p/bullet/downloads/list) ~> 2.82 * [Gverb](https://github.com/highfidelity/gverb/archive/master.zip) (direct download to latest version) +#### CMake External Project Dependencies + +The following dependencies will be downloaded, built, linked and included automatically by CMake where we require them. The CMakeLists files that handle grabbing each of the following external dependencies can be found in the [cmake/externals folder](cmake/externals). The resulting downloads, source files and binaries will be placed in the `build` directory in each of the subfolders for each external project. These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. + +* [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4 + ### OS Specific Build Guides * [BUILD_OSX.md](BUILD_OSX.md) - additional instructions for OS X. * [BUILD_LINUX.md](BUILD_LINUX.md) - additional instructions for Linux. diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index c2203316f9..d8d2d44090 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -3,7 +3,7 @@ set(TARGET_NAME assignment-client) setup_hifi_project(Core Gui Network Script Widgets) add_dependency_external_project(glm) -target_link_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) +target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) # link in the shared libraries link_hifi_libraries( diff --git a/cmake/macros/AddDependencyExternalProject.cmake b/cmake/macros/AddDependencyExternalProject.cmake index 56cf6d71be..96b3ee44ab 100644 --- a/cmake/macros/AddDependencyExternalProject.cmake +++ b/cmake/macros/AddDependencyExternalProject.cmake @@ -10,6 +10,9 @@ # macro(ADD_DEPENDENCY_EXTERNAL_PROJECT _PROJ_NAME) - add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME}/build) + if (NOT TARGET ${_PROJ_NAME}) + add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${CMAKE_BINARY_DIR}/externals/${_PROJ_NAME}) + endif () + add_dependencies(${TARGET_NAME} ${_PROJ_NAME}) endmacro() \ No newline at end of file From 50c9bb2ae53fedf222a938c0536e6d105b6a5614 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 12:33:27 -0800 Subject: [PATCH 32/63] remove glm as manual dep in BUILD guides --- BUILD_ANDROID.md | 5 ----- BUILD_OSX.md | 2 +- BUILD_WIN.md | 9 --------- cmake/externals/glm/CMakeLists.txt | 9 ++++----- cmake/macros/AddDependencyExternalProject.cmake | 12 +++++++++++- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/BUILD_ANDROID.md b/BUILD_ANDROID.md index 719aa8cfd9..6ff3160775 100644 --- a/BUILD_ANDROID.md +++ b/BUILD_ANDROID.md @@ -127,11 +127,6 @@ To put the Gear VR Service into developer mode you need an application with an O Once the application is on your device, go to `Settings->Application Manager->Gear VR Service->Manage Storage`. Tap on `VR Service Version` six times. It will scan your device to verify that you have an osig file in an application on your device, and then it will let you enable Developer mode. -####GLM - -GLM is a header only library and technically the same GLM used for desktop builds of hifi could be used for the Android build. However, to avoid conflicts with system installations of Android dependencies, CMake will only look for Android headers and libraries in `ANDROID_LIB_DIR` or in your android-ndk install. - -Download the [glm headers](http://sourceforge.net/projects/ogl-math/files/) from their sourceforge page. The version you download should match the requirement shown in the [general build guide](BUILD.md). Extract the archive into your `ANDROID_LIB_DIR` and rename the extracted folder to `glm`. ###CMake diff --git a/BUILD_OSX.md b/BUILD_OSX.md index fce74cf678..2d5460d39d 100644 --- a/BUILD_OSX.md +++ b/BUILD_OSX.md @@ -4,7 +4,7 @@ Please read the [general build guide](BUILD.md) for information on dependencies [Homebrew](http://brew.sh/) is an excellent package manager for OS X. It makes install of all hifi dependencies very simple. brew tap highfidelity/homebrew-formulas - brew install cmake glm openssl tbb libsoxr + brew install cmake openssl tbb libsoxr brew install highfidelity/formulas/qt5 brew link qt5 --force diff --git a/BUILD_WIN.md b/BUILD_WIN.md index 8022fae5b8..ebc0b60f25 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -56,9 +56,6 @@ The recommended route for CMake to find the external dependencies is to place al -> bin -> include -> lib - -> glm - -> glm - -> glm.hpp -> openssl -> bin -> include @@ -129,12 +126,6 @@ Download the binary package: `glew-1.10.0-win32.zip`. Extract to %HIFI_LIB_DIR%\ Add to the PATH: `%HIFI_LIB_DIR%\glew\bin\Release\Win32` -###GLM - -This package contains only headers, so there's nothing to add to the PATH. - -Be careful with glm. For the folder other libraries would normally call 'include', the folder containing the headers, glm opts to use 'glm'. You will have a glm folder nested inside the top-level glm folder. - ###Gverb 1. Go to https://github.com/highfidelity/gverb diff --git a/cmake/externals/glm/CMakeLists.txt b/cmake/externals/glm/CMakeLists.txt index 0692b9573d..6246993df5 100644 --- a/cmake/externals/glm/CMakeLists.txt +++ b/cmake/externals/glm/CMakeLists.txt @@ -2,10 +2,9 @@ include(ExternalProject) ExternalProject_Add( glm URL https://github.com/g-truc/glm/archive/0.9.5.4.zip - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= LOG_DOWNLOAD ON ) -ExternalProject_Get_Property(glm source_dir) -set(GLM_INCLUDE_DIRS ${source_dir}/glm) \ No newline at end of file +ExternalProject_Get_Property(glm install_dir) + +export(TARGETS glm FILE ${CMAKE_BINARY_DIR}/glm-config.cmake) \ No newline at end of file diff --git a/cmake/macros/AddDependencyExternalProject.cmake b/cmake/macros/AddDependencyExternalProject.cmake index 96b3ee44ab..c4c2c0d005 100644 --- a/cmake/macros/AddDependencyExternalProject.cmake +++ b/cmake/macros/AddDependencyExternalProject.cmake @@ -11,8 +11,18 @@ macro(ADD_DEPENDENCY_EXTERNAL_PROJECT _PROJ_NAME) if (NOT TARGET ${_PROJ_NAME}) - add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${CMAKE_BINARY_DIR}/externals/${_PROJ_NAME}) + + if (ANDROID) + set(_PROJ_BINARY_DIR ${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME}/build/android) + else () + set(_PROJ_BINARY_DIR ${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME}/build) + endif () + + add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${_PROJ_BINARY_DIR}) endif () + string(TOUPPER ${_PROJ_NAME} _PROJ_NAME_UPPER) + get_target_property(${_PROJ_NAME_UPPER}_INCLUDE_DIRS ${_PROJ_NAME} INCLUDE_DIRS) + add_dependencies(${TARGET_NAME} ${_PROJ_NAME}) endmacro() \ No newline at end of file From 8c998a65eee153ed4ed38765579a1df295ed3ed9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 12:50:32 -0800 Subject: [PATCH 33/63] use the glm find_package and check externals --- assignment-client/CMakeLists.txt | 1 + cmake/externals/glm/CMakeLists.txt | 1 + cmake/macros/HifiLibrarySearchHints.cmake | 11 +++++---- cmake/modules/FindGLM.cmake | 28 ++++++++++++++++++++++ interface/CMakeLists.txt | 1 + libraries/audio/CMakeLists.txt | 1 + libraries/avatars/CMakeLists.txt | 1 + libraries/entities-renderer/CMakeLists.txt | 1 + libraries/entities/CMakeLists.txt | 1 + libraries/environment/CMakeLists.txt | 1 + libraries/fbx/CMakeLists.txt | 1 + libraries/metavoxels/CMakeLists.txt | 1 + libraries/model/CMakeLists.txt | 1 + libraries/octree/CMakeLists.txt | 1 + libraries/physics/CMakeLists.txt | 1 + libraries/render-utils/CMakeLists.txt | 1 + libraries/script-engine/CMakeLists.txt | 1 + tests/physics/CMakeLists.txt | 1 + 18 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 cmake/modules/FindGLM.cmake diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index d8d2d44090..b16314811b 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -3,6 +3,7 @@ set(TARGET_NAME assignment-client) setup_hifi_project(Core Gui Network Script Widgets) add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) # link in the shared libraries diff --git a/cmake/externals/glm/CMakeLists.txt b/cmake/externals/glm/CMakeLists.txt index 6246993df5..a3b64b9370 100644 --- a/cmake/externals/glm/CMakeLists.txt +++ b/cmake/externals/glm/CMakeLists.txt @@ -1,6 +1,7 @@ include(ExternalProject) ExternalProject_Add( glm + PREFIX glm URL https://github.com/g-truc/glm/archive/0.9.5.4.zip CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= LOG_DOWNLOAD ON diff --git a/cmake/macros/HifiLibrarySearchHints.cmake b/cmake/macros/HifiLibrarySearchHints.cmake index e22b442beb..e4b67af15e 100644 --- a/cmake/macros/HifiLibrarySearchHints.cmake +++ b/cmake/macros/HifiLibrarySearchHints.cmake @@ -10,22 +10,23 @@ macro(HIFI_LIBRARY_SEARCH_HINTS LIBRARY_FOLDER) string(TOUPPER ${LIBRARY_FOLDER} LIBRARY_PREFIX) - set(${LIBRARY_PREFIX}_SEARCH_DIRS "") + + set(${LIBRARY_PREFIX}_SEARCH_DIRS "${EXTERNAL_PROJECT_DIR}/${LIBRARY_FOLDER}/build/${LIBRARY_FOLDER}") if (${LIBRARY_PREFIX}_ROOT_DIR) - set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_ROOT_DIR}") + list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_ROOT_DIR}") endif () if (ANDROID) - set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "/${LIBRARY_FOLDER}") + list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "/${LIBRARY_FOLDER}") endif () if (DEFINED ENV{${LIBRARY_PREFIX}_ROOT_DIR}) - set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "$ENV{${LIBRARY_PREFIX}_ROOT_DIR}") + list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "$ENV{${LIBRARY_PREFIX}_ROOT_DIR}") endif () if (DEFINED ENV{HIFI_LIB_DIR}) - set(${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_SEARCH_DIRS}" "$ENV{HIFI_LIB_DIR}/${LIBRARY_FOLDER}") + list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "$ENV{HIFI_LIB_DIR}/${LIBRARY_FOLDER}") endif () endmacro(HIFI_LIBRARY_SEARCH_HINTS _library_folder) \ No newline at end of file diff --git a/cmake/modules/FindGLM.cmake b/cmake/modules/FindGLM.cmake new file mode 100644 index 0000000000..a75730b238 --- /dev/null +++ b/cmake/modules/FindGLM.cmake @@ -0,0 +1,28 @@ +# +# FindGLM.cmake +# +# Try to find GLM include path. +# Once done this will define +# +# GLM_INCLUDE_DIRS +# +# Created on 7/17/2014 by Stephen Birarda +# Copyright 2014 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 +# + +# setup hints for GLM search +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("glm") + +# locate header +find_path(GLM_INCLUDE_DIR "glm/glm.hpp" HINTS ${GLM_SEARCH_DIRS}) + +set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIRS) + +mark_as_advanced(GLM_INCLUDE_DIRS GLM_SEARCH_DIRS) \ No newline at end of file diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 2be9f7bee2..7d581284e5 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -109,6 +109,7 @@ add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) # set up the external glm library add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) # link required hifi libraries diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index c44198ddef..6ec35e00fc 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -4,6 +4,7 @@ set(TARGET_NAME audio) setup_hifi_library(Network) add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(networking shared) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index c227e057e3..bb4b8fdde0 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -4,6 +4,7 @@ set(TARGET_NAME avatars) setup_hifi_library(Network Script) add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(audio shared networking) diff --git a/libraries/entities-renderer/CMakeLists.txt b/libraries/entities-renderer/CMakeLists.txt index 46d6b8a462..e706b07538 100644 --- a/libraries/entities-renderer/CMakeLists.txt +++ b/libraries/entities-renderer/CMakeLists.txt @@ -4,6 +4,7 @@ set(TARGET_NAME entities-renderer) setup_hifi_library(Widgets OpenGL Network Script) add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared gpu script-engine render-utils) diff --git a/libraries/entities/CMakeLists.txt b/libraries/entities/CMakeLists.txt index 8846dbfb89..d0c39cac84 100644 --- a/libraries/entities/CMakeLists.txt +++ b/libraries/entities/CMakeLists.txt @@ -4,6 +4,7 @@ set(TARGET_NAME entities) setup_hifi_library(Network Script) add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) include_bullet() diff --git a/libraries/environment/CMakeLists.txt b/libraries/environment/CMakeLists.txt index 7cd91823d3..e5e7b80701 100644 --- a/libraries/environment/CMakeLists.txt +++ b/libraries/environment/CMakeLists.txt @@ -4,6 +4,7 @@ set(TARGET_NAME environment) setup_hifi_library() add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared networking) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 7e28f63fc9..da6d471c72 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -4,6 +4,7 @@ set(TARGET_NAME fbx) setup_hifi_library() add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared gpu model networking octree) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 6143bce2dc..593ee800a7 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -9,6 +9,7 @@ setup_hifi_library(Network Script Widgets) link_hifi_libraries(shared networking) add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) # call macro to include our dependency includes and bubble them up via a property on our target diff --git a/libraries/model/CMakeLists.txt b/libraries/model/CMakeLists.txt index 6d729ea58c..0f71a25047 100755 --- a/libraries/model/CMakeLists.txt +++ b/libraries/model/CMakeLists.txt @@ -4,6 +4,7 @@ set(TARGET_NAME model) setup_hifi_library() add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared gpu) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index c55f3bae89..3c7e8e7749 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -4,6 +4,7 @@ set(TARGET_NAME octree) setup_hifi_library() add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared networking) diff --git a/libraries/physics/CMakeLists.txt b/libraries/physics/CMakeLists.txt index 8b48501458..7fc3f82496 100644 --- a/libraries/physics/CMakeLists.txt +++ b/libraries/physics/CMakeLists.txt @@ -4,6 +4,7 @@ set(TARGET_NAME physics) setup_hifi_library() add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) include_bullet() diff --git a/libraries/render-utils/CMakeLists.txt b/libraries/render-utils/CMakeLists.txt index 0bf7e91951..054b30d7fb 100644 --- a/libraries/render-utils/CMakeLists.txt +++ b/libraries/render-utils/CMakeLists.txt @@ -9,6 +9,7 @@ qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts setup_hifi_library(Widgets OpenGL Network Script) add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(animation fbx shared gpu) diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 2c325e4daf..4e13ddf513 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -4,6 +4,7 @@ set(TARGET_NAME script-engine) setup_hifi_library(Gui Network Script Widgets) add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared octree gpu model fbx entities animation audio physics metavoxels) diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 89fba47bea..e20f323392 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -3,6 +3,7 @@ set(TARGET_NAME physics-tests) setup_hifi_project() add_dependency_external_project(glm) +find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) include_bullet() From 6e63c1c1ad2e26e976cd9585b071d10c01b32b53 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 14:50:12 -0800 Subject: [PATCH 34/63] set the GLM_INCLUDE_DIRS var in cache so find hits it --- cmake/externals/glm/CMakeLists.txt | 12 ++++++++---- cmake/macros/AddDependencyExternalProject.cmake | 3 --- cmake/modules/FindGLM.cmake | 4 +--- libraries/shared/CMakeLists.txt | 4 ++++ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cmake/externals/glm/CMakeLists.txt b/cmake/externals/glm/CMakeLists.txt index a3b64b9370..8bf597ecc3 100644 --- a/cmake/externals/glm/CMakeLists.txt +++ b/cmake/externals/glm/CMakeLists.txt @@ -1,11 +1,15 @@ +set(EXTERNAL_NAME glm) + include(ExternalProject) ExternalProject_Add( - glm - PREFIX glm + ${EXTERNAL_NAME} + PREFIX ${EXTERNAL_NAME} URL https://github.com/g-truc/glm/archive/0.9.5.4.zip CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= LOG_DOWNLOAD ON ) -ExternalProject_Get_Property(glm install_dir) -export(TARGETS glm FILE ${CMAKE_BINARY_DIR}/glm-config.cmake) \ No newline at end of file +ExternalProject_Get_Property(${EXTERNAL_NAME} install_dir) + +string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) +set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${install_dir}/include CACHE TYPE STRING) \ No newline at end of file diff --git a/cmake/macros/AddDependencyExternalProject.cmake b/cmake/macros/AddDependencyExternalProject.cmake index c4c2c0d005..71c32e5e69 100644 --- a/cmake/macros/AddDependencyExternalProject.cmake +++ b/cmake/macros/AddDependencyExternalProject.cmake @@ -21,8 +21,5 @@ macro(ADD_DEPENDENCY_EXTERNAL_PROJECT _PROJ_NAME) add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${_PROJ_BINARY_DIR}) endif () - string(TOUPPER ${_PROJ_NAME} _PROJ_NAME_UPPER) - get_target_property(${_PROJ_NAME_UPPER}_INCLUDE_DIRS ${_PROJ_NAME} INCLUDE_DIRS) - add_dependencies(${TARGET_NAME} ${_PROJ_NAME}) endmacro() \ No newline at end of file diff --git a/cmake/modules/FindGLM.cmake b/cmake/modules/FindGLM.cmake index a75730b238..ace7360ea7 100644 --- a/cmake/modules/FindGLM.cmake +++ b/cmake/modules/FindGLM.cmake @@ -18,9 +18,7 @@ include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") hifi_library_search_hints("glm") # locate header -find_path(GLM_INCLUDE_DIR "glm/glm.hpp" HINTS ${GLM_SEARCH_DIRS}) - -set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") +find_path(GLM_INCLUDE_DIRS "glm/glm.hpp" HINTS ${GLM_SEARCH_DIRS}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIRS) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 0bbb39fdb5..5af2343ec2 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -4,5 +4,9 @@ set(TARGET_NAME shared) # TODO: there isn't really a good reason to have Script linked here - let's get what is requiring it out (RegisteredMetaTypes.cpp) setup_hifi_library(Gui Network Script Widgets) +add_dependency_external_project(glm) +find_package(GLM REQUIRED) +target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) + # call macro to include our dependency includes and bubble them up via a property on our target include_dependency_includes() \ No newline at end of file From ab0692229d7952ab359cfe824a2ee49efdfb9d28 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 14:54:21 -0800 Subject: [PATCH 35/63] fix GLM includes for gvr-interface and shared --- gvr-interface/CMakeLists.txt | 3 ++- libraries/shared/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gvr-interface/CMakeLists.txt b/gvr-interface/CMakeLists.txt index 68eeb86791..de0b66165b 100644 --- a/gvr-interface/CMakeLists.txt +++ b/gvr-interface/CMakeLists.txt @@ -25,7 +25,8 @@ endif () include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) add_dependency_external_project(glm) -target_link_libraries(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) +find_package(GLM REQUIRED) +target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) link_hifi_libraries(shared networking audio-client avatars) include_dependency_includes() diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 5af2343ec2..54cd91deaf 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -6,7 +6,7 @@ setup_hifi_library(Gui Network Script Widgets) add_dependency_external_project(glm) find_package(GLM REQUIRED) -target_include_directories(${TARGET_NAME} PRIVATE ${GLM_INCLUDE_DIRS}) +target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) # call macro to include our dependency includes and bubble them up via a property on our target include_dependency_includes() \ No newline at end of file From 430083681019cdb7cc785a1ff142a4a1ee36fb59 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 15:47:35 -0800 Subject: [PATCH 36/63] make gverb a cmake external project --- cmake/externals/glm/CMakeLists.txt | 4 +-- cmake/externals/gverb/CMakeLists.txt | 16 ++++++++++++ cmake/modules/FindGverb.cmake | 26 +++++-------------- libraries/audio-client/CMakeLists.txt | 12 +++------ .../audio-client/external/gverb/readme.txt | 14 ---------- libraries/audio-client/src/AudioClient.cpp | 5 ++++ libraries/audio-client/src/AudioClient.h | 6 ++--- 7 files changed, 35 insertions(+), 48 deletions(-) create mode 100644 cmake/externals/gverb/CMakeLists.txt delete mode 100644 libraries/audio-client/external/gverb/readme.txt diff --git a/cmake/externals/glm/CMakeLists.txt b/cmake/externals/glm/CMakeLists.txt index 8bf597ecc3..928603ecd2 100644 --- a/cmake/externals/glm/CMakeLists.txt +++ b/cmake/externals/glm/CMakeLists.txt @@ -9,7 +9,7 @@ ExternalProject_Add( LOG_DOWNLOAD ON ) -ExternalProject_Get_Property(${EXTERNAL_NAME} install_dir) +ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR) string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) -set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${install_dir}/include CACHE TYPE STRING) \ No newline at end of file +set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE TYPE STRING) \ No newline at end of file diff --git a/cmake/externals/gverb/CMakeLists.txt b/cmake/externals/gverb/CMakeLists.txt new file mode 100644 index 0000000000..1954df703e --- /dev/null +++ b/cmake/externals/gverb/CMakeLists.txt @@ -0,0 +1,16 @@ +set(EXTERNAL_NAME gverb) + +include(ExternalProject) +ExternalProject_Add( + ${EXTERNAL_NAME} + PREFIX ${EXTERNAL_NAME} + GIT_REPOSITORY https://github.com/birarda/gverb.git + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= + LOG_DOWNLOAD ON +) + +ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR) + +string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) +set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE TYPE STRING) +set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/libgverb.a CACHE TYPE STRING) \ No newline at end of file diff --git a/cmake/modules/FindGverb.cmake b/cmake/modules/FindGverb.cmake index d4d2377c94..7dc233333c 100644 --- a/cmake/modules/FindGverb.cmake +++ b/cmake/modules/FindGverb.cmake @@ -15,25 +15,11 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -if (GVERB_INCLUDE_DIRS) - # in cache already - set(GVERB_FOUND TRUE) -else (GVERB_INCLUDE_DIRS) +include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") +hifi_library_search_hints("gverb") - include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") - hifi_library_search_hints("gverb") +find_path(GVERB_INCLUDE_DIRS gverb.h PATH_SUFFIXES include HINTS ${GVERB_SEARCH_DIRS}) +find_path(GVERB_LIBRARIES gverb PATH_SUFFIXES lib HINTS ${GVERB_SEARCH_DIRS}) - find_path(GVERB_INCLUDE_DIRS gverb.h PATH_SUFFIXES include HINTS ${GVERB_SEARCH_DIRS} NO_CMAKE_FIND_ROOT_PATH) - find_path(GVERB_SRC_DIRS gverb.c PATH_SUFFIXES src HINTS ${GVERB_SEARCH_DIRS} NO_CMAKE_FIND_ROOT_PATH) - - if (GVERB_INCLUDE_DIRS) - set(GVERB_FOUND TRUE) - endif (GVERB_INCLUDE_DIRS) - - if (GVERB_FOUND) - message(STATUS "Found Gverb: ${GVERB_INCLUDE_DIRS}") - else (GVERB_FOUND) - message(FATAL_ERROR "Could NOT find Gverb. Read ./libraries/audio-client/externals/gverb/readme.txt") - endif (GVERB_FOUND) - -endif(GVERB_INCLUDE_DIRS) \ No newline at end of file +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GVERB DEFAULT_MSG GVERB_INCLUDE_DIRS GVERB_LIBRARIES) \ No newline at end of file diff --git a/libraries/audio-client/CMakeLists.txt b/libraries/audio-client/CMakeLists.txt index 5477be3bc5..1cd76cf2f5 100644 --- a/libraries/audio-client/CMakeLists.txt +++ b/libraries/audio-client/CMakeLists.txt @@ -8,17 +8,13 @@ link_hifi_libraries(audio) # append audio includes to our list of includes to bubble list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${HIFI_LIBRARY_DIR}/audio/src") -set(GVERB_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/gverb") +# have CMake grab Gverb from git and then set up linking and directory include +add_dependency_external_project(gverb) -# As Gverb is currently the only reverb library, it's required. find_package(Gverb REQUIRED) -file(GLOB GVERB_SRCS ${GVERB_SRC_DIRS}/*.c) -add_library(gverb STATIC ${GVERB_SRCS}) -target_link_libraries(${TARGET_NAME} gverb) - -# append gverb includes to our list of includes to bubble -list(APPEND ${TARGET_NAME}_DEPENDENCY_INCLUDES "${GVERB_INCLUDE_DIRS}") +target_link_libraries(${TARGET_NAME} ${GVERB_LIBRARIES}) +target_include_directories(${TARGET_NAME} PRIVATE ${GVERB_INCLUDE_DIRS}) # we use libsoxr for resampling find_package(Soxr REQUIRED) diff --git a/libraries/audio-client/external/gverb/readme.txt b/libraries/audio-client/external/gverb/readme.txt deleted file mode 100644 index bb01e48a74..0000000000 --- a/libraries/audio-client/external/gverb/readme.txt +++ /dev/null @@ -1,14 +0,0 @@ -Instructions for adding the Gverb library to audio-client -(This is a required library) -Clément Brisset, October 22nd, 2014 - -1. Go to https://github.com/highfidelity/gverb - Or download the sources directly via this link: - https://github.com/highfidelity/gverb/archive/master.zip - -2. Extract the archive - -3. Place the directories “include” and “src” in libraries/audio-client/external/gverb - (Normally next to this readme) - -4. Clear your build directory, run cmake, build and you should be all set. diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 1919f2bbe5..391d6aaf40 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -33,6 +33,11 @@ #include #include +extern "C" { + #include + #include +} + #include #include diff --git a/libraries/audio-client/src/AudioClient.h b/libraries/audio-client/src/AudioClient.h index e55a116e06..dc4e16d81b 100644 --- a/libraries/audio-client/src/AudioClient.h +++ b/libraries/audio-client/src/AudioClient.h @@ -47,10 +47,7 @@ #pragma warning( disable : 4273 ) #pragma warning( disable : 4305 ) #endif -extern "C" { - #include - #include -} + #ifdef _WIN32 #pragma warning( pop ) #endif @@ -68,6 +65,7 @@ class QAudioInput; class QAudioOutput; class QIODevice; struct soxr; +typedef struct ty_gverb ty_gverb; typedef glm::vec3 (*AudioPositionGetter)(); typedef glm::quat (*AudioOrientationGetter)(); From 48e7aa74330135185ffcd49a4f9bb2444487d0b2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 16:06:30 -0800 Subject: [PATCH 37/63] handle android build of gverb for external project --- cmake/externals/gverb/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/externals/gverb/CMakeLists.txt b/cmake/externals/gverb/CMakeLists.txt index 1954df703e..373089eb2d 100644 --- a/cmake/externals/gverb/CMakeLists.txt +++ b/cmake/externals/gverb/CMakeLists.txt @@ -1,11 +1,15 @@ set(EXTERNAL_NAME gverb) +if (ANDROID) + set(ANDROID_CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" "-DANDROID_NATIVE_API_LEVEL=19") +endif () + include(ExternalProject) ExternalProject_Add( ${EXTERNAL_NAME} PREFIX ${EXTERNAL_NAME} GIT_REPOSITORY https://github.com/birarda/gverb.git - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= + CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH= LOG_DOWNLOAD ON ) From d337cadb106f8787ac40f1afe8b0c50fd023e3c4 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 16:12:03 -0800 Subject: [PATCH 38/63] add gverb to list of auto-deps --- BUILD.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BUILD.md b/BUILD.md index 3065254529..f7dc22882a 100644 --- a/BUILD.md +++ b/BUILD.md @@ -14,6 +14,7 @@ The following dependencies will be downloaded, built, linked and included automatically by CMake where we require them. The CMakeLists files that handle grabbing each of the following external dependencies can be found in the [cmake/externals folder](cmake/externals). The resulting downloads, source files and binaries will be placed in the `build` directory in each of the subfolders for each external project. These are not placed in your normal build tree when doing an out of source build so that they do not need to be re-downloaded and re-compiled every time the CMake build folder is cleared. * [glm](http://glm.g-truc.net/0.9.5/index.html) ~> 0.9.5.4 +* [gverb](https://github.com/highfidelity/gverb) ### OS Specific Build Guides * [BUILD_OSX.md](BUILD_OSX.md) - additional instructions for OS X. From 691cf2d893ba783a589615b996aef751eb192f78 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 16:12:47 -0800 Subject: [PATCH 39/63] remove gverb from win build guide --- BUILD_WIN.md | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/BUILD_WIN.md b/BUILD_WIN.md index ebc0b60f25..6f26e8c809 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -126,20 +126,6 @@ Download the binary package: `glew-1.10.0-win32.zip`. Extract to %HIFI_LIB_DIR%\ Add to the PATH: `%HIFI_LIB_DIR%\glew\bin\Release\Win32` -###Gverb - -1. Go to https://github.com/highfidelity/gverb - Or download the sources directly via this link: - https://github.com/highfidelity/gverb/archive/master.zip - -2. Extract the archive - -3. Place the directories “include” and “src” in interface/external/gverb - (Normally next to this readme) - -4. Clear your build directory, run cmake, build and you should be all set. - - ###Bullet Bullet 2.82 source can be [downloaded here](https://code.google.com/p/bullet/downloads/detail?name=bullet-2.82-r2704.zip). Bullet does not come with prebuilt libraries, you need to make those yourself. From 28fabcb7884670eb3c562de570c9ca68130431cf Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 16:17:45 -0800 Subject: [PATCH 40/63] avoid ubuntu libssl error by using http links --- cmake/externals/glm/CMakeLists.txt | 2 +- cmake/externals/gverb/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/externals/glm/CMakeLists.txt b/cmake/externals/glm/CMakeLists.txt index 928603ecd2..4c9745af9f 100644 --- a/cmake/externals/glm/CMakeLists.txt +++ b/cmake/externals/glm/CMakeLists.txt @@ -4,7 +4,7 @@ include(ExternalProject) ExternalProject_Add( ${EXTERNAL_NAME} PREFIX ${EXTERNAL_NAME} - URL https://github.com/g-truc/glm/archive/0.9.5.4.zip + URL http://github.com/g-truc/glm/archive/0.9.5.4.zip CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= LOG_DOWNLOAD ON ) diff --git a/cmake/externals/gverb/CMakeLists.txt b/cmake/externals/gverb/CMakeLists.txt index 373089eb2d..bd461d349e 100644 --- a/cmake/externals/gverb/CMakeLists.txt +++ b/cmake/externals/gverb/CMakeLists.txt @@ -8,7 +8,7 @@ include(ExternalProject) ExternalProject_Add( ${EXTERNAL_NAME} PREFIX ${EXTERNAL_NAME} - GIT_REPOSITORY https://github.com/birarda/gverb.git + GIT_REPOSITORY http://github.com/birarda/gverb.git CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH= LOG_DOWNLOAD ON ) From 018b8497bddee1b64a8196975e492d0131221ff5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 16:21:19 -0800 Subject: [PATCH 41/63] use non-redirecting glm link to avoid https error --- cmake/externals/glm/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/externals/glm/CMakeLists.txt b/cmake/externals/glm/CMakeLists.txt index 4c9745af9f..b1aed7dd7f 100644 --- a/cmake/externals/glm/CMakeLists.txt +++ b/cmake/externals/glm/CMakeLists.txt @@ -4,7 +4,7 @@ include(ExternalProject) ExternalProject_Add( ${EXTERNAL_NAME} PREFIX ${EXTERNAL_NAME} - URL http://github.com/g-truc/glm/archive/0.9.5.4.zip + URL http://pkgs.fedoraproject.org/repo/pkgs/glm/glm-0.9.5.4.zip/fab76fc982b256b46208e5c750ed456a/glm-0.9.5.4.zip CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= LOG_DOWNLOAD ON ) From 9683ed92e321cdec5b7607a03f0bf08dd1753fd5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 13 Feb 2015 16:40:48 -0800 Subject: [PATCH 42/63] use proper lib path on WIN32 for gverb --- cmake/externals/gverb/CMakeLists.txt | 9 +++++++-- cmake/modules/FindGverb.cmake | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmake/externals/gverb/CMakeLists.txt b/cmake/externals/gverb/CMakeLists.txt index bd461d349e..19a44781b1 100644 --- a/cmake/externals/gverb/CMakeLists.txt +++ b/cmake/externals/gverb/CMakeLists.txt @@ -8,7 +8,7 @@ include(ExternalProject) ExternalProject_Add( ${EXTERNAL_NAME} PREFIX ${EXTERNAL_NAME} - GIT_REPOSITORY http://github.com/birarda/gverb.git + GIT_REPOSITORY https://github.com/birarda/gverb.git CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH= LOG_DOWNLOAD ON ) @@ -17,4 +17,9 @@ ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR) string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${INSTALL_DIR}/include CACHE TYPE STRING) -set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/libgverb.a CACHE TYPE STRING) \ No newline at end of file + +if (WIN32) + set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/gverb.lib CACHE TYPE STRING) +else () + set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${INSTALL_DIR}/lib/libgverb.a CACHE TYPE STRING) +endif () \ No newline at end of file diff --git a/cmake/modules/FindGverb.cmake b/cmake/modules/FindGverb.cmake index 7dc233333c..e54fba8083 100644 --- a/cmake/modules/FindGverb.cmake +++ b/cmake/modules/FindGverb.cmake @@ -19,7 +19,7 @@ include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") hifi_library_search_hints("gverb") find_path(GVERB_INCLUDE_DIRS gverb.h PATH_SUFFIXES include HINTS ${GVERB_SEARCH_DIRS}) -find_path(GVERB_LIBRARIES gverb PATH_SUFFIXES lib HINTS ${GVERB_SEARCH_DIRS}) +find_library(GVERB_LIBRARIES gverb PATH_SUFFIXES lib HINTS ${GVERB_SEARCH_DIRS}) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GVERB DEFAULT_MSG GVERB_INCLUDE_DIRS GVERB_LIBRARIES) \ No newline at end of file From f2790302839f3a150760efe077c4cfd9a26ab7b4 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 16 Feb 2015 16:15:03 +0100 Subject: [PATCH 43/63] Remove _gverbLocal --- libraries/audio-client/src/AudioClient.cpp | 19 ++----------------- libraries/audio-client/src/AudioClient.h | 1 - 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index fd4f23fabf..7277ec4d90 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -104,7 +104,6 @@ AudioClient::AudioClient() : _audioSourceInjectEnabled(false), _reverb(false), _reverbOptions(&_scriptReverbOptions), - _gverbLocal(NULL), _gverb(NULL), _inputToNetworkResampler(NULL), _networkToOutputResampler(NULL), @@ -130,20 +129,14 @@ AudioClient::AudioClient() : connect(updateTimer, &QTimer::timeout, this, &AudioClient::checkDevices); updateTimer->start(DEVICE_CHECK_INTERVAL_MSECS); - // create GVerb filters + // create GVerb filter _gverb = createGverbFilter(); - _gverbLocal = createGverbFilter(); - // configure filters configureGverbFilter(_gverb); - configureGverbFilter(_gverbLocal); } AudioClient::~AudioClient() { stop(); - if (_gverbLocal) { - gverb_free(_gverbLocal); - } if (_gverb) { gverb_free(_gverb); } @@ -158,7 +151,6 @@ void AudioClient::reset() { _inputGain.reset(); gverb_flush(_gverb); - gverb_flush(_gverbLocal); } void AudioClient::audioMixerKilled() { @@ -582,9 +574,6 @@ void AudioClient::updateGverbOptions() { gverb_free(_gverb); _gverb = createGverbFilter(); configureGverbFilter(_gverb); - gverb_free(_gverbLocal); - _gverbLocal = createGverbFilter(); - configureGverbFilter(_gverbLocal); } } @@ -593,7 +582,6 @@ void AudioClient::setReverb(bool reverb) { if (!_reverb) { gverb_flush(_gverb); - gverb_flush(_gverbLocal); } } @@ -616,9 +604,6 @@ void AudioClient::setReverbOptions(const AudioEffectOptions* options) { gverb_free(_gverb); _gverb = createGverbFilter(); configureGverbFilter(_gverb); - gverb_free(_gverbLocal); - _gverbLocal = createGverbFilter(); - configureGverbFilter(_gverbLocal); } } @@ -694,7 +679,7 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) { if (hasReverb) { updateGverbOptions(); - addReverb(_gverbLocal, inputSamples, reverbAloneSamples, numInputSamples, + addReverb(_gverb, inputSamples, reverbAloneSamples, numInputSamples, _outputFormat, !_shouldEchoLocally); } diff --git a/libraries/audio-client/src/AudioClient.h b/libraries/audio-client/src/AudioClient.h index bbba55afd2..d091fc0cc3 100644 --- a/libraries/audio-client/src/AudioClient.h +++ b/libraries/audio-client/src/AudioClient.h @@ -243,7 +243,6 @@ private: AudioEffectOptions _scriptReverbOptions; AudioEffectOptions _zoneReverbOptions; AudioEffectOptions* _reverbOptions; - ty_gverb* _gverbLocal; ty_gverb* _gverb; // possible soxr streams needed for resample From 17ce2e820fe9bf06bb054305f49d029662f90b80 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 16 Feb 2015 17:30:20 +0100 Subject: [PATCH 44/63] Cleanup addReverb() code --- libraries/audio-client/src/AudioClient.cpp | 39 ++++++++++++---------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 7277ec4d90..2264e31131 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -658,6 +658,10 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) { if (!_loopbackOutputDevice && _loopbackAudioOutput) { // we didn't have the loopback output device going so set that up now _loopbackOutputDevice = _loopbackAudioOutput->start(); + + if (!_loopbackOutputDevice) { + return; + } } // do we need to setup a resampler? @@ -670,32 +674,31 @@ void AudioClient::handleLocalEchoAndReverb(QByteArray& inputByteArray) { } } - int numInputSamples = inputByteArray.size() / sizeof(int16_t); - int16_t* inputSamples = reinterpret_cast(inputByteArray.data()); + static QByteArray reverbAlone; // Intermediary for local reverb with no echo + static QByteArray loopBackByteArray; - static QByteArray reverbAlone; - reverbAlone.resize(inputByteArray.size()); + int numInputSamples = inputByteArray.size() / sizeof(int16_t); + int numLoopbackSamples = numDestinationSamplesRequired(_inputFormat, _outputFormat, numInputSamples); + + reverbAlone.resize(numInputSamples * sizeof(int16_t)); + loopBackByteArray.resize(numLoopbackSamples * sizeof(int16_t)); + + int16_t* inputSamples = reinterpret_cast(inputByteArray.data()); int16_t* reverbAloneSamples = reinterpret_cast(reverbAlone.data()); + int16_t* loopbackSamples = reinterpret_cast(loopBackByteArray.data()); if (hasReverb) { updateGverbOptions(); addReverb(_gverb, inputSamples, reverbAloneSamples, numInputSamples, - _outputFormat, !_shouldEchoLocally); + _inputFormat, !_shouldEchoLocally); } - if (_loopbackOutputDevice) { - static QByteArray loopBackByteArray; - int numLoopbackSamples = numDestinationSamplesRequired(_inputFormat, _outputFormat, numInputSamples); - loopBackByteArray.resize(numLoopbackSamples * sizeof(int16_t)); - - possibleResampling(_loopbackResampler, - (_shouldEchoLocally) ? inputSamples : reverbAloneSamples, - reinterpret_cast(loopBackByteArray.data()), - numInputSamples, numLoopbackSamples, - _inputFormat, _outputFormat); - - _loopbackOutputDevice->write(loopBackByteArray); - } + possibleResampling(_loopbackResampler, + (_shouldEchoLocally) ? inputSamples : reverbAloneSamples, loopbackSamples, + numInputSamples, numLoopbackSamples, + _inputFormat, _outputFormat); + + _loopbackOutputDevice->write(loopBackByteArray); } void AudioClient::handleAudioInput() { From a1bf06f004406a3800c76e1d1e65d848993cbd5d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 16 Feb 2015 09:10:18 -0800 Subject: [PATCH 45/63] can't use find module for external proj --- cmake/macros/HifiLibrarySearchHints.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/macros/HifiLibrarySearchHints.cmake b/cmake/macros/HifiLibrarySearchHints.cmake index e4b67af15e..2eed364a68 100644 --- a/cmake/macros/HifiLibrarySearchHints.cmake +++ b/cmake/macros/HifiLibrarySearchHints.cmake @@ -11,8 +11,6 @@ macro(HIFI_LIBRARY_SEARCH_HINTS LIBRARY_FOLDER) string(TOUPPER ${LIBRARY_FOLDER} LIBRARY_PREFIX) - set(${LIBRARY_PREFIX}_SEARCH_DIRS "${EXTERNAL_PROJECT_DIR}/${LIBRARY_FOLDER}/build/${LIBRARY_FOLDER}") - if (${LIBRARY_PREFIX}_ROOT_DIR) list(APPEND ${LIBRARY_PREFIX}_SEARCH_DIRS "${${LIBRARY_PREFIX}_ROOT_DIR}") endif () From feaad377514864c1b5347b532566923a66d32173 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 16 Feb 2015 09:38:53 -0800 Subject: [PATCH 46/63] add a GET_PROJ_NAME var to skip external projects --- .../macros/AddDependencyExternalProject.cmake | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cmake/macros/AddDependencyExternalProject.cmake b/cmake/macros/AddDependencyExternalProject.cmake index 71c32e5e69..9e958b030b 100644 --- a/cmake/macros/AddDependencyExternalProject.cmake +++ b/cmake/macros/AddDependencyExternalProject.cmake @@ -10,16 +10,23 @@ # macro(ADD_DEPENDENCY_EXTERNAL_PROJECT _PROJ_NAME) - if (NOT TARGET ${_PROJ_NAME}) + + string(TOUPPER ${_PROJ_NAME} _PROJ_NAME_UPPER) + + if (NOT DEFINED GET_${_PROJ_NAME_UPPER} OR GET_${_PROJ_NAME_UPPER}) + if (NOT TARGET ${_PROJ_NAME}) - if (ANDROID) - set(_PROJ_BINARY_DIR ${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME}/build/android) - else () - set(_PROJ_BINARY_DIR ${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME}/build) + if (ANDROID) + set(_PROJ_BINARY_DIR ${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME}/build/android) + else () + set(_PROJ_BINARY_DIR ${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME}/build) + endif () + + add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${_PROJ_BINARY_DIR}) endif () + + add_dependencies(${TARGET_NAME} ${_PROJ_NAME}) - add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${_PROJ_BINARY_DIR}) endif () - add_dependencies(${TARGET_NAME} ${_PROJ_NAME}) endmacro() \ No newline at end of file From 57797329d13e5e670cfd3954965f3d181e3927f4 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 16 Feb 2015 12:14:03 -0800 Subject: [PATCH 47/63] do sample size arithmetic before scaling by sizeof --- interface/src/audio/AudioScope.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/audio/AudioScope.cpp b/interface/src/audio/AudioScope.cpp index 45820e2393..8cc27341d6 100644 --- a/interface/src/audio/AudioScope.cpp +++ b/interface/src/audio/AudioScope.cpp @@ -230,7 +230,7 @@ int AudioScope::addSilenceToScope(QByteArray* byteArray, int frameOffset, int si int samplesToBufferEnd = _samplesPerScope - frameOffset; if (silentSamples > samplesToBufferEnd) { memset(destination + frameOffset, 0, samplesToBufferEnd * sizeof(int16_t)); - memset(destination, 0, silentSamples - samplesToBufferEnd * sizeof(int16_t)); + memset(destination, 0, (silentSamples - samplesToBufferEnd) * sizeof(int16_t)); } else { memset(destination + frameOffset, 0, silentSamples * sizeof(int16_t)); } From b69ab6c80df6d6befb183a756f6af4e54faedcbd Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 16 Feb 2015 12:56:12 -0800 Subject: [PATCH 48/63] verify NodeList has a linkedData before using it --- libraries/networking/src/LimitedNodeList.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 13bb2b1ad8..4fbb1d14fe 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -309,13 +309,16 @@ int LimitedNodeList::updateNodeWithDataFromPacket(const SharedNodePointer& match matchingNode->setLastHeardMicrostamp(usecTimestampNow()); - if (!matchingNode->getLinkedData() && linkedDataCreateCallback) { + NodeData* linkedData = matchingNode->getLinkedData(); + if (!linkedData && linkedDataCreateCallback) { linkedDataCreateCallback(matchingNode.data()); } - - QMutexLocker linkedDataLocker(&matchingNode->getLinkedData()->getMutex()); - - return matchingNode->getLinkedData()->parseData(packet); + + if (linkedData) { + QMutexLocker linkedDataLocker(&linkedData->getMutex()); + return linkedData->parseData(packet); + } + return 0; } int LimitedNodeList::findNodeAndUpdateWithDataFromPacket(const QByteArray& packet) { From 0de598586cb2d0962d3a4c66973417941ae8fc83 Mon Sep 17 00:00:00 2001 From: Kai Ludwig Date: Tue, 17 Feb 2015 18:37:23 +0100 Subject: [PATCH 49/63] removed id "g3322" in start-script.svg because it is no longer used and causes a "link rect899 hasn't been detected!" message on script editor open. --- interface/resources/icons/start-script.svg | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/interface/resources/icons/start-script.svg b/interface/resources/icons/start-script.svg index 86354a555d..1401853fe4 100644 --- a/interface/resources/icons/start-script.svg +++ b/interface/resources/icons/start-script.svg @@ -536,22 +536,5 @@ height="44.57473" x="84.498352" y="1050.0748" /> - - - - From fa1bcc43e6d42cfa584b2cdeb85b402518d55beb Mon Sep 17 00:00:00 2001 From: Kai Ludwig Date: Tue, 17 Feb 2015 18:40:20 +0100 Subject: [PATCH 50/63] removed "Script.scriptEnding.connect(scriptEnding);" from lookWithMouse.js, because the function scriptEnding it is no longer available in that script. --- examples/lookWithMouse.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/lookWithMouse.js b/examples/lookWithMouse.js index 70a98c0733..41d7a29bd9 100644 --- a/examples/lookWithMouse.js +++ b/examples/lookWithMouse.js @@ -84,6 +84,4 @@ MyAvatar.bodyYaw = 0; MyAvatar.bodyPitch = 0; MyAvatar.bodyRoll = 0; -// would be nice to change to update -Script.update.connect(update); Script.scriptEnding.connect(scriptEnding); From d299f015d1f7e2e549cb14b869e34b5a4fe6a146 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 17 Feb 2015 09:46:39 -0800 Subject: [PATCH 51/63] use binary dir for externals as well --- cmake/macros/AddDependencyExternalProject.cmake | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/cmake/macros/AddDependencyExternalProject.cmake b/cmake/macros/AddDependencyExternalProject.cmake index 9e958b030b..ff0ced411e 100644 --- a/cmake/macros/AddDependencyExternalProject.cmake +++ b/cmake/macros/AddDependencyExternalProject.cmake @@ -14,15 +14,8 @@ macro(ADD_DEPENDENCY_EXTERNAL_PROJECT _PROJ_NAME) string(TOUPPER ${_PROJ_NAME} _PROJ_NAME_UPPER) if (NOT DEFINED GET_${_PROJ_NAME_UPPER} OR GET_${_PROJ_NAME_UPPER}) - if (NOT TARGET ${_PROJ_NAME}) - - if (ANDROID) - set(_PROJ_BINARY_DIR ${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME}/build/android) - else () - set(_PROJ_BINARY_DIR ${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME}/build) - endif () - - add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${_PROJ_BINARY_DIR}) + if (NOT TARGET ${_PROJ_NAME}) + add_subdirectory(${EXTERNAL_PROJECT_DIR}/${_PROJ_NAME} ${CMAKE_BINARY_DIR}/externals/${_PROJ_NAME}) endif () add_dependencies(${TARGET_NAME} ${_PROJ_NAME}) From 4048627de7c36ffa76e2a89a55a9e1a1d35b77cc Mon Sep 17 00:00:00 2001 From: Kai Ludwig Date: Tue, 17 Feb 2015 18:50:20 +0100 Subject: [PATCH 52/63] 2n try: removed "Script.scriptEnding.connect(scriptEnding);" from lookWithMouse.js, because the function scriptEnding it is no longer available in that script. --- examples/lookWithMouse.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/lookWithMouse.js b/examples/lookWithMouse.js index 41d7a29bd9..470a56bd63 100644 --- a/examples/lookWithMouse.js +++ b/examples/lookWithMouse.js @@ -84,4 +84,5 @@ MyAvatar.bodyYaw = 0; MyAvatar.bodyPitch = 0; MyAvatar.bodyRoll = 0; -Script.scriptEnding.connect(scriptEnding); +// would be nice to change to update +Script.update.connect(update); From a7d6d6d5618e6cf824a7815194517aed9f01740c Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Feb 2015 10:04:21 -0800 Subject: [PATCH 53/63] return non-trivial value --- libraries/networking/src/LimitedNodeList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 4fbb1d14fe..4811c9c1ff 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -325,7 +325,7 @@ int LimitedNodeList::findNodeAndUpdateWithDataFromPacket(const QByteArray& packe SharedNodePointer matchingNode = sendingNodeForPacket(packet); if (matchingNode) { - updateNodeWithDataFromPacket(matchingNode, packet); + return updateNodeWithDataFromPacket(matchingNode, packet); } // we weren't able to match the sender address to the address we have for this node, unlock and don't parse From 488492126e3609ddac80a7b8e029dfc61777df64 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Feb 2015 10:08:20 -0800 Subject: [PATCH 54/63] fix typo in comment --- libraries/networking/src/NodeList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index d35e11a1c3..f70c2d9b3c 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -347,7 +347,7 @@ void NodeList::handleICEConnectionToDomainServer() { qDebug() << "Sending ping packets to establish connectivity with domain-server with ID" << uuidStringWithoutCurlyBraces(_domainHandler.getICEDomainID()); - // send the ping packet to the local and public sockets for this nodfe + // send the ping packet to the local and public sockets for this node QByteArray localPingPacket = constructPingPacket(PingType::Local, false, _domainHandler.getICEClientID()); writeUnverifiedDatagram(localPingPacket, _domainHandler.getICEPeer().getLocalSocket()); From dd64eeb282d832d0e8425becb1ad2d47c70e23ca Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 17 Feb 2015 11:47:29 -0800 Subject: [PATCH 55/63] fix uninitialized geometry cache id in Line3DOverlay --- interface/src/ui/overlays/Line3DOverlay.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/overlays/Line3DOverlay.cpp b/interface/src/ui/overlays/Line3DOverlay.cpp index d2bfa1955b..6672a88e45 100644 --- a/interface/src/ui/overlays/Line3DOverlay.cpp +++ b/interface/src/ui/overlays/Line3DOverlay.cpp @@ -17,7 +17,9 @@ #include "Line3DOverlay.h" -Line3DOverlay::Line3DOverlay() { +Line3DOverlay::Line3DOverlay() : + _geometryCacheID(DependencyManager::get()->allocateID()) +{ } Line3DOverlay::Line3DOverlay(const Line3DOverlay* line3DOverlay) : From 505c50ebe14cf7ec350ff516d27db71e120942d0 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Feb 2015 12:07:32 -0800 Subject: [PATCH 56/63] correct gain variance in linearFade() --- libraries/audio/src/AudioEditBuffer.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/audio/src/AudioEditBuffer.h b/libraries/audio/src/AudioEditBuffer.h index b773fedfb8..66639f20bb 100644 --- a/libraries/audio/src/AudioEditBuffer.h +++ b/libraries/audio/src/AudioEditBuffer.h @@ -23,8 +23,8 @@ public: bool getZeroCrossing(uint32_t start, bool direction, float32_t epsilon, uint32_t& zero); - void linearFade(uint32_t start, uint32_t stop, bool slope); - void exponentialFade(uint32_t start, uint32_t stop, bool slope); + void linearFade(uint32_t start, uint32_t stop, bool increasing); + void exponentialFade(uint32_t start, uint32_t stop, bool increasing); }; template< typename T > @@ -74,7 +74,7 @@ inline bool AudioEditBuffer::getZeroCrossing(uint32_t start, bool direction, } template< typename T > -inline void AudioEditBuffer::linearFade(uint32_t start, uint32_t stop, bool slope) { +inline void AudioEditBuffer::linearFade(uint32_t start, uint32_t stop, bool increasing) { if (start >= stop || start > this->_frameCount || stop > this->_frameCount ) { return; @@ -84,7 +84,7 @@ inline void AudioEditBuffer::linearFade(uint32_t start, uint32_t stop, bool s float32_t delta; float32_t gain; - if (slope) { // 0.0 to 1.0f in delta increments + if (increasing) { // 0.0 to 1.0f in delta increments delta = 1.0f / (float32_t)count; gain = 0.0f; } else { // 1.0f to 0.0f in delta increments @@ -95,13 +95,13 @@ inline void AudioEditBuffer::linearFade(uint32_t start, uint32_t stop, bool s for (uint32_t i = start; i < stop; ++i) { for (uint32_t j = 0; j < this->_channelCount; ++j) { this->_frameBuffer[j][i] *= gain; - gain += delta; } + gain += delta; } } template< typename T > -inline void AudioEditBuffer::exponentialFade(uint32_t start, uint32_t stop, bool slope) { +inline void AudioEditBuffer::exponentialFade(uint32_t start, uint32_t stop, bool increasing) { // TBD } From 96b3114a36a63ff99c6193bb6e41da140ddfdeb1 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Tue, 17 Feb 2015 23:37:37 +0100 Subject: [PATCH 57/63] style --- examples/notifications.js | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/notifications.js b/examples/notifications.js index 88198a2ea1..287bfd0b36 100644 --- a/examples/notifications.js +++ b/examples/notifications.js @@ -474,7 +474,6 @@ function onOnlineUsersChanged(users) { if (last_users.indexOf(users[i]) === -1.0) { createNotification(users[i] + " has joined"); } - } for (i = 0; i < last_users.length; i += 1) { From 9fcb7591e6df784a2cae1e44fea543ba5dc74885 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 17 Feb 2015 14:52:20 -0800 Subject: [PATCH 58/63] don't crash if font load fails --- libraries/render-utils/src/TextRenderer.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/render-utils/src/TextRenderer.cpp b/libraries/render-utils/src/TextRenderer.cpp index fb720b3040..ce694ec835 100644 --- a/libraries/render-utils/src/TextRenderer.cpp +++ b/libraries/render-utils/src/TextRenderer.cpp @@ -511,6 +511,9 @@ TextRenderer::TextRenderer(const char* family, float pointSize, int weight, bool italic, EffectType effect, int effectThickness, const QColor& color) : _effectType(effect), _effectThickness(effectThickness), _pointSize(pointSize), _color(color), _font(loadFont(family)) { + if (!_font) { + qWarning() << "Unable to load font with family " << family; + } if (1 != _effectThickness) { qWarning() << "Effect thickness not current supported"; } @@ -524,7 +527,10 @@ TextRenderer::~TextRenderer() { glm::vec2 TextRenderer::computeExtent(const QString & str) const { float scale = (_pointSize / DEFAULT_POINT_SIZE) * 0.25f; - return _font->computeExtent(str) * scale; + if (_font) { + return _font->computeExtent(str) * scale; + } + return glm::vec2(0.1f,0.1f); } float TextRenderer::draw(float x, float y, const QString & str, @@ -544,7 +550,9 @@ float TextRenderer::draw(float x, float y, const QString & str, // scale at all. mv.translate(glm::vec2(x, y)).scale(glm::vec3(scale, -scale, scale)); // The font does all the OpenGL work - result = _font->drawString(x, y, str, actualColor, _effectType, bounds / scale); + if (_font) { + result = _font->drawString(x, y, str, actualColor, _effectType, bounds / scale); + } }); return result.x; } From ef2d386c75569c56942fe2f452a10a8b7fae7ab2 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 17 Feb 2015 15:12:24 -0800 Subject: [PATCH 59/63] attempt to load Courier if the requested font-family fails to load --- libraries/render-utils/src/TextRenderer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/render-utils/src/TextRenderer.cpp b/libraries/render-utils/src/TextRenderer.cpp index ce694ec835..9238db91e3 100644 --- a/libraries/render-utils/src/TextRenderer.cpp +++ b/libraries/render-utils/src/TextRenderer.cpp @@ -513,6 +513,7 @@ TextRenderer::TextRenderer(const char* family, float pointSize, int weight, _effectType(effect), _effectThickness(effectThickness), _pointSize(pointSize), _color(color), _font(loadFont(family)) { if (!_font) { qWarning() << "Unable to load font with family " << family; + _font = loadFont("Courier"); } if (1 != _effectThickness) { qWarning() << "Effect thickness not current supported"; From 8c7e147b82423790ba0c6699eb5d963f878cf740 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 17 Feb 2015 15:16:03 -0800 Subject: [PATCH 60/63] include debug symbols --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6eb3b935e..bc67d622de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ if (WIN32) elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic") #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing -ggdb") endif(WIN32) if (NOT MSVC12) From f7cc7ad7e7471165ef43c646b04475ae71da2f0b Mon Sep 17 00:00:00 2001 From: Grayson Stebbins Date: Tue, 17 Feb 2015 17:14:47 -0800 Subject: [PATCH 61/63] Added note about running inside visual studio --- BUILD_WIN.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BUILD_WIN.md b/BUILD_WIN.md index 6f26e8c809..f5bc3e09b5 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -163,6 +163,8 @@ We recommend you install it to %HIFI_LIB_DIR%\soxr. This will help our FindSoxr Extract the soxr archive wherever you like. Then, inside the extracted folder, create a directory called `build`. From that build directory, the following commands will build and then install soxr to `%HIFI_LIB_DIR%`. +(Make sure to run the following inside Visual Studio) + ``` cmake .. -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%HIFI_LIB_DIR%/soxr nmake From d10f37291b3703a7ece68d3d88e099ab47f4fee9 Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Wed, 18 Feb 2015 18:25:16 +0100 Subject: [PATCH 62/63] check if sounds are downloaded before play thanks @Atlante45 --- examples/libraries/soundArray.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/libraries/soundArray.js b/examples/libraries/soundArray.js index 0da2db07d3..813621fb4b 100644 --- a/examples/libraries/soundArray.js +++ b/examples/libraries/soundArray.js @@ -20,7 +20,9 @@ SoundArray = function(audioOptions, autoUpdateAudioPosition) { if (this.autoUpdateAudioPosition) { this.updateAudioPosition(); } - Audio.playSound(this.sounds[index], this.audioOptions); + if (this.sounds[index].downloaded) { + Audio.playSound(this.sounds[index], this.audioOptions); + } } else { print("[ERROR] libraries/soundArray.js:play() : Index " + index + " out of range."); } From 758a5522674c2de2b07f0646aa8964927abea97c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 18 Feb 2015 09:59:33 -0800 Subject: [PATCH 63/63] make sure the Agent has a SoundCache available --- assignment-client/src/Agent.cpp | 1 + assignment-client/src/AssignmentClient.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index 4755d9137a..b66226e1a5 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -47,6 +47,7 @@ Agent::Agent(const QByteArray& packet) : _scriptEngine.getEntityScriptingInterface()->setPacketSender(&_entityEditSender); DependencyManager::set(); + DependencyManager::set(); } void Agent::readPendingDatagrams() { diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index 80f3cbab5e..bf67d4d597 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -136,7 +136,6 @@ AssignmentClient::AssignmentClient(int &argc, char **argv) : // Create Singleton objects on main thread NetworkAccessManager::getInstance(); - auto soundCache = DependencyManager::get(); } void AssignmentClient::sendAssignmentRequest() {